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

staging: iio: ad2s90: Use devm_iio_device_alloc

devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Graff Yang <graff.yang@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Sachin Kamat and committed by
Jonathan Cameron
6bba7983 50711572

+4 -12
+4 -12
drivers/staging/iio/resolver/ad2s90.c
··· 64 64 struct ad2s90_state *st; 65 65 int ret = 0; 66 66 67 - indio_dev = iio_device_alloc(sizeof(*st)); 68 - if (indio_dev == NULL) { 69 - ret = -ENOMEM; 70 - goto error_ret; 71 - } 67 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 68 + if (!indio_dev) 69 + return -ENOMEM; 72 70 st = iio_priv(indio_dev); 73 71 spi_set_drvdata(spi, indio_dev); 74 72 ··· 81 83 82 84 ret = iio_device_register(indio_dev); 83 85 if (ret) 84 - goto error_free_dev; 86 + return ret; 85 87 86 88 /* need 600ns between CS and the first falling edge of SCLK */ 87 89 spi->max_speed_hz = 830000; ··· 89 91 spi_setup(spi); 90 92 91 93 return 0; 92 - 93 - error_free_dev: 94 - iio_device_free(indio_dev); 95 - error_ret: 96 - return ret; 97 94 } 98 95 99 96 static int ad2s90_remove(struct spi_device *spi) 100 97 { 101 98 iio_device_unregister(spi_get_drvdata(spi)); 102 - iio_device_free(spi_get_drvdata(spi)); 103 99 104 100 return 0; 105 101 }