All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>,
	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, 18 Jan 2024 14:47:04 +0000	[thread overview]
Message-ID: <20240118144704.GB3305748@google.com> (raw)
In-Reply-To: <3067e362-eee3-f338-9b64-49a33547bd3b@gmail.com>

On Tue, 16 Jan 2024, Jacek Anaszewski wrote:

> 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>

Thanks Jacek.  Always helpful.

-- 
Lee Jones [李琼斯]

  reply	other threads:[~2024-01-18 14:47 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
2024-01-18 14:47   ` Lee Jones [this message]
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=20240118144704.GB3305748@google.com \
    --to=lee@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=jacek.anaszewski@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.