linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Cc: linux-leds@vger.kernel.org, Dan Murphy <dmurphy@ti.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: trigger: timer: Optionally stop timer trigger on reboot
Date: Sun, 25 Apr 2021 22:30:45 +0200	[thread overview]
Message-ID: <20210425203045.GB10996@amd> (raw)
In-Reply-To: <20210213154736.2905933-1-alexander.sverdlin@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2550 bytes --]

Hi!

> This functionality is similar to heartbeat and activity triggers and
> turns the timer-triggered LEDs off right before reboot. It's configurable
> via new module parameter "reboot_off" to preserve original behaviour.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>

So actual problem this solves that LED stays on during reboot?

I'd kind of expect hardware to switch the LEDs off. If hardware does
not do that, maybe the driver should?

So I'm not sure if it should be done from trigger; but if it is, it
really should not be optional.

Best regards,
								Pavel

> ---
>  drivers/leds/trigger/ledtrig-timer.c | 39 +++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/trigger/ledtrig-timer.c b/drivers/leds/trigger/ledtrig-timer.c
> index 7c14983781ee..3eadcb0a629a 100644
> --- a/drivers/leds/trigger/ledtrig-timer.c
> +++ b/drivers/leds/trigger/ledtrig-timer.c
> @@ -16,6 +16,11 @@
>  #include <linux/device.h>
>  #include <linux/ctype.h>
>  #include <linux/leds.h>
> +#include <linux/reboot.h>
> +
> +static bool reboot_off;
> +module_param(reboot_off, bool, 0444);
> +MODULE_PARM_DESC(reboot_off, "Switch LED off on reboot");
>  
>  static ssize_t led_delay_on_show(struct device *dev,
>  		struct device_attribute *attr, char *buf)
> @@ -97,7 +102,39 @@ static struct led_trigger timer_led_trigger = {
>  	.deactivate = timer_trig_deactivate,
>  	.groups = timer_trig_groups,
>  };
> -module_led_trigger(timer_led_trigger);
> +
> +static int timer_reboot_notifier(struct notifier_block *nb, unsigned long code,
> +				 void *unused)
> +{
> +	led_trigger_unregister(&timer_led_trigger);
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block timer_reboot_nb = {
> +	.notifier_call = timer_reboot_notifier,
> +};
> +
> +static int __init timer_trig_init(void)
> +{
> +	int ret;
> +
> +	ret = led_trigger_register(&timer_led_trigger);
> +	if (ret)
> +		return ret;
> +	if (reboot_off)
> +		register_reboot_notifier(&timer_reboot_nb);
> +	return 0;
> +}
> +
> +static void __exit timer_trig_exit(void)
> +{
> +	/* Not afraid of -ENOENT */
> +	unregister_reboot_notifier(&timer_reboot_nb);
> +	led_trigger_unregister(&timer_led_trigger);
> +}
> +
> +module_init(timer_trig_init);
> +module_exit(timer_trig_exit);
>  
>  MODULE_AUTHOR("Richard Purdie <rpurdie@openedhand.com>");
>  MODULE_DESCRIPTION("Timer LED trigger");

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

      reply	other threads:[~2021-04-25 20:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 15:47 [PATCH] leds: trigger: timer: Optionally stop timer trigger on reboot Alexander Sverdlin
2021-04-25 20:30 ` Pavel Machek [this message]

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=20210425203045.GB10996@amd \
    --to=pavel@ucw.cz \
    --cc=alexander.sverdlin@gmail.com \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    /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).