Message ID | 1341372944-27145-1-git-send-email-sachin.kamat@linaro.org |
---|---|
State | Accepted |
Headers | show |
On Wed, Jul 4, 2012 at 11:35 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote: > devm_kzalloc() makes cleanup simpler. > > Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Thanks, applied. -Bryan > --- > drivers/leds/leds-gpio.c | 11 +++++------ > 1 files changed, 5 insertions(+), 6 deletions(-) > > diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c > index f4c470a..c032b21 100644 > --- a/drivers/leds/leds-gpio.c > +++ b/drivers/leds/leds-gpio.c > @@ -178,7 +178,8 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev > if (!count) > return NULL; > > - priv = kzalloc(sizeof_gpio_leds_priv(count), GFP_KERNEL); > + priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), > + GFP_KERNEL); > if (!priv) > return NULL; > > @@ -215,7 +216,6 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev > err: > for (count = priv->num_leds - 2; count >= 0; count--) > delete_gpio_led(&priv->leds[count]); > - kfree(priv); > return NULL; > } > > @@ -239,8 +239,9 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) > int i, ret = 0; > > if (pdata && pdata->num_leds) { > - priv = kzalloc(sizeof_gpio_leds_priv(pdata->num_leds), > - GFP_KERNEL); > + priv = devm_kzalloc(&pdev->dev, > + sizeof_gpio_leds_priv(pdata->num_leds), > + GFP_KERNEL); > if (!priv) > return -ENOMEM; > > @@ -253,7 +254,6 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) > /* On failure: unwind the led creations */ > for (i = i - 1; i >= 0; i--) > delete_gpio_led(&priv->leds[i]); > - kfree(priv); > return ret; > } > } > @@ -277,7 +277,6 @@ static int __devexit gpio_led_remove(struct platform_device *pdev) > delete_gpio_led(&priv->leds[i]); > > dev_set_drvdata(&pdev->dev, NULL); > - kfree(priv); > > return 0; > } > -- > 1.7.4.1 >
And I'm working on convert all kzalloc to devm_kzalloc() in drivers/leds/. Just let you know and we don't need to waste time on the same thing. Thanks, -Bryan On Wed, Jul 4, 2012 at 12:57 PM, Bryan Wu <bryan.wu@canonical.com> wrote: > On Wed, Jul 4, 2012 at 11:35 AM, Sachin Kamat <sachin.kamat@linaro.org> wrote: >> devm_kzalloc() makes cleanup simpler. >> >> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> > > Thanks, applied. > > -Bryan > >> --- >> drivers/leds/leds-gpio.c | 11 +++++------ >> 1 files changed, 5 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c >> index f4c470a..c032b21 100644 >> --- a/drivers/leds/leds-gpio.c >> +++ b/drivers/leds/leds-gpio.c >> @@ -178,7 +178,8 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev >> if (!count) >> return NULL; >> >> - priv = kzalloc(sizeof_gpio_leds_priv(count), GFP_KERNEL); >> + priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), >> + GFP_KERNEL); >> if (!priv) >> return NULL; >> >> @@ -215,7 +216,6 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev >> err: >> for (count = priv->num_leds - 2; count >= 0; count--) >> delete_gpio_led(&priv->leds[count]); >> - kfree(priv); >> return NULL; >> } >> >> @@ -239,8 +239,9 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) >> int i, ret = 0; >> >> if (pdata && pdata->num_leds) { >> - priv = kzalloc(sizeof_gpio_leds_priv(pdata->num_leds), >> - GFP_KERNEL); >> + priv = devm_kzalloc(&pdev->dev, >> + sizeof_gpio_leds_priv(pdata->num_leds), >> + GFP_KERNEL); >> if (!priv) >> return -ENOMEM; >> >> @@ -253,7 +254,6 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) >> /* On failure: unwind the led creations */ >> for (i = i - 1; i >= 0; i--) >> delete_gpio_led(&priv->leds[i]); >> - kfree(priv); >> return ret; >> } >> } >> @@ -277,7 +277,6 @@ static int __devexit gpio_led_remove(struct platform_device *pdev) >> delete_gpio_led(&priv->leds[i]); >> >> dev_set_drvdata(&pdev->dev, NULL); >> - kfree(priv); >> >> return 0; >> } >> -- >> 1.7.4.1 >> > > > > -- > 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
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index f4c470a..c032b21 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -178,7 +178,8 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev if (!count) return NULL; - priv = kzalloc(sizeof_gpio_leds_priv(count), GFP_KERNEL); + priv = devm_kzalloc(&pdev->dev, sizeof_gpio_leds_priv(count), + GFP_KERNEL); if (!priv) return NULL; @@ -215,7 +216,6 @@ static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct platform_dev err: for (count = priv->num_leds - 2; count >= 0; count--) delete_gpio_led(&priv->leds[count]); - kfree(priv); return NULL; } @@ -239,8 +239,9 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) int i, ret = 0; if (pdata && pdata->num_leds) { - priv = kzalloc(sizeof_gpio_leds_priv(pdata->num_leds), - GFP_KERNEL); + priv = devm_kzalloc(&pdev->dev, + sizeof_gpio_leds_priv(pdata->num_leds), + GFP_KERNEL); if (!priv) return -ENOMEM; @@ -253,7 +254,6 @@ static int __devinit gpio_led_probe(struct platform_device *pdev) /* On failure: unwind the led creations */ for (i = i - 1; i >= 0; i--) delete_gpio_led(&priv->leds[i]); - kfree(priv); return ret; } } @@ -277,7 +277,6 @@ static int __devexit gpio_led_remove(struct platform_device *pdev) delete_gpio_led(&priv->leds[i]); dev_set_drvdata(&pdev->dev, NULL); - kfree(priv); return 0; }
devm_kzalloc() makes cleanup simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> --- drivers/leds/leds-gpio.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-)