* [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe()
@ 2013-11-11 6:18 Wei Yongjun
2013-11-26 23:50 ` Brian Norris
0 siblings, 1 reply; 5+ messages in thread
From: Wei Yongjun @ 2013-11-11 6:18 UTC (permalink / raw)
To: dwmw2, wfp5p, artem.bityutskiy, jg1.han, computersforpeace
Cc: yongjun_wei, linux-mtd, linux-kernel
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Add missing platform_set_drvdata() in au1550nd_probe(), otherwise
calling platform_get_drvdata() in remove returns NULL.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
drivers/mtd/nand/au1550nd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index ae8dd7c..909b673 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
+ platform_set_drvdata(pdev, ctx);
+
return 0;
out3:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe()
2013-11-11 6:18 [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe() Wei Yongjun
@ 2013-11-26 23:50 ` Brian Norris
2013-11-27 0:14 ` Jingoo Han
0 siblings, 1 reply; 5+ messages in thread
From: Brian Norris @ 2013-11-26 23:50 UTC (permalink / raw)
To: Wei Yongjun
Cc: artem.bityutskiy, jg1.han, linux-kernel, yongjun_wei, wfp5p,
linux-mtd, dwmw2
On Mon, Nov 11, 2013 at 02:18:29PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Add missing platform_set_drvdata() in au1550nd_probe(), otherwise
> calling platform_get_drvdata() in remove returns NULL.
An alternative solution: just allocate ctx with devm_kzalloc(). Then you
don't have to kfree() it at all.
I don't mind one solution over the other too much. Let me know which
you'd prefer.
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
> drivers/mtd/nand/au1550nd.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
> index ae8dd7c..909b673 100644
> --- a/drivers/mtd/nand/au1550nd.c
> +++ b/drivers/mtd/nand/au1550nd.c
> @@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
>
> mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
>
> + platform_set_drvdata(pdev, ctx);
> +
Personally, I'd choose to call platform_set_drvdata() earlier in the
probe routine (e.g., immediately after its allocation), in case we end
up calling platform_get_drvdata() from some sub-routine in the future.
> return 0;
>
> out3:
>
Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe()
2013-11-26 23:50 ` Brian Norris
@ 2013-11-27 0:14 ` Jingoo Han
2013-11-27 3:35 ` Brian Norris
0 siblings, 1 reply; 5+ messages in thread
From: Jingoo Han @ 2013-11-27 0:14 UTC (permalink / raw)
To: 'Brian Norris'
Cc: 'Wei Yongjun', 'Artem Bityutskiy',
'Jingoo Han', linux-kernel, 'Wei Yongjun',
'Bill Pemberton', linux-mtd, 'David Woodhouse'
On Wednesday, November 27, 2013 8:50 AM, Brian Norris wrote:
Hi Brian Norris,
I added my questions as below. :-)
> On Mon, Nov 11, 2013 at 02:18:29PM +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >
> > Add missing platform_set_drvdata() in au1550nd_probe(), otherwise
> > calling platform_get_drvdata() in remove returns NULL.
>
> An alternative solution: just allocate ctx with devm_kzalloc().Then you
> don't have to kfree() it at all.
Even if devm_kzalloc() is used, missing platform_set_drvdata() will
be still necessary.
static int au1550nd_remove(struct platform_device *pdev)
{
struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
.....
nand_release(&ctx->info);
'ctx' is still used. Also, in order to use 'ctx',
platform_get_drvdata(pdev) should be called.
>
> I don't mind one solution over the other too much. Let me know which
> you'd prefer.
>
> > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> > ---
> > drivers/mtd/nand/au1550nd.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
> > index ae8dd7c..909b673 100644
> > --- a/drivers/mtd/nand/au1550nd.c
> > +++ b/drivers/mtd/nand/au1550nd.c
> > @@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
> >
> > mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
> >
> > + platform_set_drvdata(pdev, ctx);
> > +
>
> Personally, I'd choose to call platform_set_drvdata() earlier in the
> probe routine (e.g., immediately after its allocation), in case we end
> up calling platform_get_drvdata() from some sub-routine in the future.
Do you mean the following?
But, most drivers calls platform_set_drvdata() later in the probe routine.
static int au1550nd_probe(struct platform_device *pdev)
{
struct au1550nd_platdata *pd;
struct au1550nd_ctx *ctx;
struct nand_chip *this;
struct resource *r;
int ret, cs;
pd = dev_get_platdata(&pdev->dev);
if (!pd) {
dev_err(&pdev->dev, "missing platform data\n");
return -ENODEV;
}
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx) {
dev_err(&pdev->dev, "no memory for NAND context\n");
return -ENOMEM;
}
+ platform_set_drvdata(pdev, ctx);
+
Best regards,
Jingoo Han
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe()
2013-11-27 0:14 ` Jingoo Han
@ 2013-11-27 3:35 ` Brian Norris
2013-12-17 8:21 ` Brian Norris
0 siblings, 1 reply; 5+ messages in thread
From: Brian Norris @ 2013-11-27 3:35 UTC (permalink / raw)
To: Jingoo Han
Cc: 'Wei Yongjun', 'Artem Bityutskiy', linux-kernel,
'Wei Yongjun', 'Bill Pemberton', linux-mtd,
'David Woodhouse'
Hi Jingoo,
On Wed, Nov 27, 2013 at 09:14:18AM +0900, Jingoo Han wrote:
> On Wednesday, November 27, 2013 8:50 AM, Brian Norris wrote:
> > On Mon, Nov 11, 2013 at 02:18:29PM +0800, Wei Yongjun wrote:
> > > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> > >
> > > Add missing platform_set_drvdata() in au1550nd_probe(), otherwise
> > > calling platform_get_drvdata() in remove returns NULL.
> >
> > An alternative solution: just allocate ctx with devm_kzalloc().Then you
> > don't have to kfree() it at all.
>
> Even if devm_kzalloc() is used, missing platform_set_drvdata() will
> be still necessary.
>
> static int au1550nd_remove(struct platform_device *pdev)
> {
> struct au1550nd_ctx *ctx = platform_get_drvdata(pdev);
> .....
>
> nand_release(&ctx->info);
>
> 'ctx' is still used. Also, in order to use 'ctx',
> platform_get_drvdata(pdev) should be called.
Ah, I overlooked that. Thanks. In that case, you still have to do
something like this patch, and devm_kzalloc() can be left for another
day (or not done at all).
> >
> > I don't mind one solution over the other too much. Let me know which
> > you'd prefer.
> >
> > > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> > > ---
> > > drivers/mtd/nand/au1550nd.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
> > > index ae8dd7c..909b673 100644
> > > --- a/drivers/mtd/nand/au1550nd.c
> > > +++ b/drivers/mtd/nand/au1550nd.c
> > > @@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
> > >
> > > mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
> > >
> > > + platform_set_drvdata(pdev, ctx);
> > > +
> >
> > Personally, I'd choose to call platform_set_drvdata() earlier in the
> > probe routine (e.g., immediately after its allocation), in case we end
> > up calling platform_get_drvdata() from some sub-routine in the future.
>
> Do you mean the following?
> But, most drivers calls platform_set_drvdata() later in the probe routine.
I wouldn't say "most." An unscientific survey seemed to show some
variation, with no clear pattern.
> static int au1550nd_probe(struct platform_device *pdev)
> {
> struct au1550nd_platdata *pd;
> struct au1550nd_ctx *ctx;
> struct nand_chip *this;
> struct resource *r;
> int ret, cs;
>
> pd = dev_get_platdata(&pdev->dev);
> if (!pd) {
> dev_err(&pdev->dev, "missing platform data\n");
> return -ENODEV;
> }
>
> ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> if (!ctx) {
> dev_err(&pdev->dev, "no memory for NAND context\n");
> return -ENOMEM;
> }
>
> + platform_set_drvdata(pdev, ctx);
> +
Yes, that looks better to me.
Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe()
2013-11-27 3:35 ` Brian Norris
@ 2013-12-17 8:21 ` Brian Norris
0 siblings, 0 replies; 5+ messages in thread
From: Brian Norris @ 2013-12-17 8:21 UTC (permalink / raw)
To: Jingoo Han
Cc: 'Wei Yongjun', 'Artem Bityutskiy', linux-kernel,
'Wei Yongjun', 'Bill Pemberton', linux-mtd,
'David Woodhouse'
On Tue, Nov 26, 2013 at 07:35:55PM -0800, Brian Norris wrote:
> On Wed, Nov 27, 2013 at 09:14:18AM +0900, Jingoo Han wrote:
> > On Wednesday, November 27, 2013 8:50 AM, Brian Norris wrote:
> > > On Mon, Nov 11, 2013 at 02:18:29PM +0800, Wei Yongjun wrote:
> > > > --- a/drivers/mtd/nand/au1550nd.c
> > > > +++ b/drivers/mtd/nand/au1550nd.c
> > > > @@ -480,6 +480,8 @@ static int au1550nd_probe(struct platform_device *pdev)
> > > >
> > > > mtd_device_register(&ctx->info, pd->parts, pd->num_parts);
> > > >
> > > > + platform_set_drvdata(pdev, ctx);
> > > > +
> > >
> > > Personally, I'd choose to call platform_set_drvdata() earlier in the
> > > probe routine (e.g., immediately after its allocation), in case we end
> > > up calling platform_get_drvdata() from some sub-routine in the future.
> >
> > Do you mean the following?
> > But, most drivers calls platform_set_drvdata() later in the probe routine.
>
> I wouldn't say "most." An unscientific survey seemed to show some
> variation, with no clear pattern.
I'm just pushing the original patch, since this isn't really a big
issue.
Pushed to l2-mtd.git. I reworked the $subject, since this isn't really
about MIPS at all. Thanks Wei and Jingoo.
Brian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-17 8:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-11 6:18 [PATCH] MIPS: Alchemy: add missing platform_set_drvdata() in au1550nd_probe() Wei Yongjun
2013-11-26 23:50 ` Brian Norris
2013-11-27 0:14 ` Jingoo Han
2013-11-27 3:35 ` Brian Norris
2013-12-17 8:21 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox