Skip to content

Commit b996157

Browse files
seanyoungmchehab
authored andcommitted
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>
1 parent dde7edf commit b996157

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

‎drivers/media/rc/iguanair.c‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -347,26 +347,23 @@ static int iguanair_set_tx_mask(struct rc_dev *dev, uint32_t mask)
347347
static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
348348
{
349349
struct iguanair *ir = dev->priv;
350-
uint8_t space;
351-
unsigned i, size, periods, bytes;
350+
unsigned int i, size, p, periods;
352351
int rc;
353352

354353
mutex_lock(&ir->lock);
355354

356355
/* convert from us to carrier periods */
357-
for (i = space = size = 0; i < count; i++) {
356+
for (i = size = 0; i < count; i++) {
358357
periods = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000);
359-
bytes = DIV_ROUND_UP(periods, 127);
360-
if (size + bytes > ir->bufsize) {
361-
rc = -EINVAL;
362-
goto out;
363-
}
364358
while (periods) {
365-
unsigned p = min(periods, 127u);
366-
ir->packet->payload[size++] = p | space;
359+
p = min(periods, 127u);
360+
if (size >= ir->bufsize) {
361+
rc = -EINVAL;
362+
goto out;
363+
}
364+
ir->packet->payload[size++] = p | ((i & 1) ? 0x80 : 0);
367365
periods -= p;
368366
}
369-
space ^= 0x80;
370367
}
371368

372369
ir->packet->header.start = 0;

0 commit comments

Comments
 (0)