diff mbox series

[06/17] mtd: rawnand: nandsim: Remove debugfs entries at unload time

Message ID 20200509191431.15862-7-miquel.raynal@bootlin.com
State Changes Requested
Delegated to: Miquel Raynal
Headers show
Series Clean nandsim error path | expand

Commit Message

Miquel Raynal May 9, 2020, 7:14 p.m. UTC
Create a ns_debugfs_remove() helper for that and call it in
ns_cleanup_module().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/nandsim.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Richard Weinberger May 9, 2020, 8:43 p.m. UTC | #1
----- Ursprüngliche Mail -----
> Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> An: "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>, "Tudor Ambarus" <Tudor.Ambarus@microchip.com>,
> "linux-mtd" <linux-mtd@lists.infradead.org>
> CC: "Boris Brezillon" <boris.brezillon@collabora.com>, dedekind@infradead.org, "Miquel Raynal"
> <miquel.raynal@bootlin.com>
> Gesendet: Samstag, 9. Mai 2020 21:14:19
> Betreff: [PATCH 06/17] mtd: rawnand: nandsim: Remove debugfs entries at unload time

> Create a ns_debugfs_remove() helper for that and call it in
> ns_cleanup_module().
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> drivers/mtd/nand/raw/nandsim.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
> index c8e9c70a6641..7862c65e32ad 100644
> --- a/drivers/mtd/nand/raw/nandsim.c
> +++ b/drivers/mtd/nand/raw/nandsim.c
> @@ -520,6 +520,11 @@ static int ns_debugfs_create(struct nandsim *ns)
> 	return 0;
> }
> 
> +static void ns_debugfs_remove(struct nandsim *ns)
> +{
> +	debugfs_remove(ns->dent);
> +}
> +
> /*
>  * Allocate array of page pointers, create slab allocation for an array
>  * and initialize the array by NULL pointers.
> @@ -2398,6 +2403,7 @@ static void __exit ns_cleanup_module(void)
> 	struct nandsim *ns = nand_get_controller_data(chip);
> 	int i;
> 
> +	ns_debugfs_remove(ns);
> 	ns_free(ns);    /* Free nandsim private resources */

Why is this special and cannot done in ns_free()?

Thanks,
//richard
Miquel Raynal May 9, 2020, 10:29 p.m. UTC | #2
Hi Richard,

Richard Weinberger <richard@nod.at> wrote on Sat, 9 May 2020 22:43:00
+0200 (CEST):

> ----- Ursprüngliche Mail -----
> > Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> > An: "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>, "Tudor Ambarus" <Tudor.Ambarus@microchip.com>,
> > "linux-mtd" <linux-mtd@lists.infradead.org>
> > CC: "Boris Brezillon" <boris.brezillon@collabora.com>, dedekind@infradead.org, "Miquel Raynal"
> > <miquel.raynal@bootlin.com>
> > Gesendet: Samstag, 9. Mai 2020 21:14:19
> > Betreff: [PATCH 06/17] mtd: rawnand: nandsim: Remove debugfs entries at unload time  
> 
> > Create a ns_debugfs_remove() helper for that and call it in
> > ns_cleanup_module().
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > drivers/mtd/nand/raw/nandsim.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
> > index c8e9c70a6641..7862c65e32ad 100644
> > --- a/drivers/mtd/nand/raw/nandsim.c
> > +++ b/drivers/mtd/nand/raw/nandsim.c
> > @@ -520,6 +520,11 @@ static int ns_debugfs_create(struct nandsim *ns)
> > 	return 0;
> > }
> > 
> > +static void ns_debugfs_remove(struct nandsim *ns)
> > +{
> > +	debugfs_remove(ns->dent);
> > +}
> > +
> > /*
> >  * Allocate array of page pointers, create slab allocation for an array
> >  * and initialize the array by NULL pointers.
> > @@ -2398,6 +2403,7 @@ static void __exit ns_cleanup_module(void)
> > 	struct nandsim *ns = nand_get_controller_data(chip);
> > 	int i;
> > 
> > +	ns_debugfs_remove(ns);
> > 	ns_free(ns);    /* Free nandsim private resources */  
> 
> Why is this special and cannot done in ns_free()?
> 

