kl5kusb105.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*
  2. * KLSI KL5KUSB105 chip RS232 converter driver
  3. *
  4. * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
  5. * Copyright (C) 2001 Utz-Uwe Haus <haus@uuhaus.de>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * All information about the device was acquired using SniffUSB ans snoopUSB
  13. * on Windows98.
  14. * It was written out of frustration with the PalmConnect USB Serial adapter
  15. * sold by Palm Inc.
  16. * Neither Palm, nor their contractor (MCCI) or their supplier (KLSI) provided
  17. * information that was not already available.
  18. *
  19. * It seems that KLSI bought some silicon-design information from ScanLogic,
  20. * whose SL11R processor is at the core of the KL5KUSB chipset from KLSI.
  21. * KLSI has firmware available for their devices; it is probable that the
  22. * firmware differs from that used by KLSI in their products. If you have an
  23. * original KLSI device and can provide some information on it, I would be
  24. * most interested in adding support for it here. If you have any information
  25. * on the protocol used (or find errors in my reverse-engineered stuff), please
  26. * let me know.
  27. *
  28. * The code was only tested with a PalmConnect USB adapter; if you
  29. * are adventurous, try it with any KLSI-based device and let me know how it
  30. * breaks so that I can fix it!
  31. */
  32. /* TODO:
  33. * check modem line signals
  34. * implement handshaking or decide that we do not support it
  35. */
  36. #include <linux/kernel.h>
  37. #include <linux/errno.h>
  38. #include <linux/slab.h>
  39. #include <linux/tty.h>
  40. #include <linux/tty_driver.h>
  41. #include <linux/tty_flip.h>
  42. #include <linux/module.h>
  43. #include <linux/uaccess.h>
  44. #include <asm/unaligned.h>
  45. #include <linux/usb.h>
  46. #include <linux/usb/serial.h>
  47. #include "kl5kusb105.h"
  48. #define DRIVER_AUTHOR "Utz-Uwe Haus <haus@uuhaus.de>, Johan Hovold <jhovold@gmail.com>"
  49. #define DRIVER_DESC "KLSI KL5KUSB105 chipset USB->Serial Converter driver"
  50. /*
  51. * Function prototypes
  52. */
  53. static int klsi_105_port_probe(struct usb_serial_port *port);
  54. static int klsi_105_port_remove(struct usb_serial_port *port);
  55. static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
  56. static void klsi_105_close(struct usb_serial_port *port);
  57. static void klsi_105_set_termios(struct tty_struct *tty,
  58. struct usb_serial_port *port, struct ktermios *old);
  59. static int klsi_105_tiocmget(struct tty_struct *tty);
  60. static int klsi_105_tiocmset(struct tty_struct *tty,
  61. unsigned int set, unsigned int clear);
  62. static void klsi_105_process_read_urb(struct urb *urb);
  63. static int klsi_105_prepare_write_buffer(struct usb_serial_port *port,
  64. void *dest, size_t size);
  65. /*
  66. * All of the device info needed for the KLSI converters.
  67. */
  68. static const struct usb_device_id id_table[] = {
  69. { USB_DEVICE(PALMCONNECT_VID, PALMCONNECT_PID) },
  70. { USB_DEVICE(KLSI_VID, KLSI_KL5KUSB105D_PID) },
  71. { } /* Terminating entry */
  72. };
  73. MODULE_DEVICE_TABLE(usb, id_table);
  74. static struct usb_serial_driver kl5kusb105d_device = {
  75. .driver = {
  76. .owner = THIS_MODULE,
  77. .name = "kl5kusb105d",
  78. },
  79. .description = "KL5KUSB105D / PalmConnect",
  80. .id_table = id_table,
  81. .num_ports = 1,
  82. .bulk_out_size = 64,
  83. .open = klsi_105_open,
  84. .close = klsi_105_close,
  85. .set_termios = klsi_105_set_termios,
  86. /*.break_ctl = klsi_105_break_ctl,*/
  87. .tiocmget = klsi_105_tiocmget,
  88. .tiocmset = klsi_105_tiocmset,
  89. .port_probe = klsi_105_port_probe,
  90. .port_remove = klsi_105_port_remove,
  91. .throttle = usb_serial_generic_throttle,
  92. .unthrottle = usb_serial_generic_unthrottle,
  93. .process_read_urb = klsi_105_process_read_urb,
  94. .prepare_write_buffer = klsi_105_prepare_write_buffer,
  95. };
  96. static struct usb_serial_driver * const serial_drivers[] = {
  97. &kl5kusb105d_device, NULL
  98. };
  99. struct klsi_105_port_settings {
  100. __u8 pktlen; /* always 5, it seems */
  101. __u8 baudrate;
  102. __u8 databits;
  103. __u8 unknown1;
  104. __u8 unknown2;
  105. } __attribute__ ((packed));
  106. struct klsi_105_private {
  107. struct klsi_105_port_settings cfg;
  108. struct ktermios termios;
  109. unsigned long line_state; /* modem line settings */
  110. spinlock_t lock;
  111. };
  112. /*
  113. * Handle vendor specific USB requests
  114. */
  115. #define KLSI_TIMEOUT 5000 /* default urb timeout */
  116. static int klsi_105_chg_port_settings(struct usb_serial_port *port,
  117. struct klsi_105_port_settings *settings)
  118. {
  119. int rc;
  120. rc = usb_control_msg(port->serial->dev,
  121. usb_sndctrlpipe(port->serial->dev, 0),
  122. KL5KUSB105A_SIO_SET_DATA,
  123. USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
  124. 0, /* value */
  125. 0, /* index */
  126. settings,
  127. sizeof(struct klsi_105_port_settings),
  128. KLSI_TIMEOUT);
  129. if (rc < 0)
  130. dev_err(&port->dev,
  131. "Change port settings failed (error = %d)\n", rc);
  132. dev_info(&port->serial->dev->dev,
  133. "%d byte block, baudrate %x, databits %d, u1 %d, u2 %d\n",
  134. settings->pktlen, settings->baudrate, settings->databits,
  135. settings->unknown1, settings->unknown2);
  136. return rc;
  137. }
  138. /* translate a 16-bit status value from the device to linux's TIO bits */
  139. static unsigned long klsi_105_status2linestate(const __u16 status)
  140. {
  141. unsigned long res = 0;
  142. res = ((status & KL5KUSB105A_DSR) ? TIOCM_DSR : 0)
  143. | ((status & KL5KUSB105A_CTS) ? TIOCM_CTS : 0)
  144. ;
  145. return res;
  146. }
  147. /*
  148. * Read line control via vendor command and return result through
  149. * *line_state_p
  150. */
  151. /* It seems that the status buffer has always only 2 bytes length */
  152. #define KLSI_STATUSBUF_LEN 2
  153. static int klsi_105_get_line_state(struct usb_serial_port *port,
  154. unsigned long *line_state_p)
  155. {
  156. int rc;
  157. u8 *status_buf;
  158. __u16 status;
  159. dev_info(&port->serial->dev->dev, "sending SIO Poll request\n");
  160. status_buf = kmalloc(KLSI_STATUSBUF_LEN, GFP_KERNEL);
  161. if (!status_buf)
  162. return -ENOMEM;
  163. status_buf[0] = 0xff;
  164. status_buf[1] = 0xff;
  165. rc = usb_control_msg(port->serial->dev,
  166. usb_rcvctrlpipe(port->serial->dev, 0),
  167. KL5KUSB105A_SIO_POLL,
  168. USB_TYPE_VENDOR | USB_DIR_IN,
  169. 0, /* value */
  170. 0, /* index */
  171. status_buf, KLSI_STATUSBUF_LEN,
  172. 10000
  173. );
  174. if (rc < 0)
  175. dev_err(&port->dev, "Reading line status failed (error = %d)\n",
  176. rc);
  177. else {
  178. status = get_unaligned_le16(status_buf);
  179. dev_info(&port->serial->dev->dev, "read status %x %x\n",
  180. status_buf[0], status_buf[1]);
  181. *line_state_p = klsi_105_status2linestate(status);
  182. }
  183. kfree(status_buf);
  184. return rc;
  185. }
  186. /*
  187. * Driver's tty interface functions
  188. */
  189. static int klsi_105_port_probe(struct usb_serial_port *port)
  190. {
  191. struct klsi_105_private *priv;
  192. priv = kmalloc(sizeof(*priv), GFP_KERNEL);
  193. if (!priv)
  194. return -ENOMEM;
  195. /* set initial values for control structures */
  196. priv->cfg.pktlen = 5;
  197. priv->cfg.baudrate = kl5kusb105a_sio_b9600;
  198. priv->cfg.databits = kl5kusb105a_dtb_8;
  199. priv->cfg.unknown1 = 0;
  200. priv->cfg.unknown2 = 1;
  201. priv->line_state = 0;
  202. spin_lock_init(&priv->lock);
  203. /* priv->termios is left uninitialized until port opening */
  204. usb_set_serial_port_data(port, priv);
  205. return 0;
  206. }
  207. static int klsi_105_port_remove(struct usb_serial_port *port)
  208. {
  209. struct klsi_105_private *priv;
  210. priv = usb_get_serial_port_data(port);
  211. kfree(priv);
  212. return 0;
  213. }
  214. static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
  215. {
  216. struct klsi_105_private *priv = usb_get_serial_port_data(port);
  217. int retval = 0;
  218. int rc;
  219. int i;
  220. unsigned long line_state;
  221. struct klsi_105_port_settings *cfg;
  222. unsigned long flags;
  223. /* Do a defined restart:
  224. * Set up sane default baud rate and send the 'READ_ON'
  225. * vendor command.
  226. * FIXME: set modem line control (how?)
  227. * Then read the modem line control and store values in
  228. * priv->line_state.
  229. */
  230. cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
  231. if (!cfg)
  232. return -ENOMEM;
  233. cfg->pktlen = 5;
  234. cfg->baudrate = kl5kusb105a_sio_b9600;
  235. cfg->databits = kl5kusb105a_dtb_8;
  236. cfg->unknown1 = 0;
  237. cfg->unknown2 = 1;
  238. klsi_105_chg_port_settings(port, cfg);
  239. /* set up termios structure */
  240. spin_lock_irqsave(&priv->lock, flags);
  241. priv->termios.c_iflag = tty->termios.c_iflag;
  242. priv->termios.c_oflag = tty->termios.c_oflag;
  243. priv->termios.c_cflag = tty->termios.c_cflag;
  244. priv->termios.c_lflag = tty->termios.c_lflag;
  245. for (i = 0; i < NCCS; i++)
  246. priv->termios.c_cc[i] = tty->termios.c_cc[i];
  247. priv->cfg.pktlen = cfg->pktlen;
  248. priv->cfg.baudrate = cfg->baudrate;
  249. priv->cfg.databits = cfg->databits;
  250. priv->cfg.unknown1 = cfg->unknown1;
  251. priv->cfg.unknown2 = cfg->unknown2;
  252. spin_unlock_irqrestore(&priv->lock, flags);
  253. /* READ_ON and urb submission */
  254. rc = usb_serial_generic_open(tty, port);
  255. if (rc) {
  256. retval = rc;
  257. goto exit;
  258. }
  259. rc = usb_control_msg(port->serial->dev,
  260. usb_sndctrlpipe(port->serial->dev, 0),
  261. KL5KUSB105A_SIO_CONFIGURE,
  262. USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE,
  263. KL5KUSB105A_SIO_CONFIGURE_READ_ON,
  264. 0, /* index */
  265. NULL,
  266. 0,
  267. KLSI_TIMEOUT);
  268. if (rc < 0) {
  269. dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
  270. retval = rc;
  271. } else
  272. dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
  273. rc = klsi_105_get_line_state(port, &line_state);
  274. if (rc >= 0) {
  275. spin_lock_irqsave(&priv->lock, flags);
  276. priv->line_state = line_state;
  277. spin_unlock_irqrestore(&priv->lock, flags);
  278. dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state);
  279. retval = 0;
  280. } else
  281. retval = rc;
  282. exit:
  283. kfree(cfg);
  284. return retval;
  285. }
  286. static void klsi_105_close(struct usb_serial_port *port)
  287. {
  288. int rc;
  289. /* send READ_OFF */
  290. rc = usb_control_msg(port->serial->dev,
  291. usb_sndctrlpipe(port->serial->dev, 0),
  292. KL5KUSB105A_SIO_CONFIGURE,
  293. USB_TYPE_VENDOR | USB_DIR_OUT,
  294. KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
  295. 0, /* index */
  296. NULL, 0,
  297. KLSI_TIMEOUT);
  298. if (rc < 0)
  299. dev_err(&port->dev, "failed to disable read: %d\n", rc);
  300. /* shutdown our bulk reads and writes */
  301. usb_serial_generic_close(port);
  302. }
  303. /* We need to write a complete 64-byte data block and encode the
  304. * number actually sent in the first double-byte, LSB-order. That
  305. * leaves at most 62 bytes of payload.
  306. */
  307. #define KLSI_HDR_LEN 2
  308. static int klsi_105_prepare_write_buffer(struct usb_serial_port *port,
  309. void *dest, size_t size)
  310. {
  311. unsigned char *buf = dest;
  312. int count;
  313. count = kfifo_out_locked(&port->write_fifo, buf + KLSI_HDR_LEN, size,
  314. &port->lock);
  315. put_unaligned_le16(count, buf);
  316. return count + KLSI_HDR_LEN;
  317. }
  318. /* The data received is preceded by a length double-byte in LSB-first order.
  319. */
  320. static void klsi_105_process_read_urb(struct urb *urb)
  321. {
  322. struct usb_serial_port *port = urb->context;
  323. unsigned char *data = urb->transfer_buffer;
  324. unsigned len;
  325. /* empty urbs seem to happen, we ignore them */
  326. if (!urb->actual_length)
  327. return;
  328. if (urb->actual_length <= KLSI_HDR_LEN) {
  329. dev_dbg(&port->dev, "%s - malformed packet\n", __func__);
  330. return;
  331. }
  332. len = get_unaligned_le16(data);
  333. if (len > urb->actual_length - KLSI_HDR_LEN) {
  334. dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__);
  335. len = urb->actual_length - KLSI_HDR_LEN;
  336. }
  337. tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len);
  338. tty_flip_buffer_push(&port->port);
  339. }
  340. static void klsi_105_set_termios(struct tty_struct *tty,
  341. struct usb_serial_port *port,
  342. struct ktermios *old_termios)
  343. {
  344. struct klsi_105_private *priv = usb_get_serial_port_data(port);
  345. struct device *dev = &port->dev;
  346. unsigned int iflag = tty->termios.c_iflag;
  347. unsigned int old_iflag = old_termios->c_iflag;
  348. unsigned int cflag = tty->termios.c_cflag;
  349. unsigned int old_cflag = old_termios->c_cflag;
  350. struct klsi_105_port_settings *cfg;
  351. unsigned long flags;
  352. speed_t baud;
  353. cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
  354. if (!cfg)
  355. return;
  356. /* lock while we are modifying the settings */
  357. spin_lock_irqsave(&priv->lock, flags);
  358. /*
  359. * Update baud rate
  360. */
  361. baud = tty_get_baud_rate(tty);
  362. if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
  363. /* reassert DTR and (maybe) RTS on transition from B0 */
  364. if ((old_cflag & CBAUD) == B0) {
  365. dev_dbg(dev, "%s: baud was B0\n", __func__);
  366. #if 0
  367. priv->control_state |= TIOCM_DTR;
  368. /* don't set RTS if using hardware flow control */
  369. if (!(old_cflag & CRTSCTS))
  370. priv->control_state |= TIOCM_RTS;
  371. mct_u232_set_modem_ctrl(serial, priv->control_state);
  372. #endif
  373. }
  374. }
  375. switch (baud) {
  376. case 0: /* handled below */
  377. break;
  378. case 1200:
  379. priv->cfg.baudrate = kl5kusb105a_sio_b1200;
  380. break;
  381. case 2400:
  382. priv->cfg.baudrate = kl5kusb105a_sio_b2400;
  383. break;
  384. case 4800:
  385. priv->cfg.baudrate = kl5kusb105a_sio_b4800;
  386. break;
  387. case 9600:
  388. priv->cfg.baudrate = kl5kusb105a_sio_b9600;
  389. break;
  390. case 19200:
  391. priv->cfg.baudrate = kl5kusb105a_sio_b19200;
  392. break;
  393. case 38400:
  394. priv->cfg.baudrate = kl5kusb105a_sio_b38400;
  395. break;
  396. case 57600:
  397. priv->cfg.baudrate = kl5kusb105a_sio_b57600;
  398. break;
  399. case 115200:
  400. priv->cfg.baudrate = kl5kusb105a_sio_b115200;
  401. break;
  402. default:
  403. dev_dbg(dev, "unsupported baudrate, using 9600\n");
  404. priv->cfg.baudrate = kl5kusb105a_sio_b9600;
  405. baud = 9600;
  406. break;
  407. }
  408. if ((cflag & CBAUD) == B0) {
  409. dev_dbg(dev, "%s: baud is B0\n", __func__);
  410. /* Drop RTS and DTR */
  411. /* maybe this should be simulated by sending read
  412. * disable and read enable messages?
  413. */
  414. ;
  415. #if 0
  416. priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
  417. mct_u232_set_modem_ctrl(serial, priv->control_state);
  418. #endif
  419. }
  420. tty_encode_baud_rate(tty, baud, baud);
  421. if ((cflag & CSIZE) != (old_cflag & CSIZE)) {
  422. /* set the number of data bits */
  423. switch (cflag & CSIZE) {
  424. case CS5:
  425. dev_dbg(dev, "%s - 5 bits/byte not supported\n", __func__);
  426. spin_unlock_irqrestore(&priv->lock, flags);
  427. goto err;
  428. case CS6:
  429. dev_dbg(dev, "%s - 6 bits/byte not supported\n", __func__);
  430. spin_unlock_irqrestore(&priv->lock, flags);
  431. goto err;
  432. case CS7:
  433. priv->cfg.databits = kl5kusb105a_dtb_7;
  434. break;
  435. case CS8:
  436. priv->cfg.databits = kl5kusb105a_dtb_8;
  437. break;
  438. default:
  439. dev_err(dev, "CSIZE was not CS5-CS8, using default of 8\n");
  440. priv->cfg.databits = kl5kusb105a_dtb_8;
  441. break;
  442. }
  443. }
  444. /*
  445. * Update line control register (LCR)
  446. */
  447. if ((cflag & (PARENB|PARODD)) != (old_cflag & (PARENB|PARODD))
  448. || (cflag & CSTOPB) != (old_cflag & CSTOPB)) {
  449. /* Not currently supported */
  450. tty->termios.c_cflag &= ~(PARENB|PARODD|CSTOPB);
  451. #if 0
  452. priv->last_lcr = 0;
  453. /* set the parity */
  454. if (cflag & PARENB)
  455. priv->last_lcr |= (cflag & PARODD) ?
  456. MCT_U232_PARITY_ODD : MCT_U232_PARITY_EVEN;
  457. else
  458. priv->last_lcr |= MCT_U232_PARITY_NONE;
  459. /* set the number of stop bits */
  460. priv->last_lcr |= (cflag & CSTOPB) ?
  461. MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1;
  462. mct_u232_set_line_ctrl(serial, priv->last_lcr);
  463. #endif
  464. ;
  465. }
  466. /*
  467. * Set flow control: well, I do not really now how to handle DTR/RTS.
  468. * Just do what we have seen with SniffUSB on Win98.
  469. */
  470. if ((iflag & IXOFF) != (old_iflag & IXOFF)
  471. || (iflag & IXON) != (old_iflag & IXON)
  472. || (cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
  473. /* Not currently supported */
  474. tty->termios.c_cflag &= ~CRTSCTS;
  475. /* Drop DTR/RTS if no flow control otherwise assert */
  476. #if 0
  477. if ((iflag & IXOFF) || (iflag & IXON) || (cflag & CRTSCTS))
  478. priv->control_state |= TIOCM_DTR | TIOCM_RTS;
  479. else
  480. priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
  481. mct_u232_set_modem_ctrl(serial, priv->control_state);
  482. #endif
  483. ;
  484. }
  485. memcpy(cfg, &priv->cfg, sizeof(*cfg));
  486. spin_unlock_irqrestore(&priv->lock, flags);
  487. /* now commit changes to device */
  488. klsi_105_chg_port_settings(port, cfg);
  489. err:
  490. kfree(cfg);
  491. }
  492. #if 0
  493. static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
  494. {
  495. struct usb_serial_port *port = tty->driver_data;
  496. struct usb_serial *serial = port->serial;
  497. struct mct_u232_private *priv =
  498. (struct mct_u232_private *)port->private;
  499. unsigned char lcr = priv->last_lcr;
  500. dev_dbg(&port->dev, "%s - state=%d\n", __func__, break_state);
  501. /* LOCKING */
  502. if (break_state)
  503. lcr |= MCT_U232_SET_BREAK;
  504. mct_u232_set_line_ctrl(serial, lcr);
  505. }
  506. #endif
  507. static int klsi_105_tiocmget(struct tty_struct *tty)
  508. {
  509. struct usb_serial_port *port = tty->driver_data;
  510. struct klsi_105_private *priv = usb_get_serial_port_data(port);
  511. unsigned long flags;
  512. int rc;
  513. unsigned long line_state;
  514. rc = klsi_105_get_line_state(port, &line_state);
  515. if (rc < 0) {
  516. dev_err(&port->dev,
  517. "Reading line control failed (error = %d)\n", rc);
  518. /* better return value? EAGAIN? */
  519. return rc;
  520. }
  521. spin_lock_irqsave(&priv->lock, flags);
  522. priv->line_state = line_state;
  523. spin_unlock_irqrestore(&priv->lock, flags);
  524. dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state);
  525. return (int)line_state;
  526. }
  527. static int klsi_105_tiocmset(struct tty_struct *tty,
  528. unsigned int set, unsigned int clear)
  529. {
  530. int retval = -EINVAL;
  531. /* if this ever gets implemented, it should be done something like this:
  532. struct usb_serial *serial = port->serial;
  533. struct klsi_105_private *priv = usb_get_serial_port_data(port);
  534. unsigned long flags;
  535. int control;
  536. spin_lock_irqsave (&priv->lock, flags);
  537. if (set & TIOCM_RTS)
  538. priv->control_state |= TIOCM_RTS;
  539. if (set & TIOCM_DTR)
  540. priv->control_state |= TIOCM_DTR;
  541. if (clear & TIOCM_RTS)
  542. priv->control_state &= ~TIOCM_RTS;
  543. if (clear & TIOCM_DTR)
  544. priv->control_state &= ~TIOCM_DTR;
  545. control = priv->control_state;
  546. spin_unlock_irqrestore (&priv->lock, flags);
  547. retval = mct_u232_set_modem_ctrl(serial, control);
  548. */
  549. return retval;
  550. }
  551. module_usb_serial_driver(serial_drivers, id_table);
  552. MODULE_AUTHOR(DRIVER_AUTHOR);
  553. MODULE_DESCRIPTION(DRIVER_DESC);
  554. MODULE_LICENSE("GPL");