2 * AnyData CDMA Serial USB driver
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/tty.h>
14 #include <linux/module.h>
15 #include <linux/usb.h>
16 #include <linux/usb/serial.h>
18 static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */
22 MODULE_DEVICE_TABLE(usb, id_table);
24 /* if overridden by the user, then use their value for the size of the
25 * read and write urbs */
26 static int buffer_size;
29 static struct usb_driver anydata_driver = {
31 .probe = usb_serial_probe,
32 .disconnect = usb_serial_disconnect,
37 static int anydata_open(struct usb_serial_port *port, struct file *filp)
42 dbg("%s - port %d", __FUNCTION__, port->number);
45 /* override the default buffer sizes */
46 buffer = kmalloc(buffer_size, GFP_KERNEL);
48 dev_err(&port->dev, "%s - out of memory.\n",
52 kfree (port->read_urb->transfer_buffer);
53 port->read_urb->transfer_buffer = buffer;
54 port->read_urb->transfer_buffer_length = buffer_size;
56 buffer = kmalloc(buffer_size, GFP_KERNEL);
58 dev_err(&port->dev, "%s - out of memory.\n",
62 kfree (port->write_urb->transfer_buffer);
63 port->write_urb->transfer_buffer = buffer;
64 port->write_urb->transfer_buffer_length = buffer_size;
65 port->bulk_out_size = buffer_size;
68 /* Start reading from the device */
69 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
70 usb_rcvbulkpipe(port->serial->dev,
71 port->bulk_in_endpointAddress),
72 port->read_urb->transfer_buffer,
73 port->read_urb->transfer_buffer_length,
74 usb_serial_generic_read_bulk_callback, port);
75 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
78 "%s - failed submitting read urb, error %d\n",
79 __FUNCTION__, result);
84 static struct usb_serial_driver anydata_device = {
90 .num_interrupt_in = NUM_DONT_CARE,
91 .num_bulk_in = NUM_DONT_CARE,
92 .num_bulk_out = NUM_DONT_CARE,
97 static int __init anydata_init(void)
101 retval = usb_serial_register(&anydata_device);
104 retval = usb_register(&anydata_driver);
106 usb_serial_deregister(&anydata_device);
110 static void __exit anydata_exit(void)
112 usb_deregister(&anydata_driver);
113 usb_serial_deregister(&anydata_device);
116 module_init(anydata_init);
117 module_exit(anydata_exit);
118 MODULE_LICENSE("GPL");
120 module_param(debug, bool, S_IRUGO | S_IWUSR);
121 MODULE_PARM_DESC(debug, "Debug enabled or not");
122 module_param(buffer_size, int, 0);
123 MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers");