From: Hans de Goede <hdegoede@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>,
Denis Osterland-Heim <denis.osterland@diehl.com>
Subject: Re: [PATCH v2 1/1] leds: core: Refactor led_update_brightness() to use standard pattern
Date: Mon, 16 Oct 2023 17:35:38 +0200 [thread overview]
Message-ID: <19399d81-d61c-9287-3081-e1da5a833984@redhat.com> (raw)
In-Reply-To: <20231016153051.1409074-1-andriy.shevchenko@linux.intel.com>
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);
>
next prev parent reply other threads:[~2023-10-16 15:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 15:30 Andy Shevchenko
2023-10-16 15:35 ` Hans de Goede [this message]
2023-10-19 12:20 ` (subset) " Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=19399d81-d61c-9287-3081-e1da5a833984@redhat.com \
--to=hdegoede@redhat.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=denis.osterland@diehl.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®