ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
authorLi Zetao <lizetao1@huawei.com>
Thu, 10 Aug 2023 11:47:37 +0000 (19:47 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 14 Aug 2023 18:44:38 +0000 (19:44 +0100)
Use the helper function devm_kmemdup() rather than duplicating its
implementation, which helps to enhance code readability.

Signed-off-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/20230810114738.2103792-2-lizetao1@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/tas5805m.c

index aca3756..3b53eba 100644 (file)
@@ -520,12 +520,11 @@ static int tas5805m_i2c_probe(struct i2c_client *i2c)
        }
 
        tas5805m->dsp_cfg_len = fw->size;
-       tas5805m->dsp_cfg_data = devm_kmalloc(dev, fw->size, GFP_KERNEL);
+       tas5805m->dsp_cfg_data = devm_kmemdup(dev, fw->data, fw->size, GFP_KERNEL);
        if (!tas5805m->dsp_cfg_data) {
                release_firmware(fw);
                return -ENOMEM;
        }
-       memcpy(tas5805m->dsp_cfg_data, fw->data, fw->size);
 
        release_firmware(fw);