X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fusb%2Fserial%2Fkeyspan_pda.c;h=126b9703bbaf1136f2a4f50ab432982c44f09ba6;hb=refs%2Fheads%2Fvserver;hp=cd441d783cbe9d9a61dbeb61fdf4bf63910d47dd;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index cd441d783..126b9703b 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -66,7 +66,6 @@ */ -#include #include #include #include @@ -79,6 +78,7 @@ #include #include #include +#include static int debug; @@ -108,8 +108,6 @@ struct ezusb_hex_record { #include "xircom_pgs_fw.h" #endif -#include "usb-serial.h" - /* * Version Information */ @@ -122,6 +120,8 @@ struct keyspan_pda_private { int tx_throttled; struct work_struct wakeup_work; struct work_struct unthrottle_work; + struct usb_serial *serial; + struct usb_serial_port *port; }; @@ -150,11 +150,11 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver keyspan_pda_driver = { - .owner = THIS_MODULE, .name = "keyspan_pda", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; static struct usb_device_id id_table_std [] = { @@ -177,9 +177,11 @@ static struct usb_device_id id_table_fake_xircom [] = { }; #endif -static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) +static void keyspan_pda_wakeup_write(struct work_struct *work) { - + struct keyspan_pda_private *priv = + container_of(work, struct keyspan_pda_private, wakeup_work); + struct usb_serial_port *port = priv->port; struct tty_struct *tty = port->tty; /* wake up port processes */ @@ -189,8 +191,11 @@ static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) tty_wakeup(tty); } -static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) +static void keyspan_pda_request_unthrottle(struct work_struct *work) { + struct keyspan_pda_private *priv = + container_of(work, struct keyspan_pda_private, unthrottle_work); + struct usb_serial *serial = priv->serial; int result; dbg(" request_unthrottle"); @@ -205,14 +210,14 @@ static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) 0, /* index */ NULL, 0, - 2*HZ); + 2000); if (result < 0) dbg("%s - error %d from usb_control_msg", __FUNCTION__, result); } -static void keyspan_pda_rx_interrupt (struct urb *urb, struct pt_regs *regs) +static void keyspan_pda_rx_interrupt (struct urb *urb) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct tty_struct *tty = port->tty; @@ -285,7 +290,7 @@ static void keyspan_pda_rx_throttle (struct usb_serial_port *port) upon the device too. */ dbg("keyspan_pda_rx_throttle port %d", port->number); - usb_unlink_urb(port->interrupt_in_urb); + usb_kill_urb(port->interrupt_in_urb); } @@ -330,7 +335,7 @@ static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) 0, /* index */ NULL, /* &data */ 0, /* size */ - 2*HZ); /* timeout */ + 2000); /* timeout */ return(rc); } @@ -348,7 +353,7 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 4, /* set break */ USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - value, 0, NULL, 0, 2*HZ); + value, 0, NULL, 0, 2000); if (result < 0) dbg("%s - error %d from usb_control_msg", __FUNCTION__, result); @@ -360,7 +365,7 @@ static void keyspan_pda_break_ctl (struct usb_serial_port *port, int break_state static void keyspan_pda_set_termios (struct usb_serial_port *port, - struct termios *old_termios) + struct ktermios *old_termios) { struct usb_serial *serial = port->serial; unsigned int cflag = port->tty->termios->c_cflag; @@ -416,7 +421,7 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial, rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 3, /* get pins */ USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, - 0, 0, &data, 1, 2*HZ); + 0, 0, &data, 1, 2000); if (rc > 0) *value = data; return rc; @@ -430,7 +435,7 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial, rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 3, /* set pins */ USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_OUT, - value, 0, NULL, 0, 2*HZ); + value, 0, NULL, 0, 2000); return rc; } @@ -493,7 +498,7 @@ static int keyspan_pda_ioctl(struct usb_serial_port *port, struct file *file, return -ENOIOCTLCMD; } -static int keyspan_pda_write(struct usb_serial_port *port, int from_user, +static int keyspan_pda_write(struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; @@ -520,9 +525,13 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user, the TX urb is in-flight (wait until it completes) the device is full (wait until it says there is room) */ - if (port->write_urb->status == -EINPROGRESS || priv->tx_throttled ) { - return( 0 ); + spin_lock_bh(&port->lock); + if (port->write_urb_busy || priv->tx_throttled) { + spin_unlock_bh(&port->lock); + return 0; } + port->write_urb_busy = 1; + spin_unlock_bh(&port->lock); /* At this point the URB is in our control, nobody else can submit it again (the only sudden transition was the one from EINPROGRESS to @@ -545,7 +554,7 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user, 0, /* index */ &room, 1, - 2*HZ); + 2000); if (rc < 0) { dbg(" roomquery failed"); goto exit; @@ -567,19 +576,10 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user, if (count) { /* now transfer data */ - if (from_user) { - if( copy_from_user(port->write_urb->transfer_buffer, - buf, count) ) { - rc = -EFAULT; - goto exit; - } - } - else { - memcpy (port->write_urb->transfer_buffer, buf, count); - } + memcpy (port->write_urb->transfer_buffer, buf, count); /* send the data out the bulk port */ port->write_urb->transfer_buffer_length = count; - + priv->tx_room -= count; port->write_urb->dev = port->serial->dev; @@ -602,15 +602,18 @@ static int keyspan_pda_write(struct usb_serial_port *port, int from_user, rc = count; exit: + if (rc < 0) + port->write_urb_busy = 0; return rc; } -static void keyspan_pda_write_bulk_callback (struct urb *urb, struct pt_regs *regs) +static void keyspan_pda_write_bulk_callback (struct urb *urb) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct keyspan_pda_private *priv; + port->write_urb_busy = 0; priv = usb_get_serial_port_data(port); /* queue up a wakeup at scheduler time */ @@ -635,12 +638,12 @@ static int keyspan_pda_write_room (struct usb_serial_port *port) static int keyspan_pda_chars_in_buffer (struct usb_serial_port *port) { struct keyspan_pda_private *priv; - + priv = usb_get_serial_port_data(port); - + /* when throttled, return at least WAKEUP_CHARS to tell select() (via n_tty.c:normal_poll() ) that we're not writeable. */ - if( port->write_urb->status == -EINPROGRESS || priv->tx_throttled ) + if (port->write_urb_busy || priv->tx_throttled) return 256; return 0; } @@ -662,7 +665,7 @@ static int keyspan_pda_open (struct usb_serial_port *port, struct file *filp) 0, /* index */ &room, 1, - 2*HZ); + 2000); if (rc < 0) { dbg("%s - roomquery failed", __FUNCTION__); goto error; @@ -706,8 +709,8 @@ static void keyspan_pda_close(struct usb_serial_port *port, struct file *filp) keyspan_pda_set_modem_info(serial, 0); /* shutdown our bulk reads and writes */ - usb_unlink_urb (port->write_urb); - usb_unlink_urb (port->interrupt_in_urb); + usb_kill_urb(port->write_urb); + usb_kill_urb(port->interrupt_in_urb); } } @@ -722,12 +725,12 @@ static int keyspan_pda_fake_startup (struct usb_serial *serial) response = ezusb_set_reset(serial, 1); #ifdef KEYSPAN - if (serial->dev->descriptor.idVendor == KEYSPAN_VENDOR_ID) + if (le16_to_cpu(serial->dev->descriptor.idVendor) == KEYSPAN_VENDOR_ID) record = &keyspan_pda_firmware[0]; #endif #ifdef XIRCOM - if ((serial->dev->descriptor.idVendor == XIRCOM_VENDOR_ID) || - (serial->dev->descriptor.idVendor == ENTREGRA_VENDOR_ID)) + if ((le16_to_cpu(serial->dev->descriptor.idVendor) == XIRCOM_VENDOR_ID) || + (le16_to_cpu(serial->dev->descriptor.idVendor) == ENTREGRA_VENDOR_ID)) record = &xircom_pgs_firmware[0]; #endif if (record == NULL) { @@ -769,11 +772,10 @@ static int keyspan_pda_startup (struct usb_serial *serial) return (1); /* error */ usb_set_serial_port_data(serial->port[0], priv); init_waitqueue_head(&serial->port[0]->write_wait); - INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, - (void *)(serial->port[0])); - INIT_WORK(&priv->unthrottle_work, - (void *)keyspan_pda_request_unthrottle, - (void *)(serial)); + INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); + INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); + priv->serial = serial; + priv->port = serial->port[0]; return (0); } @@ -785,10 +787,12 @@ static void keyspan_pda_shutdown (struct usb_serial *serial) } #ifdef KEYSPAN -static struct usb_serial_device_type keyspan_pda_fake_device = { - .owner = THIS_MODULE, - .name = "Keyspan PDA - (prerenumeration)", - .short_name = "keyspan_pda_pre", +static struct usb_serial_driver keyspan_pda_fake_device = { + .driver = { + .owner = THIS_MODULE, + .name = "keyspan_pda_pre", + }, + .description = "Keyspan PDA - (prerenumeration)", .id_table = id_table_fake, .num_interrupt_in = NUM_DONT_CARE, .num_bulk_in = NUM_DONT_CARE, @@ -799,10 +803,12 @@ static struct usb_serial_device_type keyspan_pda_fake_device = { #endif #ifdef XIRCOM -static struct usb_serial_device_type xircom_pgs_fake_device = { - .owner = THIS_MODULE, - .name = "Xircom / Entregra PGS - (prerenumeration)", - .short_name = "xircom_no_firm", +static struct usb_serial_driver xircom_pgs_fake_device = { + .driver = { + .owner = THIS_MODULE, + .name = "xircom_no_firm", + }, + .description = "Xircom / Entregra PGS - (prerenumeration)", .id_table = id_table_fake_xircom, .num_interrupt_in = NUM_DONT_CARE, .num_bulk_in = NUM_DONT_CARE, @@ -812,10 +818,12 @@ static struct usb_serial_device_type xircom_pgs_fake_device = { }; #endif -static struct usb_serial_device_type keyspan_pda_device = { - .owner = THIS_MODULE, - .name = "Keyspan PDA", - .short_name = "keyspan_pda", +static struct usb_serial_driver keyspan_pda_device = { + .driver = { + .owner = THIS_MODULE, + .name = "keyspan_pda", + }, + .description = "Keyspan PDA", .id_table = id_table_std, .num_interrupt_in = 1, .num_bulk_in = 0,