[media] iguanair: simplify tx loop
authorSean Young <sean@mess.org>
Mon, 20 Jan 2014 22:10:39 +0000 (19:10 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 4 Feb 2014 19:23:06 +0000 (17:23 -0200)
Make the code simpler.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/rc/iguanair.c

index 99a3a5a509e6a00839c22490c7349643f238e31d..a83519a6a158d769b370a62642d6fda23abc413c 100644 (file)
@@ -364,20 +364,14 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
                        rc = -EINVAL;
                        goto out;
                }
-               while (periods > 127) {
-                       ir->packet->payload[size++] = 127 | space;
-                       periods -= 127;
+               while (periods) {
+                       unsigned p = min(periods, 127u);
+                       ir->packet->payload[size++] = p | space;
+                       periods -= p;
                }
-
-               ir->packet->payload[size++] = periods | space;
                space ^= 0x80;
        }
 
-       if (count == 0) {
-               rc = -EINVAL;
-               goto out;
-       }
-
        ir->packet->header.start = 0;
        ir->packet->header.direction = DIR_OUT;
        ir->packet->header.cmd = CMD_SEND;