All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <rpurdie@rpsys.net>
To: Trent Piepho <tpiepho@freescale.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Sean MacLennan <smaclennan@pikatech.com>
Subject: Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
Date: Mon, 17 Nov 2008 14:50:27 +0000	[thread overview]
Message-ID: <1226933427.17109.15.camel@ted> (raw)
In-Reply-To: <1224889741-4167-4-git-send-email-tpiepho@freescale.com>

On Fri, 2008-10-24 at 16:09 -0700, Trent Piepho wrote:
> Let GPIO LEDs get their initial value from whatever the current state of
> the GPIO line is.  On some systems the LEDs are put into some state by the
> firmware or hardware before Linux boots, and it is desired to have them
> keep this state which is otherwise unknown to Linux.
> 
> This requires that the underlying GPIO driver support reading the value of
> output GPIOs.  Some drivers support this and some do not.
> 
> The platform data for the platform device binding gets a new field
> 'keep_state' which turns this on.  keep_state overrides default_state.
> 
> For the OpenFirmware bindings, the "default-state" property gains a new
> allowable setting "keep".
> 
> Signed-off-by: Trent Piepho <tpiepho@freescale.com>
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 0dbad87..bb2a234 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -92,10 +92,13 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
>  		led_dat->cdev.blink_set = gpio_blink_set;
>  	}
>  	led_dat->cdev.brightness_set = gpio_led_set;
> -	led_dat->cdev.brightness = template->default_state ? LED_FULL : LED_OFF;
> +	if (template->keep_state)
> +		state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low;
> +	else
> +		state = template->default_state;
> +	led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
>  
> -	gpio_direction_output(led_dat->gpio,
> -	                      led_dat->active_low ^ template->default_state);
> +	gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state);
>  
>  	INIT_WORK(&led_dat->work, gpio_led_work);
>  
> @@ -266,6 +269,7 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev,
>  			of_get_property(child, "linux,default-trigger", NULL);
>  		state = of_get_property(child, "default-state", NULL);
>  		led.default_state = state && !strcmp(state, "on");
> +		led.keep_state = state && !strcmp(state, "keep");
>  
>  		ret = create_gpio_led(&led, &pdata->led_data[pdata->num_leds++],
>  				      &ofdev->dev, NULL);
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index caa3987..c51b625 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -138,7 +138,8 @@ struct gpio_led {
>  	const char *default_trigger;
>  	unsigned 	gpio;
>  	u8 		active_low;
> -	u8		default_state;
> +	u8		default_state;	/* 0 = off, 1 = on */
> +	u8		keep_state; /* overrides default_state */
>  };

How about something simpler here, just make default state have three
different values - "keep", "on" and "off"? I'm not keen on having two
different state variables like this.

Regards,

Richard

WARNING: multiple messages have this Message-ID (diff)
From: Richard Purdie <rpurdie@rpsys.net>
To: Trent Piepho <tpiepho@freescale.com>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org,
	Anton Vorontsov <avorontsov@ru.mvista.com>,
	Sean MacLennan <smaclennan@pikatech.com>,
	Wolfram Sang <w.sang@pengutronix.de>,
	Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
Date: Mon, 17 Nov 2008 14:50:27 +0000	[thread overview]
Message-ID: <1226933427.17109.15.camel@ted> (raw)
In-Reply-To: <1224889741-4167-4-git-send-email-tpiepho@freescale.com>

On Fri, 2008-10-24 at 16:09 -0700, Trent Piepho wrote:
> Let GPIO LEDs get their initial value from whatever the current state of
> the GPIO line is.  On some systems the LEDs are put into some state by the
> firmware or hardware before Linux boots, and it is desired to have them
> keep this state which is otherwise unknown to Linux.
> 
> This requires that the underlying GPIO driver support reading the value of
> output GPIOs.  Some drivers support this and some do not.
> 
> The platform data for the platform device binding gets a new field
> 'keep_state' which turns this on.  keep_state overrides default_state.
> 
> For the OpenFirmware bindings, the "default-state" property gains a new
> allowable setting "keep".
> 
> Signed-off-by: Trent Piepho <tpiepho@freescale.com>
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 0dbad87..bb2a234 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -92,10 +92,13 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
>  		led_dat->cdev.blink_set = gpio_blink_set;
>  	}
>  	led_dat->cdev.brightness_set = gpio_led_set;
> -	led_dat->cdev.brightness = template->default_state ? LED_FULL : LED_OFF;
> +	if (template->keep_state)
> +		state = !!gpio_get_value(led_dat->gpio) ^ led_dat->active_low;
> +	else
> +		state = template->default_state;
> +	led_dat->cdev.brightness = state ? LED_FULL : LED_OFF;
>  
> -	gpio_direction_output(led_dat->gpio,
> -	                      led_dat->active_low ^ template->default_state);
> +	gpio_direction_output(led_dat->gpio, led_dat->active_low ^ state);
>  
>  	INIT_WORK(&led_dat->work, gpio_led_work);
>  
> @@ -266,6 +269,7 @@ static int __devinit of_gpio_leds_probe(struct of_device *ofdev,
>  			of_get_property(child, "linux,default-trigger", NULL);
>  		state = of_get_property(child, "default-state", NULL);
>  		led.default_state = state && !strcmp(state, "on");
> +		led.keep_state = state && !strcmp(state, "keep");
>  
>  		ret = create_gpio_led(&led, &pdata->led_data[pdata->num_leds++],
>  				      &ofdev->dev, NULL);
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index caa3987..c51b625 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -138,7 +138,8 @@ struct gpio_led {
>  	const char *default_trigger;
>  	unsigned 	gpio;
>  	u8 		active_low;
> -	u8		default_state;
> +	u8		default_state;	/* 0 = off, 1 = on */
> +	u8		keep_state; /* overrides default_state */
>  };

How about something simpler here, just make default state have three
different values - "keep", "on" and "off"? I'm not keen on having two
different state variables like this.

Regards,

Richard




  parent reply	other threads:[~2008-11-17 23:03 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-24 23:04 OpenFirmware GPIO LED driver Trent Piepho
2008-10-24 23:04 ` Trent Piepho
2008-10-24 23:08 ` [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio() Trent Piepho
2008-10-24 23:08   ` Trent Piepho
2008-10-24 23:32   ` Grant Likely
2008-10-24 23:32     ` Grant Likely
2008-10-28 14:39   ` Anton Vorontsov
2008-10-28 14:39     ` Anton Vorontsov
2008-10-28 14:53     ` Grant Likely
2008-10-28 14:53       ` Grant Likely
2008-10-28 15:16       ` Anton Vorontsov
2008-10-28 15:16         ` Anton Vorontsov
2008-10-28 15:42         ` Grant Likely
2008-10-28 15:42           ` Grant Likely
2008-10-28 16:56           ` Anton Vorontsov
2008-10-28 16:56             ` Anton Vorontsov
2008-10-28 17:40             ` Grant Likely
2008-10-28 17:40               ` Grant Likely
2008-10-30  2:21     ` [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()A Trent Piepho
2008-10-30  2:21       ` Trent Piepho
2008-10-30 11:15       ` Anton Vorontsov
2008-10-30 11:15         ` Anton Vorontsov
2008-10-31  2:03         ` [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio() Trent Piepho
2008-10-31  2:03           ` Trent Piepho
2008-11-26 16:20           ` Anton Vorontsov
2008-11-26 16:20             ` Anton Vorontsov
2008-11-26 21:38             ` Paul Mackerras
2008-11-26 21:38               ` Paul Mackerras
2008-11-26 22:31               ` Anton Vorontsov
2008-11-26 22:31                 ` Anton Vorontsov
2008-11-26 22:35               ` Trent Piepho
2008-11-26 22:35                 ` Trent Piepho
2008-11-26 22:58                 ` Anton Vorontsov
2008-11-26 22:58                   ` Anton Vorontsov
2008-11-26 23:32                 ` Paul Mackerras
2008-11-26 23:32                   ` Paul Mackerras
2008-10-24 23:08 ` [PATCH 2/4] leds: Support OpenFirmware led bindings Trent Piepho
2008-10-24 23:08   ` Trent Piepho
2008-10-24 23:50   ` Grant Likely
2008-10-24 23:50     ` Grant Likely
2008-10-24 23:09 ` [PATCH 3/4] leds: Add option to have GPIO LEDs start on Trent Piepho
2008-10-24 23:09   ` Trent Piepho
2008-10-24 23:59   ` Grant Likely
2008-10-24 23:59     ` Grant Likely
2008-10-24 23:09 ` [PATCH 4/4] leds: Let GPIO LEDs keep their current state Trent Piepho
2008-10-24 23:09   ` Trent Piepho
2008-10-25  0:04   ` Grant Likely
2008-10-25  0:04     ` Grant Likely
2008-11-17 14:50   ` Richard Purdie [this message]
2008-11-17 14:50     ` Richard Purdie
2008-11-21  1:05     ` Trent Piepho
2008-11-21  1:05       ` Trent Piepho
2008-11-23 12:31       ` Pavel Machek
2008-11-23 12:31         ` Pavel Machek
2008-12-03 10:04         ` Richard Purdie
2008-12-03 10:04           ` Richard Purdie
2008-12-10  4:33           ` Trent Piepho
2008-12-10  4:33             ` Trent Piepho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1226933427.17109.15.camel@ted \
    --to=rpurdie@rpsys.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=smaclennan@pikatech.com \
    --cc=tpiepho@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.