Skip to content

Commit d63519e

Browse files
Sachin Kamatjic23
authored andcommitted
staging: iio: ad9910: 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 98d8abd commit d63519e

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

drivers/staging/iio/frequency/ad9910.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,9 @@ static int ad9910_probe(struct spi_device *spi)
367367
struct iio_dev *idev;
368368
int ret = 0;
369369

370-
idev = iio_device_alloc(sizeof(*st));
371-
if (idev == NULL) {
372-
ret = -ENOMEM;
373-
goto error_ret;
374-
}
370+
idev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
371+
if (!idev)
372+
return -ENOMEM;
375373
spi_set_drvdata(spi, idev);
376374
st = iio_priv(idev);
377375
mutex_init(&st->lock);
@@ -383,24 +381,18 @@ static int ad9910_probe(struct spi_device *spi)
383381

384382
ret = iio_device_register(idev);
385383
if (ret)
386-
goto error_free_dev;
384+
return ret;
387385
spi->max_speed_hz = 2000000;
388386
spi->mode = SPI_MODE_3;
389387
spi->bits_per_word = 8;
390388
spi_setup(spi);
391389
ad9910_init(st);
392390
return 0;
393-
394-
error_free_dev:
395-
iio_device_free(idev);
396-
error_ret:
397-
return ret;
398391
}
399392

400393
static int ad9910_remove(struct spi_device *spi)
401394
{
402395
iio_device_unregister(spi_get_drvdata(spi));
403-
iio_device_free(spi_get_drvdata(spi));
404396

405397
return 0;
406398
}

0 commit comments

Comments
 (0)