2 * USB ConnectTech WhiteHEAT driver
7 * Copyright (C) 1999 - 2001
8 * Greg Kroah-Hartman (greg@kroah.com)
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * See Documentation/usb/usb-serial.txt for more information on using this
19 #include <linux/kernel.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/slab.h>
23 #include <linux/tty.h>
24 #include <linux/tty_driver.h>
25 #include <linux/tty_flip.h>
26 #include <linux/module.h>
27 #include <linux/spinlock.h>
28 #include <linux/mutex.h>
29 #include <linux/uaccess.h>
30 #include <asm/termbits.h>
31 #include <linux/usb.h>
32 #include <linux/serial_reg.h>
33 #include <linux/serial.h>
34 #include <linux/usb/serial.h>
35 #include <linux/firmware.h>
36 #include <linux/ihex.h>
37 #include "whiteheat.h" /* WhiteHEAT specific commands */
48 #define DRIVER_VERSION "v2.0"
49 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Stuart MacDonald <stuartm@connecttech.com>"
50 #define DRIVER_DESC "USB ConnectTech WhiteHEAT driver"
52 #define CONNECT_TECH_VENDOR_ID 0x0710
53 #define CONNECT_TECH_FAKE_WHITE_HEAT_ID 0x0001
54 #define CONNECT_TECH_WHITE_HEAT_ID 0x8001
57 ID tables for whiteheat are unusual, because we want to different
58 things for different versions of the device. Eventually, this
59 will be doable from a single table. But, for now, we define two
60 separate ID tables, and then a third table that combines them
61 just for the purpose of exporting the autoloading information.
63 static const struct usb_device_id id_table_std
[] = {
64 { USB_DEVICE(CONNECT_TECH_VENDOR_ID
, CONNECT_TECH_WHITE_HEAT_ID
) },
65 { } /* Terminating entry */
68 static const struct usb_device_id id_table_prerenumeration
[] = {
69 { USB_DEVICE(CONNECT_TECH_VENDOR_ID
, CONNECT_TECH_FAKE_WHITE_HEAT_ID
) },
70 { } /* Terminating entry */
73 static const struct usb_device_id id_table_combined
[] = {
74 { USB_DEVICE(CONNECT_TECH_VENDOR_ID
, CONNECT_TECH_WHITE_HEAT_ID
) },
75 { USB_DEVICE(CONNECT_TECH_VENDOR_ID
, CONNECT_TECH_FAKE_WHITE_HEAT_ID
) },
76 { } /* Terminating entry */
79 MODULE_DEVICE_TABLE(usb
, id_table_combined
);
81 static struct usb_driver whiteheat_driver
= {
83 .probe
= usb_serial_probe
,
84 .disconnect
= usb_serial_disconnect
,
85 .id_table
= id_table_combined
,
89 /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
90 static int whiteheat_firmware_download(struct usb_serial
*serial
,
91 const struct usb_device_id
*id
);
92 static int whiteheat_firmware_attach(struct usb_serial
*serial
);
94 /* function prototypes for the Connect Tech WhiteHEAT serial converter */
95 static int whiteheat_attach(struct usb_serial
*serial
);
96 static void whiteheat_release(struct usb_serial
*serial
);
97 static int whiteheat_open(struct tty_struct
*tty
,
98 struct usb_serial_port
*port
);
99 static void whiteheat_close(struct usb_serial_port
*port
);
100 static int whiteheat_write(struct tty_struct
*tty
,
101 struct usb_serial_port
*port
,
102 const unsigned char *buf
, int count
);
103 static int whiteheat_write_room(struct tty_struct
*tty
);
104 static int whiteheat_ioctl(struct tty_struct
*tty
,
105 unsigned int cmd
, unsigned long arg
);
106 static void whiteheat_set_termios(struct tty_struct
*tty
,
107 struct usb_serial_port
*port
, struct ktermios
*old
);
108 static int whiteheat_tiocmget(struct tty_struct
*tty
);
109 static int whiteheat_tiocmset(struct tty_struct
*tty
,
110 unsigned int set
, unsigned int clear
);
111 static void whiteheat_break_ctl(struct tty_struct
*tty
, int break_state
);
112 static int whiteheat_chars_in_buffer(struct tty_struct
*tty
);
113 static void whiteheat_throttle(struct tty_struct
*tty
);
114 static void whiteheat_unthrottle(struct tty_struct
*tty
);
115 static void whiteheat_read_callback(struct urb
*urb
);
116 static void whiteheat_write_callback(struct urb
*urb
);
118 static struct usb_serial_driver whiteheat_fake_device
= {
120 .owner
= THIS_MODULE
,
121 .name
= "whiteheatnofirm",
123 .description
= "Connect Tech - WhiteHEAT - (prerenumeration)",
124 .usb_driver
= &whiteheat_driver
,
125 .id_table
= id_table_prerenumeration
,
127 .probe
= whiteheat_firmware_download
,
128 .attach
= whiteheat_firmware_attach
,
131 static struct usb_serial_driver whiteheat_device
= {
133 .owner
= THIS_MODULE
,
136 .description
= "Connect Tech - WhiteHEAT",
137 .usb_driver
= &whiteheat_driver
,
138 .id_table
= id_table_std
,
140 .attach
= whiteheat_attach
,
141 .release
= whiteheat_release
,
142 .open
= whiteheat_open
,
143 .close
= whiteheat_close
,
144 .write
= whiteheat_write
,
145 .write_room
= whiteheat_write_room
,
146 .ioctl
= whiteheat_ioctl
,
147 .set_termios
= whiteheat_set_termios
,
148 .break_ctl
= whiteheat_break_ctl
,
149 .tiocmget
= whiteheat_tiocmget
,
150 .tiocmset
= whiteheat_tiocmset
,
151 .chars_in_buffer
= whiteheat_chars_in_buffer
,
152 .throttle
= whiteheat_throttle
,
153 .unthrottle
= whiteheat_unthrottle
,
154 .read_bulk_callback
= whiteheat_read_callback
,
155 .write_bulk_callback
= whiteheat_write_callback
,
159 struct whiteheat_command_private
{
162 __u8 command_finished
;
163 wait_queue_head_t wait_command
; /* for handling sleeping whilst
164 waiting for a command to
166 __u8 result_buffer
[64];
170 #define THROTTLED 0x01
171 #define ACTUALLY_THROTTLED 0x02
173 static int urb_pool_size
= 8;
175 struct whiteheat_urb_wrap
{
176 struct list_head list
;
180 struct whiteheat_private
{
183 __u8 mcr
; /* FIXME: no locking on mcr */
184 struct list_head rx_urbs_free
;
185 struct list_head rx_urbs_submitted
;
186 struct list_head rx_urb_q
;
187 struct work_struct rx_work
;
188 struct usb_serial_port
*port
;
189 struct list_head tx_urbs_free
;
190 struct list_head tx_urbs_submitted
;
191 struct mutex deathwarrant
;
195 /* local function prototypes */
196 static int start_command_port(struct usb_serial
*serial
);
197 static void stop_command_port(struct usb_serial
*serial
);
198 static void command_port_write_callback(struct urb
*urb
);
199 static void command_port_read_callback(struct urb
*urb
);
201 static int start_port_read(struct usb_serial_port
*port
);
202 static struct whiteheat_urb_wrap
*urb_to_wrap(struct urb
*urb
,
203 struct list_head
*head
);
204 static struct list_head
*list_first(struct list_head
*head
);
205 static void rx_data_softint(struct work_struct
*work
);
207 static int firm_send_command(struct usb_serial_port
*port
, __u8 command
,
208 __u8
*data
, __u8 datasize
);
209 static int firm_open(struct usb_serial_port
*port
);
210 static int firm_close(struct usb_serial_port
*port
);
211 static void firm_setup_port(struct tty_struct
*tty
);
212 static int firm_set_rts(struct usb_serial_port
*port
, __u8 onoff
);
213 static int firm_set_dtr(struct usb_serial_port
*port
, __u8 onoff
);
214 static int firm_set_break(struct usb_serial_port
*port
, __u8 onoff
);
215 static int firm_purge(struct usb_serial_port
*port
, __u8 rxtx
);
216 static int firm_get_dtr_rts(struct usb_serial_port
*port
);
217 static int firm_report_tx_done(struct usb_serial_port
*port
);
220 #define COMMAND_PORT 4
221 #define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */
222 #define COMMAND_TIMEOUT_MS 2000
223 #define CLOSING_DELAY (30 * HZ)
226 /*****************************************************************************
227 * Connect Tech's White Heat prerenumeration driver functions
228 *****************************************************************************/
230 /* steps to download the firmware to the WhiteHEAT device:
231 - hold the reset (by writing to the reset bit of the CPUCS register)
232 - download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
233 - release the reset (by writing to the CPUCS register)
234 - download the WH.HEX file for all addresses greater than 0x1b3f using
235 VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
237 - download the WH.HEX file for all addresses less than 0x1b40 using
238 VENDOR_REQUEST_ANCHOR_LOAD
240 - device renumerated itself and comes up as new device id with all
241 firmware download completed.
243 static int whiteheat_firmware_download(struct usb_serial
*serial
,
244 const struct usb_device_id
*id
)
246 int response
, ret
= -ENOENT
;
247 const struct firmware
*loader_fw
= NULL
, *firmware_fw
= NULL
;
248 const struct ihex_binrec
*record
;
252 if (request_ihex_firmware(&firmware_fw
, "whiteheat.fw",
253 &serial
->dev
->dev
)) {
254 dev_err(&serial
->dev
->dev
,
255 "%s - request \"whiteheat.fw\" failed\n", __func__
);
258 if (request_ihex_firmware(&loader_fw
, "whiteheat_loader.fw",
259 &serial
->dev
->dev
)) {
260 dev_err(&serial
->dev
->dev
,
261 "%s - request \"whiteheat_loader.fw\" failed\n",
266 response
= ezusb_set_reset (serial
, 1);
268 record
= (const struct ihex_binrec
*)loader_fw
->data
;
270 response
= ezusb_writememory (serial
, be32_to_cpu(record
->addr
),
271 (unsigned char *)record
->data
,
272 be16_to_cpu(record
->len
), 0xa0);
274 dev_err(&serial
->dev
->dev
, "%s - ezusb_writememory "
275 "failed for loader (%d %04X %p %d)\n",
276 __func__
, response
, be32_to_cpu(record
->addr
),
277 record
->data
, be16_to_cpu(record
->len
));
280 record
= ihex_next_binrec(record
);
283 response
= ezusb_set_reset(serial
, 0);
285 record
= (const struct ihex_binrec
*)firmware_fw
->data
;
286 while (record
&& be32_to_cpu(record
->addr
) < 0x1b40)
287 record
= ihex_next_binrec(record
);
289 response
= ezusb_writememory (serial
, be32_to_cpu(record
->addr
),
290 (unsigned char *)record
->data
,
291 be16_to_cpu(record
->len
), 0xa3);
293 dev_err(&serial
->dev
->dev
, "%s - ezusb_writememory "
294 "failed for first firmware step "
295 "(%d %04X %p %d)\n", __func__
, response
,
296 be32_to_cpu(record
->addr
), record
->data
,
297 be16_to_cpu(record
->len
));
303 response
= ezusb_set_reset(serial
, 1);
305 record
= (const struct ihex_binrec
*)firmware_fw
->data
;
306 while (record
&& be32_to_cpu(record
->addr
) < 0x1b40) {
307 response
= ezusb_writememory (serial
, be32_to_cpu(record
->addr
),
308 (unsigned char *)record
->data
,
309 be16_to_cpu(record
->len
), 0xa0);
311 dev_err(&serial
->dev
->dev
, "%s - ezusb_writememory "
312 "failed for second firmware step "
313 "(%d %04X %p %d)\n", __func__
, response
,
314 be32_to_cpu(record
->addr
), record
->data
,
315 be16_to_cpu(record
->len
));
321 response
= ezusb_set_reset (serial
, 0);
323 release_firmware(loader_fw
);
324 release_firmware(firmware_fw
);
329 static int whiteheat_firmware_attach(struct usb_serial
*serial
)
331 /* We want this device to fail to have a driver assigned to it */
336 /*****************************************************************************
337 * Connect Tech's White Heat serial driver functions
338 *****************************************************************************/
339 static int whiteheat_attach(struct usb_serial
*serial
)
341 struct usb_serial_port
*command_port
;
342 struct whiteheat_command_private
*command_info
;
343 struct usb_serial_port
*port
;
344 struct whiteheat_private
*info
;
345 struct whiteheat_hw_info
*hw_info
;
355 struct whiteheat_urb_wrap
*wrap
;
356 struct list_head
*tmp
;
358 command_port
= serial
->port
[COMMAND_PORT
];
360 pipe
= usb_sndbulkpipe(serial
->dev
,
361 command_port
->bulk_out_endpointAddress
);
362 command
= kmalloc(2, GFP_KERNEL
);
364 goto no_command_buffer
;
365 command
[0] = WHITEHEAT_GET_HW_INFO
;
368 result
= kmalloc(sizeof(*hw_info
) + 1, GFP_KERNEL
);
370 goto no_result_buffer
;
372 * When the module is reloaded the firmware is still there and
373 * the endpoints are still in the usb core unchanged. This is the
374 * unlinking bug in disguise. Same for the call below.
376 usb_clear_halt(serial
->dev
, pipe
);
377 ret
= usb_bulk_msg(serial
->dev
, pipe
, command
, 2,
378 &alen
, COMMAND_TIMEOUT_MS
);
380 dev_err(&serial
->dev
->dev
, "%s: Couldn't send command [%d]\n",
381 serial
->type
->description
, ret
);
383 } else if (alen
!= 2) {
384 dev_err(&serial
->dev
->dev
, "%s: Send command incomplete [%d]\n",
385 serial
->type
->description
, alen
);
389 pipe
= usb_rcvbulkpipe(serial
->dev
,
390 command_port
->bulk_in_endpointAddress
);
391 /* See the comment on the usb_clear_halt() above */
392 usb_clear_halt(serial
->dev
, pipe
);
393 ret
= usb_bulk_msg(serial
->dev
, pipe
, result
,
394 sizeof(*hw_info
) + 1, &alen
, COMMAND_TIMEOUT_MS
);
396 dev_err(&serial
->dev
->dev
, "%s: Couldn't get results [%d]\n",
397 serial
->type
->description
, ret
);
399 } else if (alen
!= sizeof(*hw_info
) + 1) {
400 dev_err(&serial
->dev
->dev
, "%s: Get results incomplete [%d]\n",
401 serial
->type
->description
, alen
);
403 } else if (result
[0] != command
[0]) {
404 dev_err(&serial
->dev
->dev
, "%s: Command failed [%d]\n",
405 serial
->type
->description
, result
[0]);
409 hw_info
= (struct whiteheat_hw_info
*)&result
[1];
411 dev_info(&serial
->dev
->dev
, "%s: Driver %s: Firmware v%d.%02d\n",
412 serial
->type
->description
, DRIVER_VERSION
,
413 hw_info
->sw_major_rev
, hw_info
->sw_minor_rev
);
415 for (i
= 0; i
< serial
->num_ports
; i
++) {
416 port
= serial
->port
[i
];
418 info
= kmalloc(sizeof(struct whiteheat_private
), GFP_KERNEL
);
421 "%s: Out of memory for port structures\n",
422 serial
->type
->description
);
426 spin_lock_init(&info
->lock
);
427 mutex_init(&info
->deathwarrant
);
430 INIT_WORK(&info
->rx_work
, rx_data_softint
);
433 INIT_LIST_HEAD(&info
->rx_urbs_free
);
434 INIT_LIST_HEAD(&info
->rx_urbs_submitted
);
435 INIT_LIST_HEAD(&info
->rx_urb_q
);
436 INIT_LIST_HEAD(&info
->tx_urbs_free
);
437 INIT_LIST_HEAD(&info
->tx_urbs_submitted
);
439 for (j
= 0; j
< urb_pool_size
; j
++) {
440 urb
= usb_alloc_urb(0, GFP_KERNEL
);
442 dev_err(&port
->dev
, "No free urbs available\n");
445 buf_size
= port
->read_urb
->transfer_buffer_length
;
446 urb
->transfer_buffer
= kmalloc(buf_size
, GFP_KERNEL
);
447 if (!urb
->transfer_buffer
) {
449 "Couldn't allocate urb buffer\n");
452 wrap
= kmalloc(sizeof(*wrap
), GFP_KERNEL
);
455 "Couldn't allocate urb wrapper\n");
458 usb_fill_bulk_urb(urb
, serial
->dev
,
459 usb_rcvbulkpipe(serial
->dev
,
460 port
->bulk_in_endpointAddress
),
461 urb
->transfer_buffer
, buf_size
,
462 whiteheat_read_callback
, port
);
464 list_add(&wrap
->list
, &info
->rx_urbs_free
);
466 urb
= usb_alloc_urb(0, GFP_KERNEL
);
468 dev_err(&port
->dev
, "No free urbs available\n");
471 buf_size
= port
->write_urb
->transfer_buffer_length
;
472 urb
->transfer_buffer
= kmalloc(buf_size
, GFP_KERNEL
);
473 if (!urb
->transfer_buffer
) {
475 "Couldn't allocate urb buffer\n");
478 wrap
= kmalloc(sizeof(*wrap
), GFP_KERNEL
);
481 "Couldn't allocate urb wrapper\n");
484 usb_fill_bulk_urb(urb
, serial
->dev
,
485 usb_sndbulkpipe(serial
->dev
,
486 port
->bulk_out_endpointAddress
),
487 urb
->transfer_buffer
, buf_size
,
488 whiteheat_write_callback
, port
);
490 list_add(&wrap
->list
, &info
->tx_urbs_free
);
493 usb_set_serial_port_data(port
, info
);
496 command_info
= kmalloc(sizeof(struct whiteheat_command_private
),
498 if (command_info
== NULL
) {
499 dev_err(&serial
->dev
->dev
,
500 "%s: Out of memory for port structures\n",
501 serial
->type
->description
);
502 goto no_command_private
;
505 mutex_init(&command_info
->mutex
);
506 command_info
->port_running
= 0;
507 init_waitqueue_head(&command_info
->wait_command
);
508 usb_set_serial_port_data(command_port
, command_info
);
509 command_port
->write_urb
->complete
= command_port_write_callback
;
510 command_port
->read_urb
->complete
= command_port_read_callback
;
517 /* Firmware likely not running */
518 dev_err(&serial
->dev
->dev
,
519 "%s: Unable to retrieve firmware version, try replugging\n",
520 serial
->type
->description
);
521 dev_err(&serial
->dev
->dev
,
522 "%s: If the firmware is not running (status led not blinking)\n",
523 serial
->type
->description
);
524 dev_err(&serial
->dev
->dev
,
525 "%s: please contact support@connecttech.com\n",
526 serial
->type
->description
);
531 for (i
= serial
->num_ports
- 1; i
>= 0; i
--) {
532 port
= serial
->port
[i
];
533 info
= usb_get_serial_port_data(port
);
534 for (j
= urb_pool_size
- 1; j
>= 0; j
--) {
535 tmp
= list_first(&info
->tx_urbs_free
);
537 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
541 kfree(urb
->transfer_buffer
);
545 tmp
= list_first(&info
->rx_urbs_free
);
547 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
551 kfree(urb
->transfer_buffer
);
569 static void whiteheat_release(struct usb_serial
*serial
)
571 struct usb_serial_port
*command_port
;
572 struct usb_serial_port
*port
;
573 struct whiteheat_private
*info
;
574 struct whiteheat_urb_wrap
*wrap
;
576 struct list_head
*tmp
;
577 struct list_head
*tmp2
;
582 /* free up our private data for our command port */
583 command_port
= serial
->port
[COMMAND_PORT
];
584 kfree(usb_get_serial_port_data(command_port
));
586 for (i
= 0; i
< serial
->num_ports
; i
++) {
587 port
= serial
->port
[i
];
588 info
= usb_get_serial_port_data(port
);
589 list_for_each_safe(tmp
, tmp2
, &info
->rx_urbs_free
) {
591 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
594 kfree(urb
->transfer_buffer
);
597 list_for_each_safe(tmp
, tmp2
, &info
->tx_urbs_free
) {
599 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
602 kfree(urb
->transfer_buffer
);
609 static int whiteheat_open(struct tty_struct
*tty
, struct usb_serial_port
*port
)
613 dbg("%s - port %d", __func__
, port
->number
);
615 retval
= start_command_port(port
->serial
);
620 tty
->low_latency
= 1;
622 /* send an open port command */
623 retval
= firm_open(port
);
625 stop_command_port(port
->serial
);
629 retval
= firm_purge(port
, WHITEHEAT_PURGE_RX
| WHITEHEAT_PURGE_TX
);
632 stop_command_port(port
->serial
);
637 firm_setup_port(tty
);
639 /* Work around HCD bugs */
640 usb_clear_halt(port
->serial
->dev
, port
->read_urb
->pipe
);
641 usb_clear_halt(port
->serial
->dev
, port
->write_urb
->pipe
);
643 /* Start reading from the device */
644 retval
= start_port_read(port
);
647 "%s - failed submitting read urb, error %d\n",
650 stop_command_port(port
->serial
);
655 dbg("%s - exit, retval = %d", __func__
, retval
);
660 static void whiteheat_close(struct usb_serial_port
*port
)
662 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
663 struct whiteheat_urb_wrap
*wrap
;
665 struct list_head
*tmp
;
666 struct list_head
*tmp2
;
668 dbg("%s - port %d", __func__
, port
->number
);
670 firm_report_tx_done(port
);
673 /* shutdown our bulk reads and writes */
674 mutex_lock(&info
->deathwarrant
);
675 spin_lock_irq(&info
->lock
);
676 list_for_each_safe(tmp
, tmp2
, &info
->rx_urbs_submitted
) {
677 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
680 spin_unlock_irq(&info
->lock
);
682 spin_lock_irq(&info
->lock
);
683 list_add(tmp
, &info
->rx_urbs_free
);
685 list_for_each_safe(tmp
, tmp2
, &info
->rx_urb_q
)
686 list_move(tmp
, &info
->rx_urbs_free
);
687 list_for_each_safe(tmp
, tmp2
, &info
->tx_urbs_submitted
) {
688 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
691 spin_unlock_irq(&info
->lock
);
693 spin_lock_irq(&info
->lock
);
694 list_add(tmp
, &info
->tx_urbs_free
);
696 spin_unlock_irq(&info
->lock
);
697 mutex_unlock(&info
->deathwarrant
);
698 stop_command_port(port
->serial
);
702 static int whiteheat_write(struct tty_struct
*tty
,
703 struct usb_serial_port
*port
, const unsigned char *buf
, int count
)
705 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
706 struct whiteheat_urb_wrap
*wrap
;
712 struct list_head
*tmp
;
714 dbg("%s - port %d", __func__
, port
->number
);
717 dbg("%s - write request of 0 bytes", __func__
);
722 spin_lock_irqsave(&info
->lock
, flags
);
723 if (list_empty(&info
->tx_urbs_free
)) {
724 spin_unlock_irqrestore(&info
->lock
, flags
);
727 tmp
= list_first(&info
->tx_urbs_free
);
729 spin_unlock_irqrestore(&info
->lock
, flags
);
731 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
733 bytes
= (count
> port
->bulk_out_size
) ?
734 port
->bulk_out_size
: count
;
735 memcpy(urb
->transfer_buffer
, buf
+ sent
, bytes
);
737 usb_serial_debug_data(debug
, &port
->dev
,
738 __func__
, bytes
, urb
->transfer_buffer
);
740 urb
->transfer_buffer_length
= bytes
;
741 result
= usb_submit_urb(urb
, GFP_ATOMIC
);
744 "%s - failed submitting write urb, error %d\n",
747 spin_lock_irqsave(&info
->lock
, flags
);
748 list_add(tmp
, &info
->tx_urbs_free
);
749 spin_unlock_irqrestore(&info
->lock
, flags
);
754 spin_lock_irqsave(&info
->lock
, flags
);
755 list_add(tmp
, &info
->tx_urbs_submitted
);
756 spin_unlock_irqrestore(&info
->lock
, flags
);
763 static int whiteheat_write_room(struct tty_struct
*tty
)
765 struct usb_serial_port
*port
= tty
->driver_data
;
766 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
767 struct list_head
*tmp
;
771 dbg("%s - port %d", __func__
, port
->number
);
773 spin_lock_irqsave(&info
->lock
, flags
);
774 list_for_each(tmp
, &info
->tx_urbs_free
)
776 spin_unlock_irqrestore(&info
->lock
, flags
);
777 room
*= port
->bulk_out_size
;
779 dbg("%s - returns %d", __func__
, room
);
783 static int whiteheat_tiocmget(struct tty_struct
*tty
)
785 struct usb_serial_port
*port
= tty
->driver_data
;
786 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
787 unsigned int modem_signals
= 0;
789 dbg("%s - port %d", __func__
, port
->number
);
791 firm_get_dtr_rts(port
);
792 if (info
->mcr
& UART_MCR_DTR
)
793 modem_signals
|= TIOCM_DTR
;
794 if (info
->mcr
& UART_MCR_RTS
)
795 modem_signals
|= TIOCM_RTS
;
797 return modem_signals
;
800 static int whiteheat_tiocmset(struct tty_struct
*tty
,
801 unsigned int set
, unsigned int clear
)
803 struct usb_serial_port
*port
= tty
->driver_data
;
804 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
806 dbg("%s - port %d", __func__
, port
->number
);
809 info
->mcr
|= UART_MCR_RTS
;
811 info
->mcr
|= UART_MCR_DTR
;
813 if (clear
& TIOCM_RTS
)
814 info
->mcr
&= ~UART_MCR_RTS
;
815 if (clear
& TIOCM_DTR
)
816 info
->mcr
&= ~UART_MCR_DTR
;
818 firm_set_dtr(port
, info
->mcr
& UART_MCR_DTR
);
819 firm_set_rts(port
, info
->mcr
& UART_MCR_RTS
);
824 static int whiteheat_ioctl(struct tty_struct
*tty
,
825 unsigned int cmd
, unsigned long arg
)
827 struct usb_serial_port
*port
= tty
->driver_data
;
828 struct serial_struct serstruct
;
829 void __user
*user_arg
= (void __user
*)arg
;
831 dbg("%s - port %d, cmd 0x%.4x", __func__
, port
->number
, cmd
);
835 memset(&serstruct
, 0, sizeof(serstruct
));
836 serstruct
.type
= PORT_16654
;
837 serstruct
.line
= port
->serial
->minor
;
838 serstruct
.port
= port
->number
;
839 serstruct
.flags
= ASYNC_SKIP_TEST
| ASYNC_AUTO_IRQ
;
840 serstruct
.xmit_fifo_size
= port
->bulk_out_size
;
841 serstruct
.custom_divisor
= 0;
842 serstruct
.baud_base
= 460800;
843 serstruct
.close_delay
= CLOSING_DELAY
;
844 serstruct
.closing_wait
= CLOSING_DELAY
;
846 if (copy_to_user(user_arg
, &serstruct
, sizeof(serstruct
)))
857 static void whiteheat_set_termios(struct tty_struct
*tty
,
858 struct usb_serial_port
*port
, struct ktermios
*old_termios
)
860 firm_setup_port(tty
);
863 static void whiteheat_break_ctl(struct tty_struct
*tty
, int break_state
)
865 struct usb_serial_port
*port
= tty
->driver_data
;
866 firm_set_break(port
, break_state
);
870 static int whiteheat_chars_in_buffer(struct tty_struct
*tty
)
872 struct usb_serial_port
*port
= tty
->driver_data
;
873 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
874 struct list_head
*tmp
;
875 struct whiteheat_urb_wrap
*wrap
;
879 dbg("%s - port %d", __func__
, port
->number
);
881 spin_lock_irqsave(&info
->lock
, flags
);
882 list_for_each(tmp
, &info
->tx_urbs_submitted
) {
883 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
884 chars
+= wrap
->urb
->transfer_buffer_length
;
886 spin_unlock_irqrestore(&info
->lock
, flags
);
888 dbg("%s - returns %d", __func__
, chars
);
893 static void whiteheat_throttle(struct tty_struct
*tty
)
895 struct usb_serial_port
*port
= tty
->driver_data
;
896 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
898 dbg("%s - port %d", __func__
, port
->number
);
900 spin_lock_irq(&info
->lock
);
901 info
->flags
|= THROTTLED
;
902 spin_unlock_irq(&info
->lock
);
906 static void whiteheat_unthrottle(struct tty_struct
*tty
)
908 struct usb_serial_port
*port
= tty
->driver_data
;
909 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
910 int actually_throttled
;
912 dbg("%s - port %d", __func__
, port
->number
);
914 spin_lock_irq(&info
->lock
);
915 actually_throttled
= info
->flags
& ACTUALLY_THROTTLED
;
916 info
->flags
&= ~(THROTTLED
| ACTUALLY_THROTTLED
);
917 spin_unlock_irq(&info
->lock
);
919 if (actually_throttled
)
920 rx_data_softint(&info
->rx_work
);
924 /*****************************************************************************
925 * Connect Tech's White Heat callback routines
926 *****************************************************************************/
927 static void command_port_write_callback(struct urb
*urb
)
929 int status
= urb
->status
;
934 dbg("nonzero urb status: %d", status
);
940 static void command_port_read_callback(struct urb
*urb
)
942 struct usb_serial_port
*command_port
= urb
->context
;
943 struct whiteheat_command_private
*command_info
;
944 int status
= urb
->status
;
945 unsigned char *data
= urb
->transfer_buffer
;
950 command_info
= usb_get_serial_port_data(command_port
);
952 dbg("%s - command_info is NULL, exiting.", __func__
);
956 dbg("%s - nonzero urb status: %d", __func__
, status
);
957 if (status
!= -ENOENT
)
958 command_info
->command_finished
= WHITEHEAT_CMD_FAILURE
;
959 wake_up(&command_info
->wait_command
);
963 usb_serial_debug_data(debug
, &command_port
->dev
,
964 __func__
, urb
->actual_length
, data
);
966 if (data
[0] == WHITEHEAT_CMD_COMPLETE
) {
967 command_info
->command_finished
= WHITEHEAT_CMD_COMPLETE
;
968 wake_up(&command_info
->wait_command
);
969 } else if (data
[0] == WHITEHEAT_CMD_FAILURE
) {
970 command_info
->command_finished
= WHITEHEAT_CMD_FAILURE
;
971 wake_up(&command_info
->wait_command
);
972 } else if (data
[0] == WHITEHEAT_EVENT
) {
973 /* These are unsolicited reports from the firmware, hence no
974 waiting command to wakeup */
975 dbg("%s - event received", __func__
);
976 } else if (data
[0] == WHITEHEAT_GET_DTR_RTS
) {
977 memcpy(command_info
->result_buffer
, &data
[1],
978 urb
->actual_length
- 1);
979 command_info
->command_finished
= WHITEHEAT_CMD_COMPLETE
;
980 wake_up(&command_info
->wait_command
);
982 dbg("%s - bad reply from firmware", __func__
);
984 /* Continue trying to always read */
985 result
= usb_submit_urb(command_port
->read_urb
, GFP_ATOMIC
);
987 dbg("%s - failed resubmitting read urb, error %d",
992 static void whiteheat_read_callback(struct urb
*urb
)
994 struct usb_serial_port
*port
= urb
->context
;
995 struct whiteheat_urb_wrap
*wrap
;
996 unsigned char *data
= urb
->transfer_buffer
;
997 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
998 int status
= urb
->status
;
1000 dbg("%s - port %d", __func__
, port
->number
);
1002 spin_lock(&info
->lock
);
1003 wrap
= urb_to_wrap(urb
, &info
->rx_urbs_submitted
);
1005 spin_unlock(&info
->lock
);
1006 dev_err(&port
->dev
, "%s - Not my urb!\n", __func__
);
1009 list_del(&wrap
->list
);
1010 spin_unlock(&info
->lock
);
1013 dbg("%s - nonzero read bulk status received: %d",
1015 spin_lock(&info
->lock
);
1016 list_add(&wrap
->list
, &info
->rx_urbs_free
);
1017 spin_unlock(&info
->lock
);
1021 usb_serial_debug_data(debug
, &port
->dev
,
1022 __func__
, urb
->actual_length
, data
);
1024 spin_lock(&info
->lock
);
1025 list_add_tail(&wrap
->list
, &info
->rx_urb_q
);
1026 if (info
->flags
& THROTTLED
) {
1027 info
->flags
|= ACTUALLY_THROTTLED
;
1028 spin_unlock(&info
->lock
);
1031 spin_unlock(&info
->lock
);
1033 schedule_work(&info
->rx_work
);
1037 static void whiteheat_write_callback(struct urb
*urb
)
1039 struct usb_serial_port
*port
= urb
->context
;
1040 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
1041 struct whiteheat_urb_wrap
*wrap
;
1042 int status
= urb
->status
;
1044 dbg("%s - port %d", __func__
, port
->number
);
1046 spin_lock(&info
->lock
);
1047 wrap
= urb_to_wrap(urb
, &info
->tx_urbs_submitted
);
1049 spin_unlock(&info
->lock
);
1050 dev_err(&port
->dev
, "%s - Not my urb!\n", __func__
);
1053 list_move(&wrap
->list
, &info
->tx_urbs_free
);
1054 spin_unlock(&info
->lock
);
1057 dbg("%s - nonzero write bulk status received: %d",
1062 usb_serial_port_softint(port
);
1066 /*****************************************************************************
1067 * Connect Tech's White Heat firmware interface
1068 *****************************************************************************/
1069 static int firm_send_command(struct usb_serial_port
*port
, __u8 command
,
1070 __u8
*data
, __u8 datasize
)
1072 struct usb_serial_port
*command_port
;
1073 struct whiteheat_command_private
*command_info
;
1074 struct whiteheat_private
*info
;
1075 __u8
*transfer_buffer
;
1079 dbg("%s - command %d", __func__
, command
);
1081 command_port
= port
->serial
->port
[COMMAND_PORT
];
1082 command_info
= usb_get_serial_port_data(command_port
);
1083 mutex_lock(&command_info
->mutex
);
1084 command_info
->command_finished
= false;
1086 transfer_buffer
= (__u8
*)command_port
->write_urb
->transfer_buffer
;
1087 transfer_buffer
[0] = command
;
1088 memcpy(&transfer_buffer
[1], data
, datasize
);
1089 command_port
->write_urb
->transfer_buffer_length
= datasize
+ 1;
1090 retval
= usb_submit_urb(command_port
->write_urb
, GFP_NOIO
);
1092 dbg("%s - submit urb failed", __func__
);
1096 /* wait for the command to complete */
1097 t
= wait_event_timeout(command_info
->wait_command
,
1098 (bool)command_info
->command_finished
, COMMAND_TIMEOUT
);
1100 usb_kill_urb(command_port
->write_urb
);
1102 if (command_info
->command_finished
== false) {
1103 dbg("%s - command timed out.", __func__
);
1104 retval
= -ETIMEDOUT
;
1108 if (command_info
->command_finished
== WHITEHEAT_CMD_FAILURE
) {
1109 dbg("%s - command failed.", __func__
);
1114 if (command_info
->command_finished
== WHITEHEAT_CMD_COMPLETE
) {
1115 dbg("%s - command completed.", __func__
);
1117 case WHITEHEAT_GET_DTR_RTS
:
1118 info
= usb_get_serial_port_data(port
);
1119 memcpy(&info
->mcr
, command_info
->result_buffer
,
1120 sizeof(struct whiteheat_dr_info
));
1125 mutex_unlock(&command_info
->mutex
);
1130 static int firm_open(struct usb_serial_port
*port
)
1132 struct whiteheat_simple open_command
;
1134 open_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1135 return firm_send_command(port
, WHITEHEAT_OPEN
,
1136 (__u8
*)&open_command
, sizeof(open_command
));
1140 static int firm_close(struct usb_serial_port
*port
)
1142 struct whiteheat_simple close_command
;
1144 close_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1145 return firm_send_command(port
, WHITEHEAT_CLOSE
,
1146 (__u8
*)&close_command
, sizeof(close_command
));
1150 static void firm_setup_port(struct tty_struct
*tty
)
1152 struct usb_serial_port
*port
= tty
->driver_data
;
1153 struct whiteheat_port_settings port_settings
;
1154 unsigned int cflag
= tty
->termios
->c_cflag
;
1156 port_settings
.port
= port
->number
+ 1;
1158 /* get the byte size */
1159 switch (cflag
& CSIZE
) {
1160 case CS5
: port_settings
.bits
= 5; break;
1161 case CS6
: port_settings
.bits
= 6; break;
1162 case CS7
: port_settings
.bits
= 7; break;
1164 case CS8
: port_settings
.bits
= 8; break;
1166 dbg("%s - data bits = %d", __func__
, port_settings
.bits
);
1168 /* determine the parity */
1172 port_settings
.parity
= WHITEHEAT_PAR_MARK
;
1174 port_settings
.parity
= WHITEHEAT_PAR_SPACE
;
1177 port_settings
.parity
= WHITEHEAT_PAR_ODD
;
1179 port_settings
.parity
= WHITEHEAT_PAR_EVEN
;
1181 port_settings
.parity
= WHITEHEAT_PAR_NONE
;
1182 dbg("%s - parity = %c", __func__
, port_settings
.parity
);
1184 /* figure out the stop bits requested */
1186 port_settings
.stop
= 2;
1188 port_settings
.stop
= 1;
1189 dbg("%s - stop bits = %d", __func__
, port_settings
.stop
);
1191 /* figure out the flow control settings */
1192 if (cflag
& CRTSCTS
)
1193 port_settings
.hflow
= (WHITEHEAT_HFLOW_CTS
|
1194 WHITEHEAT_HFLOW_RTS
);
1196 port_settings
.hflow
= WHITEHEAT_HFLOW_NONE
;
1197 dbg("%s - hardware flow control = %s %s %s %s", __func__
,
1198 (port_settings
.hflow
& WHITEHEAT_HFLOW_CTS
) ? "CTS" : "",
1199 (port_settings
.hflow
& WHITEHEAT_HFLOW_RTS
) ? "RTS" : "",
1200 (port_settings
.hflow
& WHITEHEAT_HFLOW_DSR
) ? "DSR" : "",
1201 (port_settings
.hflow
& WHITEHEAT_HFLOW_DTR
) ? "DTR" : "");
1203 /* determine software flow control */
1205 port_settings
.sflow
= WHITEHEAT_SFLOW_RXTX
;
1207 port_settings
.sflow
= WHITEHEAT_SFLOW_NONE
;
1208 dbg("%s - software flow control = %c", __func__
, port_settings
.sflow
);
1210 port_settings
.xon
= START_CHAR(tty
);
1211 port_settings
.xoff
= STOP_CHAR(tty
);
1212 dbg("%s - XON = %2x, XOFF = %2x",
1213 __func__
, port_settings
.xon
, port_settings
.xoff
);
1215 /* get the baud rate wanted */
1216 port_settings
.baud
= tty_get_baud_rate(tty
);
1217 dbg("%s - baud rate = %d", __func__
, port_settings
.baud
);
1219 /* fixme: should set validated settings */
1220 tty_encode_baud_rate(tty
, port_settings
.baud
, port_settings
.baud
);
1221 /* handle any settings that aren't specified in the tty structure */
1222 port_settings
.lloop
= 0;
1224 /* now send the message to the device */
1225 firm_send_command(port
, WHITEHEAT_SETUP_PORT
,
1226 (__u8
*)&port_settings
, sizeof(port_settings
));
1230 static int firm_set_rts(struct usb_serial_port
*port
, __u8 onoff
)
1232 struct whiteheat_set_rdb rts_command
;
1234 rts_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1235 rts_command
.state
= onoff
;
1236 return firm_send_command(port
, WHITEHEAT_SET_RTS
,
1237 (__u8
*)&rts_command
, sizeof(rts_command
));
1241 static int firm_set_dtr(struct usb_serial_port
*port
, __u8 onoff
)
1243 struct whiteheat_set_rdb dtr_command
;
1245 dtr_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1246 dtr_command
.state
= onoff
;
1247 return firm_send_command(port
, WHITEHEAT_SET_DTR
,
1248 (__u8
*)&dtr_command
, sizeof(dtr_command
));
1252 static int firm_set_break(struct usb_serial_port
*port
, __u8 onoff
)
1254 struct whiteheat_set_rdb break_command
;
1256 break_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1257 break_command
.state
= onoff
;
1258 return firm_send_command(port
, WHITEHEAT_SET_BREAK
,
1259 (__u8
*)&break_command
, sizeof(break_command
));
1263 static int firm_purge(struct usb_serial_port
*port
, __u8 rxtx
)
1265 struct whiteheat_purge purge_command
;
1267 purge_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1268 purge_command
.what
= rxtx
;
1269 return firm_send_command(port
, WHITEHEAT_PURGE
,
1270 (__u8
*)&purge_command
, sizeof(purge_command
));
1274 static int firm_get_dtr_rts(struct usb_serial_port
*port
)
1276 struct whiteheat_simple get_dr_command
;
1278 get_dr_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1279 return firm_send_command(port
, WHITEHEAT_GET_DTR_RTS
,
1280 (__u8
*)&get_dr_command
, sizeof(get_dr_command
));
1284 static int firm_report_tx_done(struct usb_serial_port
*port
)
1286 struct whiteheat_simple close_command
;
1288 close_command
.port
= port
->number
- port
->serial
->minor
+ 1;
1289 return firm_send_command(port
, WHITEHEAT_REPORT_TX_DONE
,
1290 (__u8
*)&close_command
, sizeof(close_command
));
1294 /*****************************************************************************
1295 * Connect Tech's White Heat utility functions
1296 *****************************************************************************/
1297 static int start_command_port(struct usb_serial
*serial
)
1299 struct usb_serial_port
*command_port
;
1300 struct whiteheat_command_private
*command_info
;
1303 command_port
= serial
->port
[COMMAND_PORT
];
1304 command_info
= usb_get_serial_port_data(command_port
);
1305 mutex_lock(&command_info
->mutex
);
1306 if (!command_info
->port_running
) {
1307 /* Work around HCD bugs */
1308 usb_clear_halt(serial
->dev
, command_port
->read_urb
->pipe
);
1310 retval
= usb_submit_urb(command_port
->read_urb
, GFP_KERNEL
);
1312 dev_err(&serial
->dev
->dev
,
1313 "%s - failed submitting read urb, error %d\n",
1318 command_info
->port_running
++;
1321 mutex_unlock(&command_info
->mutex
);
1326 static void stop_command_port(struct usb_serial
*serial
)
1328 struct usb_serial_port
*command_port
;
1329 struct whiteheat_command_private
*command_info
;
1331 command_port
= serial
->port
[COMMAND_PORT
];
1332 command_info
= usb_get_serial_port_data(command_port
);
1333 mutex_lock(&command_info
->mutex
);
1334 command_info
->port_running
--;
1335 if (!command_info
->port_running
)
1336 usb_kill_urb(command_port
->read_urb
);
1337 mutex_unlock(&command_info
->mutex
);
1341 static int start_port_read(struct usb_serial_port
*port
)
1343 struct whiteheat_private
*info
= usb_get_serial_port_data(port
);
1344 struct whiteheat_urb_wrap
*wrap
;
1347 unsigned long flags
;
1348 struct list_head
*tmp
;
1349 struct list_head
*tmp2
;
1351 spin_lock_irqsave(&info
->lock
, flags
);
1353 list_for_each_safe(tmp
, tmp2
, &info
->rx_urbs_free
) {
1355 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
1357 spin_unlock_irqrestore(&info
->lock
, flags
);
1358 retval
= usb_submit_urb(urb
, GFP_KERNEL
);
1360 spin_lock_irqsave(&info
->lock
, flags
);
1361 list_add(tmp
, &info
->rx_urbs_free
);
1362 list_for_each_safe(tmp
, tmp2
, &info
->rx_urbs_submitted
) {
1363 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
1366 spin_unlock_irqrestore(&info
->lock
, flags
);
1368 spin_lock_irqsave(&info
->lock
, flags
);
1369 list_add(tmp
, &info
->rx_urbs_free
);
1373 spin_lock_irqsave(&info
->lock
, flags
);
1374 list_add(tmp
, &info
->rx_urbs_submitted
);
1377 spin_unlock_irqrestore(&info
->lock
, flags
);
1383 static struct whiteheat_urb_wrap
*urb_to_wrap(struct urb
*urb
,
1384 struct list_head
*head
)
1386 struct whiteheat_urb_wrap
*wrap
;
1387 struct list_head
*tmp
;
1389 list_for_each(tmp
, head
) {
1390 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
1391 if (wrap
->urb
== urb
)
1399 static struct list_head
*list_first(struct list_head
*head
)
1405 static void rx_data_softint(struct work_struct
*work
)
1407 struct whiteheat_private
*info
=
1408 container_of(work
, struct whiteheat_private
, rx_work
);
1409 struct usb_serial_port
*port
= info
->port
;
1410 struct tty_struct
*tty
= tty_port_tty_get(&port
->port
);
1411 struct whiteheat_urb_wrap
*wrap
;
1413 unsigned long flags
;
1414 struct list_head
*tmp
;
1415 struct list_head
*tmp2
;
1419 spin_lock_irqsave(&info
->lock
, flags
);
1420 if (info
->flags
& THROTTLED
) {
1421 spin_unlock_irqrestore(&info
->lock
, flags
);
1425 list_for_each_safe(tmp
, tmp2
, &info
->rx_urb_q
) {
1427 spin_unlock_irqrestore(&info
->lock
, flags
);
1429 wrap
= list_entry(tmp
, struct whiteheat_urb_wrap
, list
);
1432 if (tty
&& urb
->actual_length
)
1433 sent
+= tty_insert_flip_string(tty
,
1434 urb
->transfer_buffer
, urb
->actual_length
);
1436 result
= usb_submit_urb(urb
, GFP_ATOMIC
);
1439 "%s - failed resubmitting read urb, error %d\n",
1441 spin_lock_irqsave(&info
->lock
, flags
);
1442 list_add(tmp
, &info
->rx_urbs_free
);
1446 spin_lock_irqsave(&info
->lock
, flags
);
1447 list_add(tmp
, &info
->rx_urbs_submitted
);
1449 spin_unlock_irqrestore(&info
->lock
, flags
);
1452 tty_flip_buffer_push(tty
);
1458 /*****************************************************************************
1459 * Connect Tech's White Heat module functions
1460 *****************************************************************************/
1461 static int __init
whiteheat_init(void)
1464 retval
= usb_serial_register(&whiteheat_fake_device
);
1466 goto failed_fake_register
;
1467 retval
= usb_serial_register(&whiteheat_device
);
1469 goto failed_device_register
;
1470 retval
= usb_register(&whiteheat_driver
);
1472 goto failed_usb_register
;
1473 printk(KERN_INFO KBUILD_MODNAME
": " DRIVER_VERSION
":"
1476 failed_usb_register
:
1477 usb_serial_deregister(&whiteheat_device
);
1478 failed_device_register
:
1479 usb_serial_deregister(&whiteheat_fake_device
);
1480 failed_fake_register
:
1485 static void __exit
whiteheat_exit(void)
1487 usb_deregister(&whiteheat_driver
);
1488 usb_serial_deregister(&whiteheat_fake_device
);
1489 usb_serial_deregister(&whiteheat_device
);
1493 module_init(whiteheat_init
);
1494 module_exit(whiteheat_exit
);
1496 MODULE_AUTHOR(DRIVER_AUTHOR
);
1497 MODULE_DESCRIPTION(DRIVER_DESC
);
1498 MODULE_LICENSE("GPL");
1500 MODULE_FIRMWARE("whiteheat.fw");
1501 MODULE_FIRMWARE("whiteheat_loader.fw");
1503 module_param(urb_pool_size
, int, 0);
1504 MODULE_PARM_DESC(urb_pool_size
, "Number of urbs to use for buffering");
1506 module_param(debug
, bool, S_IRUGO
| S_IWUSR
);
1507 MODULE_PARM_DESC(debug
, "Debug enabled or not");