17 #include <linux/kernel.h>
18 #include <linux/errno.h>
20 #include <linux/slab.h>
21 #include <linux/tty.h>
24 #include <linux/module.h>
37 #define DRIVER_DESC "USB HandSpring Visor / Palm OS driver"
45 static void visor_read_int_callback(
struct urb *
urb);
170 .description =
"Handspring Visor / Palm OS",
173 .bulk_out_size = 256,
175 .close = visor_close,
178 .attach = treo_attach,
179 .probe = visor_probe,
180 .calc_num_ports = visor_calc_num_ports,
181 .read_int_callback = visor_read_int_callback,
190 .description =
"Sony Clie 5.0",
191 .id_table = clie_id_5_table,
193 .bulk_out_size = 256,
195 .close = visor_close,
198 .attach = clie_5_attach,
199 .probe = visor_probe,
200 .calc_num_ports = visor_calc_num_ports,
201 .read_int_callback = visor_read_int_callback,
210 .description =
"Sony Clie 3.5",
211 .id_table = clie_id_3_5_table,
213 .bulk_out_size = 256,
215 .close = visor_close,
218 .attach = clie_3_5_startup,
222 &handspring_device, &clie_5_device, &clie_3_5_device,
NULL
234 dev_err(&port->
dev,
"Device lied about number of ports, please use a lower one.\n");
244 dev_dbg(&port->
dev,
"adding interrupt input for treo\n");
248 "%s - failed submitting interrupt urb, error %d\n",
265 if (!port->
serial->disconnected) {
268 if (transfer_buffer) {
270 usb_rcvctrlpipe(port->
serial->dev, 0),
273 transfer_buffer, 0x12, 300);
274 kfree(transfer_buffer);
280 static void visor_read_int_callback(
struct urb *
urb)
294 dev_dbg(&port->
dev,
"%s - urb shutting down with status: %d\n",
298 dev_dbg(&port->
dev,
"%s - nonzero urb status received: %d\n",
310 usb_serial_debug_data(&port->
dev, __func__, urb->actual_length,
311 urb->transfer_buffer);
317 "%s - Error %d submitting interrupt urb\n",
333 if (!transfer_buffer) {
334 dev_err(dev,
"%s - kmalloc(%Zd) failed.\n", __func__,
335 sizeof(*connection_info));
341 usb_rcvctrlpipe(serial->
dev, 0),
343 0xc2, 0x0000, 0x0000, transfer_buffer,
344 sizeof(*connection_info), 300);
346 dev_err(dev,
"%s - error %d getting connection information\n",
351 if (retval ==
sizeof(*connection_info)) {
358 connection_info->
connections[i].port_function_id) {
372 string =
"Remote File System";
378 dev_info(dev,
"%s: port %d, is for %s use\n",
379 serial->
type->description,
386 if (num_ports == 0 || num_ports > 2) {
387 dev_warn(dev,
"%s: No valid connect info available\n",
388 serial->
type->description);
392 dev_info(dev,
"%s: Number of ports: %d\n", serial->
type->description,
399 usb_set_serial_data(serial, (
void *)(
long)num_ports);
404 usb_rcvctrlpipe(serial->
dev, 0),
406 0xc2, 0x0000, 0x0005, transfer_buffer,
409 dev_err(dev,
"%s - error %d getting bytes available request\n",
414 kfree(transfer_buffer);
419 static int palm_os_4_probe(
struct usb_serial *serial,
428 if (!transfer_buffer) {
429 dev_err(dev,
"%s - kmalloc(%Zd) failed.\n", __func__,
430 sizeof(*connection_info));
435 usb_rcvctrlpipe(serial->
dev, 0),
437 0xc2, 0x0000, 0x0000, transfer_buffer,
438 sizeof(*connection_info), 300);
440 dev_err(dev,
"%s - error %d getting connection info\n",
443 usb_serial_debug_data(dev, __func__, retval, transfer_buffer);
445 kfree(transfer_buffer);
450 static int visor_probe(
struct usb_serial *serial,
464 serial->
dev->descriptor.bDeviceSubClass ==
468 if (serial->
dev->actconfig->desc.bConfigurationValue != 1) {
469 dev_err(&serial->
dev->dev,
"active config #%d != 1 ??\n",
470 serial->
dev->actconfig->desc.bConfigurationValue);
474 if (id->driver_info) {
475 startup = (
void *)id->driver_info;
476 retval = startup(serial,
id);
482 static int visor_calc_num_ports(
struct usb_serial *serial)
484 int num_ports = (
int)(
long)(usb_get_serial_data(serial));
487 usb_set_serial_data(serial,
NULL);
492 static int clie_3_5_startup(
struct usb_serial *serial)
509 0, 0, data, 1, 3000);
511 dev_err(dev,
"%s: get config number failed: %d\n",
516 dev_err(dev,
"%s: get config number bad return length: %d\n",
526 0, 0, data, 1, 3000);
528 dev_err(dev,
"%s: get interface number failed: %d\n",
534 "%s: get interface number bad return length: %d\n",
547 static int treo_attach(
struct usb_serial *serial)
567 #define COPY_PORT(dest, src) \
569 dest->read_urb = src->read_urb; \
570 dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
571 dest->bulk_in_buffer = src->bulk_in_buffer; \
572 dest->interrupt_in_urb = src->interrupt_in_urb; \
573 dest->interrupt_in_endpointAddress = \
574 src->interrupt_in_endpointAddress;\
575 dest->interrupt_in_buffer = src->interrupt_in_buffer; \
589 static int clie_5_attach(
struct usb_serial *serial)
608 port = serial->
port[0];
610 serial->
port[1]->bulk_out_endpointAddress;