--- zzzz-none-000/linux-3.10.107/drivers/iio/dac/ad5755.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/iio/dac/ad5755.c 2021-02-04 17:41:59.000000000 +0000 @@ -97,7 +97,7 @@ */ union { - u32 d32; + __be32 d32; u8 d8[4]; } data[2] ____cacheline_aligned; }; @@ -253,15 +253,6 @@ return (min * (1 << chan->scan_type.realbits)) / (max - min); } -static inline int ad5755_get_scale(struct ad5755_state *st, - struct iio_chan_spec const *chan) -{ - int min, max; - - ad5755_get_min_max(st, chan, &min, &max); - return ((max - min) * 1000000000ULL) >> chan->scan_type.realbits; -} - static int ad5755_chan_reg_info(struct ad5755_state *st, struct iio_chan_spec const *chan, long info, bool write, unsigned int *reg, unsigned int *shift, unsigned int *offset) @@ -303,13 +294,15 @@ { struct ad5755_state *st = iio_priv(indio_dev); unsigned int reg, shift, offset; + int min, max; int ret; switch (info) { case IIO_CHAN_INFO_SCALE: - *val = 0; - *val2 = ad5755_get_scale(st, chan); - return IIO_VAL_INT_PLUS_NANO; + ad5755_get_min_max(st, chan, &min, &max); + *val = max - min; + *val2 = chan->scan_type.realbits; + return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: *val = ad5755_get_offset(st, chan); return IIO_VAL_INT; @@ -386,6 +379,7 @@ .name = "powerdown", .read = ad5755_read_powerdown, .write = ad5755_write_powerdown, + .shared = IIO_SEPARATE, }, { }, }; @@ -398,7 +392,12 @@ BIT(IIO_CHAN_INFO_OFFSET) | \ BIT(IIO_CHAN_INFO_CALIBSCALE) | \ BIT(IIO_CHAN_INFO_CALIBBIAS), \ - .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (_bits), \ + .storagebits = 16, \ + .shift = 16 - (_bits), \ + }, \ .ext_info = ad5755_ext_info, \ } @@ -565,7 +564,7 @@ struct ad5755_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(&spi->dev, "Failed to allocate iio device\n"); return -ENOMEM; @@ -589,34 +588,13 @@ ret = ad5755_init_channels(indio_dev, pdata); if (ret) - goto error_free; + return ret; ret = ad5755_setup_pdata(indio_dev, pdata); if (ret) - goto error_free; - - ret = iio_device_register(indio_dev); - if (ret) { - dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); - goto error_free; - } - - return 0; - -error_free: - iio_device_free(indio_dev); - - return ret; -} - -static int ad5755_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - - iio_device_unregister(indio_dev); - iio_device_free(indio_dev); + return ret; - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id ad5755_id[] = { @@ -632,10 +610,8 @@ static struct spi_driver ad5755_driver = { .driver = { .name = "ad5755", - .owner = THIS_MODULE, }, .probe = ad5755_probe, - .remove = ad5755_remove, .id_table = ad5755_id, }; module_spi_driver(ad5755_driver);