diff options
author | Frans Klaver <frans.klaver@xsens.com> | 2015-01-14 09:15:44 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2015-01-20 13:58:30 +0100 |
commit | c1ada2ff8045eacc11a3b894f2056aa5457b17b5 (patch) | |
tree | d1df53ba2ab5ba64db7d68e8c52ccb26c36eb740 /drivers/power/reset | |
parent | power: reset: ltc2952: disable timers in _remove (diff) | |
download | linux-c1ada2ff8045eacc11a3b894f2056aa5457b17b5.tar.xz linux-c1ada2ff8045eacc11a3b894f2056aa5457b17b5.zip |
power: reset: ltc2952: check trigger value before starting timer
In ltc2952_poweroff_handler it is theoretically possible that the timer
fails to start on first pass (button press), but succeeds in starting on
the second (button release). This will cause the button press to be
misinterpreted, and will incorrectly shut down the system. Because a
picture says more than a thousand words:
Expected behavior:
tmr: ++++++++++
btn: -----__________-----
Faulty behavior:
tmr: +++++
btn: -----__________-----
Legend:
+ timer runs
_ button pressed
- button depressed
To prevent this from happening, check the value of the gpio before
starting the timer. If the button is active, we should start the timer,
else we should stop it.
The situation described can now still occur if the polarity of the input
pin is set incorrectly, but that at least is predictable behavior and
can be detected during the first tests.
Signed-off-by: Frans Klaver <frans.klaver@xsens.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset')
-rw-r--r-- | drivers/power/reset/ltc2952-poweroff.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/reset/ltc2952-poweroff.c b/drivers/power/reset/ltc2952-poweroff.c index 240b294a0980..b99bc251f5b4 100644 --- a/drivers/power/reset/ltc2952-poweroff.c +++ b/drivers/power/reset/ltc2952-poweroff.c @@ -160,7 +160,7 @@ static irqreturn_t ltc2952_poweroff_handler(int irq, void *dev_id) return IRQ_HANDLED; } - if (!hrtimer_active(&data->timer_trigger)) { + if (gpiod_get_value(data->gpio_trigger)) { if (hrtimer_start(&data->timer_trigger, data->trigger_delay, HRTIMER_MODE_REL)) dev_err(data->dev, "unable to start the wait timer\n"); |