Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5fe7a41 authored by Jonathan Cameron's avatar Jonathan Cameron
Browse files

staging:iio:mag:hmc5843 fix incorrect endianness of channel as a result of...


staging:iio:mag:hmc5843 fix incorrect endianness of channel as a result of missuse of the IIO_ST macro.

This driver sets the shift value equal to IIO_BE (or 1) rather than setting
that to 0 and specificying the endianness.  This means the channel type is
missreported as
[be|le]:u16/16>>1 where the be|le is dependent on the cpu native endianness,
rather than
be:u16/16>>0 resulting in any userspace code using this information, miss
converting the channel and generating thoroughly trashed data.

Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Cc: stable@vger.kernel.org
parent 128d6637
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -451,7 +451,12 @@ static irqreturn_t hmc5843_trigger_handler(int irq, void *p)
		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |	\
		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |	\
			BIT(IIO_CHAN_INFO_SAMP_FREQ),			\
			BIT(IIO_CHAN_INFO_SAMP_FREQ),			\
		.scan_index = idx,					\
		.scan_index = idx,					\
		.scan_type = IIO_ST('s', 16, 16, IIO_BE),		\
		.scan_type = {						\
			.sign = 's',					\
			.realbits = 16,					\
			.storagebits = 16,				\
			.endianness = IIO_BE,				\
		},							\
	}
	}


static const struct iio_chan_spec hmc5843_channels[] = {
static const struct iio_chan_spec hmc5843_channels[] = {