]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iio: dac: adi-axi: fix a mistake in axi_dac_ext_info_set()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 24 Apr 2024 11:45:30 +0000 (14:45 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 29 Apr 2024 19:53:25 +0000 (20:53 +0100)
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>
drivers/iio/dac/adi-axi-dac.c

index 9047c5aec0ff9d458924f15288aa5a81468a0d15..880d83a014a1ece552a21e8d635b8bfc8687e87d 100644 (file)
@@ -383,15 +383,15 @@ static int axi_dac_ext_info_set(struct iio_backend *back, uintptr_t private,
        case AXI_DAC_FREQ_TONE_1:
        case AXI_DAC_FREQ_TONE_2:
                return axi_dac_frequency_set(st, chan, buf, len,
-                                            private - AXI_DAC_FREQ_TONE_1);
+                                            private == AXI_DAC_FREQ_TONE_2);
        case AXI_DAC_SCALE_TONE_1:
        case AXI_DAC_SCALE_TONE_2:
                return axi_dac_scale_set(st, chan, buf, len,
-                                        private - AXI_DAC_SCALE_TONE_1);
+                                        private == AXI_DAC_SCALE_TONE_2);
        case AXI_DAC_PHASE_TONE_1:
        case AXI_DAC_PHASE_TONE_2:
                return axi_dac_phase_set(st, chan, buf, len,
-                                        private - AXI_DAC_PHASE_TONE_2);
+                                        private == AXI_DAC_PHASE_TONE_2);
        default:
                return -EOPNOTSUPP;
        }