Skip to contentSkip to conversation

Input: cyttsp5 - Use dev_err_probe() to hide EPROBE_DEFER

PATCH Applied Andreas Kemnade 3 participants 3 messages Nov 19 – Nov 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: cyttsp5 - Use dev_err_probe() to hide EPROBE_DEFER

Use dev_error_probe() to avoid unnecessary noise if prerequisites are not ready like the regulators.

---
 drivers/input/touchscreen/cyttsp5.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)
drivers/input/touchscreen/cyttsp5.c +11 -22
index d4a78facfa815..82209bfdf828d 100644
@@ -844,20 +844,16 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
 	ts->supplies[1].supply = "vddio";
 	error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies),
 					ts->supplies);
-	if (error) {
-		dev_err(ts->dev, "Failed to get regulators, error %d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(ts->dev, error, "Failed to get regulators\n");
 
 	error = devm_add_action_or_reset(dev, cyttsp5_cleanup, ts);
 	if (error)
 		return error;
 
 	error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies);
-	if (error) {
-		dev_err(ts->dev, "Failed to enable regulators, error %d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(ts->dev, error, "Failed to enable regulators\n");
 
 	ts->input = devm_input_allocate_device(dev);
 	if (!ts->input) {
@@ -874,8 +870,7 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
 	ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(ts->reset_gpio)) {
 		error = PTR_ERR(ts->reset_gpio);
-		dev_err(dev, "Failed to request reset gpio, error %d\n", error);
-		return error;
+		return dev_err_probe(dev, error, "Failed to request reset gpio\n");
 	}
 
 	fsleep(10); /* Ensure long-enough reset pulse (minimum 10us). */
@@ -887,22 +882,16 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
 
 	error = devm_request_threaded_irq(dev, irq, NULL, cyttsp5_handle_irq,
 					  IRQF_ONESHOT, name, ts);
-	if (error) {
-		dev_err(dev, "unable to request IRQ\n");
-		return error;
-	}
+	if (error)
+		return dev_err_probe(dev, error, "unable to request IRQ\n");
 
 	error = cyttsp5_startup(ts);
-	if (error) {
-		dev_err(ts->dev, "Fail initial startup r=%d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(ts->dev, error, "Fail initial startup\n");
 
 	error = cyttsp5_parse_dt_key_code(dev);
-	if (error < 0) {
-		dev_err(ts->dev, "Error while parsing dts %d\n", error);
-		return error;
-	}
+	if (error < 0)
+		return dev_err_probe(ts->dev, error, "Error while parsing dts\n");
 
 	touchscreen_parse_properties(ts->input, true, &ts->prop);
 

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261119-cyt-errporbe-6b6278a09b3b

Best regards,

Signature · 1 line
Andreas Kemnade <[email protected]>
#1 lore raw
Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] Input: cyttsp5 - concurrent regmap…

Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce:
- [High] Input: cyttsp5 - concurrent regmap reads in cyttsp5_probe() [1] --

commit c1590d49f726ba5943ef8a369ba24293879c0745
Author: Andreas Kemnade <[email protected]>

Input: cyttsp5 - Use dev_err_probe() to hide EPROBE_DEFER

This commit replaces dev_err() calls in cyttsp5_probe() with dev_err_probe() to suppress error messages on deferred probe.

Quoted 4 lines
drivers/input/touchscreen/cyttsp5.c +0 -0
index d4a78facfa815..82209bfdf828d 100644

[ ... ]

Quoted 8 lines
drivers/input/touchscreen/cyttsp5.c +0 -4
@@ -887,22 +882,16 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
 
 	error = devm_request_threaded_irq(dev, irq, NULL, cyttsp5_handle_irq,
 					  IRQF_ONESHOT, name, ts);
-	if (error) {
-		dev_err(dev, "unable to request IRQ\n");
-		return error;
-	}

drivers/input/touchscreen/cyttsp5.c static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq, · line 890

Quoted 10 lines
drivers/input/touchscreen/cyttsp5.c +4 -4
+	if (error)
+		return dev_err_probe(dev, error, "unable to request IRQ\n");
 
 	error = cyttsp5_startup(ts);
-	if (error) {
-		dev_err(ts->dev, "Fail initial startup r=%d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(ts->dev, error, "Fail initial startup\n");

[Severity: High]
This problem wasn't introduced by this patch, but can cyttsp5_handle_irq() race with cyttsp5_startup() on HID_INPUT_REG reads [1]?

devm_request_threaded_irq() unmasks the interrupt before cyttsp5_startup() runs. If a pending event or touch triggers the IRQ immediately, both paths perform unserialized regmap_bulk_read() transfers against HID_INPUT_REG:

CPU0 CPU1
cyttsp5_probe()
devm_request_threaded_irq()
cyttsp5_handle_irq()
cyttsp5_read()
regmap_bulk_read() /* read size */
cyttsp5_startup()
cyttsp5_deassert_int()
regmap_bulk_read() <-- interleaves with two-step read
regmap_bulk_read() /* read data */

This corrupts the sequential HID report read protocol. In addition, if cyttsp5_deassert_int() reads a non-empty touch report (size > 2), it returns -EINVAL and aborts probe:

drivers/input/touchscreen/cyttsp5.c:cyttsp5_deassert_int() {
	...
	error = regmap_bulk_read(ts->regmap, HID_INPUT_REG, buf, sizeof(buf));
	if (error < 0)
		return error;

	size = get_unaligned_le16(&buf[0]);
	if (size == 2 || size == 0)
		return 0;

	return -EINVAL;
}

[1] https://sashiko.dev/#/bug/linux-bab102b6-93cb-4ea5-b362-6d8c8b8866ea

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1