hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/media/rc/mceusb.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for USB Windows Media Center Ed. eHome Infrared Transceivers
34 *
....@@ -19,18 +20,6 @@
1920 * remote/transceiver requirements and specification document, found at
2021 * download.microsoft.com, title
2122 * Windows-Media-Center-RC-IR-Collection-Green-Button-Specification-03-08-2011-V2.pdf
22
- *
23
- *
24
- * This program is free software; you can redistribute it and/or modify
25
- * it under the terms of the GNU General Public License as published by
26
- * the Free Software Foundation; either version 2 of the License, or
27
- * (at your option) any later version.
28
- *
29
- * This program is distributed in the hope that it will be useful,
30
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
- * GNU General Public License for more details.
33
- *
3423 */
3524
3625 #include <linux/device.h>
....@@ -80,7 +69,7 @@
8069 #define MCE_CMD 0x1f
8170 #define MCE_PORT_IR 0x4 /* (0x4 << 5) | MCE_CMD = 0x9f */
8271 #define MCE_PORT_SYS 0x7 /* (0x7 << 5) | MCE_CMD = 0xff */
83
-#define MCE_PORT_SER 0x6 /* 0xc0 thru 0xdf flush & 0x1f bytes */
72
+#define MCE_PORT_SER 0x6 /* 0xc0 through 0xdf flush & 0x1f bytes */
8473 #define MCE_PORT_MASK 0xe0 /* Mask out command bits */
8574
8675 /* Command port headers */
....@@ -433,6 +422,15 @@
433422 .driver_info = HAUPPAUGE_CX_HYBRID_TV },
434423 { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb139),
435424 .driver_info = HAUPPAUGE_CX_HYBRID_TV },
425
+ /* Hauppauge WinTV-HVR-935C - based on cx231xx */
426
+ { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb151),
427
+ .driver_info = HAUPPAUGE_CX_HYBRID_TV },
428
+ /* Hauppauge WinTV-HVR-955Q - based on cx231xx */
429
+ { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb123),
430
+ .driver_info = HAUPPAUGE_CX_HYBRID_TV },
431
+ /* Hauppauge WinTV-HVR-975 - based on cx231xx */
432
+ { USB_DEVICE(VENDOR_HAUPPAUGE, 0xb150),
433
+ .driver_info = HAUPPAUGE_CX_HYBRID_TV },
436434 { USB_DEVICE(VENDOR_PCTV, 0x0259),
437435 .driver_info = HAUPPAUGE_CX_HYBRID_TV },
438436 { USB_DEVICE(VENDOR_PCTV, 0x025e),
....@@ -464,6 +462,7 @@
464462
465463 /* usb */
466464 struct usb_device *usbdev;
465
+ struct usb_interface *usbintf;
467466 struct urb *urb_in;
468467 unsigned int pipe_in;
469468 struct usb_endpoint_descriptor *usb_ep_out;
....@@ -520,6 +519,7 @@
520519 unsigned long kevent_flags;
521520 # define EVENT_TX_HALT 0
522521 # define EVENT_RX_HALT 1
522
+# define EVENT_RST_PEND 31
523523 };
524524
525525 /* MCE Device Command Strings, generally a port and command pair */
....@@ -564,7 +564,7 @@
564564 datasize = 4;
565565 break;
566566 case MCE_CMD_G_REVISION:
567
- datasize = 2;
567
+ datasize = 4;
568568 break;
569569 case MCE_RSP_EQWAKESUPPORT:
570570 case MCE_RSP_GETWAKESOURCE:
....@@ -600,14 +600,9 @@
600600 char *inout;
601601 u8 cmd, subcmd, *data;
602602 struct device *dev = ir->dev;
603
- int start, skip = 0;
604603 u32 carrier, period;
605604
606
- /* skip meaningless 0xb1 0x60 header bytes on orig receiver */
607
- if (ir->flags.microsoft_gen1 && !out && !offset)
608
- skip = 2;
609
-
610
- if (len <= skip)
605
+ if (offset < 0 || offset >= buf_len)
611606 return;
612607
613608 dev_dbg(dev, "%cx data[%d]: %*ph (len=%d sz=%d)",
....@@ -616,11 +611,32 @@
616611
617612 inout = out ? "Request" : "Got";
618613
619
- start = offset + skip;
620
- cmd = buf[start] & 0xff;
621
- subcmd = buf[start + 1] & 0xff;
622
- data = buf + start + 2;
614
+ cmd = buf[offset];
615
+ subcmd = (offset + 1 < buf_len) ? buf[offset + 1] : 0;
616
+ data = &buf[offset] + 2;
623617
618
+ /* Trace meaningless 0xb1 0x60 header bytes on original receiver */
619
+ if (ir->flags.microsoft_gen1 && !out && !offset) {
620
+ dev_dbg(dev, "MCE gen 1 header");
621
+ return;
622
+ }
623
+
624
+ /* Trace IR data header or trailer */
625
+ if (cmd != MCE_CMD_PORT_IR &&
626
+ (cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA) {
627
+ if (cmd == MCE_IRDATA_TRAILER)
628
+ dev_dbg(dev, "End of raw IR data");
629
+ else
630
+ dev_dbg(dev, "Raw IR data, %d pulse/space samples",
631
+ cmd & MCE_PACKET_LENGTH_MASK);
632
+ return;
633
+ }
634
+
635
+ /* Unexpected end of buffer? */
636
+ if (offset + len > buf_len)
637
+ return;
638
+
639
+ /* Decode MCE command/response */
624640 switch (cmd) {
625641 case MCE_CMD_NULL:
626642 if (subcmd == MCE_CMD_NULL)
....@@ -644,7 +660,7 @@
644660 dev_dbg(dev, "Get hw/sw rev?");
645661 else
646662 dev_dbg(dev, "hw/sw rev %*ph",
647
- 4, &buf[start + 2]);
663
+ 4, &buf[offset + 2]);
648664 break;
649665 case MCE_CMD_RESUME:
650666 dev_dbg(dev, "Device resume requested");
....@@ -753,13 +769,6 @@
753769 default:
754770 break;
755771 }
756
-
757
- if (cmd == MCE_IRDATA_TRAILER)
758
- dev_dbg(dev, "End of raw IR data");
759
- else if ((cmd != MCE_CMD_PORT_IR) &&
760
- ((cmd & MCE_PORT_MASK) == MCE_COMMAND_IRDATA))
761
- dev_dbg(dev, "Raw IR data, %d pulse/space samples",
762
- cmd & MCE_PACKET_LENGTH_MASK);
763772 #endif
764773 }
765774
....@@ -772,8 +781,15 @@
772781 static void mceusb_defer_kevent(struct mceusb_dev *ir, int kevent)
773782 {
774783 set_bit(kevent, &ir->kevent_flags);
784
+
785
+ if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) {
786
+ dev_dbg(ir->dev, "kevent %d dropped pending USB Reset Device",
787
+ kevent);
788
+ return;
789
+ }
790
+
775791 if (!schedule_work(&ir->kevent))
776
- dev_err(ir->dev, "kevent %d may have been dropped", kevent);
792
+ dev_dbg(ir->dev, "kevent %d already scheduled", kevent);
777793 else
778794 dev_dbg(ir->dev, "kevent %d scheduled", kevent);
779795 }
....@@ -1061,7 +1077,7 @@
10611077 struct mceusb_dev *ir = dev->priv;
10621078 unsigned int units;
10631079
1064
- units = DIV_ROUND_CLOSEST(timeout, US_TO_NS(MCE_TIME_UNIT));
1080
+ units = DIV_ROUND_UP(timeout, MCE_TIME_UNIT);
10651081
10661082 cmdbuf[2] = units >> 8;
10671083 cmdbuf[3] = units;
....@@ -1136,32 +1152,62 @@
11361152 }
11371153
11381154 /*
1155
+ * Handle PORT_SYS/IR command response received from the MCE device.
1156
+ *
1157
+ * Assumes single response with all its data (not truncated)
1158
+ * in buf_in[]. The response itself determines its total length
1159
+ * (mceusb_cmd_datasize() + 2) and hence the minimum size of buf_in[].
1160
+ *
11391161 * We don't do anything but print debug spew for many of the command bits
11401162 * we receive from the hardware, but some of them are useful information
11411163 * we want to store so that we can use them.
11421164 */
1143
-static void mceusb_handle_command(struct mceusb_dev *ir, int index)
1165
+static void mceusb_handle_command(struct mceusb_dev *ir, u8 *buf_in)
11441166 {
1145
- DEFINE_IR_RAW_EVENT(rawir);
1146
- u8 hi = ir->buf_in[index + 1] & 0xff;
1147
- u8 lo = ir->buf_in[index + 2] & 0xff;
1167
+ u8 cmd = buf_in[0];
1168
+ u8 subcmd = buf_in[1];
1169
+ u8 *hi = &buf_in[2]; /* read only when required */
1170
+ u8 *lo = &buf_in[3]; /* read only when required */
1171
+ struct ir_raw_event rawir = {};
11481172 u32 carrier_cycles;
11491173 u32 cycles_fix;
11501174
1151
- switch (ir->buf_in[index]) {
1152
- /* the one and only 5-byte return value command */
1153
- case MCE_RSP_GETPORTSTATUS:
1154
- if ((ir->buf_in[index + 4] & 0xff) == 0x00)
1155
- ir->txports_cabled |= 1 << hi;
1156
- break;
1175
+ if (cmd == MCE_CMD_PORT_SYS) {
1176
+ switch (subcmd) {
1177
+ /* the one and only 5-byte return value command */
1178
+ case MCE_RSP_GETPORTSTATUS:
1179
+ if (buf_in[5] == 0 && *hi < 8)
1180
+ ir->txports_cabled |= 1 << *hi;
1181
+ break;
11571182
1183
+ /* 1-byte return value commands */
1184
+ case MCE_RSP_EQEMVER:
1185
+ ir->emver = *hi;
1186
+ break;
1187
+
1188
+ /* No return value commands */
1189
+ case MCE_RSP_CMD_ILLEGAL:
1190
+ ir->need_reset = true;
1191
+ break;
1192
+
1193
+ default:
1194
+ break;
1195
+ }
1196
+
1197
+ return;
1198
+ }
1199
+
1200
+ if (cmd != MCE_CMD_PORT_IR)
1201
+ return;
1202
+
1203
+ switch (subcmd) {
11581204 /* 2-byte return value commands */
11591205 case MCE_RSP_EQIRTIMEOUT:
1160
- ir->rc->timeout = US_TO_NS((hi << 8 | lo) * MCE_TIME_UNIT);
1206
+ ir->rc->timeout = (*hi << 8 | *lo) * MCE_TIME_UNIT;
11611207 break;
11621208 case MCE_RSP_EQIRNUMPORTS:
1163
- ir->num_txports = hi;
1164
- ir->num_rxports = lo;
1209
+ ir->num_txports = *hi;
1210
+ ir->num_rxports = *lo;
11651211 break;
11661212 case MCE_RSP_EQIRRXCFCNT:
11671213 /*
....@@ -1174,7 +1220,7 @@
11741220 */
11751221 if (ir->carrier_report_enabled && ir->learning_active &&
11761222 ir->pulse_tunit > 0) {
1177
- carrier_cycles = (hi << 8 | lo);
1223
+ carrier_cycles = (*hi << 8 | *lo);
11781224 /*
11791225 * Adjust carrier cycle count by adding
11801226 * 1 missed count per pulse "on"
....@@ -1192,24 +1238,24 @@
11921238 break;
11931239
11941240 /* 1-byte return value commands */
1195
- case MCE_RSP_EQEMVER:
1196
- ir->emver = hi;
1197
- break;
11981241 case MCE_RSP_EQIRTXPORTS:
1199
- ir->tx_mask = hi;
1242
+ ir->tx_mask = *hi;
12001243 break;
12011244 case MCE_RSP_EQIRRXPORTEN:
1202
- ir->learning_active = ((hi & 0x02) == 0x02);
1203
- if (ir->rxports_active != hi) {
1245
+ ir->learning_active = ((*hi & 0x02) == 0x02);
1246
+ if (ir->rxports_active != *hi) {
12041247 dev_info(ir->dev, "%s-range (0x%x) receiver active",
1205
- ir->learning_active ? "short" : "long", hi);
1206
- ir->rxports_active = hi;
1248
+ ir->learning_active ? "short" : "long", *hi);
1249
+ ir->rxports_active = *hi;
12071250 }
12081251 break;
1252
+
1253
+ /* No return value commands */
12091254 case MCE_RSP_CMD_ILLEGAL:
12101255 case MCE_RSP_TX_TIMEOUT:
12111256 ir->need_reset = true;
12121257 break;
1258
+
12131259 default:
12141260 break;
12151261 }
....@@ -1217,7 +1263,7 @@
12171263
12181264 static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)
12191265 {
1220
- DEFINE_IR_RAW_EVENT(rawir);
1266
+ struct ir_raw_event rawir = {};
12211267 bool event = false;
12221268 int i = 0;
12231269
....@@ -1235,26 +1281,26 @@
12351281 ir->rem = mceusb_cmd_datasize(ir->cmd, ir->buf_in[i]);
12361282 mceusb_dev_printdata(ir, ir->buf_in, buf_len, i - 1,
12371283 ir->rem + 2, false);
1238
- mceusb_handle_command(ir, i);
1284
+ if (i + ir->rem < buf_len)
1285
+ mceusb_handle_command(ir, &ir->buf_in[i - 1]);
12391286 ir->parser_state = CMD_DATA;
12401287 break;
12411288 case PARSE_IRDATA:
12421289 ir->rem--;
1243
- init_ir_raw_event(&rawir);
12441290 rawir.pulse = ((ir->buf_in[i] & MCE_PULSE_BIT) != 0);
12451291 rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK);
12461292 if (unlikely(!rawir.duration)) {
1247
- dev_warn(ir->dev, "nonsensical irdata %02x with duration 0",
1248
- ir->buf_in[i]);
1293
+ dev_dbg(ir->dev, "nonsensical irdata %02x with duration 0",
1294
+ ir->buf_in[i]);
12491295 break;
12501296 }
12511297 if (rawir.pulse) {
12521298 ir->pulse_tunit += rawir.duration;
12531299 ir->pulse_count++;
12541300 }
1255
- rawir.duration *= US_TO_NS(MCE_TIME_UNIT);
1301
+ rawir.duration *= MCE_TIME_UNIT;
12561302
1257
- dev_dbg(ir->dev, "Storing %s %u ns (%02x)",
1303
+ dev_dbg(ir->dev, "Storing %s %u us (%02x)",
12581304 rawir.pulse ? "pulse" : "space",
12591305 rawir.duration, ir->buf_in[i]);
12601306
....@@ -1265,26 +1311,35 @@
12651311 ir->rem--;
12661312 break;
12671313 case CMD_HEADER:
1268
- /* decode mce packets of the form (84),AA,BB,CC,DD */
1269
- /* IR data packets can span USB messages - rem */
12701314 ir->cmd = ir->buf_in[i];
12711315 if ((ir->cmd == MCE_CMD_PORT_IR) ||
12721316 ((ir->cmd & MCE_PORT_MASK) !=
12731317 MCE_COMMAND_IRDATA)) {
1318
+ /*
1319
+ * got PORT_SYS, PORT_IR, or unknown
1320
+ * command response prefix
1321
+ */
12741322 ir->parser_state = SUBCMD;
12751323 continue;
12761324 }
1325
+ /*
1326
+ * got IR data prefix (0x80 + num_bytes)
1327
+ * decode MCE packets of the form {0x83, AA, BB, CC}
1328
+ * IR data packets can span USB messages
1329
+ */
12771330 ir->rem = (ir->cmd & MCE_PACKET_LENGTH_MASK);
12781331 mceusb_dev_printdata(ir, ir->buf_in, buf_len,
12791332 i, ir->rem + 1, false);
12801333 if (ir->rem) {
12811334 ir->parser_state = PARSE_IRDATA;
12821335 } else {
1283
- init_ir_raw_event(&rawir);
1284
- rawir.timeout = 1;
1285
- rawir.duration = ir->rc->timeout;
1336
+ struct ir_raw_event ev = {
1337
+ .timeout = 1,
1338
+ .duration = ir->rc->timeout
1339
+ };
1340
+
12861341 if (ir_raw_event_store_with_filter(ir->rc,
1287
- &rawir))
1342
+ &ev))
12881343 event = true;
12891344 ir->pulse_tunit = 0;
12901345 ir->pulse_count = 0;
....@@ -1295,6 +1350,14 @@
12951350 if (ir->parser_state != CMD_HEADER && !ir->rem)
12961351 ir->parser_state = CMD_HEADER;
12971352 }
1353
+
1354
+ /*
1355
+ * Accept IR data spanning multiple rx buffers.
1356
+ * Reject MCE command response spanning multiple rx buffers.
1357
+ */
1358
+ if (ir->parser_state != PARSE_IRDATA || !ir->rem)
1359
+ ir->parser_state = CMD_HEADER;
1360
+
12981361 if (event) {
12991362 dev_dbg(ir->dev, "processed IR data");
13001363 ir_raw_event_handle(ir->rc);
....@@ -1353,42 +1416,37 @@
13531416 {
13541417 int ret;
13551418 struct device *dev = ir->dev;
1356
- char *data;
1357
-
1358
- data = kzalloc(USB_CTRL_MSG_SZ, GFP_KERNEL);
1359
- if (!data) {
1360
- dev_err(dev, "%s: memory allocation failed!", __func__);
1361
- return;
1362
- }
1419
+ char data[USB_CTRL_MSG_SZ];
13631420
13641421 /*
13651422 * This is a strange one. Windows issues a set address to the device
13661423 * on the receive control pipe and expect a certain value pair back
13671424 */
1368
- ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0),
1369
- USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0,
1370
- data, USB_CTRL_MSG_SZ, 3000);
1425
+ ret = usb_control_msg_recv(ir->usbdev, 0, USB_REQ_SET_ADDRESS,
1426
+ USB_DIR_IN | USB_TYPE_VENDOR,
1427
+ 0, 0, data, USB_CTRL_MSG_SZ, 3000,
1428
+ GFP_KERNEL);
13711429 dev_dbg(dev, "set address - ret = %d", ret);
13721430 dev_dbg(dev, "set address - data[0] = %d, data[1] = %d",
13731431 data[0], data[1]);
13741432
13751433 /* set feature: bit rate 38400 bps */
1376
- ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1377
- USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
1378
- 0xc04e, 0x0000, NULL, 0, 3000);
1434
+ ret = usb_control_msg_send(ir->usbdev, 0,
1435
+ USB_REQ_SET_FEATURE, USB_TYPE_VENDOR,
1436
+ 0xc04e, 0x0000, NULL, 0, 3000, GFP_KERNEL);
13791437
13801438 dev_dbg(dev, "set feature - ret = %d", ret);
13811439
13821440 /* bRequest 4: set char length to 8 bits */
1383
- ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1384
- 4, USB_TYPE_VENDOR,
1385
- 0x0808, 0x0000, NULL, 0, 3000);
1441
+ ret = usb_control_msg_send(ir->usbdev, 0,
1442
+ 4, USB_TYPE_VENDOR,
1443
+ 0x0808, 0x0000, NULL, 0, 3000, GFP_KERNEL);
13861444 dev_dbg(dev, "set char length - retB = %d", ret);
13871445
13881446 /* bRequest 2: set handshaking to use DTR/DSR */
1389
- ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0),
1390
- 2, USB_TYPE_VENDOR,
1391
- 0x0000, 0x0100, NULL, 0, 3000);
1447
+ ret = usb_control_msg_send(ir->usbdev, 0,
1448
+ 2, USB_TYPE_VENDOR,
1449
+ 0x0000, 0x0100, NULL, 0, 3000, GFP_KERNEL);
13921450 dev_dbg(dev, "set handshake - retC = %d", ret);
13931451
13941452 /* device resume */
....@@ -1396,8 +1454,6 @@
13961454
13971455 /* get hw/sw revision? */
13981456 mce_command_out(ir, GET_REVISION, sizeof(GET_REVISION));
1399
-
1400
- kfree(data);
14011457 }
14021458
14031459 static void mceusb_gen2_init(struct mceusb_dev *ir)
....@@ -1465,28 +1521,59 @@
14651521 container_of(work, struct mceusb_dev, kevent);
14661522 int status;
14671523
1524
+ dev_err(ir->dev, "kevent handler called (flags 0x%lx)",
1525
+ ir->kevent_flags);
1526
+
1527
+ if (test_bit(EVENT_RST_PEND, &ir->kevent_flags)) {
1528
+ dev_err(ir->dev, "kevent handler canceled pending USB Reset Device");
1529
+ return;
1530
+ }
1531
+
14681532 if (test_bit(EVENT_RX_HALT, &ir->kevent_flags)) {
14691533 usb_unlink_urb(ir->urb_in);
14701534 status = usb_clear_halt(ir->usbdev, ir->pipe_in);
1535
+ dev_err(ir->dev, "rx clear halt status = %d", status);
14711536 if (status < 0) {
1472
- dev_err(ir->dev, "rx clear halt error %d",
1473
- status);
1537
+ /*
1538
+ * Unable to clear RX halt/stall.
1539
+ * Will need to call usb_reset_device().
1540
+ */
1541
+ dev_err(ir->dev,
1542
+ "stuck RX HALT state requires USB Reset Device to clear");
1543
+ usb_queue_reset_device(ir->usbintf);
1544
+ set_bit(EVENT_RST_PEND, &ir->kevent_flags);
1545
+ clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
1546
+
1547
+ /* Cancel all other error events and handlers */
1548
+ clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
1549
+ return;
14741550 }
14751551 clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
1476
- if (status == 0) {
1477
- status = usb_submit_urb(ir->urb_in, GFP_KERNEL);
1478
- if (status < 0) {
1479
- dev_err(ir->dev,
1480
- "rx unhalt submit urb error %d",
1481
- status);
1482
- }
1552
+ status = usb_submit_urb(ir->urb_in, GFP_KERNEL);
1553
+ if (status < 0) {
1554
+ dev_err(ir->dev, "rx unhalt submit urb error = %d",
1555
+ status);
14831556 }
14841557 }
14851558
14861559 if (test_bit(EVENT_TX_HALT, &ir->kevent_flags)) {
14871560 status = usb_clear_halt(ir->usbdev, ir->pipe_out);
1488
- if (status < 0)
1489
- dev_err(ir->dev, "tx clear halt error %d", status);
1561
+ dev_err(ir->dev, "tx clear halt status = %d", status);
1562
+ if (status < 0) {
1563
+ /*
1564
+ * Unable to clear TX halt/stall.
1565
+ * Will need to call usb_reset_device().
1566
+ */
1567
+ dev_err(ir->dev,
1568
+ "stuck TX HALT state requires USB Reset Device to clear");
1569
+ usb_queue_reset_device(ir->usbintf);
1570
+ set_bit(EVENT_RST_PEND, &ir->kevent_flags);
1571
+ clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
1572
+
1573
+ /* Cancel all other error events and handlers */
1574
+ clear_bit(EVENT_RX_HALT, &ir->kevent_flags);
1575
+ return;
1576
+ }
14901577 clear_bit(EVENT_TX_HALT, &ir->kevent_flags);
14911578 }
14921579 }
....@@ -1519,8 +1606,8 @@
15191606 rc->dev.parent = dev;
15201607 rc->priv = ir;
15211608 rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
1522
- rc->min_timeout = US_TO_NS(MCE_TIME_UNIT);
1523
- rc->timeout = MS_TO_NS(100);
1609
+ rc->min_timeout = MCE_TIME_UNIT;
1610
+ rc->timeout = MS_TO_US(100);
15241611 if (!mceusb_model[ir->model].broken_irtimeout) {
15251612 rc->s_timeout = mceusb_set_timeout;
15261613 rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
....@@ -1640,7 +1727,7 @@
16401727 goto mem_alloc_fail;
16411728
16421729 ir->pipe_in = pipe;
1643
- ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_ATOMIC, &ir->dma_in);
1730
+ ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_KERNEL, &ir->dma_in);
16441731 if (!ir->buf_in)
16451732 goto buf_in_alloc_fail;
16461733
....@@ -1648,6 +1735,7 @@
16481735 if (!ir->urb_in)
16491736 goto urb_in_alloc_fail;
16501737
1738
+ ir->usbintf = intf;
16511739 ir->usbdev = usb_get_dev(dev);
16521740 ir->dev = &intf->dev;
16531741 ir->len_in = maxp;
....@@ -1669,7 +1757,7 @@
16691757 if (dev->descriptor.iManufacturer
16701758 && usb_string(dev, dev->descriptor.iManufacturer,
16711759 buf, sizeof(buf)) > 0)
1672
- strlcpy(name, buf, sizeof(name));
1760
+ strscpy(name, buf, sizeof(name));
16731761 if (dev->descriptor.iProduct
16741762 && usb_string(dev, dev->descriptor.iProduct,
16751763 buf, sizeof(buf)) > 0)
....@@ -1755,6 +1843,8 @@
17551843 struct usb_device *dev = interface_to_usbdev(intf);
17561844 struct mceusb_dev *ir = usb_get_intfdata(intf);
17571845
1846
+ dev_dbg(&intf->dev, "%s called", __func__);
1847
+
17581848 usb_set_intfdata(intf, NULL);
17591849
17601850 if (!ir)