* [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op
@ 2025-09-30 15:33 Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 1/9] iio: adc: ad4030: replace sprintf() with sysfs_emit() Nuno Sá via B4 Relay
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada, Nuno Sá
When looking at some drivers implementing the .read_label() callback it
came to my attention that there were some outliers using sprintf() (or
even snprintf() with PAGE_SIZE) instead of sysfs_emit(). This series
cleans that up.
---
Nuno Sá (9):
iio: adc: ad4030: replace sprintf() with sysfs_emit()
iio: adc: ad7768-1: replace sprintf() with sysfs_emit()
iio: adc: mcp3564: replace sprintf() with sysfs_emit()
iio: adc: meson_saradc: replace sprintf() with sysfs_emit()
iio: adc: mt6360-adc: replace snprintf() with sysfs_emit()
iio: adc: pac1921: replace sprintf() with sysfs_emit()
iio: adc: qcom-spmi-rradc: replace snprintf() with sysfs_emit()
iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit()
iio: resolver: ad2s1210: replace sprintf() with sysfs_emit()
drivers/iio/adc/ad4030.c | 4 +--
drivers/iio/adc/ad7768-1.c | 2 +-
drivers/iio/adc/mcp3564.c | 2 +-
drivers/iio/adc/meson_saradc.c | 6 ++---
drivers/iio/adc/mt6360-adc.c | 2 +-
drivers/iio/adc/pac1921.c | 8 +++---
drivers/iio/adc/qcom-spmi-rradc.c | 2 +-
.../iio/position/hid-sensor-custom-intel-hinge.c | 2 +-
drivers/iio/resolver/ad2s1210.c | 30 +++++++++++-----------
9 files changed, 29 insertions(+), 29 deletions(-)
---
base-commit: b9700f87939f0f477e5c00db817f54ab8a97702b
change-id: 20250930-dev-sprintf-cleanup-baf2c89b3460
--
Thanks!
- Nuno Sá
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/9] iio: adc: ad4030: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 2/9] iio: adc: ad7768-1: " Nuno Sá via B4 Relay
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada, Nuno Sá
From: Nuno Sá <nuno.sa@analog.com>
Update the ad4030_read_label() function to use sysfs_emit() for generating
labels.
Signed-off-by: Nuno Sá <nuno.sal@analog.com>
---
drivers/iio/adc/ad4030.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
index 1bc2f9a2247081e166680232aa6d4aebc5f41b89..4393160c7c77981729d8e43bbf1aa573616e4d40 100644
--- a/drivers/iio/adc/ad4030.c
+++ b/drivers/iio/adc/ad4030.c
@@ -852,8 +852,8 @@ static int ad4030_read_label(struct iio_dev *indio_dev,
char *label)
{
if (chan->differential)
- return sprintf(label, "differential%lu\n", chan->address);
- return sprintf(label, "common-mode%lu\n", chan->address);
+ return sysfs_emit(label, "differential%lu\n", chan->address);
+ return sysfs_emit(label, "common-mode%lu\n", chan->address);
}
static int ad4030_get_current_scan_type(const struct iio_dev *indio_dev,
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/9] iio: adc: ad7768-1: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 1/9] iio: adc: ad4030: replace sprintf() with sysfs_emit() Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 3/9] iio: adc: mcp3564: " Nuno Sá via B4 Relay
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the ad7768_read_label() function to use sysfs_emit(() for
generating labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/ad7768-1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
index 872c88d0c86cab9f083e38dbc65463676c62001f..d96802b7847a6320c12fd121b0999256f3bd04a8 100644
--- a/drivers/iio/adc/ad7768-1.c
+++ b/drivers/iio/adc/ad7768-1.c
@@ -899,7 +899,7 @@ static int ad7768_read_label(struct iio_dev *indio_dev,
{
struct ad7768_state *st = iio_priv(indio_dev);
- return sprintf(label, "%s\n", st->labels[chan->channel]);
+ return sysfs_emit(label, "%s\n", st->labels[chan->channel]);
}
static int ad7768_get_current_scan_type(const struct iio_dev *indio_dev,
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/9] iio: adc: mcp3564: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 1/9] iio: adc: ad4030: replace sprintf() with sysfs_emit() Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 2/9] iio: adc: ad7768-1: " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:59 ` Marius.Cristea
2025-09-30 15:33 ` [PATCH 4/9] iio: adc: meson_saradc: " Nuno Sá via B4 Relay
` (6 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the mcp3564_read_label() function to use sysfs_emit() for
generating labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/mcp3564.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
index cd679ff10a97c4be19ca461126bdfae2fa8431f2..fcdf13f49c48f31ba3a0a9079686d2b81a792744 100644
--- a/drivers/iio/adc/mcp3564.c
+++ b/drivers/iio/adc/mcp3564.c
@@ -987,7 +987,7 @@ static int mcp3564_read_label(struct iio_dev *indio_dev,
{
struct mcp3564_state *adc = iio_priv(indio_dev);
- return sprintf(label, "%s\n", adc->labels[chan->scan_index]);
+ return sysfs_emit(label, "%s\n", adc->labels[chan->scan_index]);
}
static int mcp3564_parse_fw_children(struct iio_dev *indio_dev)
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/9] iio: adc: meson_saradc: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (2 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 3/9] iio: adc: mcp3564: " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 5/9] iio: adc: mt6360-adc: replace snprintf() " Nuno Sá via B4 Relay
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the read_label() function to use sysfs_emit() for generating
labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/meson_saradc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index f7e7172ef4f6c2042f9ad54583d399f477ef7f5d..47cd350498a0d42536445ab324cc9249966b37d0 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -1181,12 +1181,12 @@ static int read_label(struct iio_dev *indio_dev,
char *label)
{
if (chan->type == IIO_TEMP)
- return sprintf(label, "temp-sensor\n");
+ return sysfs_emit(label, "temp-sensor\n");
if (chan->type == IIO_VOLTAGE && chan->channel >= NUM_MUX_0_VSS)
- return sprintf(label, "%s\n",
+ return sysfs_emit(label, "%s\n",
chan7_mux_names[chan->channel - NUM_MUX_0_VSS]);
if (chan->type == IIO_VOLTAGE)
- return sprintf(label, "channel-%d\n", chan->channel);
+ return sysfs_emit(label, "channel-%d\n", chan->channel);
return 0;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/9] iio: adc: mt6360-adc: replace snprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (3 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 4/9] iio: adc: meson_saradc: " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 6/9] iio: adc: pac1921: replace sprintf() " Nuno Sá via B4 Relay
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the mt6360_adc_read_label() function to use sysfs_emit() for
generating labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/mt6360-adc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 69b3569c90e5b665e1d2c59621df00d6142fbe9c..e0e4df418612469bb11a88bdbeb77aeb7cb833eb 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -216,7 +216,7 @@ static const char *mt6360_channel_labels[MT6360_CHAN_MAX] = {
static int mt6360_adc_read_label(struct iio_dev *iio_dev, const struct iio_chan_spec *chan,
char *label)
{
- return snprintf(label, PAGE_SIZE, "%s\n", mt6360_channel_labels[chan->channel]);
+ return sysfs_emit(label, "%s\n", mt6360_channel_labels[chan->channel]);
}
static const struct iio_info mt6360_adc_iio_info = {
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/9] iio: adc: pac1921: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (4 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 5/9] iio: adc: mt6360-adc: replace snprintf() " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 7/9] iio: adc: qcom-spmi-rradc: replace snprintf() " Nuno Sá via B4 Relay
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the pac1921_read_label() function to use sysfs_emit() for
generating labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/pac1921.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/adc/pac1921.c b/drivers/iio/adc/pac1921.c
index 35433250b00872edfc9214c632917a8b8ae6e281..a0227b57f23883034f84ac2ada3d4f9319e5047d 100644
--- a/drivers/iio/adc/pac1921.c
+++ b/drivers/iio/adc/pac1921.c
@@ -672,13 +672,13 @@ static int pac1921_read_label(struct iio_dev *indio_dev,
{
switch (chan->channel) {
case PAC1921_CHAN_VBUS:
- return sprintf(label, "vbus\n");
+ return sysfs_emit(label, "vbus\n");
case PAC1921_CHAN_VSENSE:
- return sprintf(label, "vsense\n");
+ return sysfs_emit(label, "vsense\n");
case PAC1921_CHAN_CURRENT:
- return sprintf(label, "current\n");
+ return sysfs_emit(label, "current\n");
case PAC1921_CHAN_POWER:
- return sprintf(label, "power\n");
+ return sysfs_emit(label, "power\n");
default:
return -EINVAL;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/9] iio: adc: qcom-spmi-rradc: replace snprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (5 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 6/9] iio: adc: pac1921: replace sprintf() " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() " Nuno Sá via B4 Relay
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the rradc_read_label() function to use sysfs_emit() for generating
labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/adc/qcom-spmi-rradc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/adc/qcom-spmi-rradc.c b/drivers/iio/adc/qcom-spmi-rradc.c
index f61ad0510f04c7760d3735020b5de854b0e31702..b245416bae12121e16033f0185d8d0d2ef28f7ee 100644
--- a/drivers/iio/adc/qcom-spmi-rradc.c
+++ b/drivers/iio/adc/qcom-spmi-rradc.c
@@ -769,7 +769,7 @@ static int rradc_read_raw(struct iio_dev *indio_dev,
static int rradc_read_label(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, char *label)
{
- return snprintf(label, PAGE_SIZE, "%s\n",
+ return sysfs_emit(label, "%s\n",
rradc_chans[chan->address].label);
}
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (6 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 7/9] iio: adc: qcom-spmi-rradc: replace snprintf() " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-09-30 16:07 ` srinivas pandruvada
2025-09-30 15:33 ` [PATCH 9/9] iio: resolver: ad2s1210: " Nuno Sá via B4 Relay
2025-10-04 14:00 ` [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Jonathan Cameron
9 siblings, 1 reply; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the hinge_read_label() function to use sysfs_emit() for generating
labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/position/hid-sensor-custom-intel-hinge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
index bff7039690ac33bcc9747add8055023dd5a1f3ab..a26d391661fdb64cc34c8c0e163333c01c1f069b 100644
--- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
+++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
@@ -176,7 +176,7 @@ static int hinge_read_label(struct iio_dev *indio_dev,
{
struct hinge_state *st = iio_priv(indio_dev);
- return sprintf(label, "%s\n", st->labels[chan->channel]);
+ return sysfs_emit(label, "%s\n", st->labels[chan->channel]);
}
static const struct iio_info hinge_info = {
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 9/9] iio: resolver: ad2s1210: replace sprintf() with sysfs_emit()
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (7 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() " Nuno Sá via B4 Relay
@ 2025-09-30 15:33 ` Nuno Sá via B4 Relay
2025-10-04 14:00 ` [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Jonathan Cameron
9 siblings, 0 replies; 13+ messages in thread
From: Nuno Sá via B4 Relay @ 2025-09-30 15:33 UTC (permalink / raw)
To: linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina,
Srinivas Pandruvada
From: Nuno Sá <nuno.sa@analog.com>
Update the ad2s1210_read_label() and ad2s1210_read_event_label() functions
to use sysfs_emit() for generating labels.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/resolver/ad2s1210.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c
index 9b028c8bb1db142e2afd743aa3ace1d6d3230ae5..06d9c784f93e01288b42a1b9aee36b9f84e4b7f4 100644
--- a/drivers/iio/resolver/ad2s1210.c
+++ b/drivers/iio/resolver/ad2s1210.c
@@ -1132,23 +1132,23 @@ static int ad2s1210_read_label(struct iio_dev *indio_dev,
{
if (chan->type == IIO_ANGL) {
if (chan->channel == 0)
- return sprintf(label, "position\n");
+ return sysfs_emit(label, "position\n");
if (chan->channel == 1)
- return sprintf(label, "tracking error\n");
+ return sysfs_emit(label, "tracking error\n");
}
if (chan->type == IIO_ANGL_VEL)
- return sprintf(label, "velocity\n");
+ return sysfs_emit(label, "velocity\n");
if (chan->type == IIO_PHASE)
- return sprintf(label, "synthetic reference\n");
+ return sysfs_emit(label, "synthetic reference\n");
if (chan->type == IIO_ALTVOLTAGE) {
if (chan->output)
- return sprintf(label, "excitation\n");
+ return sysfs_emit(label, "excitation\n");
if (chan->channel == 0)
- return sprintf(label, "monitor signal\n");
+ return sysfs_emit(label, "monitor signal\n");
if (chan->channel == 1)
- return sprintf(label, "cosine\n");
+ return sysfs_emit(label, "cosine\n");
if (chan->channel == 2)
- return sprintf(label, "sine\n");
+ return sysfs_emit(label, "sine\n");
}
return -EINVAL;
@@ -1239,24 +1239,24 @@ static int ad2s1210_read_event_label(struct iio_dev *indio_dev,
char *label)
{
if (chan->type == IIO_ANGL)
- return sprintf(label, "LOT\n");
+ return sysfs_emit(label, "LOT\n");
if (chan->type == IIO_ANGL_VEL)
- return sprintf(label, "max tracking rate\n");
+ return sysfs_emit(label, "max tracking rate\n");
if (chan->type == IIO_PHASE)
- return sprintf(label, "phase lock\n");
+ return sysfs_emit(label, "phase lock\n");
if (chan->type == IIO_ALTVOLTAGE) {
if (chan->channel == 0) {
if (type == IIO_EV_TYPE_THRESH &&
dir == IIO_EV_DIR_FALLING)
- return sprintf(label, "LOS\n");
+ return sysfs_emit(label, "LOS\n");
if (type == IIO_EV_TYPE_THRESH &&
dir == IIO_EV_DIR_RISING)
- return sprintf(label, "DOS overrange\n");
+ return sysfs_emit(label, "DOS overrange\n");
if (type == IIO_EV_TYPE_MAG)
- return sprintf(label, "DOS mismatch\n");
+ return sysfs_emit(label, "DOS mismatch\n");
}
if (chan->channel == 1 || chan->channel == 2)
- return sprintf(label, "clipped\n");
+ return sysfs_emit(label, "clipped\n");
}
return -EINVAL;
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 3/9] iio: adc: mcp3564: replace sprintf() with sysfs_emit()
2025-09-30 15:33 ` [PATCH 3/9] iio: adc: mcp3564: " Nuno Sá via B4 Relay
@ 2025-09-30 15:59 ` Marius.Cristea
0 siblings, 0 replies; 13+ messages in thread
From: Marius.Cristea @ 2025-09-30 15:59 UTC (permalink / raw)
To: nuno.sa, linux-iio
Cc: dlechner, srinivas.pandruvada, neil.armstrong, eblanc,
angelogioacchino.delregno, jic23, andy, Michael.Hennerich,
jbrunet, khilman, matthias.bgg, jikos, martin.blumenstingl,
matteomartelli3
Reviewed-by: Marius Cristea <marius.cristea@microchip.com>
On Tue, 2025-09-30 at 16:33 +0100, Nuno Sá via B4 Relay wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> From: Nuno Sá <nuno.sa@analog.com>
>
> Update the mcp3564_read_label() function to use sysfs_emit() for
> generating labels.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
> drivers/iio/adc/mcp3564.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/mcp3564.c b/drivers/iio/adc/mcp3564.c
> index
> cd679ff10a97c4be19ca461126bdfae2fa8431f2..fcdf13f49c48f31ba3a0a907968
> 6d2b81a792744 100644
> --- a/drivers/iio/adc/mcp3564.c
> +++ b/drivers/iio/adc/mcp3564.c
> @@ -987,7 +987,7 @@ static int mcp3564_read_label(struct iio_dev
> *indio_dev,
> {
> struct mcp3564_state *adc = iio_priv(indio_dev);
>
> - return sprintf(label, "%s\n", adc->labels[chan->scan_index]);
> + return sysfs_emit(label, "%s\n", adc->labels[chan-
> >scan_index]);
> }
>
> static int mcp3564_parse_fw_children(struct iio_dev *indio_dev)
>
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit()
2025-09-30 15:33 ` [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() " Nuno Sá via B4 Relay
@ 2025-09-30 16:07 ` srinivas pandruvada
0 siblings, 0 replies; 13+ messages in thread
From: srinivas pandruvada @ 2025-09-30 16:07 UTC (permalink / raw)
To: nuno.sa, linux-iio
Cc: Michael Hennerich, Esteban Blanc, Jonathan Cameron, David Lechner,
Andy Shevchenko, Marius Cristea, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl, Matthias Brugger,
AngeloGioacchino Del Regno, Matteo Martelli, Jiri Kosina
On Tue, 2025-09-30 at 16:33 +0100, Nuno Sá via B4 Relay wrote:
> From: Nuno Sá <nuno.sa@analog.com>
>
> Update the hinge_read_label() function to use sysfs_emit() for
> generating
> labels.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
> drivers/iio/position/hid-sensor-custom-intel-hinge.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> index
> bff7039690ac33bcc9747add8055023dd5a1f3ab..a26d391661fdb64cc34c8c0e163
> 333c01c1f069b 100644
> --- a/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> +++ b/drivers/iio/position/hid-sensor-custom-intel-hinge.c
> @@ -176,7 +176,7 @@ static int hinge_read_label(struct iio_dev
> *indio_dev,
> {
> struct hinge_state *st = iio_priv(indio_dev);
>
> - return sprintf(label, "%s\n", st->labels[chan->channel]);
> + return sysfs_emit(label, "%s\n", st->labels[chan->channel]);
> }
>
> static const struct iio_info hinge_info = {
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
` (8 preceding siblings ...)
2025-09-30 15:33 ` [PATCH 9/9] iio: resolver: ad2s1210: " Nuno Sá via B4 Relay
@ 2025-10-04 14:00 ` Jonathan Cameron
9 siblings, 0 replies; 13+ messages in thread
From: Jonathan Cameron @ 2025-10-04 14:00 UTC (permalink / raw)
To: Nuno Sá via B4 Relay
Cc: nuno.sa, linux-iio, Michael Hennerich, Esteban Blanc,
David Lechner, Andy Shevchenko, Marius Cristea, Neil Armstrong,
Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
Matthias Brugger, AngeloGioacchino Del Regno, Matteo Martelli,
Jiri Kosina, Srinivas Pandruvada, Nuno Sá
On Tue, 30 Sep 2025 16:33:09 +0100
Nuno Sá via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
> When looking at some drivers implementing the .read_label() callback it
> came to my attention that there were some outliers using sprintf() (or
> even snprintf() with PAGE_SIZE) instead of sysfs_emit(). This series
> cleans that up.
I hope this doesn't come back to bite us by a future in kernel consumer not
directly spitting the result of this into a sysfs read buffer. Anyhow
today it's fine and we have existing cases doing sysfs_emit() so arguably
any future problems aren't made worse by this patch set + for common usage
it's an improvement.
So applied.
Thanks,
Jonathan
>
> ---
> Nuno Sá (9):
> iio: adc: ad4030: replace sprintf() with sysfs_emit()
> iio: adc: ad7768-1: replace sprintf() with sysfs_emit()
> iio: adc: mcp3564: replace sprintf() with sysfs_emit()
> iio: adc: meson_saradc: replace sprintf() with sysfs_emit()
> iio: adc: mt6360-adc: replace snprintf() with sysfs_emit()
> iio: adc: pac1921: replace sprintf() with sysfs_emit()
> iio: adc: qcom-spmi-rradc: replace snprintf() with sysfs_emit()
> iio: position: hid-sensor-custom-intel-hinge: replace sprintf() with sysfs_emit()
> iio: resolver: ad2s1210: replace sprintf() with sysfs_emit()
>
> drivers/iio/adc/ad4030.c | 4 +--
> drivers/iio/adc/ad7768-1.c | 2 +-
> drivers/iio/adc/mcp3564.c | 2 +-
> drivers/iio/adc/meson_saradc.c | 6 ++---
> drivers/iio/adc/mt6360-adc.c | 2 +-
> drivers/iio/adc/pac1921.c | 8 +++---
> drivers/iio/adc/qcom-spmi-rradc.c | 2 +-
> .../iio/position/hid-sensor-custom-intel-hinge.c | 2 +-
> drivers/iio/resolver/ad2s1210.c | 30 +++++++++++-----------
> 9 files changed, 29 insertions(+), 29 deletions(-)
> ---
> base-commit: b9700f87939f0f477e5c00db817f54ab8a97702b
> change-id: 20250930-dev-sprintf-cleanup-baf2c89b3460
> --
>
> Thanks!
> - Nuno Sá
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-10-04 14:00 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30 15:33 [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 1/9] iio: adc: ad4030: replace sprintf() with sysfs_emit() Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 2/9] iio: adc: ad7768-1: " Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 3/9] iio: adc: mcp3564: " Nuno Sá via B4 Relay
2025-09-30 15:59 ` Marius.Cristea
2025-09-30 15:33 ` [PATCH 4/9] iio: adc: meson_saradc: " Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 5/9] iio: adc: mt6360-adc: replace snprintf() " Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 6/9] iio: adc: pac1921: replace sprintf() " Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 7/9] iio: adc: qcom-spmi-rradc: replace snprintf() " Nuno Sá via B4 Relay
2025-09-30 15:33 ` [PATCH 8/9] iio: position: hid-sensor-custom-intel-hinge: replace sprintf() " Nuno Sá via B4 Relay
2025-09-30 16:07 ` srinivas pandruvada
2025-09-30 15:33 ` [PATCH 9/9] iio: resolver: ad2s1210: " Nuno Sá via B4 Relay
2025-10-04 14:00 ` [PATCH 0/9] iio: replace sprintf() with sysfs_emit() in .read_label() op Jonathan Cameron
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).