From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Peter Ujfalusi <peter.ujfalusi@linux.intel.com>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
sound-open-firmware@alsa-project.org (moderated list:SOUND -
SOUND OPEN FIRMWARE (SOF) DRIVERS),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ASoC: SOF: Use flexible allocation for control data
Date: Mon, 18 May 2026 17:47:49 -0700 [thread overview]
Message-ID: <20260519004749.627581-1-rosenp@gmail.com> (raw)
Allocate IPC3 and IPC4 channel control data with kzalloc_flex()
for the trailing channel-value arrays instead of open-coding the
struct_size() allocation.
The existing scontrol size field continues to record the payload size
used by the control paths.
Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/sof/ipc3-topology.c | 6 ++++--
sound/soc/sof/ipc4-topology.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c
index 8c37c0657315..9597f619fbe4 100644
--- a/sound/soc/sof/ipc3-topology.c
+++ b/sound/soc/sof/ipc3-topology.c
@@ -1826,7 +1826,8 @@ static int sof_ipc3_control_load_volume(struct snd_sof_dev *sdev, struct snd_sof
/* init the volume get/put data */
scontrol->size = struct_size(cdata, chanv, scontrol->num_channels);
- scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
+ scontrol->ipc_control_data = kzalloc_flex(*cdata, chanv,
+ scontrol->num_channels);
if (!scontrol->ipc_control_data)
return -ENOMEM;
@@ -1857,7 +1858,8 @@ static int sof_ipc3_control_load_enum(struct snd_sof_dev *sdev, struct snd_sof_c
/* init the enum get/put data */
scontrol->size = struct_size(cdata, chanv, scontrol->num_channels);
- scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
+ scontrol->ipc_control_data = kzalloc_flex(*cdata, chanv,
+ scontrol->num_channels);
if (!scontrol->ipc_control_data)
return -ENOMEM;
diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c
index 76812d8fb567..9fd04a7857f6 100644
--- a/sound/soc/sof/ipc4-topology.c
+++ b/sound/soc/sof/ipc4-topology.c
@@ -2863,7 +2863,8 @@ static int sof_ipc4_control_load_volume(struct snd_sof_dev *sdev, struct snd_sof
scontrol->size = struct_size(control_data, chanv, scontrol->num_channels);
/* scontrol->ipc_control_data will be freed in sof_control_unload */
- scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
+ scontrol->ipc_control_data = kzalloc_flex(*control_data, chanv,
+ scontrol->num_channels);
if (!scontrol->ipc_control_data)
return -ENOMEM;
@@ -2905,7 +2906,8 @@ static int sof_ipc4_control_load_enum(struct snd_sof_dev *sdev, struct snd_sof_c
scontrol->size = struct_size(control_data, chanv, scontrol->num_channels);
/* scontrol->ipc_control_data will be freed in sof_control_unload */
- scontrol->ipc_control_data = kzalloc(scontrol->size, GFP_KERNEL);
+ scontrol->ipc_control_data = kzalloc_flex(*control_data, chanv,
+ scontrol->num_channels);
if (!scontrol->ipc_control_data)
return -ENOMEM;
--
2.54.0
next reply other threads:[~2026-05-19 0:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 0:47 Rosen Penev [this message]
2026-05-19 12:04 ` Péter Ujfalusi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519004749.627581-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®