leds: led-class: add support for max_brightness store

Add store interface for max_brightness to allow users
to change the maximum brightness to be supported by
the hardware.

Change-Id: I8b65debdc52ded24227483c4db21aaec63e27927
Signed-off-by: Mohan Pallaka <mpallaka@codeaurora.org>
Signed-off-by: Manaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
This commit is contained in:
Mohan Pallaka 2015-02-23 16:41:47 -08:00 committed by Archana Sriram
parent 00c6e542bb
commit 0ba12a1e95

View File

@ -72,7 +72,24 @@ static ssize_t max_brightness_show(struct device *dev,
return sprintf(buf, "%u\n", led_cdev->max_brightness);
}
static DEVICE_ATTR_RO(max_brightness);
static ssize_t max_brightness_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
unsigned long state;
ssize_t ret = -EINVAL;
ret = kstrtoul(buf, 10, &state);
if (ret)
return ret;
led_cdev->max_brightness = state;
led_set_brightness(led_cdev, led_cdev->brightness);
return size;
}
static DEVICE_ATTR_RW(max_brightness);
#ifdef CONFIG_LEDS_TRIGGERS
static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);