Skip to contentSkip to conversation

ASoC: uda1380: remove kmemdup_array

PATCH In review Rosen Penev 2 participants 2 messages May 19 – May 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: uda1380: remove kmemdup_array

Use a flexible array member to combine allocations.

---
 sound/soc/codecs/uda1380.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
sound/soc/codecs/uda1380.c +6 -7
index 55c83d95bfba..4df2d01cd5fb 100644
@@ -38,9 +38,9 @@ struct uda1380_priv {
 	unsigned int dac_clk;
 	struct work_struct work;
 	struct i2c_client *i2c;
-	u16 *reg_cache;
 	struct gpio_desc *power;
 	struct gpio_desc *reset;
+	u16 reg_cache[];
 };
 
 /*
@@ -767,11 +767,15 @@ static int uda1380_i2c_probe(struct i2c_client *i2c)
 	struct uda1380_priv *uda1380;
 	int ret;
 
-	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));
+
 	uda1380->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
 	if (IS_ERR(uda1380->reset))
 		return dev_err_probe(dev, PTR_ERR(uda1380->reset),
@@ -789,11 +793,6 @@ static int uda1380_i2c_probe(struct i2c_client *i2c)
 	if (device_property_match_string(dev, "dac-clk", "wspll") >= 0)
 		uda1380->dac_clk = UDA1380_DAC_CLK_WSPLL;
 
-	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;
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 1 line · Rosen Penev

ASoC: uda1380: remove kmemdup_array

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/1] ASoC: uda1380: remove kmemdup_array

      https://git.kernel.org/broonie/sound/c/04aec3799e14

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark