aboutsummaryrefslogtreecommitdiff
path: root/drivers/leds
diff options
context:
space:
mode:
authorAndy Shevchenko2023-10-16 18:30:51 +0300
committerLee Jones2023-11-01 11:29:18 +0000
commit49e50aad22aebaaca3ff7abbdd462deaf16c5f35 (patch)
treee673db93587fa6b60d158d77834d8f6142b58965 /drivers/leds
parent78cbcfd8b13cefe089296d053f222934a53e153d (diff)
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.c12
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);