|
@@ -104,6 +104,33 @@ int unregister_reboot_notifier(struct notifier_block *nb)
|
|
|
}
|
|
|
EXPORT_SYMBOL(unregister_reboot_notifier);
|
|
|
|
|
|
+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 {
|
|
|
+ devres_free(rcnb);
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(devm_register_reboot_notifier);
|
|
|
+
|
|
|
/*
|
|
|
* Notifier list for kernel code which wants to be called
|
|
|
* to restart the system.
|