* [PATCH] misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg()
@ 2025-08-20 10:27 Thorsten Blum
2025-08-20 11:15 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-08-20 10:27 UTC (permalink / raw)
To: Michael Hennerich, Arnd Bergmann, Greg Kroah-Hartman
Cc: Thorsten Blum, linux-kernel
Remove hard-coded strings by using the str_enabled_disabled() helper
function and silence the following Coccinelle/coccicheck warning
reported by string_choices.cocci:
opportunity for str_enabled_disabled(..)
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/misc/ad525x_dpot.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
index 756ef6912b5a..04683b981e54 100644
--- a/drivers/misc/ad525x_dpot.c
+++ b/drivers/misc/ad525x_dpot.c
@@ -73,6 +73,7 @@
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>
#include "ad525x_dpot.h"
@@ -418,10 +419,8 @@ static ssize_t sysfs_show_reg(struct device *dev,
s32 value;
if (reg & DPOT_ADDR_OTP_EN)
- return sprintf(buf, "%s\n",
- test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask) ?
- "enabled" : "disabled");
-
+ return sprintf(buf, "%s\n", str_enabled_disabled(
+ test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)));
mutex_lock(&data->update_lock);
value = dpot_read(data, reg);
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg()
2025-08-20 10:27 [PATCH] misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg() Thorsten Blum
@ 2025-08-20 11:15 ` Greg Kroah-Hartman
2025-08-20 21:46 ` Thorsten Blum
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2025-08-20 11:15 UTC (permalink / raw)
To: Thorsten Blum; +Cc: Michael Hennerich, Arnd Bergmann, linux-kernel
On Wed, Aug 20, 2025 at 12:27:34PM +0200, Thorsten Blum wrote:
> Remove hard-coded strings by using the str_enabled_disabled() helper
> function and silence the following Coccinelle/coccicheck warning
> reported by string_choices.cocci:
>
> opportunity for str_enabled_disabled(..)
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/misc/ad525x_dpot.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/misc/ad525x_dpot.c b/drivers/misc/ad525x_dpot.c
> index 756ef6912b5a..04683b981e54 100644
> --- a/drivers/misc/ad525x_dpot.c
> +++ b/drivers/misc/ad525x_dpot.c
> @@ -73,6 +73,7 @@
> #include <linux/kernel.h>
> #include <linux/delay.h>
> #include <linux/slab.h>
> +#include <linux/string_choices.h>
>
> #include "ad525x_dpot.h"
>
> @@ -418,10 +419,8 @@ static ssize_t sysfs_show_reg(struct device *dev,
> s32 value;
>
> if (reg & DPOT_ADDR_OTP_EN)
> - return sprintf(buf, "%s\n",
> - test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask) ?
> - "enabled" : "disabled");
> -
> + return sprintf(buf, "%s\n", str_enabled_disabled(
> + test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask)));
If you are going to change this, might as well call sysfs_emit() as
well, right?
that way you get two coccicheck warnings at once :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg()
2025-08-20 11:15 ` Greg Kroah-Hartman
@ 2025-08-20 21:46 ` Thorsten Blum
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-08-20 21:46 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Michael Hennerich, Arnd Bergmann, linux-kernel
On 20. Aug 2025, at 13:15, Greg Kroah-Hartman wrote:
> On Wed, Aug 20, 2025 at 12:27:34PM +0200, Thorsten Blum wrote:
>> Remove hard-coded strings by using the str_enabled_disabled() helper
>> function and silence the following Coccinelle/coccicheck warning
>> reported by string_choices.cocci:
>>
>> opportunity for str_enabled_disabled(..)
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>
> If you are going to change this, might as well call sysfs_emit() as
> well, right?
I guess, but probably in another patch because it's two separate things?
> that way you get two coccicheck warnings at once :)
I didn't look into it, but device_attr_show.cocci doesn't produce any
warnings for drivers/misc/* (at least not for me).
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-20 21:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 10:27 [PATCH] misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg() Thorsten Blum
2025-08-20 11:15 ` Greg Kroah-Hartman
2025-08-20 21:46 ` Thorsten Blum
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).