ns_debugfs_create() is called in ns_init_module(), so for me it is
natural to call ns_debugfs_remove in ns_cleanup_module(). More than
calling it from ns_free() which is the symmetry of ns_init(). No?
Richard Weinberger May 24, 2020, 9:27 p.m. UTC | #3
On Sun, May 10, 2020 at 12:30 AM Miquel Raynal
<miquel.raynal@bootlin.com> wrote:
>
> Hi Richard,
>
> Richard Weinberger <richard@nod.at> wrote on Sat, 9 May 2020 22:43:00
> +0200 (CEST):
>
> > ----- Ursprüngliche Mail -----
> > > Von: "Miquel Raynal" <miquel.raynal@bootlin.com>
> > > An: "richard" <richard@nod.at>, "Vignesh Raghavendra" <vigneshr@ti.com>, "Tudor Ambarus" <Tudor.Ambarus@microchip.com>,
> > > "linux-mtd" <linux-mtd@lists.infradead.org>
> > > CC: "Boris Brezillon" <boris.brezillon@collabora.com>, dedekind@infradead.org, "Miquel Raynal"
> > > <miquel.raynal@bootlin.com>
> > > Gesendet: Samstag, 9. Mai 2020 21:14:19
> > > Betreff: [PATCH 06/17] mtd: rawnand: nandsim: Remove debugfs entries at unload time
> >
> > > Create a ns_debugfs_remove() helper for that and call it in
> > > ns_cleanup_module().
> > >
> > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > > ---
> > > drivers/mtd/nand/raw/nandsim.c | 6 ++++++
> > > 1 file changed, 6 insertions(+)
> > >
> > > diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
> > > index c8e9c70a6641..7862c65e32ad 100644
> > > --- a/drivers/mtd/nand/raw/nandsim.c
> > > +++ b/drivers/mtd/nand/raw/nandsim.c
> > > @@ -520,6 +520,11 @@ static int ns_debugfs_create(struct nandsim *ns)
> > >     return 0;
> > > }
> > >
> > > +static void ns_debugfs_remove(struct nandsim *ns)
> > > +{
> > > +   debugfs_remove(ns->dent);
> > > +}
> > > +
> > > /*
> > >  * Allocate array of page pointers, create slab allocation for an array
> > >  * and initialize the array by NULL pointers.
> > > @@ -2398,6 +2403,7 @@ static void __exit ns_cleanup_module(void)
> > >     struct nandsim *ns = nand_get_controller_data(chip);
> > >     int i;
> > >
> > > +   ns_debugfs_remove(ns);
> > >     ns_free(ns);    /* Free nandsim private resources */
> >
> > Why is this special and cannot done in ns_free()?
> >
>
> ns_debugfs_create() is called in ns_init_module(), so for me it is
> natural to call ns_debugfs_remove in ns_cleanup_module(). More than
> calling it from ns_free() which is the symmetry of ns_init(). No?

Okay. Makes sense.
Richard Weinberger May 24, 2020, 9:33 p.m. UTC | #4
On Sat, May 9, 2020 at 9:16 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> Create a ns_debugfs_remove() helper for that and call it in
> ns_cleanup_module().
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mtd/nand/raw/nandsim.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
> index c8e9c70a6641..7862c65e32ad 100644
> --- a/drivers/mtd/nand/raw/nandsim.c
> +++ b/drivers/mtd/nand/raw/nandsim.c
> @@ -520,6 +520,11 @@ static int ns_debugfs_create(struct nandsim *ns)
>         return 0;
>  }
>
> +static void ns_debugfs_remove(struct nandsim *ns)
> +{
> +       debugfs_remove(ns->dent);

BTW: For now it is perfectly fine, but later this can be a
debugfs_remove_recursive().

> +}
> +
>  /*
>   * Allocate array of page pointers, create slab allocation for an array
>   * and initialize the array by NULL pointers.
> @@ -2398,6 +2403,7 @@ static void __exit ns_cleanup_module(void)
>         struct nandsim *ns = nand_get_controller_data(chip);
>         int i;
>
> +       ns_debugfs_remove(ns);
>         ns_free(ns);    /* Free nandsim private resources */
>         nand_release(chip); /* Unregister driver */
>         for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
> --
> 2.20.1
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
Miquel Raynal May 24, 2020, 10:14 p.m. UTC | #5
Hi Richard,

Richard Weinberger <richard.weinberger@gmail.com> wrote on Sun, 24 May
2020 23:33:06 +0200:

> On Sat, May 9, 2020 at 9:16 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >
> > Create a ns_debugfs_remove() helper for that and call it in
> > ns_cleanup_module().
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  drivers/mtd/nand/raw/nandsim.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
> > index c8e9c70a6641..7862c65e32ad 100644
> > --- a/drivers/mtd/nand/raw/nandsim.c
> > +++ b/drivers/mtd/nand/raw/nandsim.c
> > @@ -520,6 +520,11 @@ static int ns_debugfs_create(struct nandsim *ns)
> >         return 0;
> >  }
> >
> > +static void ns_debugfs_remove(struct nandsim *ns)
> > +{
> > +       debugfs_remove(ns->dent);  
> 
> BTW: For now it is perfectly fine, but later this can be a
> debugfs_remove_recursive().

Ok, I'll use it in the v2!

> 
> > +}
> > +
> >  /*
> >   * Allocate array of page pointers, create slab allocation for an array
> >   * and initialize the array by NULL pointers.
> > @@ -2398,6 +2403,7 @@ static void __exit ns_cleanup_module(void)
> >         struct nandsim *ns = nand_get_controller_data(chip);
> >         int i;
> >
> > +       ns_debugfs_remove(ns);
> >         ns_free(ns);    /* Free nandsim private resources */
> >         nand_release(chip); /* Unregister driver */
> >         for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)
> > --
> > 2.20.1
> >
> >
> > ______________________________________________________
> > Linux MTD discussion mailing list
> > http://lists.infradead.org/mailman/listinfo/linux-mtd/  
> 
> 
> 




Thanks,
Miquèl
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index c8e9c70a6641..7862c65e32ad 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -520,6 +520,11 @@  static int ns_debugfs_create(struct nandsim *ns)
 	return 0;
 }
 
+static void ns_debugfs_remove(struct nandsim *ns)
+{
+	debugfs_remove(ns->dent);
+}
+
 /*
  * Allocate array of page pointers, create slab allocation for an array
  * and initialize the array by NULL pointers.
@@ -2398,6 +2403,7 @@  static void __exit ns_cleanup_module(void)
 	struct nandsim *ns = nand_get_controller_data(chip);
 	int i;
 
+	ns_debugfs_remove(ns);
 	ns_free(ns);    /* Free nandsim private resources */
 	nand_release(chip); /* Unregister driver */
 	for (i = 0;i < ARRAY_SIZE(ns->partitions); ++i)