[PATCH 03/12] iio: adc: rohm-bd79124: Fix GPIO mask check

Matti Vaittinen <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <02b3f620fb3aca640dd2c7f53cc5af1e52e68149.1786347811.git.mazziesaccount@gmail.com>
From: Matti Vaittinen <[email protected]>

The ROHM BD79124 has pins which can be configured as GPOs or as ADC
inputs. The bd79124gpo_set_multiple() is intended to ensure that a pin
which is requested to be toggled, is indeed configured as a GPO.

The check uses XOR, causing it to fail if mask is not exactly same as
GPO configuration. Eg, if not all GPOs are asked to be toggled at once.

Fix this by checking that mask does not contain pins that are not
configured as GPO, allowing some of the pins which are configured as
GPO to be untouched.

Signed-off-by: Matti Vaittinen <[email protected]>
Fixes: 3f57a3b9ab74 ("iio: adc: Support ROHM BD79124 ADC")
---
 drivers/iio/adc/rohm-bd79124.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/rohm-bd79124.c b/drivers/iio/adc/rohm-bd79124.c
index 72207e0c60b8..84ac7fc94581 100644
--- a/drivers/iio/adc/rohm-bd79124.c
+++ b/drivers/iio/adc/rohm-bd79124.c
@@ -201,7 +201,7 @@ static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask,
 	if (ret)
 		return ret;
 
-	if (all_gpos ^ *mask) {
+	if (*mask & ~all_gpos) {
 		dev_dbg(data->dev, "Invalid mux config. Can't set value.\n");
 
 		return -EINVAL;
-- 
2.55.0
signature.asc (application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmp5gtkACgkQeFA3/03a
ocUeyQgAj6g9lTPmAOu4ZWcLodOYjGZxcWWJYAQaYp8phzUssUTH0XRlYvlB3A8C
erZAeYceU6bp3D7f/i6y9/TKwNaDMBtyFYv/8Fr2aLTuXRKpFmZ8zpDr8vUG1IqF
t7lFFi8GwBuAFdumSVYWj0weW0wNSAQuvj+GFYJylQMq8UaJ9hzQKJde0B3KjqyI
U14nU3T3rp1f1aT7qM97elzAGIYJBnLf/IVAPnOEl10hF/On18LLl5lg2ZlHqjbc
n2vQ2BjlTOCNEvb/3V3OO0ccydb31BACSEq9SLQqg5ddv4GFGk6HYxTerbUV3Pj0
TeHqeZfNimb7mnpo8KYggLEh8Yzmdw==
=A5gw
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.