Skip to contentSkip to conversation

Input: tsc2007 - Read "ti,poll-period" as u32

PATCH Superseded Rob Herring (Arm) 2 participants 3 messages Jun 12 – Aug 17

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

PATCH 1/1 Input: tsc2007 - Read "ti,poll-period" as u32

The "ti,poll-period" property is documented as a normal uint32 cell. The driver used a u64 helper, which makes the helper type disagree with the schema even though the stored value is still small.

Read "ti,poll-period" with the u32 helper matching the documented DT cell size.

Assisted-by Codex:gpt-5-5
---
 drivers/input/touchscreen/tsc2007_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/input/touchscreen/tsc2007_core.c +2 -3
index 524f14eb3da2..db18b712999d 100644
@@ -224,7 +224,6 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)
 static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
 {
 	u32 val32;
-	u64 val64;
 
 	if (!device_property_read_u32(dev, "ti,max-rt", &val32))
 		ts->max_rt = val32;
@@ -240,8 +239,8 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
 	if (!device_property_read_u32(dev, "ti,fuzzz", &val32))
 		ts->fuzzz = val32;
 
-	if (!device_property_read_u64(dev, "ti,poll-period", &val64))
-		ts->poll_period = msecs_to_jiffies(val64);
+	if (!device_property_read_u32(dev, "ti,poll-period", &val32))
+		ts->poll_period = msecs_to_jiffies(val32);
 	else
 		ts->poll_period = msecs_to_jiffies(1);
 
Signature · 1 line
2.53.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] A 'ti,poll-period' value of 0 causes an infinite polling loop in tsc2007_soft_irq(). --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] A 'ti,poll-period' value of 0 causes an infinite polling loop in tsc2007_soft_irq(). --

commit dfcc8705b785de318165f57112a4d5c957e4ec74
Author: Rob Herring (Arm) <[email protected]>

Input: tsc2007 - Read "ti,poll-period" as u32

The "ti,poll-period" property is documented as a normal uint32 cell. The driver used a u64 helper, which makes the helper type disagree with the schema even though the stored value is still small.

Read "ti,poll-period" with the u32 helper matching the documented DT cell size.

Quoted 3 lines
drivers/input/touchscreen/tsc2007_core.c +0 -0

[ ... ]

drivers/input/touchscreen/tsc2007_core.c static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) · line 241

Quoted 8 lines
drivers/input/touchscreen/tsc2007_core.c +2 -2
@@ -238,8 +237,8 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
 	if (!device_property_read_u32(dev, "ti,fuzzz", &val32))
 		ts->fuzzz = val32;
 
-	if (!device_property_read_u64(dev, "ti,poll-period", &val64))
-		ts->poll_period = msecs_to_jiffies(val64);
+	if (!device_property_read_u32(dev, "ti,poll-period", &val32))
+		ts->poll_period = msecs_to_jiffies(val32);

[Severity: High]
Does this change unintentionally allow ts->poll_period to become 0, leading to an infinite loop in tsc2007_soft_irq()?

Previously, if a 32-bit zero value was provided in the device tree, device_property_read_u64() would fail due to a length mismatch, triggering the fallback to a safe 1 jiffy (ts->poll_period = msecs_to_jiffies(1)).

With this fix, a 32-bit zero is successfully parsed, setting ts->poll_period = 0.

If ts->poll_period is 0, wait_event_timeout(ts->wait, ts->stopped, ts->poll_period) in tsc2007_soft_irq() evaluates the timeout as 0 and returns immediately without sleeping. This results in the thread spinning in a tight loop as long as the touchscreen is pressed.

Should we sanitize a 0 value here so it defaults to 1?

Quoted 3 lines
drivers/input/touchscreen/tsc2007_core.c +0 -0
 	else
 		ts->poll_period = msecs_to_jiffies(1);
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Rob Herring (Arm)
Quoted 5 lines · Rob Herring (Arm)

The "ti,poll-period" property is documented as a normal uint32 cell. The driver used a u64 helper, which makes the helper type disagree with the schema even though the stored value is still small.

Quoted 8 lines

Read "ti,poll-period" with the u32 helper matching the documented DT cell size.

Assisted-by Codex:gpt-5-5
---
 drivers/input/touchscreen/tsc2007_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Ping

Quoted 26 lines
drivers/input/touchscreen/tsc2007_core.c +2 -4
index 524f14eb3da2..db18b712999d 100644
@@ -224,7 +224,6 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev)
 static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
 {
        u32 val32;
-       u64 val64;
 
        if (!device_property_read_u32(dev, "ti,max-rt", &val32))
                ts->max_rt = val32;
@@ -240,8 +239,8 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts)
        if (!device_property_read_u32(dev, "ti,fuzzz", &val32))
                ts->fuzzz = val32;
 
-       if (!device_property_read_u64(dev, "ti,poll-period", &val64))
-               ts->poll_period = msecs_to_jiffies(val64);
+       if (!device_property_read_u32(dev, "ti,poll-period", &val32))
+               ts->poll_period = msecs_to_jiffies(val32);
        else
                ts->poll_period = msecs_to_jiffies(1);
 
--

2.53.0