mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Woithe <jwoithe@just42.net>
To: Matej Groma <matejgroma@gmail.com>
Cc: dvhart@infradead.org, platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] fujitsu-laptop: Unify max brightness of exported leds
Date: Thu, 30 Jun 2016 22:30:57 +0930	[thread overview]
Message-ID: <20160630130057.GE32030@marvin.atrad.com.au> (raw)
In-Reply-To: <20160629072758.GA2778@Matej-PC.localdomain>

On Wed, Jun 29, 2016 at 09:28:03AM +0200, Matej Groma wrote:
> Exported leds had maximum brightness previously unset, thus having
> value 255. Set maximum brightness of leds that can only be turned
> off or on to 1, making the behavior more consistent with other leds
> having binary state.

I understand the motivation here.  Is this change consistent with the LED
API though?  Currently for the binary state Fujitsu LEDs, LED_OFF (0) means
off and LED_FULL (255) means on.  It seems to me that this is the most
obvious way to use the LED API with binary state LEDs.  This patch changes
the "on" brightness to 1, which is clearly not LED_FULL (it does however
match the max_brightness configured for the LED).  Thus there is an
inconsistency: the brightness isn't LED_FULL but in reality the LED is as
bright as it goes.  Could this create problems within the LED subsystem, or
is there nothing special attached to the LED_FULL value?  A quick look
through the leds driver didn't turn up anything obvious, but I might have
missed some subtlties.

Darren: any thoughts?

Regards
  jonathan

> Signed-off-by: Matej Groma <matejgroma@gmail.com>
> ---
> Changes from v1:
> 	made commit message more clear
> 	rebased on testing
> 
>  drivers/platform/x86/fujitsu-laptop.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 6ce8e78..abb7c62 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -192,6 +192,7 @@ static void kblamps_set(struct led_classdev *cdev,
> 
>  static struct led_classdev kblamps_led = {
>   .name = "fujitsu::kblamps",
> + .max_brightness = 1,
>   .brightness_get = kblamps_get,
>   .brightness_set = kblamps_set
>  };
> @@ -202,6 +203,7 @@ static void radio_led_set(struct led_classdev *cdev,
> 
>  static struct led_classdev radio_led = {
>   .name = "fujitsu::radio_led",
> + .max_brightness = 1,
>   .brightness_get = radio_led_get,
>   .brightness_set = radio_led_set
>  };
> @@ -285,7 +287,7 @@ static void logolamp_set(struct led_classdev *cdev,
>  static void kblamps_set(struct led_classdev *cdev,
>  			       enum led_brightness brightness)
>  {
> -	if (brightness >= LED_FULL)
> +	if (brightness)
>  		call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_ON);
>  	else
>  		call_fext_func(FUNC_LEDS, 0x1, KEYBOARD_LAMPS, FUNC_LED_OFF);
> @@ -294,7 +296,7 @@ static void kblamps_set(struct led_classdev *cdev,
>  static void radio_led_set(struct led_classdev *cdev,
>  				enum led_brightness brightness)
>  {
> -	if (brightness >= LED_FULL)
> +	if (brightness)
>  		call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, RADIO_LED_ON);
>  	else
>  		call_fext_func(FUNC_RFKILL, 0x5, RADIO_LED_ON, 0x0);
> @@ -332,7 +334,7 @@ static enum led_brightness kblamps_get(struct led_classdev *cdev)
>  	enum led_brightness brightness = LED_OFF;
> 
>  	if (call_fext_func(FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
> -		brightness = LED_FULL;
> +		brightness = cdev->max_brightness;
> 
>  	return brightness;
>  }
> @@ -342,7 +344,7 @@ static enum led_brightness radio_led_get(struct led_classdev *cdev)
>  	enum led_brightness brightness = LED_OFF;
> 
>  	if (call_fext_func(FUNC_RFKILL, 0x4, 0x0, 0x0) & RADIO_LED_ON)
> -		brightness = LED_FULL;
> +		brightness = cdev->max_brightness;
> 
>  	return brightness;
>  }

-- 

  reply	other threads:[~2016-06-30 13:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29  7:28 Matej Groma
2016-06-30 13:00 ` Jonathan Woithe [this message]
2016-07-01 19:19   ` Darren Hart
2016-07-01 21:29     ` Matej Groma
2016-07-03 23:35       ` Jonathan Woithe

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=20160630130057.GE32030@marvin.atrad.com.au \
    --to=jwoithe@just42.net \
    --cc=dvhart@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matejgroma@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®