All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy
@ 2023-08-10 11:47 Li Zetao
  2023-08-10 11:47 ` [PATCH -next 1/2] ASoC: tas5805m: " Li Zetao
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Li Zetao @ 2023-08-10 11:47 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, pierre-louis.bossart,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, daniel.baluta,
	kai.vehmanen, daniel.beer, Jonathan.Cameron, luca.ceresoli,
	luzmaximilian, u.kleine-koenig
  Cc: lizetao1, alsa-devel, sound-open-firmware

This patch set use the helper function devm_kmemdup() to replace
devm_kmalloc + memcpy, which is the same as implementing the function
separately.

Li Zetao (2):
  ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
  ASoC: SOF: ipc3: Use devm_kmemdup to replace devm_kmalloc + memcpy

 sound/soc/codecs/tas5805m.c | 3 +--
 sound/soc/sof/ipc3.c        | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH -next 1/2] ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
  2023-08-10 11:47 [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
@ 2023-08-10 11:47 ` Li Zetao
  2023-08-10 18:55   ` Daniel Beer
  2023-08-10 11:47 ` [PATCH -next 2/2] ASoC: SOF: ipc3: " Li Zetao
  2023-08-15 19:17 ` [PATCH -next 0/2] " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Li Zetao @ 2023-08-10 11:47 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, pierre-louis.bossart,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, daniel.baluta,
	kai.vehmanen, daniel.beer, Jonathan.Cameron, luca.ceresoli,
	luzmaximilian, u.kleine-koenig
  Cc: lizetao1, alsa-devel, sound-open-firmware

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>
---
 sound/soc/codecs/tas5805m.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c
index aca3756ffab6..3b53eba38a0b 100644
--- a/sound/soc/codecs/tas5805m.c
+++ b/sound/soc/codecs/tas5805m.c
@@ -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);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next 2/2] ASoC: SOF: ipc3: Use devm_kmemdup to replace devm_kmalloc + memcpy
  2023-08-10 11:47 [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
  2023-08-10 11:47 ` [PATCH -next 1/2] ASoC: tas5805m: " Li Zetao
@ 2023-08-10 11:47 ` Li Zetao
  2023-08-11 15:32   ` Luca Ceresoli
  2023-08-15 19:17 ` [PATCH -next 0/2] " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Li Zetao @ 2023-08-10 11:47 UTC (permalink / raw)
  To: lgirdwood, broonie, perex, tiwai, pierre-louis.bossart,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, daniel.baluta,
	kai.vehmanen, daniel.beer, Jonathan.Cameron, luca.ceresoli,
	luzmaximilian, u.kleine-koenig
  Cc: lizetao1, alsa-devel, sound-open-firmware

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>
---
 sound/soc/sof/ipc3.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sound/soc/sof/ipc3.c b/sound/soc/sof/ipc3.c
index 33df028d4854..fb40378ad084 100644
--- a/sound/soc/sof/ipc3.c
+++ b/sound/soc/sof/ipc3.c
@@ -567,13 +567,10 @@ int sof_ipc3_get_cc_info(struct snd_sof_dev *sdev,
 	/* create read-only cc_version debugfs to store compiler version info */
 	/* use local copy of the cc_version to prevent data corruption */
 	if (sdev->first_boot) {
-		sdev->cc_version = devm_kmalloc(sdev->dev, cc->ext_hdr.hdr.size,
-						GFP_KERNEL);
-
+		sdev->cc_version = devm_kmemdup(sdev->dev, cc, cc->ext_hdr.hdr.size, GFP_KERNEL);
 		if (!sdev->cc_version)
 			return -ENOMEM;
 
-		memcpy(sdev->cc_version, cc, cc->ext_hdr.hdr.size);
 		ret = snd_sof_debugfs_buf_item(sdev, sdev->cc_version,
 					       cc->ext_hdr.hdr.size,
 					       "cc_version", 0444);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next 1/2] ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
  2023-08-10 11:47 ` [PATCH -next 1/2] ASoC: tas5805m: " Li Zetao
