media: rc: gpio-ir-tx: use ktime accessor functions
authorSean Young <sean@mess.org>
Fri, 25 Aug 2017 14:45:47 +0000 (10:45 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Thu, 31 Aug 2017 09:35:54 +0000 (05:35 -0400)
Prefer using accessor functions so we are not dependent on the ktime_t
type.

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

index 0b83408..cd476ca 100644 (file)
@@ -98,15 +98,17 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
                        // pulse
                        ktime_t last = ktime_add_us(edge, txbuf[i]);
 
-                       while (ktime_get() < last) {
+                       while (ktime_before(ktime_get(), last)) {
                                gpiod_set_value(gpio_ir->gpio, 1);
-                               edge += pulse;
-                               delta = edge - ktime_get();
+                               edge = ktime_add_ns(edge, pulse);
+                               delta = ktime_to_ns(ktime_sub(edge,
+                                                             ktime_get()));
                                if (delta > 0)
                                        ndelay(delta);
                                gpiod_set_value(gpio_ir->gpio, 0);
-                               edge += space;
-                               delta = edge - ktime_get();
+                               edge = ktime_add_ns(edge, space);
+                               delta = ktime_to_ns(ktime_sub(edge,
+                                                             ktime_get()));
                                if (delta > 0)
                                        ndelay(delta);
                        }