* [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern
@ 2023-10-16 15:30 Andy Shevchenko
2023-10-16 15:35 ` Hans de Goede
2023-10-19 12:20 ` (subset) " Lee Jones
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-10-16 15:30 UTC (permalink / raw)
To: Hans de Goede, linux-leds, linux-kernel
Cc: Pavel Machek, Lee Jones, Andy Shevchenko, Denis Osterland-Heim
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.
Acked-by: Denis Osterland-Heim <denis.osterland@diehl.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: added tag (Denis), Cc'ed to the updated list of LED maintainers
drivers/leds/led-core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 2230239283d0..89c9806cc97f 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);
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern
2023-10-16 15:30 [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern Andy Shevchenko
@ 2023-10-16 15:35 ` Hans de Goede
2023-10-19 12:20 ` (subset) " Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2023-10-16 15:35 UTC (permalink / raw)
To: Andy Shevchenko, linux-leds, linux-kernel
Cc: Pavel Machek, Lee Jones, Denis Osterland-Heim
Hi,
On 10/16/23 17:30, Andy Shevchenko wrote:
> 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.
>
> Acked-by: Denis Osterland-Heim <denis.osterland@diehl.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> v2: added tag (Denis), Cc'ed to the updated list of LED maintainers
> drivers/leds/led-core.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
> index 2230239283d0..89c9806cc97f 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);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: (subset) [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern
2023-10-16 15:30 [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern Andy Shevchenko
2023-10-16 15:35 ` Hans de Goede
@ 2023-10-19 12:20 ` Lee Jones
1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-10-19 12:20 UTC (permalink / raw)
To: Hans de Goede, linux-leds, linux-kernel, Andy Shevchenko
Cc: Pavel Machek, Lee Jones, Denis Osterland-Heim
On Mon, 16 Oct 2023 18:30:51 +0300, Andy Shevchenko wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] leds: core: Refactor led_update_brightness() to use standard pattern
commit: 0e5bb700df6a6fe36d9487a4e0a82a4c7b1f7b4e
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-19 12:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16 15:30 [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern Andy Shevchenko
2023-10-16 15:35 ` Hans de Goede
2023-10-19 12:20 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®