* [PATCH] misc: ad525x_dpot: Replace sprintf with sysfs_emit in sysfs_show_reg
@ 2025-11-03 12:34 Thorsten Blum
2025-11-03 12:46 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-11-03 12:34 UTC (permalink / raw)
To: Michael Hennerich, Arnd Bergmann, Greg Kroah-Hartman
Cc: Thorsten Blum, linux-kernel
Replace sprintf() with sysfs_emit() in sysfs_show_reg(). sysfs_emit() is
preferred for formatting sysfs output as it provides better bounds
checking. No functional changes.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/misc/ad525x_dpot.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 04683b981e54..519f97089a00 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -419,7 +419,7 @@ static ssize_t sysfs_show_reg(struct device *dev,
s32 value;
if (reg & DPOT_ADDR_OTP_EN)
- return sprintf(buf, "%s\n", str_enabled_disabled(
+ return sysfs_emit(buf, "%s\n", str_enabled_disabled(
test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)));
mutex_lock(&data->update_lock);
@@ -437,9 +437,9 @@ static ssize_t sysfs_show_reg(struct device *dev,
*/
if (reg & DPOT_REG_TOL)
- return sprintf(buf, "0x%04x\n", value & 0xFFFF);
+ return sysfs_emit(buf, "0x%04x\n", value & 0xFFFF);
else
- return sprintf(buf, "%u\n", value & data->rdac_mask);
+ return sysfs_emit(buf, "%u\n", value & data->rdac_mask);
}
static ssize_t sysfs_set_reg(struct device *dev,
--
2.51.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] misc: ad525x_dpot: Replace sprintf with sysfs_emit in sysfs_show_reg
2025-11-03 12:34 [PATCH] misc: ad525x_dpot: Replace sprintf with sysfs_emit in sysfs_show_reg Thorsten Blum
@ 2025-11-03 12:46 ` Greg Kroah-Hartman
2025-11-03 13:11 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-11-03 12:46 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Michael Hennerich, Arnd Bergmann, linux-kernel
On Mon, Nov 03, 2025 at 01:34:03PM +0100, Thorsten Blum wrote:
> Replace sprintf() with sysfs_emit() in sysfs_show_reg(). sysfs_emit() is
> preferred for formatting sysfs output as it provides better bounds
> checking. No functional changes.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/misc/ad525x_dpot.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
> index 04683b981e54..519f97089a00 100644
> --- a/drivers/misc/ad525x_dpot.c
> +++ b/drivers/misc/ad525x_dpot.c
> @@ -419,7 +419,7 @@ static ssize_t sysfs_show_reg(struct device *dev,
> s32 value;
>
> if (reg & DPOT_ADDR_OTP_EN)
> - return sprintf(buf, "%s\n", str_enabled_disabled(
> + return sysfs_emit(buf, "%s\n", str_enabled_disabled(
> test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)));
I did not suggest doing this for existing code at all, it's only needed
for new code, I've said so many times.
sprintf() works just fine here, there's no bug or issue with it.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] misc: ad525x_dpot: Replace sprintf with sysfs_emit in sysfs_show_reg
2025-11-03 12:46 ` Greg Kroah-Hartman
@ 2025-11-03 13:11 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-11-03 13:11 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Michael Hennerich, Arnd Bergmann, linux-kernel
On 3. Nov 2025, at 13:46, Greg Kroah-Hartman wrote:
> On Mon, Nov 03, 2025 at 01:34:03PM +0100, Thorsten Blum wrote:
>> Replace sprintf() with sysfs_emit() in sysfs_show_reg(). sysfs_emit() is
>> preferred for formatting sysfs output as it provides better bounds
>> checking. No functional changes.
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> ---
>> [...]
>
> I did not suggest doing this for existing code at all, it's only needed
> for new code, I've said so many times.
You suggested it in [1] for this function when I made another change to
it a few weeks ago. I even replied that there's no coccicheck warning,
and that the sysfs_emit change should probably be a separate patch.
No big deal, but still confusing.
Thanks,
Thorsten
[1] https://lore.kernel.org/lkml/2025082052-crawfish-revisable-7965@gregkh/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-03 13:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-03 12:34 [PATCH] misc: ad525x_dpot: Replace sprintf with sysfs_emit in sysfs_show_reg Thorsten Blum
2025-11-03 12:46 ` Greg Kroah-Hartman
2025-11-03 13:11 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox