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>
This commit is contained in:
parent
78cbcfd8b1
commit
49e50aad22
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user