Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: iio: fix ad7606_spi regression

As pointed out by Geert Uytterhoeven, the patch was incorrect
and breaks the driver, which was fortunately pointed out by
this gcc warning:

drivers/staging/iio/adc/ad7606_spi.c: In function ‘ad7606_spi_read_block’:
drivers/staging/iio/adc/ad7606_spi.c:34: warning: ‘data’ is used uninitialized in this function

The effect of the patch is that the data is copied into
a random memory location (from the uninitialized pointer)
instead of being byteswapped in place.

This adds the initialization for the 'data' variable back
to restore the original behavior.

Cc: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Fixes: 87787e5ef727 ("Staging: iio: Fix sparse endian warning")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Arnd Bergmann and committed by
Jonathan Cameron
7e982555 6e85dbe4

+1 -1
+1 -1
drivers/staging/iio/adc/ad7606_spi.c
··· 21 21 { 22 22 struct spi_device *spi = to_spi_device(dev); 23 23 int i, ret; 24 - unsigned short *data; 24 + unsigned short *data = buf; 25 25 __be16 *bdata = buf; 26 26 27 27 ret = spi_read(spi, buf, count * 2);