Commit 2d8364ba authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Linus Torvalds
Browse files

kernel/reboot.c: add devm_register_reboot_notifier()

Add devm_* wrapper around register_reboot_notifier to simplify device
specific reboot notifier registration/unregistration.

[ move `struct device' forward decl to top-of-file]

Signed-off-by: default avatarAndrey Smirnov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent c512ac01
......@@ -6,6 +6,8 @@
#include <linux/notifier.h>
#include <uapi/linux/reboot.h>
struct device;
#define SYS_DOWN 0x0001 /* Notify of system down */
#define SYS_HALT 0x0002 /* Notify of system halt */
......@@ -39,6 +41,8 @@ extern int reboot_force;
extern int register_reboot_notifier(struct notifier_block *);
extern int unregister_reboot_notifier(struct notifier_block *);
extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);
extern int register_restart_handler(struct notifier_block *);
extern int unregister_restart_handler(struct notifier_block *);
extern void do_kernel_restart(char *cmd);
......@@ -104,6 +104,33 @@ int unregister_reboot_notifier(struct notifier_block *nb)
static void devm_unregister_reboot_notifier(struct device *dev, void *res)
WARN_ON(unregister_reboot_notifier(*(struct notifier_block **)res));
int devm_register_reboot_notifier(struct device *dev, struct notifier_block *nb)
struct notifier_block **rcnb;
int ret;
rcnb = devres_alloc(devm_unregister_reboot_notifier,
sizeof(*rcnb), GFP_KERNEL);
if (!rcnb)
return -ENOMEM;
ret = register_reboot_notifier(nb);
if (!ret) {
*rcnb = nb;
devres_add(dev, rcnb);
} else {
return ret;
* Notifier list for kernel code which wants to be called
* to restart the system.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment