mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: intel: Replace scnprintf() calls with sysfs_emit_at()
@ 2022-08-16  8:55 zhaoxiao
  2022-08-16  9:57 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: zhaoxiao @ 2022-08-16  8:55 UTC (permalink / raw)
  To: perex, tiwai
  Cc: pierre-louis.bossart, lgirdwood, peter.ujfalusi, yung-chuan.liao,
	ranjani.sridharan, kai.vehmanen, daniel.baluta, broonie,
	guennadi.liakhovetski, sound-open-firmware, alsa-devel,
	linux-kernel, zhaoxiao

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces the open-code
with a new helper, sysfs_emit_at(), by passing the string offset.

Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
---
 sound/soc/sof/intel/hda.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 6d4ecbe14adf..917d639671a7 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -574,7 +574,7 @@ static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, const char *le
 	chip = get_chip_info(sdev->pdata);
 	for (i = 0; i < HDA_EXT_ROM_STATUS_SIZE; i++) {
 		value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + i * 0x4);
-		len += scnprintf(msg + len, sizeof(msg) - len, " 0x%x", value);
+		len += sysfs_emit_at(msg, len, " 0x%x", value);
 	}
 
 	dev_printk(level, sdev->dev, "extended rom status: %s", msg);
-- 
2.20.1


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

* Re: [PATCH] ASoC: intel: Replace scnprintf() calls with sysfs_emit_at()
  2022-08-16  8:55 [PATCH] ASoC: intel: Replace scnprintf() calls with sysfs_emit_at() zhaoxiao
@ 2022-08-16  9:57 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2022-08-16  9:57 UTC (permalink / raw)
  To: zhaoxiao
  Cc: perex, tiwai, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
	yung-chuan.liao, ranjani.sridharan, kai.vehmanen, daniel.baluta,
	broonie, guennadi.liakhovetski, sound-open-firmware, alsa-devel,
	linux-kernel

On Tue, 16 Aug 2022 10:55:02 +0200,
zhaoxiao wrote:
> 
> For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
> instead of the raw sprintf() & co.  This patch replaces the open-code
> with a new helper, sysfs_emit_at(), by passing the string offset.

Well, the function you've changed isn't used for sysfs at all...


Takashi

> 
> Signed-off-by: zhaoxiao <zhaoxiao@uniontech.com>
> ---
>  sound/soc/sof/intel/hda.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
> index 6d4ecbe14adf..917d639671a7 100644
> --- a/sound/soc/sof/intel/hda.c
> +++ b/sound/soc/sof/intel/hda.c
> @@ -574,7 +574,7 @@ static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, const char *le
>  	chip = get_chip_info(sdev->pdata);
>  	for (i = 0; i < HDA_EXT_ROM_STATUS_SIZE; i++) {
>  		value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, chip->rom_status_reg + i * 0x4);
> -		len += scnprintf(msg + len, sizeof(msg) - len, " 0x%x", value);
> +		len += sysfs_emit_at(msg, len, " 0x%x", value);
>  	}
>  
>  	dev_printk(level, sdev->dev, "extended rom status: %s", msg);
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2022-08-16 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16  8:55 [PATCH] ASoC: intel: Replace scnprintf() calls with sysfs_emit_at() zhaoxiao
2022-08-16  9:57 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®