aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-07-30 02:24:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-08-03 16:00:15 -0400
commit36db8c72169489eedca06fe308b1643256d8c4fe (patch)
tree159c424589bbc8a819fa7dc88cfb7754a03f255b /drivers
parent1003eb67baf00cca8aa51f5833090c61938aa82e (diff)
iio: amplifiers: ad8366: Use devm_* APIs
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> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/amplifiers/ad8366.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index d354554b51b3..d0a79a4bce1c 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)
139 struct ad8366_state *st; 139 struct ad8366_state *st;
140 int ret; 140 int ret;
141 141
142 indio_dev = iio_device_alloc(sizeof(*st)); 142 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
143 if (indio_dev == NULL) 143 if (indio_dev == NULL)
144 return -ENOMEM; 144 return -ENOMEM;
145 145
146 st = iio_priv(indio_dev); 146 st = iio_priv(indio_dev);
147 147
148 st->reg = regulator_get(&spi->dev, "vcc"); 148 st->reg = devm_regulator_get(&spi->dev, "vcc");
149 if (!IS_ERR(st->reg)) { 149 if (!IS_ERR(st->reg)) {
150 ret = regulator_enable(st->reg); 150 ret = regulator_enable(st->reg);
151 if (ret) 151 if (ret)
152 goto error_put_reg; 152 return ret;
153 } 153 }
154 154
155 spi_set_drvdata(spi, indio_dev); 155 spi_set_drvdata(spi, indio_dev);
@@ -173,11 +173,6 @@ static int ad8366_probe(struct spi_device *spi)
173error_disable_reg: 173error_disable_reg:
174 if (!IS_ERR(st->reg)) 174 if (!IS_ERR(st->reg))
175 regulator_disable(st->reg); 175 regulator_disable(st->reg);
176error_put_reg:
177 if (!IS_ERR(st->reg))
178 regulator_put(st->reg);
179
180 iio_device_free(indio_dev);
181 176
182 return ret; 177 return ret;
183} 178}
@@ -195,8 +190,6 @@ static int ad8366_remove(struct spi_device *spi)
195 regulator_put(reg); 190 regulator_put(reg);
196 } 191 }
197 192
198 iio_device_free(indio_dev);
199
200 return 0; 193 return 0;
201} 194}
202 195