media: gpio-ir-tx: improve precision of transmitted signal due to scheduling
authorSean Young <sean@mess.org>
Sat, 2 May 2020 12:50:52 +0000 (14:50 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 12 May 2020 15:29:11 +0000 (17:29 +0200)
usleep_range() may take longer than the max argument due to scheduling,
especially under load. This is causing random errors in the transmitted
IR. Remove the usleep_range() in favour of busy-looping with udelay().

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/rc/gpio-ir-tx.c

index 18ca12d..6670398 100644 (file)
@@ -79,13 +79,8 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
                        // space
                        edge = ktime_add_us(edge, txbuf[i]);
                        delta = ktime_us_delta(edge, ktime_get());
-                       if (delta > 10) {
-                               spin_unlock_irqrestore(&gpio_ir->lock, flags);
-                               usleep_range(delta, delta + 10);
-                               spin_lock_irqsave(&gpio_ir->lock, flags);
-                       } else if (delta > 0) {
+                       if (delta > 0)
                                udelay(delta);
-                       }
                } else {
                        // pulse
                        ktime_t last = ktime_add_us(edge, txbuf[i]);