All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] Use devm_iio_device_alloc
@ 2013-07-22 11:02 Sachin Kamat
  2013-07-22 11:02 ` [PATCH 1/8] iio: at91: " Sachin Kamat
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches

All patches are compile tested only.
Based on togreg branch of following tree:
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

Sachin Kamat (8):
  iio: at91: Use devm_iio_device_alloc
  iio: exynos_adc: Use devm_iio_device_alloc
  iio: max1363: Use devm_iio_device_alloc
  iio: frequency: adf4350: Use devm_* APIs
  staging: iio: mxs-lradc: Use devm_iio_device_alloc
  staging: iio: spear_adc: Use devm_iio_device_alloc
  staging: iio: light: isl29018: Use devm_iio_device_alloc
  staging: iio: light: isl29028: Use devm_iio_device_alloc

 drivers/iio/adc/at91_adc.c           |   23 +++++++----------------
 drivers/iio/adc/exynos_adc.c         |   23 ++++++++---------------
 drivers/iio/adc/max1363.c            |   15 +++++----------
 drivers/iio/frequency/adf4350.c      |   31 +++++++++----------------------
 drivers/staging/iio/adc/mxs-lradc.c  |   21 +++++++--------------
 drivers/staging/iio/adc/spear_adc.c  |   30 ++++++++++++------------------
 drivers/staging/iio/light/isl29018.c |   16 +++++-----------
 drivers/staging/iio/light/isl29028.c |   13 ++++---------
 8 files changed, 57 insertions(+), 115 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/8] iio: at91: Use devm_iio_device_alloc
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
@ 2013-07-22 11:02 ` Sachin Kamat
  2013-07-27 11:24   ` Jonathan Cameron
  2013-07-22 11:02 ` [PATCH 2/8] iio: exynos_adc: " Sachin Kamat
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Maxime Ripard

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/iio/adc/at91_adc.c |   23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index b6db6a0..423e079 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev)
 	struct resource *res;
 	u32 reg;
 
