4 * Copyright (c) 1999 Armin Fuerst <fuerst@in.tum.de>
5 * Copyright (c) 1999 Pavel Machek <pavel@suse.cz>
6 * Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com>
7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
9 * USB Abstract Control Model driver for USB modems and ISDN adapters
14 * v0.9 - thorough cleaning, URBification, almost a rewrite
15 * v0.10 - some more cleanups
16 * v0.11 - fixed flow control, read error doesn't stop reads
17 * v0.12 - added TIOCM ioctls, added break handling, made struct acm kmalloced
18 * v0.13 - added termios, added hangup
19 * v0.14 - sized down struct acm
20 * v0.15 - fixed flow control again - characters could be lost
21 * v0.16 - added code for modems with swapped data and control interfaces
22 * v0.17 - added new style probing
23 * v0.18 - fixed new style probing for devices with more configurations
24 * v0.19 - fixed CLOCAL handling (thanks to Richard Shih-Ping Chan)
25 * v0.20 - switched to probing on interface (rather than device) class
26 * v0.21 - revert to probing on device for devices with multiple configs
27 * v0.22 - probe only the control interface. if usbcore doesn't choose the
28 * config we want, sysadmin changes bConfigurationValue in sysfs.
29 * v0.23 - use softirq for rx processing, as needed by tty layer
33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2 of the License, or
36 * (at your option) any later version.
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
50 #include <linux/kernel.h>
51 #include <linux/errno.h>
52 #include <linux/init.h>
53 #include <linux/slab.h>
54 #include <linux/tty.h>
55 #include <linux/tty_driver.h>
56 #include <linux/tty_flip.h>
57 #include <linux/module.h>
58 #include <linux/smp_lock.h>
59 #include <asm/uaccess.h>
60 #include <linux/usb.h>
61 #include <asm/byteorder.h>
66 #define DRIVER_VERSION "v0.23"
67 #define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik"
68 #define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
71 * CMSPAR, some architectures can't have space and mark parity.
79 * Major and minor numbers.
82 #define ACM_TTY_MAJOR 166
83 #define ACM_TTY_MINORS 32
89 #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
91 #define ACM_REQ_COMMAND 0x00
92 #define ACM_REQ_RESPONSE 0x01
93 #define ACM_REQ_SET_FEATURE 0x02
94 #define ACM_REQ_GET_FEATURE 0x03
95 #define ACM_REQ_CLEAR_FEATURE 0x04
97 #define ACM_REQ_SET_LINE 0x20
98 #define ACM_REQ_GET_LINE 0x21
99 #define ACM_REQ_SET_CONTROL 0x22
100 #define ACM_REQ_SEND_BREAK 0x23
106 #define ACM_IRQ_NETWORK 0x00
107 #define ACM_IRQ_LINE_STATE 0x20
110 * Output control lines.
113 #define ACM_CTRL_DTR 0x01
114 #define ACM_CTRL_RTS 0x02
117 * Input control lines and line errors.
120 #define ACM_CTRL_DCD 0x01
121 #define ACM_CTRL_DSR 0x02
122 #define ACM_CTRL_BRK 0x04
123 #define ACM_CTRL_RI 0x08
125 #define ACM_CTRL_FRAMING 0x10
126 #define ACM_CTRL_PARITY 0x20
127 #define ACM_CTRL_OVERRUN 0x40
130 * Line speed and caracter encoding.
138 } __attribute__ ((packed));
141 * Internal driver structures.
145 struct usb_device *dev; /* the corresponding usb device */
146 struct usb_interface *control; /* control interface */
147 struct usb_interface *data; /* data interface */
148 struct tty_struct *tty; /* the corresponding tty */
149 struct urb *ctrlurb, *readurb, *writeurb; /* urbs */
150 struct acm_line line; /* line coding (bits, stop, parity) */
151 struct work_struct work; /* work queue entry for line discipline waking up */
152 struct tasklet_struct bh; /* rx processing */
153 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
154 unsigned int ctrlout; /* output control lines (DTR, RTS) */
155 unsigned int writesize; /* max packet size for the output bulk endpoint */
156 unsigned int used; /* someone has this acm's device open */
157 unsigned int minor; /* acm minor number */
158 unsigned char throttle; /* throttled by tty layer */
159 unsigned char clocal; /* termios CLOCAL */
162 static struct usb_driver acm_driver;
163 static struct tty_driver *acm_tty_driver;
164 static struct acm *acm_table[ACM_TTY_MINORS];
166 #define ACM_READY(acm) (acm && acm->dev && acm->used)
169 * Functions for ACM control messages.
172 static int acm_ctrl_msg(struct acm *acm, int request, int value, void *buf, int len)
174 int retval = usb_control_msg(acm->dev, usb_sndctrlpipe(acm->dev, 0),
175 request, USB_RT_ACM, value,
176 acm->control->altsetting[0].desc.bInterfaceNumber,
178 dbg("acm_control_msg: rq: 0x%02x val: %#x len: %#x result: %d", request, value, len, retval);
179 return retval < 0 ? retval : 0;
182 /* devices aren't required to support these requests.
183 * the cdc acm descriptor tells whether they do...
185 #define acm_set_control(acm, control) acm_ctrl_msg(acm, ACM_REQ_SET_CONTROL, control, NULL, 0)
186 #define acm_set_line(acm, line) acm_ctrl_msg(acm, ACM_REQ_SET_LINE, 0, line, sizeof(struct acm_line))
187 #define acm_send_break(acm, ms) acm_ctrl_msg(acm, ACM_REQ_SEND_BREAK, ms, NULL, 0)
190 * Interrupt handlers for various ACM device responses
193 /* control interface reports status changes with "interrupt" transfers */
194 static void acm_ctrl_irq(struct urb *urb, struct pt_regs *regs)
196 struct acm *acm = urb->context;
197 struct usb_ctrlrequest *dr = urb->transfer_buffer;
198 unsigned char *data = (unsigned char *)(dr + 1);
202 switch (urb->status) {
209 /* this urb is terminated, clean up */
210 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
213 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
220 switch (dr->bRequest) {
222 case ACM_IRQ_NETWORK:
224 dbg("%s network", dr->wValue ? "connected to" : "disconnected from");
227 case ACM_IRQ_LINE_STATE:
229 newctrl = le16_to_cpup((__u16 *) data);
231 if (acm->tty && !acm->clocal && (acm->ctrlin & ~newctrl & ACM_CTRL_DCD)) {
232 dbg("calling hangup");
233 tty_hangup(acm->tty);
236 acm->ctrlin = newctrl;
238 dbg("input control lines: dcd%c dsr%c break%c ring%c framing%c parity%c overrun%c",
239 acm->ctrlin & ACM_CTRL_DCD ? '+' : '-', acm->ctrlin & ACM_CTRL_DSR ? '+' : '-',
240 acm->ctrlin & ACM_CTRL_BRK ? '+' : '-', acm->ctrlin & ACM_CTRL_RI ? '+' : '-',
241 acm->ctrlin & ACM_CTRL_FRAMING ? '+' : '-', acm->ctrlin & ACM_CTRL_PARITY ? '+' : '-',
242 acm->ctrlin & ACM_CTRL_OVERRUN ? '+' : '-');
247 dbg("unknown control event received: request %d index %d len %d data0 %d data1 %d",
248 dr->bRequest, dr->wIndex, dr->wLength, data[0], data[1]);
252 status = usb_submit_urb (urb, GFP_ATOMIC);
254 err ("%s - usb_submit_urb failed with result %d",
255 __FUNCTION__, status);
258 /* data interface returns incoming bytes, or we got unthrottled */
259 static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
261 struct acm *acm = urb->context;
267 dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status);
269 /* calling tty_flip_buffer_push() in_irq() isn't allowed */
270 tasklet_schedule(&acm->bh);
273 static void acm_rx_tasklet(unsigned long _acm)
275 struct acm *acm = (void *)_acm;
276 struct urb *urb = acm->readurb;
277 struct tty_struct *tty = acm->tty;
278 unsigned char *data = urb->transfer_buffer;
281 if (urb->actual_length > 0 && !acm->throttle) {
282 for (i = 0; i < urb->actual_length && !acm->throttle; i++) {
283 /* if we insert more than TTY_FLIPBUF_SIZE characters,
285 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
286 tty_flip_buffer_push(tty);
288 tty_insert_flip_char(tty, data[i], 0);
290 tty_flip_buffer_push(tty);
294 memmove(data, data + i, urb->actual_length - i);
295 urb->actual_length -= i;
299 urb->actual_length = 0;
302 i = usb_submit_urb(urb, GFP_ATOMIC);
304 dev_dbg(&acm->data->dev, "bulk rx resubmit %d\n", i);
307 /* data interface wrote those outgoing bytes */
308 static void acm_write_bulk(struct urb *urb, struct pt_regs *regs)
310 struct acm *acm = (struct acm *)urb->context;
316 dbg("nonzero write bulk status received: %d", urb->status);
318 schedule_work(&acm->work);
321 static void acm_softint(void *private)
323 struct acm *acm = private;
324 struct tty_struct *tty = acm->tty;
329 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup)
330 (tty->ldisc.write_wakeup)(tty);
332 wake_up_interruptible(&tty->write_wait);
339 static int acm_tty_open(struct tty_struct *tty, struct file *filp)
341 struct acm *acm = acm_table[tty->index];
343 if (!acm || !acm->dev)
346 tty->driver_data = acm;
358 acm->ctrlurb->dev = acm->dev;
359 if (usb_submit_urb(acm->ctrlurb, GFP_KERNEL))
360 dbg("usb_submit_urb(ctrl irq) failed");
362 acm->readurb->dev = acm->dev;
363 if (usb_submit_urb(acm->readurb, GFP_KERNEL))
364 dbg("usb_submit_urb(read bulk) failed");
366 acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS);
368 /* force low_latency on so that our tty_push actually forces the data through,
369 otherwise it is scheduled, and with high data rates data can get lost. */
370 tty->low_latency = 1;
375 static void acm_tty_close(struct tty_struct *tty, struct file *filp)
377 struct acm *acm = tty->driver_data;
379 if (!acm || !acm->used)
384 acm_set_control(acm, acm->ctrlout = 0);
385 usb_unlink_urb(acm->ctrlurb);
386 usb_unlink_urb(acm->writeurb);
387 usb_unlink_urb(acm->readurb);
389 tty_unregister_device(acm_tty_driver, acm->minor);
390 acm_table[acm->minor] = NULL;
391 usb_free_urb(acm->ctrlurb);
392 usb_free_urb(acm->readurb);
393 usb_free_urb(acm->writeurb);
399 static int acm_tty_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
401 struct acm *acm = tty->driver_data;
406 if (acm->writeurb->status == -EINPROGRESS)
411 count = (count > acm->writesize) ? acm->writesize : count;
414 if (copy_from_user(acm->writeurb->transfer_buffer, (void __user *)buf, count))
417 memcpy(acm->writeurb->transfer_buffer, buf, count);
419 acm->writeurb->transfer_buffer_length = count;
420 acm->writeurb->dev = acm->dev;
422 /* GFP_KERNEL probably works if from_user */
423 stat = usb_submit_urb(acm->writeurb, GFP_ATOMIC);
425 dbg("usb_submit_urb(write bulk) failed");
432 static int acm_tty_write_room(struct tty_struct *tty)
434 struct acm *acm = tty->driver_data;
437 return acm->writeurb->status == -EINPROGRESS ? 0 : acm->writesize;
440 static int acm_tty_chars_in_buffer(struct tty_struct *tty)
442 struct acm *acm = tty->driver_data;
445 return acm->writeurb->status == -EINPROGRESS ? acm->writeurb->transfer_buffer_length : 0;
448 static void acm_tty_throttle(struct tty_struct *tty)
450 struct acm *acm = tty->driver_data;
456 static void acm_tty_unthrottle(struct tty_struct *tty)
458 struct acm *acm = tty->driver_data;
462 if (acm->readurb->status != -EINPROGRESS)
463 acm_read_bulk(acm->readurb, NULL);
466 static void acm_tty_break_ctl(struct tty_struct *tty, int state)
468 struct acm *acm = tty->driver_data;
471 if (acm_send_break(acm, state ? 0xffff : 0))
472 dbg("send break failed");
475 static int acm_tty_tiocmget(struct tty_struct *tty, struct file *file)
477 struct acm *acm = tty->driver_data;
482 return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
483 (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
484 (acm->ctrlin & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
485 (acm->ctrlin & ACM_CTRL_RI ? TIOCM_RI : 0) |
486 (acm->ctrlin & ACM_CTRL_DCD ? TIOCM_CD : 0) |
490 static int acm_tty_tiocmset(struct tty_struct *tty, struct file *file,
491 unsigned int set, unsigned int clear)
493 struct acm *acm = tty->driver_data;
494 unsigned int newctrl;
499 newctrl = acm->ctrlout;
500 set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
501 clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
503 newctrl = (newctrl & ~clear) | set;
505 if (acm->ctrlout == newctrl)
507 return acm_set_control(acm, acm->ctrlout = newctrl);
510 static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
512 struct acm *acm = tty->driver_data;
520 static __u32 acm_tty_speed[] = {
521 0, 50, 75, 110, 134, 150, 200, 300, 600,
522 1200, 1800, 2400, 4800, 9600, 19200, 38400,
523 57600, 115200, 230400, 460800, 500000, 576000,
524 921600, 1000000, 1152000, 1500000, 2000000,
525 2500000, 3000000, 3500000, 4000000
528 static __u8 acm_tty_size[] = {
532 static void acm_tty_set_termios(struct tty_struct *tty, struct termios *termios_old)
534 struct acm *acm = tty->driver_data;
535 struct termios *termios = tty->termios;
536 struct acm_line newline;
537 int newctrl = acm->ctrlout;
542 newline.speed = cpu_to_le32p(acm_tty_speed +
543 (termios->c_cflag & CBAUD & ~CBAUDEX) + (termios->c_cflag & CBAUDEX ? 15 : 0));
544 newline.stopbits = termios->c_cflag & CSTOPB ? 2 : 0;
545 newline.parity = termios->c_cflag & PARENB ?
546 (termios->c_cflag & PARODD ? 1 : 2) + (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
547 newline.databits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4];
549 acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
551 if (!newline.speed) {
552 newline.speed = acm->line.speed;
553 newctrl &= ~ACM_CTRL_DTR;
554 } else newctrl |= ACM_CTRL_DTR;
556 if (newctrl != acm->ctrlout)
557 acm_set_control(acm, acm->ctrlout = newctrl);
559 if (memcmp(&acm->line, &newline, sizeof(struct acm_line))) {
560 memcpy(&acm->line, &newline, sizeof(struct acm_line));
561 dbg("set line: %d %d %d %d", newline.speed, newline.stopbits, newline.parity, newline.databits);
562 acm_set_line(acm, &acm->line);
567 * USB probe and disconnect routines.
570 #define CHECK_XFERTYPE(descr, xfer_type) (((descr)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == xfer_type)
572 static int acm_probe (struct usb_interface *intf,
573 const struct usb_device_id *id)
575 struct usb_device *dev;
577 struct usb_host_config *cfacm;
578 struct usb_interface *data = NULL;
579 struct usb_host_interface *ifcom, *ifdata = NULL;
580 struct usb_endpoint_descriptor *epctrl = NULL;
581 struct usb_endpoint_descriptor *epread = NULL;
582 struct usb_endpoint_descriptor *epwrite = NULL;
583 int readsize, ctrlsize, minor, j;
586 dev = interface_to_usbdev (intf);
588 cfacm = dev->actconfig;
590 /* We know we're probe()d with the control interface. */
591 ifcom = intf->cur_altsetting;
593 /* ACM doesn't guarantee the data interface is
594 * adjacent to the control interface, or that if one
595 * is there it's not for call management ... so find
598 for (j = 0; j < cfacm->desc.bNumInterfaces; j++) {
599 ifdata = cfacm->interface[j]->cur_altsetting;
600 data = cfacm->interface[j];
602 if (ifdata->desc.bInterfaceClass == USB_CLASS_CDC_DATA
603 && ifdata->desc.bNumEndpoints == 2) {
605 epctrl = &ifcom->endpoint[0].desc;
606 epread = &ifdata->endpoint[0].desc;
607 epwrite = &ifdata->endpoint[1].desc;
609 if ((epctrl->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN
610 || !CHECK_XFERTYPE(epctrl, USB_ENDPOINT_XFER_INT)
611 || !CHECK_XFERTYPE(epread, USB_ENDPOINT_XFER_BULK)
612 || !CHECK_XFERTYPE(epwrite, USB_ENDPOINT_XFER_BULK)
613 || ((epread->bEndpointAddress & USB_DIR_IN)
614 ^ (epwrite->bEndpointAddress & USB_DIR_IN)) != USB_DIR_IN) {
619 if ((epread->bEndpointAddress & USB_DIR_IN) != USB_DIR_IN) {
620 /* descriptors are swapped */
621 epread = &ifdata->endpoint[1].desc;
622 epwrite = &ifdata->endpoint[0].desc;
624 dev_dbg(&intf->dev, "found data interface at %d\n", j);
633 /* there's been a problem */
635 dev_dbg(&intf->dev, "data interface not found\n");
640 for (minor = 0; minor < ACM_TTY_MINORS && acm_table[minor]; minor++);
641 if (acm_table[minor]) {
642 err("no more free acm devices");
646 if (!(acm = kmalloc(sizeof(struct acm), GFP_KERNEL))) {
647 dev_dbg(&intf->dev, "out of memory (acm kmalloc)\n");
651 memset(acm, 0, sizeof(struct acm));
653 ctrlsize = epctrl->wMaxPacketSize;
654 readsize = epread->wMaxPacketSize;
655 acm->writesize = epwrite->wMaxPacketSize;
661 acm->bh.func = acm_rx_tasklet;
662 acm->bh.data = (unsigned long) acm;
663 INIT_WORK(&acm->work, acm_softint, acm);
665 if (!(buf = kmalloc(ctrlsize + readsize + acm->writesize, GFP_KERNEL))) {
666 dev_dbg(&intf->dev, "out of memory (buf kmalloc)\n");
671 acm->ctrlurb = usb_alloc_urb(0, GFP_KERNEL);
673 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
678 acm->readurb = usb_alloc_urb(0, GFP_KERNEL);
680 dev_dbg(&intf->dev, "out of memory (readurb kmalloc)\n");
681 usb_free_urb(acm->ctrlurb);
686 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL);
687 if (!acm->writeurb) {
688 dev_dbg(&intf->dev, "out of memory (writeurb kmalloc)\n");
689 usb_free_urb(acm->readurb);
690 usb_free_urb(acm->ctrlurb);
696 usb_fill_int_urb(acm->ctrlurb, dev, usb_rcvintpipe(dev, epctrl->bEndpointAddress),
697 buf, ctrlsize, acm_ctrl_irq, acm, epctrl->bInterval);
699 usb_fill_bulk_urb(acm->readurb, dev, usb_rcvbulkpipe(dev, epread->bEndpointAddress),
700 buf += ctrlsize, readsize, acm_read_bulk, acm);
701 acm->readurb->transfer_flags |= URB_NO_FSBR;
703 usb_fill_bulk_urb(acm->writeurb, dev, usb_sndbulkpipe(dev, epwrite->bEndpointAddress),
704 buf += readsize, acm->writesize, acm_write_bulk, acm);
705 acm->writeurb->transfer_flags |= URB_NO_FSBR;
707 if ( (j = usb_driver_claim_interface(&acm_driver, data, acm)) != 0) {
709 usb_free_urb(acm->ctrlurb);
710 usb_free_urb(acm->readurb);
711 usb_free_urb(acm->writeurb);
717 tty_register_device(acm_tty_driver, minor, &intf->dev);
719 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
721 acm_set_control(acm, acm->ctrlout);
723 acm->line.speed = cpu_to_le32(9600);
724 acm->line.databits = 8;
725 acm_set_line(acm, &acm->line);
727 acm_table[minor] = acm;
728 usb_set_intfdata (intf, acm);
731 #undef CHECK_XFERTYPE
733 static void acm_disconnect(struct usb_interface *intf)
735 struct acm *acm = usb_get_intfdata (intf);
737 if (!acm || !acm->dev) {
738 dbg("disconnect on nonexisting interface");
743 usb_set_intfdata (intf, NULL);
745 usb_unlink_urb(acm->ctrlurb);
746 usb_unlink_urb(acm->readurb);
747 usb_unlink_urb(acm->writeurb);
749 kfree(acm->ctrlurb->transfer_buffer);
751 usb_driver_release_interface(&acm_driver, acm->data);
754 tty_unregister_device(acm_tty_driver, acm->minor);
755 acm_table[acm->minor] = NULL;
756 usb_free_urb(acm->ctrlurb);
757 usb_free_urb(acm->readurb);
758 usb_free_urb(acm->writeurb);
764 tty_hangup(acm->tty);
768 * USB driver structure.
771 static struct usb_device_id acm_ids[] = {
772 /* control interfaces with various AT-command sets */
773 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 1) },
774 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 2) },
775 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 3) },
776 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 4) },
777 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 5) },
778 { USB_INTERFACE_INFO(USB_CLASS_COMM, 2, 6) },
780 /* NOTE: COMM/2/0xff is likely MSFT RNDIS ... NOT a modem!! */
784 MODULE_DEVICE_TABLE (usb, acm_ids);
786 static struct usb_driver acm_driver = {
787 .owner = THIS_MODULE,
790 .disconnect = acm_disconnect,
795 * TTY driver structures.
798 static struct tty_operations acm_ops = {
799 .open = acm_tty_open,
800 .close = acm_tty_close,
801 .write = acm_tty_write,
802 .write_room = acm_tty_write_room,
803 .ioctl = acm_tty_ioctl,
804 .throttle = acm_tty_throttle,
805 .unthrottle = acm_tty_unthrottle,
806 .chars_in_buffer = acm_tty_chars_in_buffer,
807 .break_ctl = acm_tty_break_ctl,
808 .set_termios = acm_tty_set_termios,
809 .tiocmget = acm_tty_tiocmget,
810 .tiocmset = acm_tty_tiocmset,
817 static int __init acm_init(void)
820 acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
823 acm_tty_driver->owner = THIS_MODULE,
824 acm_tty_driver->driver_name = "acm",
825 acm_tty_driver->name = "ttyACM",
826 acm_tty_driver->devfs_name = "usb/acm/",
827 acm_tty_driver->major = ACM_TTY_MAJOR,
828 acm_tty_driver->minor_start = 0,
829 acm_tty_driver->type = TTY_DRIVER_TYPE_SERIAL,
830 acm_tty_driver->subtype = SERIAL_TYPE_NORMAL,
831 acm_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS,
832 acm_tty_driver->init_termios = tty_std_termios;
833 acm_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
834 tty_set_operations(acm_tty_driver, &acm_ops);
836 retval = tty_register_driver(acm_tty_driver);
838 put_tty_driver(acm_tty_driver);
842 retval = usb_register(&acm_driver);
844 tty_unregister_driver(acm_tty_driver);
845 put_tty_driver(acm_tty_driver);
849 info(DRIVER_VERSION ":" DRIVER_DESC);
854 static void __exit acm_exit(void)
856 usb_deregister(&acm_driver);
857 tty_unregister_driver(acm_tty_driver);
858 put_tty_driver(acm_tty_driver);
861 module_init(acm_init);
862 module_exit(acm_exit);
864 MODULE_AUTHOR( DRIVER_AUTHOR );
865 MODULE_DESCRIPTION( DRIVER_DESC );
866 MODULE_LICENSE("GPL");