Re: [PATCH v2] leds: heartbeat: stop on shutdown

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


Am 24.04.2012 17:24, schrieb Shuah Khan:
> On Tue, 2012-04-24 at 17:07 +0200, Alexander Holler wrote:
>> A halted kernel should not show a heartbeat.
>>
>> Signed-off-by: Alexander Holler <holler@xxxxxxxxxxxxx>
>> ---
>>  drivers/leds/ledtrig-heartbeat.c |   18 +++++++++++++++++-
>>  1 files changed, 17 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/leds/ledtrig-heartbeat.c b/drivers/leds/ledtrig-heartbeat.c
>> index 759c0bb..1c05bd9 100644
>> --- a/drivers/leds/ledtrig-heartbeat.c
>> +++ b/drivers/leds/ledtrig-heartbeat.c
>> @@ -18,6 +18,7 @@
>>  #include <linux/timer.h>
>>  #include <linux/sched.h>
>>  #include <linux/leds.h>
>> +#include <linux/reboot.h>
>>  #include "leds.h"
>>  
>>  struct heartbeat_trig_data {
>> @@ -101,13 +102,28 @@ static struct led_trigger heartbeat_led_trigger = {
>>  	.deactivate = heartbeat_trig_deactivate,
>>  };
>>  
>> +static int heartbeat_reboot_notifier(struct notifier_block *nb,
>> +				     unsigned long code, void *unused)
>> +{
>> +	led_trigger_unregister(&heartbeat_led_trigger);
>> +	return NOTIFY_DONE;
>> +}
>> +
>> +static struct notifier_block heartbeat_reboot_nb = {
>> +	.notifier_call = heartbeat_reboot_notifier,
>> +};
>> +
>>  static int __init heartbeat_trig_init(void)
>>  {
>> -	return led_trigger_register(&heartbeat_led_trigger);
>> +	int rc = led_trigger_register(&heartbeat_led_trigger);
>> +	if( ! rc )
>> +		register_reboot_notifier(&heartbeat_reboot_nb);
> 
> Do you need to check return value here? I see return value being checked
> in some places in the kernel and not in others. Not checking is fine for
> now since register_reboot_notifier() always returns 0.
> 
> Maybe adding return handling might not be a bad idea to be consistent
> with other places that do check.

What to do if it fails? As long as unregister_reboot_notifier() doesn't
do something bad with non-registered notifiers (which it doesn't), I
would let the init still succeed. And to not unregister a
non-registered-reboot_notifier, a long-living bool would be needed.

> FYI - Andrew Morton is handling led patches these days. You might want
> to send include him  <akpm@xxxxxxxxxxxxxxxxxxxx>

I have added him to CC, thanks.

Regards,

Alexander
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Kbuild]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Netdev]     [Git]     [Linux PCI]     Linux CAN Development     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [AutoFS]     [Filesystem Development]     [Ext3 Filesystem]     [Linux bcache]     [Ext4 Filesystem]     [Linux BTRFS]     [Linux CEPH Filesystem]     [Linux XFS]     [XFS]     [Linux NFS]     [Linux CIFS]     [Ecryptfs]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Linux FB Devel]     [Linux OpenGL]     [DRI Devel]     [Fastboot]     [Linux RT Users]     [Linux RT Stable]     [eCos]     [Corosync]     [Linux Clusters]     [LVS Devel]     [Hot Plug]     [Linux Virtualization]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Linux Hexagon]     [Linux Cgroups]     [Util Linux]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Linux IIO]     [Sparse]     [Smatch]     [Linux Arch]     [x86 Platform Driver]     [Linux ACPI]     [Linux IBM ACPI]     [LM Sensors]     [CPU Freq]     [Linux Power Management]     [Linmodems]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Tegra Devel]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux SCSI]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Trace Users]     [Linux Btrace]     [Linux Watchdog]     [Utrace Devel]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Linux Kernel Debugger]     [Linux gcc]     [Gcc Help]     [X.Org]     [Wine]

Add to Google Powered by Linux

[Older Kernel Discussion]     [Yosemite National Park Forum]     [Large Format Photos]     [Gimp]     [Yosemite Photos]     [Stuff]