-	idev = iio_device_alloc(sizeof(struct at91_adc_state));
-	if (idev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
+	if (!idev)
+		return -ENOMEM;
 
 	st = iio_priv(idev);
 
@@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	if (ret) {
 		dev_err(&pdev->dev, "No platform data available.\n");
-		ret = -EINVAL;
-		goto error_free_device;
+		return -EINVAL;
 	}
 
 	platform_set_drvdata(pdev, idev);
@@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev)
 	st->irq = platform_get_irq(pdev, 0);
 	if (st->irq < 0) {
 		dev_err(&pdev->dev, "No IRQ ID is designated\n");
-		ret = -ENODEV;
-		goto error_free_device;
+		return -ENODEV;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
 	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(st->reg_base)) {
-		ret = PTR_ERR(st->reg_base);
-		goto error_free_device;
+		return PTR_ERR(st->reg_base);
 	}
 
 	/*
@@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 			  idev);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
-		goto error_free_device;
+		return ret;
 	}
 
 	st->clk = devm_clk_get(&pdev->dev, "adc_clk");
@@ -752,9 +747,6 @@ error_disable_clk:
 	clk_disable_unprepare(st->clk);
 error_free_irq:
 	free_irq(st->irq, idev);
-error_free_device:
-	iio_device_free(idev);
-error_ret:
 	return ret;
 }
 
@@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(st->adc_clk);
 	clk_disable_unprepare(st->clk);
 	free_irq(st->irq, idev);
-	iio_device_free(idev);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/8] iio: exynos_adc: Use devm_iio_device_alloc
  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-22 11:02 ` Sachin Kamat
  2013-07-27 11:25   ` Jonathan Cameron
  2013-07-22 11:02 ` [PATCH 3/8] iio: max1363: " Sachin Kamat
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Naveen Krishna Chatradhi

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
---
 drivers/iio/adc/exynos_adc.c |   23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 9809fc9..d25b262 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -33,6 +33,7 @@
 #include <linux/of_irq.h>
 #include <linux/regulator/consumer.h>
 #include <linux/of_platform.h>
+#include <linux/err.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/machine.h>
@@ -261,7 +262,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
 	if (!np)
 		return ret;
 
-	indio_dev = iio_device_alloc(sizeof(struct exynos_adc));
+	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct exynos_adc));
 	if (!indio_dev) {
 		dev_err(&pdev->dev, "failed allocating iio device\n");
 		return -ENOMEM;
@@ -271,23 +272,18 @@ static int exynos_adc_probe(struct platform_device *pdev)
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	info->regs = devm_ioremap_resource(&pdev->dev, mem);
-	if (IS_ERR(info->regs)) {
-		ret = PTR_ERR(info->regs);
-		goto err_iio;
-	}
+	if (IS_ERR(info->regs))
+		return PTR_ERR(info->regs);
 
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	info->enable_reg = devm_ioremap_resource(&pdev->dev, mem);
-	if (IS_ERR(info->enable_reg)) {
-		ret = PTR_ERR(info->enable_reg);
-		goto err_iio;
-	}
+	if (IS_ERR(info->enable_reg))
+		return PTR_ERR(info->enable_reg);
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
 		dev_err(&pdev->dev, "no irq resource?\n");
-		ret = irq;
-		goto err_iio;
+		return irq;
 	}
 
 	info->irq = irq;
@@ -299,7 +295,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "failed requesting irq, irq = %d\n",
 							info->irq);
-		goto err_iio;
+		return ret;
 	}
 
 	writel(1, info->enable_reg);
@@ -365,8 +361,6 @@ err_iio_dev:
 	iio_device_unregister(indio_dev);
 err_irq:
 	free_irq(info->irq, info);
-err_iio:
-	iio_device_free(indio_dev);
 	return ret;
 }
 
@@ -382,7 +376,6 @@ static int exynos_adc_remove(struct platform_device *pdev)
 	writel(0, info->enable_reg);
 	iio_device_unregister(indio_dev);
 	free_irq(info->irq, info);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/8] iio: max1363: Use devm_iio_device_alloc
  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-22 11:02 ` [PATCH 2/8] iio: exynos_adc: " Sachin Kamat
@ 2013-07-22 11:02 ` 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
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/iio/adc/max1363.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
index f148d00..4fb35d1 100644
--- a/drivers/iio/adc/max1363.c
+++ b/drivers/iio/adc/max1363.c
@@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	struct regulator *vref;
 
-	indio_dev = iio_device_alloc(sizeof(struct max1363_state));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_out;
-	}
+	indio_dev = devm_iio_device_alloc(&client->dev,
+					  sizeof(struct max1363_state));
+	if (!indio_dev)
+		return -ENOMEM;
 
 	indio_dev->dev.of_node = client->dev.of_node;
 	ret = iio_map_array_register(indio_dev, client->dev.platform_data);
 	if (ret < 0)
-		goto error_free_device;
+		return ret;
 
 	st = iio_priv(indio_dev);
 
@@ -1590,9 +1589,6 @@ error_disable_reg:
 	regulator_disable(st->reg);
 error_unregister_map:
 	iio_map_array_unregister(indio_dev);
-error_free_device:
-	iio_device_free(indio_dev);
-error_out:
 	return ret;
 }
 
@@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client)
 		regulator_disable(st->vref);
 	regulator_disable(st->reg);
 	iio_map_array_unregister(indio_dev);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
                   ` (2 preceding siblings ...)
  2013-07-22 11:02 ` [PATCH 3/8] iio: max1363: " Sachin Kamat
@ 2013-07-22 11:02 ` Sachin Kamat
  2013-07-27 11:26   ` Jonathan Cameron
  2013-07-22 11:02 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Sachin Kamat
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Michael Hennerich

devm_* APIs are device managed and make code simpler.
This also takes care of missing clk_put function calls implicitly.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Michael Hennerich <michael.hennerich@analog.com>
---
 drivers/iio/frequency/adf4350.c |   31 +++++++++----------------------
 1 file changed, 9 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
index a4157cd..a7b30be 100644
--- a/drivers/iio/frequency/adf4350.c
+++ b/drivers/iio/frequency/adf4350.c
@@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi)
 	}
 
 	if (!pdata->clkin) {
-		clk = clk_get(&spi->dev, "clkin");
+		clk = devm_clk_get(&spi->dev, "clkin");
 		if (IS_ERR(clk))
 			return -EPROBE_DEFER;
 
@@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi)
 			return ret;
 	}
 
-	indio_dev = iio_device_alloc(sizeof(*st));
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
 	if (indio_dev == NULL)
 		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
 
-	st->reg = regulator_get(&spi->dev, "vcc");
+	st->reg = devm_regulator_get(&spi->dev, "vcc");
 	if (!IS_ERR(st->reg)) {
 		ret = regulator_enable(st->reg);
 		if (ret)
-			goto error_put_reg;
+			goto error_disable_clk;
 	}
 
 	spi_set_drvdata(spi, indio_dev);
@@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi)
 	memset(st->regs_hw, 0xFF, sizeof(st->regs_hw));
 
 	if (gpio_is_valid(pdata->gpio_lock_detect)) {
-		ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name);
+		ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect,
+					indio_dev->name);
 		if (ret) {
 			dev_err(&spi->dev, "fail to request lock detect GPIO-%d",
 				pdata->gpio_lock_detect);
@@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi)
 	if (pdata->power_up_frequency) {
 		ret = adf4350_set_freq(st, pdata->power_up_frequency);
 		if (ret)
-			goto error_free_gpio;
+			goto error_disable_reg;
 	}
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
-		goto error_free_gpio;
+		goto error_disable_reg;
 
 	return 0;
 
-error_free_gpio:
-	if (gpio_is_valid(pdata->gpio_lock_detect))
-		gpio_free(pdata->gpio_lock_detect);
-
 error_disable_reg:
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-error_put_reg:
-	if (!IS_ERR(st->reg))
-		regulator_put(st->reg);
-
+error_disable_clk:
 	if (clk)
 		clk_disable_unprepare(clk);
-	iio_device_free(indio_dev);
 
 	return ret;
 }
@@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi)
 
 	if (!IS_ERR(reg)) {
 		regulator_disable(reg);
-		regulator_put(reg);
 	}
 
-	if (gpio_is_valid(st->pdata->gpio_lock_detect))
-		gpio_free(st->pdata->gpio_lock_detect);
-
-	iio_device_free(indio_dev);
-
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
                   ` (3 preceding siblings ...)
  2013-07-22 11:02 ` [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs Sachin Kamat
@ 2013-07-22 11:02 ` Sachin Kamat
  2013-07-22 22:04   ` Marek Vasut
  2013-07-22 11:02 ` [PATCH 6/8] staging: iio: spear_adc: " Sachin Kamat
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Marek Vasut

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 6/8] staging: iio: spear_adc: Use devm_iio_device_alloc
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
                   ` (4 preceding siblings ...)
  2013-07-22 11:02 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Sachin Kamat
@ 2013-07-22 11:02 ` 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 11:03 ` [PATCH 8/8] staging: iio: light: isl29028: " Sachin Kamat
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:02 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Stefan Roese, Viresh Kumar

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Stefan Roese <sr@denx.de>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/staging/iio/adc/spear_adc.c |   30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
index 736219c..20f2d55 100644
--- a/drivers/staging/iio/adc/spear_adc.c
+++ b/drivers/staging/iio/adc/spear_adc.c
@@ -300,11 +300,10 @@ static int spear_adc_probe(struct platform_device *pdev)
 	int ret = -ENODEV;
 	int irq;
 
-	iodev = iio_device_alloc(sizeof(struct spear_adc_info));
+	iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info));
 	if (!iodev) {
 		dev_err(dev, "failed allocating iio device\n");
-		ret = -ENOMEM;
-		goto errout1;
+		return -ENOMEM;
 	}
 
 	info = iio_priv(iodev);
@@ -318,8 +317,7 @@ static int spear_adc_probe(struct platform_device *pdev)
 	info->adc_base_spear6xx = of_iomap(np, 0);
 	if (!info->adc_base_spear6xx) {
 		dev_err(dev, "failed mapping memory\n");
-		ret = -ENOMEM;
-		goto errout2;
+		return -ENOMEM;
 	}
 	info->adc_base_spear3xx =
 		(struct adc_regs_spear3xx *)info->adc_base_spear6xx;
@@ -327,33 +325,33 @@ static int spear_adc_probe(struct platform_device *pdev)
 	info->clk = clk_get(dev, NULL);
 	if (IS_ERR(info->clk)) {
 		dev_err(dev, "failed getting clock\n");
-		goto errout3;
+		goto errout1;
 	}
 
 	ret = clk_prepare_enable(info->clk);
 	if (ret) {
 		dev_err(dev, "failed enabling clock\n");
-		goto errout4;
+		goto errout2;
 	}
 
 	irq = platform_get_irq(pdev, 0);
 	if ((irq < 0) || (irq >= NR_IRQS)) {
 		dev_err(dev, "failed getting interrupt resource\n");
 		ret = -EINVAL;
-		goto errout5;
+		goto errout3;
 	}
 
 	ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
 	if (ret < 0) {
 		dev_err(dev, "failed requesting interrupt\n");
-		goto errout5;
+		goto errout3;
 	}
 
 	if (of_property_read_u32(np, "sampling-frequency",
 				 &info->sampling_freq)) {
 		dev_err(dev, "sampling-frequency missing in DT\n");
 		ret = -EINVAL;
-		goto errout5;
+		goto errout3;
 	}
 
 	/*
@@ -383,21 +381,18 @@ static int spear_adc_probe(struct platform_device *pdev)
 
 	ret = iio_device_register(iodev);
 	if (ret)
-		goto errout5;
+		goto errout3;
 
 	dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
 
 	return 0;
 
-errout5:
-	clk_disable_unprepare(info->clk);
-errout4:
-	clk_put(info->clk);
 errout3:
-	iounmap(info->adc_base_spear6xx);
+	clk_disable_unprepare(info->clk);
 errout2:
-	iio_device_free(iodev);
+	clk_put(info->clk);
 errout1:
+	iounmap(info->adc_base_spear6xx);
 	return ret;
 }
 
@@ -410,7 +405,6 @@ static int spear_adc_remove(struct platform_device *pdev)
 	clk_disable_unprepare(info->clk);
 	clk_put(info->clk);
 	iounmap(info->adc_base_spear6xx);
-	iio_device_free(iodev);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 7/8] staging: iio: light: isl29018: Use devm_iio_device_alloc
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
                   ` (5 preceding siblings ...)
  2013-07-22 11:02 ` [PATCH 6/8] staging: iio: spear_adc: " Sachin Kamat
@ 2013-07-22 11:03 ` Sachin Kamat
  2013-07-22 15:16   ` Rhyland Klein
  2013-07-22 11:03 ` [PATCH 8/8] staging: iio: light: isl29028: " Sachin Kamat
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:03 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Rhyland Klein

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Rhyland Klein <rklein@nvidia.com>
---
 drivers/staging/iio/light/isl29018.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 82478a5..351936c 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -550,11 +550,10 @@ static int isl29018_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int err;
 
-	indio_dev = iio_device_alloc(sizeof(*chip));
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
 	if (indio_dev == NULL) {
 		dev_err(&client->dev, "iio allocation fails\n");
-		err = -ENOMEM;
-		goto exit;
+		return -ENOMEM;
 	}
 	chip = iio_priv(indio_dev);
 
@@ -572,12 +571,12 @@ static int isl29018_probe(struct i2c_client *client,
 	if (IS_ERR(chip->regmap)) {
 		err = PTR_ERR(chip->regmap);
 		dev_err(chip->dev, "regmap initialization failed: %d\n", err);
-		goto exit;
+		return err;
 	}
 
 	err = isl29018_chip_init(chip);
 	if (err)
-		goto exit_iio_free;
+		return err;
 
 	indio_dev->info = &isl29108_info;
 	indio_dev->channels = isl29018_channels;
@@ -588,14 +587,10 @@ static int isl29018_probe(struct i2c_client *client,
 	err = iio_device_register(indio_dev);
 	if (err) {
 		dev_err(&client->dev, "iio registration fails\n");
-		goto exit_iio_free;
+		return err;
 	}
 
 	return 0;
-exit_iio_free:
-	iio_device_free(indio_dev);
-exit:
-	return err;
 }
 
 static int isl29018_remove(struct i2c_client *client)
@@ -604,7 +599,6 @@ static int isl29018_remove(struct i2c_client *client)
 
 	dev_dbg(&client->dev, "%s()\n", __func__);
 	iio_device_unregister(indio_dev);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 8/8] staging: iio: light: isl29028: Use devm_iio_device_alloc
  2013-07-22 11:02 [PATCH 0/8] Use devm_iio_device_alloc Sachin Kamat
                   ` (6 preceding siblings ...)
  2013-07-22 11:03 ` [PATCH 7/8] staging: iio: light: isl29018: " Sachin Kamat
@ 2013-07-22 11:03 ` Sachin Kamat
  2013-07-27 11:31   ` Jonathan Cameron
  7 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-07-22 11:03 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, patches, Laxman Dewangan

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/staging/iio/light/isl29028.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
index 8bb0d03..6014625 100644
--- a/drivers/staging/iio/light/isl29028.c
+++ b/drivers/staging/iio/light/isl29028.c
@@ -482,7 +482,7 @@ static int isl29028_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int ret;
 
-	indio_dev = iio_device_alloc(sizeof(*chip));
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
 	if (!indio_dev) {
 		dev_err(&client->dev, "iio allocation fails\n");
 		return -ENOMEM;
@@ -498,13 +498,13 @@ static int isl29028_probe(struct i2c_client *client,
 	if (IS_ERR(chip->regmap)) {
 		ret = PTR_ERR(chip->regmap);
 		dev_err(chip->dev, "regmap initialization failed: %d\n", ret);
-		goto exit_iio_free;
+		return ret;
 	}
 
 	ret = isl29028_chip_init(chip);
 	if (ret < 0) {
 		dev_err(chip->dev, "chip initialization failed: %d\n", ret);
-		goto exit_iio_free;
+		return ret;
 	}
 
 	indio_dev->info = &isl29028_info;
@@ -517,13 +517,9 @@ static int isl29028_probe(struct i2c_client *client,
 	if (ret < 0) {
 		dev_err(chip->dev, "iio registration fails with error %d\n",
 			ret);
-		goto exit_iio_free;
+		return ret;
 	}
 	return 0;
-
-exit_iio_free:
-	iio_device_free(indio_dev);
-	return ret;
 }
 
 static int isl29028_remove(struct i2c_client *client)
@@ -531,7 +527,6 @@ static int isl29028_remove(struct i2c_client *client)
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
 	iio_device_unregister(indio_dev);
-	iio_device_free(indio_dev);
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 7/8] staging: iio: light: isl29018: Use devm_iio_device_alloc
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Rhyland Klein @ 2013-07-22 15:16 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, jic23, patches

On 7/22/2013 7:03 AM, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Rhyland Klein <rklein@nvidia.com>
> ---
>  drivers/staging/iio/light/isl29018.c |   16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
> index 82478a5..351936c 100644
> --- a/drivers/staging/iio/light/isl29018.c
> +++ b/drivers/staging/iio/light/isl29018.c
> @@ -550,11 +550,10 @@ static int isl29018_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	int err;
>  
> -	indio_dev = iio_device_alloc(sizeof(*chip));
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
>  	if (indio_dev == NULL) {
>  		dev_err(&client->dev, "iio allocation fails\n");
> -		err = -ENOMEM;
> -		goto exit;
> +		return -ENOMEM;
>  	}
>  	chip = iio_priv(indio_dev);
>  
> @@ -572,12 +571,12 @@ static int isl29018_probe(struct i2c_client *client,
>  	if (IS_ERR(chip->regmap)) {
>  		err = PTR_ERR(chip->regmap);
>  		dev_err(chip->dev, "regmap initialization failed: %d\n", err);
> -		goto exit;
> +		return err;
>  	}
>  
>  	err = isl29018_chip_init(chip);
>  	if (err)
> -		goto exit_iio_free;
> +		return err;
>  
>  	indio_dev->info = &isl29108_info;
>  	indio_dev->channels = isl29018_channels;
> @@ -588,14 +587,10 @@ static int isl29018_probe(struct i2c_client *client,
>  	err = iio_device_register(indio_dev);
>  	if (err) {
>  		dev_err(&client->dev, "iio registration fails\n");
> -		goto exit_iio_free;
> +		return err;
>  	}
>  
>  	return 0;
> -exit_iio_free:
> -	iio_device_free(indio_dev);
> -exit:
> -	return err;
>  }
>  
>  static int isl29018_remove(struct i2c_client *client)
> @@ -604,7 +599,6 @@ static int isl29018_remove(struct i2c_client *client)
>  
>  	dev_dbg(&client->dev, "%s()\n", __func__);
>  	iio_device_unregister(indio_dev);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

Thanks!

Acked-by: Rhyland Klein <rklein@nvidia.com>

-- 
nvpublic

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc
  2013-07-22 11:02 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Sachin Kamat
@ 2013-07-22 22:04   ` Marek Vasut
  2013-07-27 11:29     ` Jonathan Cameron
  0 siblings, 1 reply; 19+ messages in thread
From: Marek Vasut @ 2013-07-22 22:04 UTC (permalink / raw)
  To: Sachin Kamat, Hector Palacios; +Cc: linux-iio, jic23, jic23, patches

Dear Sachin Kamat,

> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Marek Vasut <marex@denx.de>

Should work
Reviewed-by: 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;
>  }

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/8] iio: at91: Use devm_iio_device_alloc
  2013-07-22 11:02 ` [PATCH 1/8] iio: at91: " Sachin Kamat
@ 2013-07-27 11:24   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:24 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, patches, Maxime Ripard

On 07/22/13 12:02, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Applied to the togreg branch of iio.git

Thanks
> ---
>  drivers/iio/adc/at91_adc.c |   23 +++++++----------------
>  1 file changed, 7 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index b6db6a0..423e079 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	u32 reg;
>  
> -	idev = iio_device_alloc(sizeof(struct at91_adc_state));
> -	if (idev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state));
> +	if (!idev)
> +		return -ENOMEM;
>  
>  	st = iio_priv(idev);
>  
> @@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>  
>  	if (ret) {
>  		dev_err(&pdev->dev, "No platform data available.\n");
> -		ret = -EINVAL;
> -		goto error_free_device;
> +		return -EINVAL;
>  	}
>  
>  	platform_set_drvdata(pdev, idev);
> @@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev)
>  	st->irq = platform_get_irq(pdev, 0);
>  	if (st->irq < 0) {
>  		dev_err(&pdev->dev, "No IRQ ID is designated\n");
> -		ret = -ENODEV;
> -		goto error_free_device;
> +		return -ENODEV;
>  	}
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  
>  	st->reg_base = devm_ioremap_resource(&pdev->dev, res);
>  	if (IS_ERR(st->reg_base)) {
> -		ret = PTR_ERR(st->reg_base);
> -		goto error_free_device;
> +		return PTR_ERR(st->reg_base);
>  	}
>  
>  	/*
> @@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>  			  idev);
>  	if (ret) {
>  		dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
> -		goto error_free_device;
> +		return ret;
>  	}
>  
>  	st->clk = devm_clk_get(&pdev->dev, "adc_clk");
> @@ -752,9 +747,6 @@ error_disable_clk:
>  	clk_disable_unprepare(st->clk);
>  error_free_irq:
>  	free_irq(st->irq, idev);
> -error_free_device:
> -	iio_device_free(idev);
> -error_ret:
>  	return ret;
>  }
>  
> @@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev)
>  	clk_disable_unprepare(st->adc_clk);
>  	clk_disable_unprepare(st->clk);
>  	free_irq(st->irq, idev);
> -	iio_device_free(idev);
>  
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/8] iio: exynos_adc: Use devm_iio_device_alloc
  2013-07-22 11:02 ` [PATCH 2/8] iio: exynos_adc: " Sachin Kamat
@ 2013-07-27 11:25   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:25 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, patches, Naveen Krishna Chatradhi

On 07/22/13 12:02, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/adc/exynos_adc.c |   23 ++++++++---------------
>  1 file changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index 9809fc9..d25b262 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -33,6 +33,7 @@
>  #include <linux/of_irq.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/of_platform.h>
> +#include <linux/err.h>
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/machine.h>
> @@ -261,7 +262,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
>  	if (!np)
>  		return ret;
>  
> -	indio_dev = iio_device_alloc(sizeof(struct exynos_adc));
> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct exynos_adc));
>  	if (!indio_dev) {
>  		dev_err(&pdev->dev, "failed allocating iio device\n");
>  		return -ENOMEM;
> @@ -271,23 +272,18 @@ static int exynos_adc_probe(struct platform_device *pdev)
>  
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	info->regs = devm_ioremap_resource(&pdev->dev, mem);
> -	if (IS_ERR(info->regs)) {
> -		ret = PTR_ERR(info->regs);
> -		goto err_iio;
> -	}
> +	if (IS_ERR(info->regs))
> +		return PTR_ERR(info->regs);
>  
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
>  	info->enable_reg = devm_ioremap_resource(&pdev->dev, mem);
> -	if (IS_ERR(info->enable_reg)) {
> -		ret = PTR_ERR(info->enable_reg);
> -		goto err_iio;
> -	}
> +	if (IS_ERR(info->enable_reg))
> +		return PTR_ERR(info->enable_reg);
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
>  		dev_err(&pdev->dev, "no irq resource?\n");
> -		ret = irq;
> -		goto err_iio;
> +		return irq;
>  	}
>  
>  	info->irq = irq;
> @@ -299,7 +295,7 @@ static int exynos_adc_probe(struct platform_device *pdev)
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "failed requesting irq, irq = %d\n",
>  							info->irq);
> -		goto err_iio;
> +		return ret;
>  	}
>  
>  	writel(1, info->enable_reg);
> @@ -365,8 +361,6 @@ err_iio_dev:
>  	iio_device_unregister(indio_dev);
>  err_irq:
>  	free_irq(info->irq, info);
> -err_iio:
> -	iio_device_free(indio_dev);
>  	return ret;
>  }
>  
> @@ -382,7 +376,6 @@ static int exynos_adc_remove(struct platform_device *pdev)
>  	writel(0, info->enable_reg);
>  	iio_device_unregister(indio_dev);
>  	free_irq(info->irq, info);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/8] iio: max1363: Use devm_iio_device_alloc
  2013-07-22 11:02 ` [PATCH 3/8] iio: max1363: " Sachin Kamat
@ 2013-07-27 11:25   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:25 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, patches

On 07/22/13 12:02, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied to the togreg branch of iio.git.  Thanks.
> ---
>  drivers/iio/adc/max1363.c |   15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index f148d00..4fb35d1 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	struct regulator *vref;
>  
> -	indio_dev = iio_device_alloc(sizeof(struct max1363_state));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_out;
> -	}
> +	indio_dev = devm_iio_device_alloc(&client->dev,
> +					  sizeof(struct max1363_state));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  
>  	indio_dev->dev.of_node = client->dev.of_node;
>  	ret = iio_map_array_register(indio_dev, client->dev.platform_data);
>  	if (ret < 0)
> -		goto error_free_device;
> +		return ret;
>  
>  	st = iio_priv(indio_dev);
>  
> @@ -1590,9 +1589,6 @@ error_disable_reg:
>  	regulator_disable(st->reg);
>  error_unregister_map:
>  	iio_map_array_unregister(indio_dev);
> -error_free_device:
> -	iio_device_free(indio_dev);
> -error_out:
>  	return ret;
>  }
>  
> @@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client)
>  		regulator_disable(st->vref);
>  	regulator_disable(st->reg);
>  	iio_map_array_unregister(indio_dev);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs
  2013-07-22 11:02 ` [PATCH 4/8] iio: frequency: adf4350: Use devm_* APIs Sachin Kamat
@ 2013-07-27 11:26   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:26 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, patches, Michael Hennerich

On 07/22/13 12:02, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
> This also takes care of missing clk_put function calls implicitly.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Michael Hennerich <michael.hennerich@analog.com>

Nice cleanup.

Applied to togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/frequency/adf4350.c |   31 +++++++++----------------------
>  1 file changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c
> index a4157cd..a7b30be 100644
> --- a/drivers/iio/frequency/adf4350.c
> +++ b/drivers/iio/frequency/adf4350.c
> @@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi)
>  	}
>  
>  	if (!pdata->clkin) {
> -		clk = clk_get(&spi->dev, "clkin");
> +		clk = devm_clk_get(&spi->dev, "clkin");
>  		if (IS_ERR(clk))
>  			return -EPROBE_DEFER;
>  
> @@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi)
>  			return ret;
>  	}
>  
> -	indio_dev = iio_device_alloc(sizeof(*st));
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
>  	if (indio_dev == NULL)
>  		return -ENOMEM;
>  
>  	st = iio_priv(indio_dev);
>  
> -	st->reg = regulator_get(&spi->dev, "vcc");
> +	st->reg = devm_regulator_get(&spi->dev, "vcc");
>  	if (!IS_ERR(st->reg)) {
>  		ret = regulator_enable(st->reg);
>  		if (ret)
> -			goto error_put_reg;
> +			goto error_disable_clk;
>  	}
>  
>  	spi_set_drvdata(spi, indio_dev);
> @@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi)
>  	memset(st->regs_hw, 0xFF, sizeof(st->regs_hw));
>  
>  	if (gpio_is_valid(pdata->gpio_lock_detect)) {
> -		ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name);
> +		ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect,
> +					indio_dev->name);
>  		if (ret) {
>  			dev_err(&spi->dev, "fail to request lock detect GPIO-%d",
>  				pdata->gpio_lock_detect);
> @@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi)
>  	if (pdata->power_up_frequency) {
>  		ret = adf4350_set_freq(st, pdata->power_up_frequency);
>  		if (ret)
> -			goto error_free_gpio;
> +			goto error_disable_reg;
>  	}
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
> -		goto error_free_gpio;
> +		goto error_disable_reg;
>  
>  	return 0;
>  
> -error_free_gpio:
> -	if (gpio_is_valid(pdata->gpio_lock_detect))
> -		gpio_free(pdata->gpio_lock_detect);
> -
>  error_disable_reg:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> -error_put_reg:
> -	if (!IS_ERR(st->reg))
> -		regulator_put(st->reg);
> -
> +error_disable_clk:
>  	if (clk)
>  		clk_disable_unprepare(clk);
> -	iio_device_free(indio_dev);
>  
>  	return ret;
>  }
> @@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi)
>  
>  	if (!IS_ERR(reg)) {
>  		regulator_disable(reg);
> -		regulator_put(reg);
>  	}
>  
> -	if (gpio_is_valid(st->pdata->gpio_lock_detect))
> -		gpio_free(st->pdata->gpio_lock_detect);
> -
> -	iio_device_free(indio_dev);
> -
>  	return 0;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc
  2013-07-22 22:04   ` Marek Vasut
@ 2013-07-27 11:29     ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:29 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Sachin Kamat, Hector Palacios, linux-iio, patches

On 07/22/13 23:04, Marek Vasut wrote:
> Dear Sachin Kamat,
> 
>> Using devm_iio_device_alloc makes code simpler.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> Cc: Marek Vasut <marex@denx.de>
> 
> Should work
> Reviewed-by: Marek Vasut <marex@denx.de>
Applied to the togreg branch of iio.git

Thanks,
> 
>> ---
>>  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;
>>  }
> 
> Best regards,
> Marek Vasut
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/8] staging: iio: spear_adc: Use devm_iio_device_alloc
  2013-07-22 11:02 ` [PATCH 6/8] staging: iio: spear_adc: " Sachin Kamat
@ 2013-07-27 11:29   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:29 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, patches, Stefan Roese, Viresh Kumar

On 07/22/13 12:02, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Stefan Roese <sr@denx.de>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
Applied to the togreg branch of iio.git.

Thanks
> ---
>  drivers/staging/iio/adc/spear_adc.c |   30 ++++++++++++------------------
>  1 file changed, 12 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c
> index 736219c..20f2d55 100644
> --- a/drivers/staging/iio/adc/spear_adc.c
> +++ b/drivers/staging/iio/adc/spear_adc.c
> @@ -300,11 +300,10 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	int ret = -ENODEV;
>  	int irq;
>  
> -	iodev = iio_device_alloc(sizeof(struct spear_adc_info));
> +	iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info));
>  	if (!iodev) {
>  		dev_err(dev, "failed allocating iio device\n");
> -		ret = -ENOMEM;
> -		goto errout1;
> +		return -ENOMEM;
>  	}
>  
>  	info = iio_priv(iodev);
> @@ -318,8 +317,7 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	info->adc_base_spear6xx = of_iomap(np, 0);
>  	if (!info->adc_base_spear6xx) {
>  		dev_err(dev, "failed mapping memory\n");
> -		ret = -ENOMEM;
> -		goto errout2;
> +		return -ENOMEM;
>  	}
>  	info->adc_base_spear3xx =
>  		(struct adc_regs_spear3xx *)info->adc_base_spear6xx;
> @@ -327,33 +325,33 @@ static int spear_adc_probe(struct platform_device *pdev)
>  	info->clk = clk_get(dev, NULL);
>  	if (IS_ERR(info->clk)) {
>  		dev_err(dev, "failed getting clock\n");
> -		goto errout3;
> +		goto errout1;
>  	}
>  
>  	ret = clk_prepare_enable(info->clk);
>  	if (ret) {
>  		dev_err(dev, "failed enabling clock\n");
> -		goto errout4;
> +		goto errout2;
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if ((irq < 0) || (irq >= NR_IRQS)) {
>  		dev_err(dev, "failed getting interrupt resource\n");
>  		ret = -EINVAL;
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info);
>  	if (ret < 0) {
>  		dev_err(dev, "failed requesting interrupt\n");
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	if (of_property_read_u32(np, "sampling-frequency",
>  				 &info->sampling_freq)) {
>  		dev_err(dev, "sampling-frequency missing in DT\n");
>  		ret = -EINVAL;
> -		goto errout5;
> +		goto errout3;
>  	}
>  
>  	/*
> @@ -383,21 +381,18 @@ static int spear_adc_probe(struct platform_device *pdev)
>  
>  	ret = iio_device_register(iodev);
>  	if (ret)
> -		goto errout5;
> +		goto errout3;
>  
>  	dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq);
>  
>  	return 0;
>  
> -errout5:
> -	clk_disable_unprepare(info->clk);
> -errout4:
> -	clk_put(info->clk);
>  errout3:
> -	iounmap(info->adc_base_spear6xx);
> +	clk_disable_unprepare(info->clk);
>  errout2:
> -	iio_device_free(iodev);
> +	clk_put(info->clk);
>  errout1:
> +	iounmap(info->adc_base_spear6xx);
>  	return ret;
>  }
>  
> @@ -410,7 +405,6 @@ static int spear_adc_remove(struct platform_device *pdev)
>  	clk_disable_unprepare(info->clk);
>  	clk_put(info->clk);
>  	iounmap(info->adc_base_spear6xx);
> -	iio_device_free(iodev);
>  
>  	return 0;
>  }
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 7/8] staging: iio: light: isl29018: Use devm_iio_device_alloc
  2013-07-22 15:16   ` Rhyland Klein
@ 2013-07-27 11:30     ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:30 UTC (permalink / raw)
  To: Rhyland Klein; +Cc: Sachin Kamat, linux-iio, jic23, patches

On 07/22/13 16:16, Rhyland Klein wrote:
> On 7/22/2013 7:03 AM, Sachin Kamat wrote:
>> Using devm_iio_device_alloc makes code simpler.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> Cc: Rhyland Klein <rklein@nvidia.com>
Applied to the togreg branch of iio.git

Rhyland, please put any acked-by etc up here as it makes it easy
to find when applying patches (and I'm lazy)
>> ---
>>  drivers/staging/iio/light/isl29018.c |   16 +++++-----------
>>  1 file changed, 5 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
>> index 82478a5..351936c 100644
>> --- a/drivers/staging/iio/light/isl29018.c
>> +++ b/drivers/staging/iio/light/isl29018.c
>> @@ -550,11 +550,10 @@ static int isl29018_probe(struct i2c_client *client,
>>  	struct iio_dev *indio_dev;
>>  	int err;
>>  
>> -	indio_dev = iio_device_alloc(sizeof(*chip));
>> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
>>  	if (indio_dev == NULL) {
>>  		dev_err(&client->dev, "iio allocation fails\n");
>> -		err = -ENOMEM;
>> -		goto exit;
>> +		return -ENOMEM;
>>  	}
>>  	chip = iio_priv(indio_dev);
>>  
>> @@ -572,12 +571,12 @@ static int isl29018_probe(struct i2c_client *client,
>>  	if (IS_ERR(chip->regmap)) {
>>  		err = PTR_ERR(chip->regmap);
>>  		dev_err(chip->dev, "regmap initialization failed: %d\n", err);
>> -		goto exit;
>> +		return err;
>>  	}
>>  
>>  	err = isl29018_chip_init(chip);
>>  	if (err)
>> -		goto exit_iio_free;
>> +		return err;
>>  
>>  	indio_dev->info = &isl29108_info;
>>  	indio_dev->channels = isl29018_channels;
>> @@ -588,14 +587,10 @@ static int isl29018_probe(struct i2c_client *client,
>>  	err = iio_device_register(indio_dev);
>>  	if (err) {
>>  		dev_err(&client->dev, "iio registration fails\n");
>> -		goto exit_iio_free;
>> +		return err;
>>  	}
>>  
>>  	return 0;
>> -exit_iio_free:
>> -	iio_device_free(indio_dev);
>> -exit:
>> -	return err;
>>  }
>>  
>>  static int isl29018_remove(struct i2c_client *client)
>> @@ -604,7 +599,6 @@ static int isl29018_remove(struct i2c_client *client)
>>  
>>  	dev_dbg(&client->dev, "%s()\n", __func__);
>>  	iio_device_unregister(indio_dev);
>> -	iio_device_free(indio_dev);
>>  
>>  	return 0;
>>  }
>>
> 
> Thanks!
> 
> Acked-by: Rhyland Klein <rklein@nvidia.com>
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 8/8] staging: iio: light: isl29028: Use devm_iio_device_alloc
  2013-07-22 11:03 ` [PATCH 8/8] staging: iio: light: isl29028: " Sachin Kamat
@ 2013-07-27 11:31   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-07-27 11:31 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, patches, Laxman Dewangan

On 07/22/13 12:03, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Laxman Dewangan <ldewangan@nvidia.com>
Applied to the togreg branch of iio.git

Thanks for all of these.

> ---
>  drivers/staging/iio/light/isl29028.c |   13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c
> index 8bb0d03..6014625 100644
> --- a/drivers/staging/iio/light/isl29028.c
> +++ b/drivers/staging/iio/light/isl29028.c
> @@ -482,7 +482,7 @@ static int isl29028_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	int ret;
>  
> -	indio_dev = iio_device_alloc(sizeof(*chip));
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
>  	if (!indio_dev) {
>  		dev_err(&client->dev, "iio allocation fails\n");
>  		return -ENOMEM;
> @@ -498,13 +498,13 @@ static int isl29028_probe(struct i2c_client *client,
>  	if (IS_ERR(chip->regmap)) {
>  		ret = PTR_ERR(chip->regmap);
>  		dev_err(chip->dev, "regmap initialization failed: %d\n", ret);
> -		goto exit_iio_free;
> +		return ret;
>  	}
>  
>  	ret = isl29028_chip_init(chip);
>  	if (ret < 0) {
>  		dev_err(chip->dev, "chip initialization failed: %d\n", ret);
> -		goto exit_iio_free;
> +		return ret;
>  	}
>  
>  	indio_dev->info = &isl29028_info;
> @@ -517,13 +517,9 @@ static int isl29028_probe(struct i2c_client *client,
>  	if (ret < 0) {
>  		dev_err(chip->dev, "iio registration fails with error %d\n",
>  			ret);
> -		goto exit_iio_free;
> +		return ret;
>  	}
>  	return 0;
> -
> -exit_iio_free:
> -	iio_device_free(indio_dev);
> -	return ret;
>  }
>  
>  static int isl29028_remove(struct i2c_client *client)
> @@ -531,7 +527,6 @@ static int isl29028_remove(struct i2c_client *client)
>  	struct iio_dev *indio_dev = i2c_get_clientdata(client);
>  
>  	iio_device_unregister(indio_dev);
> -	iio_device_free(indio_dev);
>  	return 0;
>  }
>  
> 

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-07-27 10:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 5/8] staging: iio: mxs-lradc: Use devm_iio_device_alloc Sachin Kamat
2013-07-22 22:04   ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.