aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-22 06:09:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 16:03:22 -0400
commit80359a9c5c03d585686e2596c9ee46703eb03047 (patch)
treedcf823d8b97c50c0a0f310936c351af3516574ac /drivers/usb
parent95da310e66ee8090119596c70ca8432e57f9a97f (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')
-rw-r--r--drivers/usb/serial/ezusb.c22
-rw-r--r--drivers/usb/serial/whiteheat.c386
-rw-r--r--drivers/usb/serial/whiteheat.h78
3 files changed, 280 insertions, 206 deletions
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
index cc4fbd9d60be..711e84f6ed82 100644
--- a/drivers/usb/serial/ezusb.c
+++ b/drivers/usb/serial/ezusb.c
@@ -20,7 +20,8 @@
20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ 20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
21#define CPUCS_REG 0x7F92 21#define CPUCS_REG 0x7F92
22 22
23int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest) 23int ezusb_writememory(struct usb_serial *serial, int address,
24 unsigned char *data, int length, __u8 request)
24{ 25{
25 int result; 26 int result;
26 unsigned char *transfer_buffer; 27 unsigned char *transfer_buffer;
@@ -33,26 +34,27 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
33 34
34 transfer_buffer = kmemdup(data, length, GFP_KERNEL); 35 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
35 if (!transfer_buffer) { 36 if (!transfer_buffer) {
36 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length); 37 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
38 __func__, length);
37 return -ENOMEM; 39 return -ENOMEM;
38 } 40 }
39 result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000); 41 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
40 kfree (transfer_buffer); 42 request, 0x40, address, 0, transfer_buffer, length, 3000);
43 kfree(transfer_buffer);
41 return result; 44 return result;
42} 45}
46EXPORT_SYMBOL_GPL(ezusb_writememory);
43 47
44int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit) 48int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit)
45{ 49{
46 int response; 50 int response;
47 51
48 /* dbg("%s - %d", __func__, reset_bit); */ 52 /* dbg("%s - %d", __func__, reset_bit); */
49 response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0); 53 response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
50 if (response < 0) 54 if (response < 0)
51 dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit); 55 dev_err(&serial->dev->dev, "%s- %d failed\n",
56 __func__, reset_bit);
52 return response; 57 return response;
53} 58}
54
55
56EXPORT_SYMBOL_GPL(ezusb_writememory);
57EXPORT_SYMBOL_GPL(ezusb_set_reset); 59EXPORT_SYMBOL_GPL(ezusb_set_reset);
58 60
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
128MODULE_DEVICE_TABLE (usb, id_table_combined); 130MODULE_DEVICE_TABLE(usb, id_table_combined);
129 131
130static struct usb_driver whiteheat_driver = { 132static 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 */
139static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id); 141static int whiteheat_firmware_download(struct usb_serial *serial,
140static int whiteheat_firmware_attach (struct usb_serial *serial); 142 const struct usb_device_id *id);
143static 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 */
143static int whiteheat_attach (struct usb_serial *serial); 146static int whiteheat_attach(struct usb_serial *serial);
144static void whiteheat_shutdown (struct usb_serial *serial); 147static void whiteheat_shutdown(struct usb_serial *serial);
145static int whiteheat_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 148static int whiteheat_open(struct tty_struct *tty,
146static void whiteheat_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 149 struct usb_serial_port *port, struct file *filp);
147static int whiteheat_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); 150static void whiteheat_close(struct tty_struct *tty,
148static int whiteheat_write_room (struct tty_struct *tty); 151 struct usb_serial_port *port, struct file *filp);
149static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); 152static int whiteheat_write(struct tty_struct *tty,
150static void whiteheat_set_termios (struct tty_struct *tty, struct usb_serial_port *port, struct ktermios * old); 153 struct usb_serial_port *port,
151static int whiteheat_tiocmget (struct tty_struct *tty, struct file *file); 154 const unsigned char *buf, int count);
152static int whiteheat_tiocmset (struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); 155static int whiteheat_write_room(struct tty_struct *tty);
153static void whiteheat_break_ctl (struct tty_struct *tty, int break_state); 156static int whiteheat_ioctl(struct tty_struct *tty, struct file *file,
154static int whiteheat_chars_in_buffer (struct tty_struct *tty); 157 unsigned int cmd, unsigned long arg);
155static void whiteheat_throttle (struct tty_struct *tty); 158static void whiteheat_set_termios(struct tty_struct *tty,
156static void whiteheat_unthrottle (struct tty_struct *tty); 159 struct usb_serial_port *port, struct ktermios *old);
157static void whiteheat_read_callback (struct urb *urb); 160static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file);
158static void whiteheat_write_callback (struct urb *urb); 161static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file,
162 unsigned int set, unsigned int clear);
163static void whiteheat_break_ctl(struct tty_struct *tty, int break_state);
164static int whiteheat_chars_in_buffer(struct tty_struct *tty);
165static void whiteheat_throttle(struct tty_struct *tty);
166static void whiteheat_unthrottle(struct tty_struct *tty);
167static void whiteheat_read_callback(struct urb *urb);
168static void whiteheat_write_callback(struct urb *urb);
159 169
160static struct usb_serial_driver whiteheat_fake_device = { 170static 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);
239static void command_port_read_callback(struct urb *urb); 251static void command_port_read_callback(struct urb *urb);
240 252
241static int start_port_read(struct usb_serial_port *port); 253static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 254static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb,
255 struct list_head *head);
243static struct list_head *list_first(struct list_head *head); 256static struct list_head *list_first(struct list_head *head);
244static void rx_data_softint(struct work_struct *work); 257static void rx_data_softint(struct work_struct *work);
245 258
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 259static int firm_send_command(struct usb_serial_port *port, __u8 command,
260 __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 261static int firm_open(struct usb_serial_port *port);
248static int firm_close(struct usb_serial_port *port); 262static int firm_close(struct usb_serial_port *port);
249static int firm_setup_port(struct tty_struct *tty); 263static 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*/
281static int whiteheat_firmware_download (struct usb_serial *serial, const struct usb_device_id *id) 295static 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
358static int whiteheat_firmware_attach (struct usb_serial *serial) 373static 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 *****************************************************************************/
368static int whiteheat_attach (struct usb_serial *serial) 383static 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
526no_firmware: 553no_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
573static void whiteheat_shutdown (struct usb_serial *serial) 603static 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 645static int whiteheat_open(struct tty_struct *tty,
616static 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
670static void whiteheat_close(struct tty_struct *tty, 700static 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
800static int whiteheat_write_room(struct tty_struct *tty) 832static 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 852static int whiteheat_tiocmget(struct tty_struct *tty, struct file *file)
821static 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 869static int whiteheat_tiocmset(struct tty_struct *tty, struct file *file,
839static 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
863static int whiteheat_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) 893static 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
909static void whiteheat_set_termios(struct tty_struct *tty, struct usb_serial_port *port, struct ktermios *old_termios) 926static 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 933static void whiteheat_break_ctl(struct tty_struct *tty, int break_state)
915static 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
944static void whiteheat_throttle (struct tty_struct *tty) 963static 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
960static void whiteheat_unthrottle (struct tty_struct *tty) 979static 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 *****************************************************************************/
1123static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize) 1146static 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
1178exit: 1202exit:
1179 mutex_unlock(&command_info->mutex); 1203 mutex_unlock(&command_info->mutex);
1180 return retval; 1204 return retval;
1181} 1205}
1182 1206
1183 1207
1184static int firm_open(struct usb_serial_port *port) { 1208static 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
1192static int firm_close(struct usb_serial_port *port) { 1218static 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
1200static int firm_setup_port(struct tty_struct *tty) { 1228static 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
1276static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) { 1308static 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
1285static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) { 1319static 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
1294static int firm_set_break(struct usb_serial_port *port, __u8 onoff) { 1330static 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
1303static int firm_purge(struct usb_serial_port *port, __u8 rxtx) { 1341static 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
1312static int firm_get_dtr_rts(struct usb_serial_port *port) { 1352static 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
1320static int firm_report_tx_done(struct usb_serial_port *port) { 1362static 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
1417static struct whiteheat_urb_wrap *urb_to_wrap(struct urb* urb, struct list_head *head) 1462static 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 *****************************************************************************/
1502static int __init whiteheat_init (void) 1550static 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
1525static void __exit whiteheat_exit (void) 1573static 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
1533module_init(whiteheat_init); 1581module_init(whiteheat_init);
1534module_exit(whiteheat_exit); 1582module_exit(whiteheat_exit);
1535 1583
1536MODULE_AUTHOR( DRIVER_AUTHOR ); 1584MODULE_AUTHOR(DRIVER_AUTHOR);
1537MODULE_DESCRIPTION( DRIVER_DESC ); 1585MODULE_DESCRIPTION(DRIVER_DESC);
1538MODULE_LICENSE("GPL"); 1586MODULE_LICENSE("GPL");
1539 1587
1540MODULE_FIRMWARE("whiteheat.fw"); 1588MODULE_FIRMWARE("whiteheat.fw");
diff --git a/drivers/usb/serial/whiteheat.h b/drivers/usb/serial/whiteheat.h
index f16079705664..38065df4d2d8 100644
--- a/drivers/usb/serial/whiteheat.h
+++ b/drivers/usb/serial/whiteheat.h
@@ -2,7 +2,7 @@
2 * USB ConnectTech WhiteHEAT driver 2 * USB ConnectTech WhiteHEAT driver
3 * 3 *
4 * Copyright (C) 2002 4 * Copyright (C) 2002
5 * Connect Tech Inc. 5 * Connect Tech Inc.
6 * 6 *
7 * Copyright (C) 1999, 2000 7 * Copyright (C) 1999, 2000
8 * Greg Kroah-Hartman (greg@kroah.com) 8 * Greg Kroah-Hartman (greg@kroah.com)
@@ -12,7 +12,8 @@
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 */ 18 */
18 19
@@ -30,13 +31,16 @@
30#define WHITEHEAT_DUMP 7 /* dump memory */ 31#define WHITEHEAT_DUMP 7 /* dump memory */
31#define WHITEHEAT_STATUS 8 /* get status */ 32#define WHITEHEAT_STATUS 8 /* get status */
32#define WHITEHEAT_PURGE 9 /* clear the UART fifos */ 33#define WHITEHEAT_PURGE 9 /* clear the UART fifos */
33#define WHITEHEAT_GET_DTR_RTS 10 /* get the state of DTR and RTS for a port */ 34#define WHITEHEAT_GET_DTR_RTS 10 /* get the state of DTR and RTS
34#define WHITEHEAT_GET_HW_INFO 11 /* get EEPROM info and hardware ID */ 35 for a port */
36#define WHITEHEAT_GET_HW_INFO 11 /* get EEPROM info and
37 hardware ID */
35#define WHITEHEAT_REPORT_TX_DONE 12 /* get the next TX done */ 38#define WHITEHEAT_REPORT_TX_DONE 12 /* get the next TX done */
36#define WHITEHEAT_EVENT 13 /* unsolicited status events */ 39#define WHITEHEAT_EVENT 13 /* unsolicited status events */
37#define WHITEHEAT_ECHO 14 /* send data to the indicated IN endpoint */ 40#define WHITEHEAT_ECHO 14 /* send data to the indicated
38#define WHITEHEAT_DO_TEST 15 /* perform the specified test */ 41 IN endpoint */
39#define WHITEHEAT_CMD_COMPLETE 16 /* reply for certain commands */ 42#define WHITEHEAT_DO_TEST 15 /* perform specified test */
43#define WHITEHEAT_CMD_COMPLETE 16 /* reply for some commands */
40#define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */ 44#define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */
41 45
42 46
@@ -67,20 +71,28 @@ struct whiteheat_simple {
67#define WHITEHEAT_PAR_MARK '1' /* mark (force 1) parity */ 71#define WHITEHEAT_PAR_MARK '1' /* mark (force 1) parity */
68 72
69#define WHITEHEAT_SFLOW_NONE 'n' /* no software flow control */ 73#define WHITEHEAT_SFLOW_NONE 'n' /* no software flow control */
70#define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX fills/empties */ 74#define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX
71#define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will stop/start TX */ 75 fills/empties */
76#define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will
77 stop/start TX */
72#define WHITEHEAT_SFLOW_RXTX 'b' /* both SFLOW_RX and SFLOW_TX */ 78#define WHITEHEAT_SFLOW_RXTX 'b' /* both SFLOW_RX and SFLOW_TX */
73 79
74#define WHITEHEAT_HFLOW_NONE 0x00 /* no hardware flow control */ 80#define WHITEHEAT_HFLOW_NONE 0x00 /* no hardware flow control */
75#define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit, off otherwise */ 81#define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit,
76#define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX fills/empties */ 82 off otherwise */
77#define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on will stop/start TX */ 83#define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX
78#define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on will stop/start TX */ 84 fills/empties */
79#define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX fills/empties */ 85#define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on
86 will stop/start TX */
87#define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on
88 will stop/start TX */
89#define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX
90 fills/empties */
80 91
81struct whiteheat_port_settings { 92struct whiteheat_port_settings {
82 __u8 port; /* port number (1 to N) */ 93 __u8 port; /* port number (1 to N) */
83 __u32 baud; /* any value 7 - 460800, firmware calculates best fit; arrives little endian */ 94 __u32 baud; /* any value 7 - 460800, firmware calculates
95 best fit; arrives little endian */
84 __u8 bits; /* 5, 6, 7, or 8 */ 96 __u8 bits; /* 5, 6, 7, or 8 */
85 __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */ 97 __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
86 __u8 parity; /* see WHITEHEAT_PAR_* above */ 98 __u8 parity; /* see WHITEHEAT_PAR_* above */
@@ -167,12 +179,14 @@ struct whiteheat_echo {
167 */ 179 */
168#define WHITEHEAT_TEST_UART_RW 0x01 /* read/write uart registers */ 180#define WHITEHEAT_TEST_UART_RW 0x01 /* read/write uart registers */
169#define WHITEHEAT_TEST_UART_INTR 0x02 /* uart interrupt */ 181#define WHITEHEAT_TEST_UART_INTR 0x02 /* uart interrupt */
170#define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for PORT_CONT/PORT_DISCONT */ 182#define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for
183 PORT_CONT/PORT_DISCONT */
171#define WHITEHEAT_TEST_PORT_CONT 0x04 /* port connect */ 184#define WHITEHEAT_TEST_PORT_CONT 0x04 /* port connect */
172#define WHITEHEAT_TEST_PORT_DISCONT 0x05 /* port disconnect */ 185#define WHITEHEAT_TEST_PORT_DISCONT 0x05 /* port disconnect */
173#define WHITEHEAT_TEST_UART_CLK_START 0x06 /* uart clock test start */ 186#define WHITEHEAT_TEST_UART_CLK_START 0x06 /* uart clock test start */
174#define WHITEHEAT_TEST_UART_CLK_STOP 0x07 /* uart clock test stop */ 187#define WHITEHEAT_TEST_UART_CLK_STOP 0x07 /* uart clock test stop */
175#define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a loopback cable/connector */ 188#define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a
189 loopback cable/connector */
176#define WHITEHEAT_TEST_ERASE_EEPROM 0x09 /* erase eeprom */ 190#define WHITEHEAT_TEST_ERASE_EEPROM 0x09 /* erase eeprom */
177#define WHITEHEAT_TEST_READ_EEPROM 0x0a /* read eeprom */ 191#define WHITEHEAT_TEST_READ_EEPROM 0x0a /* read eeprom */
178#define WHITEHEAT_TEST_PROGRAM_EEPROM 0x0b /* program eeprom */ 192#define WHITEHEAT_TEST_PROGRAM_EEPROM 0x0b /* program eeprom */
@@ -198,19 +212,27 @@ struct whiteheat_test {
198#define WHITEHEAT_EVENT_CONNECT 0x08 /* connect field is valid */ 212#define WHITEHEAT_EVENT_CONNECT 0x08 /* connect field is valid */
199 213
200#define WHITEHEAT_FLOW_NONE 0x00 /* no flow control active */ 214#define WHITEHEAT_FLOW_NONE 0x00 /* no flow control active */
201#define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS (waiting for CTS to go on) */ 215#define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS
202#define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped by RTS */ 216 (waiting for CTS to go on) */
203#define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF received (waiting for XON) */ 217#define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped
204#define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF transmitted */ 218 by RTS */
219#define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF
220 received (waiting for XON) */
221#define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF
222 transmitted */
205#define WHITEHEAT_FLOW_TX_DONE 0x80 /* TX has completed */ 223#define WHITEHEAT_FLOW_TX_DONE 0x80 /* TX has completed */
206 224
207struct whiteheat_status_info { 225struct whiteheat_status_info {
208 __u8 port; /* port number (1 to N) */ 226 __u8 port; /* port number (1 to N) */
209 __u8 event; /* indicates what the current event is, see WHITEHEAT_EVENT_* above */ 227 __u8 event; /* indicates what the current event is,
210 __u8 modem; /* modem signal status (copy of uart's MSR register) */ 228 see WHITEHEAT_EVENT_* above */
229 __u8 modem; /* modem signal status (copy of uart's
230 MSR register) */
211 __u8 error; /* line status (copy of uart's LSR register) */ 231 __u8 error; /* line status (copy of uart's LSR register) */
212 __u8 flow; /* flow control state, see WHITEHEAT_FLOW_* above */ 232 __u8 flow; /* flow control state, see WHITEHEAT_FLOW_*
213 __u8 connect; /* 0 means not connected, non-zero means connected */ 233 above */
234 __u8 connect; /* 0 means not connected, non-zero means
235 connected */
214}; 236};
215 237
216 238
@@ -256,7 +278,8 @@ struct whiteheat_hw_info {
256struct whiteheat_event_info { 278struct whiteheat_event_info {
257 __u8 port; /* port number (1 to N) */ 279 __u8 port; /* port number (1 to N) */
258 __u8 event; /* see whiteheat_status_info.event */ 280 __u8 event; /* see whiteheat_status_info.event */
259 __u8 info; /* see whiteheat_status_info.modem, .error, .flow, .connect */ 281 __u8 info; /* see whiteheat_status_info.modem, .error,
282 .flow, .connect */
260}; 283};
261 284
262 285
@@ -269,7 +292,8 @@ struct whiteheat_event_info {
269 292
270struct whiteheat_test_info { 293struct whiteheat_test_info {
271 __u8 port; /* port number (1 to N) */ 294 __u8 port; /* port number (1 to N) */
272 __u8 test; /* indicates which test this is a response for, see WHITEHEAT_DO_TEST above */ 295 __u8 test; /* indicates which test this is a response for,
296 see WHITEHEAT_DO_TEST above */
273 __u8 status; /* see WHITEHEAT_TEST_* above */ 297 __u8 status; /* see WHITEHEAT_TEST_* above */
274 __u8 results[32]; /* test-dependent results */ 298 __u8 results[32]; /* test-dependent results */
275}; 299};