* [PATCH] ASoC: uda1380: simplify allocation
@ 2026-03-27 3:07 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-03-27 3:07 UTC (permalink / raw)
To: linux-sound
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
open list
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-27 3:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 3:07 [PATCH] ASoC: uda1380: simplify allocation Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox