alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit()
@ 2022-08-01 17:01 Takashi Iwai
  2022-08-01 17:01 ` [PATCH 1/8] ASoC: cs43130: Replace scnprintf() " Takashi Iwai
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

Hi,

this is a patch set for rather simple conversions from the plain
sprintf() & co to the new helpers, sysfs_emit() and sysfs_emit_at().
No functional changes are expected.


Takashi

===

Takashi Iwai (8):
  ASoC: cs43130: Replace scnprintf() with sysfs_emit()
  ASoC: tlv320aic26: Replace sprintf() with sysfs_emit()
  ASoC: Intel: sst: Replace sprintf() with sysfs_emit()
  ASoC: Intel: catpt: Replace sprintf() with sysfs_emit()
  ASoC: Intel: skylake: Replace sprintf() with sysfs_emit()
  ASoC: core: Replace sprintf() with sysfs_emit()
  ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at()
  ASoC: omap: Replace sprintf() with sysfs_emit()

 sound/soc/codecs/cs43130.c         | 11 +++++------
 sound/soc/codecs/tlv320aic26.c     |  2 +-
 sound/soc/intel/atom/sst/sst.c     |  8 ++++----
 sound/soc/intel/catpt/sysfs.c      |  6 +++---
 sound/soc/intel/skylake/skl-nhlt.c |  2 +-
 sound/soc/soc-core.c               |  2 +-
 sound/soc/soc-dapm.c               |  9 ++++-----
 sound/soc/ti/omap-mcbsp-st.c       |  6 +++---
 sound/soc/ti/omap-mcbsp.c          |  8 ++++----
 9 files changed, 26 insertions(+), 28 deletions(-)

-- 
2.35.3


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

* [PATCH 1/8] ASoC: cs43130: Replace scnprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 17:01 ` [PATCH 2/8] ASoC: tlv320aic26: Replace sprintf() " Takashi Iwai
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

sysfs_emit() is a new helper to simplify the sysfs string output.
Replace the open-code straightforwardly with this new helper.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/cs43130.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c
index ca4d47cc9c91..06c6ad3ca2b7 100644
--- a/sound/soc/codecs/cs43130.c
+++ b/sound/soc/codecs/cs43130.c
@@ -1666,10 +1666,9 @@ static int cs43130_show_dc(struct device *dev, char *buf, u8 ch)
 	struct cs43130_private *cs43130 = i2c_get_clientdata(client);
 
 	if (!cs43130->hpload_done)
-		return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n");
+		return sysfs_emit(buf, "NO_HPLOAD\n");
 	else
-		return scnprintf(buf, PAGE_SIZE, "%u\n",
-				 cs43130->hpload_dc[ch]);
+		return sysfs_emit(buf, "%u\n", cs43130->hpload_dc[ch]);
 }
 
 static ssize_t hpload_dc_l_show(struct device *dev,
@@ -1705,8 +1704,8 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch)
 
 	if (cs43130->hpload_done && cs43130->ac_meas) {
 		for (i = 0; i < ARRAY_SIZE(cs43130_ac_freq); i++) {
-			tmp = scnprintf(buf + j, PAGE_SIZE - j, "%u\n",
-					cs43130->hpload_ac[i][ch]);
+			tmp = sysfs_emit_at(buf, j, "%u\n",
+					    cs43130->hpload_ac[i][ch]);
 			if (!tmp)
 				break;
 
@@ -1715,7 +1714,7 @@ static int cs43130_show_ac(struct device *dev, char *buf, u8 ch)
 
 		return j;
 	} else {
-		return scnprintf(buf, PAGE_SIZE, "NO_HPLOAD\n");
+		return sysfs_emit(buf, "NO_HPLOAD\n");
 	}
 }
 
-- 
2.35.3


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

* [PATCH 2/8] ASoC: tlv320aic26: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
  2022-08-01 17:01 ` [PATCH 1/8] ASoC: cs43130: Replace scnprintf() " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 17:01 ` [PATCH 3/8] ASoC: Intel: sst: " Takashi Iwai
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces the sprintf()
usage straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/codecs/tlv320aic26.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 8bae4b475068..e5dfb3d752a3 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -271,7 +271,7 @@ static ssize_t keyclick_show(struct device *dev,
 	freq = (125 << ((val >> 8) & 0x7)) >> 1;
 	len = 2 * (1 + ((val >> 4) & 0xf));
 
-	return sprintf(buf, "amp=%x freq=%iHz len=%iclks\n", amp, freq, len);
+	return sysfs_emit(buf, "amp=%x freq=%iHz len=%iclks\n", amp, freq, len);
 }
 
 /* Any write to the keyclick attribute will trigger the keyclick event */
