All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs
@ 2013-07-30  6:24 Sachin Kamat
  2013-07-30  6:24 ` [PATCH 2/3] iio: frequency: ad9523: " Sachin Kamat
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sachin Kamat @ 2013-07-30  6:24 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Michael Hennerich

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
---
This series compile tested on togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
---
 drivers/iio/amplifiers/ad8366.c |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index d354554..d0a79a4 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -139,17 +139,17 @@ static int ad8366_probe(struct spi_device *spi)
 	struct ad8366_state *st;
 	int 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;
+			return ret;
 	}
 
 	spi_set_drvdata(spi, indio_dev);
@@ -173,11 +173,6 @@ static int ad8366_probe(struct spi_device *spi)
 error_disable_reg:
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-error_put_reg:
-	if (!IS_ERR(st->reg))
-		regulator_put(st->reg);
-
-	iio_device_free(indio_dev);
 
 	return ret;
 }
@@ -195,8 +190,6 @@ static int ad8366_remove(struct spi_device *spi)
 		regulator_put(reg);
 	}
 
-	iio_device_free(indio_dev);
-
 	return 0;
 }
 
-- 
1.7.9.5

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

* [PATCH 2/3] iio: frequency: ad9523: Use devm_* APIs
  2013-07-30  6:24 [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Sachin Kamat
@ 2013-07-30  6:24 ` Sachin Kamat
  2013-08-03 20:01   ` Jonathan Cameron
  2013-07-30  6:24 ` [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc Sachin Kamat
  2013-08-03 20:00 ` [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Sachin Kamat @ 2013-07-30  6:24 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, jic23, sachin.kamat, Michael Hennerich

devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
---
 drivers/iio/frequency/ad9523.c |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index 92276de..7c5245d 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -961,17 +961,17 @@ static int ad9523_probe(struct spi_device *spi)
 		return -EINVAL;
 	}
 
-	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;
+			return ret;
 	}
 
 	spi_set_drvdata(spi, indio_dev);
@@ -1001,11 +1001,6 @@ static int ad9523_probe(struct spi_device *spi)
 error_disable_reg:
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-error_put_reg:
-	if (!IS_ERR(st->reg))
-		regulator_put(st->reg);
-
-	iio_device_free(indio_dev);
 
 	return ret;
 }
@@ -1017,12 +1012,8 @@ static int ad9523_remove(struct spi_device *spi)
 
 	iio_device_unregister(indio_dev);
 
-	if (!IS_ERR(st->reg)) {
+	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-		regulator_put(st->reg);
-	}
-
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc
  2013-07-30  6:24 [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Sachin Kamat
  2013-07-30  6:24 ` [PATCH 2/3] iio: frequency: ad9523: " Sachin Kamat
@ 2013-07-30  6:24 ` Sachin Kamat
  2013-08-03 20:03   ` Jonathan Cameron
  2013-08-03 20:00 ` [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Sachin Kamat @ 2013-07-30  6:24 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/pressure/st_pressure_core.c |    1 -
 drivers/iio/pressure/st_pressure_i2c.c  |   15 ++++-----------
 drivers/iio/pressure/st_pressure_spi.c  |   15 ++++-----------
 3 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index b8ecc87..093b045 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -270,7 +270,6 @@ void st_press_common_remove(struct iio_dev *indio_dev)
 		st_sensors_deallocate_trigger(indio_dev);
 		st_press_deallocate_ring(indio_dev);
 	}
-	iio_device_free(indio_dev);
 }
 EXPORT_SYMBOL(st_press_common_remove);
 
diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
index 3065993..08aac5e 100644
--- a/drivers/iio/pressure/st_pressure_i2c.c
+++ b/drivers/iio/pressure/st_pressure_i2c.c
@@ -25,11 +25,9 @@ static int st_press_i2c_probe(struct i2c_client *client,
 	struct st_sensor_data *pdata;
 	int err;
 
-	indio_dev = iio_device_alloc(sizeof(*pdata));
-	if (indio_dev == NULL) {
-		err = -ENOMEM;
-		goto iio_device_alloc_error;
-	}
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pdata));
+	if (!indio_dev)
+		return -ENOMEM;
 
 	pdata = iio_priv(indio_dev);
 	pdata->dev = &client->dev;
@@ -38,14 +36,9 @@ static int st_press_i2c_probe(struct i2c_client *client,
 
 	err = st_press_common_probe(indio_dev, client->dev.platform_data);
 	if (err < 0)
-		goto st_press_common_probe_error;
+		return err;
 
 	return 0;
-
-st_press_common_probe_error:
-	iio_device_free(indio_dev);
-iio_device_alloc_error:
-	return err;
 }
 
 static int st_press_i2c_remove(struct i2c_client *client)
diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
index b2aded6..399a29b 100644
--- a/drivers/iio/pressure/st_pressure_spi.c
+++ b/drivers/iio/pressure/st_pressure_spi.c
@@ -24,11 +24,9 @@ static int st_press_spi_probe(struct spi_device *spi)
 	struct st_sensor_data *pdata;
 	int err;
 
-	indio_dev = iio_device_alloc(sizeof(*pdata));
-	if (indio_dev == NULL) {
-		err = -ENOMEM;
-		goto iio_device_alloc_error;
-	}
+	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*pdata));
+	if (indio_dev == NULL)
+		return -ENOMEM;
 
 	pdata = iio_priv(indio_dev);
 	pdata->dev = &spi->dev;
@@ -37,14 +35,9 @@ static int st_press_spi_probe(struct spi_device *spi)
 
 	err = st_press_common_probe(indio_dev, spi->dev.platform_data);
 	if (err < 0)
-		goto st_press_common_probe_error;
+		return err;
 
 	return 0;
-
-st_press_common_probe_error:
-	iio_device_free(indio_dev);
-iio_device_alloc_error:
-	return err;
 }
 
 static int st_press_spi_remove(struct spi_device *spi)
-- 
1.7.9.5

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

* Re: [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs
  2013-07-30  6:24 [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Sachin Kamat
  2013-07-30  6:24 ` [PATCH 2/3] iio: frequency: ad9523: " Sachin Kamat
  2013-07-30  6:24 ` [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc Sachin Kamat
@ 2013-08-03 20:00 ` Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 20:00 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Michael Hennerich

On 07/30/13 07:24, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
Applied to the togreg branch of iio.git

Thanks.
> ---
> This series compile tested on togreg branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> ---
>  drivers/iio/amplifiers/ad8366.c |   13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index d354554..d0a79a4 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -139,17 +139,17 @@ static int ad8366_probe(struct spi_device *spi)
>  	struct ad8366_state *st;
>  	int 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;
> +			return ret;
>  	}
>  
>  	spi_set_drvdata(spi, indio_dev);
> @@ -173,11 +173,6 @@ static int ad8366_probe(struct spi_device *spi)
>  error_disable_reg:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> -error_put_reg:
> -	if (!IS_ERR(st->reg))
> -		regulator_put(st->reg);
> -
> -	iio_device_free(indio_dev);
>  
>  	return ret;
>  }
> @@ -195,8 +190,6 @@ static int ad8366_remove(struct spi_device *spi)
>  		regulator_put(reg);
>  	}
>  
> -	iio_device_free(indio_dev);
> -
>  	return 0;
>  }
>  
> 

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

