Commit e4590620 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Richard Purdie

leds: leds-pwm: Set led_classdev max_brightness

Currently the driver leds-pwm doesn't set max_brightness for the led device
although it's platform data proides a maximum brightness. Instead it stores its
own private driver struct. The max_brightness defaults to 255 for led device if
it has not been set.
As a result any leds-pwm device with a different maximum brightness will show
incorrect behavior, as it is posible to either set a longer then period duty
time or not be able to switch the led to full brightness.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
parent 19981115
...@@ -27,7 +27,6 @@ struct led_pwm_data { ...@@ -27,7 +27,6 @@ struct led_pwm_data {
struct pwm_device *pwm; struct pwm_device *pwm;
unsigned int active_low; unsigned int active_low;
unsigned int period; unsigned int period;
unsigned int max_brightness;
}; };
static void led_pwm_set(struct led_classdev *led_cdev, static void led_pwm_set(struct led_classdev *led_cdev,
...@@ -35,7 +34,7 @@ static void led_pwm_set(struct led_classdev *led_cdev, ...@@ -35,7 +34,7 @@ static void led_pwm_set(struct led_classdev *led_cdev,
{ {
struct led_pwm_data *led_dat = struct led_pwm_data *led_dat =
container_of(led_cdev, struct led_pwm_data, cdev); container_of(led_cdev, struct led_pwm_data, cdev);
unsigned int max = led_dat->max_brightness; unsigned int max = led_dat->cdev.max_brightness;
unsigned int period = led_dat->period; unsigned int period = led_dat->period;
if (brightness == 0) { if (brightness == 0) {
...@@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev) ...@@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev)
led_dat->cdev.name = cur_led->name; led_dat->cdev.name = cur_led->name;
led_dat->cdev.default_trigger = cur_led->default_trigger; led_dat->cdev.default_trigger = cur_led->default_trigger;
led_dat->active_low = cur_led->active_low; led_dat->active_low = cur_led->active_low;
led_dat->max_brightness = cur_led->max_brightness;
led_dat->period = cur_led->pwm_period_ns; led_dat->period = cur_led->pwm_period_ns;
led_dat->cdev.brightness_set = led_pwm_set; led_dat->cdev.brightness_set = led_pwm_set;
led_dat->cdev.brightness = LED_OFF; led_dat->cdev.brightness = LED_OFF;
led_dat->cdev.max_brightness = cur_led->max_brightness;
led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
ret = led_classdev_register(&pdev->dev, &led_dat->cdev); ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
......
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