[media] lirc: make transmit interface consistent
authorSean Young <sean@mess.org>
Mon, 8 Jul 2013 20:33:09 +0000 (17:33 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 30 Jul 2013 20:04:23 +0000 (17:04 -0300)
All lirc drivers that can transmit, return EINVAL when they are passed
more than IR data than they can send. That is, except for two drivers
which I touched.

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

index 8d7eb6bf6312f4934c613912b7930d127c12956a..34cada2ca71038694f11faa3f1060fe641b12bd1 100644 (file)
@@ -46,7 +46,9 @@ describing an IR signal are read from the chardev.</para>
 values. Pulses and spaces are only marked implicitly by their position. The
 data must start and end with a pulse, therefore, the data must always include
 an uneven number of samples. The write function must block until the data has
-been transmitted by the hardware.</para>
+been transmitted by the hardware. If more data is provided than the hardware
+can send, the driver returns EINVAL.</para>
+
 </section>
 
 <section id="lirc_ioctl">
index a4ab2e6b3f82fcdba0364745e064be3970b3ba8b..19632b1c21908cb52e0c483f7a7339f647756e1e 100644 (file)
@@ -364,8 +364,8 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
                periods = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000);
                bytes = DIV_ROUND_UP(periods, 127);
                if (size + bytes > ir->bufsize) {
-                       count = i;
-                       break;
+                       rc = -EINVAL;
+                       goto out;
                }
                while (periods > 127) {
                        ir->packet->payload[size++] = 127 | space;
index 37494433dc9f9db950fd6a371cc21d80cc7cca28..0042367b060cc5b5cf578f1691ce43248a2a4747 100644 (file)
@@ -762,7 +762,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
                return -EAGAIN;
        }
 
-       count = min_t(unsigned, count, RR3_MAX_SIG_SIZE - RR3_TX_TRAILER_LEN);
+       if (count > RR3_MAX_SIG_SIZE - RR3_TX_TRAILER_LEN)
+               return -EINVAL;
 
        /* rr3 will disable rc detector on transmit */
        rr3->transmitting = true;
@@ -801,8 +802,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,
                                                &irdata->lens[curlencheck]);
                                curlencheck++;
                        } else {
-                               count = i - 1;
-                               break;
+                               ret = -EINVAL;
+                               goto out;
                        }
                }
                irdata->sigdata[i] = lencheck;