* [PATCH v2 00/17] Clean nandsim error path
@ 2020-05-25 8:52 Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/62] mtd: rawnand: ams-delta: Stop using nand_release() Miquel Raynal
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-25 8:52 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
Cc: Boris Brezillon, Miquel Raynal
Hello,
As part of a bigger cleanup I realized the error path of nandsim.c was
horribly wrong. There are a few additional changes, like having a
consistent naming for a given object, but moreover this is an error
path cleanup, driver-wide.
Cheers,
Miquèl
Changes in v2:
* Reordered the kfree() and the list_del() to avoid a use after free
issue that I introduced in v1.
* Used debugfs_remove_recursive() instead of just debugfs_remove().
Miquel Raynal (17):
mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
mtd: rawnand: nandsim: Use octal permissions
mtd: rawnand: nandsim: Use a consistent ns_ prefix for all functions
mtd: rawnand: nandsim: Clean error handling
mtd: rawnand: nandsim: Keep track of the created debugfs entries
mtd: rawnand: nandsim: Remove debugfs entries at unload time
mtd: rawnand: nandsim: Fix the two ns_alloc_device() error paths
mtd: rawnand: nandsim: Free partition names on error in ns_init()
mtd: rawnand: nandsim: Free the allocated device on error in ns_init()
mtd: rawnand: nandsim: Free the partition names in ns_free()
mtd: rawnand: nandsim: Stop using nand_release()
mtd: rawnand: nandsim: Use an additional label when freeing the
nandsim object
mtd: rawnand: nandsim: Free erase_block_wear on error
mtd: rawnand: nandsim: Fix the label pointing on nand_cleanup()
mtd: rawnand: nandsim: Manage lists on error in ns_init_module()
mtd: rawnand: nandsim: Rename a label in ns_init_module()
mtd: rawnand: nandsim: Reorganize ns_cleanup_module()
drivers/mtd/nand/raw/nandsim.c | 437 +++++++++++++++++++--------------
1 file changed, 253 insertions(+), 184 deletions(-)
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 01/62] mtd: rawnand: ams-delta: Stop using nand_release()
2020-05-25 8:52 [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
@ 2020-05-25 8:52 ` Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev' Miquel Raynal
2020-05-25 8:55 ` [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-25 8:52 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
Cc: Boris Brezillon, Miquel Raynal
This helper is not very useful and very often people get confused:
they use nand_release() instead of nand_cleanup().
Let's stop using nand_release() by calling mtd_device_unregister() and
nand_cleanup() directly.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/ams-delta.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c
index d66dab25df20..3711e7a0436c 100644
--- a/drivers/mtd/nand/raw/ams-delta.c
+++ b/drivers/mtd/nand/raw/ams-delta.c
@@ -387,12 +387,15 @@ static int gpio_nand_remove(struct platform_device *pdev)
{
struct gpio_nand *priv = platform_get_drvdata(pdev);
struct mtd_info *mtd = nand_to_mtd(&priv->nand_chip);
+ int ret;
/* Apply write protection */
gpiod_set_value(priv->gpiod_nwp, 1);
/* Unregister device */
- nand_release(mtd_to_nand(mtd));
+ ret = mtd_device_unregister(mtd);
+ WARN_ON(ret);
+ nand_cleanup(mtd_to_nand(mtd));
return 0;
}
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
2020-05-25 8:52 [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/62] mtd: rawnand: ams-delta: Stop using nand_release() Miquel Raynal
@ 2020-05-25 8:52 ` Miquel Raynal
2020-05-25 8:55 ` [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-25 8:52 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
Cc: Boris Brezillon, Miquel Raynal
The nandsim object is called 'ns' almost everywhere, keep it that way
everywhere for consistency.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/nandsim.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index 23cda67a3f53..0062e4fedcc0 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -487,12 +487,12 @@ DEFINE_SHOW_ATTRIBUTE(nandsim);
/**
* nandsim_debugfs_create - initialize debugfs
- * @dev: nandsim device description object
+ * @ns: nandsim device description object
*
* This function creates all debugfs files for UBI device @ubi. Returns zero in
* case of success and a negative error code in case of failure.
*/
-static int nandsim_debugfs_create(struct nandsim *dev)
+static int nandsim_debugfs_create(struct nandsim *ns)
{
struct dentry *root = nsmtd->dbg.dfs_dir;
struct dentry *dent;
@@ -508,8 +508,8 @@ static int nandsim_debugfs_create(struct nandsim *dev)
return 0;
}
- dent = debugfs_create_file("nandsim_wear_report", S_IRUSR,
- root, dev, &nandsim_fops);
+ dent = debugfs_create_file("nandsim_wear_report", S_IRUSR, root, ns,
+ &nandsim_fops);
if (IS_ERR_OR_NULL(dent)) {
NS_ERR("cannot create \"nandsim_wear_report\" debugfs entry\n");
return -1;
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 00/17] Clean nandsim error path
2020-05-25 8:52 [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/62] mtd: rawnand: ams-delta: Stop using nand_release() Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev' Miquel Raynal
@ 2020-05-25 8:55 ` Miquel Raynal
2 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-25 8:55 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
Cc: Boris Brezillon
Miquel Raynal <miquel.raynal@bootlin.com> wrote on Mon, 25 May 2020
10:52:10 +0200:
> Hello,
>
> As part of a bigger cleanup I realized the error path of nandsim.c was
> horribly wrong. There are a few additional changes, like having a
> consistent naming for a given object, but moreover this is an error
> path cleanup, driver-wide.
Wrong operation on my side, I was about to send 90 patches so I
canceled the operation.
I will resend, sorry for the noise.
>
> Cheers,
> Miquèl
>
> Changes in v2:
> * Reordered the kfree() and the list_del() to avoid a use after free
> issue that I introduced in v1.
> * Used debugfs_remove_recursive() instead of just debugfs_remove().
>
> Miquel Raynal (17):
> mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
> mtd: rawnand: nandsim: Use octal permissions
> mtd: rawnand: nandsim: Use a consistent ns_ prefix for all functions
> mtd: rawnand: nandsim: Clean error handling
> mtd: rawnand: nandsim: Keep track of the created debugfs entries
> mtd: rawnand: nandsim: Remove debugfs entries at unload time
> mtd: rawnand: nandsim: Fix the two ns_alloc_device() error paths
> mtd: rawnand: nandsim: Free partition names on error in ns_init()
> mtd: rawnand: nandsim: Free the allocated device on error in ns_init()
> mtd: rawnand: nandsim: Free the partition names in ns_free()
> mtd: rawnand: nandsim: Stop using nand_release()
> mtd: rawnand: nandsim: Use an additional label when freeing the
> nandsim object
> mtd: rawnand: nandsim: Free erase_block_wear on error
> mtd: rawnand: nandsim: Fix the label pointing on nand_cleanup()
> mtd: rawnand: nandsim: Manage lists on error in ns_init_module()
> mtd: rawnand: nandsim: Rename a label in ns_init_module()
> mtd: rawnand: nandsim: Reorganize ns_cleanup_module()
>
> drivers/mtd/nand/raw/nandsim.c | 437 +++++++++++++++++++--------------
> 1 file changed, 253 insertions(+), 184 deletions(-)
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
2020-05-25 8:58 ` [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev' Miquel Raynal
@ 2020-05-27 14:13 ` Miquel Raynal
0 siblings, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2020-05-27 14:13 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
Tudor Ambarus, linux-mtd
Cc: Boris Brezillon
On Mon, 2020-05-25 at 08:58:35 UTC, Miquel Raynal wrote:
> The nandsim object is called 'ns' almost everywhere, keep it that way
> everywhere for consistency.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev'
2020-05-25 8:58 Miquel Raynal
@ 2020-05-25 8:58 ` Miquel Raynal
2020-05-27 14:13 ` Miquel Raynal
0 siblings, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2020-05-25 8:58 UTC (permalink / raw)
To: Richard Weinberger, Vignesh Raghavendra, Tudor Ambarus, linux-mtd
Cc: Boris Brezillon, Miquel Raynal
The nandsim object is called 'ns' almost everywhere, keep it that way
everywhere for consistency.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mtd/nand/raw/nandsim.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index 23cda67a3f53..0062e4fedcc0 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -487,12 +487,12 @@ DEFINE_SHOW_ATTRIBUTE(nandsim);
/**
* nandsim_debugfs_create - initialize debugfs
- * @dev: nandsim device description object
+ * @ns: nandsim device description object
*
* This function creates all debugfs files for UBI device @ubi. Returns zero in
* case of success and a negative error code in case of failure.
*/
-static int nandsim_debugfs_create(struct nandsim *dev)
+static int nandsim_debugfs_create(struct nandsim *ns)
{
struct dentry *root = nsmtd->dbg.dfs_dir;
struct dentry *dent;
@@ -508,8 +508,8 @@ static int nandsim_debugfs_create(struct nandsim *dev)
return 0;
}
- dent = debugfs_create_file("nandsim_wear_report", S_IRUSR,
- root, dev, &nandsim_fops);
+ dent = debugfs_create_file("nandsim_wear_report", S_IRUSR, root, ns,
+ &nandsim_fops);
if (IS_ERR_OR_NULL(dent)) {
NS_ERR("cannot create \"nandsim_wear_report\" debugfs entry\n");
return -1;
--
2.20.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-05-27 14:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-25 8:52 [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/62] mtd: rawnand: ams-delta: Stop using nand_release() Miquel Raynal
2020-05-25 8:52 ` [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev' Miquel Raynal
2020-05-25 8:55 ` [PATCH v2 00/17] Clean nandsim error path Miquel Raynal
2020-05-25 8:58 Miquel Raynal
2020-05-25 8:58 ` [PATCH v2 01/17] mtd: rawnand: nandsim: Consistent use of 'ns' instead of 'dev' Miquel Raynal
2020-05-27 14:13 ` Miquel Raynal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.