Re: [PATCH] leds: trigger: panic: simplify led_trigger_set_panic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Thanks Jacek.  Always helpful.

-- 
Lee Jones [李琼斯]




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux