* [PATCH] mtd: bcm47xxnflash: really unregister NAND on device removal
@ 2015-12-09 1:04 Brian Norris
2015-12-14 17:49 ` Boris Brezillon
0 siblings, 1 reply; 3+ messages in thread
From: Brian Norris @ 2015-12-09 1:04 UTC (permalink / raw)
To: linux-mtd
Cc: Boris Brezillon, Brian Norris, Rafał Miłecki,
linux-wireless
The field bcma_nflash::mtd is never set to be non-zero anywhere, but we
test for it in the removal path. So the MTD is never unregistered.
Also, we should use nand_release(), not mtd_device_unregister().
Finally, we don't need to use the 'platdata' for stashing/retrieving our
*driver* data -- that's what *_{get,set}_drvdata() are for.
So, kill off bcm_nflash::mtd, and stash the struct bcm47xxnflash in
drvdata instead. Also move the forward declaration of mtd_info up a bit,
since struct bcma_sflash should be using it.
Caught while inspecting other changes being made to this driver. Compile
tested only.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: "Rafał Miłecki" <zajec5@gmail.com>
Cc: linux-wireless@vger.kernel.org
---
Might have some small conflict with Boris' NAND/MTD refactoring patch set. I
can rebase this small one if his gets in proper shape. Just wanted to get this
out there.
drivers/mtd/nand/bcm47xxnflash/main.c | 7 ++++---
include/linux/bcma/bcma_driver_chipcommon.h | 6 ++----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
index 9ba0c0f2cd9b..0b3acc439181 100644
--- a/drivers/mtd/nand/bcm47xxnflash/main.c
+++ b/drivers/mtd/nand/bcm47xxnflash/main.c
@@ -49,6 +49,8 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
return err;
}
+ platform_set_drvdata(pdev, b47n);
+
err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0);
if (err) {
pr_err("Failed to register MTD device: %d\n", err);
@@ -60,10 +62,9 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
static int bcm47xxnflash_remove(struct platform_device *pdev)
{
- struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
+ struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
- if (nflash->mtd)
- mtd_device_unregister(nflash->mtd);
+ nand_release(&nflash->mtd);
return 0;
}
diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
index cf038431a5cc..db51a6ffb7d6 100644
--- a/include/linux/bcma/bcma_driver_chipcommon.h
+++ b/include/linux/bcma/bcma_driver_chipcommon.h
@@ -579,6 +579,8 @@ struct bcma_pflash {
};
#ifdef CONFIG_BCMA_SFLASH
+struct mtd_info;
+
struct bcma_sflash {
bool present;
u32 window;
@@ -592,13 +594,9 @@ struct bcma_sflash {
#endif
#ifdef CONFIG_BCMA_NFLASH
-struct mtd_info;
-
struct bcma_nflash {
bool present;
bool boot; /* This is the flash the SoC boots from */
-
- struct mtd_info *mtd;
};
#endif
--
2.6.0.rc2.230.g3dd15c0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mtd: bcm47xxnflash: really unregister NAND on device removal
2015-12-09 1:04 [PATCH] mtd: bcm47xxnflash: really unregister NAND on device removal Brian Norris
@ 2015-12-14 17:49 ` Boris Brezillon
2015-12-14 18:12 ` Brian Norris
0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2015-12-14 17:49 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd, Rafał Miłecki, linux-wireless
On Tue, 8 Dec 2015 17:04:59 -0800
Brian Norris <computersforpeace@gmail.com> wrote:
> The field bcma_nflash::mtd is never set to be non-zero anywhere, but we
> test for it in the removal path. So the MTD is never unregistered.
>
> Also, we should use nand_release(), not mtd_device_unregister().
>
> Finally, we don't need to use the 'platdata' for stashing/retrieving our
> *driver* data -- that's what *_{get,set}_drvdata() are for.
>
> So, kill off bcm_nflash::mtd, and stash the struct bcm47xxnflash in
> drvdata instead. Also move the forward declaration of mtd_info up a bit,
> since struct bcma_sflash should be using it.
>
> Caught while inspecting other changes being made to this driver. Compile
> tested only.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> Cc: "Rafał Miłecki" <zajec5@gmail.com>
> Cc: linux-wireless@vger.kernel.org
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Might have some small conflict with Boris' NAND/MTD refactoring patch set. I
> can rebase this small one if his gets in proper shape. Just wanted to get this
> out there.
>
> drivers/mtd/nand/bcm47xxnflash/main.c | 7 ++++---
> include/linux/bcma/bcma_driver_chipcommon.h | 6 ++----
> 2 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c
> index 9ba0c0f2cd9b..0b3acc439181 100644
> --- a/drivers/mtd/nand/bcm47xxnflash/main.c
> +++ b/drivers/mtd/nand/bcm47xxnflash/main.c
> @@ -49,6 +49,8 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
> return err;
> }
>
> + platform_set_drvdata(pdev, b47n);
> +
> err = mtd_device_parse_register(&b47n->mtd, probes, NULL, NULL, 0);
> if (err) {
> pr_err("Failed to register MTD device: %d\n", err);
> @@ -60,10 +62,9 @@ static int bcm47xxnflash_probe(struct platform_device *pdev)
>
> static int bcm47xxnflash_remove(struct platform_device *pdev)
> {
> - struct bcma_nflash *nflash = dev_get_platdata(&pdev->dev);
> + struct bcm47xxnflash *nflash = platform_get_drvdata(pdev);
>
> - if (nflash->mtd)
> - mtd_device_unregister(nflash->mtd);
> + nand_release(&nflash->mtd);
>
> return 0;
> }
> diff --git a/include/linux/bcma/bcma_driver_chipcommon.h b/include/linux/bcma/bcma_driver_chipcommon.h
> index cf038431a5cc..db51a6ffb7d6 100644
> --- a/include/linux/bcma/bcma_driver_chipcommon.h
> +++ b/include/linux/bcma/bcma_driver_chipcommon.h
> @@ -579,6 +579,8 @@ struct bcma_pflash {
> };
>
> #ifdef CONFIG_BCMA_SFLASH
> +struct mtd_info;
> +
> struct bcma_sflash {
> bool present;
> u32 window;
> @@ -592,13 +594,9 @@ struct bcma_sflash {
> #endif
>
> #ifdef CONFIG_BCMA_NFLASH
> -struct mtd_info;
> -
> struct bcma_nflash {
> bool present;
> bool boot; /* This is the flash the SoC boots from */
> -
> - struct mtd_info *mtd;
> };
> #endif
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mtd: bcm47xxnflash: really unregister NAND on device removal
2015-12-14 17:49 ` Boris Brezillon
@ 2015-12-14 18:12 ` Brian Norris
0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2015-12-14 18:12 UTC (permalink / raw)
To: Boris Brezillon; +Cc: linux-mtd, Rafał Miłecki, linux-wireless
On Mon, Dec 14, 2015 at 06:49:07PM +0100, Boris Brezillon wrote:
> On Tue, 8 Dec 2015 17:04:59 -0800
> Brian Norris <computersforpeace@gmail.com> wrote:
>
> > The field bcma_nflash::mtd is never set to be non-zero anywhere, but we
> > test for it in the removal path. So the MTD is never unregistered.
> >
> > Also, we should use nand_release(), not mtd_device_unregister().
> >
> > Finally, we don't need to use the 'platdata' for stashing/retrieving our
> > *driver* data -- that's what *_{get,set}_drvdata() are for.
> >
> > So, kill off bcm_nflash::mtd, and stash the struct bcm47xxnflash in
> > drvdata instead. Also move the forward declaration of mtd_info up a bit,
> > since struct bcma_sflash should be using it.
> >
> > Caught while inspecting other changes being made to this driver. Compile
> > tested only.
> >
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > Cc: "Rafał Miłecki" <zajec5@gmail.com>
> > Cc: linux-wireless@vger.kernel.org
>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Applied to l2-mtd.git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-14 18:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 1:04 [PATCH] mtd: bcm47xxnflash: really unregister NAND on device removal Brian Norris
2015-12-14 17:49 ` Boris Brezillon
2015-12-14 18:12 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).