aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/serial/visor.c340
1 files changed, 191 insertions, 149 deletions
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 373a3c7ea77b..cf8924f9a2cc 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -9,7 +9,8 @@
9 * modify it under the terms of the GNU General Public License version 9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation. 10 * 2 as published by the Free Software Foundation.
11 * 11 *
12 * See Documentation/usb/usb-serial.txt for more information on using this driver 12 * See Documentation/usb/usb-serial.txt for more information on using this
13 * driver
13 * 14 *
14 */ 15 */
15 16
@@ -23,7 +24,7 @@
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
25#include <linux/spinlock.h> 26#include <linux/spinlock.h>
26#include <asm/uaccess.h> 27#include <linux/uaccess.h>
27#include <linux/usb.h> 28#include <linux/usb.h>
28#include <linux/usb/serial.h> 29#include <linux/usb/serial.h>
29#include "visor.h" 30#include "visor.h"
@@ -35,23 +36,29 @@
35#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver" 36#define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
36 37
37/* function prototypes for a handspring visor */ 38/* function prototypes for a handspring visor */
38static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 39static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
39static void visor_close (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp); 40 struct file *filp);
40static int visor_write (struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count); 41static void visor_close(struct tty_struct *tty, struct usb_serial_port *port,
41static int visor_write_room (struct tty_struct *tty); 42 struct file *filp);
42static void visor_throttle (struct tty_struct *tty); 43static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
43static void visor_unthrottle (struct tty_struct *tty); 44 const unsigned char *buf, int count);
44static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id); 45static int visor_write_room(struct tty_struct *tty);
46static void visor_throttle(struct tty_struct *tty);
47static void visor_unthrottle(struct tty_struct *tty);
48static int visor_probe(struct usb_serial *serial,
49 const struct usb_device_id *id);
45static int visor_calc_num_ports(struct usb_serial *serial); 50static int visor_calc_num_ports(struct usb_serial *serial);
46static void visor_shutdown (struct usb_serial *serial); 51static void visor_shutdown(struct usb_serial *serial);
47static void visor_write_bulk_callback (struct urb *urb); 52static void visor_write_bulk_callback(struct urb *urb);
48static void visor_read_bulk_callback (struct urb *urb); 53static void visor_read_bulk_callback(struct urb *urb);
49static void visor_read_int_callback (struct urb *urb); 54static void visor_read_int_callback(struct urb *urb);
50static int clie_3_5_startup (struct usb_serial *serial); 55static int clie_3_5_startup(struct usb_serial *serial);
51static int treo_attach (struct usb_serial *serial); 56static int treo_attach(struct usb_serial *serial);
52static int clie_5_attach (struct usb_serial *serial); 57static int clie_5_attach(struct usb_serial *serial);
53static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id); 58static int palm_os_3_probe(struct usb_serial *serial,
54static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id); 59 const struct usb_device_id *id);
60static int palm_os_4_probe(struct usb_serial *serial,
61 const struct usb_device_id *id);
55 62
56/* Parameters that may be passed into the module. */ 63/* Parameters that may be passed into the module. */
57static int debug; 64static int debug;
@@ -103,13 +110,13 @@ static struct usb_device_id id_table [] = {
103 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 110 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
104 { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID), 111 { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID),
105 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 112 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
106 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), 113 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID),
107 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 114 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
108 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), 115 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID),
109 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 116 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
110 { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID), 117 { USB_DEVICE(TAPWAVE_VENDOR_ID, TAPWAVE_ZODIAC_ID),
111 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 118 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
112 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID), 119 { USB_DEVICE(GARMIN_VENDOR_ID, GARMIN_IQUE_3600_ID),
113 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 120 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
114 { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID), 121 { USB_DEVICE(ACEECA_VENDOR_ID, ACEECA_MEZ1000_ID),
115 .driver_info = (kernel_ulong_t)&palm_os_4_probe }, 122 .driver_info = (kernel_ulong_t)&palm_os_4_probe },
@@ -168,7 +175,7 @@ static struct usb_device_id id_table_combined [] = {
168 { } /* Terminating entry */ 175 { } /* Terminating entry */
169}; 176};
170 177
171MODULE_DEVICE_TABLE (usb, id_table_combined); 178MODULE_DEVICE_TABLE(usb, id_table_combined);
172 179
173static struct usb_driver visor_driver = { 180static struct usb_driver visor_driver = {
174 .name = "visor", 181 .name = "visor",
@@ -178,7 +185,8 @@ static struct usb_driver visor_driver = {
178 .no_dynamic_id = 1, 185 .no_dynamic_id = 1,
179}; 186};
180 187
181/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ 188/* All of the device info needed for the Handspring Visor,
189 and Palm 4.0 devices */
182static struct usb_serial_driver handspring_device = { 190static struct usb_serial_driver handspring_device = {
183 .driver = { 191 .driver = {
184 .owner = THIS_MODULE, 192 .owner = THIS_MODULE,
@@ -266,7 +274,8 @@ static int stats;
266/****************************************************************************** 274/******************************************************************************
267 * Handspring Visor specific driver functions 275 * Handspring Visor specific driver functions
268 ******************************************************************************/ 276 ******************************************************************************/
269static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, struct file *filp) 277static int visor_open(struct tty_struct *tty, struct usb_serial_port *port,
278 struct file *filp)
270{ 279{
271 struct usb_serial *serial = port->serial; 280 struct usb_serial *serial = port->serial;
272 struct visor_private *priv = usb_get_serial_port_data(port); 281 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -296,39 +305,41 @@ static int visor_open (struct tty_struct *tty, struct usb_serial_port *port, str
296 tty->low_latency = 1; 305 tty->low_latency = 1;
297 306
298 /* Start reading from the device */ 307 /* Start reading from the device */
299 usb_fill_bulk_urb (port->read_urb, serial->dev, 308 usb_fill_bulk_urb(port->read_urb, serial->dev,
300 usb_rcvbulkpipe (serial->dev, 309 usb_rcvbulkpipe(serial->dev,
301 port->bulk_in_endpointAddress), 310 port->bulk_in_endpointAddress),
302 port->read_urb->transfer_buffer, 311 port->read_urb->transfer_buffer,
303 port->read_urb->transfer_buffer_length, 312 port->read_urb->transfer_buffer_length,
304 visor_read_bulk_callback, port); 313 visor_read_bulk_callback, port);
305 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 314 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
306 if (result) { 315 if (result) {
307 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", 316 dev_err(&port->dev,
308 __func__, result); 317 "%s - failed submitting read urb, error %d\n",
318 __func__, result);
309 goto exit; 319 goto exit;
310 } 320 }
311 321
312 if (port->interrupt_in_urb) { 322 if (port->interrupt_in_urb) {
313 dbg("%s - adding interrupt input for treo", __func__); 323 dbg("%s - adding interrupt input for treo", __func__);
314 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 324 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
315 if (result) 325 if (result)
316 dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", 326 dev_err(&port->dev,
317 __func__, result); 327 "%s - failed submitting interrupt urb, error %d\n",
328 __func__, result);
318 } 329 }
319exit: 330exit:
320 return result; 331 return result;
321} 332}
322 333
323 334
324static void visor_close(struct tty_struct *tty, 335static void visor_close(struct tty_struct *tty,
325 struct usb_serial_port *port, struct file * filp) 336 struct usb_serial_port *port, struct file *filp)
326{ 337{
327 struct visor_private *priv = usb_get_serial_port_data(port); 338 struct visor_private *priv = usb_get_serial_port_data(port);
328 unsigned char *transfer_buffer; 339 unsigned char *transfer_buffer;
329 340
330 dbg("%s - port %d", __func__, port->number); 341 dbg("%s - port %d", __func__, port->number);
331 342
332 /* shutdown our urbs */ 343 /* shutdown our urbs */
333 usb_kill_urb(port->read_urb); 344 usb_kill_urb(port->read_urb);
334 usb_kill_urb(port->interrupt_in_urb); 345 usb_kill_urb(port->interrupt_in_urb);
@@ -336,14 +347,14 @@ static void visor_close(struct tty_struct *tty,
336 mutex_lock(&port->serial->disc_mutex); 347 mutex_lock(&port->serial->disc_mutex);
337 if (!port->serial->disconnected) { 348 if (!port->serial->disconnected) {
338 /* Try to send shutdown message, unless the device is gone */ 349 /* Try to send shutdown message, unless the device is gone */
339 transfer_buffer = kmalloc (0x12, GFP_KERNEL); 350 transfer_buffer = kmalloc(0x12, GFP_KERNEL);
340 if (transfer_buffer) { 351 if (transfer_buffer) {
341 usb_control_msg (port->serial->dev, 352 usb_control_msg(port->serial->dev,
342 usb_rcvctrlpipe(port->serial->dev, 0), 353 usb_rcvctrlpipe(port->serial->dev, 0),
343 VISOR_CLOSE_NOTIFICATION, 0xc2, 354 VISOR_CLOSE_NOTIFICATION, 0xc2,
344 0x0000, 0x0000, 355 0x0000, 0x0000,
345 transfer_buffer, 0x12, 300); 356 transfer_buffer, 0x12, 300);
346 kfree (transfer_buffer); 357 kfree(transfer_buffer);
347 } 358 }
348 } 359 }
349 mutex_unlock(&port->serial->disc_mutex); 360 mutex_unlock(&port->serial->disc_mutex);
@@ -375,7 +386,7 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
375 priv->outstanding_urbs++; 386 priv->outstanding_urbs++;
376 spin_unlock_irqrestore(&priv->lock, flags); 387 spin_unlock_irqrestore(&priv->lock, flags);
377 388
378 buffer = kmalloc (count, GFP_ATOMIC); 389 buffer = kmalloc(count, GFP_ATOMIC);
379 if (!buffer) { 390 if (!buffer) {
380 dev_err(&port->dev, "out of memory\n"); 391 dev_err(&port->dev, "out of memory\n");
381 count = -ENOMEM; 392 count = -ENOMEM;
@@ -389,21 +400,22 @@ static int visor_write(struct tty_struct *tty, struct usb_serial_port *port,
389 goto error_no_urb; 400 goto error_no_urb;
390 } 401 }
391 402
392 memcpy (buffer, buf, count); 403 memcpy(buffer, buf, count);
393 404
394 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); 405 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
395 406
396 usb_fill_bulk_urb (urb, serial->dev, 407 usb_fill_bulk_urb(urb, serial->dev,
397 usb_sndbulkpipe (serial->dev, 408 usb_sndbulkpipe(serial->dev,
398 port->bulk_out_endpointAddress), 409 port->bulk_out_endpointAddress),
399 buffer, count, 410 buffer, count,
400 visor_write_bulk_callback, port); 411 visor_write_bulk_callback, port);
401 412
402 /* send it down the pipe */ 413 /* send it down the pipe */
403 status = usb_submit_urb(urb, GFP_ATOMIC); 414 status = usb_submit_urb(urb, GFP_ATOMIC);
404 if (status) { 415 if (status) {
405 dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed with status = %d\n", 416 dev_err(&port->dev,
406 __func__, status); 417 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
418 __func__, status);
407 count = status; 419 count = status;
408 goto error; 420 goto error;
409 } else { 421 } else {
@@ -429,7 +441,7 @@ error_no_buffer:
429} 441}
430 442
431 443
432static int visor_write_room (struct tty_struct *tty) 444static int visor_write_room(struct tty_struct *tty)
433{ 445{
434 struct usb_serial_port *port = tty->driver_data; 446 struct usb_serial_port *port = tty->driver_data;
435 struct visor_private *priv = usb_get_serial_port_data(port); 447 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -455,7 +467,7 @@ static int visor_write_room (struct tty_struct *tty)
455} 467}
456 468
457 469
458static void visor_write_bulk_callback (struct urb *urb) 470static void visor_write_bulk_callback(struct urb *urb)
459{ 471{
460 struct usb_serial_port *port = urb->context; 472 struct usb_serial_port *port = urb->context;
461 struct visor_private *priv = usb_get_serial_port_data(port); 473 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -463,7 +475,7 @@ static void visor_write_bulk_callback (struct urb *urb)
463 unsigned long flags; 475 unsigned long flags;
464 476
465 /* free up the transfer buffer, as usb_free_urb() does not do this */ 477 /* free up the transfer buffer, as usb_free_urb() does not do this */
466 kfree (urb->transfer_buffer); 478 kfree(urb->transfer_buffer);
467 479
468 dbg("%s - port %d", __func__, port->number); 480 dbg("%s - port %d", __func__, port->number);
469 481
@@ -479,7 +491,7 @@ static void visor_write_bulk_callback (struct urb *urb)
479} 491}
480 492
481 493
482static void visor_read_bulk_callback (struct urb *urb) 494static void visor_read_bulk_callback(struct urb *urb)
483{ 495{
484 struct usb_serial_port *port = urb->context; 496 struct usb_serial_port *port = urb->context;
485 struct visor_private *priv = usb_get_serial_port_data(port); 497 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -497,11 +509,13 @@ static void visor_read_bulk_callback (struct urb *urb)
497 return; 509 return;
498 } 510 }
499 511
500 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, data); 512 usb_serial_debug_data(debug, &port->dev, __func__,
513 urb->actual_length, data);
501 514
502 tty = port->port.tty; 515 tty = port->port.tty;
503 if (tty && urb->actual_length) { 516 if (tty && urb->actual_length) {
504 available_room = tty_buffer_request_room(tty, urb->actual_length); 517 available_room = tty_buffer_request_room(tty,
518 urb->actual_length);
505 if (available_room) { 519 if (available_room) {
506 tty_insert_flip_string(tty, data, available_room); 520 tty_insert_flip_string(tty, data, available_room);
507 tty_flip_buffer_push(tty); 521 tty_flip_buffer_push(tty);
@@ -515,22 +529,23 @@ static void visor_read_bulk_callback (struct urb *urb)
515 529
516 /* Continue trying to always read if we should */ 530 /* Continue trying to always read if we should */
517 if (!priv->throttled) { 531 if (!priv->throttled) {
518 usb_fill_bulk_urb (port->read_urb, port->serial->dev, 532 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
519 usb_rcvbulkpipe(port->serial->dev, 533 usb_rcvbulkpipe(port->serial->dev,
520 port->bulk_in_endpointAddress), 534 port->bulk_in_endpointAddress),
521 port->read_urb->transfer_buffer, 535 port->read_urb->transfer_buffer,
522 port->read_urb->transfer_buffer_length, 536 port->read_urb->transfer_buffer_length,
523 visor_read_bulk_callback, port); 537 visor_read_bulk_callback, port);
524 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 538 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
525 if (result) 539 if (result)
526 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n", __func__, result); 540 dev_err(&port->dev,
527 } else { 541 "%s - failed resubmitting read urb, error %d\n",
542 __func__, result);
543 } else
528 priv->actually_throttled = 1; 544 priv->actually_throttled = 1;
529 }
530 spin_unlock(&priv->lock); 545 spin_unlock(&priv->lock);
531} 546}
532 547
533static void visor_read_int_callback (struct urb *urb) 548static void visor_read_int_callback(struct urb *urb)
534{ 549{
535 struct usb_serial_port *port = urb->context; 550 struct usb_serial_port *port = urb->context;
536 int status = urb->status; 551 int status = urb->status;
@@ -564,13 +579,14 @@ static void visor_read_int_callback (struct urb *urb)
564 urb->actual_length, urb->transfer_buffer); 579 urb->actual_length, urb->transfer_buffer);
565 580
566exit: 581exit:
567 result = usb_submit_urb (urb, GFP_ATOMIC); 582 result = usb_submit_urb(urb, GFP_ATOMIC);
568 if (result) 583 if (result)
569 dev_err(&urb->dev->dev, "%s - Error %d submitting interrupt urb\n", 584 dev_err(&urb->dev->dev,
570 __func__, result); 585 "%s - Error %d submitting interrupt urb\n",
586 __func__, result);
571} 587}
572 588
573static void visor_throttle (struct tty_struct *tty) 589static void visor_throttle(struct tty_struct *tty)
574{ 590{
575 struct usb_serial_port *port = tty->driver_data; 591 struct usb_serial_port *port = tty->driver_data;
576 struct visor_private *priv = usb_get_serial_port_data(port); 592 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -583,7 +599,7 @@ static void visor_throttle (struct tty_struct *tty)
583} 599}
584 600
585 601
586static void visor_unthrottle (struct tty_struct *tty) 602static void visor_unthrottle(struct tty_struct *tty)
587{ 603{
588 struct usb_serial_port *port = tty->driver_data; 604 struct usb_serial_port *port = tty->driver_data;
589 struct visor_private *priv = usb_get_serial_port_data(port); 605 struct visor_private *priv = usb_get_serial_port_data(port);
@@ -599,10 +615,13 @@ static void visor_unthrottle (struct tty_struct *tty)
599 port->read_urb->dev = port->serial->dev; 615 port->read_urb->dev = port->serial->dev;
600 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 616 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
601 if (result) 617 if (result)
602 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __func__, result); 618 dev_err(&port->dev,
619 "%s - failed submitting read urb, error %d\n",
620 __func__, result);
603} 621}
604 622
605static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_id *id) 623static int palm_os_3_probe(struct usb_serial *serial,
624 const struct usb_device_id *id)
606{ 625{
607 struct device *dev = &serial->dev->dev; 626 struct device *dev = &serial->dev->dev;
608 struct visor_connection_info *connection_info; 627 struct visor_connection_info *connection_info;
@@ -614,7 +633,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
614 633
615 dbg("%s", __func__); 634 dbg("%s", __func__);
616 635
617 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); 636 transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL);
618 if (!transfer_buffer) { 637 if (!transfer_buffer) {
619 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, 638 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
620 sizeof(*connection_info)); 639 sizeof(*connection_info));
@@ -622,7 +641,7 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
622 } 641 }
623 642
624 /* send a get connection info request */ 643 /* send a get connection info request */
625 retval = usb_control_msg (serial->dev, 644 retval = usb_control_msg(serial->dev,
626 usb_rcvctrlpipe(serial->dev, 0), 645 usb_rcvctrlpipe(serial->dev, 0),
627 VISOR_GET_CONNECTION_INFORMATION, 646 VISOR_GET_CONNECTION_INFORMATION,
628 0xc2, 0x0000, 0x0000, transfer_buffer, 647 0xc2, 0x0000, 0x0000, transfer_buffer,
@@ -634,29 +653,31 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
634 } 653 }
635 654
636 if (retval == sizeof(*connection_info)) { 655 if (retval == sizeof(*connection_info)) {
637 connection_info = (struct visor_connection_info *)transfer_buffer; 656 connection_info = (struct visor_connection_info *)
657 transfer_buffer;
638 658
639 num_ports = le16_to_cpu(connection_info->num_ports); 659 num_ports = le16_to_cpu(connection_info->num_ports);
640 for (i = 0; i < num_ports; ++i) { 660 for (i = 0; i < num_ports; ++i) {
641 switch (connection_info->connections[i].port_function_id) { 661 switch (
642 case VISOR_FUNCTION_GENERIC: 662 connection_info->connections[i].port_function_id) {
643 string = "Generic"; 663 case VISOR_FUNCTION_GENERIC:
644 break; 664 string = "Generic";
645 case VISOR_FUNCTION_DEBUGGER: 665 break;
646 string = "Debugger"; 666 case VISOR_FUNCTION_DEBUGGER:
647 break; 667 string = "Debugger";
648 case VISOR_FUNCTION_HOTSYNC: 668 break;
649 string = "HotSync"; 669 case VISOR_FUNCTION_HOTSYNC:
650 break; 670 string = "HotSync";
651 case VISOR_FUNCTION_CONSOLE: 671 break;
652 string = "Console"; 672 case VISOR_FUNCTION_CONSOLE:
653 break; 673 string = "Console";
654 case VISOR_FUNCTION_REMOTE_FILE_SYS: 674 break;
655 string = "Remote File System"; 675 case VISOR_FUNCTION_REMOTE_FILE_SYS:
656 break; 676 string = "Remote File System";
657 default: 677 break;
658 string = "unknown"; 678 default:
659 break; 679 string = "unknown";
680 break;
660 } 681 }
661 dev_info(dev, "%s: port %d, is for %s use\n", 682 dev_info(dev, "%s: port %d, is for %s use\n",
662 serial->type->description, 683 serial->type->description,
@@ -667,11 +688,11 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
667 * Handle devices that report invalid stuff here. 688 * Handle devices that report invalid stuff here.
668 */ 689 */
669 if (num_ports == 0 || num_ports > 2) { 690 if (num_ports == 0 || num_ports > 2) {
670 dev_warn (dev, "%s: No valid connect info available\n", 691 dev_warn(dev, "%s: No valid connect info available\n",
671 serial->type->description); 692 serial->type->description);
672 num_ports = 2; 693 num_ports = 2;
673 } 694 }
674 695
675 dev_info(dev, "%s: Number of ports: %d\n", serial->type->description, 696 dev_info(dev, "%s: Number of ports: %d\n", serial->type->description,
676 num_ports); 697 num_ports);
677 698
@@ -681,8 +702,9 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
681 */ 702 */
682 usb_set_serial_data(serial, (void *)(long)num_ports); 703 usb_set_serial_data(serial, (void *)(long)num_ports);
683 704
684 /* ask for the number of bytes available, but ignore the response as it is broken */ 705 /* ask for the number of bytes available, but ignore the
685 retval = usb_control_msg (serial->dev, 706 response as it is broken */
707 retval = usb_control_msg(serial->dev,
686 usb_rcvctrlpipe(serial->dev, 0), 708 usb_rcvctrlpipe(serial->dev, 0),
687 VISOR_REQUEST_BYTES_AVAILABLE, 709 VISOR_REQUEST_BYTES_AVAILABLE,
688 0xc2, 0x0000, 0x0005, transfer_buffer, 710 0xc2, 0x0000, 0x0005, transfer_buffer,
@@ -693,12 +715,13 @@ static int palm_os_3_probe (struct usb_serial *serial, const struct usb_device_i
693 retval = 0; 715 retval = 0;
694 716
695exit: 717exit:
696 kfree (transfer_buffer); 718 kfree(transfer_buffer);
697 719
698 return retval; 720 return retval;
699} 721}
700 722
701static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_id *id) 723static int palm_os_4_probe(struct usb_serial *serial,
724 const struct usb_device_id *id)
702{ 725{
703 struct device *dev = &serial->dev->dev; 726 struct device *dev = &serial->dev->dev;
704 struct palm_ext_connection_info *connection_info; 727 struct palm_ext_connection_info *connection_info;
@@ -707,18 +730,18 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
707 730
708 dbg("%s", __func__); 731 dbg("%s", __func__);
709 732
710 transfer_buffer = kmalloc (sizeof (*connection_info), GFP_KERNEL); 733 transfer_buffer = kmalloc(sizeof(*connection_info), GFP_KERNEL);
711 if (!transfer_buffer) { 734 if (!transfer_buffer) {
712 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__, 735 dev_err(dev, "%s - kmalloc(%Zd) failed.\n", __func__,
713 sizeof(*connection_info)); 736 sizeof(*connection_info));
714 return -ENOMEM; 737 return -ENOMEM;
715 } 738 }
716 739
717 retval = usb_control_msg (serial->dev, 740 retval = usb_control_msg(serial->dev,
718 usb_rcvctrlpipe(serial->dev, 0), 741 usb_rcvctrlpipe(serial->dev, 0),
719 PALM_GET_EXT_CONNECTION_INFORMATION, 742 PALM_GET_EXT_CONNECTION_INFORMATION,
720 0xc2, 0x0000, 0x0000, transfer_buffer, 743 0xc2, 0x0000, 0x0000, transfer_buffer,
721 sizeof (*connection_info), 300); 744 sizeof(*connection_info), 300);
722 if (retval < 0) 745 if (retval < 0)
723 dev_err(dev, "%s - error %d getting connection info\n", 746 dev_err(dev, "%s - error %d getting connection info\n",
724 __func__, retval); 747 __func__, retval);
@@ -726,15 +749,17 @@ static int palm_os_4_probe (struct usb_serial *serial, const struct usb_device_i
726 usb_serial_debug_data(debug, &serial->dev->dev, __func__, 749 usb_serial_debug_data(debug, &serial->dev->dev, __func__,
727 retval, transfer_buffer); 750 retval, transfer_buffer);
728 751
729 kfree (transfer_buffer); 752 kfree(transfer_buffer);
730 return 0; 753 return 0;
731} 754}
732 755
733 756
734static int visor_probe (struct usb_serial *serial, const struct usb_device_id *id) 757static int visor_probe(struct usb_serial *serial,
758 const struct usb_device_id *id)
735{ 759{
736 int retval = 0; 760 int retval = 0;
737 int (*startup) (struct usb_serial *serial, const struct usb_device_id *id); 761 int (*startup)(struct usb_serial *serial,
762 const struct usb_device_id *id);
738 763
739 dbg("%s", __func__); 764 dbg("%s", __func__);
740 765
@@ -752,7 +777,7 @@ static int visor_probe (struct usb_serial *serial, const struct usb_device_id *i
752 return retval; 777 return retval;
753} 778}
754 779
755static int visor_calc_num_ports (struct usb_serial *serial) 780static int visor_calc_num_ports(struct usb_serial *serial)
756{ 781{
757 int num_ports = (int)(long)(usb_get_serial_data(serial)); 782 int num_ports = (int)(long)(usb_get_serial_data(serial));
758 783
@@ -769,7 +794,7 @@ static int generic_startup(struct usb_serial *serial)
769 int i; 794 int i;
770 795
771 for (i = 0; i < serial->num_ports; ++i) { 796 for (i = 0; i < serial->num_ports; ++i) {
772 priv = kzalloc (sizeof(*priv), GFP_KERNEL); 797 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
773 if (!priv) { 798 if (!priv) {
774 while (i-- != 0) { 799 while (i-- != 0) {
775 priv = usb_get_serial_port_data(ports[i]); 800 priv = usb_get_serial_port_data(ports[i]);
@@ -784,7 +809,7 @@ static int generic_startup(struct usb_serial *serial)
784 return 0; 809 return 0;
785} 810}
786 811
787static int clie_3_5_startup (struct usb_serial *serial) 812static int clie_3_5_startup(struct usb_serial *serial)
788{ 813{
789 struct device *dev = &serial->dev->dev; 814 struct device *dev = &serial->dev->dev;
790 int result; 815 int result;
@@ -797,62 +822,72 @@ static int clie_3_5_startup (struct usb_serial *serial)
797 */ 822 */
798 823
799 /* get the config number */ 824 /* get the config number */
800 result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), 825 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
801 USB_REQ_GET_CONFIGURATION, USB_DIR_IN, 826 USB_REQ_GET_CONFIGURATION, USB_DIR_IN,
802 0, 0, &data, 1, 3000); 827 0, 0, &data, 1, 3000);
803 if (result < 0) { 828 if (result < 0) {
804 dev_err(dev, "%s: get config number failed: %d\n", __func__, result); 829 dev_err(dev, "%s: get config number failed: %d\n",
830 __func__, result);
805 return result; 831 return result;
806 } 832 }
807 if (result != 1) { 833 if (result != 1) {
808 dev_err(dev, "%s: get config number bad return length: %d\n", __func__, result); 834 dev_err(dev, "%s: get config number bad return length: %d\n",
835 __func__, result);
809 return -EIO; 836 return -EIO;
810 } 837 }
811 838
812 /* get the interface number */ 839 /* get the interface number */
813 result = usb_control_msg (serial->dev, usb_rcvctrlpipe(serial->dev, 0), 840 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
814 USB_REQ_GET_INTERFACE, 841 USB_REQ_GET_INTERFACE,
815 USB_DIR_IN | USB_RECIP_INTERFACE, 842 USB_DIR_IN | USB_RECIP_INTERFACE,
816 0, 0, &data, 1, 3000); 843 0, 0, &data, 1, 3000);
817 if (result < 0) { 844 if (result < 0) {
818 dev_err(dev, "%s: get interface number failed: %d\n", __func__, result); 845 dev_err(dev, "%s: get interface number failed: %d\n",
846 __func__, result);
819 return result; 847 return result;
820 } 848 }
821 if (result != 1) { 849 if (result != 1) {
822 dev_err(dev, "%s: get interface number bad return length: %d\n", __func__, result); 850 dev_err(dev,
851 "%s: get interface number bad return length: %d\n",
852 __func__, result);
823 return -EIO; 853 return -EIO;
824 } 854 }
825 855
826 return generic_startup(serial); 856 return generic_startup(serial);
827} 857}
828 858
829static int treo_attach (struct usb_serial *serial) 859static int treo_attach(struct usb_serial *serial)
830{ 860{
831 struct usb_serial_port *swap_port; 861 struct usb_serial_port *swap_port;
832 862
833 /* Only do this endpoint hack for the Handspring devices with 863 /* Only do this endpoint hack for the Handspring devices with
834 * interrupt in endpoints, which for now are the Treo devices. */ 864 * interrupt in endpoints, which for now are the Treo devices. */
835 if (!((le16_to_cpu(serial->dev->descriptor.idVendor) == HANDSPRING_VENDOR_ID) || 865 if (!((le16_to_cpu(serial->dev->descriptor.idVendor)
836 (le16_to_cpu(serial->dev->descriptor.idVendor) == KYOCERA_VENDOR_ID)) || 866 == HANDSPRING_VENDOR_ID) ||
837 (serial->num_interrupt_in == 0)) 867 (le16_to_cpu(serial->dev->descriptor.idVendor)
868 == KYOCERA_VENDOR_ID)) ||
869 (serial->num_interrupt_in == 0))
838 goto generic_startup; 870 goto generic_startup;
839 871
840 dbg("%s", __func__); 872 dbg("%s", __func__);
841 873
842 /* 874 /*
843 * It appears that Treos and Kyoceras want to use the 875 * It appears that Treos and Kyoceras want to use the
844 * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint, 876 * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
845 * so let's swap the 1st and 2nd bulk in and interrupt endpoints. 877 * so let's swap the 1st and 2nd bulk in and interrupt endpoints.
846 * Note that swapping the bulk out endpoints would break lots of 878 * Note that swapping the bulk out endpoints would break lots of
847 * apps that want to communicate on the second port. 879 * apps that want to communicate on the second port.
848 */ 880 */
849#define COPY_PORT(dest, src) \ 881#define COPY_PORT(dest, src) \
850 dest->read_urb = src->read_urb; \ 882 do { \
851 dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress; \ 883 dest->read_urb = src->read_urb; \
852 dest->bulk_in_buffer = src->bulk_in_buffer; \ 884 dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
853 dest->interrupt_in_urb = src->interrupt_in_urb; \ 885 dest->bulk_in_buffer = src->bulk_in_buffer; \
854 dest->interrupt_in_endpointAddress = src->interrupt_in_endpointAddress; \ 886 dest->interrupt_in_urb = src->interrupt_in_urb; \
855 dest->interrupt_in_buffer = src->interrupt_in_buffer; 887 dest->interrupt_in_endpointAddress = \
888 src->interrupt_in_endpointAddress;\
889 dest->interrupt_in_buffer = src->interrupt_in_buffer; \
890 } while (0);
856 891
857 swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL); 892 swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
858 if (!swap_port) 893 if (!swap_port)
@@ -866,28 +901,30 @@ generic_startup:
866 return generic_startup(serial); 901 return generic_startup(serial);
867} 902}
868 903
869static int clie_5_attach (struct usb_serial *serial) 904static int clie_5_attach(struct usb_serial *serial)
870{ 905{
871 dbg("%s", __func__); 906 dbg("%s", __func__);
872 907
873 /* TH55 registers 2 ports. 908 /* TH55 registers 2 ports.
874 Communication in from the UX50/TH55 uses bulk_in_endpointAddress from port 0 909 Communication in from the UX50/TH55 uses bulk_in_endpointAddress
875 Communication out to the UX50/TH55 uses bulk_out_endpointAddress from port 1 910 from port 0. Communication out to the UX50/TH55 uses
876 911 bulk_out_endpointAddress from port 1
912
877 Lets do a quick and dirty mapping 913 Lets do a quick and dirty mapping
878 */ 914 */
879 915
880 /* some sanity check */ 916 /* some sanity check */
881 if (serial->num_ports < 2) 917 if (serial->num_ports < 2)
882 return -1; 918 return -1;
883 919
884 /* port 0 now uses the modified endpoint Address */ 920 /* port 0 now uses the modified endpoint Address */
885 serial->port[0]->bulk_out_endpointAddress = serial->port[1]->bulk_out_endpointAddress; 921 serial->port[0]->bulk_out_endpointAddress =
922 serial->port[1]->bulk_out_endpointAddress;
886 923
887 return generic_startup(serial); 924 return generic_startup(serial);
888} 925}
889 926
890static void visor_shutdown (struct usb_serial *serial) 927static void visor_shutdown(struct usb_serial *serial)
891{ 928{
892 struct visor_private *priv; 929 struct visor_private *priv;
893 int i; 930 int i;
@@ -903,30 +940,35 @@ static void visor_shutdown (struct usb_serial *serial)
903 } 940 }
904} 941}
905 942
906static int __init visor_init (void) 943static int __init visor_init(void)
907{ 944{
908 int i, retval; 945 int i, retval;
909 /* Only if parameters were passed to us */ 946 /* Only if parameters were passed to us */
910 if ((vendor>0) && (product>0)) { 947 if (vendor > 0 && product > 0) {
911 struct usb_device_id usb_dev_temp[]= 948 struct usb_device_id usb_dev_temp[] = {
912 {{USB_DEVICE(vendor, product), 949 {
913 .driver_info = (kernel_ulong_t)&palm_os_4_probe }}; 950 USB_DEVICE(vendor, product),
951 .driver_info =
952 (kernel_ulong_t) &palm_os_4_probe
953 }
954 };
914 955
915 /* Find the last entry in id_table */ 956 /* Find the last entry in id_table */
916 for (i=0; ; i++) { 957 for (i = 0;; i++) {
917 if (id_table[i].idVendor==0) { 958 if (id_table[i].idVendor == 0) {
918 id_table[i] = usb_dev_temp[0]; 959 id_table[i] = usb_dev_temp[0];
919 break; 960 break;
920 } 961 }
921 } 962 }
922 /* Find the last entry in id_table_combined */ 963 /* Find the last entry in id_table_combined */
923 for (i=0; ; i++) { 964 for (i = 0;; i++) {
924 if (id_table_combined[i].idVendor==0) { 965 if (id_table_combined[i].idVendor == 0) {
925 id_table_combined[i] = usb_dev_temp[0]; 966 id_table_combined[i] = usb_dev_temp[0];
926 break; 967 break;
927 } 968 }
928 } 969 }
929 info("Untested USB device specified at time of module insertion"); 970 info(
971 "Untested USB device specified at time of module insertion");
930 info("Warning: This is not guaranteed to work"); 972 info("Warning: This is not guaranteed to work");
931 info("Using a newer kernel is preferred to this method"); 973 info("Using a newer kernel is preferred to this method");
932 info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x", 974 info("Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x",
@@ -942,7 +984,7 @@ static int __init visor_init (void)
942 if (retval) 984 if (retval)
943 goto failed_clie_5_register; 985 goto failed_clie_5_register;
944 retval = usb_register(&visor_driver); 986 retval = usb_register(&visor_driver);
945 if (retval) 987 if (retval)
946 goto failed_usb_register; 988 goto failed_usb_register;
947 info(DRIVER_DESC); 989 info(DRIVER_DESC);
948 990
@@ -960,18 +1002,18 @@ failed_handspring_register:
960 1002
961static void __exit visor_exit (void) 1003static void __exit visor_exit (void)
962{ 1004{
963 usb_deregister (&visor_driver); 1005 usb_deregister(&visor_driver);
964 usb_serial_deregister (&handspring_device); 1006 usb_serial_deregister(&handspring_device);
965 usb_serial_deregister (&clie_3_5_device); 1007 usb_serial_deregister(&clie_3_5_device);
966 usb_serial_deregister (&clie_5_device); 1008 usb_serial_deregister(&clie_5_device);
967} 1009}
968 1010
969 1011
970module_init(visor_init); 1012module_init(visor_init);
971module_exit(visor_exit); 1013module_exit(visor_exit);
972 1014
973MODULE_AUTHOR( DRIVER_AUTHOR ); 1015MODULE_AUTHOR(DRIVER_AUTHOR);
974MODULE_DESCRIPTION( DRIVER_DESC ); 1016MODULE_DESCRIPTION(DRIVER_DESC);
975MODULE_LICENSE("GPL"); 1017MODULE_LICENSE("GPL");
976 1018
977module_param(debug, bool, S_IRUGO | S_IWUSR); 1019module_param(debug, bool, S_IRUGO | S_IWUSR);