Skip to content

Commit 177e4af

Browse files
Sachin Kamatjic23
authored andcommitted
staging: iio: ad9951: Use devm_iio_device_alloc
devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent d63519e commit 177e4af

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

drivers/staging/iio/frequency/ad9951.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,9 @@ static int ad9951_probe(struct spi_device *spi)
176176
struct iio_dev *idev;
177177
int ret = 0;
178178

179-
idev = iio_device_alloc(sizeof(*st));
180-
if (idev == NULL) {
181-
ret = -ENOMEM;
182-
goto error_ret;
183-
}
179+
idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
180+
if (!idev)
181+
return -ENOMEM;
184182
spi_set_drvdata(spi, idev);
185183
st = iio_priv(idev);
186184
mutex_init(&st->lock);
@@ -193,25 +191,18 @@ static int ad9951_probe(struct spi_device *spi)
193191

194192
ret = iio_device_register(idev);
195193
if (ret)
196-
goto error_free_dev;
194+
return ret;
197195
spi->max_speed_hz = 2000000;
198196
spi->mode = SPI_MODE_3;
199197
spi->bits_per_word = 8;
200198
spi_setup(spi);
201199
ad9951_init(st);
202200
return 0;
203-
204-
error_free_dev:
205-
iio_device_free(idev);
206-
207-
error_ret:
208-
return ret;
209201
}
210202

211203
static int ad9951_remove(struct spi_device *spi)
212204
{
213205
iio_device_unregister(spi_get_drvdata(spi));
214-
iio_device_free(spi_get_drvdata(spi));
215206

216207
return 0;
217208
}

0 commit comments

Comments
 (0)