Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sachin Kamat and committed by
Jonathan Cameron
538ee7cb d15b73c5

+4 -12
+4 -12
drivers/staging/iio/cdc/ad7152.c
··· 481 481 struct ad7152_chip_info *chip; 482 482 struct iio_dev *indio_dev; 483 483 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; 489 487 chip = iio_priv(indio_dev); 490 488 /* this is only used for device removal purposes */ 491 489 i2c_set_clientdata(client, indio_dev); ··· 504 506 505 507 ret = iio_device_register(indio_dev); 506 508 if (ret) 507 - goto error_free_dev; 509 + return ret; 508 510 509 511 dev_err(&client->dev, "%s capacitive sensor registered\n", id->name); 510 512 511 513 return 0; 512 - 513 - error_free_dev: 514 - iio_device_free(indio_dev); 515 - error_ret: 516 - return ret; 517 514 } 518 515 519 516 static int ad7152_remove(struct i2c_client *client) ··· 516 523 struct iio_dev *indio_dev = i2c_get_clientdata(client); 517 524 518 525 iio_device_unregister(indio_dev); 519 - iio_device_free(indio_dev); 520 526 521 527 return 0; 522 528 }