Skip to content

Commit 538ee7c

Browse files
Sachin Kamatjic23
authored andcommitted
staging: iio: ad7152: Use devm_iio_device_alloc
Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent d15b73c commit 538ee7c

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

‎drivers/staging/iio/cdc/ad7152.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,9 @@ static int ad7152_probe(struct i2c_client *client,
481481
struct ad7152_chip_info *chip;
482482
struct iio_dev *indio_dev;
483483

484-
indio_dev = iio_device_alloc(sizeof(*chip));
485-
if (indio_dev == NULL) {
486-
ret = -ENOMEM;
487-
goto error_ret;
488-
}
484+
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip));
485+
if (!indio_dev)
486+
return -ENOMEM;
489487
chip = iio_priv(indio_dev);
490488
/* this is only used for device removal purposes */
491489
i2c_set_clientdata(client, indio_dev);
@@ -506,24 +504,18 @@ static int ad7152_probe(struct i2c_client *client,
506504

507505
ret = iio_device_register(indio_dev);
508506
if (ret)
509-
goto error_free_dev;
507+
return ret;
510508

511509
dev_err(&client->dev, "%s capacitive sensor registered\n", id->name);
512510

513511
return 0;
514-
515-
error_free_dev:
516-
iio_device_free(indio_dev);
517-
error_ret:
518-
return ret;
519512
}
520513

521514
static int ad7152_remove(struct i2c_client *client)
522515
{
523516
struct iio_dev *indio_dev = i2c_get_clientdata(client);
524517

525518
iio_device_unregister(indio_dev);
526-
iio_device_free(indio_dev);
527519

528520
return 0;
529521
}

0 commit comments

Comments
 (0)