From: pavel@ucw.cz (Pavel Machek)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] leds: triggers: Allow to switch the trigger to "panic" on a kernel panic
Date: Sun, 24 Apr 2016 11:29:51 +0200 [thread overview]
Message-ID: <20160424092951.GA25596@amd> (raw)
In-Reply-To: <20160424092551.GB23015@amd>
On Sun 2016-04-24 11:25:51, Pavel Machek wrote:
> On Mon 2016-04-04 17:22:02, Ezequiel Garcia wrote:
> > This commit adds a new led_cdev flag LED_BLINK_AT_PANIC, which
> > allows to mark a specific LED to be switched to the "panic"
> > trigger, on a kernel panic.
> >
> > This is useful to allow the user to assign a regular trigger
> > to a given LED, and still blink that LED on a kernel panic.
> >
> > Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
>
>
> > drivers/leds/led-triggers.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/leds.h | 1 +
>
> Could we get this out of the core? I'm pretty sure most users are not
> interested...
Thinking about it some more....
This is not really a trigger. This is very special. Maybe hard-coded
handling, like we do for keyboard leds on x86 would be suitable?
>
> Pavel
>
> > +/*
> > + * This is a called in a special context by the atomic panic
> > + * notifier. This means the trigger can be changed without
> > + * worrying about locking.
> > + */
> > +static void led_trigger_set_panic(struct led_classdev *led_cdev)
> > +{
> > + struct led_trigger *trig;
> > +
> > + 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);
> > + led_cdev->trigger = trig;
> > + if (trig->activate)
> > + trig->activate(led_cdev);
> > + break;
> > + }
> > +}
> > +
> > +static int led_trigger_panic_notifier(struct notifier_block *nb,
> > + unsigned long code, void *unused)
> > +{
> > + struct led_classdev *led_cdev;
> > +
> > + list_for_each_entry(led_cdev, &leds_list, node)
> > + if (led_cdev->flags & LED_BLINK_AT_PANIC)
> > + led_trigger_set_panic(led_cdev);
> > + return NOTIFY_DONE;
> > +}
> > +
> > +static struct notifier_block led_trigger_panic_nb = {
> > + .notifier_call = led_trigger_panic_notifier,
> > +};
> > +
> > void led_trigger_set_default(struct led_classdev *led_cdev)
> > {
> > struct led_trigger *trig;
> > @@ -356,6 +393,21 @@ void led_trigger_unregister_simple(struct led_trigger *trig)
> > }
> > EXPORT_SYMBOL_GPL(led_trigger_unregister_simple);
> >
> > +static int __init leds_trigger_init(void)
> > +{
> > + atomic_notifier_chain_register(&panic_notifier_list,
> > + &led_trigger_panic_nb);
> > + return 0;
> > +}
> > +
> > +static void __exit leds_trigger_exit(void)
> > +{
> > + atomic_notifier_chain_unregister(&panic_notifier_list,
> > + &led_trigger_panic_nb);
> > +}
> > +module_init(leds_trigger_init);
> > +module_exit(leds_trigger_exit);
> > +
> > MODULE_AUTHOR("Richard Purdie");
> > MODULE_LICENSE("GPL");
> > MODULE_DESCRIPTION("LED Triggers Core");
> > diff --git a/include/linux/leds.h b/include/linux/leds.h
> > index f203a8f89d30..7f1428bb1e69 100644
> > --- a/include/linux/leds.h
> > +++ b/include/linux/leds.h
> > @@ -50,6 +50,7 @@ struct led_classdev {
> > #define LED_SYSFS_DISABLE (1 << 22)
> > #define LED_DEV_CAP_FLASH (1 << 23)
> > #define LED_HW_PLUGGABLE (1 << 24)
> > +#define LED_BLINK_AT_PANIC (1 << 25)
> >
> > /* Set LED brightness level
> > * Must not sleep. Use brightness_set_blocking for drivers
>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
next prev parent reply other threads:[~2016-04-24 9:29 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 20:22 [PATCH 0/5] Extend the LED panic trigger Ezequiel Garcia
2016-04-04 20:22 ` [PATCH 1/5] leds: triggers: Allow to switch the trigger to "panic" on a kernel panic Ezequiel Garcia
2016-04-05 21:36 ` Jacek Anaszewski
2016-04-24 9:25 ` Pavel Machek
2016-04-24 9:29 ` Pavel Machek [this message]
2016-04-25 6:56 ` Jacek Anaszewski
2016-04-25 16:27 ` Ezequiel Garcia
2016-04-26 7:15 ` Jacek Anaszewski
2016-04-27 20:10 ` Ezequiel Garcia
2016-05-02 7:06 ` Pavel Machek
2016-04-04 20:22 ` [PATCH 2/5] leds: triggers: Add a led_trigger_event_nosleep API Ezequiel Garcia
2016-04-05 21:36 ` Jacek Anaszewski
2016-04-06 4:38 ` Ezequiel Garcia
2016-04-06 6:12 ` Jacek Anaszewski
2016-04-04 20:22 ` [PATCH 3/5] leds: trigger: panic: Use led_trigger_event_nosleep Ezequiel Garcia
2016-04-04 20:22 ` [PATCH 4/5] devicetree: leds: Introduce "panic-blink" optional property Ezequiel Garcia
2016-04-05 21:37 ` Jacek Anaszewski
2016-04-06 4:39 ` Ezequiel Garcia
2016-04-06 15:12 ` Rob Herring
2016-04-06 16:13 ` Ezequiel Garcia
2016-04-04 20:22 ` [PATCH 5/5] leds: gpio: Support the panic-blink firmware property Ezequiel Garcia
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=20160424092951.GA25596@amd \
--to=pavel@ucw.cz \
--cc=linux-arm-kernel@lists.infradead.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).