summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/ti-adc081c.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-23 09:58:00 +0100
committerJonathan Cameron <jic23@kernel.org>2013-08-03 18:40:42 +0100
commit99e94b6d567188275b1269d4bd72d78cc10df8c3 (patch)
tree52a194b19a2d0682cbae634e275311afdfffb965 /drivers/iio/adc/ti-adc081c.c
parented6886c104c151c4d2d8fbce154da945c3d04dad (diff)
iio: adc: ti-adc081c: Use devm_* APIs
devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Reviewed-by: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/adc/ti-adc081c.c')
-rw-r--r--drivers/iio/adc/ti-adc081c.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c
index 2826faae706c..ee5f72bffe5a 100644
--- a/drivers/iio/adc/ti-adc081c.c
+++ b/drivers/iio/adc/ti-adc081c.c
@@ -74,22 +74,20 @@ static int adc081c_probe(struct i2c_client *client,
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV;
- iio = iio_device_alloc(sizeof(*adc));
+ iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
if (!iio)
return -ENOMEM;
adc = iio_priv(iio);
adc->i2c = client;
- adc->ref = regulator_get(&client->dev, "vref");
- if (IS_ERR(adc->ref)) {
- err = PTR_ERR(adc->ref);
- goto iio_free;
- }
+ adc->ref = devm_regulator_get(&client->dev, "vref");
+ if (IS_ERR(adc->ref))
+ return PTR_ERR(adc->ref);
err = regulator_enable(adc->ref);
if (err < 0)
- goto regulator_put;
+ return err;
iio->dev.parent = &client->dev;
iio->name = dev_name(&client->dev);
@@ -109,10 +107,6 @@ static int adc081c_probe(struct i2c_client *client,
regulator_disable:
regulator_disable(adc->ref);
-regulator_put:
- regulator_put(adc->ref);
-iio_free:
- iio_device_free(iio);
return err;
}
@@ -124,8 +118,6 @@ static int adc081c_remove(struct i2c_client *client)
iio_device_unregister(iio);
regulator_disable(adc->ref);
- regulator_put(adc->ref);
- iio_device_free(iio);
return 0;
}