Message ID | 20181119205955.32042-4-boris.brezillon@bootlin.com |
---|---|
State | Superseded |
Delegated to: | Jagannadha Sutradharudu Teki |
Headers | show |
Series | mtd/sf: Various fixes | expand |
Hello Boris, Am 19.11.2018 um 21:59 schrieb Boris Brezillon: > If we don't do that, partitions might still be exposed while the > underlying device is gone. > > Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling") > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > --- > Changes in v3: > - None > > Changes in v2: > - Fix build failures when CONFIG_MTD_PARTITIONS is not enabled > --- > drivers/mtd/mtdcore.c | 1 + > include/linux/mtd/mtd.h | 15 +++++++++++++++ > 2 files changed, 16 insertions(+) Tested-by: Heiko Schocher <hs@denx.de> bye, Heiko
On Mon, 19 Nov 2018 21:59:47 +0100 Boris Brezillon <boris.brezillon@bootlin.com> wrote: > If we don't do that, partitions might still be exposed while the > underlying device is gone. > > Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling") > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> > --- > Changes in v3: > - None > > Changes in v2: > - Fix build failures when CONFIG_MTD_PARTITIONS is not enabled > --- > drivers/mtd/mtdcore.c | 1 + > include/linux/mtd/mtd.h | 15 +++++++++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c > index 7a15ded8c883..46657fe7c949 100644 > --- a/drivers/mtd/mtdcore.c > +++ b/drivers/mtd/mtdcore.c > @@ -528,6 +528,7 @@ int del_mtd_device(struct mtd_info *mtd) > struct mtd_notifier *not; > #endif > > + del_mtd_partitions(mtd); We should check and propagate the error (if any). ret = del_mtd_partitions(mtd); if (ret) return ret; I'll fix that in v4. > mutex_lock(&mtd_table_mutex); > > if (idr_find(&mtd_idr, mtd->index) != mtd) { > diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h > index d20ebd820289..4d0096d9f1d8 100644 > --- a/include/linux/mtd/mtd.h > +++ b/include/linux/mtd/mtd.h > @@ -562,8 +562,23 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd); > /* drivers/mtd/mtdcore.h */ > int add_mtd_device(struct mtd_info *mtd); > int del_mtd_device(struct mtd_info *mtd); > + > +#ifdef CONFIG_MTD_PARTITIONS > int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); > int del_mtd_partitions(struct mtd_info *); > +#else > +static inline int add_mtd_partitions(struct mtd_info *mtd, > + const struct mtd_partition *parts, > + int nparts) > +{ > + return 0; > +} > + > +static inline int del_mtd_partitions(struct mtd_info *mtd) > +{ > + return 0; > +} > +#endif > > struct mtd_info *__mtd_next_device(int i); > #define mtd_for_each_device(mtd) \
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 7a15ded8c883..46657fe7c949 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -528,6 +528,7 @@ int del_mtd_device(struct mtd_info *mtd) struct mtd_notifier *not; #endif + del_mtd_partitions(mtd); mutex_lock(&mtd_table_mutex); if (idr_find(&mtd_idr, mtd->index) != mtd) { diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index d20ebd820289..4d0096d9f1d8 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -562,8 +562,23 @@ unsigned mtd_mmap_capabilities(struct mtd_info *mtd); /* drivers/mtd/mtdcore.h */ int add_mtd_device(struct mtd_info *mtd); int del_mtd_device(struct mtd_info *mtd); + +#ifdef CONFIG_MTD_PARTITIONS int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); int del_mtd_partitions(struct mtd_info *); +#else +static inline int add_mtd_partitions(struct mtd_info *mtd, + const struct mtd_partition *parts, + int nparts) +{ + return 0; +} + +static inline int del_mtd_partitions(struct mtd_info *mtd) +{ + return 0; +} +#endif struct mtd_info *__mtd_next_device(int i); #define mtd_for_each_device(mtd) \
If we don't do that, partitions might still be exposed while the underlying device is gone. Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> --- Changes in v3: - None Changes in v2: - Fix build failures when CONFIG_MTD_PARTITIONS is not enabled --- drivers/mtd/mtdcore.c | 1 + include/linux/mtd/mtd.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+)