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

iio: dac: adi-axi: fix a mistake in axi_dac_ext_info_set()

The last parameter of these axi_dac_(frequency|scale|phase)_set()
functions is supposed to be true for TONE_2 and false for TONE_1. The
bug is the last call where it passes "private - TONE_2". That
subtraction is going to be zero/false for TONE_2 and and -1/true for
TONE_1. Fix the bug, and re-write it as "private == TONE_2" so it's
more obvious what is happening.

Fixes: 4e3949a192e4 ("iio: dac: add support for AXI DAC IP core")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/df7c6e1b-b619-40c3-9881-838587ed15d4@moroto.mountain
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Dan Carpenter and committed by
Jonathan Cameron
73e49886 a1432b5b

+3 -3
+3 -3
drivers/iio/dac/adi-axi-dac.c
··· 383 383 case AXI_DAC_FREQ_TONE_1: 384 384 case AXI_DAC_FREQ_TONE_2: 385 385 return axi_dac_frequency_set(st, chan, buf, len, 386 - private - AXI_DAC_FREQ_TONE_1); 386 + private == AXI_DAC_FREQ_TONE_2); 387 387 case AXI_DAC_SCALE_TONE_1: 388 388 case AXI_DAC_SCALE_TONE_2: 389 389 return axi_dac_scale_set(st, chan, buf, len, 390 - private - AXI_DAC_SCALE_TONE_1); 390 + private == AXI_DAC_SCALE_TONE_2); 391 391 case AXI_DAC_PHASE_TONE_1: 392 392 case AXI_DAC_PHASE_TONE_2: 393 393 return axi_dac_phase_set(st, chan, buf, len, 394 - private - AXI_DAC_PHASE_TONE_2); 394 + private == AXI_DAC_PHASE_TONE_2); 395 395 default: 396 396 return -EOPNOTSUPP; 397 397 }