staging:iio:adc:ad7280a: Fix handing of device address bit reversing.
authorJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 6 Feb 2022 19:03:09 +0000 (19:03 +0000)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 21 Feb 2022 19:33:04 +0000 (19:33 +0000)
The bit reversal was wrong for bits 1 and 3 of the 5 bits.
Result is driver failure to probe if you have more than 2 daisy-chained
devices.  Discovered via QEMU based device emulation.

Fixes tag is for when this moved from a macro to a function, but it
was broken before that.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Fixes: 065a7c0b1fec ("Staging: iio: adc: ad7280a.c: Fixed Macro argument reuse")
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Link: https://lore.kernel.org/r/20220206190328.333093-2-jic23@kernel.org
drivers/staging/iio/adc/ad7280a.c

index fef0055..20183b2 100644 (file)
 static unsigned int ad7280a_devaddr(unsigned int addr)
 {
        return ((addr & 0x1) << 4) |
-              ((addr & 0x2) << 3) |
+              ((addr & 0x2) << 2) |
               (addr & 0x4) |
-              ((addr & 0x8) >> 3) |
+              ((addr & 0x8) >> 2) |
               ((addr & 0x10) >> 4);
 }