Commit 06b83158 authored by Matthias Reichl's avatar Matthias Reichl Committed by Mauro Carvalho Chehab

media: rc: fix timeout handling after switch to microsecond durations

Commit 528222d8 ("media: rc: harmonize infrared durations to
microseconds") missed to switch some timeout calculations from
nanoseconds to microseconds. This resulted in spurious key_up+key_down
events at the last scancode if the rc device uses a long timeout
(eg 100ms on nuvoton-cir) as the device timeout wasn't properly
accounted for in the keyup timeout calculation.

Fix this by applying the proper conversion functions.

Cc: stable@vger.kernel.org
Fixes: 528222d8 ("media: rc: harmonize infrared durations to microseconds")
Signed-off-by: default avatarMatthias Reichl <hias@horus.com>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 2984a99f
...@@ -320,7 +320,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev) ...@@ -320,7 +320,7 @@ static int ir_mce_kbd_decode(struct rc_dev *dev, struct ir_raw_event ev)
data->body); data->body);
spin_lock(&data->keylock); spin_lock(&data->keylock);
if (scancode) { if (scancode) {
delay = nsecs_to_jiffies(dev->timeout) + delay = usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(100); msecs_to_jiffies(100);
mod_timer(&data->rx_timeout, jiffies + delay); mod_timer(&data->rx_timeout, jiffies + delay);
} else { } else {
......
...@@ -737,7 +737,7 @@ static unsigned int repeat_period(int protocol) ...@@ -737,7 +737,7 @@ static unsigned int repeat_period(int protocol)
void rc_repeat(struct rc_dev *dev) void rc_repeat(struct rc_dev *dev)
{ {
unsigned long flags; unsigned long flags;
unsigned int timeout = nsecs_to_jiffies(dev->timeout) + unsigned int timeout = usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(repeat_period(dev->last_protocol)); msecs_to_jiffies(repeat_period(dev->last_protocol));
struct lirc_scancode sc = { struct lirc_scancode sc = {
.scancode = dev->last_scancode, .rc_proto = dev->last_protocol, .scancode = dev->last_scancode, .rc_proto = dev->last_protocol,
...@@ -855,7 +855,7 @@ void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u64 scancode, ...@@ -855,7 +855,7 @@ void rc_keydown(struct rc_dev *dev, enum rc_proto protocol, u64 scancode,
ir_do_keydown(dev, protocol, scancode, keycode, toggle); ir_do_keydown(dev, protocol, scancode, keycode, toggle);
if (dev->keypressed) { if (dev->keypressed) {
dev->keyup_jiffies = jiffies + nsecs_to_jiffies(dev->timeout) + dev->keyup_jiffies = jiffies + usecs_to_jiffies(dev->timeout) +
msecs_to_jiffies(repeat_period(protocol)); msecs_to_jiffies(repeat_period(protocol));
mod_timer(&dev->timer_keyup, dev->keyup_jiffies); mod_timer(&dev->timer_keyup, dev->keyup_jiffies);
} }
......
...@@ -385,7 +385,7 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah) ...@@ -385,7 +385,7 @@ static irqreturn_t serial_ir_irq_handler(int i, void *blah)
} while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */ } while (!(sinp(UART_IIR) & UART_IIR_NO_INT)); /* still pending ? */
mod_timer(&serial_ir.timeout_timer, mod_timer(&serial_ir.timeout_timer,
jiffies + nsecs_to_jiffies(serial_ir.rcdev->timeout)); jiffies + usecs_to_jiffies(serial_ir.rcdev->timeout));
ir_raw_event_handle(serial_ir.rcdev); ir_raw_event_handle(serial_ir.rcdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment