ChangeSet 1.1639, 2004/05/14 11:49:41-07:00, greg@kroah.com USB: remove get_usb_serial() as it's pretty much unneeded It also could hide real bugs, and that's not good. And the name implies that a reference is grabbed, and that's not true at all. drivers/usb/serial/belkin_sa.c | 16 +---- drivers/usb/serial/console.c | 5 - drivers/usb/serial/cyberjack.c | 20 +----- drivers/usb/serial/empeg.c | 22 +------ drivers/usb/serial/ftdi_sio.c | 119 ++++++++++++++++----------------------- drivers/usb/serial/generic.c | 13 ---- drivers/usb/serial/io_edgeport.c | 65 +++++++++------------ drivers/usb/serial/io_ti.c | 72 +++++++++-------------- drivers/usb/serial/ipaq.c | 16 ----- drivers/usb/serial/ir-usb.c | 27 +------- drivers/usb/serial/keyspan.c | 6 - drivers/usb/serial/kl5kusb105.c | 58 ++++++------------- drivers/usb/serial/omninet.c | 31 ++-------- drivers/usb/serial/pl2303.c | 19 ------ drivers/usb/serial/safe_serial.c | 13 ---- drivers/usb/serial/usb-serial.c | 83 +++++---------------------- drivers/usb/serial/usb-serial.h | 13 ---- drivers/usb/serial/visor.c | 21 +----- drivers/usb/serial/whiteheat.c | 23 ------- 19 files changed, 187 insertions(+), 455 deletions(-) diff -Nru a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c --- a/drivers/usb/serial/belkin_sa.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/belkin_sa.c Fri May 14 15:27:19 2004 @@ -244,20 +244,12 @@ static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial; - - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - dbg("%s port %d", __FUNCTION__, port->number); - 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); - } + /* 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); } /* belkin_sa_close */ diff -Nru a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c --- a/drivers/usb/serial/console.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/console.c Fri May 14 15:27:19 2004 @@ -199,11 +199,12 @@ { static struct usbcons_info *info = &usbcons_info; struct usb_serial_port *port = info->port; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); + struct usb_serial *serial; int retval = -ENODEV; - if (!serial || !port) + if (!port) return; + serial = port->serial; if (count == 0) return; diff -Nru a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c --- a/drivers/usb/serial/cyberjack.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/cyberjack.c Fri May 14 15:27:19 2004 @@ -375,7 +375,6 @@ { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; short todo; @@ -384,11 +383,6 @@ dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); @@ -436,15 +430,9 @@ { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct cyberjack_private *priv = usb_get_serial_port_data(port); - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); return; @@ -472,11 +460,11 @@ priv->wrsent+=length; /* set up our urb */ - usb_fill_bulk_urb(port->write_urb, serial->dev, - usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), + usb_fill_bulk_urb(port->write_urb, port->serial->dev, + usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, length, - ((serial->type->write_bulk_callback) ? - serial->type->write_bulk_callback : + ((port->serial->type->write_bulk_callback) ? + port->serial->type->write_bulk_callback : cyberjack_write_bulk_callback), port); diff -Nru a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c --- a/drivers/usb/serial/empeg.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/empeg.c Fri May 14 15:27:19 2004 @@ -187,18 +187,10 @@ static void empeg_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; - dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - if (serial->dev) { - /* shutdown our bulk read */ - usb_unlink_urb (port->read_urb); - } + /* shutdown our bulk read */ + usb_unlink_urb (port->read_urb); /* Uncomment the following line if you want to see some statistics in your syslog */ /* dev_info (&port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */ } @@ -361,7 +353,6 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int i; @@ -369,11 +360,6 @@ dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -404,8 +390,8 @@ /* Continue trying to always read */ usb_fill_bulk_urb( port->read_urb, - serial->dev, - usb_rcvbulkpipe(serial->dev, + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c --- a/drivers/usb/serial/ftdi_sio.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/ftdi_sio.c Fri May 14 15:27:19 2004 @@ -1282,7 +1282,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) { /* ftdi_open */ struct termios tmp_termios; - struct usb_serial *serial = port->serial; + struct usb_device *dev = port->serial->dev; struct ftdi_private *priv = usb_get_serial_port_data(port); int result = 0; @@ -1295,7 +1295,7 @@ /* No error checking for this (will get errors later anyway) */ /* See ftdi_sio.h for description of what is reset */ - usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, FTDI_SIO_RESET_SIO, 0, buf, 0, WDR_TIMEOUT); @@ -1318,8 +1318,8 @@ } /* Start reading from the device */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, dev, + usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ftdi_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_KERNEL); @@ -1342,47 +1342,37 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp) { /* ftdi_close */ - struct usb_serial *serial; unsigned int c_cflag = port->tty->termios->c_cflag; char buf[1]; dbg("%s", __FUNCTION__); - serial = get_usb_serial ( port, __FUNCTION__); - if (!serial) - return; + if (c_cflag & HUPCL){ + /* Disable flow control */ + if (usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), + FTDI_SIO_SET_FLOW_CTRL_REQUEST, + FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, + 0, 0, buf, 0, WDR_TIMEOUT) < 0) { + err("error from flowcontrol urb"); + } - if (serial->dev) { - if (c_cflag & HUPCL){ - /* Disable flow control */ - if (usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), - FTDI_SIO_SET_FLOW_CTRL_REQUEST, - FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - 0, 0, buf, 0, WDR_TIMEOUT) < 0) { - err("error from flowcontrol urb"); - } - - /* drop DTR */ - if (set_dtr(port, LOW) < 0){ - err("Error from DTR LOW urb"); - } - /* drop RTS */ - if (set_rts(port, LOW) < 0) { - err("Error from RTS LOW urb"); - } - } /* Note change no line if hupcl is off */ - - /* shutdown our bulk read */ - if (port->read_urb) { - if (usb_unlink_urb (port->read_urb) < 0) { - err("Error unlinking read urb"); - } + /* drop DTR */ + if (set_dtr(port, LOW) < 0){ + err("Error from DTR LOW urb"); } - - } /* if (serial->dev) */ - - + /* drop RTS */ + if (set_rts(port, LOW) < 0) { + err("Error from RTS LOW urb"); + } + } /* Note change no line if hupcl is off */ + + /* shutdown our bulk read */ + if (port->read_urb) { + if (usb_unlink_urb (port->read_urb) < 0) { + err("Error unlinking read urb"); + } + } } /* ftdi_close */ @@ -1397,7 +1387,6 @@ static int ftdi_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { /* ftdi_write */ - struct usb_serial *serial = get_usb_serial ( port, __FUNCTION__); struct ftdi_private *priv = usb_get_serial_port_data(port); struct urb *urb; unsigned char *buffer; @@ -1484,8 +1473,8 @@ usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size, buffer); /* fill the buffer and send it */ - usb_fill_bulk_urb(urb, serial->dev, - usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), + usb_fill_bulk_urb(urb, port->serial->dev, + usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), buffer, transfer_size, ftdi_write_bulk_callback, port); @@ -1555,7 +1544,6 @@ static void ftdi_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { /* ftdi_read_bulk_callback */ struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial; struct tty_struct *tty; struct ftdi_private *priv; char error_flag; @@ -1577,12 +1565,6 @@ if (port->open_count <= 0) return; - serial = get_usb_serial(port,__FUNCTION__); - if (!serial){ - dbg("%s - bad serial pointer - exiting",__FUNCTION__); - return; - } - tty = port->tty; if (!tty) { dbg("%s - bad tty pointer - exiting",__FUNCTION__); @@ -1690,8 +1672,8 @@ /* if the port is closed stop trying to read */ if (port->open_count > 0){ /* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ftdi_read_bulk_callback, port); @@ -1706,7 +1688,6 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) { - struct usb_serial *serial = port->serial; struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value = 0; char buf[1]; @@ -1722,7 +1703,7 @@ } - if (usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), FTDI_SIO_SET_DATA_REQUEST, FTDI_SIO_SET_DATA_REQUEST_TYPE, urb_value , 0, @@ -1742,7 +1723,7 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_termios) { /* ftdi_termios */ - struct usb_serial *serial = port->serial; + struct usb_device *dev = port->serial->dev; unsigned int cflag = port->tty->termios->c_cflag; struct ftdi_private *priv = usb_get_serial_port_data(port); __u16 urb_value; /* will hold the new flags */ @@ -1801,7 +1782,7 @@ * or'ed with this value */ priv->last_set_data_urb_value = urb_value; - if (usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_DATA_REQUEST, FTDI_SIO_SET_DATA_REQUEST_TYPE, urb_value , 0, @@ -1812,7 +1793,7 @@ /* Now do the baudrate */ if ((cflag & CBAUD) == B0 ) { /* Disable flow control */ - if (usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 0, 0, @@ -1838,8 +1819,8 @@ /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ if (cflag & CRTSCTS) { dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); - if (usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(dev, + usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 0 , FTDI_SIO_RTS_CTS_HS, @@ -1864,8 +1845,8 @@ vstop=port->tty->termios->c_cc[VSTOP]; urb_value=(vstop << 8) | (vstart); - if (usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(dev, + usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, urb_value , FTDI_SIO_XON_XOFF_HS, @@ -1876,8 +1857,8 @@ /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ dbg("%s Turning off hardware flow control", __FUNCTION__); - if (usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), + if (usb_control_msg(dev, + usb_sndctrlpipe(dev, 0), FTDI_SIO_SET_FLOW_CTRL_REQUEST, FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 0, 0, @@ -1893,7 +1874,6 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file) { - struct usb_serial *serial = port->serial; struct ftdi_private *priv = usb_get_serial_port_data(port); unsigned char buf[2]; int ret; @@ -1902,8 +1882,8 @@ switch (priv->chip_type) { case SIO: /* Request the status from the device */ - if ((ret = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), + if ((ret = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), FTDI_SIO_GET_MODEM_STATUS_REQUEST, FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 0, 0, @@ -1917,8 +1897,8 @@ case FT232BM: /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same format as the data returned from the in point */ - if ((ret = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), + if ((ret = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), FTDI_SIO_GET_MODEM_STATUS_REQUEST, FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 0, 0, @@ -2101,14 +2081,13 @@ static void ftdi_unthrottle (struct usb_serial_port *port) { int result; - struct usb_serial *serial = port->serial; dbg("%s - port %d", __FUNCTION__, port->number); - port->read_urb->dev = serial->dev; + port->read_urb->dev = port->serial->dev; - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ftdi_read_bulk_callback, port); diff -Nru a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c --- a/drivers/usb/serial/generic.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/generic.c Fri May 14 15:27:19 2004 @@ -220,7 +220,7 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); + struct usb_serial *serial = port->serial; struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int i; @@ -228,11 +228,6 @@ dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -270,14 +265,8 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); dbg("%s - port %d", __FUNCTION__, port->number); - - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } if (urb->status) { dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); diff -Nru a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c --- a/drivers/usb/serial/io_edgeport.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/io_edgeport.c Fri May 14 15:27:19 2004 @@ -1219,52 +1219,45 @@ *****************************************************************************/ static void edge_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; int status; dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - edge_serial = usb_get_serial_data(serial); + edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; - if (serial->dev) { - // block until tx is empty - block_until_tx_empty(edge_port); - - edge_port->closePending = TRUE; - - /* flush and chase */ - edge_port->chaseResponsePending = TRUE; - - dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); - status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); - if (status == 0) { - // block until chase finished - block_until_chase_response(edge_port); - } else { - edge_port->chaseResponsePending = FALSE; - } - - /* close the port */ - dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__); - send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); - - //port->close = TRUE; - edge_port->closePending = FALSE; - edge_port->open = FALSE; - edge_port->openPending = FALSE; - - if (edge_port->write_urb) { - usb_unlink_urb (edge_port->write_urb); - } + // block until tx is empty + block_until_tx_empty(edge_port); + + edge_port->closePending = TRUE; + + /* flush and chase */ + edge_port->chaseResponsePending = TRUE; + + dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); + status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); + if (status == 0) { + // block until chase finished + block_until_chase_response(edge_port); + } else { + edge_port->chaseResponsePending = FALSE; + } + + /* close the port */ + dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__); + send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); + + //port->close = TRUE; + edge_port->closePending = FALSE; + edge_port->open = FALSE; + edge_port->openPending = FALSE; + + if (edge_port->write_urb) { + usb_unlink_urb (edge_port->write_urb); } if (edge_port->write_urb) { diff -Nru a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c --- a/drivers/usb/serial/io_ti.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/io_ti.c Fri May 14 15:27:19 2004 @@ -1792,23 +1792,17 @@ static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; dbg ("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg ("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg ("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); if (urb->status == -EPIPE) { /* clear any problem that might have happened on this pipe */ - usb_clear_halt (serial->dev, urb->pipe); + usb_clear_halt (port->serial->dev, urb->pipe); } return; } @@ -1978,7 +1972,6 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; struct edgeport_serial *edge_serial; struct edgeport_port *edge_port; int port_number; @@ -1986,50 +1979,43 @@ dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - edge_serial = usb_get_serial_data(serial); + edge_serial = usb_get_serial_data(port->serial); edge_port = usb_get_serial_port_data(port); if ((edge_serial == NULL) || (edge_port == NULL)) return; - if (serial->dev) { - /* The bulkreadcompletion routine will check - * this flag and dump add read data */ - edge_port->close_pending = 1; - - /* chase the port close */ - TIChasePort (edge_port); - - usb_unlink_urb (port->read_urb); - - /* assuming we can still talk to the device, - * send a close port command to it */ - dbg("%s - send umpc_close_port", __FUNCTION__); - port_number = port->number - port->serial->minor; - status = TIWriteCommandSync (port->serial->dev, - UMPC_CLOSE_PORT, - (__u8)(UMPM_UART1_PORT + port_number), - 0, - NULL, - 0); - --edge_port->edge_serial->num_ports_open; - if (edge_port->edge_serial->num_ports_open <= 0) { - /* last port is now closed, let's shut down our interrupt urb */ - usb_unlink_urb (serial->port[0]->interrupt_in_urb); - edge_port->edge_serial->num_ports_open = 0; - } - edge_port->close_pending = 0; + /* The bulkreadcompletion routine will check + * this flag and dump add read data */ + edge_port->close_pending = 1; + + /* chase the port close */ + TIChasePort (edge_port); + + usb_unlink_urb (port->read_urb); + + /* assuming we can still talk to the device, + * send a close port command to it */ + dbg("%s - send umpc_close_port", __FUNCTION__); + port_number = port->number - port->serial->minor; + status = TIWriteCommandSync (port->serial->dev, + UMPC_CLOSE_PORT, + (__u8)(UMPM_UART1_PORT + port_number), + 0, + NULL, + 0); + --edge_port->edge_serial->num_ports_open; + if (edge_port->edge_serial->num_ports_open <= 0) { + /* last port is now closed, let's shut down our interrupt urb */ + usb_unlink_urb (port->serial->port[0]->interrupt_in_urb); + edge_port->edge_serial->num_ports_open = 0; } + edge_port->close_pending = 0; dbg("%s - exited", __FUNCTION__); } static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count) { - struct usb_serial *serial = port->serial; struct edgeport_port *edge_port = usb_get_serial_port_data(port); int result; @@ -2062,8 +2048,8 @@ usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer); /* set up our urb */ - usb_fill_bulk_urb (port->write_urb, serial->dev, - usb_sndbulkpipe (serial->dev, + usb_fill_bulk_urb (port->write_urb, port->serial->dev, + usb_sndbulkpipe (port->serial->dev, port->bulk_out_endpointAddress), port->write_urb->transfer_buffer, count, edge_bulk_out_callback, diff -Nru a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c --- a/drivers/usb/serial/ipaq.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/ipaq.c Fri May 14 15:27:19 2004 @@ -284,19 +284,13 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial; struct ipaq_private *priv = usb_get_serial_port_data(port); dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial(port, __FUNCTION__); - if (!serial) - return; - /* * shut down bulk read and write */ - usb_unlink_urb(port->write_urb); usb_unlink_urb(port->read_urb); ipaq_destroy_lists(port); @@ -310,18 +304,12 @@ static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int i, result; dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -344,8 +332,8 @@ } /* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ipaq_read_bulk_callback, port); result = usb_submit_urb(port->read_urb, GFP_ATOMIC); diff -Nru a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c --- a/drivers/usb/serial/ir-usb.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/ir-usb.c Fri May 14 15:27:19 2004 @@ -279,7 +279,6 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial = port->serial; char *buffer; int result = 0; @@ -310,8 +309,8 @@ /* Start reading from the device */ usb_fill_bulk_urb ( port->read_urb, - serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, ir_read_bulk_callback, @@ -325,18 +324,10 @@ static void ir_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; - dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - if (serial->dev) { - /* shutdown our bulk read */ - usb_unlink_urb (port->read_urb); - } + /* shutdown our bulk read */ + usb_unlink_urb (port->read_urb); } static int ir_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) @@ -424,18 +415,12 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int result; dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (!port->open_count) { dbg("%s - port closed.", __FUNCTION__); return; @@ -484,8 +469,8 @@ /* Continue trying to always read */ usb_fill_bulk_urb ( port->read_urb, - serial->dev, - usb_rcvbulkpipe(serial->dev, + port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, diff -Nru a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c --- a/drivers/usb/serial/keyspan.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/keyspan.c Fri May 14 15:27:19 2004 @@ -1141,13 +1141,9 @@ static void keyspan_close(struct usb_serial_port *port, struct file *filp) { int i; - struct usb_serial *serial; + struct usb_serial *serial = port->serial; struct keyspan_serial_private *s_priv; struct keyspan_port_private *p_priv; - - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; dbg("%s", __FUNCTION__); s_priv = usb_get_serial_data(serial); diff -Nru a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c --- a/drivers/usb/serial/kl5kusb105.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/kl5kusb105.c Fri May 14 15:27:19 2004 @@ -187,12 +187,13 @@ #define KLSI_TIMEOUT (HZ * 5 ) /* default urb timeout */ -static int klsi_105_chg_port_settings(struct usb_serial *serial, +static int klsi_105_chg_port_settings(struct usb_serial_port *port, struct klsi_105_port_settings *settings) { int rc; - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + rc = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_SET_DATA, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, 0, /* value */ @@ -227,7 +228,7 @@ */ /* It seems that the status buffer has always only 2 bytes length */ #define KLSI_STATUSBUF_LEN 2 -static int klsi_105_get_line_state(struct usb_serial *serial, +static int klsi_105_get_line_state(struct usb_serial_port *port, unsigned long *line_state_p) { int rc; @@ -235,7 +236,8 @@ __u16 status; info("%s - sending SIO Poll request", __FUNCTION__); - rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), + rc = usb_control_msg(port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_POLL, USB_TYPE_VENDOR | USB_DIR_IN, 0, /* value */ @@ -362,7 +364,6 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial = port->serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); int retval = 0; int rc; @@ -389,7 +390,7 @@ cfg.databits = kl5kusb105a_dtb_8; cfg.unknown1 = 0; cfg.unknown2 = 1; - klsi_105_chg_port_settings(serial, &cfg); + klsi_105_chg_port_settings(port, &cfg); /* set up termios structure */ spin_lock_irqsave (&priv->lock, flags); @@ -407,8 +408,8 @@ spin_unlock_irqrestore (&priv->lock, flags); /* READ_ON and urb submission */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, @@ -422,7 +423,8 @@ goto exit; } - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0), + rc = usb_control_msg(port->serial->dev, + usb_sndctrlpipe(port->serial->dev,0), KL5KUSB105A_SIO_CONFIGURE, USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, KL5KUSB105A_SIO_CONFIGURE_READ_ON, @@ -436,7 +438,7 @@ } else dbg("%s - enabled reading", __FUNCTION__); - rc = klsi_105_get_line_state(serial, &line_state); + rc = klsi_105_get_line_state(port, &line_state); if (rc >= 0) { spin_lock_irqsave (&priv->lock, flags); priv->line_state = line_state; @@ -453,20 +455,14 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); int rc; dbg("%s port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - - if(!serial) - return; - /* send READ_OFF */ - rc = usb_control_msg (serial->dev, - usb_sndctrlpipe(serial->dev, 0), + rc = usb_control_msg (port->serial->dev, + usb_sndctrlpipe(port->serial->dev, 0), KL5KUSB105A_SIO_CONFIGURE, USB_TYPE_VENDOR | USB_DIR_OUT, KL5KUSB105A_SIO_CONFIGURE_READ_OFF, @@ -497,7 +493,6 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { - struct usb_serial *serial = port->serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); int result, size; int bytes_sent=0; @@ -551,8 +546,8 @@ ((__u8 *)urb->transfer_buffer)[1] = (__u8) ((size & 0xFF00)>>8); /* set up our urb */ - usb_fill_bulk_urb(urb, serial->dev, - usb_sndbulkpipe(serial->dev, + usb_fill_bulk_urb(urb, port->serial->dev, + usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), urb->transfer_buffer, URB_TRANSFER_BUFFER_SIZE, @@ -579,15 +574,9 @@ static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = port->serial; dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); @@ -646,7 +635,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = port->serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -660,10 +648,6 @@ urb->status); return; } - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } /* The data received is again preceded by a length double-byte in LSB- * first order (see klsi_105_write() ) @@ -714,8 +698,8 @@ priv->bytes_in += bytes_sent; } /* Continue trying to always read */ - usb_fill_bulk_urb(port->read_urb, serial->dev, - usb_rcvbulkpipe(serial->dev, + usb_fill_bulk_urb(port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, @@ -730,7 +714,6 @@ static void klsi_105_set_termios (struct usb_serial_port *port, struct termios *old_termios) { - struct usb_serial *serial = port->serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); unsigned int iflag = port->tty->termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag; @@ -868,7 +851,7 @@ spin_unlock_irqrestore (&priv->lock, flags); /* now commit changes to device */ - klsi_105_chg_port_settings(serial, &cfg); + klsi_105_chg_port_settings(port, &cfg); } /* klsi_105_set_termios */ @@ -890,14 +873,13 @@ static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) { - struct usb_serial *serial = port->serial; struct klsi_105_private *priv = usb_get_serial_port_data(port); unsigned long flags; int rc; unsigned long line_state; dbg("%s - request, just guessing", __FUNCTION__); - rc = klsi_105_get_line_state(serial, &line_state); + rc = klsi_105_get_line_state(port, &line_state); if (rc < 0) { err("Reading line control failed (error = %d)", rc); /* better return value? EAGAIN? */ diff -Nru a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c --- a/drivers/usb/serial/omninet.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/omninet.c Fri May 14 15:27:19 2004 @@ -151,17 +151,13 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial; + struct usb_serial *serial = port->serial; struct usb_serial_port *wport; struct omninet_data *od; int result = 0; dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return -ENODEV; - od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL ); if( !od ) { err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); @@ -186,21 +182,15 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; + struct usb_serial *serial = port->serial; struct usb_serial_port *wport; struct omninet_data *od; dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - - if (serial->dev) { - wport = serial->port[1]; - usb_unlink_urb (wport->write_urb); - usb_unlink_urb (port->read_urb); - } + wport = serial->port[1]; + usb_unlink_urb(wport->write_urb); + usb_unlink_urb(port->read_urb); od = usb_get_serial_port_data(port); if (od) @@ -215,8 +205,6 @@ static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - unsigned char *data = urb->transfer_buffer; struct omninet_header *header = (struct omninet_header *) &data[0]; @@ -225,11 +213,6 @@ // dbg("omninet_read_bulk_callback"); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -253,8 +236,8 @@ } /* Continue trying to always read */ - usb_fill_bulk_urb(urb, serial->dev, - usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb(urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), urb->transfer_buffer, urb->transfer_buffer_length, omninet_read_bulk_callback, port); result = usb_submit_urb(urb, GFP_ATOMIC); diff -Nru a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c --- a/drivers/usb/serial/pl2303.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/pl2303.c Fri May 14 15:27:19 2004 @@ -471,16 +471,11 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp) { - struct usb_serial *serial; struct pl2303_private *priv; unsigned long flags; unsigned int c_cflag; int result; - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - dbg("%s - port %d", __FUNCTION__, port->number); /* shutdown our urbs */ @@ -657,7 +652,6 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *) urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; unsigned long flags; @@ -681,9 +675,6 @@ goto exit; } - if (!serial) { - return; - } usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer); @@ -708,7 +699,6 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *) urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct pl2303_private *priv = usb_get_serial_port_data(port); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; @@ -720,11 +710,6 @@ dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - urb->status = %d", __FUNCTION__, urb->status); if (!port->open_count) { @@ -735,7 +720,7 @@ /* PL2303 mysteriously fails with -EPROTO reschedule the read */ dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); urb->status = 0; - urb->dev = serial->dev; + urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); @@ -783,7 +768,7 @@ /* Schedule the next read _if_ we are still open */ if (port->open_count) { - urb->dev = serial->dev; + urb->dev = port->serial->dev; result = usb_submit_urb(urb, GFP_ATOMIC); if (result) dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); diff -Nru a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c --- a/drivers/usb/serial/safe_serial.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/safe_serial.c Fri May 14 15:27:19 2004 @@ -211,7 +211,6 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *) urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); unsigned char *data = urb->transfer_buffer; unsigned char length = urb->actual_length; int i; @@ -219,11 +218,6 @@ dbg ("%s", __FUNCTION__); - if (!serial) { - dbg ("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg ("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -272,8 +266,8 @@ } /* Continue trying to always read */ - usb_fill_bulk_urb (urb, serial->dev, - usb_rcvbulkpipe (serial->dev, port->bulk_in_endpointAddress), + usb_fill_bulk_urb (urb, port->serial->dev, + usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress), urb->transfer_buffer, urb->transfer_buffer_length, safe_read_bulk_callback, port); @@ -284,7 +278,6 @@ static int safe_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) { - struct usb_serial *serial = port->serial; unsigned char *data; int result; int i; @@ -367,7 +360,7 @@ printk ("\n"); } #endif - port->write_urb->dev = serial->dev; + port->write_urb->dev = port->serial->dev; if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) { err ("%s - failed submitting write urb, error %d", __FUNCTION__, result); return 0; diff -Nru a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c --- a/drivers/usb/serial/usb-serial.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/usb-serial.c Fri May 14 15:27:19 2004 @@ -492,10 +492,6 @@ static void serial_close(struct tty_struct *tty, struct file * filp) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - return; dbg("%s - port %d", __FUNCTION__, port->number); @@ -520,12 +516,8 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); int retval = -EINVAL; - if (!serial) - return -ENODEV; - dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); if (!port->open_count) { @@ -534,7 +526,7 @@ } /* pass on to the driver specific version of this function */ - retval = serial->type->write(port, from_user, buf, count); + retval = port->serial->type->write(port, from_user, buf, count); exit: return retval; @@ -543,12 +535,8 @@ static int serial_write_room (struct tty_struct *tty) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); int retval = -EINVAL; - if (!serial) - return -ENODEV; - dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -557,7 +545,7 @@ } /* pass on to the driver specific version of this function */ - retval = serial->type->write_room(port); + retval = port->serial->type->write_room(port); exit: return retval; @@ -566,12 +554,8 @@ static int serial_chars_in_buffer (struct tty_struct *tty) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); int retval = -EINVAL; - if (!serial) - return -ENODEV; - dbg("%s = port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -580,7 +564,7 @@ } /* pass on to the driver specific version of this function */ - retval = serial->type->chars_in_buffer(port); + retval = port->serial->type->chars_in_buffer(port); exit: return retval; @@ -589,10 +573,6 @@ static void serial_throttle (struct tty_struct * tty) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - return; dbg("%s - port %d", __FUNCTION__, port->number); @@ -602,8 +582,8 @@ } /* pass on to the driver specific version of this function */ - if (serial->type->throttle) - serial->type->throttle(port); + if (port->serial->type->throttle) + port->serial->type->throttle(port); exit: ; @@ -612,10 +592,6 @@ static void serial_unthrottle (struct tty_struct * tty) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - return; dbg("%s - port %d", __FUNCTION__, port->number); @@ -625,8 +601,8 @@ } /* pass on to the driver specific version of this function */ - if (serial->type->unthrottle) - serial->type->unthrottle(port); + if (port->serial->type->unthrottle) + port->serial->type->unthrottle(port); exit: ; @@ -635,12 +611,8 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); int retval = -ENODEV; - if (!serial) - return -ENODEV; - dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); if (!port->open_count) { @@ -649,8 +621,8 @@ } /* pass on to the driver specific version of this function if it is available */ - if (serial->type->ioctl) - retval = serial->type->ioctl(port, file, cmd, arg); + if (port->serial->type->ioctl) + retval = port->serial->type->ioctl(port, file, cmd, arg); else retval = -ENOIOCTLCMD; @@ -661,10 +633,6 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - return; dbg("%s - port %d", __FUNCTION__, port->number); @@ -674,8 +642,8 @@ } /* pass on to the driver specific version of this function if it is available */ - if (serial->type->set_termios) - serial->type->set_termios(port, old); + if (port->serial->type->set_termios) + port->serial->type->set_termios(port, old); exit: ; @@ -684,10 +652,6 @@ static void serial_break (struct tty_struct *tty, int break_state) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - return; dbg("%s - port %d", __FUNCTION__, port->number); @@ -697,8 +661,8 @@ } /* pass on to the driver specific version of this function if it is available */ - if (serial->type->break_ctl) - serial->type->break_ctl(port, break_state); + if (port->serial->type->break_ctl) + port->serial->type->break_ctl(port, break_state); exit: ; @@ -757,10 +721,6 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - goto exit; dbg("%s - port %d", __FUNCTION__, port->number); @@ -769,8 +729,8 @@ goto exit; } - if (serial->type->tiocmget) - return serial->type->tiocmget(port, file); + if (port->serial->type->tiocmget) + return port->serial->type->tiocmget(port, file); exit: return -EINVAL; @@ -780,10 +740,6 @@ unsigned int set, unsigned int clear) { struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); - - if (!serial) - goto exit; dbg("%s - port %d", __FUNCTION__, port->number); @@ -792,8 +748,8 @@ goto exit; } - if (serial->type->tiocmset) - return serial->type->tiocmset(port, file, set, clear); + if (port->serial->type->tiocmset) + return port->serial->type->tiocmset(port, file, set, clear); exit: return -EINVAL; @@ -802,16 +758,11 @@ void usb_serial_port_softint(void *private) { struct usb_serial_port *port = (struct usb_serial_port *)private; - struct usb_serial *serial; struct tty_struct *tty; dbg("%s - port %d", __FUNCTION__, port->number); if (!port) - return; - - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) return; tty = port->tty; diff -Nru a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h --- a/drivers/usb/serial/usb-serial.h Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/usb-serial.h Fri May 14 15:27:19 2004 @@ -294,19 +294,6 @@ extern struct bus_type usb_serial_bus_type; extern struct tty_driver *usb_serial_tty_driver; -static inline struct usb_serial* get_usb_serial (struct usb_serial_port *port, const char *function) -{ - /* if no port was specified, or it fails a paranoia check */ - if (!port) { - /* then say that we don't have a valid usb_serial thing, which will - * end up genrating -ENODEV return values */ - return NULL; - } - - return port->serial; -} - - static inline void usb_serial_debug_data (const char *file, const char *function, int size, const unsigned char *data) { int i; diff -Nru a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c --- a/drivers/usb/serial/visor.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/visor.c Fri May 14 15:27:19 2004 @@ -443,15 +443,10 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) { - struct usb_serial *serial; unsigned char *transfer_buffer; dbg("%s - port %d", __FUNCTION__, port->number); - serial = get_usb_serial (port, __FUNCTION__); - if (!serial) - return; - /* shutdown our urbs */ usb_unlink_urb (port->read_urb); if (port->interrupt_in_urb) @@ -460,8 +455,8 @@ /* Try to send shutdown message, if the device is gone, this will just fail. */ transfer_buffer = kmalloc (0x12, GFP_KERNEL); if (transfer_buffer) { - usb_control_msg (serial->dev, - usb_rcvctrlpipe(serial->dev, 0), + usb_control_msg (port->serial->dev, + usb_rcvctrlpipe(port->serial->dev, 0), VISOR_CLOSE_NOTIFICATION, 0xc2, 0x0000, 0x0000, transfer_buffer, 0x12, 300); @@ -578,7 +573,6 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct tty_struct *tty; unsigned char *data = urb->transfer_buffer; int i; @@ -586,11 +580,6 @@ dbg("%s - port %d", __FUNCTION__, port->number); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); return; @@ -613,9 +602,9 @@ bytes_in += urb->actual_length; /* Continue trying to always read */ - usb_fill_bulk_urb (port->read_urb, serial->dev, - usb_rcvbulkpipe (serial->dev, - port->bulk_in_endpointAddress), + usb_fill_bulk_urb (port->read_urb, port->serial->dev, + usb_rcvbulkpipe(port->serial->dev, + port->bulk_in_endpointAddress), port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, visor_read_bulk_callback, port); diff -Nru a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c --- a/drivers/usb/serial/whiteheat.c Fri May 14 15:27:19 2004 +++ b/drivers/usb/serial/whiteheat.c Fri May 14 15:27:19 2004 @@ -984,7 +984,6 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (command_port, __FUNCTION__); struct whiteheat_command_private *command_info; unsigned char *data = urb->transfer_buffer; int result; @@ -997,11 +996,6 @@ return; } - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } - usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); command_info = usb_get_serial_port_data(command_port); @@ -1029,7 +1023,7 @@ } /* Continue trying to always read */ - command_port->read_urb->dev = serial->dev; + command_port->read_urb->dev = command_port->serial->dev; result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); spin_unlock_irqrestore(&command_info->lock, flags); if (result) @@ -1040,7 +1034,6 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct whiteheat_urb_wrap *wrap; unsigned char *data = urb->transfer_buffer; struct whiteheat_private *info = usb_get_serial_port_data(port); @@ -1057,14 +1050,6 @@ list_del(&wrap->list); spin_unlock(&info->lock); - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - spin_lock(&info->lock); - list_add(&wrap->list, &info->rx_urbs_free); - spin_unlock(&info->lock); - return; - } - if (urb->status) { dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); spin_lock(&info->lock); @@ -1091,7 +1076,6 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) { struct usb_serial_port *port = (struct usb_serial_port *)urb->context; - struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_urb_wrap *wrap; @@ -1107,11 +1091,6 @@ list_del(&wrap->list); list_add(&wrap->list, &info->tx_urbs_free); spin_unlock(&info->lock); - - if (!serial) { - dbg("%s - bad serial pointer, exiting", __FUNCTION__); - return; - } if (urb->status) { dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);