--- zzzz-none-000/linux-3.10.107/drivers/iio/accel/kxsd9.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/iio/accel/kxsd9.c 2021-02-04 17:41:59.000000000 +0000 @@ -225,13 +225,11 @@ { struct iio_dev *indio_dev; struct kxsd9_state *st; - int ret; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); @@ -248,22 +246,12 @@ spi_setup(spi); kxsd9_power_up(st); - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - - return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; + return iio_device_register(indio_dev); } static int kxsd9_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); return 0; } @@ -277,7 +265,6 @@ static struct spi_driver kxsd9_driver = { .driver = { .name = "kxsd9", - .owner = THIS_MODULE, }, .probe = kxsd9_probe, .remove = kxsd9_remove,