From: Rosen Penev <rosenp@gmail.com>
To: linux-sound@vger.kernel.org
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE
SUPPORT), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ASoC: tegra: ADX: simplify probe allocation
Date: Fri, 24 Apr 2026 18:42:44 -0700 [thread overview]
Message-ID: <20260425014244.439788-1-rosenp@gmail.com> (raw)
Reduce 3 allocations to one using a flexible array member.
Also use of_device_get_match_data. No error checking since it cannot be
NULL.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/tegra/tegra210_adx.c | 24 ++++++++----------------
sound/soc/tegra/tegra210_adx.h | 2 +-
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/sound/soc/tegra/tegra210_adx.c b/sound/soc/tegra/tegra210_adx.c
index d2f742ffc59d..3f6c068d00c8 100644
--- a/sound/soc/tegra/tegra210_adx.c
+++ b/sound/soc/tegra/tegra210_adx.c
@@ -676,17 +676,20 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct tegra210_adx *adx;
- const struct of_device_id *match;
- struct tegra210_adx_soc_data *soc_data;
+ const struct tegra210_adx_soc_data *soc_data;
void __iomem *regs;
+ size_t alloc_size;
int err;
- adx = devm_kzalloc(dev, sizeof(*adx), GFP_KERNEL);
+ soc_data = of_device_get_match_data(&pdev->dev);
+ alloc_size = struct_size(adx, map, soc_data->ram_depth);
+ alloc_size += sizeof(u32) * soc_data->byte_mask_size;
+
+ adx = devm_kzalloc(dev, alloc_size, GFP_KERNEL);
if (!adx)
return -ENOMEM;
- match = of_match_device(tegra210_adx_of_match, dev);
- soc_data = (struct tegra210_adx_soc_data *)match->data;
+ adx->byte_mask = adx->map + soc_data->ram_depth;
adx->soc_data = soc_data;
dev_set_drvdata(dev, adx);
@@ -703,17 +706,6 @@ static int tegra210_adx_platform_probe(struct platform_device *pdev)
regcache_cache_only(adx->regmap, true);
- adx->map = devm_kzalloc(dev, soc_data->ram_depth * sizeof(*adx->map),
- GFP_KERNEL);
- if (!adx->map)
- return -ENOMEM;
-
- adx->byte_mask = devm_kzalloc(dev,
- soc_data->byte_mask_size * sizeof(*adx->byte_mask),
- GFP_KERNEL);
- if (!adx->byte_mask)
- return -ENOMEM;
-
tegra210_adx_dais[TEGRA_ADX_IN_DAI_ID].playback.channels_max =
adx->soc_data->max_ch;
diff --git a/sound/soc/tegra/tegra210_adx.h b/sound/soc/tegra/tegra210_adx.h
index 176a4e40de0a..4406a4a74496 100644
--- a/sound/soc/tegra/tegra210_adx.h
+++ b/sound/soc/tegra/tegra210_adx.h
@@ -88,9 +88,9 @@ struct tegra210_adx_soc_data {
struct tegra210_adx {
struct regmap *regmap;
- unsigned int *map;
unsigned int *byte_mask;
const struct tegra210_adx_soc_data *soc_data;
+ unsigned int map[];
};
#endif
--
2.54.0
next reply other threads:[~2026-04-25 1:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 1:42 Rosen Penev [this message]
2026-04-25 8:31 ` [PATCH] ASoC: tegra: ADX: simplify probe allocation Jon Hunter
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=20260425014244.439788-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=broonie@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=perex@perex.cz \
--cc=thierry.reding@kernel.org \
--cc=tiwai@suse.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