Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: visor: clean up clie_5 endpoint hack

Use the new endpoint-remap functionality to configure the ports for
clie_5 devices.

Note that the same bulk-out endpoint is being used for both ports.

Signed-off-by: Johan Hovold <johan@kernel.org>

+23 -34
+23 -34
drivers/usb/serial/visor.c
··· 42 42 const struct usb_device_id *id); 43 43 static int visor_calc_num_ports(struct usb_serial *serial, 44 44 struct usb_serial_endpoints *epds); 45 + static int clie_5_calc_num_ports(struct usb_serial *serial, 46 + struct usb_serial_endpoints *epds); 45 47 static void visor_read_int_callback(struct urb *urb); 46 48 static int clie_3_5_startup(struct usb_serial *serial); 47 49 static int treo_attach(struct usb_serial *serial); 48 - static int clie_5_attach(struct usb_serial *serial); 49 50 static int palm_os_3_probe(struct usb_serial *serial, 50 51 const struct usb_device_id *id); 51 52 static int palm_os_4_probe(struct usb_serial *serial, ··· 191 190 .description = "Sony Clie 5.0", 192 191 .id_table = clie_id_5_table, 193 192 .num_ports = 2, 193 + .num_bulk_out = 2, 194 194 .bulk_out_size = 256, 195 195 .open = visor_open, 196 196 .close = visor_close, 197 197 .throttle = usb_serial_generic_throttle, 198 198 .unthrottle = usb_serial_generic_unthrottle, 199 - .attach = clie_5_attach, 200 199 .probe = visor_probe, 200 + .calc_num_ports = clie_5_calc_num_ports, 201 201 .read_int_callback = visor_read_int_callback, 202 202 }; 203 203 ··· 479 477 return num_ports; 480 478 } 481 479 480 + static int clie_5_calc_num_ports(struct usb_serial *serial, 481 + struct usb_serial_endpoints *epds) 482 + { 483 + /* 484 + * TH55 registers 2 ports. 485 + * Communication in from the UX50/TH55 uses the first bulk-in 486 + * endpoint, while communication out to the UX50/TH55 uses the second 487 + * bulk-out endpoint. 488 + */ 489 + 490 + /* 491 + * FIXME: Should we swap the descriptors instead of using the same 492 + * bulk-out endpoint for both ports? 493 + */ 494 + epds->bulk_out[0] = epds->bulk_out[1]; 495 + 496 + return serial->type->num_ports; 497 + } 498 + 482 499 static int clie_3_5_startup(struct usb_serial *serial) 483 500 { 484 501 struct device *dev = &serial->dev->dev; ··· 605 584 COPY_PORT(serial->port[0], serial->port[1]); 606 585 COPY_PORT(serial->port[1], swap_port); 607 586 kfree(swap_port); 608 - 609 - return 0; 610 - } 611 - 612 - static int clie_5_attach(struct usb_serial *serial) 613 - { 614 - struct usb_serial_port *port; 615 - unsigned int pipe; 616 - int j; 617 - 618 - /* TH55 registers 2 ports. 619 - Communication in from the UX50/TH55 uses bulk_in_endpointAddress 620 - from port 0. Communication out to the UX50/TH55 uses 621 - bulk_out_endpointAddress from port 1 622 - 623 - Lets do a quick and dirty mapping 624 - */ 625 - 626 - /* some sanity check */ 627 - if (serial->num_bulk_out < 2) { 628 - dev_err(&serial->interface->dev, "missing bulk out endpoints\n"); 629 - return -ENODEV; 630 - } 631 - 632 - /* port 0 now uses the modified endpoint Address */ 633 - port = serial->port[0]; 634 - port->bulk_out_endpointAddress = 635 - serial->port[1]->bulk_out_endpointAddress; 636 - 637 - pipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress); 638 - for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j) 639 - port->write_urbs[j]->pipe = pipe; 640 587 641 588 return 0; 642 589 }