@ 2023-08-10 18:55   ` Daniel Beer
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Beer @ 2023-08-10 18:55 UTC (permalink / raw)
  To: Li Zetao
  Cc: lgirdwood, broonie, perex, tiwai, pierre-louis.bossart,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, daniel.baluta,
	kai.vehmanen, Jonathan.Cameron, luca.ceresoli, luzmaximilian,
	u.kleine-koenig, alsa-devel, sound-open-firmware

On Thu, Aug 10, 2023 at 07:47:37PM +0800, Li Zetao wrote:
> -	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);

You could probably now move the release_firmware call to be immediately
after the devm_kmemdup attempt, and avoid having to call it from two
different places.

Cheers,
Daniel

-- 
Daniel Beer
Firmware Engineer at Igor Institute
daniel.beer@igorinstitute.com or +64-27-420-8101
Offices in Seattle, San Francisco, and Vancouver BC or (206) 494-3312

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next 2/2] ASoC: SOF: ipc3: Use devm_kmemdup to replace devm_kmalloc + memcpy
  2023-08-10 11:47 ` [PATCH -next 2/2] ASoC: SOF: ipc3: " Li Zetao
@ 2023-08-11 15:32   ` Luca Ceresoli
  0 siblings, 0 replies; 6+ messages in thread
From: Luca Ceresoli @ 2023-08-11 15:32 UTC (permalink / raw)
  To: Li Zetao
  Cc: lgirdwood, broonie, perex, tiwai, pierre-louis.bossart,
	peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, daniel.baluta,
	kai.vehmanen, daniel.beer, Jonathan.Cameron, luzmaximilian,
	u.kleine-koenig, alsa-devel, sound-open-firmware

On Thu, 10 Aug 2023 19:47:38 +0800
Li Zetao <lizetao1@huawei.com> wrote:

> 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>

Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy
  2023-08-10 11:47 [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
  2023-08-10 11:47 ` [PATCH -next 1/2] ASoC: tas5805m: " Li Zetao
  2023-08-10 11:47 ` [PATCH -next 2/2] ASoC: SOF: ipc3: " Li Zetao
@ 2023-08-15 19:17 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2023-08-15 19:17 UTC (permalink / raw)
  To: lgirdwood, perex, tiwai, pierre-louis.bossart, peter.ujfalusi,
	yung-chuan.liao, ranjani.sridharan, daniel.baluta, kai.vehmanen,
	daniel.beer, Jonathan.Cameron, luca.ceresoli, luzmaximilian,
	u.kleine-koenig, Li Zetao
  Cc: alsa-devel, sound-open-firmware

On Thu, 10 Aug 2023 19:47:36 +0800, Li Zetao wrote:
> This patch set use the helper function devm_kmemdup() to replace
> devm_kmalloc + memcpy, which is the same as implementing the function
> separately.
> 
> Li Zetao (2):
>   ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
>   ASoC: SOF: ipc3: Use devm_kmemdup to replace devm_kmalloc + memcpy
> 
> [...]

Applied to

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

Thanks!

[1/2] ASoC: tas5805m: Use devm_kmemdup to replace devm_kmalloc + memcpy
      commit: b0a4c7f5921d9c2998bdd767a93d995786d72adc
[2/2] ASoC: SOF: ipc3: Use devm_kmemdup to replace devm_kmalloc + memcpy
      commit: 29681184da28babc990a66e197d27ab98f2027af

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-15 19:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-10 11:47 [PATCH -next 0/2] Use devm_kmemdup to replace devm_kmalloc + memcpy Li Zetao
2023-08-10 11:47 ` [PATCH -next 1/2] ASoC: tas5805m: " Li Zetao
2023-08-10 18:55   ` Daniel Beer
2023-08-10 11:47 ` [PATCH -next 2/2] ASoC: SOF: ipc3: " Li Zetao
2023-08-11 15:32   ` Luca Ceresoli
2023-08-15 19:17 ` [PATCH -next 0/2] " Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.