Skip to content

Commit 597cd63

Browse files
committed
gpio-fsm: Clamp the delay time to zero
The sysfs delay_ms value is calculated live, and it is possible for the time left to appear to be negative briefly if the timer handling hasn't completed. Ensure the displayed value never goes below zero, for the sake of appearances. Signed-off-by: Phil Elwell <[email protected]>
1 parent 6173e64 commit 597cd63

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpio-fsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ static ssize_t delay_ms_show(struct device *dev,
884884
const struct gpio_fsm *gf = dev_get_drvdata(dev);
885885
int jiffies_left;
886886

887-
jiffies_left = gf->delay_jiffies - jiffies;
887+
jiffies_left = max((int)(gf->delay_jiffies - jiffies), 0);
888888
return sprintf(buf,
889889
gf->delay_target_state ? "%u\n" : "-\n",
890890
jiffies_to_msecs(jiffies_left));

0 commit comments

Comments
 (0)