diff options
Diffstat (limited to 'drivers/iio/amplifiers/ad8366.c')
-rw-r--r-- | drivers/iio/amplifiers/ad8366.c | 13 |
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) | |||
173 | error_disable_reg: | 173 | error_disable_reg: |
174 | if (!IS_ERR(st->reg)) | 174 | if (!IS_ERR(st->reg)) |
175 | regulator_disable(st->reg); | 175 | regulator_disable(st->reg); |
176 | error_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 | ||