diff options
author | Brian Norris <computersforpeace@gmail.com> | 2014-11-26 04:01:08 -0500 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2015-01-07 20:54:22 -0500 |
commit | 3efe41be224c4441f2a872a25471a14d85ceb7c6 (patch) | |
tree | 4ad8e184902893b5cffa0159e0bf9fdb2ea753c2 /drivers/mtd | |
parent | 362376a7c65936835f39ff29b082a646d522efbc (diff) |
mtd: implement common reboot notifier boilerplate
cfi_cmdset_000{1,2}.c already implement their own reboot notifiers, and
we're going to add one for NAND. Let's put the boilerplate in one place.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Tested-by: Scott Branden <sbranden@broadcom.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdcore.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 4c611871d7e6..cbc0fc46d2d6 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/backing-dev.h> | 37 | #include <linux/backing-dev.h> |
38 | #include <linux/gfp.h> | 38 | #include <linux/gfp.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/reboot.h> | ||
40 | 41 | ||
41 | #include <linux/mtd/mtd.h> | 42 | #include <linux/mtd/mtd.h> |
42 | #include <linux/mtd/partitions.h> | 43 | #include <linux/mtd/partitions.h> |
@@ -365,6 +366,17 @@ static struct device_type mtd_devtype = { | |||
365 | .release = mtd_release, | 366 | .release = mtd_release, |
366 | }; | 367 | }; |
367 | 368 | ||
369 | static int mtd_reboot_notifier(struct notifier_block *n, unsigned long state, | ||
370 | void *cmd) | ||
371 | { | ||
372 | struct mtd_info *mtd; | ||
373 | |||
374 | mtd = container_of(n, struct mtd_info, reboot_notifier); | ||
375 | mtd->_reboot(mtd); | ||
376 | |||
377 | return NOTIFY_DONE; | ||
378 | } | ||
379 | |||
368 | /** | 380 | /** |
369 | * add_mtd_device - register an MTD device | 381 | * add_mtd_device - register an MTD device |
370 | * @mtd: pointer to new MTD device info structure | 382 | * @mtd: pointer to new MTD device info structure |
@@ -565,6 +577,11 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types, | |||
565 | err = -ENODEV; | 577 | err = -ENODEV; |
566 | } | 578 | } |
567 | 579 | ||
580 | if (mtd->_reboot) { | ||
581 | mtd->reboot_notifier.notifier_call = mtd_reboot_notifier; | ||
582 | register_reboot_notifier(&mtd->reboot_notifier); | ||
583 | } | ||
584 | |||
568 | return err; | 585 | return err; |
569 | } | 586 | } |
570 | EXPORT_SYMBOL_GPL(mtd_device_parse_register); | 587 | EXPORT_SYMBOL_GPL(mtd_device_parse_register); |
@@ -579,6 +596,9 @@ int mtd_device_unregister(struct mtd_info *master) | |||
579 | { | 596 | { |
580 | int err; | 597 | int err; |
581 | 598 | ||
599 | if (master->_reboot) | ||
600 | unregister_reboot_notifier(&master->reboot_notifier); | ||
601 | |||
582 | err = del_mtd_partitions(master); | 602 | err = del_mtd_partitions(master); |
583 | if (err) | 603 | if (err) |
584 | return err; | 604 | return err; |