-- 
2.35.3


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

* [PATCH 3/8] ASoC: Intel: sst: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
  2022-08-01 17:01 ` [PATCH 1/8] ASoC: cs43130: Replace scnprintf() " Takashi Iwai
  2022-08-01 17:01 ` [PATCH 2/8] ASoC: tlv320aic26: Replace sprintf() " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 17:01 ` [PATCH 4/8] ASoC: Intel: catpt: " Takashi Iwai
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces those usages
straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/atom/sst/sst.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c
index 160b50f479fb..a0d29510d2bc 100644
--- a/sound/soc/intel/atom/sst/sst.c
+++ b/sound/soc/intel/atom/sst/sst.c
@@ -242,11 +242,11 @@ static ssize_t firmware_version_show(struct device *dev,
 
 	if (ctx->fw_version.type == 0 && ctx->fw_version.major == 0 &&
 	    ctx->fw_version.minor == 0 && ctx->fw_version.build == 0)
-		return sprintf(buf, "FW not yet loaded\n");
+		return sysfs_emit(buf, "FW not yet loaded\n");
 	else
-		return sprintf(buf, "v%02x.%02x.%02x.%02x\n",
-			       ctx->fw_version.type, ctx->fw_version.major,
-			       ctx->fw_version.minor, ctx->fw_version.build);
+		return sysfs_emit(buf, "v%02x.%02x.%02x.%02x\n",
+				  ctx->fw_version.type, ctx->fw_version.major,
+				  ctx->fw_version.minor, ctx->fw_version.build);
 
 }
 
-- 
2.35.3


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

