aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSean Young <sean@mess.org>2012-08-13 07:59:42 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-13 15:07:00 -0400
commit884bfd08e3d4f694574e54bd1886cd8817d9b986 (patch)
treeacdd64dc9a7e21516da5eb292fcedb04fd50c527 /drivers
parent7c0bd96b767da250e5aa5ee135c530d87454d9fe (diff)
[media] iguanair: fix return value for transmit
Also fix error codes returned from open. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/rc/iguanair.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index f1c5846b35f4..68172585c961 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -327,7 +327,7 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
327{ 327{
328 struct iguanair *ir = dev->priv; 328 struct iguanair *ir = dev->priv;
329 uint8_t space, *payload; 329 uint8_t space, *payload;
330 unsigned i, size, rc; 330 unsigned i, size, rc, bytes;
331 struct send_packet *packet; 331 struct send_packet *packet;
332 332
333 mutex_lock(&ir->lock); 333 mutex_lock(&ir->lock);
@@ -335,17 +335,22 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
335 /* convert from us to carrier periods */ 335 /* convert from us to carrier periods */
336 for (i = size = 0; i < count; i++) { 336 for (i = size = 0; i < count; i++) {
337 txbuf[i] = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000); 337 txbuf[i] = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000);
338 size += (txbuf[i] + 126) / 127; 338 bytes = (txbuf[i] + 126) / 127;
339 if (size + bytes > ir->bufsize) {
340 count = i;
341 break;
342 }
343 size += bytes;
339 } 344 }
340 345
341 packet = kmalloc(sizeof(*packet) + size, GFP_KERNEL); 346 if (count == 0) {
342 if (!packet) { 347 rc = -EINVAL;
343 rc = -ENOMEM;
344 goto out; 348 goto out;
345 } 349 }
346 350
347 if (size > ir->bufsize) { 351 packet = kmalloc(sizeof(*packet) + size, GFP_KERNEL);
348 rc = -E2BIG; 352 if (!packet) {
353 rc = -ENOMEM;
349 goto out; 354 goto out;
350 } 355 }
351 356
@@ -376,7 +381,7 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
376 rc = iguanair_receiver(ir, false); 381 rc = iguanair_receiver(ir, false);
377 if (rc) { 382 if (rc) {
378 dev_warn(ir->dev, "disable receiver before transmit failed\n"); 383 dev_warn(ir->dev, "disable receiver before transmit failed\n");
379 goto out; 384 goto out_kfree;
380 } 385 }
381 } 386 }
382 387
@@ -392,11 +397,12 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
392 dev_warn(ir->dev, "re-enable receiver after transmit failed\n"); 397 dev_warn(ir->dev, "re-enable receiver after transmit failed\n");
393 } 398 }
394 399
400out_kfree:
401 kfree(packet);
395out: 402out:
396 mutex_unlock(&ir->lock); 403 mutex_unlock(&ir->lock);
397 kfree(packet);
398 404
399 return rc; 405 return rc ? rc : count;
400} 406}
401 407
402static int iguanair_open(struct rc_dev *rdev) 408static int iguanair_open(struct rc_dev *rdev)
@@ -444,7 +450,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf,
444 ir = kzalloc(sizeof(*ir), GFP_KERNEL); 450 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
445 rc = rc_allocate_device(); 451 rc = rc_allocate_device();
446 if (!ir || !rc) { 452 if (!ir || !rc) {
447 ret = ENOMEM; 453 ret = -ENOMEM;
448 goto out; 454 goto out;
449 } 455 }
450 456
@@ -453,7 +459,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf,
453 ir->urb_in = usb_alloc_urb(0, GFP_KERNEL); 459 ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
454 460
455 if (!ir->buf_in || !ir->urb_in) { 461 if (!ir->buf_in || !ir->urb_in) {
456 ret = ENOMEM; 462 ret = -ENOMEM;
457 goto out; 463 goto out;
458 } 464 }
459 465