Skip to contentSkip to conversation

touchscreen/88pm860x-ts: check the pm860x_set_bits return value

PATCH In review Li Zhong 2 participants 2 messages Sep 21, 2022

Subsystems (2)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 touchscreen/88pm860x-ts: check the pm860x_set_bits return value

pm860x_touch_close() got the return value of pm860x_set_bits() but didn't check it. However, pm860x_set_bits() could fail when writing the reg map fails. Since pm860x_touch_close() cannot return an error value, we retry the bit setting in the error handling.

---
 drivers/input/touchscreen/88pm860x-ts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/touchscreen/88pm860x-ts.c +4 -1
index 81a3ea4b9a3d..043520d1ff26 100644
@@ -106,10 +106,13 @@ static void pm860x_touch_close(struct input_dev *dev)
 {
 	struct pm860x_touch *touch = input_get_drvdata(dev);
 	int data;
+	int ret;
 
 	data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN
 		| MEAS_TSIZ1_EN | MEAS_TSIZ2_EN;
-	pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
+	ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
+	if (ret < 0)
+		pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Hi,

Quoted 3 lines · Li Zhong

pm860x_touch_close() got the return value of pm860x_set_bits() but didn't check it. However, pm860x_set_bits() could fail when writing the reg map fails.

Under what conditions would the write fail?

Quoted 2 lines

Since pm860x_touch_close() cannot return an error value, we retry the bit setting in the error handling.

What guarantees that the repeated write will not fail again? What is the failure mode if write does not succeed?

Quoted 28 lines
---
 drivers/input/touchscreen/88pm860x-ts.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/touchscreen/88pm860x-ts.c +4 -1
index 81a3ea4b9a3d..043520d1ff26 100644
@@ -106,10 +106,13 @@ static void pm860x_touch_close(struct input_dev *dev)
 {
 	struct pm860x_touch *touch = input_get_drvdata(dev);
 	int data;
+	int ret;
 
 	data = MEAS_PD_EN | MEAS_TSIX_EN | MEAS_TSIY_EN
 		| MEAS_TSIZ1_EN | MEAS_TSIZ2_EN;
-	pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
+	ret = pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
+	if (ret < 0)
+		pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0);
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.25.1

Thanks.

Signature · 1 line
Dmitry