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>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ASoC: uda1380: simplify allocation
Date: Thu, 26 Mar 2026 20:07:52 -0700 [thread overview]
Message-ID: <20260327030752.9048-1-rosenp@gmail.com> (raw)
Use a flexible array member to combine allocations.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
sound/soc/codecs/uda1380.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 63c3ea878fcf..7ee9172c81c4 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -35,7 +35,7 @@ struct uda1380_priv {
unsigned int dac_clk;
struct work_struct work;
struct i2c_client *i2c;
- u16 *reg_cache;
+ u16 reg_cache[];
};
/*
@@ -767,11 +767,14 @@ static int uda1380_i2c_probe(struct i2c_client *i2c)
if (!pdata)
return -EINVAL;
- uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv),
+ uda1380 = devm_kzalloc(&i2c->dev, struct_size(uda1380, reg_cache, ARRAY_SIZE(uda1380_reg)),
GFP_KERNEL);
if (uda1380 == NULL)
return -ENOMEM;
+ memcpy(uda1380->reg_cache, uda1380_reg,
+ ARRAY_SIZE(uda1380_reg) * sizeof(*uda1380->reg_cache));
+
if (gpio_is_valid(pdata->gpio_reset)) {
ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_reset,
GPIOF_OUT_INIT_LOW, "uda1380 reset");
@@ -786,11 +789,6 @@ static int uda1380_i2c_probe(struct i2c_client *i2c)
return ret;
}
- uda1380->reg_cache = devm_kmemdup_array(&i2c->dev, uda1380_reg, ARRAY_SIZE(uda1380_reg),
- sizeof(uda1380_reg[0]), GFP_KERNEL);
- if (!uda1380->reg_cache)
- return -ENOMEM;
-
i2c_set_clientdata(i2c, uda1380);
uda1380->i2c = i2c;
--
2.53.0
reply other threads:[~2026-03-27 3:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260327030752.9048-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--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