RE: [PATCH v7 2/2] iio: imu: smi240: add driver

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

 



>Hi Shen,
>
>I suspect I led you astray.  regmap core seems unlikely to feed us little endian
>buffers on writes (they should be CPU endian I think) so there should be memcpy()
>for that not a get_unaligned_le16()
>
>> +
>> +static int smi240_regmap_spi_write(void *context, const void *data,
>> +				   size_t count)
>> +{
>> +	u8 reg_addr;
>> +	u16 reg_data;
>> +	u32 request;
>> +	struct spi_device *spi = context;
>> +	struct iio_dev *indio_dev = dev_get_drvdata(&spi->dev);
>> +	struct smi240_data *iio_priv_data = iio_priv(indio_dev);
>> +
>> +	if (count < 2)
>> +		return -EINVAL;
>> +
>> +	reg_addr = ((u8 *)data)[0];
>> +	reg_data = get_unaligned_le16(&((u8 *)data)[1]);
>
>Why is the regmap core giving us an le16?
>I probably sent you wrong way with this earlier :( memcpy probably the correct
>choice here.

Yes, you are right. We shall use memcpy to keep the be CPU endian.  Just using memcpy may be not enough.

Shall we also change regmap_config.val_format_endian  from REGMAP_ENDIAN_LITTLE to  REGMAP_ENDIAN_NATIVE ?

This is to make sure that regmap_write passes the reg-value to smi240_regmap_spi_write without changing the CPU endian.





[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