summaryrefslogtreecommitdiff
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2017-12-11 17:21:28 -0500
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-18 15:20:53 -0500
commitb996157dd2b9de57a61a6abbe4ab2d63e1d10908 (patch)
tree7c9896ba0562a30290af417ce6b377fe52c2524f /drivers/media/rc
parentdde7edff359461d07074ef2f0c4dc85b775d493f (diff)
media: rc: iguanair: simplify tx loop
The TX loop is more complex than it should. Simplify it. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/iguanair.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 30e24da67226..7daac8bab83b 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -347,26 +347,23 @@ static int iguanair_set_tx_mask(struct rc_dev *dev, uint32_t mask)
static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
{
struct iguanair *ir = dev->priv;
- uint8_t space;
- unsigned i, size, periods, bytes;
+ unsigned int i, size, p, periods;
int rc;
mutex_lock(&ir->lock);
/* convert from us to carrier periods */
- for (i = space = size = 0; i < count; i++) {
+ for (i = size = 0; i < count; i++) {
periods = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000);
- bytes = DIV_ROUND_UP(periods, 127);
- if (size + bytes > ir->bufsize) {
- rc = -EINVAL;
- goto out;
- }
while (periods) {
- unsigned p = min(periods, 127u);
- ir->packet->payload[size++] = p | space;
+ p = min(periods, 127u);
+ if (size >= ir->bufsize) {
+ rc = -EINVAL;
+ goto out;
+ }
+ ir->packet->payload[size++] = p | ((i & 1) ? 0x80 : 0);
periods -= p;
}
- space ^= 0x80;
}
ir->packet->header.start = 0;