[PATCH v3 17/20] ASoC: tlv320dac33: use devm_kmemdup_array()

Raag Jadav posted 20 patches 1 year ago
There is a newer version of this series
[PATCH v3 17/20] ASoC: tlv320dac33: use devm_kmemdup_array()
Posted by Raag Jadav 1 year ago
Convert to use devm_kmemdup_array() which is more robust.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 sound/soc/codecs/tlv320dac33.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c
index fa46f51d4341..3919f8b14995 100644
--- a/sound/soc/codecs/tlv320dac33.c
+++ b/sound/soc/codecs/tlv320dac33.c
@@ -1477,10 +1477,8 @@ static int dac33_i2c_probe(struct i2c_client *client)
 	if (dac33 == NULL)
 		return -ENOMEM;
 
-	dac33->reg_cache = devm_kmemdup(&client->dev,
-					dac33_reg,
-					ARRAY_SIZE(dac33_reg) * sizeof(u8),
-					GFP_KERNEL);
+	dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg),
+					      sizeof(u8), GFP_KERNEL);
 	if (!dac33->reg_cache)
 		return -ENOMEM;
 
-- 
2.34.1
Re: [PATCH v3 17/20] ASoC: tlv320dac33: use devm_kmemdup_array()
Posted by Andy Shevchenko 1 year ago
On Mon, Feb 03, 2025 at 01:38:59PM +0530, Raag Jadav wrote:
> Convert to use devm_kmemdup_array() which is more robust.

...

> -	dac33->reg_cache = devm_kmemdup(&client->dev,
> -					dac33_reg,
> -					ARRAY_SIZE(dac33_reg) * sizeof(u8),
> -					GFP_KERNEL);
> +	dac33->reg_cache = devm_kmemdup_array(&client->dev, dac33_reg, ARRAY_SIZE(dac33_reg),
> +					      sizeof(u8), GFP_KERNEL);

sizeof(*dac33->reg_cache) ?

>  	if (!dac33->reg_cache)
>  		return -ENOMEM;

-- 
With Best Regards,
Andy Shevchenko