Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: codecs: tlv320dac33: remove kmemdup_array

Use a flexible array member and struct_size to use one allocation.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260402025040.93569-1-rosenp@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Rosen Penev and committed by
Mark Brown
04cc4762 9557ec3f

+4 -6
+4 -6
sound/soc/codecs/tlv320dac33.c
··· 91 91 int mode1_latency; /* latency caused by the i2c writes in 92 92 * us */ 93 93 u8 burst_bclkdiv; /* BCLK divider value in burst mode */ 94 - u8 *reg_cache; 95 94 unsigned int burst_rate; /* Interface speed in Burst modes */ 96 95 97 96 int keep_bclk; /* Keep the BCLK continuously running ··· 107 108 108 109 enum dac33_state state; 109 110 struct i2c_client *i2c; 111 + 112 + u8 reg_cache[]; 110 113 }; 111 114 112 115 static const u8 dac33_reg[DAC33_CACHEREGNUM] = { ··· 1478 1477 struct tlv320dac33_priv *dac33; 1479 1478 int ret, i; 1480 1479 1481 - dac33 = devm_kzalloc(&client->dev, sizeof(struct tlv320dac33_priv), 1480 + dac33 = devm_kzalloc(&client->dev, struct_size(dac33, reg_cache, ARRAY_SIZE(dac33_reg)), 1482 1481 GFP_KERNEL); 1483 1482 if (dac33 == NULL) 1484 1483 return -ENOMEM; 1485 1484 1486 - dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg), 1487 - sizeof(dac33_reg[0]), GFP_KERNEL); 1488 - if (!dac33->reg_cache) 1489 - return -ENOMEM; 1485 + memcpy(dac33->reg_cache, dac33_reg, ARRAY_SIZE(dac33_reg)); 1490 1486 1491 1487 dac33->i2c = client; 1492 1488 mutex_init(&dac33->mutex);