aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdcore.c
diff options
context:
space:
mode:
authorMaxim Levitsky <maximlevitsky@gmail.com>2010-02-22 13:39:32 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-02-26 12:37:10 -0500
commit75c0b84d41c6f08c0cb083464907005683ef2920 (patch)
treef1a997c8c2a583551afc2e733e0df815d3c9bc91 /drivers/mtd/mtdcore.c
parent298304f1a554d44cf13391e531ced3cde69a8ce4 (diff)
mtd: call the remove notifiers before assuming it is in use
Now that mtd block common layer is prepared for proper hotplug support, enable it here Now all users of the mtd device have a chance to put the mtd device when they are notified to do so, and they have to do so to make hotplug work. [dwmw2: There's more work to be done to fix hotplug in the general case, but this is a reasonable start] Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r--drivers/mtd/mtdcore.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 67669a76eaf5..70a78587c3c0 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -350,31 +350,34 @@ fail_locked:
350int del_mtd_device (struct mtd_info *mtd) 350int del_mtd_device (struct mtd_info *mtd)
351{ 351{
352 int ret; 352 int ret;
353 struct mtd_notifier *not;
353 354
354 mutex_lock(&mtd_table_mutex); 355 mutex_lock(&mtd_table_mutex);
355 356
356 if (idr_find(&mtd_idr, mtd->index) != mtd) { 357 if (idr_find(&mtd_idr, mtd->index) != mtd) {
357 ret = -ENODEV; 358 ret = -ENODEV;
358 } else if (mtd->usecount) { 359 goto out_error;
360 }
361
362 /* No need to get a refcount on the module containing
363 the notifier, since we hold the mtd_table_mutex */
364 list_for_each_entry(not, &mtd_notifiers, list)
365 not->remove(mtd);
366
367 if (mtd->usecount) {
359 printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", 368 printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
360 mtd->index, mtd->name, mtd->usecount); 369 mtd->index, mtd->name, mtd->usecount);
361 ret = -EBUSY; 370 ret = -EBUSY;
362 } else { 371 } else {
363 struct mtd_notifier *not;
364
365 device_unregister(&mtd->dev); 372 device_unregister(&mtd->dev);
366 373
367 /* No need to get a refcount on the module containing
368 the notifier, since we hold the mtd_table_mutex */
369 list_for_each_entry(not, &mtd_notifiers, list)
370 not->remove(mtd);
371
372 idr_remove(&mtd_idr, mtd->index); 374 idr_remove(&mtd_idr, mtd->index);
373 375
374 module_put(THIS_MODULE); 376 module_put(THIS_MODULE);
375 ret = 0; 377 ret = 0;
376 } 378 }
377 379
380out_error:
378 mutex_unlock(&mtd_table_mutex); 381 mutex_unlock(&mtd_table_mutex);
379 return ret; 382 return ret;
380} 383}