leds: core: Refactor led_update_brightness()
PATCH 1/1 leds: core: Refactor led_update_brightness()
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 <[email protected]>
--- drivers/leds/led-core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/leds/led-core.c +5 -6
@@ -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);
Signature · 1 line
2.23.0.rc1
Quoted 3 lines · 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.
Please, ignore this, it's not correct in this form.
Signature · 2 lines
With Best Regards, Andy Shevchenko