Re: [PATCH v2 6/9] iio: imu: st_lsm6dsx: add i2c embedded controller support

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

 



On Sun, 11 Nov 2018 15:15:33 +0100
Lorenzo Bianconi <lorenzo.bianconi@xxxxxxxxxx> wrote:

> i2c controller embedded in lsm6dx series can connect up to four
> slave devices using accelerometer sensor as trigger for i2c
> read/write operations.
> Introduce sensor hub support for lsm6dso sensor. Add register map
> for lis2mdl magnetometer sensor.
> In order to perform single read/write operations st_lsm6dsx driver
> relies on SLV0 channel (hw FIFO is not supported yet)
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxxxxxx>
Hi Lorenzo.

A build warning came up pointing out an issue with little endian
sizes.

I've 'guessed' that data is actually meant to be __le16 but
please confirm I got that right!

> +static int
> +st_lsm6dsx_shub_read_oneshot(struct st_lsm6dsx_sensor *sensor,
> +			     struct iio_chan_spec const *ch,
> +			     int *val)
> +{
> +	int err, delay, len = ch->scan_type.realbits >> 3;
> +	__le32 data;
> +
> +	err = st_lsm6dsx_shub_set_enable(sensor, true);
> +	if (err < 0)
> +		return err;
> +
> +	delay = 1000000 / sensor->odr;
> +	usleep_range(delay, 2 * delay);
> +
> +	err = st_lsm6dsx_shub_read(sensor, ch->address, (u8 *)&data, len);
> +	if (err < 0)
> +		return err;
> +
> +	st_lsm6dsx_shub_set_enable(sensor, false);
> +
> +	switch (len) {
> +	case 2:
> +		*val = (s16)le16_to_cpu(data);
This one is odd given data is an __le32?
What's going on here?

> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return IIO_VAL_INT;
> +}
> +



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux