# 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.616 -> 1.617 # drivers/usb/serial/belkin_sa.c 1.14 -> 1.15 # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/08/29 greg@kroah.com 1.617 # belkin_sa update due to usbserial core changes. # -------------------------------------------- # diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c --- a/drivers/usb/serial/belkin_sa.c Thu Aug 29 13:55:00 2002 +++ b/drivers/usb/serial/belkin_sa.c Thu Aug 29 13:55:00 2002 @@ -1,8 +1,8 @@ /* * Belkin USB Serial Adapter Driver * - * Copyright (C) 2000 - * William Greathouse (wgreathouse@smva.com) + * Copyright (C) 2000 William Greathouse (wgreathouse@smva.com) + * Copyright (C) 2000-2001 Greg Kroah-Hartman (greg@kroah.com) * * This program is largely derived from work by the linux-usb group * and associated source files. Please see the usb/serial files for @@ -24,6 +24,9 @@ * -- Add support for flush commands * -- Add everything that is missing :) * + * 27-Nov-2001 gkh + * compressed all the differnent device entries into 1. + * * 30-May-2001 gkh * switched from using spinlock to a semaphore, which fixes lots of problems. * @@ -62,18 +65,15 @@ #include #include -#include -#include #include -#include #include #include -#include #include #include #include #include #include +#include #include #ifdef CONFIG_USB_SERIAL_DEBUG @@ -88,7 +88,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v1.1" +#define DRIVER_VERSION "v1.2" #define DRIVER_AUTHOR "William Greathouse " #define DRIVER_DESC "USB Belkin Serial converter driver" @@ -103,7 +103,7 @@ static void belkin_sa_break_ctl (struct usb_serial_port *port, int break_state ); -static __devinitdata struct usb_device_id id_table_combined [] = { +static struct usb_device_id id_table_combined [] = { { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) }, { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) }, { USB_DEVICE(PERACOM_VID, PERACOM_PID) }, @@ -112,137 +112,25 @@ { } /* Terminating entry */ }; -static struct usb_device_id belkin_dockstation_table [] = { - { USB_DEVICE(BELKIN_DOCKSTATION_VID, BELKIN_DOCKSTATION_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id belkin_sa_table [] = { - { USB_DEVICE(BELKIN_SA_VID, BELKIN_SA_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id belkin_old_table [] = { - { USB_DEVICE(BELKIN_OLD_VID, BELKIN_OLD_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id peracom_table [] = { - { USB_DEVICE(PERACOM_VID, PERACOM_PID) }, - { } /* Terminating entry */ -}; - -static struct usb_device_id gocom232_table [] = { - { USB_DEVICE(GOHUBS_VID, GOHUBS_PID) }, - { } /* Terminating entry */ -}; - MODULE_DEVICE_TABLE (usb, id_table_combined); -/* All of the device info needed for the Belkin dockstation serial converter */ -static struct usb_serial_device_type belkin_dockstation_device = { - name: "Belkin F5U120-PC USB Serial Adapter", - id_table: belkin_dockstation_table, /* the Belkin F5U103 device */ - needs_interrupt_in: MUST_HAVE, /* this device must have an interrupt in endpoint */ - needs_bulk_in: MUST_HAVE, /* this device must have a bulk in endpoint */ - needs_bulk_out: MUST_HAVE, /* this device must have a bulk out endpoint */ - num_interrupt_in: 1, - num_bulk_in: 1, - num_bulk_out: 1, - num_ports: 1, - open: belkin_sa_open, - close: belkin_sa_close, - read_int_callback: belkin_sa_read_int_callback, /* How we get the status info */ - ioctl: belkin_sa_ioctl, - set_termios: belkin_sa_set_termios, - break_ctl: belkin_sa_break_ctl, - startup: belkin_sa_startup, - shutdown: belkin_sa_shutdown, -}; - -/* All of the device info needed for the Belkin serial converter */ -static struct usb_serial_device_type belkin_sa_device = { - name: "Belkin F5U103 USB Serial Adapter", - id_table: belkin_sa_table, /* the Belkin F5U103 device */ - needs_interrupt_in: MUST_HAVE, /* this device must have an interrupt in endpoint */ - needs_bulk_in: MUST_HAVE, /* this device must have a bulk in endpoint */ - needs_bulk_out: MUST_HAVE, /* this device must have a bulk out endpoint */ - num_interrupt_in: 1, - num_bulk_in: 1, - num_bulk_out: 1, - num_ports: 1, - open: belkin_sa_open, - close: belkin_sa_close, - read_int_callback: belkin_sa_read_int_callback, /* How we get the status info */ - ioctl: belkin_sa_ioctl, - set_termios: belkin_sa_set_termios, - break_ctl: belkin_sa_break_ctl, - startup: belkin_sa_startup, - shutdown: belkin_sa_shutdown, -}; - - -/* This driver also supports the "old" school Belkin single port adaptor */ -static struct usb_serial_device_type belkin_old_device = { - name: "Belkin USB Serial Adapter", - id_table: belkin_old_table, /* the old Belkin device */ - needs_interrupt_in: MUST_HAVE, /* this device must have an interrupt in endpoint */ - needs_bulk_in: MUST_HAVE, /* this device must have a bulk in endpoint */ - needs_bulk_out: MUST_HAVE, /* this device must have a bulk out endpoint */ - num_interrupt_in: 1, - num_bulk_in: 1, - num_bulk_out: 1, - num_ports: 1, - open: belkin_sa_open, - close: belkin_sa_close, - read_int_callback: belkin_sa_read_int_callback, /* How we get the status info */ - ioctl: belkin_sa_ioctl, - set_termios: belkin_sa_set_termios, - break_ctl: belkin_sa_break_ctl, - startup: belkin_sa_startup, - shutdown: belkin_sa_shutdown, -}; - -/* this driver also works for the Peracom single port adapter */ -static struct usb_serial_device_type peracom_device = { - name: "Peracom single port USB Serial Adapter", - id_table: peracom_table, /* the Peracom device */ - needs_interrupt_in: MUST_HAVE, /* this device must have an interrupt in endpoint */ - needs_bulk_in: MUST_HAVE, /* this device must have a bulk in endpoint */ - needs_bulk_out: MUST_HAVE, /* this device must have a bulk out endpoint */ - num_interrupt_in: 1, - num_bulk_in: 1, - num_bulk_out: 1, - num_ports: 1, - open: belkin_sa_open, - close: belkin_sa_close, - read_int_callback: belkin_sa_read_int_callback, /* How we get the status info */ - ioctl: belkin_sa_ioctl, - set_termios: belkin_sa_set_termios, - break_ctl: belkin_sa_break_ctl, - startup: belkin_sa_startup, - shutdown: belkin_sa_shutdown, -}; - -/* the GoHubs Go-COM232 device is the same as the Peracom single port adapter */ -static struct usb_serial_device_type gocom232_device = { - name: "GO-COM232 USB Serial Converter", - id_table: gocom232_table, /* the GO-COM232 device */ - needs_interrupt_in: MUST_HAVE, /* this device must have an interrupt in endpoint */ - needs_bulk_in: MUST_HAVE, /* this device must have a bulk in endpoint */ - needs_bulk_out: MUST_HAVE, /* this device must have a bulk out endpoint */ - num_interrupt_in: 1, - num_bulk_in: 1, - num_bulk_out: 1, - num_ports: 1, - open: belkin_sa_open, - close: belkin_sa_close, - read_int_callback: belkin_sa_read_int_callback, /* How we get the status info */ - ioctl: belkin_sa_ioctl, - set_termios: belkin_sa_set_termios, - break_ctl: belkin_sa_break_ctl, - startup: belkin_sa_startup, - shutdown: belkin_sa_shutdown, +/* All of the device info needed for the serial converters */ +static struct usb_serial_device_type belkin_device = { + .owner = THIS_MODULE, + .name = "Belkin / Peracom / GoHubs USB Serial Adapter", + .id_table = id_table_combined, + .num_interrupt_in = 1, + .num_bulk_in = 1, + .num_bulk_out = 1, + .num_ports = 1, + .open = belkin_sa_open, + .close = belkin_sa_close, + .read_int_callback = belkin_sa_read_int_callback, /* How we get the status info */ + .ioctl = belkin_sa_ioctl, + .set_termios = belkin_sa_set_termios, + .break_ctl = belkin_sa_break_ctl, + .startup = belkin_sa_startup, + .shutdown = belkin_sa_shutdown, }; @@ -300,9 +188,6 @@ /* stop reads and writes on all ports */ for (i=0; i < serial->num_ports; ++i) { - while (serial->port[i].open_count > 0) { - belkin_sa_close (&serial->port[i], NULL); - } /* My special items, the standard routines free my urbs */ if (serial->port[i].private) kfree(serial->port[i].private); @@ -316,34 +201,23 @@ dbg("%s port %d", __FUNCTION__, port->number); - down (&port->sem); - - ++port->open_count; - MOD_INC_USE_COUNT; - - if (!port->active) { - port->active = 1; - - /*Start reading from the device*/ - /* TODO: Look at possibility of submitting mulitple URBs to device to - * enhance buffering. Win trace shows 16 initial read URBs. - */ - 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"); + /*Start reading from the device*/ + /* TODO: Look at possibility of submitting mulitple URBs to device to + * enhance buffering. Win trace shows 16 initial read URBs. + */ + 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; } - -exit: - up (&port->sem); + 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: return retval; } /* belkin_sa_open */ @@ -361,22 +235,12 @@ dbg("%s port %d", __FUNCTION__, port->number); - down (&port->sem); - - --port->open_count; - - if (port->open_count <= 0) { - if (serial->dev) { - /* shutdown our bulk reads and writes */ - usb_unlink_urb (port->write_urb); - usb_unlink_urb (port->read_urb); - usb_unlink_urb (port->interrupt_in_urb); - } - port->active = 0; + if (serial->dev) { + /* shutdown our bulk reads and writes */ + 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; } /* belkin_sa_close */ @@ -457,12 +321,31 @@ { struct usb_serial *serial = port->serial; struct belkin_sa_private *priv = (struct belkin_sa_private *)port->private; - unsigned int iflag = port->tty->termios->c_iflag; - unsigned int cflag = port->tty->termios->c_cflag; - unsigned int old_iflag = old_termios->c_iflag; - unsigned int old_cflag = old_termios->c_cflag; + unsigned int iflag; + unsigned int cflag; + unsigned int old_iflag = 0; + unsigned int old_cflag = 0; __u16 urb_value = 0; /* Will hold the new flags */ + if ((!port->tty) || (!port->tty->termios)) { + dbg ("%s - no tty or termios structure", __FUNCTION__); + return; + } + + iflag = port->tty->termios->c_iflag; + cflag = port->tty->termios->c_cflag; + + /* check that they really want us to change something */ + if (old_termios) { + if ((cflag == old_termios->c_cflag) && + (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) { + dbg("%s - nothing to change...", __FUNCTION__); + return; + } + old_iflag = old_termios->c_iflag; + old_cflag = old_termios->c_cflag; + } + /* Set the baud rate */ if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { /* reassert DTR and (maybe) RTS on transition from B0 */ @@ -642,11 +525,7 @@ static int __init belkin_sa_init (void) { - usb_serial_register (&belkin_dockstation_device); - usb_serial_register (&belkin_sa_device); - usb_serial_register (&belkin_old_device); - usb_serial_register (&peracom_device); - usb_serial_register (&gocom232_device); + usb_serial_register (&belkin_device); info(DRIVER_DESC " " DRIVER_VERSION); return 0; } @@ -654,11 +533,7 @@ static void __exit belkin_sa_exit (void) { - usb_serial_deregister (&belkin_dockstation_device); - usb_serial_deregister (&belkin_sa_device); - usb_serial_deregister (&belkin_old_device); - usb_serial_deregister (&peracom_device); - usb_serial_deregister (&gocom232_device); + usb_serial_deregister (&belkin_device); }