summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-07 05:40:24 -0400
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-14 11:37:47 -0400
commitbd1f976cc95b0689f889c8d93434ee61dd09b08b (patch)
treed1e637e65c285746c720b35fe7cc6fc61a01b695 /drivers/media
parent17ce039b4e5405c49d8c0d64e6d781cc6f4dc1ac (diff)
[media] dib0700: be sure that dib0700_ctrl_rd() users can do DMA
dib0700_ctrl_rd() takes a RX and a TX pointer. Be sure that both will point to a memory allocated via kmalloc(). Reviewed-by: Patrick Boettcher <patrick.boettcher@posteo.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_core.c4
-rw-r--r--drivers/media/usb/dvb-usb/dib0700_devices.c25
2 files changed, 16 insertions, 13 deletions
diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
index f3196658fb70..515f89dba199 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -292,13 +292,15 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
292 292
293 /* special thing in the current firmware: when length is zero the read-failed */ 293 /* special thing in the current firmware: when length is zero the read-failed */
294 len = dib0700_ctrl_rd(d, st->buf, msg[i].len + 2, 294 len = dib0700_ctrl_rd(d, st->buf, msg[i].len + 2,
295 msg[i+1].buf, msg[i+1].len); 295 st->buf, msg[i + 1].len);
296 if (len <= 0) { 296 if (len <= 0) {
297 deb_info("I2C read failed on address 0x%02x\n", 297 deb_info("I2C read failed on address 0x%02x\n",
298 msg[i].addr); 298 msg[i].addr);
299 break; 299 break;
300 } 300 }
301 301
302 memcpy(msg[i + 1].buf, st->buf, msg[i + 1].len);
303
302 msg[i+1].len = len; 304 msg[i+1].len = len;
303 305
304 i++; 306 i++;
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 0857b56e652c..ef1b8ee75c57 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -508,8 +508,6 @@ static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap)
508 508
509#define DEFAULT_RC_INTERVAL 50 509#define DEFAULT_RC_INTERVAL 50
510 510
511static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
512
513/* 511/*
514 * This function is used only when firmware is < 1.20 version. Newer 512 * This function is used only when firmware is < 1.20 version. Newer
515 * firmwares use bulk mode, with functions implemented at dib0700_core, 513 * firmwares use bulk mode, with functions implemented at dib0700_core,
@@ -517,7 +515,6 @@ static u8 rc_request[] = { REQUEST_POLL_RC, 0 };
517 */ 515 */
518static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d) 516static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
519{ 517{
520 u8 key[4];
521 enum rc_type protocol; 518 enum rc_type protocol;
522 u32 scancode; 519 u32 scancode;
523 u8 toggle; 520 u8 toggle;
@@ -532,39 +529,43 @@ static int dib0700_rc_query_old_firmware(struct dvb_usb_device *d)
532 return 0; 529 return 0;
533 } 530 }
534 531
535 i = dib0700_ctrl_rd(d, rc_request, 2, key, 4); 532 st->buf[0] = REQUEST_POLL_RC;
533 st->buf[1] = 0;
534
535 i = dib0700_ctrl_rd(d, st->buf, 2, st->buf, 4);
536 if (i <= 0) { 536 if (i <= 0) {
537 err("RC Query Failed"); 537 err("RC Query Failed");
538 return -1; 538 return -EIO;
539 } 539 }
540 540
541 /* losing half of KEY_0 events from Philipps rc5 remotes.. */ 541 /* losing half of KEY_0 events from Philipps rc5 remotes.. */
542 if (key[0] == 0 && key[1] == 0 && key[2] == 0 && key[3] == 0) 542 if (st->buf[0] == 0 && st->buf[1] == 0
543 && st->buf[2] == 0 && st->buf[3] == 0)
543 return 0; 544 return 0;
544 545
545 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */ 546 /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)st->buf[3 - 2],(int)st->buf[3 - 3],(int)st->buf[3 - 1],(int)st->buf[3]); */
546 547
547 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */ 548 dib0700_rc_setup(d, NULL); /* reset ir sensor data to prevent false events */
548 549
549 switch (d->props.rc.core.protocol) { 550 switch (d->props.rc.core.protocol) {
550 case RC_BIT_NEC: 551 case RC_BIT_NEC:
551 /* NEC protocol sends repeat code as 0 0 0 FF */ 552 /* NEC protocol sends repeat code as 0 0 0 FF */
552 if ((key[3-2] == 0x00) && (key[3-3] == 0x00) && 553 if ((st->buf[3 - 2] == 0x00) && (st->buf[3 - 3] == 0x00) &&
553 (key[3] == 0xff)) { 554 (st->buf[3] == 0xff)) {
554 rc_repeat(d->rc_dev); 555 rc_repeat(d->rc_dev);
555 return 0; 556 return 0;
556 } 557 }
557 558
558 protocol = RC_TYPE_NEC; 559 protocol = RC_TYPE_NEC;
559 scancode = RC_SCANCODE_NEC(key[3-2], key[3-3]); 560 scancode = RC_SCANCODE_NEC(st->buf[3 - 2], st->buf[3 - 3]);
560 toggle = 0; 561 toggle = 0;
561 break; 562 break;
562 563
563 default: 564 default:
564 /* RC-5 protocol changes toggle bit on new keypress */ 565 /* RC-5 protocol changes toggle bit on new keypress */
565 protocol = RC_TYPE_RC5; 566 protocol = RC_TYPE_RC5;
566 scancode = RC_SCANCODE_RC5(key[3-2], key[3-3]); 567 scancode = RC_SCANCODE_RC5(st->buf[3 - 2], st->buf[3 - 3]);
567 toggle = key[3-1]; 568 toggle = st->buf[3 - 1];
568 break; 569 break;
569 } 570 }
570 571