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

Dwaipayan Ray dwaipayanray1 at gmail.com
Sat Dec 12 15:35:17 UTC 2020


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);
 
 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 ... */
 
diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
index 1505521249b5..d15cc0808573 100644
--- a/drivers/leds/leds-lm355x.c
+++ b/drivers/leds/leds-lm355x.c
@@ -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,
diff --git a/drivers/leds/leds-lm3642.c b/drivers/leds/leds-lm3642.c
index 62c14872caf7..b7c2edd0234a 100644
--- a/drivers/leds/leds-lm3642.c
+++ b/drivers/leds/leds-lm3642.c
@@ -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)
diff --git a/drivers/leds/leds-lp55xx-common.h b/drivers/leds/leds-lp55xx-common.h
index 2f38c5b33830..9345ab1cf323 100644
--- a/drivers/leds/leds-lp55xx-common.h
+++ b/drivers/leds/leds-lp55xx-common.h
@@ -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,		\
-- 
2.27.0



More information about the Linux-kernel-mentees mailing list