All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: leds-pwm: Set led_classdev max_brightness
@ 2009-11-27  5:17 Lars-Peter Clausen
  2009-11-27  7:44 ` Luotao Fu
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2009-11-27  5:17 UTC (permalink / raw)
  To: rpurdie; +Cc: l.fu, linux-kernel, Lars-Peter Clausen

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: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/leds/leds-pwm.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index cdfdc87..88b1dd0 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -27,7 +27,6 @@ struct led_pwm_data {
 	struct pwm_device	*pwm;
 	unsigned int 		active_low;
 	unsigned int		period;
-	unsigned int		max_brightness;
 };
 
 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 =
 		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;
 
 	if (brightness == 0) {
@@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev)
 		led_dat->cdev.name = cur_led->name;
 		led_dat->cdev.default_trigger = cur_led->default_trigger;
 		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->cdev.brightness_set = led_pwm_set;
 		led_dat->cdev.brightness = LED_OFF;
+		led_dat->cdev.max_brightness = cur_led->max_brightness;
 		led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
 
 		ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] leds: leds-pwm: Set led_classdev max_brightness
  2009-11-27  5:17 [PATCH] leds: leds-pwm: Set led_classdev max_brightness Lars-Peter Clausen
@ 2009-11-27  7:44 ` Luotao Fu
  0 siblings, 0 replies; 2+ messages in thread
From: Luotao Fu @ 2009-11-27  7:44 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: rpurdie, l.fu, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2802 bytes --]

Hi Lars-Peter,

On Fri, Nov 27, 2009 at 06:17:38AM +0100, Lars-Peter Clausen wrote:
> 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: Lars-Peter Clausen <lars@metafoo.de>

Thanks for the patch, however Pls note that the pwm framework has seen
some major changes by Bill Gatliff, including this driver, see
http://lwn.net/Articles/357837/
The patches are pending, but it's quite possible that this driver will
become obsolete soon.
for the patch it self:

Acked-by: Luotao Fu <l.fu@pengutronix.de>

> ---
>  drivers/leds/leds-pwm.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index cdfdc87..88b1dd0 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -27,7 +27,6 @@ struct led_pwm_data {
>  	struct pwm_device	*pwm;
>  	unsigned int 		active_low;
>  	unsigned int		period;
> -	unsigned int		max_brightness;
>  };
>  
>  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 =
>  		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;
>  
>  	if (brightness == 0) {
> @@ -77,10 +76,10 @@ static int led_pwm_probe(struct platform_device *pdev)
>  		led_dat->cdev.name = cur_led->name;
>  		led_dat->cdev.default_trigger = cur_led->default_trigger;
>  		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->cdev.brightness_set = led_pwm_set;
>  		led_dat->cdev.brightness = LED_OFF;
> +		led_dat->cdev.max_brightness = cur_led->max_brightness;
>  		led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME;
>  
>  		ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
> -- 
> 1.5.6.5
> 

cheers
Luotao Fu
-- 
Pengutronix e.K.                           | Dipl.-Ing. Luotao Fu        |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-11-27  7:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-27  5:17 [PATCH] leds: leds-pwm: Set led_classdev max_brightness Lars-Peter Clausen
2009-11-27  7:44 ` Luotao Fu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.