--- zzzz-none-000/linux-3.10.107/drivers/iio/gyro/adxrs450.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/iio/gyro/adxrs450.c 2021-02-04 17:41:59.000000000 +0000 @@ -90,7 +90,6 @@ u8 reg_address, u16 *val) { - struct spi_message msg; struct adxrs450_state *st = iio_priv(indio_dev); u32 tx; int ret; @@ -114,10 +113,7 @@ tx |= ADXRS450_P; st->tx = cpu_to_be32(tx); - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n", reg_address); @@ -169,7 +165,6 @@ **/ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val) { - struct spi_message msg; struct adxrs450_state *st = iio_priv(indio_dev); int ret; struct spi_transfer xfers[] = { @@ -188,10 +183,7 @@ mutex_lock(&st->buf_lock); st->tx = cpu_to_be32(ADXRS450_SENSOR_DATA); - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - ret = spi_sync(st->us, &msg); + ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); if (ret) { dev_err(&st->us->dev, "Problem while reading sensor data\n"); goto error_ret; @@ -354,7 +346,6 @@ default: return -EINVAL; } - break; case IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW: ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t); if (ret) @@ -426,11 +417,9 @@ struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - 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); st->us = spi; mutex_init(&st->buf_lock); @@ -445,28 +434,14 @@ indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); indio_dev->name = spi->dev.driver->name; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(&spi->dev, indio_dev); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adxrs450_initial_setup(indio_dev); if (ret) - goto error_initial; - return 0; -error_initial: - iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); - -error_ret: - return ret; -} - -static int adxrs450_remove(struct spi_device *spi) -{ - iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); + return ret; return 0; } @@ -481,10 +456,8 @@ static struct spi_driver adxrs450_driver = { .driver = { .name = "adxrs450", - .owner = THIS_MODULE, }, .probe = adxrs450_probe, - .remove = adxrs450_remove, .id_table = adxrs450_id, }; module_spi_driver(adxrs450_driver);