diff options
author | Alan Cox <alan@redhat.com> | 2008-07-22 06:09:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-22 16:03:22 -0400 |
commit | 80359a9c5c03d585686e2596c9ee46703eb03047 (patch) | |
tree | dcf823d8b97c50c0a0f310936c351af3516574ac /drivers/usb/serial/whiteheat.c | |
parent | 95da310e66ee8090119596c70ca8432e57f9a97f (diff) |
whiteheat: coding style
Bring ezusb and whiteheat into line with the coding style
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb/serial/whiteheat.c')
-rw-r--r-- | drivers/usb/serial/whiteheat.c | 386 |
1 files changed, 217 insertions, 169 deletions
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index b07d6a5cac31..2569b68b8334 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -12,29 +12,31 @@ | |||
12 | * the Free Software Foundation; either version 2 of the License, or | 12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. | 13 | * (at your option) any later version. |
14 | * | 14 | * |
15 | * See Documentation/usb/usb-serial.txt for more information on using this driver | 15 | * See Documentation/usb/usb-serial.txt for more information on using this |
16 | * driver | ||
16 | * | 17 | * |
17 | * (10/09/2002) Stuart MacDonald (stuartm@connecttech.com) | 18 | * (10/09/2002) Stuart MacDonald (stuartm@connecttech.com) |
18 | * Upgrade to full working driver | 19 | * Upgrade to full working driver |
19 | * | 20 | * |
20 | * (05/30/2001) gkh | 21 | * (05/30/2001) gkh |
21 | * switched from using spinlock to a semaphore, which fixes lots of problems. | 22 | * switched from using spinlock to a semaphore, which fixes lots of |
23 | * problems. | ||
22 | * | 24 | * |
23 | * (04/08/2001) gb | 25 | * (04/08/2001) gb |
24 | * Identify version on module load. | 26 | * Identify version on module load. |
25 | * | 27 | * |
26 | * 2001_Mar_19 gkh | 28 | * 2001_Mar_19 gkh |
27 | * Fixed MOD_INC and MOD_DEC logic, the ability to open a port more | 29 | * Fixed MOD_INC and MOD_DEC logic, the ability to open a port more |
28 | * than once, and the got the proper usb_device_id table entries so | 30 | * than once, and the got the proper usb_device_id table entries so |
29 | * the driver works again. | 31 | * the driver works again. |
30 | * | 32 | * |
31 | * (11/01/2000) Adam J. Richter | 33 | * (11/01/2000) Adam J. Richter |
32 | * usb_device_id table support | 34 | * usb_device_id table support |
33 | * | 35 | * |
34 | * (10/05/2000) gkh | 36 | * (10/05/2000) gkh |
35 | * Fixed bug with urb->dev not being set properly, now that the usb | 37 | * Fixed bug with urb->dev not being set properly, now that the usb |
36 | * core needs it. | 38 | * core needs it. |
37 | * | 39 | * |
38 | * (10/03/2000) smd | 40 | * (10/03/2000) smd |
39 | * firmware is improved to guard against crap sent to device | 41 | * firmware is improved to guard against crap sent to device |
40 | * firmware now replies CMD_FAILURE on bad things | 42 | * firmware now replies CMD_FAILURE on bad things |
@@ -52,9 +54,9 @@ | |||
52 | * Fixed bug with port->minor that was found by Al Borchers | 54 | * Fixed bug with port->minor that was found by Al Borchers |
53 | * | 55 | * |
54 | * (07/04/2000) gkh | 56 | * (07/04/2000) gkh |
55 | * Added support for port settings. Baud rate can now be changed. Line signals | 57 | * Added support for port settings. Baud rate can now be changed. Line |
56 | * are not transferred to and from the tty layer yet, but things seem to be | 58 | * signals are not transferred to and from the tty layer yet, but things |
57 | * working well now. | 59 | * seem to be working well now. |
58 | * | 60 | * |
59 | * (05/04/2000) gkh | 61 | * (05/04/2000) gkh |
60 | * First cut at open and close commands. Data can flow through the ports at | 62 | * First cut at open and close commands. Data can flow through the ports at |
@@ -62,7 +64,7 @@ | |||
62 | * | 64 | * |
63 | * (03/26/2000) gkh | 65 | * (03/26/2000) gkh |
64 | * Split driver up into device specific pieces. | 66 | * Split driver up into device specific pieces. |
65 | * | 67 | * |
66 | */ | 68 | */ |
67 | 69 | ||
68 | #include <linux/kernel.h> | 70 | #include <linux/kernel.h> |
@@ -75,7 +77,7 @@ | |||
75 | #include <linux/module.h> | 77 | #include <linux/module.h> |
76 | #include <linux/spinlock.h> | 78 | #include <linux/spinlock.h> |
77 | #include <linux/mutex.h> | 79 | #include <linux/mutex.h> |
78 | #include <asm/uaccess.h> | 80 | #include <linux/uaccess.h> |
79 | #include <asm/termbits.h> | 81 | #include <asm/termbits.h> |
80 | #include <linux/usb.h> | 82 | #include <linux/usb.h> |
81 | #include <linux/serial_reg.h> | 83 | #include <linux/serial_reg.h> |
@@ -125,7 +127,7 @@ static struct usb_device_id id_table_combined [] = { | |||
125 | { } /* Terminating entry */ | 127 | { } /* Terminating entry */ |
126 | }; | 128 | }; |
127 | 129 | ||
128 | MODULE_DEVICE_TABLE (usb, id_table_combined); | 130 | MODULE_DEVICE_TABLE(usb, id_table_combined); |
129 | 131 | ||
130 | static struct usb_driver whiteheat_driver = { | 132 | static struct usb_driver whiteheat_driver = { |
131 | .name = "whiteheat", | 133 | .name = "whiteheat", |
@@ -136,26 +138,34 @@ static struct usb_driver whiteheat_driver = { | |||
136 | }; | 138 | }; |
137 | 139 | ||
138 | /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ | 140 | /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ |
139 | static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id); | 141 | static int whiteheat_firmware_download(struct usb_serial *serial, |
140 | static int whiteheat_firmware_attach (struct usb_serial *serial); | 142 | const struct usb_device_id *id); |
143 | static int whiteheat_firmware_attach(struct usb_serial *serial); | ||
141 | 144 | ||
142 | /* function prototypes for the Connect Tech WhiteHEAT serial converter */ | 145 | /* function prototypes for the Connect Tech WhiteHEAT serial converter */ |
143 | static int whiteheat_attach (struct usb_serial *serial); | 146 | static int whiteheat_attach(struct usb_serial *serial); |
144 | static void whiteheat_shutdown (struct usb_serial *serial); | 147 | static void whiteheat_shutdown(struct usb_serial *serial); |
145 | static int whiteheat_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 148 | static int whiteheat_open(struct tty_struct *tty, |
146 | static void whiteheat_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); | 149 | struct usb_serial_port *port, struct file *filp); |
147 | static int whiteheat_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); | 150 | static void whiteheat_close(struct tty_struct *tty, |
148 | static int whiteheat_write_room (struct tty_struct *tty); | 151 | struct usb_serial_port *port, struct file *filp); |
149 | static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); | 152 | static int whiteheat_write(struct tty_struct *tty, |
150 | static void whiteheat_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); | 153 | struct usb_serial_port *port, |
151 | static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file); | 154 | const unsigned char *buf, int count); |
152 | static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); | 155 | static int whiteheat_write_room(struct tty_struct *tty); |
153 | static void whiteheat_break_ctl (struct tty_struct *tty, int break_state); | 156 | static int whiteheat_ioctl(struct tty_struct *tty, struct file *file, |
154 | static int whiteheat_chars_in_buffer (struct tty_struct *tty); | 157 | unsigned int cmd, unsigned long arg); |
155 | static void whiteheat_throttle (struct tty_struct *tty); | 158 | static void whiteheat_set_termios(struct tty_struct *tty, |
156 | static void whiteheat_unthrottle (struct tty_struct *tty); | 159 | struct usb_serial_port *port, struct ktermios *old); |
157 | static void whiteheat_read_callback (struct urb *urb); | 160 | static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file); |
158 | static void whiteheat_write_callback (struct urb *urb); | 161 | static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file, |
162 | unsigned int set, unsigned int clear); | ||
163 | static void whiteheat_break_ctl(struct tty_struct *tty, int break_state); | ||
164 | static int whiteheat_chars_in_buffer(struct tty_struct *tty); | ||
165 | static void whiteheat_throttle(struct tty_struct *tty); | ||
166 | static void whiteheat_unthrottle(struct tty_struct *tty); | ||
167 | static void whiteheat_read_callback(struct urb *urb); | ||
168 | static void whiteheat_write_callback(struct urb *urb); | ||
159 | 169 | ||
160 | static struct usb_serial_driver whiteheat_fake_device = { | 170 | static struct usb_serial_driver whiteheat_fake_device = { |
161 | .driver = { | 171 | .driver = { |
@@ -202,7 +212,9 @@ struct whiteheat_command_private { | |||
202 | struct mutex mutex; | 212 | struct mutex mutex; |
203 | __u8 port_running; | 213 | __u8 port_running; |
204 | __u8 command_finished; | 214 | __u8 command_finished; |
205 | wait_queue_head_t wait_command; /* for handling sleeping while waiting for a command to finish */ | 215 | wait_queue_head_t wait_command; /* for handling sleeping whilst |
216 | waiting for a command to | ||
217 | finish */ | ||
206 | __u8 result_buffer[64]; | 218 | __u8 result_buffer[64]; |
207 | }; | 219 | }; |
208 | 220 | ||
@@ -239,11 +251,13 @@ static void command_port_write_callback(struct urb *urb); | |||
239 | static void command_port_read_callback(struct urb *urb); | 251 | static void command_port_read_callback(struct urb *urb); |
240 | 252 | ||
241 | static int start_port_read(struct usb_serial_port *port); | 253 | static int start_port_read(struct usb_serial_port *port); |
242 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); | 254 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, |
255 | struct list_head *head); | ||
243 | static struct list_head *list_first(struct list_head *head); | 256 | static struct list_head *list_first(struct list_head *head); |
244 | static void rx_data_softint(struct work_struct *work); | 257 | static void rx_data_softint(struct work_struct *work); |
245 | 258 | ||
246 | static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); | 259 | static int firm_send_command(struct usb_serial_port *port, __u8 command, |
260 | __u8 *data, __u8 datasize); | ||
247 | static int firm_open(struct usb_serial_port *port); | 261 | static int firm_open(struct usb_serial_port *port); |
248 | static int firm_close(struct usb_serial_port *port); | 262 | static int firm_close(struct usb_serial_port *port); |
249 | static int firm_setup_port(struct tty_struct *tty); | 263 | static int firm_setup_port(struct tty_struct *tty); |
@@ -278,7 +292,8 @@ static int firm_report_tx_done(struct usb_serial_port *port); | |||
278 | - device renumerated itself and comes up as new device id with all | 292 | - device renumerated itself and comes up as new device id with all |
279 | firmware download completed. | 293 | firmware download completed. |
280 | */ | 294 | */ |
281 | static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id) | 295 | static int whiteheat_firmware_download(struct usb_serial *serial, |
296 | const struct usb_device_id *id) | ||
282 | { | 297 | { |
283 | int response, ret = -ENOENT; | 298 | int response, ret = -ENOENT; |
284 | const struct firmware *loader_fw = NULL, *firmware_fw = NULL; | 299 | const struct firmware *loader_fw = NULL, *firmware_fw = NULL; |
@@ -313,7 +328,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct | |||
313 | record = ihex_next_binrec(record); | 328 | record = ihex_next_binrec(record); |
314 | } | 329 | } |
315 | 330 | ||
316 | response = ezusb_set_reset (serial, 0); | 331 | response = ezusb_set_reset(serial, 0); |
317 | 332 | ||
318 | record = (const struct ihex_binrec *)firmware_fw->data; | 333 | record = (const struct ihex_binrec *)firmware_fw->data; |
319 | while (record && be32_to_cpu(record->addr) < 0x1b40) | 334 | while (record && be32_to_cpu(record->addr) < 0x1b40) |
@@ -330,8 +345,8 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct | |||
330 | } | 345 | } |
331 | ++record; | 346 | ++record; |
332 | } | 347 | } |
333 | 348 | ||
334 | response = ezusb_set_reset (serial, 1); | 349 | response = ezusb_set_reset(serial, 1); |
335 | 350 | ||
336 | record = (const struct ihex_binrec *)firmware_fw->data; | 351 | record = (const struct ihex_binrec *)firmware_fw->data; |
337 | while (record && be32_to_cpu(record->addr) < 0x1b40) { | 352 | while (record && be32_to_cpu(record->addr) < 0x1b40) { |
@@ -355,7 +370,7 @@ static int whiteheat_firmware_download (struct usb_serial *serial, const struct | |||
355 | } | 370 | } |
356 | 371 | ||
357 | 372 | ||
358 | static int whiteheat_firmware_attach (struct usb_serial *serial) | 373 | static int whiteheat_firmware_attach(struct usb_serial *serial) |
359 | { | 374 | { |
360 | /* We want this device to fail to have a driver assigned to it */ | 375 | /* We want this device to fail to have a driver assigned to it */ |
361 | return 1; | 376 | return 1; |
@@ -365,7 +380,7 @@ static int whiteheat_firmware_attach (struct usb_serial *serial) | |||
365 | /***************************************************************************** | 380 | /***************************************************************************** |
366 | * Connect Tech's White Heat serial driver functions | 381 | * Connect Tech's White Heat serial driver functions |
367 | *****************************************************************************/ | 382 | *****************************************************************************/ |
368 | static int whiteheat_attach (struct usb_serial *serial) | 383 | static int whiteheat_attach(struct usb_serial *serial) |
369 | { | 384 | { |
370 | struct usb_serial_port *command_port; | 385 | struct usb_serial_port *command_port; |
371 | struct whiteheat_command_private *command_info; | 386 | struct whiteheat_command_private *command_info; |
@@ -386,43 +401,52 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
386 | 401 | ||
387 | command_port = serial->port[COMMAND_PORT]; | 402 | command_port = serial->port[COMMAND_PORT]; |
388 | 403 | ||
389 | pipe = usb_sndbulkpipe (serial->dev, command_port->bulk_out_endpointAddress); | 404 | pipe = usb_sndbulkpipe(serial->dev, |
405 | command_port->bulk_out_endpointAddress); | ||
390 | command = kmalloc(2, GFP_KERNEL); | 406 | command = kmalloc(2, GFP_KERNEL); |
391 | if (!command) | 407 | if (!command) |
392 | goto no_command_buffer; | 408 | goto no_command_buffer; |
393 | command[0] = WHITEHEAT_GET_HW_INFO; | 409 | command[0] = WHITEHEAT_GET_HW_INFO; |
394 | command[1] = 0; | 410 | command[1] = 0; |
395 | 411 | ||
396 | result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL); | 412 | result = kmalloc(sizeof(*hw_info) + 1, GFP_KERNEL); |
397 | if (!result) | 413 | if (!result) |
398 | goto no_result_buffer; | 414 | goto no_result_buffer; |
399 | /* | 415 | /* |
400 | * When the module is reloaded the firmware is still there and | 416 | * When the module is reloaded the firmware is still there and |
401 | * the endpoints are still in the usb core unchanged. This is the | 417 | * the endpoints are still in the usb core unchanged. This is the |
402 | * unlinking bug in disguise. Same for the call below. | 418 | * unlinking bug in disguise. Same for the call below. |
403 | */ | 419 | */ |
404 | usb_clear_halt(serial->dev, pipe); | 420 | usb_clear_halt(serial->dev, pipe); |
405 | ret = usb_bulk_msg (serial->dev, pipe, command, 2, &alen, COMMAND_TIMEOUT_MS); | 421 | ret = usb_bulk_msg(serial->dev, pipe, command, 2, |
422 | &alen, COMMAND_TIMEOUT_MS); | ||
406 | if (ret) { | 423 | if (ret) { |
407 | err("%s: Couldn't send command [%d]", serial->type->description, ret); | 424 | err("%s: Couldn't send command [%d]", |
425 | serial->type->description, ret); | ||
408 | goto no_firmware; | 426 | goto no_firmware; |
409 | } else if (alen != 2) { | 427 | } else if (alen != 2) { |
410 | err("%s: Send command incomplete [%d]", serial->type->description, alen); | 428 | err("%s: Send command incomplete [%d]", |
429 | serial->type->description, alen); | ||
411 | goto no_firmware; | 430 | goto no_firmware; |
412 | } | 431 | } |
413 | 432 | ||
414 | pipe = usb_rcvbulkpipe (serial->dev, command_port->bulk_in_endpointAddress); | 433 | pipe = usb_rcvbulkpipe(serial->dev, |
434 | command_port->bulk_in_endpointAddress); | ||
415 | /* See the comment on the usb_clear_halt() above */ | 435 | /* See the comment on the usb_clear_halt() above */ |
416 | usb_clear_halt(serial->dev, pipe); | 436 | usb_clear_halt(serial->dev, pipe); |
417 | ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); | 437 | ret = usb_bulk_msg(serial->dev, pipe, result, |
438 | sizeof(*hw_info) + 1, &alen, COMMAND_TIMEOUT_MS); | ||
418 | if (ret) { | 439 | if (ret) { |
419 | err("%s: Couldn't get results [%d]", serial->type->description, ret); | 440 | err("%s: Couldn't get results [%d]", |
441 | serial->type->description, ret); | ||
420 | goto no_firmware; | 442 | goto no_firmware; |
421 | } else if (alen != sizeof(*hw_info) + 1) { | 443 | } else if (alen != sizeof(*hw_info) + 1) { |
422 | err("%s: Get results incomplete [%d]", serial->type->description, alen); | 444 | err("%s: Get results incomplete [%d]", |
445 | serial->type->description, alen); | ||
423 | goto no_firmware; | 446 | goto no_firmware; |
424 | } else if (result[0] != command[0]) { | 447 | } else if (result[0] != command[0]) { |
425 | err("%s: Command failed [%d]", serial->type->description, result[0]); | 448 | err("%s: Command failed [%d]", |
449 | serial->type->description, result[0]); | ||
426 | goto no_firmware; | 450 | goto no_firmware; |
427 | } | 451 | } |
428 | 452 | ||
@@ -436,7 +460,8 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
436 | 460 | ||
437 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); | 461 | info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL); |
438 | if (info == NULL) { | 462 | if (info == NULL) { |
439 | err("%s: Out of memory for port structures\n", serial->type->description); | 463 | err("%s: Out of memory for port structures\n", |
464 | serial->type->description); | ||
440 | goto no_private; | 465 | goto no_private; |
441 | } | 466 | } |
442 | 467 | ||
@@ -506,9 +531,11 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
506 | usb_set_serial_port_data(port, info); | 531 | usb_set_serial_port_data(port, info); |
507 | } | 532 | } |
508 | 533 | ||
509 | command_info = kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL); | 534 | command_info = kmalloc(sizeof(struct whiteheat_command_private), |
535 | GFP_KERNEL); | ||
510 | if (command_info == NULL) { | 536 | if (command_info == NULL) { |
511 | err("%s: Out of memory for port structures\n", serial->type->description); | 537 | err("%s: Out of memory for port structures\n", |
538 | serial->type->description); | ||
512 | goto no_command_private; | 539 | goto no_command_private; |
513 | } | 540 | } |
514 | 541 | ||
@@ -525,9 +552,12 @@ static int whiteheat_attach (struct usb_serial *serial) | |||
525 | 552 | ||
526 | no_firmware: | 553 | no_firmware: |
527 | /* Firmware likely not running */ | 554 | /* Firmware likely not running */ |
528 | err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description); | 555 | err("%s: Unable to retrieve firmware version, try replugging\n", |
529 | err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description); | 556 | serial->type->description); |
530 | err("%s: please contact support@connecttech.com\n", serial->type->description); | 557 | err("%s: If the firmware is not running (status led not blinking)\n", |
558 | serial->type->description); | ||
559 | err("%s: please contact support@connecttech.com\n", | ||
560 | serial->type->description); | ||
531 | kfree(result); | 561 | kfree(result); |
532 | return -ENODEV; | 562 | return -ENODEV; |
533 | 563 | ||
@@ -570,7 +600,7 @@ no_command_buffer: | |||
570 | } | 600 | } |
571 | 601 | ||
572 | 602 | ||
573 | static void whiteheat_shutdown (struct usb_serial *serial) | 603 | static void whiteheat_shutdown(struct usb_serial *serial) |
574 | { | 604 | { |
575 | struct usb_serial_port *command_port; | 605 | struct usb_serial_port *command_port; |
576 | struct usb_serial_port *port; | 606 | struct usb_serial_port *port; |
@@ -585,7 +615,7 @@ static void whiteheat_shutdown (struct usb_serial *serial) | |||
585 | 615 | ||
586 | /* free up our private data for our command port */ | 616 | /* free up our private data for our command port */ |
587 | command_port = serial->port[COMMAND_PORT]; | 617 | command_port = serial->port[COMMAND_PORT]; |
588 | kfree (usb_get_serial_port_data(command_port)); | 618 | kfree(usb_get_serial_port_data(command_port)); |
589 | 619 | ||
590 | for (i = 0; i < serial->num_ports; i++) { | 620 | for (i = 0; i < serial->num_ports; i++) { |
591 | port = serial->port[i]; | 621 | port = serial->port[i]; |
@@ -612,8 +642,7 @@ static void whiteheat_shutdown (struct usb_serial *serial) | |||
612 | return; | 642 | return; |
613 | } | 643 | } |
614 | 644 | ||
615 | 645 | static int whiteheat_open(struct tty_struct *tty, | |
616 | static int whiteheat_open (struct tty_struct *tty, | ||
617 | struct usb_serial_port *port, struct file *filp) | 646 | struct usb_serial_port *port, struct file *filp) |
618 | { | 647 | { |
619 | int retval = 0; | 648 | int retval = 0; |
@@ -655,7 +684,8 @@ static int whiteheat_open (struct tty_struct *tty, | |||
655 | /* Start reading from the device */ | 684 | /* Start reading from the device */ |
656 | retval = start_port_read(port); | 685 | retval = start_port_read(port); |
657 | if (retval) { | 686 | if (retval) { |
658 | err("%s - failed submitting read urb, error %d", __func__, retval); | 687 | err("%s - failed submitting read urb, error %d", |
688 | __func__, retval); | ||
659 | firm_close(port); | 689 | firm_close(port); |
660 | stop_command_port(port->serial); | 690 | stop_command_port(port->serial); |
661 | goto exit; | 691 | goto exit; |
@@ -668,7 +698,7 @@ exit: | |||
668 | 698 | ||
669 | 699 | ||
670 | static void whiteheat_close(struct tty_struct *tty, | 700 | static void whiteheat_close(struct tty_struct *tty, |
671 | struct usb_serial_port *port, struct file * filp) | 701 | struct usb_serial_port *port, struct file *filp) |
672 | { | 702 | { |
673 | struct whiteheat_private *info = usb_get_serial_port_data(port); | 703 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
674 | struct whiteheat_urb_wrap *wrap; | 704 | struct whiteheat_urb_wrap *wrap; |
@@ -769,16 +799,19 @@ static int whiteheat_write(struct tty_struct *tty, | |||
769 | 799 | ||
770 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); | 800 | wrap = list_entry(tmp, struct whiteheat_urb_wrap, list); |
771 | urb = wrap->urb; | 801 | urb = wrap->urb; |
772 | bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count; | 802 | bytes = (count > port->bulk_out_size) ? |
773 | memcpy (urb->transfer_buffer, buf + sent, bytes); | 803 | port->bulk_out_size : count; |
804 | memcpy(urb->transfer_buffer, buf + sent, bytes); | ||
774 | 805 | ||
775 | usb_serial_debug_data(debug, &port->dev, __func__, bytes, urb->transfer_buffer); | 806 | usb_serial_debug_data(debug, &port->dev, |
807 | __func__, bytes, urb->transfer_buffer); | ||
776 | 808 | ||
777 | urb->dev = serial->dev; | 809 | urb->dev = serial->dev; |
778 | urb->transfer_buffer_length = bytes; | 810 | urb->transfer_buffer_length = bytes; |
779 | result = usb_submit_urb(urb, GFP_ATOMIC); | 811 | result = usb_submit_urb(urb, GFP_ATOMIC); |
780 | if (result) { | 812 | if (result) { |
781 | err("%s - failed submitting write urb, error %d", __func__, result); | 813 | err("%s - failed submitting write urb, error %d", |
814 | __func__, result); | ||
782 | sent = result; | 815 | sent = result; |
783 | spin_lock_irqsave(&info->lock, flags); | 816 | spin_lock_irqsave(&info->lock, flags); |
784 | list_add(tmp, &info->tx_urbs_free); | 817 | list_add(tmp, &info->tx_urbs_free); |
@@ -796,7 +829,6 @@ static int whiteheat_write(struct tty_struct *tty, | |||
796 | return sent; | 829 | return sent; |
797 | } | 830 | } |
798 | 831 | ||
799 | |||
800 | static int whiteheat_write_room(struct tty_struct *tty) | 832 | static int whiteheat_write_room(struct tty_struct *tty) |
801 | { | 833 | { |
802 | struct usb_serial_port *port = tty->driver_data; | 834 | struct usb_serial_port *port = tty->driver_data; |
@@ -806,7 +838,7 @@ static int whiteheat_write_room(struct tty_struct *tty) | |||
806 | unsigned long flags; | 838 | unsigned long flags; |
807 | 839 | ||
808 | dbg("%s - port %d", __func__, port->number); | 840 | dbg("%s - port %d", __func__, port->number); |
809 | 841 | ||
810 | spin_lock_irqsave(&info->lock, flags); | 842 | spin_lock_irqsave(&info->lock, flags); |
811 | list_for_each(tmp, &info->tx_urbs_free) | 843 | list_for_each(tmp, &info->tx_urbs_free) |
812 | room++; | 844 | room++; |
@@ -817,8 +849,7 @@ static int whiteheat_write_room(struct tty_struct *tty) | |||
817 | return (room); | 849 | return (room); |
818 | } | 850 | } |
819 | 851 | ||
820 | 852 | static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file) | |
821 | static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file) | ||
822 | { | 853 | { |
823 | struct usb_serial_port *port = tty->driver_data; | 854 | struct usb_serial_port *port = tty->driver_data; |
824 | struct whiteheat_private *info = usb_get_serial_port_data(port); | 855 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
@@ -835,8 +866,7 @@ static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file) | |||
835 | return modem_signals; | 866 | return modem_signals; |
836 | } | 867 | } |
837 | 868 | ||
838 | 869 | static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file, | |
839 | static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, | ||
840 | unsigned int set, unsigned int clear) | 870 | unsigned int set, unsigned int clear) |
841 | { | 871 | { |
842 | struct usb_serial_port *port = tty->driver_data; | 872 | struct usb_serial_port *port = tty->driver_data; |
@@ -860,7 +890,8 @@ static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, | |||
860 | } | 890 | } |
861 | 891 | ||
862 | 892 | ||
863 | static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) | 893 | static int whiteheat_ioctl(struct tty_struct *tty, struct file *file, |
894 | unsigned int cmd, unsigned long arg) | ||
864 | { | 895 | { |
865 | struct usb_serial_port *port = tty->driver_data; | 896 | struct usb_serial_port *port = tty->driver_data; |
866 | struct serial_struct serstruct; | 897 | struct serial_struct serstruct; |
@@ -869,50 +900,38 @@ static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned | |||
869 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); | 900 | dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); |
870 | 901 | ||
871 | switch (cmd) { | 902 | switch (cmd) { |
872 | case TIOCGSERIAL: | 903 | case TIOCGSERIAL: |
873 | memset(&serstruct, 0, sizeof(serstruct)); | 904 | memset(&serstruct, 0, sizeof(serstruct)); |
874 | serstruct.type = PORT_16654; | 905 | serstruct.type = PORT_16654; |
875 | serstruct.line = port->serial->minor; | 906 | serstruct.line = port->serial->minor; |
876 | serstruct.port = port->number; | 907 | serstruct.port = port->number; |
877 | serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | 908 | serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
878 | serstruct.xmit_fifo_size = port->bulk_out_size; | 909 | serstruct.xmit_fifo_size = port->bulk_out_size; |
879 | serstruct.custom_divisor = 0; | 910 | serstruct.custom_divisor = 0; |
880 | serstruct.baud_base = 460800; | 911 | serstruct.baud_base = 460800; |
881 | serstruct.close_delay = CLOSING_DELAY; | 912 | serstruct.close_delay = CLOSING_DELAY; |
882 | serstruct.closing_wait = CLOSING_DELAY; | 913 | serstruct.closing_wait = CLOSING_DELAY; |
883 | 914 | ||
884 | if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) | 915 | if (copy_to_user(user_arg, &serstruct, sizeof(serstruct))) |
885 | return -EFAULT; | 916 | return -EFAULT; |
886 | 917 | break; | |
887 | break; | 918 | default: |
888 | 919 | break; | |
889 | case TIOCSSERIAL: | ||
890 | if (copy_from_user(&serstruct, user_arg, sizeof(serstruct))) | ||
891 | return -EFAULT; | ||
892 | |||
893 | /* | ||
894 | * For now this is ignored. dip sets the ASYNC_[V]HI flags | ||
895 | * but this isn't used by us at all. Maybe someone somewhere | ||
896 | * will need the custom_divisor setting. | ||
897 | */ | ||
898 | |||
899 | break; | ||
900 | |||
901 | default: | ||
902 | break; | ||
903 | } | 920 | } |
904 | 921 | ||
905 | return -ENOIOCTLCMD; | 922 | return -ENOIOCTLCMD; |
906 | } | 923 | } |
907 | 924 | ||
908 | 925 | ||
909 | static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) | 926 | static void whiteheat_set_termios(struct tty_struct *tty, |
927 | struct usb_serial_port *port, struct ktermios *old_termios) | ||
910 | { | 928 | { |
929 | /* FIXME */ | ||
911 | firm_setup_port(tty); | 930 | firm_setup_port(tty); |
912 | } | 931 | } |
913 | 932 | ||
914 | 933 | static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) | |
915 | static void whiteheat_break_ctl(struct tty_struct *tty, int break_state) { | 934 | { |
916 | struct usb_serial_port *port = tty->driver_data; | 935 | struct usb_serial_port *port = tty->driver_data; |
917 | firm_set_break(port, break_state); | 936 | firm_set_break(port, break_state); |
918 | } | 937 | } |
@@ -936,12 +955,12 @@ static int whiteheat_chars_in_buffer(struct tty_struct *tty) | |||
936 | } | 955 | } |
937 | spin_unlock_irqrestore(&info->lock, flags); | 956 | spin_unlock_irqrestore(&info->lock, flags); |
938 | 957 | ||
939 | dbg ("%s - returns %d", __func__, chars); | 958 | dbg("%s - returns %d", __func__, chars); |
940 | return chars; | 959 | return chars; |
941 | } | 960 | } |
942 | 961 | ||
943 | 962 | ||
944 | static void whiteheat_throttle (struct tty_struct *tty) | 963 | static void whiteheat_throttle(struct tty_struct *tty) |
945 | { | 964 | { |
946 | struct usb_serial_port *port = tty->driver_data; | 965 | struct usb_serial_port *port = tty->driver_data; |
947 | struct whiteheat_private *info = usb_get_serial_port_data(port); | 966 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
@@ -957,7 +976,7 @@ static void whiteheat_throttle (struct tty_struct *tty) | |||
957 | } | 976 | } |
958 | 977 | ||
959 | 978 | ||
960 | static void whiteheat_unthrottle (struct tty_struct *tty) | 979 | static void whiteheat_unthrottle(struct tty_struct *tty) |
961 | { | 980 | { |
962 | struct usb_serial_port *port = tty->driver_data; | 981 | struct usb_serial_port *port = tty->driver_data; |
963 | struct whiteheat_private *info = usb_get_serial_port_data(port); | 982 | struct whiteheat_private *info = usb_get_serial_port_data(port); |
@@ -1006,7 +1025,7 @@ static void command_port_read_callback(struct urb *urb) | |||
1006 | 1025 | ||
1007 | command_info = usb_get_serial_port_data(command_port); | 1026 | command_info = usb_get_serial_port_data(command_port); |
1008 | if (!command_info) { | 1027 | if (!command_info) { |
1009 | dbg ("%s - command_info is NULL, exiting.", __func__); | 1028 | dbg("%s - command_info is NULL, exiting.", __func__); |
1010 | return; | 1029 | return; |
1011 | } | 1030 | } |
1012 | if (status) { | 1031 | if (status) { |
@@ -1017,7 +1036,8 @@ static void command_port_read_callback(struct urb *urb) | |||
1017 | return; | 1036 | return; |
1018 | } | 1037 | } |
1019 | 1038 | ||
1020 | usb_serial_debug_data(debug, &command_port->dev, __func__, urb->actual_length, data); | 1039 | usb_serial_debug_data(debug, &command_port->dev, |
1040 | __func__, urb->actual_length, data); | ||
1021 | 1041 | ||
1022 | if (data[0] == WHITEHEAT_CMD_COMPLETE) { | 1042 | if (data[0] == WHITEHEAT_CMD_COMPLETE) { |
1023 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; | 1043 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
@@ -1026,21 +1046,23 @@ static void command_port_read_callback(struct urb *urb) | |||
1026 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; | 1046 | command_info->command_finished = WHITEHEAT_CMD_FAILURE; |
1027 | wake_up(&command_info->wait_command); | 1047 | wake_up(&command_info->wait_command); |
1028 | } else if (data[0] == WHITEHEAT_EVENT) { | 1048 | } else if (data[0] == WHITEHEAT_EVENT) { |
1029 | /* These are unsolicited reports from the firmware, hence no waiting command to wakeup */ | 1049 | /* These are unsolicited reports from the firmware, hence no |
1050 | waiting command to wakeup */ | ||
1030 | dbg("%s - event received", __func__); | 1051 | dbg("%s - event received", __func__); |
1031 | } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { | 1052 | } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { |
1032 | memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1); | 1053 | memcpy(command_info->result_buffer, &data[1], |
1054 | urb->actual_length - 1); | ||
1033 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; | 1055 | command_info->command_finished = WHITEHEAT_CMD_COMPLETE; |
1034 | wake_up(&command_info->wait_command); | 1056 | wake_up(&command_info->wait_command); |
1035 | } else { | 1057 | } else |
1036 | dbg("%s - bad reply from firmware", __func__); | 1058 | dbg("%s - bad reply from firmware", __func__); |
1037 | } | 1059 | |
1038 | |||
1039 | /* Continue trying to always read */ | 1060 | /* Continue trying to always read */ |
1040 | command_port->read_urb->dev = command_port->serial->dev; | 1061 | command_port->read_urb->dev = command_port->serial->dev; |
1041 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); | 1062 | result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); |
1042 | if (result) | 1063 | if (result) |
1043 | dbg("%s - failed resubmitting read urb, error %d", __func__, result); | 1064 | dbg("%s - failed resubmitting read urb, error %d", |
1065 | __func__, result); | ||
1044 | } | 1066 | } |
1045 | 1067 | ||
1046 | 1068 | ||
@@ -1073,7 +1095,8 @@ static void whiteheat_read_callback(struct urb *urb) | |||
1073 | return; | 1095 | return; |
1074 | } | 1096 | } |
1075 | 1097 | ||
1076 | usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); | 1098 | usb_serial_debug_data(debug, &port->dev, |
1099 | __func__, urb->actual_length, data); | ||
1077 | 1100 | ||
1078 | spin_lock(&info->lock); | 1101 | spin_lock(&info->lock); |
1079 | list_add_tail(&wrap->list, &info->rx_urb_q); | 1102 | list_add_tail(&wrap->list, &info->rx_urb_q); |
@@ -1120,7 +1143,8 @@ static void whiteheat_write_callback(struct urb *urb) | |||
1120 | /***************************************************************************** | 1143 | /***************************************************************************** |
1121 | * Connect Tech's White Heat firmware interface | 1144 | * Connect Tech's White Heat firmware interface |
1122 | *****************************************************************************/ | 1145 | *****************************************************************************/ |
1123 | static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize) | 1146 | static int firm_send_command(struct usb_serial_port *port, __u8 command, |
1147 | __u8 *data, __u8 datasize) | ||
1124 | { | 1148 | { |
1125 | struct usb_serial_port *command_port; | 1149 | struct usb_serial_port *command_port; |
1126 | struct whiteheat_command_private *command_info; | 1150 | struct whiteheat_command_private *command_info; |
@@ -1135,13 +1159,13 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d | |||
1135 | command_info = usb_get_serial_port_data(command_port); | 1159 | command_info = usb_get_serial_port_data(command_port); |
1136 | mutex_lock(&command_info->mutex); | 1160 | mutex_lock(&command_info->mutex); |
1137 | command_info->command_finished = false; | 1161 | command_info->command_finished = false; |
1138 | 1162 | ||
1139 | transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; | 1163 | transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer; |
1140 | transfer_buffer[0] = command; | 1164 | transfer_buffer[0] = command; |
1141 | memcpy (&transfer_buffer[1], data, datasize); | 1165 | memcpy(&transfer_buffer[1], data, datasize); |
1142 | command_port->write_urb->transfer_buffer_length = datasize + 1; | 1166 | command_port->write_urb->transfer_buffer_length = datasize + 1; |
1143 | command_port->write_urb->dev = port->serial->dev; | 1167 | command_port->write_urb->dev = port->serial->dev; |
1144 | retval = usb_submit_urb (command_port->write_urb, GFP_NOIO); | 1168 | retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); |
1145 | if (retval) { | 1169 | if (retval) { |
1146 | dbg("%s - submit urb failed", __func__); | 1170 | dbg("%s - submit urb failed", __func__); |
1147 | goto exit; | 1171 | goto exit; |
@@ -1168,36 +1192,41 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *d | |||
1168 | if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { | 1192 | if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { |
1169 | dbg("%s - command completed.", __func__); | 1193 | dbg("%s - command completed.", __func__); |
1170 | switch (command) { | 1194 | switch (command) { |
1171 | case WHITEHEAT_GET_DTR_RTS: | 1195 | case WHITEHEAT_GET_DTR_RTS: |
1172 | info = usb_get_serial_port_data(port); | 1196 | info = usb_get_serial_port_data(port); |
1173 | memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info)); | 1197 | memcpy(&info->mcr, command_info->result_buffer, |
1198 | sizeof(struct whiteheat_dr_info)); | ||
1174 | break; | 1199 | break; |
1175 | } | 1200 | } |
1176 | } | 1201 | } |
1177 | |||
1178 | exit: | 1202 | exit: |
1179 | mutex_unlock(&command_info->mutex); | 1203 | mutex_unlock(&command_info->mutex); |
1180 | return retval; | 1204 | return retval; |
1181 | } | 1205 | } |
1182 | 1206 | ||
1183 | 1207 | ||
1184 | static int firm_open(struct usb_serial_port *port) { | 1208 | static int firm_open(struct usb_serial_port *port) |
1209 | { | ||
1185 | struct whiteheat_simple open_command; | 1210 | struct whiteheat_simple open_command; |
1186 | 1211 | ||
1187 | open_command.port = port->number - port->serial->minor + 1; | 1212 | open_command.port = port->number - port->serial->minor + 1; |
1188 | return firm_send_command(port, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command)); | 1213 | return firm_send_command(port, WHITEHEAT_OPEN, |
1214 | (__u8 *)&open_command, sizeof(open_command)); | ||
1189 | } | 1215 | } |
1190 | 1216 | ||
1191 | 1217 | ||
1192 | static int firm_close(struct usb_serial_port *port) { | 1218 | static int firm_close(struct usb_serial_port *port) |
1219 | { | ||
1193 | struct whiteheat_simple close_command; | 1220 | struct whiteheat_simple close_command; |
1194 | 1221 | ||
1195 | close_command.port = port->number - port->serial->minor + 1; | 1222 | close_command.port = port->number - port->serial->minor + 1; |
1196 | return firm_send_command(port, WHITEHEAT_CLOSE, (__u8 *)&close_command, sizeof(close_command)); | 1223 | return firm_send_command(port, WHITEHEAT_CLOSE, |
1224 | (__u8 *)&close_command, sizeof(close_command)); | ||
1197 | } | 1225 | } |
1198 | 1226 | ||
1199 | 1227 | ||
1200 | static int firm_setup_port(struct tty_struct *tty) { | 1228 | static int firm_setup_port(struct tty_struct *tty) |
1229 | { | ||
1201 | struct usb_serial_port *port = tty->driver_data; | 1230 | struct usb_serial_port *port = tty->driver_data; |
1202 | struct whiteheat_port_settings port_settings; | 1231 | struct whiteheat_port_settings port_settings; |
1203 | unsigned int cflag = tty->termios->c_cflag; | 1232 | unsigned int cflag = tty->termios->c_cflag; |
@@ -1206,14 +1235,14 @@ static int firm_setup_port(struct tty_struct *tty) { | |||
1206 | 1235 | ||
1207 | /* get the byte size */ | 1236 | /* get the byte size */ |
1208 | switch (cflag & CSIZE) { | 1237 | switch (cflag & CSIZE) { |
1209 | case CS5: port_settings.bits = 5; break; | 1238 | case CS5: port_settings.bits = 5; break; |
1210 | case CS6: port_settings.bits = 6; break; | 1239 | case CS6: port_settings.bits = 6; break; |
1211 | case CS7: port_settings.bits = 7; break; | 1240 | case CS7: port_settings.bits = 7; break; |
1212 | default: | 1241 | default: |
1213 | case CS8: port_settings.bits = 8; break; | 1242 | case CS8: port_settings.bits = 8; break; |
1214 | } | 1243 | } |
1215 | dbg("%s - data bits = %d", __func__, port_settings.bits); | 1244 | dbg("%s - data bits = %d", __func__, port_settings.bits); |
1216 | 1245 | ||
1217 | /* determine the parity */ | 1246 | /* determine the parity */ |
1218 | if (cflag & PARENB) | 1247 | if (cflag & PARENB) |
1219 | if (cflag & CMSPAR) | 1248 | if (cflag & CMSPAR) |
@@ -1239,7 +1268,8 @@ static int firm_setup_port(struct tty_struct *tty) { | |||
1239 | 1268 | ||
1240 | /* figure out the flow control settings */ | 1269 | /* figure out the flow control settings */ |
1241 | if (cflag & CRTSCTS) | 1270 | if (cflag & CRTSCTS) |
1242 | port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS); | 1271 | port_settings.hflow = (WHITEHEAT_HFLOW_CTS | |
1272 | WHITEHEAT_HFLOW_RTS); | ||
1243 | else | 1273 | else |
1244 | port_settings.hflow = WHITEHEAT_HFLOW_NONE; | 1274 | port_settings.hflow = WHITEHEAT_HFLOW_NONE; |
1245 | dbg("%s - hardware flow control = %s %s %s %s", __func__, | 1275 | dbg("%s - hardware flow control = %s %s %s %s", __func__, |
@@ -1247,17 +1277,18 @@ static int firm_setup_port(struct tty_struct *tty) { | |||
1247 | (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", | 1277 | (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", |
1248 | (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", | 1278 | (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", |
1249 | (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); | 1279 | (port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : ""); |
1250 | 1280 | ||
1251 | /* determine software flow control */ | 1281 | /* determine software flow control */ |
1252 | if (I_IXOFF(tty)) | 1282 | if (I_IXOFF(tty)) |
1253 | port_settings.sflow = WHITEHEAT_SFLOW_RXTX; | 1283 | port_settings.sflow = WHITEHEAT_SFLOW_RXTX; |
1254 | else | 1284 | else |
1255 | port_settings.sflow = WHITEHEAT_SFLOW_NONE; | 1285 | port_settings.sflow = WHITEHEAT_SFLOW_NONE; |
1256 | dbg("%s - software flow control = %c", __func__, port_settings.sflow); | 1286 | dbg("%s - software flow control = %c", __func__, port_settings.sflow); |
1257 | 1287 | ||
1258 | port_settings.xon = START_CHAR(tty); | 1288 | port_settings.xon = START_CHAR(tty); |
1259 | port_settings.xoff = STOP_CHAR(tty); | 1289 | port_settings.xoff = STOP_CHAR(tty); |
1260 | dbg("%s - XON = %2x, XOFF = %2x", __func__, port_settings.xon, port_settings.xoff); | 1290 | dbg("%s - XON = %2x, XOFF = %2x", |
1291 | __func__, port_settings.xon, port_settings.xoff); | ||
1261 | 1292 | ||
1262 | /* get the baud rate wanted */ | 1293 | /* get the baud rate wanted */ |
1263 | port_settings.baud = tty_get_baud_rate(tty); | 1294 | port_settings.baud = tty_get_baud_rate(tty); |
@@ -1267,61 +1298,74 @@ static int firm_setup_port(struct tty_struct *tty) { | |||
1267 | tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); | 1298 | tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); |
1268 | /* handle any settings that aren't specified in the tty structure */ | 1299 | /* handle any settings that aren't specified in the tty structure */ |
1269 | port_settings.lloop = 0; | 1300 | port_settings.lloop = 0; |
1270 | 1301 | ||
1271 | /* now send the message to the device */ | 1302 | /* now send the message to the device */ |
1272 | return firm_send_command(port, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings)); | 1303 | return firm_send_command(port, WHITEHEAT_SETUP_PORT, |
1304 | (__u8 *)&port_settings, sizeof(port_settings)); | ||
1273 | } | 1305 | } |
1274 | 1306 | ||
1275 | 1307 | ||
1276 | static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) { | 1308 | static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) |
1309 | { | ||
1277 | struct whiteheat_set_rdb rts_command; | 1310 | struct whiteheat_set_rdb rts_command; |
1278 | 1311 | ||
1279 | rts_command.port = port->number - port->serial->minor + 1; | 1312 | rts_command.port = port->number - port->serial->minor + 1; |
1280 | rts_command.state = onoff; | 1313 | rts_command.state = onoff; |
1281 | return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&rts_command, sizeof(rts_command)); | 1314 | return firm_send_command(port, WHITEHEAT_SET_RTS, |
1315 | (__u8 *)&rts_command, sizeof(rts_command)); | ||
1282 | } | 1316 | } |
1283 | 1317 | ||
1284 | 1318 | ||
1285 | static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) { | 1319 | static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) |
1320 | { | ||
1286 | struct whiteheat_set_rdb dtr_command; | 1321 | struct whiteheat_set_rdb dtr_command; |
1287 | 1322 | ||
1288 | dtr_command.port = port->number - port->serial->minor + 1; | 1323 | dtr_command.port = port->number - port->serial->minor + 1; |
1289 | dtr_command.state = onoff; | 1324 | dtr_command.state = onoff; |
1290 | return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&dtr_command, sizeof(dtr_command)); | 1325 | return firm_send_command(port, WHITEHEAT_SET_RTS, |
1326 | (__u8 *)&dtr_command, sizeof(dtr_command)); | ||
1291 | } | 1327 | } |
1292 | 1328 | ||
1293 | 1329 | ||
1294 | static int firm_set_break(struct usb_serial_port *port, __u8 onoff) { | 1330 | static int firm_set_break(struct usb_serial_port *port, __u8 onoff) |
1331 | { | ||
1295 | struct whiteheat_set_rdb break_command; | 1332 | struct whiteheat_set_rdb break_command; |
1296 | 1333 | ||
1297 | break_command.port = port->number - port->serial->minor + 1; | 1334 | break_command.port = port->number - port->serial->minor + 1; |
1298 | break_command.state = onoff; | 1335 | break_command.state = onoff; |
1299 | return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&break_command, sizeof(break_command)); | 1336 | return firm_send_command(port, WHITEHEAT_SET_RTS, |
1337 | (__u8 *)&break_command, sizeof(break_command)); | ||
1300 | } | 1338 | } |
1301 | 1339 | ||
1302 | 1340 | ||
1303 | static int firm_purge(struct usb_serial_port *port, __u8 rxtx) { | 1341 | static int firm_purge(struct usb_serial_port *port, __u8 rxtx) |
1342 | { | ||
1304 | struct whiteheat_purge purge_command; | 1343 | struct whiteheat_purge purge_command; |
1305 | 1344 | ||
1306 | purge_command.port = port->number - port->serial->minor + 1; | 1345 | purge_command.port = port->number - port->serial->minor + 1; |
1307 | purge_command.what = rxtx; | 1346 | purge_command.what = rxtx; |
1308 | return firm_send_command(port, WHITEHEAT_PURGE, (__u8 *)&purge_command, sizeof(purge_command)); | 1347 | return firm_send_command(port, WHITEHEAT_PURGE, |
1348 | (__u8 *)&purge_command, sizeof(purge_command)); | ||
1309 | } | 1349 | } |
1310 | 1350 | ||
1311 | 1351 | ||
1312 | static int firm_get_dtr_rts(struct usb_serial_port *port) { | 1352 | static int firm_get_dtr_rts(struct usb_serial_port *port) |
1353 | { | ||
1313 | struct whiteheat_simple get_dr_command; | 1354 | struct whiteheat_simple get_dr_command; |
1314 | 1355 | ||
1315 | get_dr_command.port = port->number - port->serial->minor + 1; | 1356 | get_dr_command.port = port->number - port->serial->minor + 1; |
1316 | return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, (__u8 *)&get_dr_command, sizeof(get_dr_command)); | 1357 | return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, |
1358 | (__u8 *)&get_dr_command, sizeof(get_dr_command)); | ||
1317 | } | 1359 | } |
1318 | 1360 | ||
1319 | 1361 | ||
1320 | static int firm_report_tx_done(struct usb_serial_port *port) { | 1362 | static int firm_report_tx_done(struct usb_serial_port *port) |
1363 | { | ||
1321 | struct whiteheat_simple close_command; | 1364 | struct whiteheat_simple close_command; |
1322 | 1365 | ||
1323 | close_command.port = port->number - port->serial->minor + 1; | 1366 | close_command.port = port->number - port->serial->minor + 1; |
1324 | return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, (__u8 *)&close_command, sizeof(close_command)); | 1367 | return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, |
1368 | (__u8 *)&close_command, sizeof(close_command)); | ||
1325 | } | 1369 | } |
1326 | 1370 | ||
1327 | 1371 | ||
@@ -1333,7 +1377,7 @@ static int start_command_port(struct usb_serial *serial) | |||
1333 | struct usb_serial_port *command_port; | 1377 | struct usb_serial_port *command_port; |
1334 | struct whiteheat_command_private *command_info; | 1378 | struct whiteheat_command_private *command_info; |
1335 | int retval = 0; | 1379 | int retval = 0; |
1336 | 1380 | ||
1337 | command_port = serial->port[COMMAND_PORT]; | 1381 | command_port = serial->port[COMMAND_PORT]; |
1338 | command_info = usb_get_serial_port_data(command_port); | 1382 | command_info = usb_get_serial_port_data(command_port); |
1339 | mutex_lock(&command_info->mutex); | 1383 | mutex_lock(&command_info->mutex); |
@@ -1344,7 +1388,8 @@ static int start_command_port(struct usb_serial *serial) | |||
1344 | command_port->read_urb->dev = serial->dev; | 1388 | command_port->read_urb->dev = serial->dev; |
1345 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); | 1389 | retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL); |
1346 | if (retval) { | 1390 | if (retval) { |
1347 | err("%s - failed submitting read urb, error %d", __func__, retval); | 1391 | err("%s - failed submitting read urb, error %d", |
1392 | __func__, retval); | ||
1348 | goto exit; | 1393 | goto exit; |
1349 | } | 1394 | } |
1350 | } | 1395 | } |
@@ -1414,7 +1459,8 @@ static int start_port_read(struct usb_serial_port *port) | |||
1414 | } | 1459 | } |
1415 | 1460 | ||
1416 | 1461 | ||
1417 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) | 1462 | static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, |
1463 | struct list_head *head) | ||
1418 | { | 1464 | { |
1419 | struct whiteheat_urb_wrap *wrap; | 1465 | struct whiteheat_urb_wrap *wrap; |
1420 | struct list_head *tmp; | 1466 | struct list_head *tmp; |
@@ -1463,7 +1509,8 @@ static void rx_data_softint(struct work_struct *work) | |||
1463 | urb = wrap->urb; | 1509 | urb = wrap->urb; |
1464 | 1510 | ||
1465 | if (tty && urb->actual_length) { | 1511 | if (tty && urb->actual_length) { |
1466 | int len = tty_buffer_request_room(tty, urb->actual_length); | 1512 | int len = tty_buffer_request_room(tty, |
1513 | urb->actual_length); | ||
1467 | /* This stuff can go away now I suspect */ | 1514 | /* This stuff can go away now I suspect */ |
1468 | if (unlikely(len < urb->actual_length)) { | 1515 | if (unlikely(len < urb->actual_length)) { |
1469 | spin_lock_irqsave(&info->lock, flags); | 1516 | spin_lock_irqsave(&info->lock, flags); |
@@ -1480,7 +1527,8 @@ static void rx_data_softint(struct work_struct *work) | |||
1480 | urb->dev = port->serial->dev; | 1527 | urb->dev = port->serial->dev; |
1481 | result = usb_submit_urb(urb, GFP_ATOMIC); | 1528 | result = usb_submit_urb(urb, GFP_ATOMIC); |
1482 | if (result) { | 1529 | if (result) { |
1483 | err("%s - failed resubmitting read urb, error %d", __func__, result); | 1530 | err("%s - failed resubmitting read urb, error %d", |
1531 | __func__, result); | ||
1484 | spin_lock_irqsave(&info->lock, flags); | 1532 | spin_lock_irqsave(&info->lock, flags); |
1485 | list_add(tmp, &info->rx_urbs_free); | 1533 | list_add(tmp, &info->rx_urbs_free); |
1486 | continue; | 1534 | continue; |
@@ -1499,7 +1547,7 @@ static void rx_data_softint(struct work_struct *work) | |||
1499 | /***************************************************************************** | 1547 | /***************************************************************************** |
1500 | * Connect Tech's White Heat module functions | 1548 | * Connect Tech's White Heat module functions |
1501 | *****************************************************************************/ | 1549 | *****************************************************************************/ |
1502 | static int __init whiteheat_init (void) | 1550 | static int __init whiteheat_init(void) |
1503 | { | 1551 | { |
1504 | int retval; | 1552 | int retval; |
1505 | retval = usb_serial_register(&whiteheat_fake_device); | 1553 | retval = usb_serial_register(&whiteheat_fake_device); |
@@ -1522,19 +1570,19 @@ failed_fake_register: | |||
1522 | } | 1570 | } |
1523 | 1571 | ||
1524 | 1572 | ||
1525 | static void __exit whiteheat_exit (void) | 1573 | static void __exit whiteheat_exit(void) |
1526 | { | 1574 | { |
1527 | usb_deregister (&whiteheat_driver); | 1575 | usb_deregister(&whiteheat_driver); |
1528 | usb_serial_deregister (&whiteheat_fake_device); | 1576 | usb_serial_deregister(&whiteheat_fake_device); |
1529 | usb_serial_deregister (&whiteheat_device); | 1577 | usb_serial_deregister(&whiteheat_device); |
1530 | } | 1578 | } |
1531 | 1579 | ||
1532 | 1580 | ||
1533 | module_init(whiteheat_init); | 1581 | module_init(whiteheat_init); |
1534 | module_exit(whiteheat_exit); | 1582 | module_exit(whiteheat_exit); |
1535 | 1583 | ||
1536 | MODULE_AUTHOR( DRIVER_AUTHOR ); | 1584 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1537 | MODULE_DESCRIPTION( DRIVER_DESC ); | 1585 | MODULE_DESCRIPTION(DRIVER_DESC); |
1538 | MODULE_LICENSE("GPL"); | 1586 | MODULE_LICENSE("GPL"); |
1539 | 1587 | ||
1540 | MODULE_FIRMWARE("whiteheat.fw"); | 1588 | MODULE_FIRMWARE("whiteheat.fw"); |