All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc
@ 2013-08-13  6:34 Sachin Kamat
  2013-08-13  6:34 ` [PATCH 2/9] iio: gyro: adis16130: " Sachin Kamat
                   ` (9 more replies)
  0 siblings, 10 replies; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Lars-Peter Clausen

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
---
This series compile tested on togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
---
 drivers/iio/gyro/adis16080.c |   21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c
index e1bb5f9..e9ec022 100644
--- a/drivers/iio/gyro/adis16080.c
+++ b/drivers/iio/gyro/adis16080.c
@@ -192,16 +192,13 @@ static const struct adis16080_chip_info adis16080_chip_info[] = {
 static int adis16080_probe(struct spi_device *spi)
 {
 	const struct spi_device_id *id = spi_get_device_id(spi);
-	int ret;
 	struct adis16080_state *st;
 	struct iio_dev *indio_dev;
 
 	/* setup the industrialio driver allocated elements */
-	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
 	st = iio_priv(indio_dev);
 	/* this is only used for removal purposes */
 	spi_set_drvdata(spi, indio_dev);
@@ -217,22 +214,12 @@ static int adis16080_probe(struct spi_device *spi)
 	indio_dev->info = &adis16080_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		goto error_free_dev;
-	return 0;
-
-error_free_dev:
-	iio_device_free(indio_dev);
-error_ret:
-	return ret;
+	return iio_device_register(indio_dev);
 }
 
 static int adis16080_remove(struct spi_device *spi)
 {
 	iio_device_unregister(spi_get_drvdata(spi));
-	iio_device_free(spi_get_drvdata(spi));
-
 	return 0;
 }
 
-- 
1.7.9.5


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

* [PATCH 2/9] iio: gyro: adis16130: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:35   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 3/9] iio: gyro: adis16136: " Sachin Kamat
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Lars-Peter Clausen

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/gyro/adis16130.c |   23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c
index 129acdf..ac66fc1 100644
--- a/drivers/iio/gyro/adis16130.c
+++ b/drivers/iio/gyro/adis16130.c
@@ -148,16 +148,13 @@ static const struct iio_info adis16130_info = {
 
 static int adis16130_probe(struct spi_device *spi)
 {
-	int ret;
 	struct adis16130_state *st;
 	struct iio_dev *indio_dev;
 
 	/* setup the industrialio driver allocated elements */
-	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
 	st = iio_priv(indio_dev);
 	/* this is only used for removal purposes */
 	spi_set_drvdata(spi, indio_dev);
@@ -170,24 +167,12 @@ static int adis16130_probe(struct spi_device *spi)
 	indio_dev->info = &adis16130_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = iio_device_register(indio_dev);
-	if (ret)
-		goto error_free_dev;
-
-	return 0;
-
-error_free_dev:
-	iio_device_free(indio_dev);
-
-error_ret:
-	return ret;
+	return iio_device_register(indio_dev);
 }
 
 static int adis16130_remove(struct spi_device *spi)
 {
 	iio_device_unregister(spi_get_drvdata(spi));
-	iio_device_free(spi_get_drvdata(spi));
-
 	return 0;
 }
 
-- 
1.7.9.5

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

* [PATCH 3/9] iio: gyro: adis16136: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
  2013-08-13  6:34 ` [PATCH 2/9] iio: gyro: adis16130: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:35   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 4/9] iio: gyro: adis16260: " Sachin Kamat
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Lars-Peter Clausen

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/gyro/adis16136.c |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
index 058e6d5..591bd55 100644
--- a/drivers/iio/gyro/adis16136.c
+++ b/drivers/iio/gyro/adis16136.c
@@ -497,7 +497,7 @@ static int adis16136_probe(struct spi_device *spi)
 	struct iio_dev *indio_dev;
 	int ret;
 
-	indio_dev = iio_device_alloc(sizeof(*adis16136));
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16136));
 	if (indio_dev == NULL)
 		return -ENOMEM;
 
@@ -515,11 +515,11 @@ static int adis16136_probe(struct spi_device *spi)
 
 	ret = adis_init(&adis16136->adis, indio_dev, spi, &adis16136_data);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	ret = adis16136_initial_setup(indio_dev);
 	if (ret)
@@ -537,8 +537,6 @@ error_stop_device:
 	adis16136_stop_device(indio_dev);
 error_cleanup_buffer:
 	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
-error_free_dev:
-	iio_device_free(indio_dev);
 	return ret;
 }
 
@@ -552,8 +550,6 @@ static int adis16136_remove(struct spi_device *spi)
 
 	adis_cleanup_buffer_and_trigger(&adis16136->adis, 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/9] iio: gyro: adis16260: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
  2013-08-13  6:34 ` [PATCH 2/9] iio: gyro: adis16130: " Sachin Kamat
  2013-08-13  6:34 ` [PATCH 3/9] iio: gyro: adis16136: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:37   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 5/9] iio: gyro: adxrs450: " Sachin Kamat
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/iio/gyro/adis16260.c |   16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
index b4cf800..0654116 100644
--- a/drivers/iio/gyro/adis16260.c
+++ b/drivers/iio/gyro/adis16260.c
@@ -343,11 +343,9 @@ static int adis16260_probe(struct spi_device *spi)
 	int ret;
 
 	/* setup the industrialio driver allocated elements */
-	indio_dev = iio_device_alloc(sizeof(*adis));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis));
+	if (!indio_dev)
+		return -ENOMEM;
 	adis = iio_priv(indio_dev);
 	/* this is only used for removal purposes */
 	spi_set_drvdata(spi, indio_dev);
@@ -361,11 +359,11 @@ static int adis16260_probe(struct spi_device *spi)
 
 	ret = adis_init(adis, indio_dev, spi, &adis16260_data);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	/* Get the device into a sane initial state */
 	ret = adis_initial_startup(adis);
@@ -379,9 +377,6 @@ static int adis16260_probe(struct spi_device *spi)
 
 error_cleanup_buffer_trigger:
 	adis_cleanup_buffer_and_trigger(adis, indio_dev);
-error_free_dev:
-	iio_device_free(indio_dev);
-error_ret:
 	return ret;
 }
 
@@ -393,7 +388,6 @@ static int adis16260_remove(struct spi_device *spi)
 	iio_device_unregister(indio_dev);
 	adis16260_stop_device(indio_dev);
 	adis_cleanup_buffer_and_trigger(adis, indio_dev);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH 5/9] iio: gyro: adxrs450: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (2 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 4/9] iio: gyro: adis16260: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:38   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 6/9] iio: hid-sensor-gyro-3d: " Sachin Kamat
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/iio/gyro/adxrs450.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c
index 8bd72b4..6dab299 100644
--- a/drivers/iio/gyro/adxrs450.c
+++ b/drivers/iio/gyro/adxrs450.c
@@ -426,11 +426,9 @@ static int adxrs450_probe(struct spi_device *spi)
 	struct iio_dev *indio_dev;
 
 	/* setup the industrialio driver allocated elements */
-	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
 	st = iio_priv(indio_dev);
 	st->us = spi;
 	mutex_init(&st->buf_lock);
@@ -447,7 +445,7 @@ static int adxrs450_probe(struct spi_device *spi)
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	/* Get the device into a sane initial state */
 	ret = adxrs450_initial_setup(indio_dev);
@@ -456,17 +454,12 @@ static int adxrs450_probe(struct spi_device *spi)
 	return 0;
 error_initial:
 	iio_device_unregister(indio_dev);
-error_free_dev:
-	iio_device_free(indio_dev);
-
-error_ret:
 	return ret;
 }
 
 static int adxrs450_remove(struct spi_device *spi)
 {
 	iio_device_unregister(spi_get_drvdata(spi));
-	iio_device_free(spi_get_drvdata(spi));
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH 6/9] iio: hid-sensor-gyro-3d: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (3 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 5/9] iio: gyro: adxrs450: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:39   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 7/9] iio: gyro: itg3200_core: " Sachin Kamat
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Srinivas Pandruvada

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
---
 drivers/iio/gyro/hid-sensor-gyro-3d.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index 9cc8aa1..d9d7bef 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -282,11 +282,9 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
 	struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
 	struct iio_chan_spec *channels;
 
-	indio_dev = iio_device_alloc(sizeof(struct gyro_3d_state));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
+	if (!indio_dev)
+		return -ENOMEM;
 	platform_set_drvdata(pdev, indio_dev);
 
 	gyro_state = iio_priv(indio_dev);
@@ -298,15 +296,14 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
 						&gyro_state->common_attributes);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to setup common attributes\n");
-		goto error_free_dev;
+		return ret;
 	}
 
 	channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
 			   GFP_KERNEL);
 	if (!channels) {
-		ret = -ENOMEM;
 		dev_err(&pdev->dev, "failed to duplicate channels\n");
-		goto error_free_dev;
+		return -ENOMEM;
 	}
 
 	ret = gyro_3d_parse_report(pdev, hsdev, channels,
@@ -363,9 +360,6 @@ error_unreg_buffer_funcs:
 	iio_triggered_buffer_cleanup(indio_dev);
 error_free_dev_mem:
 	kfree(indio_dev->channels);
-error_free_dev:
-	iio_device_free(indio_dev);
-error_ret:
 	return ret;
 }
 
@@ -380,7 +374,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
 	hid_sensor_remove_trigger(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 	kfree(indio_dev->channels);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH 7/9] iio: gyro: itg3200_core: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (4 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 6/9] iio: hid-sensor-gyro-3d: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:40   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 8/9] iio: gyro: st_gyro: " Sachin Kamat
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Christian Strobel

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Christian Strobel <christian.strobel@iis.fraunhofer.de>
---
 drivers/iio/gyro/itg3200_core.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
index d66605d2..4d3f3b9 100644
--- a/drivers/iio/gyro/itg3200_core.c
+++ b/drivers/iio/gyro/itg3200_core.c
@@ -309,11 +309,9 @@ static int itg3200_probe(struct i2c_client *client,
 
 	dev_dbg(&client->dev, "probe I2C dev with IRQ %i", client->irq);
 
-	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret =  -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
 
@@ -330,7 +328,7 @@ static int itg3200_probe(struct i2c_client *client,
 
 	ret = itg3200_buffer_configure(indio_dev);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	if (client->irq) {
 		ret = itg3200_probe_trigger(indio_dev);
@@ -353,9 +351,6 @@ error_remove_trigger:
 		itg3200_remove_trigger(indio_dev);
 error_unconfigure_buffer:
 	itg3200_buffer_unconfigure(indio_dev);
-error_free_dev:
-	iio_device_free(indio_dev);
-error_ret:
 	return ret;
 }
 
@@ -370,8 +365,6 @@ static int itg3200_remove(struct i2c_client *client)
 
 	itg3200_buffer_unconfigure(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/9] iio: gyro: st_gyro: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (5 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 7/9] iio: gyro: itg3200_core: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:41   ` Jonathan Cameron
  2013-08-13  6:34 ` [PATCH 9/9] iio: gyro: adis16060_core: " Sachin Kamat
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Denis Ciocca

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Denis Ciocca <denis.ciocca@st.com>
---
 drivers/iio/gyro/st_gyro_core.c |    1 -
 drivers/iio/gyro/st_gyro_i2c.c  |   15 ++++-----------
 drivers/iio/gyro/st_gyro_spi.c  |   15 ++++-----------
 3 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index 85fa8d3..e13c2b0 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -366,7 +366,6 @@ void st_gyro_common_remove(struct iio_dev *indio_dev)
 		st_sensors_deallocate_trigger(indio_dev);
 		st_gyro_deallocate_ring(indio_dev);
 	}
-	iio_device_free(indio_dev);
 }
 EXPORT_SYMBOL(st_gyro_common_remove);
 
diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
index c7a29a4..16b8b8d 100644
--- a/drivers/iio/gyro/st_gyro_i2c.c
+++ b/drivers/iio/gyro/st_gyro_i2c.c
@@ -25,11 +25,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
 	struct st_sensor_data *gdata;
 	int err;
 
-	indio_dev = iio_device_alloc(sizeof(*gdata));
-	if (indio_dev == NULL) {
-		err = -ENOMEM;
-		goto iio_device_alloc_error;
-	}
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*gdata));
+	if (!indio_dev)
+		return -ENOMEM;
 
 	gdata = iio_priv(indio_dev);
 	gdata->dev = &client->dev;
@@ -39,14 +37,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
 	err = st_gyro_common_probe(indio_dev,
 				(struct st_sensors_platform_data *)&gyro_pdata);
 	if (err < 0)
-		goto st_gyro_common_probe_error;
+		return err;
 
 	return 0;
-
-st_gyro_common_probe_error:
-	iio_device_free(indio_dev);
-iio_device_alloc_error:
-	return err;
 }
 
 static int st_gyro_i2c_remove(struct i2c_client *client)
diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
index 14b0762..94763e2 100644
--- a/drivers/iio/gyro/st_gyro_spi.c
+++ b/drivers/iio/gyro/st_gyro_spi.c
@@ -24,11 +24,9 @@ static int st_gyro_spi_probe(struct spi_device *spi)
 	struct st_sensor_data *gdata;
 	int err;
 
-	indio_dev = iio_device_alloc(sizeof(*gdata));
-	if (indio_dev == NULL) {
-		err = -ENOMEM;
-		goto iio_device_alloc_error;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*gdata));
+	if (!indio_dev)
+		return -ENOMEM;
 
 	gdata = iio_priv(indio_dev);
 	gdata->dev = &spi->dev;
@@ -38,14 +36,9 @@ static int st_gyro_spi_probe(struct spi_device *spi)
 	err = st_gyro_common_probe(indio_dev,
 				(struct st_sensors_platform_data *)&gyro_pdata);
 	if (err < 0)
-		goto st_gyro_common_probe_error;
+		return err;
 
 	return 0;
-
-st_gyro_common_probe_error:
-	iio_device_free(indio_dev);
-iio_device_alloc_error:
-	return err;
 }
 
 static int st_gyro_spi_remove(struct spi_device *spi)
-- 
1.7.9.5

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

* [PATCH 9/9] iio: gyro: adis16060_core: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (6 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 8/9] iio: gyro: st_gyro: " Sachin Kamat
@ 2013-08-13  6:34 ` Sachin Kamat
  2013-08-13 18:42   ` Jonathan Cameron
  2013-08-13  9:03 ` [PATCH 1/9] iio: gyro: adis16080: " Lars-Peter Clausen
  2013-08-13 18:32 ` Jonathan Cameron
  9 siblings, 1 reply; 19+ messages in thread
From: Sachin Kamat @ 2013-08-13  6:34 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/staging/iio/gyro/adis16060_core.c |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c
index c67d3a8..6d3d771 100644
--- a/drivers/staging/iio/gyro/adis16060_core.c
+++ b/drivers/staging/iio/gyro/adis16060_core.c
@@ -151,11 +151,9 @@ static int adis16060_r_probe(struct spi_device *spi)
 	struct iio_dev *indio_dev;
 
 	/* setup the industrialio driver allocated elements */
-	indio_dev = iio_device_alloc(sizeof(*st));
-	if (indio_dev == NULL) {
-		ret = -ENOMEM;
-		goto error_ret;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+	if (!indio_dev)
+		return -ENOMEM;
 	/* this is only used for removal purposes */
 	spi_set_drvdata(spi, indio_dev);
 	st = iio_priv(indio_dev);
@@ -171,23 +169,16 @@ static int adis16060_r_probe(struct spi_device *spi)
 
 	ret = iio_device_register(indio_dev);
 	if (ret)
-		goto error_free_dev;
+		return ret;
 
 	adis16060_iio_dev = indio_dev;
 	return 0;
-
-error_free_dev:
-	iio_device_free(indio_dev);
-error_ret:
-	return ret;
 }
 
 /* fixme, confirm ordering in this function */
 static int adis16060_r_remove(struct spi_device *spi)
 {
 	iio_device_unregister(spi_get_drvdata(spi));
-	iio_device_free(spi_get_drvdata(spi));
-
 	return 0;
 }
 
-- 
1.7.9.5

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

* Re: [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (7 preceding siblings ...)
  2013-08-13  6:34 ` [PATCH 9/9] iio: gyro: adis16060_core: " Sachin Kamat
@ 2013-08-13  9:03 ` Lars-Peter Clausen
  2013-08-13 18:32 ` Jonathan Cameron
  9 siblings, 0 replies; 19+ messages in thread
From: Lars-Peter Clausen @ 2013-08-13  9:03 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, jic23

On 08/13/2013 08:34 AM, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>

All the adis* patches in this series:

Acked-by: Lars-Peter Clausen <lars@metafoo.de>

> ---
> This series compile tested on togreg branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> ---
>   drivers/iio/gyro/adis16080.c |   21 ++++-----------------
>   1 file changed, 4 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c
> index e1bb5f9..e9ec022 100644
> --- a/drivers/iio/gyro/adis16080.c
> +++ b/drivers/iio/gyro/adis16080.c
> @@ -192,16 +192,13 @@ static const struct adis16080_chip_info adis16080_chip_info[] = {
>   static int adis16080_probe(struct spi_device *spi)
>   {
>   	const struct spi_device_id *id = spi_get_device_id(spi);
> -	int ret;
>   	struct adis16080_state *st;
>   	struct iio_dev *indio_dev;
>
>   	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>   	st = iio_priv(indio_dev);
>   	/* this is only used for removal purposes */
>   	spi_set_drvdata(spi, indio_dev);
> @@ -217,22 +214,12 @@ static int adis16080_probe(struct spi_device *spi)
>   	indio_dev->info = &adis16080_info;
>   	indio_dev->modes = INDIO_DIRECT_MODE;
>
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto error_free_dev;
> -	return 0;
> -
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
> -	return ret;
> +	return iio_device_register(indio_dev);
>   }
>
>   static int adis16080_remove(struct spi_device *spi)
>   {
>   	iio_device_unregister(spi_get_drvdata(spi));
> -	iio_device_free(spi_get_drvdata(spi));
> -
>   	return 0;
>   }
>
>


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

* Re: [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc
  2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
                   ` (8 preceding siblings ...)
  2013-08-13  9:03 ` [PATCH 1/9] iio: gyro: adis16080: " Lars-Peter Clausen
@ 2013-08-13 18:32 ` Jonathan Cameron
  9 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:32 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Lars-Peter Clausen

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git.

Thanks,

Jonathan
> ---
> This series compile tested on togreg branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> ---
>  drivers/iio/gyro/adis16080.c |   21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c
> index e1bb5f9..e9ec022 100644
> --- a/drivers/iio/gyro/adis16080.c
> +++ b/drivers/iio/gyro/adis16080.c
> @@ -192,16 +192,13 @@ static const struct adis16080_chip_info adis16080_chip_info[] = {
>  static int adis16080_probe(struct spi_device *spi)
>  {
>  	const struct spi_device_id *id = spi_get_device_id(spi);
> -	int ret;
>  	struct adis16080_state *st;
>  	struct iio_dev *indio_dev;
>  
>  	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	st = iio_priv(indio_dev);
>  	/* this is only used for removal purposes */
>  	spi_set_drvdata(spi, indio_dev);
> @@ -217,22 +214,12 @@ static int adis16080_probe(struct spi_device *spi)
>  	indio_dev->info = &adis16080_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto error_free_dev;
> -	return 0;
> -
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
> -	return ret;
> +	return iio_device_register(indio_dev);
>  }
>  
>  static int adis16080_remove(struct spi_device *spi)
>  {
>  	iio_device_unregister(spi_get_drvdata(spi));
> -	iio_device_free(spi_get_drvdata(spi));
> -
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH 2/9] iio: gyro: adis16130: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 2/9] iio: gyro: adis16130: " Sachin Kamat
@ 2013-08-13 18:35   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:35 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Lars-Peter Clausen

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/gyro/adis16130.c |   23 ++++-------------------
>  1 file changed, 4 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c
> index 129acdf..ac66fc1 100644
> --- a/drivers/iio/gyro/adis16130.c
> +++ b/drivers/iio/gyro/adis16130.c
> @@ -148,16 +148,13 @@ static const struct iio_info adis16130_info = {
>  
>  static int adis16130_probe(struct spi_device *spi)
>  {
> -	int ret;
>  	struct adis16130_state *st;
>  	struct iio_dev *indio_dev;
>  
>  	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	st = iio_priv(indio_dev);
>  	/* this is only used for removal purposes */
>  	spi_set_drvdata(spi, indio_dev);
> @@ -170,24 +167,12 @@ static int adis16130_probe(struct spi_device *spi)
>  	indio_dev->info = &adis16130_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = iio_device_register(indio_dev);
> -	if (ret)
> -		goto error_free_dev;
> -
> -	return 0;
> -
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -
> -error_ret:
> -	return ret;
> +	return iio_device_register(indio_dev);
>  }
>  
>  static int adis16130_remove(struct spi_device *spi)
>  {
>  	iio_device_unregister(spi_get_drvdata(spi));
> -	iio_device_free(spi_get_drvdata(spi));
> -
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH 3/9] iio: gyro: adis16136: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 3/9] iio: gyro: adis16136: " Sachin Kamat
@ 2013-08-13 18:35   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:35 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Lars-Peter Clausen

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git

Thanks,

> ---
>  drivers/iio/gyro/adis16136.c |   10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
> index 058e6d5..591bd55 100644
> --- a/drivers/iio/gyro/adis16136.c
> +++ b/drivers/iio/gyro/adis16136.c
> @@ -497,7 +497,7 @@ static int adis16136_probe(struct spi_device *spi)
>  	struct iio_dev *indio_dev;
>  	int ret;
>  
> -	indio_dev = iio_device_alloc(sizeof(*adis16136));
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16136));
>  	if (indio_dev == NULL)
>  		return -ENOMEM;
>  
> @@ -515,11 +515,11 @@ static int adis16136_probe(struct spi_device *spi)
>  
>  	ret = adis_init(&adis16136->adis, indio_dev, spi, &adis16136_data);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	ret = adis16136_initial_setup(indio_dev);
>  	if (ret)
> @@ -537,8 +537,6 @@ error_stop_device:
>  	adis16136_stop_device(indio_dev);
>  error_cleanup_buffer:
>  	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
> -error_free_dev:
> -	iio_device_free(indio_dev);
>  	return ret;
>  }
>  
> @@ -552,8 +550,6 @@ static int adis16136_remove(struct spi_device *spi)
>  
>  	adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev);
>  
> -	iio_device_free(indio_dev);
> -
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH 4/9] iio: gyro: adis16260: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 4/9] iio: gyro: adis16260: " Sachin Kamat
@ 2013-08-13 18:37   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:37 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied.
(getting lazy with my messages.  One day I'll get around to automating them automate them).
> ---
>  drivers/iio/gyro/adis16260.c |   16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
> index b4cf800..0654116 100644
> --- a/drivers/iio/gyro/adis16260.c
> +++ b/drivers/iio/gyro/adis16260.c
> @@ -343,11 +343,9 @@ static int adis16260_probe(struct spi_device *spi)
>  	int ret;
>  
>  	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*adis));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	adis = iio_priv(indio_dev);
>  	/* this is only used for removal purposes */
>  	spi_set_drvdata(spi, indio_dev);
> @@ -361,11 +359,11 @@ static int adis16260_probe(struct spi_device *spi)
>  
>  	ret = adis_init(adis, indio_dev, spi, &adis16260_data);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	/* Get the device into a sane initial state */
>  	ret = adis_initial_startup(adis);
> @@ -379,9 +377,6 @@ static int adis16260_probe(struct spi_device *spi)
>  
>  error_cleanup_buffer_trigger:
>  	adis_cleanup_buffer_and_trigger(adis, indio_dev);
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
>  	return ret;
>  }
>  
> @@ -393,7 +388,6 @@ static int adis16260_remove(struct spi_device *spi)
>  	iio_device_unregister(indio_dev);
>  	adis16260_stop_device(indio_dev);
>  	adis_cleanup_buffer_and_trigger(adis, indio_dev);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH 5/9] iio: gyro: adxrs450: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 5/9] iio: gyro: adxrs450: " Sachin Kamat
@ 2013-08-13 18:38   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:38 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied.
> ---
>  drivers/iio/gyro/adxrs450.c |   15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c
> index 8bd72b4..6dab299 100644
> --- a/drivers/iio/gyro/adxrs450.c
> +++ b/drivers/iio/gyro/adxrs450.c
> @@ -426,11 +426,9 @@ static int adxrs450_probe(struct spi_device *spi)
>  	struct iio_dev *indio_dev;
>  
>  	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	st = iio_priv(indio_dev);
>  	st->us = spi;
>  	mutex_init(&st->buf_lock);
> @@ -447,7 +445,7 @@ static int adxrs450_probe(struct spi_device *spi)
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	/* Get the device into a sane initial state */
>  	ret = adxrs450_initial_setup(indio_dev);
> @@ -456,17 +454,12 @@ static int adxrs450_probe(struct spi_device *spi)
>  	return 0;
>  error_initial:
>  	iio_device_unregister(indio_dev);
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -
> -error_ret:
>  	return ret;
>  }
>  
>  static int adxrs450_remove(struct spi_device *spi)
>  {
>  	iio_device_unregister(spi_get_drvdata(spi));
> -	iio_device_free(spi_get_drvdata(spi));
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH 6/9] iio: hid-sensor-gyro-3d: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 6/9] iio: hid-sensor-gyro-3d: " Sachin Kamat
@ 2013-08-13 18:39   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:39 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Srinivas Pandruvada

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Srinivas Pandruvada <srinivas.pandruvada@intel.com>
Applied to the togreg branch of iio.git.
> ---
>  drivers/iio/gyro/hid-sensor-gyro-3d.c |   17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> index 9cc8aa1..d9d7bef 100644
> --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
> +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
> @@ -282,11 +282,9 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
>  	struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
>  	struct iio_chan_spec *channels;
>  
> -	indio_dev = iio_device_alloc(sizeof(struct gyro_3d_state));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	platform_set_drvdata(pdev, indio_dev);
>  
>  	gyro_state = iio_priv(indio_dev);
> @@ -298,15 +296,14 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
>  						&gyro_state->common_attributes);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to setup common attributes\n");
> -		goto error_free_dev;
> +		return ret;
>  	}
>  
>  	channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
>  			   GFP_KERNEL);
>  	if (!channels) {
> -		ret = -ENOMEM;
>  		dev_err(&pdev->dev, "failed to duplicate channels\n");
> -		goto error_free_dev;
> +		return -ENOMEM;
>  	}
>  
>  	ret = gyro_3d_parse_report(pdev, hsdev, channels,
> @@ -363,9 +360,6 @@ error_unreg_buffer_funcs:
>  	iio_triggered_buffer_cleanup(indio_dev);
>  error_free_dev_mem:
>  	kfree(indio_dev->channels);
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
>  	return ret;
>  }
>  
> @@ -380,7 +374,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
>  	hid_sensor_remove_trigger(indio_dev);
>  	iio_triggered_buffer_cleanup(indio_dev);
>  	kfree(indio_dev->channels);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH 7/9] iio: gyro: itg3200_core: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 7/9] iio: gyro: itg3200_core: " Sachin Kamat
@ 2013-08-13 18:40   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:40 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Christian Strobel

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Christian Strobel <christian.strobel@iis.fraunhofer.de>
Applied to the togreg branch of iio.git

Jonathan
> ---
>  drivers/iio/gyro/itg3200_core.c |   15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c
> index d66605d2..4d3f3b9 100644
> --- a/drivers/iio/gyro/itg3200_core.c
> +++ b/drivers/iio/gyro/itg3200_core.c
> @@ -309,11 +309,9 @@ static int itg3200_probe(struct i2c_client *client,
>  
>  	dev_dbg(&client->dev, "probe I2C dev with IRQ %i", client->irq);
>  
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret =  -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  
>  	st = iio_priv(indio_dev);
>  
> @@ -330,7 +328,7 @@ static int itg3200_probe(struct i2c_client *client,
>  
>  	ret = itg3200_buffer_configure(indio_dev);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	if (client->irq) {
>  		ret = itg3200_probe_trigger(indio_dev);
> @@ -353,9 +351,6 @@ error_remove_trigger:
>  		itg3200_remove_trigger(indio_dev);
>  error_unconfigure_buffer:
>  	itg3200_buffer_unconfigure(indio_dev);
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
>  	return ret;
>  }
>  
> @@ -370,8 +365,6 @@ static int itg3200_remove(struct i2c_client *client)
>  
>  	itg3200_buffer_unconfigure(indio_dev);
>  
> -	iio_device_free(indio_dev);
> -
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH 8/9] iio: gyro: st_gyro: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 8/9] iio: gyro: st_gyro: " Sachin Kamat
@ 2013-08-13 18:41   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:41 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Denis Ciocca

On 08/13/13 07:34, Sachin Kamat wrote:
> Using devm_iio_device_alloc makes code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Denis Ciocca <denis.ciocca@st.com>
Applied to the togreg branch of iio.git

Thanks,

Jonathan
> ---
>  drivers/iio/gyro/st_gyro_core.c |    1 -
>  drivers/iio/gyro/st_gyro_i2c.c  |   15 ++++-----------
>  drivers/iio/gyro/st_gyro_spi.c  |   15 ++++-----------
>  3 files changed, 8 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
> index 85fa8d3..e13c2b0 100644
> --- a/drivers/iio/gyro/st_gyro_core.c
> +++ b/drivers/iio/gyro/st_gyro_core.c
> @@ -366,7 +366,6 @@ void st_gyro_common_remove(struct iio_dev *indio_dev)
>  		st_sensors_deallocate_trigger(indio_dev);
>  		st_gyro_deallocate_ring(indio_dev);
>  	}
> -	iio_device_free(indio_dev);
>  }
>  EXPORT_SYMBOL(st_gyro_common_remove);
>  
> diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c
> index c7a29a4..16b8b8d 100644
> --- a/drivers/iio/gyro/st_gyro_i2c.c
> +++ b/drivers/iio/gyro/st_gyro_i2c.c
> @@ -25,11 +25,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
>  	struct st_sensor_data *gdata;
>  	int err;
>  
> -	indio_dev = iio_device_alloc(sizeof(*gdata));
> -	if (indio_dev == NULL) {
> -		err = -ENOMEM;
> -		goto iio_device_alloc_error;
> -	}
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*gdata));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  
>  	gdata = iio_priv(indio_dev);
>  	gdata->dev = &client->dev;
> @@ -39,14 +37,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client,
>  	err = st_gyro_common_probe(indio_dev,
>  				(struct st_sensors_platform_data *)&gyro_pdata);
>  	if (err < 0)
> -		goto st_gyro_common_probe_error;
> +		return err;
>  
>  	return 0;
> -
> -st_gyro_common_probe_error:
> -	iio_device_free(indio_dev);
> -iio_device_alloc_error:
> -	return err;
>  }
>  
>  static int st_gyro_i2c_remove(struct i2c_client *client)
> diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> index 14b0762..94763e2 100644
> --- a/drivers/iio/gyro/st_gyro_spi.c
> +++ b/drivers/iio/gyro/st_gyro_spi.c
> @@ -24,11 +24,9 @@ static int st_gyro_spi_probe(struct spi_device *spi)
>  	struct st_sensor_data *gdata;
>  	int err;
>  
> -	indio_dev = iio_device_alloc(sizeof(*gdata));
> -	if (indio_dev == NULL) {
> -		err = -ENOMEM;
> -		goto iio_device_alloc_error;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*gdata));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  
>  	gdata = iio_priv(indio_dev);
>  	gdata->dev = &spi->dev;
> @@ -38,14 +36,9 @@ static int st_gyro_spi_probe(struct spi_device *spi)
>  	err = st_gyro_common_probe(indio_dev,
>  				(struct st_sensors_platform_data *)&gyro_pdata);
>  	if (err < 0)
> -		goto st_gyro_common_probe_error;
> +		return err;
>  
>  	return 0;
> -
> -st_gyro_common_probe_error:
> -	iio_device_free(indio_dev);
> -iio_device_alloc_error:
> -	return err;
>  }
>  
>  static int st_gyro_spi_remove(struct spi_device *spi)
> 

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

* Re: [PATCH 9/9] iio: gyro: adis16060_core: Use devm_iio_device_alloc
  2013-08-13  6:34 ` [PATCH 9/9] iio: gyro: adis16060_core: " Sachin Kamat
@ 2013-08-13 18:42   ` Jonathan Cameron
  0 siblings, 0 replies; 19+ messages in thread
From: Jonathan Cameron @ 2013-08-13 18:42 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23

On 08/13/13 07:34, 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 again for doing all these.

Jonathan
> ---
>  drivers/staging/iio/gyro/adis16060_core.c |   17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c
> index c67d3a8..6d3d771 100644
> --- a/drivers/staging/iio/gyro/adis16060_core.c
> +++ b/drivers/staging/iio/gyro/adis16060_core.c
> @@ -151,11 +151,9 @@ static int adis16060_r_probe(struct spi_device *spi)
>  	struct iio_dev *indio_dev;
>  
>  	/* setup the industrialio driver allocated elements */
> -	indio_dev = iio_device_alloc(sizeof(*st));
> -	if (indio_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto error_ret;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  	/* this is only used for removal purposes */
>  	spi_set_drvdata(spi, indio_dev);
>  	st = iio_priv(indio_dev);
> @@ -171,23 +169,16 @@ static int adis16060_r_probe(struct spi_device *spi)
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret)
> -		goto error_free_dev;
> +		return ret;
>  
>  	adis16060_iio_dev = indio_dev;
>  	return 0;
> -
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -error_ret:
> -	return ret;
>  }
>  
>  /* fixme, confirm ordering in this function */
>  static int adis16060_r_remove(struct spi_device *spi)
>  {
>  	iio_device_unregister(spi_get_drvdata(spi));
> -	iio_device_free(spi_get_drvdata(spi));
> -
>  	return 0;
>  }
>  
> 

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

end of thread, other threads:[~2013-08-13 17:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13  6:34 [PATCH 1/9] iio: gyro: adis16080: Use devm_iio_device_alloc Sachin Kamat
2013-08-13  6:34 ` [PATCH 2/9] iio: gyro: adis16130: " Sachin Kamat
2013-08-13 18:35   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 3/9] iio: gyro: adis16136: " Sachin Kamat
2013-08-13 18:35   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 4/9] iio: gyro: adis16260: " Sachin Kamat
2013-08-13 18:37   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 5/9] iio: gyro: adxrs450: " Sachin Kamat
2013-08-13 18:38   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 6/9] iio: hid-sensor-gyro-3d: " Sachin Kamat
2013-08-13 18:39   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 7/9] iio: gyro: itg3200_core: " Sachin Kamat
2013-08-13 18:40   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 8/9] iio: gyro: st_gyro: " Sachin Kamat
2013-08-13 18:41   ` Jonathan Cameron
2013-08-13  6:34 ` [PATCH 9/9] iio: gyro: adis16060_core: " Sachin Kamat
2013-08-13 18:42   ` Jonathan Cameron
2013-08-13  9:03 ` [PATCH 1/9] iio: gyro: adis16080: " Lars-Peter Clausen
2013-08-13 18:32 ` 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.