[Linux-kernel-mentees] [PATCH] leds: convert symbolic permission bit macros to octal

Greg KH gregkh at linuxfoundation.org
Sat Dec 12 17:51:07 UTC 2020


On Sat, Dec 12, 2020 at 09:05:17PM +0530, Dwaipayan Ray wrote:
> Symbolic macro names are hard to understand and should not be
> used for permission bits.
> 
> Convert all bad symbolic permission bit macro uses in led to just use
> the octal numbers.
> 
> Following macros were replaced:
> 
> S_IRUGO => 0444
> S_IWUSR => 0200
> S_IRUGO | S_IWUSR => 0644
> 
> Link: https://lore.kernel.org/lkml/CA+55aFw5v23T-zvDZp-MmD_EYxF8WbafwwB59934FV7g21uMGQ@mail.gmail.com/
> 
> Signed-off-by: Dwaipayan Ray <dwaipayanray1 at gmail.com>
> ---
>  drivers/leds/leds-blinkm.c        | 8 ++++----
>  drivers/leds/leds-lm355x.c        | 2 +-
>  drivers/leds/leds-lm3642.c        | 4 ++--
>  drivers/leds/leds-lp55xx-common.h | 6 +++---
>  4 files changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c
> index e11fe1788242..6b9b13f58d8a 100644
> --- a/drivers/leds/leds-blinkm.c
> +++ b/drivers/leds/leds-blinkm.c
> @@ -209,7 +209,7 @@ static ssize_t store_red(struct device *dev, struct device_attribute *attr,
>  	return count;
>  }
>  
> -static DEVICE_ATTR(red, S_IRUGO | S_IWUSR, show_red, store_red);
> +static DEVICE_ATTR(red, 0644, show_red, store_red);

Why not use DEVICE_ATTR_RW() instead?  THat would handle all of this
automatically for you, which is why they are recommended to be used
instead.

thanks,

greg k-h


More information about the Linux-kernel-mentees mailing list