misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg()
PATCH 1/1 misc: ad525x_dpot: Use str_enabled_disabled() in sysfs_show_reg()
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(..)
--- drivers/misc/ad525x_dpot.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/misc/ad525x_dpot.c +3 -4
@@ -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);
Signature · 1 line
2.50.1
Greg Kroah-Hartman
maintainerQuoted 24 lines · Thorsten Blum
Remove hard-coded strings by using the
str_enabled_disabled()helper function and silence the following Coccinelle/coccicheck warning reported bystring_choices.cocci:opportunity for
str_enabled_disabled(..)Signed-off-by Thorsten Blum <[email protected]>--- drivers/misc/ad525x_dpot.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/misc/ad525x_dpot.c +1
-0@@ -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"
drivers/misc/ad525x_dpot.c static ssize_t sysfs_show_reg(struct device *dev, · line 423
Quoted 9 lines
drivers/misc/ad525x_dpot.c +2
-4@@ -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
Quoted 5 lines · Greg Kroah-Hartman
Quoted 4 lines · Thorsten Blum
Remove hard-coded strings by using the
str_enabled_disabled()helper function and silence the following Coccinelle/coccicheck warning reported bystring_choices.cocci:
Quoted 7 lines
Quoted 4 lines
opportunity for
str_enabled_disabled(..)Signed-off-by Thorsten Blum <[email protected]>---
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?
Quoted 1 line
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