Commit 5ccfa39d authored by Dwaipayan Ray's avatar Dwaipayan Ray Committed by Pavel Machek

leds: Use DEVICE_ATTR_{RW, RO, WO} macros

Instead of open coding DEVICE_ATTR() defines, use the
DEVICE_ATTR_RW(), DEVICE_ATTR_WO(), and DEVICE_ATTR_RO()
macros.

This required a few functions to be renamed, but the functionality
itself is unchanged.
Reviewed-by: default avatarLukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: default avatarDwaipayan Ray <dwaipayanray1@gmail.com>
Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
parent 5c8fe583
...@@ -192,13 +192,13 @@ static int store_color_common(struct device *dev, const char *buf, int color) ...@@ -192,13 +192,13 @@ static int store_color_common(struct device *dev, const char *buf, int color)
return 0; return 0;
} }
static ssize_t show_red(struct device *dev, struct device_attribute *attr, static ssize_t red_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, RED); return show_color_common(dev, buf, RED);
} }
static ssize_t store_red(struct device *dev, struct device_attribute *attr, static ssize_t red_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int ret; int ret;
...@@ -209,15 +209,15 @@ static ssize_t store_red(struct device *dev, struct device_attribute *attr, ...@@ -209,15 +209,15 @@ static ssize_t store_red(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(red, S_IRUGO | S_IWUSR, show_red, store_red); static DEVICE_ATTR_RW(red);
static ssize_t show_green(struct device *dev, struct device_attribute *attr, static ssize_t green_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, GREEN); return show_color_common(dev, buf, GREEN);
} }
static ssize_t store_green(struct device *dev, struct device_attribute *attr, static ssize_t green_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -229,15 +229,15 @@ static ssize_t store_green(struct device *dev, struct device_attribute *attr, ...@@ -229,15 +229,15 @@ static ssize_t store_green(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(green, S_IRUGO | S_IWUSR, show_green, store_green); static DEVICE_ATTR_RW(green);
static ssize_t show_blue(struct device *dev, struct device_attribute *attr, static ssize_t blue_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return show_color_common(dev, buf, BLUE); return show_color_common(dev, buf, BLUE);
} }
static ssize_t store_blue(struct device *dev, struct device_attribute *attr, static ssize_t blue_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int ret; int ret;
...@@ -248,16 +248,16 @@ static ssize_t store_blue(struct device *dev, struct device_attribute *attr, ...@@ -248,16 +248,16 @@ static ssize_t store_blue(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(blue, S_IRUGO | S_IWUSR, show_blue, store_blue); static DEVICE_ATTR_RW(blue);
static ssize_t show_test(struct device *dev, struct device_attribute *attr, static ssize_t test_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
return scnprintf(buf, PAGE_SIZE, return scnprintf(buf, PAGE_SIZE,
"#Write into test to start test sequence!#\n"); "#Write into test to start test sequence!#\n");
} }
static ssize_t store_test(struct device *dev, struct device_attribute *attr, static ssize_t test_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
...@@ -273,7 +273,7 @@ static ssize_t store_test(struct device *dev, struct device_attribute *attr, ...@@ -273,7 +273,7 @@ static ssize_t store_test(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(test, S_IRUGO | S_IWUSR, show_test, store_test); static DEVICE_ATTR_RW(test);
/* TODO: HSB, fade, timeadj, script ... */ /* TODO: HSB, fade, timeadj, script ... */
......
...@@ -346,8 +346,8 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev, ...@@ -346,8 +346,8 @@ static void lm3530_brightness_set(struct led_classdev *led_cdev,
} }
} }
static ssize_t lm3530_mode_get(struct device *dev, static ssize_t mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct lm3530_data *drvdata; struct lm3530_data *drvdata;
...@@ -365,8 +365,8 @@ static ssize_t lm3530_mode_get(struct device *dev, ...@@ -365,8 +365,8 @@ static ssize_t lm3530_mode_get(struct device *dev,
return len; return len;
} }
static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute static ssize_t mode_store(struct device *dev, struct device_attribute
*attr, const char *buf, size_t size) *attr, const char *buf, size_t size)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct lm3530_data *drvdata; struct lm3530_data *drvdata;
...@@ -397,7 +397,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute ...@@ -397,7 +397,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute
return sizeof(drvdata->mode); return sizeof(drvdata->mode);
} }
static DEVICE_ATTR(mode, 0644, lm3530_mode_get, lm3530_mode_set); static DEVICE_ATTR_RW(mode);
static struct attribute *lm3530_attrs[] = { static struct attribute *lm3530_attrs[] = {
&dev_attr_mode.attr, &dev_attr_mode.attr,
......
...@@ -349,9 +349,9 @@ static int lm355x_indicator_brightness_set(struct led_classdev *cdev, ...@@ -349,9 +349,9 @@ static int lm355x_indicator_brightness_set(struct led_classdev *cdev,
} }
/* indicator pattern only for lm3556*/ /* indicator pattern only for lm3556*/
static ssize_t lm3556_indicator_pattern_store(struct device *dev, static ssize_t pattern_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
ssize_t ret; ssize_t ret;
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -381,7 +381,7 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev, ...@@ -381,7 +381,7 @@ static ssize_t lm3556_indicator_pattern_store(struct device *dev,
return ret; return ret;
} }
static DEVICE_ATTR(pattern, S_IWUSR, NULL, lm3556_indicator_pattern_store); static DEVICE_ATTR_WO(pattern);
static struct attribute *lm355x_indicator_attrs[] = { static struct attribute *lm355x_indicator_attrs[] = {
&dev_attr_pattern.attr, &dev_attr_pattern.attr,
......
...@@ -165,9 +165,9 @@ static int lm3642_control(struct lm3642_chip_data *chip, ...@@ -165,9 +165,9 @@ static int lm3642_control(struct lm3642_chip_data *chip,
/* torch */ /* torch */
/* torch pin config for lm3642 */ /* torch pin config for lm3642 */
static ssize_t lm3642_torch_pin_store(struct device *dev, static ssize_t torch_pin_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
ssize_t ret; ssize_t ret;
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -193,7 +193,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev, ...@@ -193,7 +193,7 @@ static ssize_t lm3642_torch_pin_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(torch_pin, S_IWUSR, NULL, lm3642_torch_pin_store); static DEVICE_ATTR_WO(torch_pin);
static int lm3642_torch_brightness_set(struct led_classdev *cdev, static int lm3642_torch_brightness_set(struct led_classdev *cdev,
enum led_brightness brightness) enum led_brightness brightness)
...@@ -212,9 +212,9 @@ static int lm3642_torch_brightness_set(struct led_classdev *cdev, ...@@ -212,9 +212,9 @@ static int lm3642_torch_brightness_set(struct led_classdev *cdev,
/* flash */ /* flash */
/* strobe pin config for lm3642*/ /* strobe pin config for lm3642*/
static ssize_t lm3642_strobe_pin_store(struct device *dev, static ssize_t strobe_pin_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
ssize_t ret; ssize_t ret;
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
...@@ -240,7 +240,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev, ...@@ -240,7 +240,7 @@ static ssize_t lm3642_strobe_pin_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(strobe_pin, S_IWUSR, NULL, lm3642_strobe_pin_store); static DEVICE_ATTR_WO(strobe_pin);
static int lm3642_strobe_brightness_set(struct led_classdev *cdev, static int lm3642_strobe_brightness_set(struct led_classdev *cdev,
enum led_brightness brightness) enum led_brightness brightness)
......
...@@ -160,8 +160,8 @@ static void max8997_led_brightness_set(struct led_classdev *led_cdev, ...@@ -160,8 +160,8 @@ static void max8997_led_brightness_set(struct led_classdev *led_cdev,
} }
} }
static ssize_t max8997_led_show_mode(struct device *dev, static ssize_t mode_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct max8997_led *led = struct max8997_led *led =
...@@ -193,9 +193,9 @@ static ssize_t max8997_led_show_mode(struct device *dev, ...@@ -193,9 +193,9 @@ static ssize_t max8997_led_show_mode(struct device *dev,
return ret; return ret;
} }
static ssize_t max8997_led_store_mode(struct device *dev, static ssize_t mode_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct max8997_led *led = struct max8997_led *led =
...@@ -222,7 +222,7 @@ static ssize_t max8997_led_store_mode(struct device *dev, ...@@ -222,7 +222,7 @@ static ssize_t max8997_led_store_mode(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode); static DEVICE_ATTR_RW(mode);
static struct attribute *max8997_attrs[] = { static struct attribute *max8997_attrs[] = {
&dev_attr_mode.attr, &dev_attr_mode.attr,
......
...@@ -204,9 +204,9 @@ static void netxbig_led_set(struct led_classdev *led_cdev, ...@@ -204,9 +204,9 @@ static void netxbig_led_set(struct led_classdev *led_cdev,
spin_unlock_irqrestore(&led_dat->lock, flags); spin_unlock_irqrestore(&led_dat->lock, flags);
} }
static ssize_t netxbig_led_sata_store(struct device *dev, static ssize_t sata_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buff, size_t count) const char *buff, size_t count)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct netxbig_led_data *led_dat = struct netxbig_led_data *led_dat =
...@@ -255,8 +255,8 @@ static ssize_t netxbig_led_sata_store(struct device *dev, ...@@ -255,8 +255,8 @@ static ssize_t netxbig_led_sata_store(struct device *dev,
return ret; return ret;
} }
static ssize_t netxbig_led_sata_show(struct device *dev, static ssize_t sata_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct netxbig_led_data *led_dat = struct netxbig_led_data *led_dat =
...@@ -265,7 +265,7 @@ static ssize_t netxbig_led_sata_show(struct device *dev, ...@@ -265,7 +265,7 @@ static ssize_t netxbig_led_sata_show(struct device *dev,
return sprintf(buf, "%d\n", led_dat->sata); return sprintf(buf, "%d\n", led_dat->sata);
} }
static DEVICE_ATTR(sata, 0644, netxbig_led_sata_show, netxbig_led_sata_store); static DEVICE_ATTR_RW(sata);
static struct attribute *netxbig_led_attrs[] = { static struct attribute *netxbig_led_attrs[] = {
&dev_attr_sata.attr, &dev_attr_sata.attr,
......
...@@ -441,8 +441,8 @@ static void set_power_light_amber_noblink(void) ...@@ -441,8 +441,8 @@ static void set_power_light_amber_noblink(void)
nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL); nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
} }
static ssize_t nas_led_blink_show(struct device *dev, static ssize_t blink_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led = dev_get_drvdata(dev); struct led_classdev *led = dev_get_drvdata(dev);
int blinking = 0; int blinking = 0;
...@@ -451,9 +451,9 @@ static ssize_t nas_led_blink_show(struct device *dev, ...@@ -451,9 +451,9 @@ static ssize_t nas_led_blink_show(struct device *dev,
return sprintf(buf, "%u\n", blinking); return sprintf(buf, "%u\n", blinking);
} }
static ssize_t nas_led_blink_store(struct device *dev, static ssize_t blink_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
int ret; int ret;
struct led_classdev *led = dev_get_drvdata(dev); struct led_classdev *led = dev_get_drvdata(dev);
...@@ -468,7 +468,7 @@ static ssize_t nas_led_blink_store(struct device *dev, ...@@ -468,7 +468,7 @@ static ssize_t nas_led_blink_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(blink, 0644, nas_led_blink_show, nas_led_blink_store); static DEVICE_ATTR_RW(blink);
static struct attribute *nasgpio_led_attrs[] = { static struct attribute *nasgpio_led_attrs[] = {
&dev_attr_blink.attr, &dev_attr_blink.attr,
......
...@@ -155,8 +155,8 @@ static const char * const led_src_texts[] = { ...@@ -155,8 +155,8 @@ static const char * const led_src_texts[] = {
"soft", "soft",
}; };
static ssize_t wm831x_status_src_show(struct device *dev, static ssize_t src_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct wm831x_status *led = to_wm831x_status(led_cdev); struct wm831x_status *led = to_wm831x_status(led_cdev);
...@@ -178,9 +178,9 @@ static ssize_t wm831x_status_src_show(struct device *dev, ...@@ -178,9 +178,9 @@ static ssize_t wm831x_status_src_show(struct device *dev,
return ret; return ret;
} }
static ssize_t wm831x_status_src_store(struct device *dev, static ssize_t src_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t size) const char *buf, size_t size)
{ {
struct led_classdev *led_cdev = dev_get_drvdata(dev); struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct wm831x_status *led = to_wm831x_status(led_cdev); struct wm831x_status *led = to_wm831x_status(led_cdev);
...@@ -197,7 +197,7 @@ static ssize_t wm831x_status_src_store(struct device *dev, ...@@ -197,7 +197,7 @@ static ssize_t wm831x_status_src_store(struct device *dev,
return size; return size;
} }
static DEVICE_ATTR(src, 0644, wm831x_status_src_show, wm831x_status_src_store); static DEVICE_ATTR_RW(src);
static struct attribute *wm831x_status_attrs[] = { static struct attribute *wm831x_status_attrs[] = {
&dev_attr_src.attr, &dev_attr_src.attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment