Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1239113
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Shraddha Barke <shraddha.6596@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] Staging: iio: meter: Use devm functions |
| Date | Sun, 04 Oct 2015 14:50:02 +0200 |
| Message-ID | <qfQTM-Bf-9@gated-at.bofh.it> (permalink) |
| References | <qfJfz-6Bs-5@gated-at.bofh.it> <qfQh3-8jP-9@gated-at.bofh.it> |
| X-Original-To | Jonathan Cameron <jic23@kernel.org> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=nTf5ZJWM7Lm03/MLKQCAqzxGgf8KHxb8eehPnc6EG34=; b=XHnOyt2K1vzpQeFAQEBwNIe56vPXDT8c7hZ4SsQpfLZDDNWuQn63zg8zMsISy9hxBs SXZcBJw0nXMsJLi1tD9WSKEO1JXMClW0T4I9p/rYbphPI6NilUb3ZN7xEratcVzSwxcf ZRZFALYovgOdjhtjJ5ZHk+sVeOojxbtmPHuanQrMAOL7Ox/fZkPB5OaZ8kmImr4QsYB+ nu7nggX7zsT79XFngPdLyqB0QKsrEXFe4/wrfCwYdFaCvLUaGhl3NnuTtguzGvY6Tlep V06q4v73TdHlQRFIwbBZnALTYp27oqRmsuRrXzduOH3fHhyngnTnrtEDKU8MtMxaTsk6 FROg== |
| X-Received | by 10.68.94.99 with SMTP id db3mr33009578pbb.165.1443962659195; Sun, 04 Oct 2015 05:44:19 -0700 (PDT) |
| X-X-Sender | root@shraddha-370R4E-370R4V-370R5E-3570RE-370R5V |
| User-Agent | Alpine 2.11 (DEB 23 2013-08-11) |
| MIME-Version | 1.0 |
| Content-Type | TEXT/PLAIN; charset=US-ASCII; format=flowed |
| X-Cyberoam-Smtpxy-Version | 1.0.6.3 |
| X-Cyberoam-Av-Policy | default |
| X-Ctch-Pver | 0000001 |
| X-Ctch-Spam | Unknown |
| X-Ctch-Vod | Unknown |
| X-Ctch-Refid | str=0001.0A150201.56111F21.003A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 |
| X-Ctch-Score | 0.000 |
| X-Ctch-Scorecust | 0.000 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 97 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Shraddha Barke <shraddha.6596@gmail.com>, Lars-Peter Clausen <lars@metafoo.de>, Michael Hennerich <Michael.Hennerich@analog.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org |
| X-Original-Date | Sun, 4 Oct 2015 18:13:37 +0530 (IST) |
| X-Original-Message-ID | <alpine.DEB.2.11.1510041809250.26738@shraddha-370R4E-370R4V-370R5E-3570RE-370R5V> |
| X-Original-References | <1443933272-23398-1-git-send-email-shraddha.6596@gmail.com> <56111645.3060004@kernel.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1239113 |
Show key headers only | View raw
On Sun, 4 Oct 2015, Jonathan Cameron wrote:
> On 04/10/15 05:34, Shraddha Barke wrote:
>> Introduce use of managed resource function devm_iio_trigger_alloc
>> instead of iio_trigger_alloc and devm_request_irq instead of request_irq
>> Remove corresponding calls to iio_trigger_free and free_irq in the probe
>> and remove functions.
>> The now unnecessary labels error_free_trig and err_free_irq are dropped.
>>
>> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>> ---
>>
>> drivers/staging/iio/meter/ade7758_trigger.c | 26 ++++++++++----------------
>> 1 file changed, 10 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/staging/iio/meter/ade7758_trigger.c b/drivers/staging/iio/meter/ade7758_trigger.c
>> index 5b35a7f..e313b37 100644
>> --- a/drivers/staging/iio/meter/ade7758_trigger.c
>> +++ b/drivers/staging/iio/meter/ade7758_trigger.c
>> @@ -63,21 +63,21 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
>> struct ade7758_state *st = iio_priv(indio_dev);
>> int ret;
>>
>> - st->trig = iio_trigger_alloc("%s-dev%d",
>> - spi_get_device_id(st->us)->name,
>> - indio_dev->id);
>> + st->trig = devm_iio_trigger_alloc(&indio_dev->id, "%s-dev%d",
>> + spi_get_device_id(st->us)->name,
>> + indio_dev->id);
>> if (!st->trig) {
>> ret = -ENOMEM;
>> goto error_ret;
>> }
>>
>> - ret = request_irq(st->us->irq,
>> - ade7758_data_rdy_trig_poll,
>> - IRQF_TRIGGER_LOW,
>> - spi_get_device_id(st->us)->name,
>> - st->trig);
>> + ret = devm_request_irq(&indio_dev->dev, st->us->irq,
>> + ade7758_data_rdy_trig_poll,
>> + IRQF_TRIGGER_LOW,
>> + spi_get_device_id(st->us)->name,
>> + st->trig);
>> if (ret)
>> - goto error_free_trig;
>> + goto error_ret
>>
>> st->trig->dev.parent = &st->us->dev;
>> st->trig->ops = &ade7758_trigger_ops;
>> @@ -87,14 +87,10 @@ int ade7758_probe_trigger(struct iio_dev *indio_dev)
>> /* select default trigger */
>> indio_dev->trig = iio_trigger_get(st->trig);
>> if (ret)
>> - goto error_free_irq;
>> + goto error_ret;
>>
>> return 0;
>>
>> -error_free_irq:
>> - free_irq(st->us->irq, st->trig);
>> -error_free_trig:
>> - iio_trigger_free(st->trig);
>> error_ret:
>> return ret;
> Whilst you are here, direct returns are preferred when there is no unwinding to do
> so if you could just return the error from anywhere it does the goto error_ret
> that would be great!
I was a little skeptical about the change from request_irq to
devm_request_irq because I'm not sure whether the things that are
freed by the function are needed by the interrupt handler. Do you
think it's correct?
Shraddha
>
> Thanks,
>
> Jonathan
>> }
>> @@ -104,6 +100,4 @@ void ade7758_remove_trigger(struct iio_dev *indio_dev)
>> struct ade7758_state *st = iio_priv(indio_dev);
>>
>> iio_trigger_unregister(st->trig);
>> - free_irq(st->us->irq, st->trig);
>> - iio_trigger_free(st->trig);
>> }
>>
>
>
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] Staging: iio: meter: Use devm functions Shraddha Barke <shraddha.6596@gmail.com> - 2015-10-04 06:40 +0200
Re: [PATCH] Staging: iio: meter: Use devm functions Lars-Peter Clausen <lars@metafoo.de> - 2015-10-04 14:10 +0200
Re: [PATCH] Staging: iio: meter: Use devm functions Jonathan Cameron <jic23@kernel.org> - 2015-10-04 14:10 +0200
Re: [PATCH] Staging: iio: meter: Use devm functions Shraddha Barke <shraddha.6596@gmail.com> - 2015-10-04 14:50 +0200
Re: [PATCH] Staging: iio: meter: Use devm functions Jonathan Cameron <jic23@kernel.org> - 2015-10-04 16:40 +0200
csiph-web