generic.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * USB Serial Converter Generic functions
  4. *
  5. * Copyright (C) 2010 - 2013 Johan Hovold ([email protected])
  6. * Copyright (C) 1999 - 2002 Greg Kroah-Hartman ([email protected])
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/sched/signal.h>
  10. #include <linux/errno.h>
  11. #include <linux/slab.h>
  12. #include <linux/sysrq.h>
  13. #include <linux/tty.h>
  14. #include <linux/tty_flip.h>
  15. #include <linux/module.h>
  16. #include <linux/moduleparam.h>
  17. #include <linux/usb.h>
  18. #include <linux/usb/serial.h>
  19. #include <linux/uaccess.h>
  20. #include <linux/kfifo.h>
  21. #include <linux/serial.h>
  22. #ifdef CONFIG_USB_SERIAL_GENERIC
  23. static __u16 vendor = 0x05f9;
  24. static __u16 product = 0xffff;
  25. module_param(vendor, ushort, 0);
  26. MODULE_PARM_DESC(vendor, "User specified USB idVendor");
  27. module_param(product, ushort, 0);
  28. MODULE_PARM_DESC(product, "User specified USB idProduct");
  29. static struct usb_device_id generic_device_ids[2]; /* Initially all zeroes. */
  30. static int usb_serial_generic_probe(struct usb_serial *serial,
  31. const struct usb_device_id *id)
  32. {
  33. struct device *dev = &serial->interface->dev;
  34. dev_info(dev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n");
  35. dev_info(dev, "Tell [email protected] to add your device to a proper driver.\n");
  36. return 0;
  37. }
  38. static int usb_serial_generic_calc_num_ports(struct usb_serial *serial,
  39. struct usb_serial_endpoints *epds)
  40. {
  41. struct device *dev = &serial->interface->dev;
  42. int num_ports;
  43. num_ports = max(epds->num_bulk_in, epds->num_bulk_out);
  44. if (num_ports == 0) {
  45. dev_err(dev, "device has no bulk endpoints\n");
  46. return -ENODEV;
  47. }
  48. return num_ports;
  49. }
  50. static struct usb_serial_driver usb_serial_generic_device = {
  51. .driver = {
  52. .owner = THIS_MODULE,
  53. .name = "generic",
  54. },
  55. .id_table = generic_device_ids,
  56. .probe = usb_serial_generic_probe,
  57. .calc_num_ports = usb_serial_generic_calc_num_ports,
  58. .throttle = usb_serial_generic_throttle,
  59. .unthrottle = usb_serial_generic_unthrottle,
  60. .resume = usb_serial_generic_resume,
  61. };
  62. static struct usb_serial_driver * const serial_drivers[] = {
  63. &usb_serial_generic_device, NULL
  64. };
  65. #endif
  66. int usb_serial_generic_register(void)
  67. {
  68. int retval = 0;
  69. #ifdef CONFIG_USB_SERIAL_GENERIC
  70. generic_device_ids[0].idVendor = vendor;
  71. generic_device_ids[0].idProduct = product;
  72. generic_device_ids[0].match_flags =
  73. USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT;
  74. retval = usb_serial_register_drivers(serial_drivers,
  75. "usbserial_generic", generic_device_ids);
  76. #endif
  77. return retval;
  78. }
  79. void usb_serial_generic_deregister(void)
  80. {
  81. #ifdef CONFIG_USB_SERIAL_GENERIC
  82. usb_serial_deregister_drivers(serial_drivers);
  83. #endif
  84. }
  85. int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port)
  86. {
  87. int result = 0;
  88. clear_bit(USB_SERIAL_THROTTLED, &port->flags);
  89. if (port->bulk_in_size)
  90. result = usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
  91. return result;
  92. }
  93. EXPORT_SYMBOL_GPL(usb_serial_generic_open);
  94. void usb_serial_generic_close(struct usb_serial_port *port)
  95. {
  96. unsigned long flags;
  97. int i;
  98. if (port->bulk_out_size) {
  99. for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i)
  100. usb_kill_urb(port->write_urbs[i]);
  101. spin_lock_irqsave(&port->lock, flags);
  102. kfifo_reset_out(&port->write_fifo);
  103. spin_unlock_irqrestore(&port->lock, flags);
  104. }
  105. if (port->bulk_in_size) {
  106. for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
  107. usb_kill_urb(port->read_urbs[i]);
  108. }
  109. }
  110. EXPORT_SYMBOL_GPL(usb_serial_generic_close);
  111. int usb_serial_generic_prepare_write_buffer(struct usb_serial_port *port,
  112. void *dest, size_t size)
  113. {
  114. return kfifo_out_locked(&port->write_fifo, dest, size, &port->lock);
  115. }
  116. /**
  117. * usb_serial_generic_write_start - start writing buffered data
  118. * @port: usb-serial port
  119. * @mem_flags: flags to use for memory allocations
  120. *
  121. * Serialised using USB_SERIAL_WRITE_BUSY flag.
  122. *
  123. * Return: Zero on success or if busy, otherwise a negative errno value.
  124. */
  125. int usb_serial_generic_write_start(struct usb_serial_port *port,
  126. gfp_t mem_flags)
  127. {
  128. struct urb *urb;
  129. int count, result;
  130. unsigned long flags;
  131. int i;
  132. if (test_and_set_bit_lock(USB_SERIAL_WRITE_BUSY, &port->flags))
  133. return 0;
  134. retry:
  135. spin_lock_irqsave(&port->lock, flags);
  136. if (!port->write_urbs_free || !kfifo_len(&port->write_fifo)) {
  137. clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
  138. spin_unlock_irqrestore(&port->lock, flags);
  139. return 0;
  140. }
  141. i = (int)find_first_bit(&port->write_urbs_free,
  142. ARRAY_SIZE(port->write_urbs));
  143. spin_unlock_irqrestore(&port->lock, flags);
  144. urb = port->write_urbs[i];
  145. count = port->serial->type->prepare_write_buffer(port,
  146. urb->transfer_buffer,
  147. port->bulk_out_size);
  148. urb->transfer_buffer_length = count;
  149. usb_serial_debug_data(&port->dev, __func__, count, urb->transfer_buffer);
  150. spin_lock_irqsave(&port->lock, flags);
  151. port->tx_bytes += count;
  152. spin_unlock_irqrestore(&port->lock, flags);
  153. clear_bit(i, &port->write_urbs_free);
  154. result = usb_submit_urb(urb, mem_flags);
  155. if (result) {
  156. dev_err_console(port, "%s - error submitting urb: %d\n",
  157. __func__, result);
  158. set_bit(i, &port->write_urbs_free);
  159. spin_lock_irqsave(&port->lock, flags);
  160. port->tx_bytes -= count;
  161. spin_unlock_irqrestore(&port->lock, flags);
  162. clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
  163. return result;
  164. }
  165. goto retry; /* try sending off another urb */
  166. }
  167. EXPORT_SYMBOL_GPL(usb_serial_generic_write_start);
  168. /**
  169. * usb_serial_generic_write - generic write function
  170. * @tty: tty for the port
  171. * @port: usb-serial port
  172. * @buf: data to write
  173. * @count: number of bytes to write
  174. *
  175. * Return: The number of characters buffered, which may be anything from
  176. * zero to @count, or a negative errno value.
  177. */
  178. int usb_serial_generic_write(struct tty_struct *tty,
  179. struct usb_serial_port *port, const unsigned char *buf, int count)
  180. {
  181. int result;
  182. if (!port->bulk_out_size)
  183. return -ENODEV;
  184. if (!count)
  185. return 0;
  186. count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
  187. result = usb_serial_generic_write_start(port, GFP_ATOMIC);
  188. if (result)
  189. return result;
  190. return count;
  191. }
  192. EXPORT_SYMBOL_GPL(usb_serial_generic_write);
  193. unsigned int usb_serial_generic_write_room(struct tty_struct *tty)
  194. {
  195. struct usb_serial_port *port = tty->driver_data;
  196. unsigned long flags;
  197. unsigned int room;
  198. if (!port->bulk_out_size)
  199. return 0;
  200. spin_lock_irqsave(&port->lock, flags);
  201. room = kfifo_avail(&port->write_fifo);
  202. spin_unlock_irqrestore(&port->lock, flags);
  203. dev_dbg(&port->dev, "%s - returns %u\n", __func__, room);
  204. return room;
  205. }
  206. unsigned int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
  207. {
  208. struct usb_serial_port *port = tty->driver_data;
  209. unsigned long flags;
  210. unsigned int chars;
  211. if (!port->bulk_out_size)
  212. return 0;
  213. spin_lock_irqsave(&port->lock, flags);
  214. chars = kfifo_len(&port->write_fifo) + port->tx_bytes;
  215. spin_unlock_irqrestore(&port->lock, flags);
  216. dev_dbg(&port->dev, "%s - returns %u\n", __func__, chars);
  217. return chars;
  218. }
  219. EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer);
  220. void usb_serial_generic_wait_until_sent(struct tty_struct *tty, long timeout)
  221. {
  222. struct usb_serial_port *port = tty->driver_data;
  223. unsigned int bps;
  224. unsigned long period;
  225. unsigned long expire;
  226. bps = tty_get_baud_rate(tty);
  227. if (!bps)
  228. bps = 9600; /* B0 */
  229. /*
  230. * Use a poll-period of roughly the time it takes to send one
  231. * character or at least one jiffy.
  232. */
  233. period = max_t(unsigned long, (10 * HZ / bps), 1);
  234. if (timeout)
  235. period = min_t(unsigned long, period, timeout);
  236. dev_dbg(&port->dev, "%s - timeout = %u ms, period = %u ms\n",
  237. __func__, jiffies_to_msecs(timeout),
  238. jiffies_to_msecs(period));
  239. expire = jiffies + timeout;
  240. while (!port->serial->type->tx_empty(port)) {
  241. schedule_timeout_interruptible(period);
  242. if (signal_pending(current))
  243. break;
  244. if (timeout && time_after(jiffies, expire))
  245. break;
  246. }
  247. }
  248. EXPORT_SYMBOL_GPL(usb_serial_generic_wait_until_sent);
  249. static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port,
  250. int index, gfp_t mem_flags)
  251. {
  252. int res;
  253. if (!test_and_clear_bit(index, &port->read_urbs_free))
  254. return 0;
  255. dev_dbg(&port->dev, "%s - urb %d\n", __func__, index);
  256. res = usb_submit_urb(port->read_urbs[index], mem_flags);
  257. if (res) {
  258. if (res != -EPERM && res != -ENODEV) {
  259. dev_err(&port->dev,
  260. "%s - usb_submit_urb failed: %d\n",
  261. __func__, res);
  262. }
  263. set_bit(index, &port->read_urbs_free);
  264. return res;
  265. }
  266. return 0;
  267. }
  268. int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,
  269. gfp_t mem_flags)
  270. {
  271. int res;
  272. int i;
  273. for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) {
  274. res = usb_serial_generic_submit_read_urb(port, i, mem_flags);
  275. if (res)
  276. goto err;
  277. }
  278. return 0;
  279. err:
  280. for (; i >= 0; --i)
  281. usb_kill_urb(port->read_urbs[i]);
  282. return res;
  283. }
  284. EXPORT_SYMBOL_GPL(usb_serial_generic_submit_read_urbs);
  285. void usb_serial_generic_process_read_urb(struct urb *urb)
  286. {
  287. struct usb_serial_port *port = urb->context;
  288. char *ch = urb->transfer_buffer;
  289. int i;
  290. if (!urb->actual_length)
  291. return;
  292. /*
  293. * The per character mucking around with sysrq path it too slow for
  294. * stuff like 3G modems, so shortcircuit it in the 99.9999999% of
  295. * cases where the USB serial is not a console anyway.
  296. */
  297. if (port->sysrq) {
  298. for (i = 0; i < urb->actual_length; i++, ch++) {
  299. if (!usb_serial_handle_sysrq_char(port, *ch))
  300. tty_insert_flip_char(&port->port, *ch, TTY_NORMAL);
  301. }
  302. } else {
  303. tty_insert_flip_string(&port->port, ch, urb->actual_length);
  304. }
  305. tty_flip_buffer_push(&port->port);
  306. }
  307. EXPORT_SYMBOL_GPL(usb_serial_generic_process_read_urb);
  308. void usb_serial_generic_read_bulk_callback(struct urb *urb)
  309. {
  310. struct usb_serial_port *port = urb->context;
  311. unsigned char *data = urb->transfer_buffer;
  312. bool stopped = false;
  313. int status = urb->status;
  314. int i;
  315. for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i) {
  316. if (urb == port->read_urbs[i])
  317. break;
  318. }
  319. dev_dbg(&port->dev, "%s - urb %d, len %d\n", __func__, i,
  320. urb->actual_length);
  321. switch (status) {
  322. case 0:
  323. usb_serial_debug_data(&port->dev, __func__, urb->actual_length,
  324. data);
  325. port->serial->type->process_read_urb(urb);
  326. break;
  327. case -ENOENT:
  328. case -ECONNRESET:
  329. case -ESHUTDOWN:
  330. dev_dbg(&port->dev, "%s - urb stopped: %d\n",
  331. __func__, status);
  332. stopped = true;
  333. break;
  334. case -EPIPE:
  335. dev_err(&port->dev, "%s - urb stopped: %d\n",
  336. __func__, status);
  337. stopped = true;
  338. break;
  339. default:
  340. dev_dbg(&port->dev, "%s - nonzero urb status: %d\n",
  341. __func__, status);
  342. break;
  343. }
  344. /*
  345. * Make sure URB processing is done before marking as free to avoid
  346. * racing with unthrottle() on another CPU. Matches the barriers
  347. * implied by the test_and_clear_bit() in
  348. * usb_serial_generic_submit_read_urb().
  349. */
  350. smp_mb__before_atomic();
  351. set_bit(i, &port->read_urbs_free);
  352. /*
  353. * Make sure URB is marked as free before checking the throttled flag
  354. * to avoid racing with unthrottle() on another CPU. Matches the
  355. * smp_mb__after_atomic() in unthrottle().
  356. */
  357. smp_mb__after_atomic();
  358. if (stopped)
  359. return;
  360. if (test_bit(USB_SERIAL_THROTTLED, &port->flags))
  361. return;
  362. usb_serial_generic_submit_read_urb(port, i, GFP_ATOMIC);
  363. }
  364. EXPORT_SYMBOL_GPL(usb_serial_generic_read_bulk_callback);
  365. void usb_serial_generic_write_bulk_callback(struct urb *urb)
  366. {
  367. unsigned long flags;
  368. struct usb_serial_port *port = urb->context;
  369. int status = urb->status;
  370. int i;
  371. for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) {
  372. if (port->write_urbs[i] == urb)
  373. break;
  374. }
  375. spin_lock_irqsave(&port->lock, flags);
  376. port->tx_bytes -= urb->transfer_buffer_length;
  377. set_bit(i, &port->write_urbs_free);
  378. spin_unlock_irqrestore(&port->lock, flags);
  379. switch (status) {
  380. case 0:
  381. break;
  382. case -ENOENT:
  383. case -ECONNRESET:
  384. case -ESHUTDOWN:
  385. dev_dbg(&port->dev, "%s - urb stopped: %d\n",
  386. __func__, status);
  387. return;
  388. case -EPIPE:
  389. dev_err_console(port, "%s - urb stopped: %d\n",
  390. __func__, status);
  391. return;
  392. default:
  393. dev_err_console(port, "%s - nonzero urb status: %d\n",
  394. __func__, status);
  395. break;
  396. }
  397. usb_serial_generic_write_start(port, GFP_ATOMIC);
  398. usb_serial_port_softint(port);
  399. }
  400. EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
  401. void usb_serial_generic_throttle(struct tty_struct *tty)
  402. {
  403. struct usb_serial_port *port = tty->driver_data;
  404. set_bit(USB_SERIAL_THROTTLED, &port->flags);
  405. }
  406. EXPORT_SYMBOL_GPL(usb_serial_generic_throttle);
  407. void usb_serial_generic_unthrottle(struct tty_struct *tty)
  408. {
  409. struct usb_serial_port *port = tty->driver_data;
  410. clear_bit(USB_SERIAL_THROTTLED, &port->flags);
  411. /*
  412. * Matches the smp_mb__after_atomic() in
  413. * usb_serial_generic_read_bulk_callback().
  414. */
  415. smp_mb__after_atomic();
  416. usb_serial_generic_submit_read_urbs(port, GFP_KERNEL);
  417. }
  418. EXPORT_SYMBOL_GPL(usb_serial_generic_unthrottle);
  419. static bool usb_serial_generic_msr_changed(struct tty_struct *tty,
  420. unsigned long arg, struct async_icount *cprev)
  421. {
  422. struct usb_serial_port *port = tty->driver_data;
  423. struct async_icount cnow;
  424. unsigned long flags;
  425. bool ret;
  426. /*
  427. * Use tty-port initialised flag to detect all hangups including the
  428. * one generated at USB-device disconnect.
  429. */
  430. if (!tty_port_initialized(&port->port))
  431. return true;
  432. spin_lock_irqsave(&port->lock, flags);
  433. cnow = port->icount; /* atomic copy*/
  434. spin_unlock_irqrestore(&port->lock, flags);
  435. ret = ((arg & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
  436. ((arg & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
  437. ((arg & TIOCM_CD) && (cnow.dcd != cprev->dcd)) ||
  438. ((arg & TIOCM_CTS) && (cnow.cts != cprev->cts));
  439. *cprev = cnow;
  440. return ret;
  441. }
  442. int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg)
  443. {
  444. struct usb_serial_port *port = tty->driver_data;
  445. struct async_icount cnow;
  446. unsigned long flags;
  447. int ret;
  448. spin_lock_irqsave(&port->lock, flags);
  449. cnow = port->icount; /* atomic copy */
  450. spin_unlock_irqrestore(&port->lock, flags);
  451. ret = wait_event_interruptible(port->port.delta_msr_wait,
  452. usb_serial_generic_msr_changed(tty, arg, &cnow));
  453. if (!ret && !tty_port_initialized(&port->port))
  454. ret = -EIO;
  455. return ret;
  456. }
  457. EXPORT_SYMBOL_GPL(usb_serial_generic_tiocmiwait);
  458. int usb_serial_generic_get_icount(struct tty_struct *tty,
  459. struct serial_icounter_struct *icount)
  460. {
  461. struct usb_serial_port *port = tty->driver_data;
  462. struct async_icount cnow;
  463. unsigned long flags;
  464. spin_lock_irqsave(&port->lock, flags);
  465. cnow = port->icount; /* atomic copy */
  466. spin_unlock_irqrestore(&port->lock, flags);
  467. icount->cts = cnow.cts;
  468. icount->dsr = cnow.dsr;
  469. icount->rng = cnow.rng;
  470. icount->dcd = cnow.dcd;
  471. icount->tx = cnow.tx;
  472. icount->rx = cnow.rx;
  473. icount->frame = cnow.frame;
  474. icount->parity = cnow.parity;
  475. icount->overrun = cnow.overrun;
  476. icount->brk = cnow.brk;
  477. icount->buf_overrun = cnow.buf_overrun;
  478. return 0;
  479. }
  480. EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
  481. #if defined(CONFIG_USB_SERIAL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
  482. int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
  483. {
  484. if (port->sysrq) {
  485. if (ch && time_before(jiffies, port->sysrq)) {
  486. handle_sysrq(ch);
  487. port->sysrq = 0;
  488. return 1;
  489. }
  490. port->sysrq = 0;
  491. }
  492. return 0;
  493. }
  494. EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
  495. int usb_serial_handle_break(struct usb_serial_port *port)
  496. {
  497. if (!port->port.console)
  498. return 0;
  499. if (!port->sysrq) {
  500. port->sysrq = jiffies + HZ*5;
  501. return 1;
  502. }
  503. port->sysrq = 0;
  504. return 0;
  505. }
  506. EXPORT_SYMBOL_GPL(usb_serial_handle_break);
  507. #endif
  508. /**
  509. * usb_serial_handle_dcd_change - handle a change of carrier detect state
  510. * @port: usb-serial port
  511. * @tty: tty for the port
  512. * @status: new carrier detect status, nonzero if active
  513. */
  514. void usb_serial_handle_dcd_change(struct usb_serial_port *port,
  515. struct tty_struct *tty, unsigned int status)
  516. {
  517. dev_dbg(&port->dev, "%s - status %d\n", __func__, status);
  518. if (tty) {
  519. struct tty_ldisc *ld = tty_ldisc_ref(tty);
  520. if (ld) {
  521. if (ld->ops->dcd_change)
  522. ld->ops->dcd_change(tty, status);
  523. tty_ldisc_deref(ld);
  524. }
  525. }
  526. if (status)
  527. wake_up_interruptible(&port->port.open_wait);
  528. else if (tty && !C_CLOCAL(tty))
  529. tty_hangup(tty);
  530. }
  531. EXPORT_SYMBOL_GPL(usb_serial_handle_dcd_change);
  532. int usb_serial_generic_resume(struct usb_serial *serial)
  533. {
  534. struct usb_serial_port *port;
  535. int i, c = 0, r;
  536. for (i = 0; i < serial->num_ports; i++) {
  537. port = serial->port[i];
  538. if (!tty_port_initialized(&port->port))
  539. continue;
  540. if (port->bulk_in_size) {
  541. r = usb_serial_generic_submit_read_urbs(port,
  542. GFP_NOIO);
  543. if (r < 0)
  544. c++;
  545. }
  546. if (port->bulk_out_size) {
  547. r = usb_serial_generic_write_start(port, GFP_NOIO);
  548. if (r < 0)
  549. c++;
  550. }
  551. }
  552. return c ? -EIO : 0;
  553. }
  554. EXPORT_SYMBOL_GPL(usb_serial_generic_resume);