From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Heiner Kallweit <hkallweit1@gmail.com>,
Pavel Machek <pavel@ucw.cz>, Lee Jones <lee@kernel.org>
Cc: "linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH] leds: trigger: panic: simplify led_trigger_set_panic
Date: Tue, 16 Jan 2024 23:44:34 +0100 [thread overview]
Message-ID: <3067e362-eee3-f338-9b64-49a33547bd3b@gmail.com> (raw)
In-Reply-To: <84c0fa67-2f03-4474-aa75-914d65d88dd0@gmail.com>
On 12/9/23 23:54, Heiner Kallweit wrote:
> I don't see why we iterate over all triggers to find the panic trigger.
> We *are* the panic trigger. Therefore we also know that the panic
> trigger doesn't have an activate() hook. So we can simplify the code
> significantly.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> drivers/leds/trigger/ledtrig-panic.c | 23 +++++++----------------
> 1 file changed, 7 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/leds/trigger/ledtrig-panic.c b/drivers/leds/trigger/ledtrig-panic.c
> index 72297a845..c646a3cbc 100644
> --- a/drivers/leds/trigger/ledtrig-panic.c
> +++ b/drivers/leds/trigger/ledtrig-panic.c
> @@ -21,24 +21,15 @@ static struct led_trigger *trigger;
> */
> static void led_trigger_set_panic(struct led_classdev *led_cdev)
> {
> - struct led_trigger *trig;
> + if (led_cdev->trigger)
> + list_del(&led_cdev->trig_list);
> + list_add_tail(&led_cdev->trig_list, &trigger->led_cdevs);
>
> - list_for_each_entry(trig, &trigger_list, next_trig) {
> - if (strcmp("panic", trig->name))
> - continue;
> - if (led_cdev->trigger)
> - list_del(&led_cdev->trig_list);
> - list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
> + /* Avoid the delayed blink path */
> + led_cdev->blink_delay_on = 0;
> + led_cdev->blink_delay_off = 0;
>
> - /* Avoid the delayed blink path */
> - led_cdev->blink_delay_on = 0;
> - led_cdev->blink_delay_off = 0;
> -
> - led_cdev->trigger = trig;
> - if (trig->activate)
> - trig->activate(led_cdev);
> - break;
> - }
> + led_cdev->trigger = trigger;
> }
>
> static int led_trigger_panic_notifier(struct notifier_block *nb,
Looks good to me.
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
--
Best regards,
Jacek Anaszewski
next prev parent reply other threads:[~2024-01-16 22:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-09 22:54 [PATCH] leds: trigger: panic: simplify led_trigger_set_panic Heiner Kallweit
2024-01-11 9:03 ` Lee Jones
2024-01-16 22:44 ` Jacek Anaszewski [this message]
2024-01-18 14:47 ` Lee Jones
2024-01-25 13:34 ` (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=3067e362-eee3-f338-9b64-49a33547bd3b@gmail.com \
--to=jacek.anaszewski@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=lee@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;
as well as URLs for NNTP newsgroup(s).