Skip to content

Commit 6ac609d

Browse files
dlechjic23
authored andcommitted
iio: adc: adi-axi-adc: fix ad7606_bus_reg_read()
Mask the value read before returning it. The value read over the parallel bus via the AXI ADC IP block contains both the address and the data, but callers expect val to only contain the data. axi_adc_raw_write() takes a u32 parameter, so addr was the wrong type. This wasn't causing any issues but is corrected anyway since we are touching the same line to add a new variable. Cc: stable@vger.kernel.org Fixes: 79c4748 ("iio: adc: adi-axi-adc: add support for AD7606 register writing") Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250530-iio-adc-adi-axi-adc-fix-ad7606_bus_reg_read-v2-1-ad2dfc0694ce@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 43d8c4a commit 6ac609d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/iio/adc/adi-axi-adc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static int axi_adc_raw_read(struct iio_backend *back, u32 *val)
445445
static int ad7606_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val)
446446
{
447447
struct adi_axi_adc_state *st = iio_backend_get_priv(back);
448-
int addr;
448+
u32 addr, reg_val;
449449

450450
guard(mutex)(&st->lock);
451451

@@ -455,7 +455,9 @@ static int ad7606_bus_reg_read(struct iio_backend *back, u32 reg, u32 *val)
455455
*/
456456
addr = FIELD_PREP(ADI_AXI_REG_ADDRESS_MASK, reg) | ADI_AXI_REG_READ_BIT;
457457
axi_adc_raw_write(back, addr);
458-
axi_adc_raw_read(back, val);
458+
axi_adc_raw_read(back, &reg_val);
459+
460+
*val = FIELD_GET(ADI_AXI_REG_VALUE_MASK, reg_val);
459461

460462
/* Write 0x0 on the bus to get back to ADC mode */
461463
axi_adc_raw_write(back, 0);

0 commit comments

Comments
 (0)