* [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
@ 2014-07-01 21:19 Himangi Saraogi
2014-07-07 12:34 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Himangi Saraogi @ 2014-07-01 21:19 UTC (permalink / raw)
To: Jonathan Cameron, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel
Cc: julia.lawall
This patch introduces the use of the managed version of kzalloc and
removes the kfrees in the probe and remove functions. More return
paths are added and the labels are renamed to order them.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
---
v2: add more return paths
Not compile tested.
drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 31 ++++++++---------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
index 16f1a06..a21b7c5 100644
--- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
+++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
@@ -182,45 +182,40 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
unsigned int config;
int ret;
- st = kzalloc(sizeof(*st), GFP_KERNEL);
- if (st == NULL) {
- ret = -ENOMEM;
- goto out;
- }
+ st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
+ if (st == NULL)
+ return -ENOMEM;
st->irq = platform_get_irq(pdev, 0);
if (!st->irq) {
dev_err(&pdev->dev, "No IRQs specified");
- ret = -ENODEV;
- goto out1;
+ return -ENODEV;
}
ret = iio_bfin_tmr_get_number(st->irq);
if (ret < 0)
- goto out1;
+ return ret;
st->timer_num = ret;
st->t = &iio_bfin_timer_code[st->timer_num];
st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
- if (!st->trig) {
- ret = -ENOMEM;
- goto out1;
- }
+ if (!st->trig)
+ return -ENOMEM;
st->trig->ops = &iio_bfin_tmr_trigger_ops;
st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
iio_trigger_set_drvdata(st->trig, st);
ret = iio_trigger_register(st->trig);
if (ret)
- goto out2;
+ goto out;
ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
0, st->trig->name, st);
if (ret) {
dev_err(&pdev->dev,
"request IRQ-%d failed", st->irq);
- goto out4;
+ goto out1;
}
config = PWM_OUT | PERIOD_CNT | IRQ_ENA;
@@ -260,13 +255,10 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
return 0;
out_free_irq:
free_irq(st->irq, st);
-out4:
- iio_trigger_unregister(st->trig);
-out2:
- iio_trigger_put(st->trig);
out1:
- kfree(st);
+ iio_trigger_unregister(st->trig);
out:
+ iio_trigger_put(st->trig);
return ret;
}
@@ -280,7 +272,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
free_irq(st->irq, st);
iio_trigger_unregister(st->trig);
iio_trigger_put(st->trig);
- kfree(st);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
2014-07-01 21:19 [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc Himangi Saraogi
@ 2014-07-07 12:34 ` Jonathan Cameron
2014-07-07 12:37 ` Lars-Peter Clausen
2014-07-07 12:52 ` Julia Lawall
0 siblings, 2 replies; 6+ messages in thread
From: Jonathan Cameron @ 2014-07-07 12:34 UTC (permalink / raw)
To: Himangi Saraogi, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel
Cc: julia.lawall, Lars-Peter Clausen, Michael Hennerich
On 01/07/14 22:19, Himangi Saraogi wrote:
> This patch introduces the use of the managed version of kzalloc and
> removes the kfrees in the probe and remove functions. More return
> paths are added and the labels are renamed to order them.
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Looks sane, but I'd like an ack or reviewed-by from someone as Analog for this one.
cc'd Lars and Michael.
> ---
> v2: add more return paths
> Not compile tested.
> drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 31 ++++++++---------------
> 1 file changed, 11 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> index 16f1a06..a21b7c5 100644
> --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> @@ -182,45 +182,40 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
> unsigned int config;
> int ret;
>
> - st = kzalloc(sizeof(*st), GFP_KERNEL);
> - if (st == NULL) {
> - ret = -ENOMEM;
> - goto out;
> - }
> + st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
> + if (st == NULL)
> + return -ENOMEM;
>
> st->irq = platform_get_irq(pdev, 0);
> if (!st->irq) {
> dev_err(&pdev->dev, "No IRQs specified");
> - ret = -ENODEV;
> - goto out1;
> + return -ENODEV;
> }
>
> ret = iio_bfin_tmr_get_number(st->irq);
> if (ret < 0)
> - goto out1;
> + return ret;
>
> st->timer_num = ret;
> st->t = &iio_bfin_timer_code[st->timer_num];
>
> st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
> - if (!st->trig) {
> - ret = -ENOMEM;
> - goto out1;
> - }
> + if (!st->trig)
> + return -ENOMEM;
>
> st->trig->ops = &iio_bfin_tmr_trigger_ops;
> st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
> iio_trigger_set_drvdata(st->trig, st);
> ret = iio_trigger_register(st->trig);
> if (ret)
> - goto out2;
> + goto out;
>
> ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
> 0, st->trig->name, st);
> if (ret) {
> dev_err(&pdev->dev,
> "request IRQ-%d failed", st->irq);
> - goto out4;
> + goto out1;
> }
>
> config = PWM_OUT | PERIOD_CNT | IRQ_ENA;
> @@ -260,13 +255,10 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev)
> return 0;
> out_free_irq:
> free_irq(st->irq, st);
> -out4:
> - iio_trigger_unregister(st->trig);
> -out2:
> - iio_trigger_put(st->trig);
> out1:
> - kfree(st);
> + iio_trigger_unregister(st->trig);
> out:
> + iio_trigger_put(st->trig);
> return ret;
> }
>
> @@ -280,7 +272,6 @@ static int iio_bfin_tmr_trigger_remove(struct platform_device *pdev)
> free_irq(st->irq, st);
> iio_trigger_unregister(st->trig);
> iio_trigger_put(st->trig);
> - kfree(st);
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
2014-07-07 12:34 ` Jonathan Cameron
@ 2014-07-07 12:37 ` Lars-Peter Clausen
2014-07-07 16:23 ` Jonathan Cameron
2014-07-07 12:52 ` Julia Lawall
1 sibling, 1 reply; 6+ messages in thread
From: Lars-Peter Clausen @ 2014-07-07 12:37 UTC (permalink / raw)
To: Jonathan Cameron, Himangi Saraogi, Greg Kroah-Hartman, linux-iio,
devel, linux-kernel
Cc: julia.lawall, Michael Hennerich
On 07/07/2014 02:34 PM, Jonathan Cameron wrote:
> On 01/07/14 22:19, Himangi Saraogi wrote:
>> This patch introduces the use of the managed version of kzalloc and
>> removes the kfrees in the probe and remove functions. More return
>> paths are added and the labels are renamed to order them.
>>
>> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Looks sane, but I'd like an ack or reviewed-by from someone as Analog for
> this one.
> cc'd Lars and Michael.
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
2014-07-07 12:34 ` Jonathan Cameron
2014-07-07 12:37 ` Lars-Peter Clausen
@ 2014-07-07 12:52 ` Julia Lawall
2014-07-07 12:55 ` Lars-Peter Clausen
1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2014-07-07 12:52 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Himangi Saraogi, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel, julia.lawall, Lars-Peter Clausen, Michael Hennerich
On Mon, 7 Jul 2014, Jonathan Cameron wrote:
> On 01/07/14 22:19, Himangi Saraogi wrote:
> > This patch introduces the use of the managed version of kzalloc and
> > removes the kfrees in the probe and remove functions. More return
> > paths are added and the labels are renamed to order them.
> >
> > Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Looks sane, but I'd like an ack or reviewed-by from someone as Analog for this
> one.
> cc'd Lars and Michael.
Should MAINTAINERS be updated somehow?
julia
>
> > ---
> > v2: add more return paths
> > Not compile tested.
> > drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 31
> > ++++++++---------------
> > 1 file changed, 11 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> > b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> > index 16f1a06..a21b7c5 100644
> > --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> > +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c
> > @@ -182,45 +182,40 @@ static int iio_bfin_tmr_trigger_probe(struct
> > platform_device *pdev)
> > unsigned int config;
> > int ret;
> >
> > - st = kzalloc(sizeof(*st), GFP_KERNEL);
> > - if (st == NULL) {
> > - ret = -ENOMEM;
> > - goto out;
> > - }
> > + st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL);
> > + if (st == NULL)
> > + return -ENOMEM;
> >
> > st->irq = platform_get_irq(pdev, 0);
> > if (!st->irq) {
> > dev_err(&pdev->dev, "No IRQs specified");
> > - ret = -ENODEV;
> > - goto out1;
> > + return -ENODEV;
> > }
> >
> > ret = iio_bfin_tmr_get_number(st->irq);
> > if (ret < 0)
> > - goto out1;
> > + return ret;
> >
> > st->timer_num = ret;
> > st->t = &iio_bfin_timer_code[st->timer_num];
> >
> > st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num);
> > - if (!st->trig) {
> > - ret = -ENOMEM;
> > - goto out1;
> > - }
> > + if (!st->trig)
> > + return -ENOMEM;
> >
> > st->trig->ops = &iio_bfin_tmr_trigger_ops;
> > st->trig->dev.groups = iio_bfin_tmr_trigger_attr_groups;
> > iio_trigger_set_drvdata(st->trig, st);
> > ret = iio_trigger_register(st->trig);
> > if (ret)
> > - goto out2;
> > + goto out;
> >
> > ret = request_irq(st->irq, iio_bfin_tmr_trigger_isr,
> > 0, st->trig->name, st);
> > if (ret) {
> > dev_err(&pdev->dev,
> > "request IRQ-%d failed", st->irq);
> > - goto out4;
> > + goto out1;
> > }
> >
> > config = PWM_OUT | PERIOD_CNT | IRQ_ENA;
> > @@ -260,13 +255,10 @@ static int iio_bfin_tmr_trigger_probe(struct
> > platform_device *pdev)
> > return 0;
> > out_free_irq:
> > free_irq(st->irq, st);
> > -out4:
> > - iio_trigger_unregister(st->trig);
> > -out2:
> > - iio_trigger_put(st->trig);
> > out1:
> > - kfree(st);
> > + iio_trigger_unregister(st->trig);
> > out:
> > + iio_trigger_put(st->trig);
> > return ret;
> > }
> >
> > @@ -280,7 +272,6 @@ static int iio_bfin_tmr_trigger_remove(struct
> > platform_device *pdev)
> > free_irq(st->irq, st);
> > iio_trigger_unregister(st->trig);
> > iio_trigger_put(st->trig);
> > - kfree(st);
> >
> > return 0;
> > }
> >
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
2014-07-07 12:52 ` Julia Lawall
@ 2014-07-07 12:55 ` Lars-Peter Clausen
0 siblings, 0 replies; 6+ messages in thread
From: Lars-Peter Clausen @ 2014-07-07 12:55 UTC (permalink / raw)
To: Julia Lawall, Jonathan Cameron
Cc: Himangi Saraogi, Greg Kroah-Hartman, linux-iio, devel,
linux-kernel, Michael Hennerich
On 07/07/2014 02:52 PM, Julia Lawall wrote:
> On Mon, 7 Jul 2014, Jonathan Cameron wrote:
>
>> On 01/07/14 22:19, Himangi Saraogi wrote:
>>> This patch introduces the use of the managed version of kzalloc and
>>> removes the kfrees in the probe and remove functions. More return
>>> paths are added and the labels are renamed to order them.
>>>
>>> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
>> Looks sane, but I'd like an ack or reviewed-by from someone as Analog for this
>> one.
>> cc'd Lars and Michael.
>
> Should MAINTAINERS be updated somehow?
>
> julia
yea, it's been on my todo list for a while.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc
2014-07-07 12:37 ` Lars-Peter Clausen
@ 2014-07-07 16:23 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2014-07-07 16:23 UTC (permalink / raw)
To: Lars-Peter Clausen, Himangi Saraogi, Greg Kroah-Hartman,
linux-iio, devel, linux-kernel
Cc: julia.lawall, Michael Hennerich
On 07/07/14 13:37, Lars-Peter Clausen wrote:
> On 07/07/2014 02:34 PM, Jonathan Cameron wrote:
>> On 01/07/14 22:19, Himangi Saraogi wrote:
>>> This patch introduces the use of the managed version of kzalloc and
>>> removes the kfrees in the probe and remove functions. More return
>>> paths are added and the labels are renamed to order them.
>>>
>>> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
>> Looks sane, but I'd like an ack or reviewed-by from someone as Analog for
>> this one.
>> cc'd Lars and Michael.
>
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git
Thanks,
Jonathan
>
> Thanks.
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-07 16:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 21:19 [PATCH v2] iio:trigger: Introduce the use of devm_kzalloc Himangi Saraogi
2014-07-07 12:34 ` Jonathan Cameron
2014-07-07 12:37 ` Lars-Peter Clausen
2014-07-07 16:23 ` Jonathan Cameron
2014-07-07 12:52 ` Julia Lawall
2014-07-07 12:55 ` Lars-Peter Clausen
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).