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

staging: iio: ade7854: Use devm_iio_device_alloc

devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Barry Song <21cnbao@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Sachin Kamat and committed by
Jonathan Cameron
b909459f b67637a3

+3 -11
+1 -3
drivers/staging/iio/meter/ade7854-i2c.c
··· 208 208 struct ade7854_state *st; 209 209 struct iio_dev *indio_dev; 210 210 211 - indio_dev = iio_device_alloc(sizeof(*st)); 211 + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); 212 212 if (indio_dev == NULL) 213 213 return -ENOMEM; 214 214 st = iio_priv(indio_dev); ··· 225 225 st->irq = client->irq; 226 226 227 227 ret = ade7854_probe(indio_dev, &client->dev); 228 - if (ret) 229 - iio_device_free(indio_dev); 230 228 231 229 return ret; 232 230 }
+1 -3
drivers/staging/iio/meter/ade7854-spi.c
··· 278 278 struct ade7854_state *st; 279 279 struct iio_dev *indio_dev; 280 280 281 - indio_dev = iio_device_alloc(sizeof(*st)); 281 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 282 282 if (indio_dev == NULL) 283 283 return -ENOMEM; 284 284 st = iio_priv(indio_dev); ··· 296 296 297 297 298 298 ret = ade7854_probe(indio_dev, &spi->dev); 299 - if (ret) 300 - iio_device_free(indio_dev); 301 299 302 300 return 0; 303 301 }
+1 -5
drivers/staging/iio/meter/ade7854.c
··· 550 550 551 551 ret = iio_device_register(indio_dev); 552 552 if (ret) 553 - goto error_free_dev; 553 + return ret; 554 554 555 555 /* Get the device into a sane initial state */ 556 556 ret = ade7854_initial_setup(indio_dev); ··· 561 561 562 562 error_unreg_dev: 563 563 iio_device_unregister(indio_dev); 564 - error_free_dev: 565 - iio_device_free(indio_dev); 566 - 567 564 return ret; 568 565 } 569 566 EXPORT_SYMBOL(ade7854_probe); ··· 568 571 int ade7854_remove(struct iio_dev *indio_dev) 569 572 { 570 573 iio_device_unregister(indio_dev); 571 - iio_device_free(indio_dev); 572 574 573 575 return 0; 574 576 }