Re: [PATCH v2 2/4] iio: accel: adxl345: use scan_index for accessing accel registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 18, 2018 at 6:59 PM, Akinobu Mita <akinobu.mita@xxxxxxxxx> wrote:
> Currently the address field in iio_chan_spec is filled with an accel
> data register address for the corresponding axis.
>
> In preparation for adding calibration offset support, this makes use of
> scan_index field to access accel data registers instead of using address
> field.  This change makes it easier to access both accel registers and
> calibration offset registers with fewer lines of code as these are
> located in X-axis, Y-axis, Z-axis order.

> +               ret = regmap_bulk_read(data->regmap, ADXL345_REG_DATAX0 +
> +                                      sizeof(regval) * chan->scan_index,
> +                                      &regval, sizeof(regval));

Can't we do something like

#define ADXL345_REG_DATA_AXIS(si)  (0x32 + (si) * sizeof(__le16))

instead and use where applicable?

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux