diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2013-08-24 15:24:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-08-28 15:21:33 -0400 |
commit | 538ee7cbffc1663d76f257438c35c889b0664fcc (patch) | |
tree | 564abe24b2a799fc0e2a1288883ea4bef3b8947a | |
parent | d15b73c5bf67f273ded2f4405aea4ba79c3542ae (diff) |
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>
-rw-r--r-- | drivers/staging/iio/cdc/ad7152.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index 1d7c5283a85c..f2c309d1eb59 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c | |||
@@ -481,11 +481,9 @@ static int ad7152_probe(struct i2c_client *client, | |||
481 | struct ad7152_chip_info *chip; | 481 | struct ad7152_chip_info *chip; |
482 | struct iio_dev *indio_dev; | 482 | struct iio_dev *indio_dev; |
483 | 483 | ||
484 | indio_dev = iio_device_alloc(sizeof(*chip)); | 484 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); |
485 | if (indio_dev == NULL) { | 485 | if (!indio_dev) |
486 | ret = -ENOMEM; | 486 | return -ENOMEM; |
487 | goto error_ret; | ||
488 | } | ||
489 | chip = iio_priv(indio_dev); | 487 | chip = iio_priv(indio_dev); |
490 | /* this is only used for device removal purposes */ | 488 | /* this is only used for device removal purposes */ |
491 | i2c_set_clientdata(client, indio_dev); | 489 | i2c_set_clientdata(client, indio_dev); |
@@ -506,16 +504,11 @@ static int ad7152_probe(struct i2c_client *client, | |||
506 | 504 | ||
507 | ret = iio_device_register(indio_dev); | 505 | ret = iio_device_register(indio_dev); |
508 | if (ret) | 506 | if (ret) |
509 | goto error_free_dev; | 507 | return ret; |
510 | 508 | ||
511 | dev_err(&client->dev, "%s capacitive sensor registered\n", id->name); | 509 | dev_err(&client->dev, "%s capacitive sensor registered\n", id->name); |
512 | 510 | ||
513 | return 0; | 511 | return 0; |
514 | |||
515 | error_free_dev: | ||
516 | iio_device_free(indio_dev); | ||
517 | error_ret: | ||
518 | return ret; | ||
519 | } | 512 | } |
520 | 513 | ||
521 | static int ad7152_remove(struct i2c_client *client) | 514 | static int ad7152_remove(struct i2c_client *client) |
@@ -523,7 +516,6 @@ static int ad7152_remove(struct i2c_client *client) | |||
523 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | 516 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
524 | 517 | ||
525 | iio_device_unregister(indio_dev); | 518 | iio_device_unregister(indio_dev); |
526 | iio_device_free(indio_dev); | ||
527 | 519 | ||
528 | return 0; | 520 | return 0; |
529 | } | 521 | } |