Skip to content

Commit

Permalink
Merge branch 'fixes-for-3.5' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/cooloney/linux-leds

Pull leds fix from Bryan Wu:
 "Fix for heartbeat led trigger driver"

* 'fixes-for-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  leds: heartbeat: fix bug on panic
  • Loading branch information
Linus Torvalds committed Jul 5, 2012
2 parents 5eecb9c + fb31fbe commit 24eee62
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion drivers/leds/ledtrig-heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <linux/reboot.h>
#include "leds.h"

static int panic_heartbeats;

struct heartbeat_trig_data {
unsigned int phase;
unsigned int period;
Expand All @@ -34,6 +36,11 @@ static void led_heartbeat_function(unsigned long data)
unsigned long brightness = LED_OFF;
unsigned long delay = 0;

if (unlikely(panic_heartbeats)) {
led_set_brightness(led_cdev, LED_OFF);
return;
}

/* acts like an actual heart beat -- ie thump-thump-pause... */
switch (heartbeat_data->phase) {
case 0:
Expand Down Expand Up @@ -111,12 +118,19 @@ static int heartbeat_reboot_notifier(struct notifier_block *nb,
return NOTIFY_DONE;
}

static int heartbeat_panic_notifier(struct notifier_block *nb,
unsigned long code, void *unused)
{
panic_heartbeats = 1;
return NOTIFY_DONE;
}

static struct notifier_block heartbeat_reboot_nb = {
.notifier_call = heartbeat_reboot_notifier,
};

static struct notifier_block heartbeat_panic_nb = {
.notifier_call = heartbeat_reboot_notifier,
.notifier_call = heartbeat_panic_notifier,
};

static int __init heartbeat_trig_init(void)
Expand Down

0 comments on commit 24eee62

Please sign in to comment.