From: Lee Jones <lee@kernel.org>
To: Heiner Kallweit <hkallweit1@gmail.com>, ezequiel@vanguardiasur.com.ar
Cc: Pavel Machek <pavel@ucw.cz>,
"linux-leds@vger.kernel.org" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH] leds: trigger: panic: simplify led_trigger_set_panic
Date: Thu, 11 Jan 2024 09:03:28 +0000 [thread overview]
Message-ID: <20240111090328.GK7948@google.com> (raw)
In-Reply-To: <84c0fa67-2f03-4474-aa75-914d65d88dd0@gmail.com>
On Sat, 09 Dec 2023, 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(-)
I would like to take a little advice from the author here who should
have been Cc:ed. In case there is information we're missing or
overseeing.
> 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,
> --
> 2.43.0
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2024-01-11 9:03 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 [this message]
2024-01-16 22:44 ` Jacek Anaszewski
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=20240111090328.GK7948@google.com \
--to=lee@kernel.org \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=hkallweit1@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.