From: Sachin Kamat <sachin.kamat@linaro.org>
To: linux-iio@vger.kernel.org
Cc: jic23@cam.ac.uk, jic23@kernel.org, sachin.kamat@linaro.org,
patches@linaro.org, Marek Vasut <marex@denx.de>
Subject: [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc
Date: Mon, 22 Jul 2013 16:32:58 +0530 [thread overview]
Message-ID: <1374490981-24373-6-git-send-email-sachin.kamat@linaro.org> (raw)
In-Reply-To: <1374490981-24373-1-git-send-email-sachin.kamat@linaro.org>
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Marek Vasut <marex@denx.de>
---
drivers/staging/iio/adc/mxs-lradc.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index 327914e..6f8d3a0 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -913,7 +913,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
int i;
/* Allocate the IIO device. */
- iio = iio_device_alloc(sizeof(*lradc));
+ iio = devm_iio_device_alloc(dev, sizeof(*lradc));
if (!iio) {
dev_err(dev, "Failed to allocate IIO device\n");
return -ENOMEM;
@@ -925,10 +925,8 @@ static int mxs_lradc_probe(struct platform_device *pdev)
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lradc->dev = &pdev->dev;
lradc->base = devm_ioremap_resource(dev, iores);
- if (IS_ERR(lradc->base)) {
- ret = PTR_ERR(lradc->base);
- goto err_addr;
- }
+ if (IS_ERR(lradc->base))
+ return PTR_ERR(lradc->base);
INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work);
@@ -948,16 +946,14 @@ static int mxs_lradc_probe(struct platform_device *pdev)
/* Grab all IRQ sources */
for (i = 0; i < of_cfg->irq_count; i++) {
lradc->irq[i] = platform_get_irq(pdev, i);
- if (lradc->irq[i] < 0) {
- ret = -EINVAL;
- goto err_addr;
- }
+ if (lradc->irq[i] < 0)
+ return -EINVAL;
ret = devm_request_irq(dev, lradc->irq[i],
mxs_lradc_handle_irq, 0,
of_cfg->irq_name[i], iio);
if (ret)
- goto err_addr;
+ return ret;
}
platform_set_drvdata(pdev, iio);
@@ -977,7 +973,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
&mxs_lradc_trigger_handler,
&mxs_lradc_buffer_ops);
if (ret)
- goto err_addr;
+ return ret;
ret = mxs_lradc_trigger_init(iio);
if (ret)
@@ -1008,8 +1004,6 @@ err_dev:
mxs_lradc_trigger_remove(iio);
err_trig:
iio_triggered_buffer_cleanup(iio);
-err_addr:
- iio_device_free(iio);
return ret;
}
@@ -1025,7 +1019,6 @@ static int mxs_lradc_remove(struct platform_device *pdev)
iio_device_unregister(iio);
iio_triggered_buffer_cleanup(iio);
mxs_lradc_trigger_remove(iio);
- iio_device_free(iio);
return 0;
}
--
1.7.9.5
next prev parent reply other threads:[~2013-07-22 11:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
2013-07-22 11:02 ` [PATCH 1/8] iio: at91: " Sachin Kamat
2013-07-27 11:24 ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 2/8] iio: exynos_adc: " Sachin Kamat
2013-07-27 11:25 ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 3/8] iio: max1363: " Sachin Kamat
2013-07-27 11:25 ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs Sachin Kamat
2013-07-27 11:26 ` Jonathan Cameron
2013-07-22 11:02 ` Sachin Kamat [this message]
2013-07-22 22:04 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Marek Vasut
2013-07-27 11:29 ` Jonathan Cameron
2013-07-22 11:02 ` [PATCH 6/8] staging: iio: spear_adc: " Sachin Kamat
2013-07-27 11:29 ` Jonathan Cameron
2013-07-22 11:03 ` [PATCH 7/8] staging: iio: light: isl29018: " Sachin Kamat
2013-07-22 15:16 ` Rhyland Klein
2013-07-27 11:30 ` Jonathan Cameron
2013-07-22 11:03 ` [PATCH 8/8] staging: iio: light: isl29028: " Sachin Kamat
2013-07-27 11:31 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374490981-24373-6-git-send-email-sachin.kamat@linaro.org \
--to=sachin.kamat@linaro.org \
--cc=jic23@cam.ac.uk \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=marex@denx.de \
--cc=patches@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).