Skip to contentSkip to conversation

leds: ledtrig-transient: fix duration to be msec instead of jiffies

PATCH Applied Rob Herring 2 participants 2 messages Nov 10, 2015 – Nov 16, 2015 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: ledtrig-transient: fix duration to be msec instead of jiffies

The transient trigger duration is documented to be in msec units, but is actually in jiffies units. Other time based triggers are in msec units as well. Fix the timer setup to convert from msec.

This could break an existing userspace that worked around this problem, but exposing jiffies to userspace is just wrong and would break anyway if HZ is changed.

Cc Shuah Khan <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Jacek Anaszewski <[email protected]>
---
 drivers/leds/trigger/ledtrig-transient.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/trigger/ledtrig-transient.c +1 -1
index 3c34de4..60034bf 100644
@@ -85,7 +85,7 @@ static ssize_t transient_activate_store(struct device *dev,
 		transient_data->restore_state =
 		    (transient_data->state == LED_FULL) ? LED_OFF : LED_FULL;
 		mod_timer(&transient_data->timer,
-			  jiffies + transient_data->duration);
+			  jiffies + msecs_to_jiffies(transient_data->duration));
 	}
 
 	/* state == 0 && transient_data->activate == 0
Signature · 1 line
2.5.0
#1 lore raw

Hi Rob,

Quoted 23 lines · Rob Herring

The transient trigger duration is documented to be in msec units, but is actually in jiffies units. Other time based triggers are in msec units as well. Fix the timer setup to convert from msec.

This could break an existing userspace that worked around this problem, but exposing jiffies to userspace is just wrong and would break anyway if HZ is changed.

Cc Shuah Khan <[email protected]>
Cc Richard Purdie <[email protected]>
Cc Jacek Anaszewski <[email protected]>
---
  drivers/leds/trigger/ledtrig-transient.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/trigger/ledtrig-transient.c +0 -0
index 3c34de4..60034bf 100644

drivers/leds/trigger/ledtrig-transient.c static ssize_t transient_activate_store(struct device *dev, · line 91

Quoted 8 lines
drivers/leds/trigger/ledtrig-transient.c +1 -1
@@ -85,7 +85,7 @@ static ssize_t transient_activate_store(struct device *dev,
  		transient_data->restore_state =
  		    (transient_data->state == LED_FULL) ? LED_OFF : LED_FULL;
  		mod_timer(&transient_data->timer,
-			  jiffies + transient_data->duration);
+			  jiffies + msecs_to_jiffies(transient_data->duration));
  	}
 
  	/* state == 0 && transient_data->activate == 0

Applied, thanks.

Signature · 2 lines
Best Regards,
Jacek Anaszewski