]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
staging: iio: adc: ad7816: Correct conditional logic for store mode
authorGabriel Shahrouzi <gshahrouzi@gmail.com>
Mon, 14 Apr 2025 15:40:49 +0000 (11:40 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 18 May 2025 06:20:36 +0000 (08:20 +0200)
commit2cb6a49a46f05076a6740c96bdf5596f77eab531
treead35594f42c10481ab8cecafbebeb6a451059d12
parent40c8117be683488585866d94266cccf1cc0fe3a1
staging: iio: adc: ad7816: Correct conditional logic for store mode

commit 2e922956277187655ed9bedf7b5c28906e51708f upstream.

The mode setting logic in ad7816_store_mode was reversed due to
incorrect handling of the strcmp return value. strcmp returns 0 on
match, so the `if (strcmp(buf, "full"))` block executed when the
input was not "full".

This resulted in "full" setting the mode to AD7816_PD (power-down) and
other inputs setting it to AD7816_FULL.

Fix this by checking it against 0 to correctly check for "full" and
"power-down", mapping them to AD7816_FULL and AD7816_PD respectively.

Fixes: 7924425db04a ("staging: iio: adc: new driver for AD7816 devices")
Cc: stable@vger.kernel.org
Signed-off-by: Gabriel Shahrouzi <gshahrouzi@gmail.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/stable/20250414152920.467505-1-gshahrouzi%40gmail.com
Link: https://patch.msgid.link/20250414154050.469482-1-gshahrouzi@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/adc/ad7816.c