* Re: [PATCH 2/3] iio: frequency: ad9523: Use devm_* APIs
  2013-07-30  6:24 ` [PATCH 2/3] iio: frequency: ad9523: " Sachin Kamat
@ 2013-08-03 20:01   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 20:01 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Michael Hennerich

On 07/30/13 07:24, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Michael Hennerich <hennerich@blackfin.uclinux.org>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/frequency/ad9523.c |   17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
> index 92276de..7c5245d 100644
> --- a/drivers/iio/frequency/ad9523.c
> +++ b/drivers/iio/frequency/ad9523.c
> @@ -961,17 +961,17 @@ static int ad9523_probe(struct spi_device *spi)
>  		return -EINVAL;
>  	}
>  
> -	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;
> +			return ret;
>  	}
>  
>  	spi_set_drvdata(spi, indio_dev);
> @@ -1001,11 +1001,6 @@ static int ad9523_probe(struct spi_device *spi)
>  error_disable_reg:
>  	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> -error_put_reg:
> -	if (!IS_ERR(st->reg))
> -		regulator_put(st->reg);
> -
> -	iio_device_free(indio_dev);
>  
>  	return ret;
>  }
> @@ -1017,12 +1012,8 @@ static int ad9523_remove(struct spi_device *spi)
>  
>  	iio_device_unregister(indio_dev);
>  
> -	if (!IS_ERR(st->reg)) {
> +	if (!IS_ERR(st->reg))
>  		regulator_disable(st->reg);
> -		regulator_put(st->reg);
> -	}
> -
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 

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

* Re: [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc
  2013-07-30  6:24 ` [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc Sachin Kamat
@ 2013-08-03 20:03   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 20:03 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-iio, jic23, Denis Ciocca

On 07/30/13 07:24, 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,
> ---
>  drivers/iio/pressure/st_pressure_core.c |    1 -
>  drivers/iio/pressure/st_pressure_i2c.c  |   15 ++++-----------
>  drivers/iio/pressure/st_pressure_spi.c  |   15 ++++-----------
>  3 files changed, 8 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> index b8ecc87..093b045 100644
> --- a/drivers/iio/pressure/st_pressure_core.c
> +++ b/drivers/iio/pressure/st_pressure_core.c
> @@ -270,7 +270,6 @@ void st_press_common_remove(struct iio_dev *indio_dev)
>  		st_sensors_deallocate_trigger(indio_dev);
>  		st_press_deallocate_ring(indio_dev);
>  	}
> -	iio_device_free(indio_dev);
>  }
>  EXPORT_SYMBOL(st_press_common_remove);
>  
> diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c
> index 3065993..08aac5e 100644
> --- a/drivers/iio/pressure/st_pressure_i2c.c
> +++ b/drivers/iio/pressure/st_pressure_i2c.c
> @@ -25,11 +25,9 @@ static int st_press_i2c_probe(struct i2c_client *client,
>  	struct st_sensor_data *pdata;
>  	int err;
>  
> -	indio_dev = iio_device_alloc(sizeof(*pdata));
> -	if (indio_dev == NULL) {
> -		err = -ENOMEM;
> -		goto iio_device_alloc_error;
> -	}
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pdata));
> +	if (!indio_dev)
> +		return -ENOMEM;
>  
>  	pdata = iio_priv(indio_dev);
>  	pdata->dev = &client->dev;
> @@ -38,14 +36,9 @@ static int st_press_i2c_probe(struct i2c_client *client,
>  
>  	err = st_press_common_probe(indio_dev, client->dev.platform_data);
>  	if (err < 0)
> -		goto st_press_common_probe_error;
> +		return err;
>  
>  	return 0;
> -
> -st_press_common_probe_error:
> -	iio_device_free(indio_dev);
> -iio_device_alloc_error:
> -	return err;
>  }
>  
>  static int st_press_i2c_remove(struct i2c_client *client)
> diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c
> index b2aded6..399a29b 100644
> --- a/drivers/iio/pressure/st_pressure_spi.c
> +++ b/drivers/iio/pressure/st_pressure_spi.c
> @@ -24,11 +24,9 @@ static int st_press_spi_probe(struct spi_device *spi)
>  	struct st_sensor_data *pdata;
>  	int err;
>  
> -	indio_dev = iio_device_alloc(sizeof(*pdata));
> -	if (indio_dev == NULL) {
> -		err = -ENOMEM;
> -		goto iio_device_alloc_error;
> -	}
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*pdata));
> +	if (indio_dev == NULL)
> +		return -ENOMEM;
>  
>  	pdata = iio_priv(indio_dev);
>  	pdata->dev = &spi->dev;
> @@ -37,14 +35,9 @@ static int st_press_spi_probe(struct spi_device *spi)
>  
>  	err = st_press_common_probe(indio_dev, spi->dev.platform_data);
>  	if (err < 0)
> -		goto st_press_common_probe_error;
> +		return err;
>  
>  	return 0;
> -
> -st_press_common_probe_error:
> -	iio_device_free(indio_dev);
> -iio_device_alloc_error:
> -	return err;
>  }
>  
>  static int st_press_spi_remove(struct spi_device *spi)
> 

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

end of thread, other threads:[~2013-08-03 19:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-30  6:24 [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs Sachin Kamat
2013-07-30  6:24 ` [PATCH 2/3] iio: frequency: ad9523: " Sachin Kamat
2013-08-03 20:01   ` Jonathan Cameron
2013-07-30  6:24 ` [PATCH 3/3] iio: pressure: st_pressure: Use devm_iio_device_alloc Sachin Kamat
2013-08-03 20:03   ` Jonathan Cameron
2013-08-03 20:00 ` [PATCH 1/3] iio: amplifiers: ad8366: Use devm_* APIs 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.