* [PATCH] leds-88pm860x: use the goto label at data->port @ 2012-07-02 8:22 Devendra Naga 2012-07-02 9:05 ` Bryan Wu 0 siblings, 1 reply; 4+ messages in thread From: Devendra Naga @ 2012-07-02 8:22 UTC (permalink / raw) To: Bryan Wu, Richard Purdie, linux-leds, linux-kernel; +Cc: Devendra Naga at the goto lable out: we are doing free of the led data, and returning ret. the same we are doing at the data->port < 0 case, so use the goto end and assign ret to -EINVAL. this will make the common err path for the data->port and led_classdev_register functions. Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> --- drivers/leds/leds-88pm860x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 5b61aaf..538aaa3 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev) data->port = pdata->flags; if (data->port < 0) { dev_err(&pdev->dev, "check device failed\n"); - kfree(data); - return -EINVAL; + ret = -EINVAL; + goto out; } data->current_brightness = 0; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] leds-88pm860x: use the goto label at data->port 2012-07-02 8:22 [PATCH] leds-88pm860x: use the goto label at data->port Devendra Naga @ 2012-07-02 9:05 ` Bryan Wu 2012-07-02 9:16 ` devendra.aaru 0 siblings, 1 reply; 4+ messages in thread From: Bryan Wu @ 2012-07-02 9:05 UTC (permalink / raw) To: Devendra Naga; +Cc: Richard Purdie, linux-leds, linux-kernel On Mon, Jul 2, 2012 at 4:22 PM, Devendra Naga <devendra.aaru@gmail.com> wrote: > at the goto lable out: we are doing free of the led data, and returning ret. > the same we are doing at the data->port < 0 case, so use the goto end and > assign ret to -EINVAL. this will make the common err path for the > data->port and led_classdev_register functions. > This patch is not wrong, but it'd better we replace kzalloc/kfree to devm_kzalloc. So we don't care about kfree anymore. Are interested in doing that? Thanks, -Bryan > Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> > --- > drivers/leds/leds-88pm860x.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c > index 5b61aaf..538aaa3 100644 > --- a/drivers/leds/leds-88pm860x.c > +++ b/drivers/leds/leds-88pm860x.c > @@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev) > data->port = pdata->flags; > if (data->port < 0) { > dev_err(&pdev->dev, "check device failed\n"); > - kfree(data); > - return -EINVAL; > + ret = -EINVAL; > + goto out; > } > > data->current_brightness = 0; > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-leds" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Bryan Wu <bryan.wu@canonical.com> Kernel Developer +86.186-168-78255 Mobile Canonical Ltd. www.canonical.com Ubuntu - Linux for human beings | www.ubuntu.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds-88pm860x: use the goto label at data->port 2012-07-02 9:05 ` Bryan Wu @ 2012-07-02 9:16 ` devendra.aaru 2012-07-02 9:58 ` Bryan Wu 0 siblings, 1 reply; 4+ messages in thread From: devendra.aaru @ 2012-07-02 9:16 UTC (permalink / raw) To: Bryan Wu; +Cc: Richard Purdie, linux-leds, linux-kernel On Mon, Jul 2, 2012 at 2:35 PM, Bryan Wu <bryan.wu@canonical.com> wrote: > On Mon, Jul 2, 2012 at 4:22 PM, Devendra Naga <devendra.aaru@gmail.com> wrote: >> at the goto lable out: we are doing free of the led data, and returning ret. >> the same we are doing at the data->port < 0 case, so use the goto end and >> assign ret to -EINVAL. this will make the common err path for the >> data->port and led_classdev_register functions. >> > > This patch is not wrong, but it'd better we replace kzalloc/kfree to > devm_kzalloc. So we don't care about kfree anymore. > Are interested in doing that? > I have a doubt, I think the dev pointer is chip->dev for using devm_* ? please suggest me if i am wrong. > Thanks, > -Bryan > >> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> >> --- >> drivers/leds/leds-88pm860x.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c >> index 5b61aaf..538aaa3 100644 >> --- a/drivers/leds/leds-88pm860x.c >> +++ b/drivers/leds/leds-88pm860x.c >> @@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev) >> data->port = pdata->flags; >> if (data->port < 0) { >> dev_err(&pdev->dev, "check device failed\n"); >> - kfree(data); >> - return -EINVAL; >> + ret = -EINVAL; >> + goto out; >> } >> >> data->current_brightness = 0; >> -- >> 1.7.9.5 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-leds" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html > > > > -- > Bryan Wu <bryan.wu@canonical.com> > Kernel Developer +86.186-168-78255 Mobile > Canonical Ltd. www.canonical.com > Ubuntu - Linux for human beings | www.ubuntu.com Thanks, Devendra. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] leds-88pm860x: use the goto label at data->port 2012-07-02 9:16 ` devendra.aaru @ 2012-07-02 9:58 ` Bryan Wu 0 siblings, 0 replies; 4+ messages in thread From: Bryan Wu @ 2012-07-02 9:58 UTC (permalink / raw) To: devendra.aaru; +Cc: Richard Purdie, linux-leds, linux-kernel On Mon, Jul 2, 2012 at 5:16 PM, devendra.aaru <devendra.aaru@gmail.com> wrote: > On Mon, Jul 2, 2012 at 2:35 PM, Bryan Wu <bryan.wu@canonical.com> wrote: >> On Mon, Jul 2, 2012 at 4:22 PM, Devendra Naga <devendra.aaru@gmail.com> wrote: >>> at the goto lable out: we are doing free of the led data, and returning ret. >>> the same we are doing at the data->port < 0 case, so use the goto end and >>> assign ret to -EINVAL. this will make the common err path for the >>> data->port and led_classdev_register functions. >>> >> >> This patch is not wrong, but it'd better we replace kzalloc/kfree to >> devm_kzalloc. So we don't care about kfree anymore. >> Are interested in doing that? >> > I have a doubt, > > I think the dev pointer is chip->dev for using devm_* ? > data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL); You can simply just use pdev->dev, right? -Bryan > please suggest me if i am wrong. >> Thanks, >> -Bryan >> >>> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com> >>> --- >>> drivers/leds/leds-88pm860x.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c >>> index 5b61aaf..538aaa3 100644 >>> --- a/drivers/leds/leds-88pm860x.c >>> +++ b/drivers/leds/leds-88pm860x.c >>> @@ -220,8 +220,8 @@ static int pm860x_led_probe(struct platform_device *pdev) >>> data->port = pdata->flags; >>> if (data->port < 0) { >>> dev_err(&pdev->dev, "check device failed\n"); >>> - kfree(data); >>> - return -EINVAL; >>> + ret = -EINVAL; >>> + goto out; >>> } >>> >>> data->current_brightness = 0; >>> -- >>> 1.7.9.5 >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-leds" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> >> >> -- >> Bryan Wu <bryan.wu@canonical.com> >> Kernel Developer +86.186-168-78255 Mobile >> Canonical Ltd. www.canonical.com >> Ubuntu - Linux for human beings | www.ubuntu.com > > Thanks, > Devendra. > -- > To unsubscribe from this list: send the line "unsubscribe linux-leds" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Bryan Wu <bryan.wu@canonical.com> Kernel Developer +86.186-168-78255 Mobile Canonical Ltd. www.canonical.com Ubuntu - Linux for human beings | www.ubuntu.com ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-02 9:59 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-07-02 8:22 [PATCH] leds-88pm860x: use the goto label at data->port Devendra Naga 2012-07-02 9:05 ` Bryan Wu 2012-07-02 9:16 ` devendra.aaru 2012-07-02 9:58 ` Bryan Wu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox