* [PATCH v1] leds: core: Refactor led_update_brightness()
@ 2019-08-22 15:25 Andy Shevchenko
2019-08-22 15:31 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2019-08-22 15:25 UTC (permalink / raw)
To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds; +Cc: Andy Shevchenko
There is neither need to have an additional assignment of ret, nor
the non-so-standard conditional. Moreover, the resulting code better to read
and less LOCs.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/leds/led-core.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index f1f718dbe0f8..810053fbe0f6 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -308,17 +308,16 @@ EXPORT_SYMBOL_GPL(led_set_brightness_sync);
int led_update_brightness(struct led_classdev *led_cdev)
{
- int ret = 0;
+ int ret;
if (led_cdev->brightness_get) {
ret = led_cdev->brightness_get(led_cdev);
- if (ret >= 0) {
- led_cdev->brightness = ret;
- return 0;
- }
+ if (ret < 0)
+ return ret;
}
- return ret;
+ led_cdev->brightness = ret;
+ return 0;
}
EXPORT_SYMBOL_GPL(led_update_brightness);
--
2.23.0.rc1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] leds: core: Refactor led_update_brightness()
2019-08-22 15:25 [PATCH v1] leds: core: Refactor led_update_brightness() Andy Shevchenko
@ 2019-08-22 15:31 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2019-08-22 15:31 UTC (permalink / raw)
To: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds
On Thu, Aug 22, 2019 at 06:25:39PM +0300, Andy Shevchenko wrote:
> There is neither need to have an additional assignment of ret, nor
> the non-so-standard conditional. Moreover, the resulting code better to read
> and less LOCs.
Please, ignore this, it's not correct in this form.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-22 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22 15:25 [PATCH v1] leds: core: Refactor led_update_brightness() Andy Shevchenko
2019-08-22 15:31 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).