sst-linux/drivers/iio/adc
Uwe Kleine-König 7098ae7ee2 iio: adc: ad7124: Fix comparison of channel configs
[ Upstream commit 05a5d874f7327b75e9bc4359618017e047cc129c ]

Checking the binary representation of two structs (of the same type)
for equality doesn't have the same semantic as comparing all members for
equality. The former might find a difference where the latter doesn't in
the presence of padding or when ambiguous types like float or bool are
involved. (Floats typically have different representations for single
values, like -0.0 vs +0.0, or 0.5 * 2² vs 0.25 * 2³. The type bool has
at least 8 bits and the raw values 1 and 2 (probably) both evaluate to
true, but memcmp finds a difference.)

When searching for a channel that already has the configuration we need,
the comparison by member is the one that is needed.

Convert the comparison accordingly to compare the members one after
another. Also add a static_assert guard to (somewhat) ensure that when
struct ad7124_channel_config::config_props is expanded, the comparison
is adapted, too.

This issue is somewhat theoretic, but using memcmp() on a struct is a
bad pattern that is worth fixing.

Fixes: 7b8d045e49 ("iio: adc: ad7124: allow more than 8 channels")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20250303114659.1672695-13-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-04-10 14:33:36 +02:00
..
ab8500-gpadc.c
ad799x.c
ad7091r5.c iio: adc: ad7091r: Allow users to configure device events 2024-01-31 16:16:58 -08:00
ad7091r-base.c iio: adc: ad7091r: Enable internal vref if external vref is not supplied 2024-01-31 16:17:00 -08:00
ad7091r-base.h iio: adc: ad7091r: Enable internal vref if external vref is not supplied 2024-01-31 16:17:00 -08:00
ad7124.c iio: adc: ad7124: Fix comparison of channel configs 2025-04-10 14:33:36 +02:00
ad7192.c iio: adc: ad7192: Correct reference voltage 2023-10-25 12:03:09 +02:00
ad7266.c iio: adc: ad7266: Fix variable checking bug 2024-07-05 09:31:53 +02:00
ad7280a.c
ad7291.c
ad7292.c
ad7298.c
ad7476.c
ad7606_par.c iio: adc: ad7606: remove frstdata check for serial mode 2024-09-12 11:10:26 +02:00
ad7606_spi.c iio: adc: ad7606: fix oversampling gpio array 2024-10-17 15:21:10 +02:00
ad7606.c iio: adc: ad7606: fix standby gpio state to match the documentation 2024-10-17 15:21:11 +02:00
ad7606.h iio: adc: ad7606: remove frstdata check for serial mode 2024-09-12 11:10:26 +02:00
ad7766.c
ad7768-1.c
ad7780.c ad7780: fix division by zero in ad7780_write_raw() 2024-12-14 19:54:14 +01:00
ad7791.c
ad7793.c
ad7887.c
ad7923.c iio: adc: ad7923: Fix buffer overflow for tx_buf and ring_xfer 2024-12-14 19:54:16 +01:00
ad7949.c
ad9467.c iio: adc: ad9467: fix scan type sign 2024-06-21 14:35:53 +02:00
ad_sigma_delta.c iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag 2023-06-09 10:34:19 +02:00
adi-axi-adc.c iio: adc: ad9467: fix scale setting 2024-01-25 15:27:47 -08:00
aspeed_adc.c
at91_adc.c iio: adc: at91: call input_free_device() on allocated iio_dev 2025-01-17 13:34:46 +01:00
at91-sama5d2_adc.c iio: adc: at91-sama5d2_adc: fix sama7g5 realbits value 2025-03-13 12:53:23 +01:00
axp20x_adc.c
axp288_adc.c
bcm_iproc_adc.c
berlin2-adc.c
cc10001_adc.c
cpcap-adc.c
da9150-gpadc.c
dln2-adc.c
envelope-detector.c
ep93xx_adc.c
exynos_adc.c iio: exynos-adc: request second interupt only when touchscreen mode is used 2023-11-02 09:35:29 +01:00
fsl-imx25-gcq.c
hi8435.c
hx711.c
imx7d_adc.c
imx8qxp-adc.c iio: adc: imx8qxp: Fix address for command buffer registers 2023-10-19 23:08:55 +02:00
ina2xx-adc.c iio: adc: ina2xx: avoid NULL pointer dereference on OF device match 2023-08-16 18:27:24 +02:00
ingenic-adc.c
intel_mrfld_adc.c
Kconfig iio: adc: ti-ads124s08: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig 2024-10-22 15:56:48 +02:00
lp8788_adc.c
lpc18xx_adc.c
lpc32xx_adc.c
ltc2471.c
ltc2485.c
ltc2496.c
ltc2497-core.c
ltc2497.c
ltc2497.h
Makefile
max1027.c
max1118.c
max1241.c
max1363.c
max9611.c
max11100.c
max11205.c
mcp320x.c
mcp3422.c
mcp3911.c
men_z188_adc.c
meson_saradc.c meson saradc: fix clock divider mask length 2023-07-23 13:49:42 +02:00
mp2629_adc.c
mt6360-adc.c
mt6577_auxadc.c
mxs-lradc-adc.c
nau7802.c
npcm_adc.c
palmas_gpadc.c
qcom-pm8xxx-xoadc.c
qcom-spmi-adc5.c
qcom-spmi-iadc.c
qcom-spmi-rradc.c
qcom-spmi-vadc.c
qcom-vadc-common.c
rcar-gyroadc.c
rn5t618-adc.c
rockchip_saradc.c iio: adc: rockchip_saradc: fix information leak in triggered buffer 2025-01-23 17:17:16 +01:00
rtq6056.c
rzg2l_adc.c
sc27xx_adc.c
sd_adc_modulator.c
spear_adc.c
stm32-adc-core.c iio: adc: stm32-adc: harden against NULL pointer deref in stm32_adc_probe() 2023-11-28 17:07:01 +00:00
stm32-adc-core.h
stm32-adc.c iio: adc: stm32: Fixing err code to not indicate success 2024-06-12 11:03:37 +02:00
stm32-dfsdm-adc.c
stm32-dfsdm-core.c
stm32-dfsdm.h
stmpe-adc.c
sun4i-gpadc-iio.c
ti_am335x_adc.c iio: adc: ti_am335x_adc: Fix return value check of tiadc_request_dma() 2024-01-01 12:39:01 +00:00
ti-adc081c.c
ti-adc084s021.c
ti-adc108s102.c
ti-adc128s052.c
ti-adc161s626.c
ti-adc0832.c
ti-adc12138.c
ti-ads124s08.c iio: adc: ti-ads124s08: Use gpiod_set_value_cansleep() 2025-01-17 13:34:46 +01:00
ti-ads131e08.c
ti-ads1015.c
ti-ads7950.c
ti-ads8344.c
ti-ads8688.c iio: adc: ti-ads8688: fix information leak in triggered buffer 2025-01-17 13:34:46 +01:00
ti-tlc4541.c
ti-tsc2046.c
twl4030-madc.c
twl6030-gpadc.c
vf610_adc.c
viperboard_adc.c
xilinx-ams.c iio: xilinx-ams: Don't include ams_ctrl_channels in scan_mask 2024-07-05 09:31:53 +02:00
xilinx-xadc-core.c iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale 2023-11-02 09:35:30 +01:00
xilinx-xadc-events.c
xilinx-xadc.h iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale 2023-11-02 09:35:30 +01:00