aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-03-03 21:16:48 -0500
committerDavid S. Miller <davem@davemloft.net>2015-03-03 21:16:48 -0500
commit71a83a6db6138b9d41d8a0b6b91cb59f6dc4742c (patch)
treef74b6e4e48257ec6ce40b95645ecb8533b9cc1f8 /drivers/mtd/mtdcore.c
parentb97526f3ff95f92b107f0fb52cbb8627e395429b (diff)
parenta6c5170d1edea97c538c81e377e56c7b5c5b7e63 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Conflicts: drivers/net/ethernet/rocker/rocker.c The rocker commit was two overlapping changes, one to rename the ->vport member to ->pport, and another making the bitmask expression use '1ULL' instead of plain '1'. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 0ec4d6ea1e4b..11883bd26d9d 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>
@@ -356,6 +357,17 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd)
356EXPORT_SYMBOL_GPL(mtd_mmap_capabilities); 357EXPORT_SYMBOL_GPL(mtd_mmap_capabilities);
357#endif 358#endif
358 359
360static int mtd_reboot_notifier(struct notifier_block *n, unsigned long state,
361 void *cmd)
362{
363 struct mtd_info *mtd;
364
365 mtd = container_of(n, struct mtd_info, reboot_notifier);
366 mtd->_reboot(mtd);
367
368 return NOTIFY_DONE;
369}
370
359/** 371/**
360 * add_mtd_device - register an MTD device 372 * add_mtd_device - register an MTD device
361 * @mtd: pointer to new MTD device info structure 373 * @mtd: pointer to new MTD device info structure
@@ -544,6 +556,19 @@ int mtd_device_parse_register(struct mtd_info *mtd, const char * const *types,
544 err = -ENODEV; 556 err = -ENODEV;
545 } 557 }
546 558
559 /*
560 * FIXME: some drivers unfortunately call this function more than once.
561 * So we have to check if we've already assigned the reboot notifier.
562 *
563 * Generally, we can make multiple calls work for most cases, but it
564 * does cause problems with parse_mtd_partitions() above (e.g.,
565 * cmdlineparts will register partitions more than once).
566 */
567 if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) {
568 mtd->reboot_notifier.notifier_call = mtd_reboot_notifier;
569 register_reboot_notifier(&mtd->reboot_notifier);
570 }
571
547 return err; 572 return err;
548} 573}
549EXPORT_SYMBOL_GPL(mtd_device_parse_register); 574EXPORT_SYMBOL_GPL(mtd_device_parse_register);
@@ -558,6 +583,9 @@ int mtd_device_unregister(struct mtd_info *master)
558{ 583{
559 int err; 584 int err;
560 585
586 if (master->_reboot)
587 unregister_reboot_notifier(&master->reboot_notifier);
588
561 err = del_mtd_partitions(master); 589 err = del_mtd_partitions(master);
562 if (err) 590 if (err)
563 return err; 591 return err;