ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy

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>
This commit is contained in:
Li Zetao 2023-08-10 19:47:37 +08:00 committed by Mark Brown
parent 85cc1ee950
commit b0a4c7f592
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View 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);