Message ID | 1467669983-12105-5-git-send-email-richard@nod.at |
---|---|
State | Superseded |
Headers | show |
On Tue, 5 Jul 2016 00:06:22 +0200 Richard Weinberger <richard@nod.at> wrote: > Only call them when we're really removing the MTD. > > Signed-off-by: Richard Weinberger <richard@nod.at> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> > --- > drivers/mtd/mtdcore.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index 36e5fb0..f49e103 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -499,16 +499,16 @@ int del_mtd_device(struct mtd_info *mtd) > goto out_error; > } > > - /* No need to get a refcount on the module containing > - the notifier, since we hold the mtd_table_mutex */ > - list_for_each_entry(not, &mtd_notifiers, list) > - not->remove(mtd); > - > if (mtd->usecount) { > printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", > mtd->index, mtd->name, mtd->usecount); > ret = -EBUSY; > } else { > + /* No need to get a refcount on the module containing > + the notifier, since we hold the mtd_table_mutex */ > + list_for_each_entry(not, &mtd_notifiers, list) > + not->remove(mtd); > + > device_unregister(&mtd->dev); > > idr_remove(&mtd_idr, mtd->index);
On Tue, Jul 05, 2016 at 12:06:22AM +0200, Richard Weinberger wrote: > Only call them when we're really removing the MTD. > > Signed-off-by: Richard Weinberger <richard@nod.at> > --- > drivers/mtd/mtdcore.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index 36e5fb0..f49e103 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -499,16 +499,16 @@ int del_mtd_device(struct mtd_info *mtd) > goto out_error; > } > > - /* No need to get a refcount on the module containing > - the notifier, since we hold the mtd_table_mutex */ > - list_for_each_entry(not, &mtd_notifiers, list) > - not->remove(mtd); > - > if (mtd->usecount) { > printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", > mtd->index, mtd->name, mtd->usecount); > ret = -EBUSY; > } else { > + /* No need to get a refcount on the module containing > + the notifier, since we hold the mtd_table_mutex */ > + list_for_each_entry(not, &mtd_notifiers, list) > + not->remove(mtd); > + The ordering looks like it was somewhat intentional here: 75c0b84d41c6 mtd: call the remove notifiers before assuming it is in use Have we fixed or refactored the issues that seem to have prompted that? Brian > device_unregister(&mtd->dev); > > idr_remove(&mtd_idr, mtd->index); > -- > 2.7.3 >
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 36e5fb0..f49e103 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -499,16 +499,16 @@ int del_mtd_device(struct mtd_info *mtd) goto out_error; } - /* No need to get a refcount on the module containing - the notifier, since we hold the mtd_table_mutex */ - list_for_each_entry(not, &mtd_notifiers, list) - not->remove(mtd); - if (mtd->usecount) { printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n", mtd->index, mtd->name, mtd->usecount); ret = -EBUSY; } else { + /* No need to get a refcount on the module containing + the notifier, since we hold the mtd_table_mutex */ + list_for_each_entry(not, &mtd_notifiers, list) + not->remove(mtd); + device_unregister(&mtd->dev); idr_remove(&mtd_idr, mtd->index);
Only call them when we're really removing the MTD. Signed-off-by: Richard Weinberger <richard@nod.at> --- drivers/mtd/mtdcore.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)