Re: [PATCH] iio: Fix endianness issue in ak8975_read_axis()

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

 



Hello Srinivas,

> > -	/* Endian conversion of the measured values. */
> > -	raw = (s16) (le16_to_cpu(meas_reg));
> > -
> >   	/* Clamp to valid range. */
> > -	raw = clamp_t(s16, raw, -4096, 4095);
> > -	*val = raw;
> > +	*val = clamp_t(s16, ret, -4096, 4095);
> >   	return IIO_VAL_INT;
> > 
> >   exit:
> > 
> I did some experiments on little-endian platforms,  so your change
> won't hurt on x86.

good!

> Don't we need to convert for big-endian platforms?
> 
> When I trace the path for i2c, I don't see any host order
> conversion.

> order word according to SMBUS specification, low byte on the bus first
> 	case I2C_SMBUS_WORD_DATA:
> 		case I2C_SMBUS_PROC_CALL:
> 			data->word = msgbuf1[0] | (msgbuf1[1] << 8);
> 			break;
> }
> 	But there is no host order conversion?

data->word = msgbuf1[0] | (msgbuf1[1] << 8);
will work irrespective of host endianness

the story would be different for
data->word = *(short *)msgbuf1;
which works for little-endian, but not for big-endian

so: don't worry :)

p.

-- 

Peter Meerwald
+43-664-2444418 (mobile)
--
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