leds: convert symbolic permission bit macros to octal
Subsystems (2)
PATCH 1/1 leds: convert symbolic permission bit macros to octal
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 => 0444S_IWUSR => 0200S_IRUGO | S_IWUSR => 0644
--- 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(-)
drivers/leds/leds-blinkm.c +4 -4
@@ -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);static ssize_t show_green (struct device *dev,struct device_attribute *attr,char *buf)
@@ -229,7 +229,7 @@ static ssize_t store_green(struct device *dev, struct device_attribute *attr,return count; } -static DEVICE_ATTR(green, S_IRUGO | S_IWUSR, show_green, store_green); +static DEVICE_ATTR(green, 0644, show_green, store_green);static ssize_t show_blue (struct device *dev,struct device_attribute *attr,char *buf)
@@ -248,7 +248,7 @@ static ssize_t store_blue(struct device *dev, struct device_attribute *attr,return count; } -static DEVICE_ATTR(blue, S_IRUGO | S_IWUSR, show_blue, store_blue); +static DEVICE_ATTR(blue, 0644, show_blue, store_blue);static ssize_t show_test (struct device *dev,struct device_attribute *attr,char *buf)
@@ -273,7 +273,7 @@ static ssize_t store_test(struct device *dev, struct device_attribute *attr,return count; } -static DEVICE_ATTR(test, S_IRUGO | S_IWUSR, show_test, store_test); +static DEVICE_ATTR(test, 0644, show_test, store_test);/* TODO: HSB, fade, timeadj, script ... */
drivers/leds/leds-lm355x.c +1 -1
@@ -381,7 +381,7 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev,return ret; } -static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); +static DEVICE_ATTR(pattern, 0200, NULL, lm3556_indicator_pattern_store);static struct attribute *lm355x_indicator_attrs[] = { &dev_attr_pattern.attr,
drivers/leds/leds-lm3642.c +2 -2
@@ -193,7 +193,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev,return size; } -static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); +static DEVICE_ATTR(torch_pin, 0200, NULL, lm3642_torch_pin_store);static int lm3642_torch_brightness_set (struct led_classdev *cdev,enum led_brightness brightness)
@@ -240,7 +240,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev,return size; } -static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); +static DEVICE_ATTR(strobe_pin, 0200, NULL, lm3642_strobe_pin_store);static int lm3642_strobe_brightness_set (struct led_classdev *cdev,enum led_brightness brightness)
drivers/leds/leds-lp55xx-common.h +3 -3
@@ -29,11 +29,11 @@ enum lp55xx_engine_mode { };#define LP55XX_DEV_ATTR_RW (name, show, store) \ - DEVICE_ATTR(name, S_IRUGO | S_IWUSR, show, store) + DEVICE_ATTR(name, 0644, show, store)#define LP55XX_DEV_ATTR_RO (name, show) \ - DEVICE_ATTR(name, S_IRUGO, show, NULL) + DEVICE_ATTR(name, 0444, show, NULL)#define LP55XX_DEV_ATTR_WO (name, store) \ - DEVICE_ATTR(name, S_IWUSR, NULL, store) + DEVICE_ATTR(name, 0200, NULL, store)#define show_mode (nr) \ static ssize_t show_engine##nr##_mode(struct device *dev, \
Signature · 6 lines
2.27.0 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 27 lines · Dwaipayan Ray
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=> 0444S_IWUSR=> 0200S_IRUGO|S_IWUSR=> 0644Signed-off-by Dwaipayan Ray <[email protected]>--- 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(-)drivers/leds/leds-blinkm.c +0
-0
drivers/leds/leds-blinkm.c static ssize_t store_red(struct device *dev, struct device_attribute *attr, · line 212
Quoted 5 lines
drivers/leds/leds-blinkm.c +1
-1@@ -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
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 39 lines · Greg KH
Quoted 27 lines · Dwaipayan Ray
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=> 0444S_IWUSR=> 0200S_IRUGO|S_IWUSR=> 0644Signed-off-by Dwaipayan Ray <[email protected]>--- 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(-)drivers/leds/leds-blinkm.c +0
-0drivers/leds/leds-blinkm.c static ssize_t store_red(struct device *dev, struct device_attribute *attr, · line 212
Quoted 5 lines
drivers/leds/leds-blinkm.c +1
-1@@ -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.
Quoted 3 lines
thanks,
greg k-h
Thanks Greg, I will do that.
Seems like the led drivers are still using a lot of those old constructs. leds$ git grep -P "DEVICE_ATTR\(" | wc -l
31
Will correct them all.
Thank you,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees