aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse>2006-10-17 13:17:58 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-10-17 17:46:34 -0400
commit964ee1deb3eac802902cd758ddb94b6a95c77987 (patch)
tree31450378b2e8d9748b01906be44982b5a2079f64 /drivers/usb
parent033a3fb980b041c5b1c865d3e9dce9217d1dc94b (diff)
USB: cleanup sierra wireless driver a bit
This saves over 30 lines and fixes a warning from sparse and allows debugging to work dynamically like all other usb-serial drivers. Cc: Kevin Lloyd <linux@sierrawireless.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/sierra.c269
1 files changed, 118 insertions, 151 deletions
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 39799d21b855..6bdb11717e53 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -29,30 +29,6 @@
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
31 31
32/* Function prototypes */
33static int sierra_open(struct usb_serial_port *port, struct file *filp);
34static void sierra_close(struct usb_serial_port *port, struct file *filp);
35static int sierra_startup(struct usb_serial *serial);
36static void sierra_shutdown(struct usb_serial *serial);
37static void sierra_rx_throttle(struct usb_serial_port *port);
38static void sierra_rx_unthrottle(struct usb_serial_port *port);
39static int sierra_write_room(struct usb_serial_port *port);
40
41static void sierra_instat_callback(struct urb *urb);
42
43static int sierra_write(struct usb_serial_port *port,
44 const unsigned char *buf, int count);
45
46static int sierra_chars_in_buffer(struct usb_serial_port *port);
47static int sierra_ioctl(struct usb_serial_port *port, struct file *file,
48 unsigned int cmd, unsigned long arg);
49static void sierra_set_termios(struct usb_serial_port *port,
50 struct termios *old);
51static void sierra_break_ctl(struct usb_serial_port *port, int break_state);
52static int sierra_tiocmget(struct usb_serial_port *port, struct file *file);
53static int sierra_tiocmset(struct usb_serial_port *port, struct file *file,
54 unsigned int set, unsigned int clear);
55static int sierra_send_setup(struct usb_serial_port *port);
56 32
57static struct usb_device_id id_table [] = { 33static struct usb_device_id id_table [] = {
58 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */ 34 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
@@ -68,6 +44,7 @@ static struct usb_device_id id_table [] = {
68 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */ 44 { USB_DEVICE(0x0F3D, 0x0112) }, /* AirPrime/Sierra PC 5220 */
69 { } 45 { }
70}; 46};
47MODULE_DEVICE_TABLE(usb, id_table);
71 48
72static struct usb_device_id id_table_1port [] = { 49static struct usb_device_id id_table_1port [] = {
73 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */ 50 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless AirCard 580 */
@@ -87,88 +64,22 @@ static struct usb_device_id id_table_3port [] = {
87 { } 64 { }
88}; 65};
89 66
90
91MODULE_DEVICE_TABLE(usb, id_table);
92
93static struct usb_driver sierra_driver = { 67static struct usb_driver sierra_driver = {
94 .name = "sierra", 68 .name = "sierra",
95 .probe = usb_serial_probe, 69 .probe = usb_serial_probe,
96 .disconnect = usb_serial_disconnect, 70 .disconnect = usb_serial_disconnect,
97 .id_table = id_table, 71 .id_table = id_table,
98 .no_dynamic_id = 3, 72 .no_dynamic_id = 1,
99}; 73};
100 74
101 75
102//static struct usb_serial_driver *sierra_device;
103
104static struct usb_serial_driver sierra_1port_device = {
105 .driver = {
106 .owner = THIS_MODULE,
107 .name = "sierra1",
108 },
109 .description = "Sierra USB modem (1 port)",
110 .id_table = id_table_1port,
111 .num_interrupt_in = NUM_DONT_CARE,
112 .num_bulk_in = 1,
113 .num_bulk_out = 1,
114 .num_ports = 1,
115 .open = sierra_open,
116 .close = sierra_close,
117 .write = sierra_write,
118 .write_room = sierra_write_room,
119 .chars_in_buffer = sierra_chars_in_buffer,
120 .throttle = sierra_rx_throttle,
121 .unthrottle = sierra_rx_unthrottle,
122 .ioctl = sierra_ioctl,
123 .set_termios = sierra_set_termios,
124 .break_ctl = sierra_break_ctl,
125 .tiocmget = sierra_tiocmget,
126 .tiocmset = sierra_tiocmset,
127 .attach = sierra_startup,
128 .shutdown = sierra_shutdown,
129 .read_int_callback = sierra_instat_callback,
130};
131
132static struct usb_serial_driver sierra_3port_device = {
133 .driver = {
134 .owner = THIS_MODULE,
135 .name = "sierra3",
136 },
137 .description = "Sierra USB modem (3 port)",
138 .id_table = id_table_3port,
139 .num_interrupt_in = NUM_DONT_CARE,
140 .num_bulk_in = 3,
141 .num_bulk_out = 3,
142 .num_ports = 3,
143 .open = sierra_open,
144 .close = sierra_close,
145 .write = sierra_write,
146 .write_room = sierra_write_room,
147 .chars_in_buffer = sierra_chars_in_buffer,
148 .throttle = sierra_rx_throttle,
149 .unthrottle = sierra_rx_unthrottle,
150 .ioctl = sierra_ioctl,
151 .set_termios = sierra_set_termios,
152 .break_ctl = sierra_break_ctl,
153 .tiocmget = sierra_tiocmget,
154 .tiocmset = sierra_tiocmset,
155 .attach = sierra_startup,
156 .shutdown = sierra_shutdown,
157 .read_int_callback = sierra_instat_callback,
158};
159
160#ifdef CONFIG_USB_DEBUG
161static int debug; 76static int debug;
162#else
163#define debug 0
164#endif
165 77
166/* per port private data */ 78/* per port private data */
167 79#define N_IN_URB 4
168#define N_IN_URB 4 80#define N_OUT_URB 1
169#define N_OUT_URB 1 81#define IN_BUFLEN 4096
170#define IN_BUFLEN 4096 82#define OUT_BUFLEN 128
171#define OUT_BUFLEN 128
172 83
173struct sierra_port_private { 84struct sierra_port_private {
174 /* Input endpoints and buffer for this port */ 85 /* Input endpoints and buffer for this port */
@@ -189,44 +100,30 @@ struct sierra_port_private {
189 unsigned long tx_start_time[N_OUT_URB]; 100 unsigned long tx_start_time[N_OUT_URB];
190}; 101};
191 102
192/* Functions used by new usb-serial code. */ 103static int sierra_send_setup(struct usb_serial_port *port)
193static int __init sierra_init(void)
194{ 104{
195 int retval; 105 struct usb_serial *serial = port->serial;
196 retval = usb_serial_register(&sierra_1port_device); 106 struct sierra_port_private *portdata;
197 if (retval)
198 goto failed_1port_device_register;
199 retval = usb_serial_register(&sierra_3port_device);
200 if (retval)
201 goto failed_3port_device_register;
202
203 107
204 retval = usb_register(&sierra_driver); 108 dbg("%s", __FUNCTION__);
205 if (retval)
206 goto failed_driver_register;
207 109
208 info(DRIVER_DESC ": " DRIVER_VERSION); 110 portdata = usb_get_serial_port_data(port);
209 111
210 return 0; 112 if (port->tty) {
113 int val = 0;
114 if (portdata->dtr_state)
115 val |= 0x01;
116 if (portdata->rts_state)
117 val |= 0x02;
211 118
212failed_driver_register: 119 return usb_control_msg(serial->dev,
213 usb_serial_deregister(&sierra_3port_device); 120 usb_rcvctrlpipe(serial->dev, 0),
214failed_3port_device_register: 121 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
215 usb_serial_deregister(&sierra_1port_device); 122 }
216failed_1port_device_register:
217 return retval;
218}
219 123
220static void __exit sierra_exit(void) 124 return 0;
221{
222 usb_deregister (&sierra_driver);
223 usb_serial_deregister(&sierra_1port_device);
224 usb_serial_deregister(&sierra_3port_device);
225} 125}
226 126
227module_init(sierra_init);
228module_exit(sierra_exit);
229
230static void sierra_rx_throttle(struct usb_serial_port *port) 127static void sierra_rx_throttle(struct usb_serial_port *port)
231{ 128{
232 dbg("%s", __FUNCTION__); 129 dbg("%s", __FUNCTION__);
@@ -578,8 +475,8 @@ static void sierra_close(struct usb_serial_port *port, struct file *filp)
578 475
579/* Helper functions used by sierra_setup_urbs */ 476/* Helper functions used by sierra_setup_urbs */
580static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint, 477static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
581 int dir, void *ctx, char *buf, int len, 478 int dir, void *ctx, char *buf, int len,
582 void (*callback)(struct urb *)) 479 usb_complete_t callback)
583{ 480{
584 struct urb *urb; 481 struct urb *urb;
585 482
@@ -629,30 +526,6 @@ static void sierra_setup_urbs(struct usb_serial *serial)
629 } 526 }
630} 527}
631 528
632static int sierra_send_setup(struct usb_serial_port *port)
633{
634 struct usb_serial *serial = port->serial;
635 struct sierra_port_private *portdata;
636
637 dbg("%s", __FUNCTION__);
638
639 portdata = usb_get_serial_port_data(port);
640
641 if (port->tty) {
642 int val = 0;
643 if (portdata->dtr_state)
644 val |= 0x01;
645 if (portdata->rts_state)
646 val |= 0x02;
647
648 return usb_control_msg(serial->dev,
649 usb_rcvctrlpipe(serial->dev, 0),
650 0x22,0x21,val,0,NULL,0,USB_CTRL_SET_TIMEOUT);
651 }
652
653 return 0;
654}
655
656static int sierra_startup(struct usb_serial *serial) 529static int sierra_startup(struct usb_serial *serial)
657{ 530{
658 int i, err; 531 int i, err;
@@ -730,6 +603,100 @@ static void sierra_shutdown(struct usb_serial *serial)
730 } 603 }
731} 604}
732 605
606static struct usb_serial_driver sierra_1port_device = {
607 .driver = {
608 .owner = THIS_MODULE,
609 .name = "sierra1",
610 },
611 .description = "Sierra USB modem (1 port)",
612 .id_table = id_table_1port,
613 .num_interrupt_in = NUM_DONT_CARE,
614 .num_bulk_in = 1,
615 .num_bulk_out = 1,
616 .num_ports = 1,
617 .open = sierra_open,
618 .close = sierra_close,
619 .write = sierra_write,
620 .write_room = sierra_write_room,
621 .chars_in_buffer = sierra_chars_in_buffer,
622 .throttle = sierra_rx_throttle,
623 .unthrottle = sierra_rx_unthrottle,
624 .ioctl = sierra_ioctl,
625 .set_termios = sierra_set_termios,
626 .break_ctl = sierra_break_ctl,
627 .tiocmget = sierra_tiocmget,
628 .tiocmset = sierra_tiocmset,
629 .attach = sierra_startup,
630 .shutdown = sierra_shutdown,
631 .read_int_callback = sierra_instat_callback,
632};
633
634static struct usb_serial_driver sierra_3port_device = {
635 .driver = {
636 .owner = THIS_MODULE,
637 .name = "sierra3",
638 },
639 .description = "Sierra USB modem (3 port)",
640 .id_table = id_table_3port,
641 .num_interrupt_in = NUM_DONT_CARE,
642 .num_bulk_in = 3,
643 .num_bulk_out = 3,
644 .num_ports = 3,
645 .open = sierra_open,
646 .close = sierra_close,
647 .write = sierra_write,
648 .write_room = sierra_write_room,
649 .chars_in_buffer = sierra_chars_in_buffer,
650 .throttle = sierra_rx_throttle,
651 .unthrottle = sierra_rx_unthrottle,
652 .ioctl = sierra_ioctl,
653 .set_termios = sierra_set_termios,
654 .break_ctl = sierra_break_ctl,
655 .tiocmget = sierra_tiocmget,
656 .tiocmset = sierra_tiocmset,
657 .attach = sierra_startup,
658 .shutdown = sierra_shutdown,
659 .read_int_callback = sierra_instat_callback,
660};
661
662/* Functions used by new usb-serial code. */
663static int __init sierra_init(void)
664{
665 int retval;
666 retval = usb_serial_register(&sierra_1port_device);
667 if (retval)
668 goto failed_1port_device_register;
669 retval = usb_serial_register(&sierra_3port_device);
670 if (retval)
671 goto failed_3port_device_register;
672
673
674 retval = usb_register(&sierra_driver);
675 if (retval)
676 goto failed_driver_register;
677
678 info(DRIVER_DESC ": " DRIVER_VERSION);
679
680 return 0;
681
682failed_driver_register:
683 usb_serial_deregister(&sierra_3port_device);
684failed_3port_device_register:
685 usb_serial_deregister(&sierra_1port_device);
686failed_1port_device_register:
687 return retval;
688}
689
690static void __exit sierra_exit(void)
691{
692 usb_deregister (&sierra_driver);
693 usb_serial_deregister(&sierra_1port_device);
694 usb_serial_deregister(&sierra_3port_device);
695}
696
697module_init(sierra_init);
698module_exit(sierra_exit);
699
733MODULE_AUTHOR(DRIVER_AUTHOR); 700MODULE_AUTHOR(DRIVER_AUTHOR);
734MODULE_DESCRIPTION(DRIVER_DESC); 701MODULE_DESCRIPTION(DRIVER_DESC);
735MODULE_VERSION(DRIVER_VERSION); 702MODULE_VERSION(DRIVER_VERSION);