diff mbox

[v2,2/2] platform/x86: fujitsu-laptop: simplify logolamp_get()

Message ID 20170109131417.9677-2-kernel@kempniu.pl (mailing list archive)
State Accepted, archived
Delegated to: Andy Shevchenko
Headers show

Commit Message

Michał Kępień Jan. 9, 2017, 1:14 p.m. UTC
Now that call_fext_func() is invoked by logolamp_set() for both
LOGOLAMP_POWERON and LOGOLAMP_ALWAYS for every brightness value,
logolamp_get() can be simplified to decrease indentation and number of
local variables.

Signed-off-by: Michał Kępień <kernel@kempniu.pl>
---
Changes from v1:

  - This patch was not present in v1.
    
One thing worth noting is that in case call_fext_func() returns an
error, logolamp_get() will still return LED_OFF, just like the original
version.

 drivers/platform/x86/fujitsu-laptop.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Jonathan Woithe Jan. 9, 2017, 1:35 p.m. UTC | #1
On Mon, Jan 09, 2017 at 02:14:17PM +0100, Micha?? K??pie?? wrote:
> Now that call_fext_func() is invoked by logolamp_set() for both
> LOGOLAMP_POWERON and LOGOLAMP_ALWAYS for every brightness value,
> logolamp_get() can be simplified to decrease indentation and number of
> local variables.
> 
> Signed-off-by: Micha?? K??pie?? <kernel@kempniu.pl>

Seems sensible to me.

Acked-by: Jonathan Woithe <jwoithe@just42.net>

> ---
> Changes from v1:
> 
>   - This patch was not present in v1.
>     
> One thing worth noting is that in case call_fext_func() returns an
> error, logolamp_get() will still return LED_OFF, just like the original
> version.
> 
>  drivers/platform/x86/fujitsu-laptop.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 34b8481fb0ed..7fa082558a42 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -319,17 +319,17 @@ static int eco_led_set(struct led_classdev *cdev,
>  
>  static enum led_brightness logolamp_get(struct led_classdev *cdev)
>  {
> -	enum led_brightness brightness = LED_OFF;
> -	int poweron, always;
> -
> -	poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
> -	if (poweron == FUNC_LED_ON) {
> -		brightness = LED_HALF;
> -		always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
> -		if (always == FUNC_LED_ON)
> -			brightness = LED_FULL;
> -	}
> -	return brightness;
> +	int ret;
> +
> +	ret = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
> +	if (ret == FUNC_LED_ON)
> +		return LED_FULL;
> +
> +	ret = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
> +	if (ret == FUNC_LED_ON)
> +		return LED_HALF;
> +
> +	return LED_OFF;
>  }
>  
>  static enum led_brightness kblamps_get(struct led_classdev *cdev)
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index 34b8481fb0ed..7fa082558a42 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -319,17 +319,17 @@  static int eco_led_set(struct led_classdev *cdev,
 
 static enum led_brightness logolamp_get(struct led_classdev *cdev)
 {
-	enum led_brightness brightness = LED_OFF;
-	int poweron, always;
-
-	poweron = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
-	if (poweron == FUNC_LED_ON) {
-		brightness = LED_HALF;
-		always = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
-		if (always == FUNC_LED_ON)
-			brightness = LED_FULL;
-	}
-	return brightness;
+	int ret;
+
+	ret = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
+	if (ret == FUNC_LED_ON)
+		return LED_FULL;
+
+	ret = call_fext_func(FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
+	if (ret == FUNC_LED_ON)
+		return LED_HALF;
+
+	return LED_OFF;
 }
 
 static enum led_brightness kblamps_get(struct led_classdev *cdev)