* [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 20:59 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 03/12] staging: iio: ad5930: " Sachin Kamat
` (10 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23, J. August Brenner
devm_iio_device_alloc makes the code simple. While at it also
fixed an uninitialized return with -EINVAL.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: J. August Brenner <jbrenner@taosinc.com>
---
drivers/staging/iio/light/tsl2583.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index b377dd3..d2aaf16 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -815,12 +815,9 @@ static int taos_probe(struct i2c_client *clientp,
return -EOPNOTSUPP;
}
- indio_dev = iio_device_alloc(sizeof(*chip));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- dev_err(&clientp->dev, "iio allocation failed\n");
- goto fail1;
- }
+ indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
chip = iio_priv(indio_dev);
chip->client = clientp;
i2c_set_clientdata(clientp, indio_dev);
@@ -835,14 +832,14 @@ static int taos_probe(struct i2c_client *clientp,
if (ret < 0) {
dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd "
"reg failed in taos_probe(), err = %d\n", ret);
- goto fail2;
+ return ret;
}
ret = i2c_smbus_read_byte(clientp);
if (ret < 0) {
dev_err(&clientp->dev, "i2c_smbus_read_byte from "
"reg failed in taos_probe(), err = %d\n", ret);
- goto fail2;
+ return ret;
}
buf[i] = ret;
}
@@ -850,14 +847,14 @@ static int taos_probe(struct i2c_client *clientp,
if (!taos_tsl258x_device(buf)) {
dev_info(&clientp->dev, "i2c device found but does not match "
"expected id in taos_probe()\n");
- goto fail2;
+ return -EINVAL;
}
ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL));
if (ret < 0) {
dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg "
"failed in taos_probe(), err = %d\n", ret);
- goto fail2;
+ return ret;
}
indio_dev->info = &tsl2583_info;
@@ -867,7 +864,7 @@ static int taos_probe(struct i2c_client *clientp,
ret = iio_device_register(indio_dev);
if (ret) {
dev_err(&clientp->dev, "iio registration failed\n");
- goto fail2;
+ return ret;
}
/* Load up the V2 defaults (these are hard coded defaults for now) */
@@ -878,10 +875,6 @@ static int taos_probe(struct i2c_client *clientp,
dev_info(&clientp->dev, "Light sensor found.\n");
return 0;
-fail1:
- iio_device_free(indio_dev);
-fail2:
- return ret;
}
#ifdef CONFIG_PM_SLEEP
@@ -926,7 +919,6 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);
static int taos_remove(struct i2c_client *client)
{
iio_device_unregister(i2c_get_clientdata(client));
- iio_device_free(i2c_get_clientdata(client));
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc
2013-09-05 9:29 ` [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc Sachin Kamat
@ 2013-09-07 20:59 ` Jonathan Cameron
2013-09-08 13:14 ` Sachin Kamat
0 siblings, 1 reply; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 20:59 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars, J. August Brenner
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_iio_device_alloc makes the code simple. While at it also
> fixed an uninitialized return with -EINVAL.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: J. August Brenner <jbrenner@taosinc.com>
Applied to the togreg branch of iio.git. Jon mentioned he was very
busy so I won't wait for his feedback on this. Ideally this would have
been two patches, the fix and the devm stuff on top of that so that
we could push the fix into stable if anyone cares. Here it is obscure
enough I doubt anyone ever will so never mind.
Applied to the togreg branch of iio.git
> ---
> drivers/staging/iio/light/tsl2583.c | 24 ++++++++----------------
> 1 file changed, 8 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index b377dd3..d2aaf16 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -815,12 +815,9 @@ static int taos_probe(struct i2c_client *clientp,
> return -EOPNOTSUPP;
> }
>
> - indio_dev = iio_device_alloc(sizeof(*chip));
> - if (indio_dev == NULL) {
> - ret = -ENOMEM;
> - dev_err(&clientp->dev, "iio allocation failed\n");
> - goto fail1;
> - }
> + indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
> + if (!indio_dev)
> + return -ENOMEM;
> chip = iio_priv(indio_dev);
> chip->client = clientp;
> i2c_set_clientdata(clientp, indio_dev);
> @@ -835,14 +832,14 @@ static int taos_probe(struct i2c_client *clientp,
> if (ret < 0) {
> dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd "
> "reg failed in taos_probe(), err = %d\n", ret);
> - goto fail2;
> + return ret;
> }
> ret = i2c_smbus_read_byte(clientp);
> if (ret < 0) {
> dev_err(&clientp->dev, "i2c_smbus_read_byte from "
> "reg failed in taos_probe(), err = %d\n", ret);
>
> - goto fail2;
> + return ret;
> }
> buf[i] = ret;
> }
> @@ -850,14 +847,14 @@ static int taos_probe(struct i2c_client *clientp,
> if (!taos_tsl258x_device(buf)) {
> dev_info(&clientp->dev, "i2c device found but does not match "
> "expected id in taos_probe()\n");
> - goto fail2;
> + return -EINVAL;
> }
>
> ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL));
> if (ret < 0) {
> dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg "
> "failed in taos_probe(), err = %d\n", ret);
> - goto fail2;
> + return ret;
> }
>
> indio_dev->info = &tsl2583_info;
> @@ -867,7 +864,7 @@ static int taos_probe(struct i2c_client *clientp,
> ret = iio_device_register(indio_dev);
> if (ret) {
> dev_err(&clientp->dev, "iio registration failed\n");
> - goto fail2;
> + return ret;
> }
>
> /* Load up the V2 defaults (these are hard coded defaults for now) */
> @@ -878,10 +875,6 @@ static int taos_probe(struct i2c_client *clientp,
>
> dev_info(&clientp->dev, "Light sensor found.\n");
> return 0;
> -fail1:
> - iio_device_free(indio_dev);
> -fail2:
> - return ret;
> }
>
> #ifdef CONFIG_PM_SLEEP
> @@ -926,7 +919,6 @@ static SIMPLE_DEV_PM_OPS(taos_pm_ops, taos_suspend, taos_resume);
> static int taos_remove(struct i2c_client *client)
> {
> iio_device_unregister(i2c_get_clientdata(client));
> - iio_device_free(i2c_get_clientdata(client));
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc
2013-09-07 20:59 ` Jonathan Cameron
@ 2013-09-08 13:14 ` Sachin Kamat
2013-09-08 14:32 ` Jonathan Cameron
0 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-08 13:14 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, J. August Brenner
Hi Jonathan,
On 8 September 2013 02:29, Jonathan Cameron <jic23@kernel.org> wrote:
> On 09/05/13 10:29, Sachin Kamat wrote:
>> devm_iio_device_alloc makes the code simple. While at it also
>> fixed an uninitialized return with -EINVAL.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> Cc: J. August Brenner <jbrenner@taosinc.com>
> Applied to the togreg branch of iio.git. Jon mentioned he was very
> busy so I won't wait for his feedback on this. Ideally this would have
> been two patches, the fix and the devm stuff on top of that so that
> we could push the fix into stable if anyone cares. Here it is obscure
> enough I doubt anyone ever will so never mind.
I can probably still do that. Create a patch just to fix this on top
of your fixes branch which can go into
3.12-rc and below. But you may have to resolve a conflict (I believe
this one might give) when you merge
it with your togreg branch. Let me know your opinion in any case.
>
> Applied to the togreg branch of iio.git
Thanks for applying this and all others :)
--
With warm regards,
Sachin
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc
2013-09-08 13:14 ` Sachin Kamat
@ 2013-09-08 14:32 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-08 14:32 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, Lars-Peter Clausen, J. August Brenner
On 09/08/13 14:14, Sachin Kamat wrote:
> Hi Jonathan,
>
> On 8 September 2013 02:29, Jonathan Cameron <jic23@kernel.org> wrote:
>> On 09/05/13 10:29, Sachin Kamat wrote:
>>> devm_iio_device_alloc makes the code simple. While at it also
>>> fixed an uninitialized return with -EINVAL.
>>>
>>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>>> Cc: J. August Brenner <jbrenner@taosinc.com>
>> Applied to the togreg branch of iio.git. Jon mentioned he was very
>> busy so I won't wait for his feedback on this. Ideally this would have
>> been two patches, the fix and the devm stuff on top of that so that
>> we could push the fix into stable if anyone cares. Here it is obscure
>> enough I doubt anyone ever will so never mind.
>
> I can probably still do that. Create a patch just to fix this on top
> of your fixes branch which can go into
> 3.12-rc and below. But you may have to resolve a conflict (I believe
> this one might give) when you merge
> it with your togreg branch. Let me know your opinion in any case.
Don't worry about it. It is pretty obscure and we don't know if anyone
has ever actually hit it!
>
>>
>> Applied to the togreg branch of iio.git
>
> Thanks for applying this and all others :)
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 03/12] staging: iio: ad5930: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
2013-09-05 9:29 ` [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:00 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 04/12] staging: iio: ad9832: Use devm_* APIs Sachin Kamat
` (9 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad5930.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad5930.c b/drivers/staging/iio/frequency/ad5930.c
index 69e90e9..a4aeee6 100644
--- a/drivers/staging/iio/frequency/ad5930.c
+++ b/drivers/staging/iio/frequency/ad5930.c
@@ -94,11 +94,9 @@ static int ad5930_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_device_alloc(sizeof(*st));
- if (idev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!idev)
+ return -ENOMEM;
spi_set_drvdata(spi, idev);
st = iio_priv(idev);
@@ -110,24 +108,18 @@ static int ad5930_probe(struct spi_device *spi)
ret = iio_device_register(idev);
if (ret)
- goto error_free_dev;
+ return ret;
spi->max_speed_hz = 2000000;
spi->mode = SPI_MODE_3;
spi->bits_per_word = 16;
spi_setup(spi);
return 0;
-
-error_free_dev:
- iio_device_free(idev);
-error_ret:
- return ret;
}
static int ad5930_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] 26+ messages in thread* Re: [PATCH 03/12] staging: iio: ad5930: Use devm_iio_device_alloc
2013-09-05 9:29 ` [PATCH 03/12] staging: iio: ad5930: " Sachin Kamat
@ 2013-09-07 21:00 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:00 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_iio_device_alloc makes code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Nice simple one!
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/frequency/ad5930.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad5930.c b/drivers/staging/iio/frequency/ad5930.c
> index 69e90e9..a4aeee6 100644
> --- a/drivers/staging/iio/frequency/ad5930.c
> +++ b/drivers/staging/iio/frequency/ad5930.c
> @@ -94,11 +94,9 @@ static int ad5930_probe(struct spi_device *spi)
> struct iio_dev *idev;
> int ret = 0;
>
> - idev = iio_device_alloc(sizeof(*st));
> - if (idev == NULL) {
> - ret = -ENOMEM;
> - goto error_ret;
> - }
> + idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> + if (!idev)
> + return -ENOMEM;
> spi_set_drvdata(spi, idev);
> st = iio_priv(idev);
>
> @@ -110,24 +108,18 @@ static int ad5930_probe(struct spi_device *spi)
>
> ret = iio_device_register(idev);
> if (ret)
> - goto error_free_dev;
> + return ret;
> spi->max_speed_hz = 2000000;
> spi->mode = SPI_MODE_3;
> spi->bits_per_word = 16;
> spi_setup(spi);
>
> return 0;
> -
> -error_free_dev:
> - iio_device_free(idev);
> -error_ret:
> - return ret;
> }
>
> static int ad5930_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] 26+ messages in thread
* [PATCH 04/12] staging: iio: ad9832: Use devm_* APIs
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
2013-09-05 9:29 ` [PATCH 02/12] staging: iio: tsl2583: Use devm_iio_device_alloc Sachin Kamat
2013-09-05 9:29 ` [PATCH 03/12] staging: iio: ad5930: " Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:01 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 05/12] staging: iio: ad9834: " Sachin Kamat
` (8 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9832.c | 32 ++++++++++++--------------------
1 file changed, 12 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 4e18380..adc91b7 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -214,14 +214,14 @@ static int ad9832_probe(struct spi_device *spi)
return -ENODEV;
}
- reg = regulator_get(&spi->dev, "vcc");
+ reg = devm_regulator_get(&spi->dev, "vcc");
if (!IS_ERR(reg)) {
ret = regulator_enable(reg);
if (ret)
- goto error_put_reg;
+ return ret;
}
- indio_dev = iio_device_alloc(sizeof(*st));
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_disable_reg;
@@ -279,47 +279,42 @@ static int ad9832_probe(struct spi_device *spi)
ret = spi_sync(st->spi, &st->msg);
if (ret) {
dev_err(&spi->dev, "device init failed\n");
- goto error_free_device;
+ goto error_disable_reg;
}
ret = ad9832_write_frequency(st, AD9832_FREQ0HM, pdata->freq0);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9832_write_frequency(st, AD9832_FREQ1HM, pdata->freq1);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9832_write_phase(st, AD9832_PHASE0H, pdata->phase0);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9832_write_phase(st, AD9832_PHASE1H, pdata->phase1);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9832_write_phase(st, AD9832_PHASE2H, pdata->phase2);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9832_write_phase(st, AD9832_PHASE3H, pdata->phase3);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
return 0;
-error_free_device:
- iio_device_free(indio_dev);
error_disable_reg:
if (!IS_ERR(reg))
regulator_disable(reg);
-error_put_reg:
- if (!IS_ERR(reg))
- regulator_put(reg);
return ret;
}
@@ -330,11 +325,8 @@ static int ad9832_remove(struct spi_device *spi)
struct ad9832_state *st = iio_priv(indio_dev);
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] 26+ messages in thread* Re: [PATCH 04/12] staging: iio: ad9832: Use devm_* APIs
2013-09-05 9:29 ` [PATCH 04/12] staging: iio: ad9832: Use devm_* APIs Sachin Kamat
@ 2013-09-07 21:01 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:01 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/frequency/ad9832.c | 32 ++++++++++++--------------------
> 1 file changed, 12 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
> index 4e18380..adc91b7 100644
> --- a/drivers/staging/iio/frequency/ad9832.c
> +++ b/drivers/staging/iio/frequency/ad9832.c
> @@ -214,14 +214,14 @@ static int ad9832_probe(struct spi_device *spi)
> return -ENODEV;
> }
>
> - reg = regulator_get(&spi->dev, "vcc");
> + reg = devm_regulator_get(&spi->dev, "vcc");
> if (!IS_ERR(reg)) {
> ret = regulator_enable(reg);
> if (ret)
> - goto error_put_reg;
> + return ret;
> }
>
> - indio_dev = iio_device_alloc(sizeof(*st));
> + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> if (indio_dev == NULL) {
> ret = -ENOMEM;
> goto error_disable_reg;
> @@ -279,47 +279,42 @@ static int ad9832_probe(struct spi_device *spi)
> ret = spi_sync(st->spi, &st->msg);
> if (ret) {
> dev_err(&spi->dev, "device init failed\n");
> - goto error_free_device;
> + goto error_disable_reg;
> }
>
> ret = ad9832_write_frequency(st, AD9832_FREQ0HM, pdata->freq0);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9832_write_frequency(st, AD9832_FREQ1HM, pdata->freq1);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9832_write_phase(st, AD9832_PHASE0H, pdata->phase0);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9832_write_phase(st, AD9832_PHASE1H, pdata->phase1);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9832_write_phase(st, AD9832_PHASE2H, pdata->phase2);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9832_write_phase(st, AD9832_PHASE3H, pdata->phase3);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = iio_device_register(indio_dev);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> return 0;
>
> -error_free_device:
> - iio_device_free(indio_dev);
> error_disable_reg:
> if (!IS_ERR(reg))
> regulator_disable(reg);
> -error_put_reg:
> - if (!IS_ERR(reg))
> - regulator_put(reg);
>
> return ret;
> }
> @@ -330,11 +325,8 @@ static int ad9832_remove(struct spi_device *spi)
> struct ad9832_state *st = iio_priv(indio_dev);
>
> 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] 26+ messages in thread
* [PATCH 05/12] staging: iio: ad9834: Use devm_* APIs
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (2 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 04/12] staging: iio: ad9832: Use devm_* APIs Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:02 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 06/12] staging: iio: ad9850: Use devm_iio_device_alloc Sachin Kamat
` (7 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9834.c | 29 +++++++++++------------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
index 5cba3c0..2562b22 100644
--- a/drivers/staging/iio/frequency/ad9834.c
+++ b/drivers/staging/iio/frequency/ad9834.c
@@ -327,14 +327,14 @@ static int ad9834_probe(struct spi_device *spi)
return -ENODEV;
}
- reg = regulator_get(&spi->dev, "vcc");
+ reg = devm_regulator_get(&spi->dev, "vcc");
if (!IS_ERR(reg)) {
ret = regulator_enable(reg);
if (ret)
- goto error_put_reg;
+ return ret;
}
- indio_dev = iio_device_alloc(sizeof(*st));
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (indio_dev == NULL) {
ret = -ENOMEM;
goto error_disable_reg;
@@ -388,39 +388,35 @@ static int ad9834_probe(struct spi_device *spi)
ret = spi_sync(st->spi, &st->msg);
if (ret) {
dev_err(&spi->dev, "device init failed\n");
- goto error_free_device;
+ goto error_disable_reg;
}
ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, pdata->freq0);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, pdata->freq1);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9834_write_phase(st, AD9834_REG_PHASE0, pdata->phase0);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = ad9834_write_phase(st, AD9834_REG_PHASE1, pdata->phase1);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_device;
+ goto error_disable_reg;
return 0;
-error_free_device:
- iio_device_free(indio_dev);
error_disable_reg:
if (!IS_ERR(reg))
regulator_disable(reg);
-error_put_reg:
- if (!IS_ERR(reg))
- regulator_put(reg);
+
return ret;
}
@@ -430,11 +426,8 @@ static int ad9834_remove(struct spi_device *spi)
struct ad9834_state *st = iio_priv(indio_dev);
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] 26+ messages in thread* Re: [PATCH 05/12] staging: iio: ad9834: Use devm_* APIs
2013-09-05 9:29 ` [PATCH 05/12] staging: iio: ad9834: " Sachin Kamat
@ 2013-09-07 21:02 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:02 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/frequency/ad9834.c | 29 +++++++++++------------------
> 1 file changed, 11 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c
> index 5cba3c0..2562b22 100644
> --- a/drivers/staging/iio/frequency/ad9834.c
> +++ b/drivers/staging/iio/frequency/ad9834.c
> @@ -327,14 +327,14 @@ static int ad9834_probe(struct spi_device *spi)
> return -ENODEV;
> }
>
> - reg = regulator_get(&spi->dev, "vcc");
> + reg = devm_regulator_get(&spi->dev, "vcc");
> if (!IS_ERR(reg)) {
> ret = regulator_enable(reg);
> if (ret)
> - goto error_put_reg;
> + return ret;
> }
>
> - indio_dev = iio_device_alloc(sizeof(*st));
> + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> if (indio_dev == NULL) {
> ret = -ENOMEM;
> goto error_disable_reg;
> @@ -388,39 +388,35 @@ static int ad9834_probe(struct spi_device *spi)
> ret = spi_sync(st->spi, &st->msg);
> if (ret) {
> dev_err(&spi->dev, "device init failed\n");
> - goto error_free_device;
> + goto error_disable_reg;
> }
>
> ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, pdata->freq0);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, pdata->freq1);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9834_write_phase(st, AD9834_REG_PHASE0, pdata->phase0);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = ad9834_write_phase(st, AD9834_REG_PHASE1, pdata->phase1);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> ret = iio_device_register(indio_dev);
> if (ret)
> - goto error_free_device;
> + goto error_disable_reg;
>
> return 0;
>
> -error_free_device:
> - iio_device_free(indio_dev);
> error_disable_reg:
> if (!IS_ERR(reg))
> regulator_disable(reg);
> -error_put_reg:
> - if (!IS_ERR(reg))
> - regulator_put(reg);
> +
> return ret;
> }
>
> @@ -430,11 +426,8 @@ static int ad9834_remove(struct spi_device *spi)
> struct ad9834_state *st = iio_priv(indio_dev);
>
> 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] 26+ messages in thread
* [PATCH 06/12] staging: iio: ad9850: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (3 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 05/12] staging: iio: ad9834: " Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:02 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 07/12] staging: iio: ad9852: " Sachin Kamat
` (6 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9850.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9850.c b/drivers/staging/iio/frequency/ad9850.c
index 01a8a93..af877ff 100644
--- a/drivers/staging/iio/frequency/ad9850.c
+++ b/drivers/staging/iio/frequency/ad9850.c
@@ -80,11 +80,9 @@ static int ad9850_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_device_alloc(sizeof(*st));
- if (idev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!idev)
+ return -ENOMEM;
spi_set_drvdata(spi, idev);
st = iio_priv(idev);
mutex_init(&st->lock);
@@ -96,24 +94,18 @@ static int ad9850_probe(struct spi_device *spi)
ret = iio_device_register(idev);
if (ret)
- goto error_free_dev;
+ return ret;
spi->max_speed_hz = 2000000;
spi->mode = SPI_MODE_3;
spi->bits_per_word = 16;
spi_setup(spi);
return 0;
-
-error_free_dev:
- iio_device_free(idev);
-error_ret:
- return ret;
}
static int ad9850_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] 26+ messages in thread* Re: [PATCH 06/12] staging: iio: ad9850: Use devm_iio_device_alloc
2013-09-05 9:29 ` [PATCH 06/12] staging: iio: ad9850: Use devm_iio_device_alloc Sachin Kamat
@ 2013-09-07 21:02 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:02 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> 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/staging/iio/frequency/ad9850.c | 16 ++++------------
> 1 file changed, 4 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9850.c b/drivers/staging/iio/frequency/ad9850.c
> index 01a8a93..af877ff 100644
> --- a/drivers/staging/iio/frequency/ad9850.c
> +++ b/drivers/staging/iio/frequency/ad9850.c
> @@ -80,11 +80,9 @@ static int ad9850_probe(struct spi_device *spi)
> struct iio_dev *idev;
> int ret = 0;
>
> - idev = iio_device_alloc(sizeof(*st));
> - if (idev == NULL) {
> - ret = -ENOMEM;
> - goto error_ret;
> - }
> + idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> + if (!idev)
> + return -ENOMEM;
> spi_set_drvdata(spi, idev);
> st = iio_priv(idev);
> mutex_init(&st->lock);
> @@ -96,24 +94,18 @@ static int ad9850_probe(struct spi_device *spi)
>
> ret = iio_device_register(idev);
> if (ret)
> - goto error_free_dev;
> + return ret;
> spi->max_speed_hz = 2000000;
> spi->mode = SPI_MODE_3;
> spi->bits_per_word = 16;
> spi_setup(spi);
>
> return 0;
> -
> -error_free_dev:
> - iio_device_free(idev);
> -error_ret:
> - return ret;
> }
>
> static int ad9850_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] 26+ messages in thread
* [PATCH 07/12] staging: iio: ad9852: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (4 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 06/12] staging: iio: ad9850: Use devm_iio_device_alloc Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:03 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 08/12] staging: iio: ad9910: " Sachin Kamat
` (5 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9852.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9852.c b/drivers/staging/iio/frequency/ad9852.c
index 1344031..4be2cf8 100644
--- a/drivers/staging/iio/frequency/ad9852.c
+++ b/drivers/staging/iio/frequency/ad9852.c
@@ -229,11 +229,9 @@ static int ad9852_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_device_alloc(sizeof(*st));
- if (idev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!idev)
+ return -ENOMEM;
st = iio_priv(idev);
spi_set_drvdata(spi, idev);
mutex_init(&st->lock);
@@ -245,7 +243,7 @@ static int ad9852_probe(struct spi_device *spi)
ret = iio_device_register(idev);
if (ret)
- goto error_free_dev;
+ return ret;
spi->max_speed_hz = 2000000;
spi->mode = SPI_MODE_3;
spi->bits_per_word = 8;
@@ -253,18 +251,11 @@ static int ad9852_probe(struct spi_device *spi)
ad9852_init(st);
return 0;
-
-error_free_dev:
- iio_device_free(idev);
-
-error_ret:
- return ret;
}
static int ad9852_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] 26+ messages in thread* Re: [PATCH 07/12] staging: iio: ad9852: Use devm_iio_device_alloc
2013-09-05 9:29 ` [PATCH 07/12] staging: iio: ad9852: " Sachin Kamat
@ 2013-09-07 21:03 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:03 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_iio_device_alloc makes code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied
> ---
> drivers/staging/iio/frequency/ad9852.c | 17 ++++-------------
> 1 file changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/iio/frequency/ad9852.c b/drivers/staging/iio/frequency/ad9852.c
> index 1344031..4be2cf8 100644
> --- a/drivers/staging/iio/frequency/ad9852.c
> +++ b/drivers/staging/iio/frequency/ad9852.c
> @@ -229,11 +229,9 @@ static int ad9852_probe(struct spi_device *spi)
> struct iio_dev *idev;
> int ret = 0;
>
> - idev = iio_device_alloc(sizeof(*st));
> - if (idev == NULL) {
> - ret = -ENOMEM;
> - goto error_ret;
> - }
> + idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> + if (!idev)
> + return -ENOMEM;
> st = iio_priv(idev);
> spi_set_drvdata(spi, idev);
> mutex_init(&st->lock);
> @@ -245,7 +243,7 @@ static int ad9852_probe(struct spi_device *spi)
>
> ret = iio_device_register(idev);
> if (ret)
> - goto error_free_dev;
> + return ret;
> spi->max_speed_hz = 2000000;
> spi->mode = SPI_MODE_3;
> spi->bits_per_word = 8;
> @@ -253,18 +251,11 @@ static int ad9852_probe(struct spi_device *spi)
> ad9852_init(st);
>
> return 0;
> -
> -error_free_dev:
> - iio_device_free(idev);
> -
> -error_ret:
> - return ret;
> }
>
> static int ad9852_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] 26+ messages in thread
* [PATCH 08/12] staging: iio: ad9910: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (5 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 07/12] staging: iio: ad9852: " Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:03 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 09/12] staging: iio: ad9951: " Sachin Kamat
` (4 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9910.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9910.c b/drivers/staging/iio/frequency/ad9910.c
index e48f874..a7d528e 100644
--- a/drivers/staging/iio/frequency/ad9910.c
+++ b/drivers/staging/iio/frequency/ad9910.c
@@ -367,11 +367,9 @@ static int ad9910_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_device_alloc(sizeof(*st));
- if (idev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!idev)
+ return -ENOMEM;
spi_set_drvdata(spi, idev);
st = iio_priv(idev);
mutex_init(&st->lock);
@@ -383,24 +381,18 @@ static int ad9910_probe(struct spi_device *spi)
ret = iio_device_register(idev);
if (ret)
- goto error_free_dev;
+ return ret;
spi->max_speed_hz = 2000000;
spi->mode = SPI_MODE_3;
spi->bits_per_word = 8;
spi_setup(spi);
ad9910_init(st);
return 0;
-
-error_free_dev:
- iio_device_free(idev);
-error_ret:
- return ret;
}
static int ad9910_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] 26+ messages in thread* [PATCH 09/12] staging: iio: ad9951: Use devm_iio_device_alloc
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (6 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 08/12] staging: iio: ad9910: " Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:04 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 10/12] staging: iio: tsl2x7x_core: Use devm_* APIs Sachin Kamat
` (3 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23
devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/frequency/ad9951.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9951.c b/drivers/staging/iio/frequency/ad9951.c
index 8234e3c..0094c2f 100644
--- a/drivers/staging/iio/frequency/ad9951.c
+++ b/drivers/staging/iio/frequency/ad9951.c
@@ -176,11 +176,9 @@ static int ad9951_probe(struct spi_device *spi)
struct iio_dev *idev;
int ret = 0;
- idev = iio_device_alloc(sizeof(*st));
- if (idev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!idev)
+ return -ENOMEM;
spi_set_drvdata(spi, idev);
st = iio_priv(idev);
mutex_init(&st->lock);
@@ -193,25 +191,18 @@ static int ad9951_probe(struct spi_device *spi)
ret = iio_device_register(idev);
if (ret)
- goto error_free_dev;
+ return ret;
spi->max_speed_hz = 2000000;
spi->mode = SPI_MODE_3;
spi->bits_per_word = 8;
spi_setup(spi);
ad9951_init(st);
return 0;
-
-error_free_dev:
- iio_device_free(idev);
-
-error_ret:
- return ret;
}
static int ad9951_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] 26+ messages in thread* [PATCH 10/12] staging: iio: tsl2x7x_core: Use devm_* APIs
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (7 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 09/12] staging: iio: ad9951: " Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:05 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 11/12] staging: iio: tsl2x7x_core: Fix sparse warning Sachin Kamat
` (2 subsequent siblings)
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23, J. August Brenner
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: J. August Brenner <jbrenner@taosinc.com>
---
drivers/staging/iio/light/tsl2x7x_core.c | 38 ++++++++++--------------------
1 file changed, 13 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index c99f890..aa86725 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -1851,7 +1851,7 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
struct iio_dev *indio_dev;
struct tsl2X7X_chip *chip;
- indio_dev = iio_device_alloc(sizeof(*chip));
+ indio_dev = devm_iio_device_alloc(&clientp->dev, sizeof(*chip));
if (!indio_dev)
return -ENOMEM;
@@ -1862,22 +1862,21 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
ret = tsl2x7x_i2c_read(chip->client,
TSL2X7X_CHIPID, &device_id);
if (ret < 0)
- goto fail1;
+ return ret;
if ((!tsl2x7x_device_id(&device_id, id->driver_data)) ||
(tsl2x7x_device_id(&device_id, id->driver_data) == -EINVAL)) {
dev_info(&chip->client->dev,
"%s: i2c device found does not match expected id\n",
__func__);
- ret = -EINVAL;
- goto fail1;
+ return -EINVAL;
}
ret = i2c_smbus_write_byte(clientp, (TSL2X7X_CMD_REG | TSL2X7X_CNTRL));
if (ret < 0) {
dev_err(&clientp->dev, "%s: write to cmd reg failed. err = %d\n",
__func__, ret);
- goto fail1;
+ return ret;
}
/* ALS and PROX functions can be invoked via user space poll
@@ -1899,16 +1898,17 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
indio_dev->num_channels = chip->chip_info->chan_table_elements;
if (clientp->irq) {
- ret = request_threaded_irq(clientp->irq,
- NULL,
- &tsl2x7x_event_handler,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- "TSL2X7X_event",
- indio_dev);
+ ret = devm_request_threaded_irq(&clientp->dev, clientp->irq,
+ NULL,
+ &tsl2x7x_event_handler,
+ IRQF_TRIGGER_RISING |
+ IRQF_ONESHOT,
+ "TSL2X7X_event",
+ indio_dev);
if (ret) {
dev_err(&clientp->dev,
"%s: irq request failed", __func__);
- goto fail1;
+ return ret;
}
}
@@ -1921,20 +1921,12 @@ static int tsl2x7x_probe(struct i2c_client *clientp,
if (ret) {
dev_err(&clientp->dev,
"%s: iio registration failed\n", __func__);
- goto fail2;
+ return ret;
}
dev_info(&clientp->dev, "%s Light sensor found.\n", id->name);
return 0;
-
-fail2:
- if (clientp->irq)
- free_irq(clientp->irq, indio_dev);
-fail1:
- iio_device_free(indio_dev);
-
- return ret;
}
static int tsl2x7x_suspend(struct device *dev)
@@ -1980,10 +1972,6 @@ static int tsl2x7x_remove(struct i2c_client *client)
tsl2x7x_chip_off(indio_dev);
iio_device_unregister(indio_dev);
- if (client->irq)
- free_irq(client->irq, indio_dev);
-
- iio_device_free(indio_dev);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 26+ messages in thread* [PATCH 11/12] staging: iio: tsl2x7x_core: Fix sparse warning
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (8 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 10/12] staging: iio: tsl2x7x_core: Use devm_* APIs Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:06 ` Jonathan Cameron
2013-09-05 9:29 ` [PATCH 12/12] staging: iio: hmc5843: Fix a trivial typo Sachin Kamat
2013-09-07 20:53 ` [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Jonathan Cameron
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23, J. August Brenner
Silences the following warning:
drivers/staging/iio/light/tsl2x7x_core.c:553:70:
warning: Using plain integer as NULL pointer
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: J. August Brenner <jbrenner@taosinc.com>
---
drivers/staging/iio/light/tsl2x7x_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index aa86725..3439d37 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -550,7 +550,7 @@ prox_poll_err:
static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
{
/* If Operational settings defined elsewhere.. */
- if (chip->pdata && chip->pdata->platform_default_settings != 0)
+ if (chip->pdata && chip->pdata->platform_default_settings)
memcpy(&(chip->tsl2x7x_settings),
chip->pdata->platform_default_settings,
sizeof(tsl2x7x_default_settings));
--
1.7.9.5
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH 11/12] staging: iio: tsl2x7x_core: Fix sparse warning
2013-09-05 9:29 ` [PATCH 11/12] staging: iio: tsl2x7x_core: Fix sparse warning Sachin Kamat
@ 2013-09-07 21:06 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:06 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars, J. August Brenner
On 09/05/13 10:29, Sachin Kamat wrote:
> Silences the following warning:
> drivers/staging/iio/light/tsl2x7x_core.c:553:70:
> warning: Using plain integer as NULL pointer
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: J. August Brenner <jbrenner@taosinc.com>
Thanks,
I've been meaning to fix that one myself for ages :(
Much easier just to apply your patch though.
Applied to the togreg branch of iio.git
> ---
> drivers/staging/iio/light/tsl2x7x_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
> index aa86725..3439d37 100644
> --- a/drivers/staging/iio/light/tsl2x7x_core.c
> +++ b/drivers/staging/iio/light/tsl2x7x_core.c
> @@ -550,7 +550,7 @@ prox_poll_err:
> static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
> {
> /* If Operational settings defined elsewhere.. */
> - if (chip->pdata && chip->pdata->platform_default_settings != 0)
> + if (chip->pdata && chip->pdata->platform_default_settings)
> memcpy(&(chip->tsl2x7x_settings),
> chip->pdata->platform_default_settings,
> sizeof(tsl2x7x_default_settings));
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 12/12] staging: iio: hmc5843: Fix a trivial typo
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (9 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 11/12] staging: iio: tsl2x7x_core: Fix sparse warning Sachin Kamat
@ 2013-09-05 9:29 ` Sachin Kamat
2013-09-07 21:07 ` Jonathan Cameron
2013-09-07 20:53 ` [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Jonathan Cameron
11 siblings, 1 reply; 26+ messages in thread
From: Sachin Kamat @ 2013-09-05 9:29 UTC (permalink / raw)
To: linux-iio; +Cc: lars, sachin.kamat, jic23, Shubhrajyoti Datta
Add a missing closing brace.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Shubhrajyoti Datta <shubhrajyoti@ti.com>
---
drivers/staging/iio/magnetometer/hmc5843.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index d2748c3..67c1ce7 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -730,6 +730,6 @@ static struct i2c_driver hmc5843_driver = {
};
module_i2c_driver(hmc5843_driver);
-MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com");
+MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com>");
MODULE_DESCRIPTION("HMC5843/5883/5883L driver");
MODULE_LICENSE("GPL");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH 12/12] staging: iio: hmc5843: Fix a trivial typo
2013-09-05 9:29 ` [PATCH 12/12] staging: iio: hmc5843: Fix a trivial typo Sachin Kamat
@ 2013-09-07 21:07 ` Jonathan Cameron
0 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 21:07 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars, Shubhrajyoti Datta
On 09/05/13 10:29, Sachin Kamat wrote:
> Add a missing closing brace.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> Cc: Shubhrajyoti Datta <shubhrajyoti@ti.com>
Good spot.
Applied to the togreg branch of iio.git
Thanks,
> ---
> drivers/staging/iio/magnetometer/hmc5843.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index d2748c3..67c1ce7 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843.c
> @@ -730,6 +730,6 @@ static struct i2c_driver hmc5843_driver = {
> };
> module_i2c_driver(hmc5843_driver);
>
> -MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com");
> +MODULE_AUTHOR("Shubhrajyoti Datta <shubhrajyoti@ti.com>");
> MODULE_DESCRIPTION("HMC5843/5883/5883L driver");
> MODULE_LICENSE("GPL");
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs
2013-09-05 9:29 [PATCH 01/12] staging: iio: ad5933: Use devm_* APIs Sachin Kamat
` (10 preceding siblings ...)
2013-09-05 9:29 ` [PATCH 12/12] staging: iio: hmc5843: Fix a trivial typo Sachin Kamat
@ 2013-09-07 20:53 ` Jonathan Cameron
11 siblings, 0 replies; 26+ messages in thread
From: Jonathan Cameron @ 2013-09-07 20:53 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 09/05/13 10:29, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Applied to the togreg branch of iio.git
Thanks,
Jonathan
> ---
> This series is compile tested.
> ---
> drivers/staging/iio/impedance-analyzer/ad5933.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 6330af6..23a0d71 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -703,7 +703,9 @@ static int ad5933_probe(struct i2c_client *client,
> int ret, voltage_uv = 0;
> struct ad5933_platform_data *pdata = client->dev.platform_data;
> struct ad5933_state *st;
> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
> + struct iio_dev *indio_dev;
> +
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st));
> if (indio_dev == NULL)
> return -ENOMEM;
>
> @@ -716,11 +718,11 @@ static int ad5933_probe(struct i2c_client *client,
> else
> st->pdata = pdata;
>
> - st->reg = regulator_get(&client->dev, "vcc");
> + st->reg = devm_regulator_get(&client->dev, "vcc");
> if (!IS_ERR(st->reg)) {
> ret = regulator_enable(st->reg);
> if (ret)
> - goto error_put_reg;
> + return ret;
> voltage_uv = regulator_get_voltage(st->reg);
> }
>
> @@ -778,11 +780,6 @@ error_unreg_ring:
> 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;
> }
> @@ -795,11 +792,8 @@ static int ad5933_remove(struct i2c_client *client)
> iio_device_unregister(indio_dev);
> iio_buffer_unregister(indio_dev);
> iio_kfifo_free(indio_dev->buffer);
> - 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] 26+ messages in thread