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

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
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -192,13 +192,13 @@ static int store_color_common(struct device *dev, const char *buf, int color)
	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)
{
	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)
{
	int ret;
@@ -209,15 +209,15 @@ 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_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)
{
	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)
{

@@ -229,15 +229,15 @@ 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_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)
{
	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)
{
	int ret;
@@ -248,16 +248,16 @@ 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_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)
{
	return scnprintf(buf, PAGE_SIZE,
			 "#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)
{

@@ -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_RW(test);

/* TODO: HSB, fade, timeadj, script ... */

+5 −5
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ 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 led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -365,7 +365,7 @@ static ssize_t lm3530_mode_get(struct device *dev,
	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)
{
	struct led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -397,7 +397,7 @@ static ssize_t lm3530_mode_set(struct device *dev, struct device_attribute

	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[] = {
	&dev_attr_mode.attr,
+4 −4
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ static int lm355x_indicator_brightness_set(struct led_classdev *cdev,
}

/* 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,
			     const char *buf, size_t size)
{
@@ -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_WO(pattern);

static struct attribute *lm355x_indicator_attrs[] = {
	&dev_attr_pattern.attr,
+8 −8
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ static int lm3642_control(struct lm3642_chip_data *chip,
/* torch */

/* 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,
			       const char *buf, size_t size)
{
@@ -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_WO(torch_pin);

static int lm3642_torch_brightness_set(struct led_classdev *cdev,
					enum led_brightness brightness)
@@ -212,7 +212,7 @@ static int lm3642_torch_brightness_set(struct led_classdev *cdev,
/* flash */

/* 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,
				const char *buf, size_t size)
{
@@ -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_WO(strobe_pin);

static int lm3642_strobe_brightness_set(struct led_classdev *cdev,
					 enum led_brightness brightness)
+6 −6
Original line number Diff line number Diff line
@@ -160,7 +160,7 @@ 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 led_classdev *led_cdev = dev_get_drvdata(dev);
@@ -193,7 +193,7 @@ static ssize_t max8997_led_show_mode(struct device *dev,
	return ret;
}

static ssize_t max8997_led_store_mode(struct device *dev,
static ssize_t mode_store(struct device *dev,
			  struct device_attribute *attr,
			  const char *buf, size_t size)
{
@@ -222,7 +222,7 @@ static ssize_t max8997_led_store_mode(struct device *dev,
	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[] = {
	&dev_attr_mode.attr,
Loading