From: "Michał Kępień" <kernel@kempniu.pl>
To: Jonathan Woithe <jwoithe@just42.net>, Darren Hart <dvhart@infradead.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] platform/x86: fujitsu-laptop: simplify logolamp_get()
Date: Mon, 9 Jan 2017 14:14:17 +0100 [thread overview]
Message-ID: <20170109131417.9677-2-kernel@kempniu.pl> (raw)
In-Reply-To: <20170109131417.9677-1-kernel@kempniu.pl>
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(-)
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
next prev parent reply other threads:[~2017-01-09 13:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-09 13:14 [PATCH v2 1/2] platform/x86: fujitsu-laptop: rework logolamp_set() to properly handle errors Michał Kępień
2017-01-09 13:14 ` Michał Kępień [this message]
2017-01-09 13:35 ` [PATCH v2 2/2] platform/x86: fujitsu-laptop: simplify logolamp_get() Jonathan Woithe
2017-01-09 13:35 ` [PATCH v2 1/2] platform/x86: fujitsu-laptop: rework logolamp_set() to properly handle errors Jonathan Woithe
2017-01-18 19:02 ` Andy Shevchenko
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=20170109131417.9677-2-kernel@kempniu.pl \
--to=kernel@kempniu.pl \
--cc=andy.shevchenko@gmail.com \
--cc=dvhart@infradead.org \
--cc=jwoithe@just42.net \
--cc=linux-kernel@vger.kernel.org \
--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