* [PATCH 4/8] ASoC: Intel: catpt: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (2 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 3/8] ASoC: Intel: sst: " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-02 10:17   ` Cezary Rojewski
  2022-08-01 17:01 ` [PATCH 5/8] ASoC: Intel: skylake: " Takashi Iwai
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces those usages
straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/catpt/sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/intel/catpt/sysfs.c b/sound/soc/intel/catpt/sysfs.c
index 1bdbcc04dc71..9b6d2d93a2e7 100644
--- a/sound/soc/intel/catpt/sysfs.c
+++ b/sound/soc/intel/catpt/sysfs.c
@@ -27,8 +27,8 @@ static ssize_t fw_version_show(struct device *dev,
 	if (ret)
 		return CATPT_IPC_ERROR(ret);
 
-	return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
-		       version.minor, version.build);
+	return sysfs_emit(buf, "%d.%d.%d.%d\n", version.type, version.major,
+			  version.minor, version.build);
 }
 static DEVICE_ATTR_RO(fw_version);
 
@@ -37,7 +37,7 @@ static ssize_t fw_info_show(struct device *dev,
 {
 	struct catpt_dev *cdev = dev_get_drvdata(dev);
 
-	return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
+	return sysfs_emit(buf, "%s\n", cdev->ipc.config.fw_info);
 }
 static DEVICE_ATTR_RO(fw_info);
 
-- 
2.35.3


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

* [PATCH 5/8] ASoC: Intel: skylake: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (3 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 4/8] ASoC: Intel: catpt: " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-02 10:17   ` Cezary Rojewski
  2022-08-01 17:01 ` [PATCH 6/8] ASoC: core: " Takashi Iwai
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces those usages
straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/skylake/skl-nhlt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index deb7b820325e..e617b4c335a4 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -61,7 +61,7 @@ static ssize_t platform_id_show(struct device *dev,
 			nhlt->header.oem_revision);
 
 	skl_nhlt_trim_space(platform_id);
-	return sprintf(buf, "%s\n", platform_id);
+	return sysfs_emit(buf, "%s\n", platform_id);
 }
 
 static DEVICE_ATTR_RO(platform_id);
-- 
2.35.3


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

* [PATCH 6/8] ASoC: core: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (4 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 5/8] ASoC: Intel: skylake: " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 17:01 ` [PATCH 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at() Takashi Iwai
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
instead of the raw sprintf() & co.  This patch replaces the sprintf()
usage straightforwardly with a new helper, sysfs_emit().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/soc-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e824ff1a9fc0..e020ab49cfb1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -72,7 +72,7 @@ static ssize_t pmdown_time_show(struct device *dev,
 {
 	struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev);
 
-	return sprintf(buf, "%ld\n", rtd->pmdown_time);
+	return sysfs_emit(buf, "%ld\n", rtd->pmdown_time);
 }
 
 static ssize_t pmdown_time_store(struct device *dev,
-- 
2.35.3


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

* [PATCH 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (5 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 6/8] ASoC: core: " Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 17:01 ` [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit() Takashi Iwai
  2022-08-15 16:23 ` [PATCH 0/8] ASoC: " Mark Brown
  8 siblings, 0 replies; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

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: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/soc-dapm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index b05231414c1d..73b8bd452ca7 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2386,11 +2386,10 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
 EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
 
 static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
-	char *buf)
+					  char *buf, int count)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(cmpnt);
 	struct snd_soc_dapm_widget *w;
-	int count = 0;
 	char *state = "not set";
 
 	/* card won't be set for the dummy component, as a spot fix
@@ -2423,7 +2422,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
 		case snd_soc_dapm_pinctrl:
 		case snd_soc_dapm_clock_supply:
 			if (w->name)
-				count += sprintf(buf + count, "%s: %s\n",
+				count += sysfs_emit_at(buf, count, "%s: %s\n",
 					w->name, w->power ? "On":"Off");
 		break;
 		default:
@@ -2445,7 +2444,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt,
 		state = "Off";
 		break;
 	}
-	count += sprintf(buf + count, "PM State: %s\n", state);
+	count += sysfs_emit_at(buf, count, "PM State: %s\n", state);
 
 	return count;
 }
@@ -2463,7 +2462,7 @@ static ssize_t dapm_widget_show(struct device *dev,
 	for_each_rtd_codec_dais(rtd, i, codec_dai) {
 		struct snd_soc_component *cmpnt = codec_dai->component;
 
-		count += dapm_widget_show_component(cmpnt, buf + count);
+		count = dapm_widget_show_component(cmpnt, buf, count);
 	}
 
 	mutex_unlock(&rtd->card->dapm_mutex);
-- 
2.35.3


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

* [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (6 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at() Takashi Iwai
@ 2022-08-01 17:01 ` Takashi Iwai
  2022-08-01 18:54   ` Péter Ujfalusi
  2022-08-15 16:23 ` [PATCH 0/8] ASoC: " Mark Brown
  8 siblings, 1 reply; 13+ messages in thread
From: Takashi Iwai @ 2022-08-01 17:01 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Ranjani Sridharan,
	Pierre-Louis Bossart, Peter Ujfalusi

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 new helpers, sysfs_emit() and sysfs_emit_at(), with the proper
string offset.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/ti/omap-mcbsp-st.c | 6 +++---
 sound/soc/ti/omap-mcbsp.c    | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
index 7e8179cae92e..8163f453bf36 100644
--- a/sound/soc/ti/omap-mcbsp-st.c
+++ b/sound/soc/ti/omap-mcbsp-st.c
@@ -244,10 +244,10 @@ static ssize_t st_taps_show(struct device *dev,
 
 	spin_lock_irq(&mcbsp->lock);
 	for (i = 0; i < st_data->nr_taps; i++)
-		status += sprintf(&buf[status], (i ? ", %d" : "%d"),
-				  st_data->taps[i]);
+		status += sysfs_emit_at(buf, status, (i ? ", %d" : "%d"),
+					st_data->taps[i]);
 	if (i)
-		status += sprintf(&buf[status], "\n");
+		status += sysfs_emit_at(buf, status, "\n");
 	spin_unlock_irq(&mcbsp->lock);
 
 	return status;
diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
index c4ac1f30b9fe..0b377bb7737f 100644
--- a/sound/soc/ti/omap-mcbsp.c
+++ b/sound/soc/ti/omap-mcbsp.c
@@ -517,7 +517,7 @@ static ssize_t prop##_show(struct device *dev,				\
 {									\
 	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);		\
 									\
-	return sprintf(buf, "%u\n", mcbsp->prop);			\
+	return sysfs_emit(buf, "%u\n", mcbsp->prop);			\
 }									\
 									\
 static ssize_t prop##_store(struct device *dev,				\
@@ -560,11 +560,11 @@ static ssize_t dma_op_mode_show(struct device *dev,
 
 	for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
 		if (dma_op_mode == i)
-			len += sprintf(buf + len, "[%s] ", *s);
+			len += sysfs_emit_at(buf, len, "[%s] ", *s);
 		else
-			len += sprintf(buf + len, "%s ", *s);
+			len += sysfs_emit_at(buf, len, "%s ", *s);
 	}
-	len += sprintf(buf + len, "\n");
+	len += sysfs_emit_at(buf, len, "\n");
 
 	return len;
 }
-- 
2.35.3


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

* Re: [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 ` [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit() Takashi Iwai
@ 2022-08-01 18:54   ` Péter Ujfalusi
  0 siblings, 0 replies; 13+ messages in thread
From: Péter Ujfalusi @ 2022-08-01 18:54 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown
  Cc: alsa-devel, Lucas Tanure, Cezary Rojewski, Pierre-Louis Bossart,
	Ranjani Sridharan, Peter Ujfalusi



On 01/08/2022 20:01, Takashi Iwai 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 new helpers, sysfs_emit() and sysfs_emit_at(), with the proper
> string offset.

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  sound/soc/ti/omap-mcbsp-st.c | 6 +++---
>  sound/soc/ti/omap-mcbsp.c    | 8 ++++----
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/soc/ti/omap-mcbsp-st.c b/sound/soc/ti/omap-mcbsp-st.c
> index 7e8179cae92e..8163f453bf36 100644
> --- a/sound/soc/ti/omap-mcbsp-st.c
> +++ b/sound/soc/ti/omap-mcbsp-st.c
> @@ -244,10 +244,10 @@ static ssize_t st_taps_show(struct device *dev,
>  
>  	spin_lock_irq(&mcbsp->lock);
>  	for (i = 0; i < st_data->nr_taps; i++)
> -		status += sprintf(&buf[status], (i ? ", %d" : "%d"),
> -				  st_data->taps[i]);
> +		status += sysfs_emit_at(buf, status, (i ? ", %d" : "%d"),
> +					st_data->taps[i]);
>  	if (i)
> -		status += sprintf(&buf[status], "\n");
> +		status += sysfs_emit_at(buf, status, "\n");
>  	spin_unlock_irq(&mcbsp->lock);
>  
>  	return status;
> diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c
> index c4ac1f30b9fe..0b377bb7737f 100644
> --- a/sound/soc/ti/omap-mcbsp.c
> +++ b/sound/soc/ti/omap-mcbsp.c
> @@ -517,7 +517,7 @@ static ssize_t prop##_show(struct device *dev,				\
>  {									\
>  	struct omap_mcbsp *mcbsp = dev_get_drvdata(dev);		\
>  									\
> -	return sprintf(buf, "%u\n", mcbsp->prop);			\
> +	return sysfs_emit(buf, "%u\n", mcbsp->prop);			\
>  }									\
>  									\
>  static ssize_t prop##_store(struct device *dev,				\
> @@ -560,11 +560,11 @@ static ssize_t dma_op_mode_show(struct device *dev,
>  
>  	for (s = &dma_op_modes[i]; i < ARRAY_SIZE(dma_op_modes); s++, i++) {
>  		if (dma_op_mode == i)
> -			len += sprintf(buf + len, "[%s] ", *s);
> +			len += sysfs_emit_at(buf, len, "[%s] ", *s);
>  		else
> -			len += sprintf(buf + len, "%s ", *s);
> +			len += sysfs_emit_at(buf, len, "%s ", *s);
>  	}
> -	len += sprintf(buf + len, "\n");
> +	len += sysfs_emit_at(buf, len, "\n");
>  
>  	return len;
>  }

-- 
Péter

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

* Re: [PATCH 4/8] ASoC: Intel: catpt: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 ` [PATCH 4/8] ASoC: Intel: catpt: " Takashi Iwai
@ 2022-08-02 10:17   ` Cezary Rojewski
  0 siblings, 0 replies; 13+ messages in thread
From: Cezary Rojewski @ 2022-08-02 10:17 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown
  Cc: alsa-devel, Peter Ujfalusi, Pierre-Louis Bossart, Lucas Tanure,
	Ranjani Sridharan

On 2022-08-01 7:01 PM, Takashi Iwai wrote:
> For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
> instead of the raw sprintf() & co.  This patch replaces those usages
> straightforwardly with a new helper, sysfs_emit().

Acked-by: Cezary Rojewski <cezary.rojewski@intel.com>

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

* Re: [PATCH 5/8] ASoC: Intel: skylake: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 ` [PATCH 5/8] ASoC: Intel: skylake: " Takashi Iwai
@ 2022-08-02 10:17   ` Cezary Rojewski
  0 siblings, 0 replies; 13+ messages in thread
From: Cezary Rojewski @ 2022-08-02 10:17 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown
  Cc: alsa-devel, Peter Ujfalusi, Pierre-Louis Bossart, Lucas Tanure,
	Ranjani Sridharan

On 2022-08-01 7:01 PM, Takashi Iwai wrote:
> For sysfs outputs, it's safer to use a new helper, sysfs_emit(),
> instead of the raw sprintf() & co.  This patch replaces those usages
> straightforwardly with a new helper, sysfs_emit().

Acked-by: Cezary Rojewski <cezary.rojewski@intel.com>

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

* Re: [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit()
  2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
                   ` (7 preceding siblings ...)
  2022-08-01 17:01 ` [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit() Takashi Iwai
@ 2022-08-15 16:23 ` Mark Brown
  8 siblings, 0 replies; 13+ messages in thread
From: Mark Brown @ 2022-08-15 16:23 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Pierre-Louis Bossart, Cezary Rojewski, Lucas Tanure, alsa-devel,
	Ranjani Sridharan, Peter Ujfalusi

On Mon, 1 Aug 2022 19:01:00 +0200, Takashi Iwai wrote:
> this is a patch set for rather simple conversions from the plain
> sprintf() & co to the new helpers, sysfs_emit() and sysfs_emit_at().
> No functional changes are expected.
> 
> 
> Takashi
> 
> [...]

Applied to

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

Thanks!

[1/8] ASoC: cs43130: Replace scnprintf() with sysfs_emit()
      commit: 32d3679cbb383478c7e9dff590f367f1d7dda975
[2/8] ASoC: tlv320aic26: Replace sprintf() with sysfs_emit()
      commit: 1218d67d376156aa8dc9dbc39616867823f60783
[3/8] ASoC: Intel: sst: Replace sprintf() with sysfs_emit()
      commit: 0aab7bda03086061abd5f8a7794324bb70f769a3
[4/8] ASoC: Intel: catpt: Replace sprintf() with sysfs_emit()
      commit: 7ae8d8ea9427b6fb1ed04b02faf31ad5e3a6de8b
[5/8] ASoC: Intel: skylake: Replace sprintf() with sysfs_emit()
      commit: 11af2b1e33e8c9e72ddf14cd61f9494f34e06c40
[6/8] ASoC: core: Replace sprintf() with sysfs_emit()
      commit: 628d0f72d5828611cae353bd8b49d7647711c283
[7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at()
      commit: 69f7cbfb08c7ee2ca565f532b0073b847db20bdc
[8/8] ASoC: omap: Replace sprintf() with sysfs_emit()
      commit: a111ae4d7f0796cf2ea0e8bf3ab6c06a401e0560

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] 13+ messages in thread

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01 17:01 [PATCH 0/8] ASoC: Replace sprintf() with sysfs_emit() Takashi Iwai
2022-08-01 17:01 ` [PATCH 1/8] ASoC: cs43130: Replace scnprintf() " Takashi Iwai
2022-08-01 17:01 ` [PATCH 2/8] ASoC: tlv320aic26: Replace sprintf() " Takashi Iwai
2022-08-01 17:01 ` [PATCH 3/8] ASoC: Intel: sst: " Takashi Iwai
2022-08-01 17:01 ` [PATCH 4/8] ASoC: Intel: catpt: " Takashi Iwai
2022-08-02 10:17   ` Cezary Rojewski
2022-08-01 17:01 ` [PATCH 5/8] ASoC: Intel: skylake: " Takashi Iwai
2022-08-02 10:17   ` Cezary Rojewski
2022-08-01 17:01 ` [PATCH 6/8] ASoC: core: " Takashi Iwai
2022-08-01 17:01 ` [PATCH 7/8] ASoC: DAPM: Replace sprintf() calls with sysfs_emit_at() Takashi Iwai
2022-08-01 17:01 ` [PATCH 8/8] ASoC: omap: Replace sprintf() with sysfs_emit() Takashi Iwai
2022-08-01 18:54   ` Péter Ujfalusi
2022-08-15 16:23 ` [PATCH 0/8] ASoC: " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).