Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758805AbaGAUZK (ORCPT ); Tue, 1 Jul 2014 16:25:10 -0400 Received: from mout.gmx.net ([212.227.17.21]:57489 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754995AbaGAUZI (ORCPT ); Tue, 1 Jul 2014 16:25:08 -0400 Message-ID: <53B3191C.3050706@gmx.de> Date: Tue, 01 Jul 2014 22:25:00 +0200 From: Hartmut Knaack User-Agent: Mozilla/5.0 (X11; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0 SeaMonkey/2.26.1 MIME-Version: 1.0 To: Himangi Saraogi , Jonathan Cameron , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio:trigger: Introduce the use of devm_kzalloc References: <20140701183858.GA2939@himangi-Dell> In-Reply-To: <20140701183858.GA2939@himangi-Dell> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:yo1kNxOArVZlOnqWwGoy1sQuxTpw3qPstHAmqZrGmcWuDIIxCBr DbwJ+ZPVj6p/nviWfgTv/On/+ZviUFE6QcwZJPcz+RyozEpnn6vIcdAHvG4gvIfH0PPK4Xh JoiGjVTmqjGOWRHAX+wNWAPfBfa+DesGGQJhuw2s3+F+xEW6KlLib4qJcLGg0cn3LqbLPhY 3OBJ3bg5Qo+6ZAIvhZvmg== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Himangi Saraogi schrieb: > This patch introduces the use of the managed version of kzalloc and > removes the kfrees in the probe and remove functions. Also, the labels > are renamed to order them. Since you are already on it, better drop label "out" and return the errorcode immediately after checking for errors. > > Signed-off-by: Himangi Saraogi > Acked-by: Julia Lawall > --- > drivers/staging/iio/trigger/iio-trig-bfin-timer.c | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 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..cc858aa 100644 > --- a/drivers/staging/iio/trigger/iio-trig-bfin-timer.c > +++ b/drivers/staging/iio/trigger/iio-trig-bfin-timer.c > @@ -182,7 +182,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) > unsigned int config; > int ret; > > - st = kzalloc(sizeof(*st), GFP_KERNEL); > + st = devm_kzalloc(&pdev->dev, sizeof(*st), GFP_KERNEL); > if (st == NULL) { > ret = -ENOMEM; > goto out; > @@ -192,12 +192,12 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) > if (!st->irq) { > dev_err(&pdev->dev, "No IRQs specified"); > ret = -ENODEV; > - goto out1; > + goto out; > } > > ret = iio_bfin_tmr_get_number(st->irq); > if (ret < 0) > - goto out1; > + goto out; > > st->timer_num = ret; > st->t = &iio_bfin_timer_code[st->timer_num]; > @@ -205,7 +205,7 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) > st->trig = iio_trigger_alloc("bfintmr%d", st->timer_num); > if (!st->trig) { > ret = -ENOMEM; > - goto out1; > + goto out; > } > > st->trig->ops = &iio_bfin_tmr_trigger_ops; > @@ -213,14 +213,14 @@ static int iio_bfin_tmr_trigger_probe(struct platform_device *pdev) > iio_trigger_set_drvdata(st->trig, st); > ret = iio_trigger_register(st->trig); > if (ret) > - goto out2; > + goto out1; > > 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 out2; > } > > config = PWM_OUT | PERIOD_CNT | IRQ_ENA; > @@ -260,12 +260,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); > + iio_trigger_unregister(st->trig); > out1: > - kfree(st); > + iio_trigger_put(st->trig); > out: > return ret; > } > @@ -280,7 +278,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; > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/