aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/adc/ti-adc081c.c
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-23 04:58:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 13:40:42 -0400
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,
74 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) 74 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
75 return -ENODEV; 75 return -ENODEV;
76 76
77 iio = iio_device_alloc(sizeof(*adc)); 77 iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
78 if (!iio) 78 if (!iio)
79 return -ENOMEM; 79 return -ENOMEM;
80 80
81 adc = iio_priv(iio); 81 adc = iio_priv(iio);
82 adc->i2c = client; 82 adc->i2c = client;
83 83
84 adc->ref = regulator_get(&client->dev, "vref"); 84 adc->ref = devm_regulator_get(&client->dev, "vref");
85 if (IS_ERR(adc->ref)) { 85 if (IS_ERR(adc->ref))
86 err = PTR_ERR(adc->ref); 86 return PTR_ERR(adc->ref);
87 goto iio_free;
88 }
89 87
90 err = regulator_enable(adc->ref); 88 err = regulator_enable(adc->ref);
91 if (err < 0) 89 if (err < 0)
92 goto regulator_put; 90 return err;
93 91
94 iio->dev.parent = &client->dev; 92 iio->dev.parent = &client->dev;
95 iio->name = dev_name(&client->dev); 93 iio->name = dev_name(&client->dev);
@@ -109,10 +107,6 @@ static int adc081c_probe(struct i2c_client *client,
109 107
110regulator_disable: 108regulator_disable:
111 regulator_disable(adc->ref); 109 regulator_disable(adc->ref);
112regulator_put:
113 regulator_put(adc->ref);
114iio_free:
115 iio_device_free(iio);
116 110
117 return err; 111 return err;
118} 112}
@@ -124,8 +118,6 @@ static int adc081c_remove(struct i2c_client *client)
124 118
125 iio_device_unregister(iio); 119 iio_device_unregister(iio);
126 regulator_disable(adc->ref); 120 regulator_disable(adc->ref);
127 regulator_put(adc->ref);
128 iio_device_free(iio);
129 121
130 return 0; 122 return 0;
131} 123}