* [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs
@ 2013-08-24 19:24 Sachin Kamat
2013-08-24 19:24 ` [PATCH 2/3] staging: iio: ad7152: Use devm_iio_device_alloc Sachin Kamat
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Sachin Kamat @ 2013-08-24 19:24 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, jic23, sachin.kamat, lars
devm_* APIs are device managed and make code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
Series compile tested on togreg branch of
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
---
drivers/staging/iio/cdc/ad7150.c | 36 ++++++++----------------------------
1 files changed, 8 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
index 687dd2c..f4a0341 100644
--- a/drivers/staging/iio/cdc/ad7150.c
+++ b/drivers/staging/iio/cdc/ad7150.c
@@ -558,11 +558,9 @@ static int ad7150_probe(struct i2c_client *client,
struct ad7150_chip_info *chip;
struct iio_dev *indio_dev;
- indio_dev = iio_device_alloc(sizeof(*chip));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
chip = iio_priv(indio_dev);
mutex_init(&chip->state_lock);
/* this is only used for device removal purposes */
@@ -581,7 +579,7 @@ static int ad7150_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE;
if (client->irq) {
- ret = request_threaded_irq(client->irq,
+ ret = devm_request_threaded_irq(&client->dev, client->irq,
NULL,
&ad7150_event_handler,
IRQF_TRIGGER_RISING |
@@ -590,11 +588,11 @@ static int ad7150_probe(struct i2c_client *client,
"ad7150_irq1",
indio_dev);
if (ret)
- goto error_free_dev;
+ return ret;
}
if (client->dev.platform_data) {
- ret = request_threaded_irq(*(unsigned int *)
+ ret = devm_request_threaded_irq(&client->dev, *(unsigned int *)
client->dev.platform_data,
NULL,
&ad7150_event_handler,
@@ -604,28 +602,17 @@ static int ad7150_probe(struct i2c_client *client,
"ad7150_irq2",
indio_dev);
if (ret)
- goto error_free_irq;
+ return ret;
}
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_irq2;
+ return ret;
dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n",
id->name, client->irq);
return 0;
-error_free_irq2:
- if (client->dev.platform_data)
- free_irq(*(unsigned int *)client->dev.platform_data,
- indio_dev);
-error_free_irq:
- if (client->irq)
- free_irq(client->irq, indio_dev);
-error_free_dev:
- iio_device_free(indio_dev);
-error_ret:
- return ret;
}
static int ad7150_remove(struct i2c_client *client)
@@ -633,13 +620,6 @@ static int ad7150_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
- if (client->irq)
- free_irq(client->irq, indio_dev);
-
- if (client->dev.platform_data)
- free_irq(*(unsigned int *)client->dev.platform_data, indio_dev);
-
- iio_device_free(indio_dev);
return 0;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] staging: iio: ad7152: Use devm_iio_device_alloc
2013-08-24 19:24 [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Sachin Kamat
@ 2013-08-24 19:24 ` Sachin Kamat
2013-08-24 19:24 ` [PATCH 3/3] staging: iio: ad7746: " Sachin Kamat
2013-08-28 19:23 ` [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Sachin Kamat @ 2013-08-24 19:24 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, jic23, sachin.kamat, lars
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/cdc/ad7152.c | 16 ++++------------
1 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c
index 1d7c528..f2c309d 100644
--- a/drivers/staging/iio/cdc/ad7152.c
+++ b/drivers/staging/iio/cdc/ad7152.c
@@ -481,11 +481,9 @@ static int ad7152_probe(struct i2c_client *client,
struct ad7152_chip_info *chip;
struct iio_dev *indio_dev;
- indio_dev = iio_device_alloc(sizeof(*chip));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
chip = iio_priv(indio_dev);
/* this is only used for device removal purposes */
i2c_set_clientdata(client, indio_dev);
@@ -506,16 +504,11 @@ static int ad7152_probe(struct i2c_client *client,
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_dev;
+ return ret;
dev_err(&client->dev, "%s capacitive sensor registered\n", id->name);
return 0;
-
-error_free_dev:
- iio_device_free(indio_dev);
-error_ret:
- return ret;
}
static int ad7152_remove(struct i2c_client *client)
@@ -523,7 +516,6 @@ static int ad7152_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
- iio_device_free(indio_dev);
return 0;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] staging: iio: ad7746: Use devm_iio_device_alloc
2013-08-24 19:24 [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Sachin Kamat
2013-08-24 19:24 ` [PATCH 2/3] staging: iio: ad7152: Use devm_iio_device_alloc Sachin Kamat
@ 2013-08-24 19:24 ` Sachin Kamat
2013-08-28 19:23 ` [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: Sachin Kamat @ 2013-08-24 19:24 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, jic23, sachin.kamat, lars
Using devm_iio_device_alloc makes code simpler.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
drivers/staging/iio/cdc/ad7746.c | 18 +++++-------------
1 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index 94f9ca7..75a533b 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -699,11 +699,9 @@ static int ad7746_probe(struct i2c_client *client,
int ret = 0;
unsigned char regval = 0;
- indio_dev = iio_device_alloc(sizeof(*chip));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
+ if (!indio_dev)
+ return -ENOMEM;
chip = iio_priv(indio_dev);
/* this is only used for device removal purposes */
i2c_set_clientdata(client, indio_dev);
@@ -748,20 +746,15 @@ static int ad7746_probe(struct i2c_client *client,
ret = i2c_smbus_write_byte_data(chip->client,
AD7746_REG_EXC_SETUP, regval);
if (ret < 0)
- goto error_free_dev;
+ return ret;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_free_dev;
+ return ret;
dev_info(&client->dev, "%s capacitive sensor registered\n", id->name);
return 0;
-
-error_free_dev:
- iio_device_free(indio_dev);
-error_ret:
- return ret;
}
static int ad7746_remove(struct i2c_client *client)
@@ -769,7 +762,6 @@ static int ad7746_remove(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
iio_device_unregister(indio_dev);
- iio_device_free(indio_dev);
return 0;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs
2013-08-24 19:24 [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Sachin Kamat
2013-08-24 19:24 ` [PATCH 2/3] staging: iio: ad7152: Use devm_iio_device_alloc Sachin Kamat
2013-08-24 19:24 ` [PATCH 3/3] staging: iio: ad7746: " Sachin Kamat
@ 2013-08-28 19:23 ` Jonathan Cameron
2013-08-29 10:27 ` Sachin Kamat
2 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2013-08-28 19:23 UTC (permalink / raw)
To: Sachin Kamat; +Cc: linux-iio, lars
On 08/24/13 20:24, Sachin Kamat wrote:
> devm_* APIs are device managed and make code simpler.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
All 3 of this series applied.
Thanks. I like these patches as I can review them on a mobile phone.
(though then I have to remember to apply them later ;)
Hmm. I really need to update my own MAINTAINERS entries before that email
address goes away. For reference, jic23@kernel.org is the right one.
Somehow updating these things is never urgent enough to get around to doing!
Thanks,
Jonathan
> ---
> Series compile tested on togreg branch of
> git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
> ---
> drivers/staging/iio/cdc/ad7150.c | 36 ++++++++----------------------------
> 1 files changed, 8 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
> index 687dd2c..f4a0341 100644
> --- a/drivers/staging/iio/cdc/ad7150.c
> +++ b/drivers/staging/iio/cdc/ad7150.c
> @@ -558,11 +558,9 @@ static int ad7150_probe(struct i2c_client *client,
> struct ad7150_chip_info *chip;
> struct iio_dev *indio_dev;
>
> - indio_dev = iio_device_alloc(sizeof(*chip));
> - if (indio_dev == NULL) {
> - ret = -ENOMEM;
> - goto error_ret;
> - }
> + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
> + if (!indio_dev)
> + return -ENOMEM;
> chip = iio_priv(indio_dev);
> mutex_init(&chip->state_lock);
> /* this is only used for device removal purposes */
> @@ -581,7 +579,7 @@ static int ad7150_probe(struct i2c_client *client,
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> if (client->irq) {
> - ret = request_threaded_irq(client->irq,
> + ret = devm_request_threaded_irq(&client->dev, client->irq,
> NULL,
> &ad7150_event_handler,
> IRQF_TRIGGER_RISING |
> @@ -590,11 +588,11 @@ static int ad7150_probe(struct i2c_client *client,
> "ad7150_irq1",
> indio_dev);
> if (ret)
> - goto error_free_dev;
> + return ret;
> }
>
> if (client->dev.platform_data) {
> - ret = request_threaded_irq(*(unsigned int *)
> + ret = devm_request_threaded_irq(&client->dev, *(unsigned int *)
> client->dev.platform_data,
> NULL,
> &ad7150_event_handler,
> @@ -604,28 +602,17 @@ static int ad7150_probe(struct i2c_client *client,
> "ad7150_irq2",
> indio_dev);
> if (ret)
> - goto error_free_irq;
> + return ret;
> }
>
> ret = iio_device_register(indio_dev);
> if (ret)
> - goto error_free_irq2;
> + return ret;
>
> dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n",
> id->name, client->irq);
>
> return 0;
> -error_free_irq2:
> - if (client->dev.platform_data)
> - free_irq(*(unsigned int *)client->dev.platform_data,
> - indio_dev);
> -error_free_irq:
> - if (client->irq)
> - free_irq(client->irq, indio_dev);
> -error_free_dev:
> - iio_device_free(indio_dev);
> -error_ret:
> - return ret;
> }
>
> static int ad7150_remove(struct i2c_client *client)
> @@ -633,13 +620,6 @@ static int ad7150_remove(struct i2c_client *client)
> struct iio_dev *indio_dev = i2c_get_clientdata(client);
>
> iio_device_unregister(indio_dev);
> - if (client->irq)
> - free_irq(client->irq, indio_dev);
> -
> - if (client->dev.platform_data)
> - free_irq(*(unsigned int *)client->dev.platform_data, indio_dev);
> -
> - iio_device_free(indio_dev);
>
> return 0;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs
2013-08-28 19:23 ` [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Jonathan Cameron
@ 2013-08-29 10:27 ` Sachin Kamat
0 siblings, 0 replies; 5+ messages in thread
From: Sachin Kamat @ 2013-08-29 10:27 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
On 29 August 2013 00:53, Jonathan Cameron <jic23@kernel.org> wrote:
> On 08/24/13 20:24, Sachin Kamat wrote:
>> devm_* APIs are device managed and make code simpler.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> All 3 of this series applied.
Thanks Jonathan.
>
> Thanks. I like these patches as I can review them on a mobile phone.
> (though then I have to remember to apply them later ;)
Hope you send them soon to Greg too :)
>
> Hmm. I really need to update my own MAINTAINERS entries before that email
> address goes away. For reference, jic23@kernel.org is the right one.
> Somehow updating these things is never urgent enough to get around to doing!
Do you want me to do it for you? :)
--
With warm regards,
Sachin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-08-29 10:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-24 19:24 [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Sachin Kamat
2013-08-24 19:24 ` [PATCH 2/3] staging: iio: ad7152: Use devm_iio_device_alloc Sachin Kamat
2013-08-24 19:24 ` [PATCH 3/3] staging: iio: ad7746: " Sachin Kamat
2013-08-28 19:23 ` [PATCH 1/3] staging: iio: ad7150: Use devm_* APIs Jonathan Cameron
2013-08-29 10:27 ` Sachin Kamat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).