]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iio: adc: ad7124: fix config comparison
authorDumitru Ceclan <mitrutzceclan@gmail.com>
Wed, 31 Jul 2024 12:37:23 +0000 (15:37 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 3 Aug 2024 15:02:55 +0000 (16:02 +0100)
commit2f6b92d0f69f04d9e2ea0db1228ab7f82f3173af
tree3c7ffc9b02183938b535865f2988cb8be8324a36
parent96f9ab0d5933c1c00142dd052f259fce0bc3ced2
iio: adc: ad7124: fix config comparison

The ad7124_find_similar_live_cfg() computes the compare size by
substracting the address of the cfg struct from the address of the live
field. Because the live field is the first field in the struct, the
result is 0.

Also, the memcmp() call is made from the start of the cfg struct, which
includes the live and cfg_slot fields, which are not relevant for the
comparison.

Fix by grouping the relevant fields with struct_group() and use the
size of the group to compute the compare size; make the memcmp() call
from the address of the group.

Fixes: 7b8d045e497a ("iio: adc: ad7124: allow more than 8 channels")
Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240731-ad7124-fix-v1-2-46a76aa4b9be@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7124.c