# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.628 -> 1.629 # drivers/usb/serial/mct_u232.c 1.17 -> 1.18 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/08/29 greg@kroah.com 1.629 # USB: mct_u232 update due to usbserial core changes. # -------------------------------------------- # diff -Nru a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c --- a/drivers/usb/serial/mct_u232.c Thu Aug 29 13:54:29 2002 +++ b/drivers/usb/serial/mct_u232.c Thu Aug 29 13:54:29 2002 @@ -61,18 +61,15 @@ #include #include -#include -#include #include -#include #include #include -#include #include #include #include #include #include +#include #include #ifdef CONFIG_USB_SERIAL_DEBUG @@ -132,7 +129,7 @@ /* * All of the device info needed for the MCT USB-RS232 converter. */ -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) }, { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) }, { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) }, @@ -140,99 +137,31 @@ { } /* Terminating entry */ }; -static struct usb_device_id mct_u232_table [] = { - { USB_DEVICE(MCT_U232_VID, MCT_U232_PID) }, - { USB_DEVICE(MCT_U232_BELKIN_F5U109_VID, MCT_U232_BELKIN_F5U109_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id mct_u232_sitecom_table [] = { - { USB_DEVICE(MCT_U232_VID, MCT_U232_SITECOM_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id mct_u232_du_h3sp_table [] = { - { USB_DEVICE(MCT_U232_VID, MCT_U232_DU_H3SP_PID) }, - { } /* Terminating entry */ -}; - MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_serial_device_type mct_u232_device = { - name: "Magic Control Technology USB-RS232", - id_table: mct_u232_table, - needs_interrupt_in: MUST_HAVE, /* 2 interrupt-in endpoints */ - needs_bulk_in: MUST_HAVE_NOT, /* no bulk-in endpoint */ - needs_bulk_out: MUST_HAVE, /* 1 bulk-out endpoint */ - num_interrupt_in: 2, - num_bulk_in: 0, - num_bulk_out: 1, - num_ports: 1, - open: mct_u232_open, - close: mct_u232_close, + .owner = THIS_MODULE, + .name = "Magic Control Technology USB-RS232", + .id_table = id_table_combined, + .num_interrupt_in = 2, + .num_bulk_in = 0, + .num_bulk_out = 1, + .num_ports = 1, + .open = mct_u232_open, + .close = mct_u232_close, #ifdef FIX_WRITE_RETURN_CODE_PROBLEM - write: mct_u232_write, - write_bulk_callback: mct_u232_write_bulk_callback, + .write = mct_u232_write, + .write_bulk_callback = mct_u232_write_bulk_callback, #endif - read_int_callback: mct_u232_read_int_callback, - ioctl: mct_u232_ioctl, - set_termios: mct_u232_set_termios, - break_ctl: mct_u232_break_ctl, - startup: mct_u232_startup, - shutdown: mct_u232_shutdown, + .read_int_callback = mct_u232_read_int_callback, + .ioctl = mct_u232_ioctl, + .set_termios = mct_u232_set_termios, + .break_ctl = mct_u232_break_ctl, + .startup = mct_u232_startup, + .shutdown = mct_u232_shutdown, }; -static struct usb_serial_device_type mct_u232_sitecom_device = { - name: "MCT/Sitecom USB-RS232", - id_table: mct_u232_sitecom_table, - needs_interrupt_in: MUST_HAVE, /* 2 interrupt-in endpoints */ - needs_bulk_in: MUST_HAVE_NOT, /* no bulk-in endpoint */ - needs_bulk_out: MUST_HAVE, /* 1 bulk-out endpoint */ - num_interrupt_in: 2, - num_bulk_in: 0, - num_bulk_out: 1, - num_ports: 1, - open: mct_u232_open, - close: mct_u232_close, -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM - write: mct_u232_write, - write_bulk_callback: mct_u232_write_bulk_callback, -#endif - read_int_callback: mct_u232_read_int_callback, - ioctl: mct_u232_ioctl, - set_termios: mct_u232_set_termios, - break_ctl: mct_u232_break_ctl, - startup: mct_u232_startup, - shutdown: mct_u232_shutdown, -}; - -static struct usb_serial_device_type mct_u232_du_h3sp_device = { - name: "MCT/D-Link DU-H3SP USB BAY", - id_table: mct_u232_du_h3sp_table, - needs_interrupt_in: MUST_HAVE, /* 2 interrupt-in endpoints */ - needs_bulk_in: MUST_HAVE_NOT, /* no bulk-in endpoint */ - needs_bulk_out: MUST_HAVE, /* 1 bulk-out endpoint */ - num_interrupt_in: 2, - num_bulk_in: 0, - num_bulk_out: 1, - num_ports: 1, - open: mct_u232_open, - close: mct_u232_close, -#ifdef FIX_WRITE_RETURN_CODE_PROBLEM - write: mct_u232_write, - write_bulk_callback: mct_u232_write_bulk_callback, -#endif - read_int_callback: mct_u232_read_int_callback, - ioctl: mct_u232_ioctl, - set_termios: mct_u232_set_termios, - break_ctl: mct_u232_break_ctl, - startup: mct_u232_startup, - shutdown: mct_u232_shutdown, -}; - - - struct mct_u232_private { unsigned long control_state; /* Modem Line Setting (TIOCM) */ @@ -392,9 +321,6 @@ /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { - while (serial->port[i].open_count > 0) { - mct_u232_close (&serial->port[i], NULL); - } /* My special items, the standard routines free my urbs */ if (serial->port[i].private) kfree(serial->port[i].private); @@ -409,68 +335,56 @@ dbg("%s port %d", __FUNCTION__, port->number); - down (&port->sem); - - ++port->open_count; - MOD_INC_USE_COUNT; - - if (!port->active) { - port->active = 1; + /* Compensate for a hardware bug: although the Sitecom U232-P25 + * device reports a maximum output packet size of 32 bytes, + * it seems to be able to accept only 16 bytes (and that's what + * SniffUSB says too...) + */ + if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID) + port->bulk_out_size = 16; - /* Compensate for a hardware bug: although the Sitecom U232-P25 - * device reports a maximum output packet size of 32 bytes, - * it seems to be able to accept only 16 bytes (and that's what - * SniffUSB says too...) - */ - if (serial->dev->descriptor.idProduct == MCT_U232_SITECOM_PID) - port->bulk_out_size = 16; - - /* Do a defined restart: the normal serial device seems to - * always turn on DTR and RTS here, so do the same. I'm not - * sure if this is really necessary. But it should not harm - * either. - */ - if (port->tty->termios->c_cflag & CBAUD) - priv->control_state = TIOCM_DTR | TIOCM_RTS; - else - priv->control_state = 0; - mct_u232_set_modem_ctrl(serial, priv->control_state); - - priv->last_lcr = (MCT_U232_DATA_BITS_8 | - MCT_U232_PARITY_NONE | - MCT_U232_STOP_BITS_1); - mct_u232_set_line_ctrl(serial, priv->last_lcr); + /* Do a defined restart: the normal serial device seems to + * always turn on DTR and RTS here, so do the same. I'm not + * sure if this is really necessary. But it should not harm + * either. + */ + if (port->tty->termios->c_cflag & CBAUD) + priv->control_state = TIOCM_DTR | TIOCM_RTS; + else + priv->control_state = 0; + mct_u232_set_modem_ctrl(serial, priv->control_state); + + priv->last_lcr = (MCT_U232_DATA_BITS_8 | + MCT_U232_PARITY_NONE | + MCT_U232_STOP_BITS_1); + mct_u232_set_line_ctrl(serial, priv->last_lcr); - /* Read modem status and update control state */ - mct_u232_get_modem_stat(serial, &priv->last_msr); - mct_u232_msr_to_state(&priv->control_state, priv->last_msr); - - { - /* Puh, that's dirty */ - struct usb_serial_port *rport; - rport = &serial->port[1]; - rport->tty = port->tty; - rport->private = port->private; - port->read_urb = rport->interrupt_in_urb; - } - - port->read_urb->dev = port->serial->dev; - retval = usb_submit_urb(port->read_urb); - if (retval) { - err("usb_submit_urb(read bulk) failed"); - goto exit; - } - - port->interrupt_in_urb->dev = port->serial->dev; - retval = usb_submit_urb(port->interrupt_in_urb); - if (retval) - err(" usb_submit_urb(read int) failed"); + /* Read modem status and update control state */ + mct_u232_get_modem_stat(serial, &priv->last_msr); + mct_u232_msr_to_state(&priv->control_state, priv->last_msr); - } + { + /* Puh, that's dirty */ + struct usb_serial_port *rport; + rport = &serial->port[1]; + rport->tty = port->tty; + rport->private = port->private; + port->read_urb = rport->interrupt_in_urb; + } + + port->read_urb->dev = port->serial->dev; + retval = usb_submit_urb(port->read_urb); + if (retval) { + err("usb_submit_urb(read bulk) failed"); + goto exit; + } + + port->interrupt_in_urb->dev = port->serial->dev; + retval = usb_submit_urb(port->interrupt_in_urb); + if (retval) + err(" usb_submit_urb(read int) failed"); exit: - up (&port->sem); - return 0; } /* mct_u232_open */ @@ -479,22 +393,12 @@ { dbg("%s port %d", __FUNCTION__, port->number); - down (&port->sem); - - --port->open_count; - - if (port->open_count <= 0) { - if (port->serial->dev) { - /* shutdown our urbs */ - usb_unlink_urb (port->write_urb); - usb_unlink_urb (port->read_urb); - usb_unlink_urb (port->interrupt_in_urb); - } - port->active = 0; + if (port->serial->dev) { + /* shutdown our urbs */ + usb_unlink_urb (port->write_urb); + usb_unlink_urb (port->read_urb); + usb_unlink_urb (port->interrupt_in_urb); } - - up (&port->sem); - MOD_DEC_USE_COUNT; } /* mct_u232_close */ @@ -526,16 +430,12 @@ bytes_sent = 0; while (count > 0) { - - down (&port->sem); - size = (count > port->bulk_out_size) ? port->bulk_out_size : count; usb_serial_debug_data (__FILE__, __FUNCTION__, size, buf); if (from_user) { if (copy_from_user(port->write_urb->transfer_buffer, buf, size)) { - up (&port->sem); return -EFAULT; } } @@ -557,12 +457,9 @@ result = usb_submit_urb(port->write_urb); if (result) { err("%s - failed submitting write urb, error %d", __FUNCTION__, result); - up (&port->sem); return result; } - up (&port->sem); - bytes_sent += size; if (write_blocking) interruptible_sleep_on(&port->write_wait); @@ -885,9 +782,7 @@ static int __init mct_u232_init (void) { usb_serial_register (&mct_u232_device); - usb_serial_register (&mct_u232_sitecom_device); - usb_serial_register (&mct_u232_du_h3sp_device); - info(DRIVER_VERSION ":" DRIVER_DESC); + info(DRIVER_DESC " " DRIVER_VERSION); return 0; } @@ -895,8 +790,6 @@ static void __exit mct_u232_exit (void) { usb_serial_deregister (&mct_u232_device); - usb_serial_deregister (&mct_u232_sitecom_device); - usb_serial_deregister (&mct_u232_du_h3sp_device); }