diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2023-10-16 17:30:51 +0200 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2023-11-01 12:29:18 +0100 |
commit | 49e50aad22aebaaca3ff7abbdd462deaf16c5f35 (patch) | |
tree | e673db93587fa6b60d158d77834d8f6142b58965 /drivers/leds | |
parent | leds: turris-omnia: Fix brightness setting and trigger activating (diff) | |
download | linux-49e50aad22aebaaca3ff7abbdd462deaf16c5f35.tar.xz linux-49e50aad22aebaaca3ff7abbdd462deaf16c5f35.zip |
leds: core: Refactor led_update_brightness() to use standard pattern
The standard conditional pattern is to check for errors first and
bail out if any. Refactor led_update_brightness() accordingly.
While at it, drop unneeded assignment and return 0 unconditionally
on success.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Denis Osterland-Heim <denis.osterland@diehl.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20231016153051.1409074-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/led-core.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 742595d923ee..cedda8204c57 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -364,17 +364,17 @@ 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; + + led_cdev->brightness = ret; } - return ret; + return 0; } EXPORT_SYMBOL_GPL(led_update_brightness); |