Commit 198ec964 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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.
parent 0cc8b902
...@@ -244,20 +244,12 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp) ...@@ -244,20 +244,12 @@ static int belkin_sa_open (struct usb_serial_port *port, struct file *filp)
static void belkin_sa_close (struct usb_serial_port *port, struct file *filp) 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); dbg("%s port %d", __FUNCTION__, port->number);
if (serial->dev) { /* shutdown our bulk reads and writes */
/* shutdown our bulk reads and writes */ usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->interrupt_in_urb);
usb_unlink_urb (port->interrupt_in_urb);
}
} /* belkin_sa_close */ } /* belkin_sa_close */
......
...@@ -199,11 +199,12 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun ...@@ -199,11 +199,12 @@ static void usb_console_write(struct console *co, const char *buf, unsigned coun
{ {
static struct usbcons_info *info = &usbcons_info; static struct usbcons_info *info = &usbcons_info;
struct usb_serial_port *port = info->port; struct usb_serial_port *port = info->port;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial;
int retval = -ENODEV; int retval = -ENODEV;
if (!serial || !port) if (!port)
return; return;
serial = port->serial;
if (count == 0) if (count == 0)
return; return;
......
...@@ -375,7 +375,6 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -375,7 +375,6 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct cyberjack_private *priv = usb_get_serial_port_data(port); struct cyberjack_private *priv = usb_get_serial_port_data(port);
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
short todo; short todo;
...@@ -384,11 +383,6 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -384,11 +383,6 @@ static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer); usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
...@@ -436,15 +430,9 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs ...@@ -436,15 +430,9 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct cyberjack_private *priv = usb_get_serial_port_data(port); 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); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -472,11 +460,11 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs ...@@ -472,11 +460,11 @@ static void cyberjack_write_bulk_callback (struct urb *urb, struct pt_regs *regs
priv->wrsent+=length; priv->wrsent+=length;
/* set up our urb */ /* set up our urb */
usb_fill_bulk_urb(port->write_urb, serial->dev, usb_fill_bulk_urb(port->write_urb, port->serial->dev,
usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress), usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
port->write_urb->transfer_buffer, length, port->write_urb->transfer_buffer, length,
((serial->type->write_bulk_callback) ? ((port->serial->type->write_bulk_callback) ?
serial->type->write_bulk_callback : port->serial->type->write_bulk_callback :
cyberjack_write_bulk_callback), cyberjack_write_bulk_callback),
port); port);
......
...@@ -187,18 +187,10 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp) ...@@ -187,18 +187,10 @@ static int empeg_open (struct usb_serial_port *port, struct file *filp)
static void empeg_close (struct usb_serial_port *port, struct file * filp) static void empeg_close (struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__); /* shutdown our bulk read */
if (!serial) usb_unlink_urb (port->read_urb);
return;
if (serial->dev) {
/* shutdown our bulk read */
usb_unlink_urb (port->read_urb);
}
/* Uncomment the following line if you want to see some statistics in your syslog */ /* 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); */ /* dev_info (&port->dev, "Bytes In = %d Bytes Out = %d\n", bytes_in, bytes_out); */
} }
...@@ -361,7 +353,6 @@ static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -361,7 +353,6 @@ static void empeg_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int i; int i;
...@@ -369,11 +360,6 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -369,11 +360,6 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -404,8 +390,8 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -404,8 +390,8 @@ static void empeg_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb( usb_fill_bulk_urb(
port->read_urb, port->read_urb,
serial->dev, port->serial->dev,
usb_rcvbulkpipe(serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
......
This diff is collapsed.
...@@ -220,7 +220,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port) ...@@ -220,7 +220,7 @@ int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port)
void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_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; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int i; int i;
...@@ -228,11 +228,6 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg ...@@ -228,11 +228,6 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -270,15 +265,9 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg ...@@ -270,15 +265,9 @@ void usb_serial_generic_read_bulk_callback (struct urb *urb, struct pt_regs *reg
void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
return; return;
......
...@@ -1219,52 +1219,45 @@ static void block_until_tx_empty (struct edgeport_port *edge_port) ...@@ -1219,52 +1219,45 @@ static void block_until_tx_empty (struct edgeport_port *edge_port)
*****************************************************************************/ *****************************************************************************/
static void edge_close (struct usb_serial_port *port, struct file * filp) static void edge_close (struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial;
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
int status; int status;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__); edge_serial = usb_get_serial_data(port->serial);
if (!serial)
return;
edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port); edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL)) if ((edge_serial == NULL) || (edge_port == NULL))
return; return;
if (serial->dev) { // block until tx is empty
// block until tx is empty block_until_tx_empty(edge_port);
block_until_tx_empty(edge_port);
edge_port->closePending = TRUE; edge_port->closePending = TRUE;
/* flush and chase */ /* flush and chase */
edge_port->chaseResponsePending = TRUE; edge_port->chaseResponsePending = TRUE;
dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__); dbg("%s - Sending IOSP_CMD_CHASE_PORT", __FUNCTION__);
status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0); status = send_iosp_ext_cmd (edge_port, IOSP_CMD_CHASE_PORT, 0);
if (status == 0) { if (status == 0) {
// block until chase finished // block until chase finished
block_until_chase_response(edge_port); block_until_chase_response(edge_port);
} else { } else {
edge_port->chaseResponsePending = FALSE; edge_port->chaseResponsePending = FALSE;
} }
/* close the port */ /* close the port */
dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__); dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __FUNCTION__);
send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0); send_iosp_ext_cmd (edge_port, IOSP_CMD_CLOSE_PORT, 0);
//port->close = TRUE; //port->close = TRUE;
edge_port->closePending = FALSE; edge_port->closePending = FALSE;
edge_port->open = FALSE; edge_port->open = FALSE;
edge_port->openPending = FALSE; edge_port->openPending = FALSE;
if (edge_port->write_urb) { if (edge_port->write_urb) {
usb_unlink_urb (edge_port->write_urb); usb_unlink_urb (edge_port->write_urb);
}
} }
if (edge_port->write_urb) { if (edge_port->write_urb) {
......
...@@ -1792,23 +1792,17 @@ static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs) ...@@ -1792,23 +1792,17 @@ static void edge_bulk_in_callback (struct urb *urb, struct pt_regs *regs)
static void edge_bulk_out_callback (struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
dbg ("%s - port %d", __FUNCTION__, port->number); dbg ("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg ("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg ("%s - nonzero write bulk status received: %d", dbg ("%s - nonzero write bulk status received: %d",
__FUNCTION__, urb->status); __FUNCTION__, urb->status);
if (urb->status == -EPIPE) { if (urb->status == -EPIPE) {
/* clear any problem that might have happened on this pipe */ /* 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; return;
} }
...@@ -1978,7 +1972,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp) ...@@ -1978,7 +1972,6 @@ static int edge_open (struct usb_serial_port *port, struct file * filp)
static void edge_close (struct usb_serial_port *port, struct file * filp) static void edge_close (struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial;
struct edgeport_serial *edge_serial; struct edgeport_serial *edge_serial;
struct edgeport_port *edge_port; struct edgeport_port *edge_port;
int port_number; int port_number;
...@@ -1986,50 +1979,43 @@ static void edge_close (struct usb_serial_port *port, struct file * filp) ...@@ -1986,50 +1979,43 @@ static void edge_close (struct usb_serial_port *port, struct file * filp)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__); edge_serial = usb_get_serial_data(port->serial);
if (!serial)
return;
edge_serial = usb_get_serial_data(serial);
edge_port = usb_get_serial_port_data(port); edge_port = usb_get_serial_port_data(port);
if ((edge_serial == NULL) || (edge_port == NULL)) if ((edge_serial == NULL) || (edge_port == NULL))
return; return;
if (serial->dev) { /* The bulkreadcompletion routine will check
/* The bulkreadcompletion routine will check * this flag and dump add read data */
* this flag and dump add read data */ edge_port->close_pending = 1;
edge_port->close_pending = 1;
/* chase the port close */
/* chase the port close */ TIChasePort (edge_port);
TIChasePort (edge_port);
usb_unlink_urb (port->read_urb);
usb_unlink_urb (port->read_urb);
/* assuming we can still talk to the device,
/* assuming we can still talk to the device, * send a close port command to it */
* send a close port command to it */ dbg("%s - send umpc_close_port", __FUNCTION__);
dbg("%s - send umpc_close_port", __FUNCTION__); port_number = port->number - port->serial->minor;
port_number = port->number - port->serial->minor; status = TIWriteCommandSync (port->serial->dev,
status = TIWriteCommandSync (port->serial->dev, UMPC_CLOSE_PORT,
UMPC_CLOSE_PORT, (__u8)(UMPM_UART1_PORT + port_number),
(__u8)(UMPM_UART1_PORT + port_number), 0,
0, NULL,
NULL, 0);
0); --edge_port->edge_serial->num_ports_open;
--edge_port->edge_serial->num_ports_open; if (edge_port->edge_serial->num_ports_open <= 0) {
if (edge_port->edge_serial->num_ports_open <= 0) { /* last port is now closed, let's shut down our interrupt urb */
/* last port is now closed, let's shut down our interrupt urb */ usb_unlink_urb (port->serial->port[0]->interrupt_in_urb);
usb_unlink_urb (serial->port[0]->interrupt_in_urb); edge_port->edge_serial->num_ports_open = 0;
edge_port->edge_serial->num_ports_open = 0;
}
edge_port->close_pending = 0;
} }
edge_port->close_pending = 0;
dbg("%s - exited", __FUNCTION__); dbg("%s - exited", __FUNCTION__);
} }
static int edge_write (struct usb_serial_port *port, int from_user, const unsigned char *data, int count) 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); struct edgeport_port *edge_port = usb_get_serial_port_data(port);
int result; int result;
...@@ -2062,8 +2048,8 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign ...@@ -2062,8 +2048,8 @@ static int edge_write (struct usb_serial_port *port, int from_user, const unsign
usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer); usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
/* set up our urb */ /* set up our urb */
usb_fill_bulk_urb (port->write_urb, serial->dev, usb_fill_bulk_urb (port->write_urb, port->serial->dev,
usb_sndbulkpipe (serial->dev, usb_sndbulkpipe (port->serial->dev,
port->bulk_out_endpointAddress), port->bulk_out_endpointAddress),
port->write_urb->transfer_buffer, count, port->write_urb->transfer_buffer, count,
edge_bulk_out_callback, edge_bulk_out_callback,
......
...@@ -284,19 +284,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp) ...@@ -284,19 +284,13 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
static void ipaq_close(struct usb_serial_port *port, struct file *filp) 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); struct ipaq_private *priv = usb_get_serial_port_data(port);
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial(port, __FUNCTION__);
if (!serial)
return;
/* /*
* shut down bulk read and write * shut down bulk read and write
*/ */
usb_unlink_urb(port->write_urb); usb_unlink_urb(port->write_urb);
usb_unlink_urb(port->read_urb); usb_unlink_urb(port->read_urb);
ipaq_destroy_lists(port); ipaq_destroy_lists(port);
...@@ -310,18 +304,12 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp) ...@@ -310,18 +304,12 @@ static void ipaq_close(struct usb_serial_port *port, struct file *filp)
static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int i, result; int i, result;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -344,8 +332,8 @@ static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs) ...@@ -344,8 +332,8 @@ static void ipaq_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
} }
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb(port->read_urb, serial->dev, usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
ipaq_read_bulk_callback, port); ipaq_read_bulk_callback, port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC); result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
......
...@@ -279,7 +279,6 @@ static int ir_startup (struct usb_serial *serial) ...@@ -279,7 +279,6 @@ static int ir_startup (struct usb_serial *serial)
static int ir_open (struct usb_serial_port *port, struct file *filp) static int ir_open (struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial = port->serial;
char *buffer; char *buffer;
int result = 0; int result = 0;
...@@ -310,8 +309,8 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -310,8 +309,8 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
/* Start reading from the device */ /* Start reading from the device */
usb_fill_bulk_urb ( usb_fill_bulk_urb (
port->read_urb, port->read_urb,
serial->dev, port->serial->dev,
usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
ir_read_bulk_callback, ir_read_bulk_callback,
...@@ -325,18 +324,10 @@ static int ir_open (struct usb_serial_port *port, struct file *filp) ...@@ -325,18 +324,10 @@ static int ir_open (struct usb_serial_port *port, struct file *filp)
static void ir_close (struct usb_serial_port *port, struct file * filp) static void ir_close (struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__); /* shutdown our bulk read */
if (!serial) usb_unlink_urb (port->read_urb);
return;
if (serial->dev) {
/* 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) 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_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -424,18 +415,12 @@ static void ir_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int result; int result;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (!port->open_count) { if (!port->open_count) {
dbg("%s - port closed.", __FUNCTION__); dbg("%s - port closed.", __FUNCTION__);
return; return;
...@@ -484,8 +469,8 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -484,8 +469,8 @@ static void ir_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb ( usb_fill_bulk_urb (
port->read_urb, port->read_urb,
serial->dev, port->serial->dev,
usb_rcvbulkpipe(serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
......
...@@ -1141,14 +1141,10 @@ static inline void stop_urb(struct urb *urb) ...@@ -1141,14 +1141,10 @@ static inline void stop_urb(struct urb *urb)
static void keyspan_close(struct usb_serial_port *port, struct file *filp) static void keyspan_close(struct usb_serial_port *port, struct file *filp)
{ {
int i; int i;
struct usb_serial *serial; struct usb_serial *serial = port->serial;
struct keyspan_serial_private *s_priv; struct keyspan_serial_private *s_priv;
struct keyspan_port_private *p_priv; struct keyspan_port_private *p_priv;
serial = get_usb_serial (port, __FUNCTION__);
if (!serial)
return;
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
s_priv = usb_get_serial_data(serial); s_priv = usb_get_serial_data(serial);
p_priv = usb_get_serial_port_data(port); p_priv = usb_get_serial_port_data(port);
......
...@@ -187,12 +187,13 @@ struct klsi_105_private { ...@@ -187,12 +187,13 @@ struct klsi_105_private {
#define KLSI_TIMEOUT (HZ * 5 ) /* default urb timeout */ #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) struct klsi_105_port_settings *settings)
{ {
int rc; 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, KL5KUSB105A_SIO_SET_DATA,
USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE,
0, /* value */ 0, /* value */
...@@ -227,7 +228,7 @@ static unsigned long klsi_105_status2linestate(const __u16 status) ...@@ -227,7 +228,7 @@ static unsigned long klsi_105_status2linestate(const __u16 status)
*/ */
/* It seems that the status buffer has always only 2 bytes length */ /* It seems that the status buffer has always only 2 bytes length */
#define KLSI_STATUSBUF_LEN 2 #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) unsigned long *line_state_p)
{ {
int rc; int rc;
...@@ -235,7 +236,8 @@ static int klsi_105_get_line_state(struct usb_serial *serial, ...@@ -235,7 +236,8 @@ static int klsi_105_get_line_state(struct usb_serial *serial,
__u16 status; __u16 status;
info("%s - sending SIO Poll request", __FUNCTION__); 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, KL5KUSB105A_SIO_POLL,
USB_TYPE_VENDOR | USB_DIR_IN, USB_TYPE_VENDOR | USB_DIR_IN,
0, /* value */ 0, /* value */
...@@ -362,7 +364,6 @@ static void klsi_105_shutdown (struct usb_serial *serial) ...@@ -362,7 +364,6 @@ static void klsi_105_shutdown (struct usb_serial *serial)
static int klsi_105_open (struct usb_serial_port *port, struct file *filp) 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); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int retval = 0; int retval = 0;
int rc; int rc;
...@@ -389,7 +390,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -389,7 +390,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
cfg.databits = kl5kusb105a_dtb_8; cfg.databits = kl5kusb105a_dtb_8;
cfg.unknown1 = 0; cfg.unknown1 = 0;
cfg.unknown2 = 1; cfg.unknown2 = 1;
klsi_105_chg_port_settings(serial, &cfg); klsi_105_chg_port_settings(port, &cfg);
/* set up termios structure */ /* set up termios structure */
spin_lock_irqsave (&priv->lock, flags); spin_lock_irqsave (&priv->lock, flags);
...@@ -407,8 +408,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -407,8 +408,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
spin_unlock_irqrestore (&priv->lock, flags); spin_unlock_irqrestore (&priv->lock, flags);
/* READ_ON and urb submission */ /* READ_ON and urb submission */
usb_fill_bulk_urb(port->read_urb, serial->dev, usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
...@@ -422,7 +423,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -422,7 +423,8 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
goto exit; 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, KL5KUSB105A_SIO_CONFIGURE,
USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE,
KL5KUSB105A_SIO_CONFIGURE_READ_ON, KL5KUSB105A_SIO_CONFIGURE_READ_ON,
...@@ -436,7 +438,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -436,7 +438,7 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
} else } else
dbg("%s - enabled reading", __FUNCTION__); 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) { if (rc >= 0) {
spin_lock_irqsave (&priv->lock, flags); spin_lock_irqsave (&priv->lock, flags);
priv->line_state = line_state; priv->line_state = line_state;
...@@ -453,20 +455,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp) ...@@ -453,20 +455,14 @@ static int klsi_105_open (struct usb_serial_port *port, struct file *filp)
static void klsi_105_close (struct usb_serial_port *port, struct file *filp) 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); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int rc; int rc;
dbg("%s port %d", __FUNCTION__, port->number); dbg("%s port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__);
if(!serial)
return;
/* send READ_OFF */ /* send READ_OFF */
rc = usb_control_msg (serial->dev, rc = usb_control_msg (port->serial->dev,
usb_sndctrlpipe(serial->dev, 0), usb_sndctrlpipe(port->serial->dev, 0),
KL5KUSB105A_SIO_CONFIGURE, KL5KUSB105A_SIO_CONFIGURE,
USB_TYPE_VENDOR | USB_DIR_OUT, USB_TYPE_VENDOR | USB_DIR_OUT,
KL5KUSB105A_SIO_CONFIGURE_READ_OFF, KL5KUSB105A_SIO_CONFIGURE_READ_OFF,
...@@ -497,7 +493,6 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp) ...@@ -497,7 +493,6 @@ static void klsi_105_close (struct usb_serial_port *port, struct file *filp)
static int klsi_105_write (struct usb_serial_port *port, int from_user, static int klsi_105_write (struct usb_serial_port *port, int from_user,
const unsigned char *buf, int count) const unsigned char *buf, int count)
{ {
struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
int result, size; int result, size;
int bytes_sent=0; int bytes_sent=0;
...@@ -551,8 +546,8 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user, ...@@ -551,8 +546,8 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
((__u8 *)urb->transfer_buffer)[1] = (__u8) ((size & 0xFF00)>>8); ((__u8 *)urb->transfer_buffer)[1] = (__u8) ((size & 0xFF00)>>8);
/* set up our urb */ /* set up our urb */
usb_fill_bulk_urb(urb, serial->dev, usb_fill_bulk_urb(urb, port->serial->dev,
usb_sndbulkpipe(serial->dev, usb_sndbulkpipe(port->serial->dev,
port->bulk_out_endpointAddress), port->bulk_out_endpointAddress),
urb->transfer_buffer, urb->transfer_buffer,
URB_TRANSFER_BUFFER_SIZE, URB_TRANSFER_BUFFER_SIZE,
...@@ -579,15 +574,9 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user, ...@@ -579,15 +574,9 @@ static int klsi_105_write (struct usb_serial_port *port, int from_user,
static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = port->serial;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
urb->status); urb->status);
...@@ -646,7 +635,6 @@ static int klsi_105_write_room (struct usb_serial_port *port) ...@@ -646,7 +635,6 @@ static int klsi_105_write_room (struct usb_serial_port *port)
static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_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 klsi_105_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -660,10 +648,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -660,10 +648,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
urb->status); urb->status);
return; return;
} }
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
/* The data received is again preceded by a length double-byte in LSB- /* The data received is again preceded by a length double-byte in LSB-
* first order (see klsi_105_write() ) * first order (see klsi_105_write() )
...@@ -714,8 +698,8 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -714,8 +698,8 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
priv->bytes_in += bytes_sent; priv->bytes_in += bytes_sent;
} }
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb(port->read_urb, serial->dev, usb_fill_bulk_urb(port->read_urb, port->serial->dev,
usb_rcvbulkpipe(serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
...@@ -730,7 +714,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -730,7 +714,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void klsi_105_set_termios (struct usb_serial_port *port, static void klsi_105_set_termios (struct usb_serial_port *port,
struct termios *old_termios) struct termios *old_termios)
{ {
struct usb_serial *serial = port->serial;
struct klsi_105_private *priv = usb_get_serial_port_data(port); struct klsi_105_private *priv = usb_get_serial_port_data(port);
unsigned int iflag = port->tty->termios->c_iflag; unsigned int iflag = port->tty->termios->c_iflag;
unsigned int old_iflag = old_termios->c_iflag; unsigned int old_iflag = old_termios->c_iflag;
...@@ -868,7 +851,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port, ...@@ -868,7 +851,7 @@ static void klsi_105_set_termios (struct usb_serial_port *port,
spin_unlock_irqrestore (&priv->lock, flags); spin_unlock_irqrestore (&priv->lock, flags);
/* now commit changes to device */ /* now commit changes to device */
klsi_105_chg_port_settings(serial, &cfg); klsi_105_chg_port_settings(port, &cfg);
} /* klsi_105_set_termios */ } /* klsi_105_set_termios */
...@@ -890,14 +873,13 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state ) ...@@ -890,14 +873,13 @@ static void mct_u232_break_ctl( struct usb_serial_port *port, int break_state )
static int klsi_105_tiocmget (struct usb_serial_port *port, struct file *file) 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); struct klsi_105_private *priv = usb_get_serial_port_data(port);
unsigned long flags; unsigned long flags;
int rc; int rc;
unsigned long line_state; unsigned long line_state;
dbg("%s - request, just guessing", __FUNCTION__); 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) { if (rc < 0) {
err("Reading line control failed (error = %d)", rc); err("Reading line control failed (error = %d)", rc);
/* better return value? EAGAIN? */ /* better return value? EAGAIN? */
......
...@@ -151,17 +151,13 @@ struct omninet_data ...@@ -151,17 +151,13 @@ struct omninet_data
static int omninet_open (struct usb_serial_port *port, struct file *filp) 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 usb_serial_port *wport;
struct omninet_data *od; struct omninet_data *od;
int result = 0; int result = 0;
dbg("%s - port %d", __FUNCTION__, port->number); 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 ); od = kmalloc( sizeof(struct omninet_data), GFP_KERNEL );
if( !od ) { if( !od ) {
err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data)); err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct omninet_data));
...@@ -186,21 +182,15 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp) ...@@ -186,21 +182,15 @@ static int omninet_open (struct usb_serial_port *port, struct file *filp)
static void omninet_close (struct usb_serial_port *port, struct file * filp) 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 usb_serial_port *wport;
struct omninet_data *od; struct omninet_data *od;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__); wport = serial->port[1];
if (!serial) usb_unlink_urb(wport->write_urb);
return; usb_unlink_urb(port->read_urb);
if (serial->dev) {
wport = serial->port[1];
usb_unlink_urb (wport->write_urb);
usb_unlink_urb (port->read_urb);
}
od = usb_get_serial_port_data(port); od = usb_get_serial_port_data(port);
if (od) if (od)
...@@ -215,8 +205,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp) ...@@ -215,8 +205,6 @@ static void omninet_close (struct usb_serial_port *port, struct file * filp)
static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_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 *data = urb->transfer_buffer;
struct omninet_header *header = (struct omninet_header *) &data[0]; struct omninet_header *header = (struct omninet_header *) &data[0];
...@@ -225,11 +213,6 @@ static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -225,11 +213,6 @@ static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
// dbg("omninet_read_bulk_callback"); // dbg("omninet_read_bulk_callback");
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -253,8 +236,8 @@ static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -253,8 +236,8 @@ static void omninet_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
} }
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb(urb, serial->dev, usb_fill_bulk_urb(urb, port->serial->dev,
usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
urb->transfer_buffer, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_buffer_length,
omninet_read_bulk_callback, port); omninet_read_bulk_callback, port);
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
......
...@@ -471,16 +471,11 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp) ...@@ -471,16 +471,11 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
static void pl2303_close (struct usb_serial_port *port, struct file *filp) static void pl2303_close (struct usb_serial_port *port, struct file *filp)
{ {
struct usb_serial *serial;
struct pl2303_private *priv; struct pl2303_private *priv;
unsigned long flags; unsigned long flags;
unsigned int c_cflag; unsigned int c_cflag;
int result; int result;
serial = get_usb_serial (port, __FUNCTION__);
if (!serial)
return;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
/* shutdown our urbs */ /* shutdown our urbs */
...@@ -657,7 +652,6 @@ static void pl2303_shutdown (struct usb_serial *serial) ...@@ -657,7 +652,6 @@ static void pl2303_shutdown (struct usb_serial *serial)
static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) 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_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 pl2303_private *priv = usb_get_serial_port_data(port);
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
unsigned long flags; unsigned long flags;
...@@ -681,9 +675,6 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -681,9 +675,6 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs)
goto exit; goto exit;
} }
if (!serial) {
return;
}
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer); usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
...@@ -708,7 +699,6 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) ...@@ -708,7 +699,6 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs)
static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_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 pl2303_private *priv = usb_get_serial_port_data(port);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
...@@ -720,11 +710,6 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -720,11 +710,6 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - urb->status = %d", __FUNCTION__, urb->status); dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
if (!port->open_count) { if (!port->open_count) {
...@@ -735,7 +720,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -735,7 +720,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
/* PL2303 mysteriously fails with -EPROTO reschedule the read */ /* PL2303 mysteriously fails with -EPROTO reschedule the read */
dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__);
urb->status = 0; urb->status = 0;
urb->dev = serial->dev; urb->dev = port->serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) if (result)
dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
...@@ -783,7 +768,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -783,7 +768,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
/* Schedule the next read _if_ we are still open */ /* Schedule the next read _if_ we are still open */
if (port->open_count) { if (port->open_count) {
urb->dev = serial->dev; urb->dev = port->serial->dev;
result = usb_submit_urb(urb, GFP_ATOMIC); result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) if (result)
dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result);
......
...@@ -211,7 +211,6 @@ static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs) ...@@ -211,7 +211,6 @@ static __u16 __inline__ fcs_compute10 (unsigned char *sp, int len, __u16 fcs)
static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_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 *data = urb->transfer_buffer;
unsigned char length = urb->actual_length; unsigned char length = urb->actual_length;
int i; int i;
...@@ -219,11 +218,6 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -219,11 +218,6 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
dbg ("%s", __FUNCTION__); dbg ("%s", __FUNCTION__);
if (!serial) {
dbg ("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg ("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg ("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -272,8 +266,8 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -272,8 +266,8 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
} }
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb (urb, serial->dev, usb_fill_bulk_urb (urb, port->serial->dev,
usb_rcvbulkpipe (serial->dev, port->bulk_in_endpointAddress), usb_rcvbulkpipe (port->serial->dev, port->bulk_in_endpointAddress),
urb->transfer_buffer, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_buffer_length,
safe_read_bulk_callback, port); safe_read_bulk_callback, port);
...@@ -284,7 +278,6 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -284,7 +278,6 @@ static void safe_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
static int safe_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count) 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; unsigned char *data;
int result; int result;
int i; int i;
...@@ -367,7 +360,7 @@ static int safe_write (struct usb_serial_port *port, int from_user, const unsign ...@@ -367,7 +360,7 @@ static int safe_write (struct usb_serial_port *port, int from_user, const unsign
printk ("\n"); printk ("\n");
} }
#endif #endif
port->write_urb->dev = serial->dev; port->write_urb->dev = port->serial->dev;
if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) { if ((result = usb_submit_urb (port->write_urb, GFP_KERNEL))) {
err ("%s - failed submitting write urb, error %d", __FUNCTION__, result); err ("%s - failed submitting write urb, error %d", __FUNCTION__, result);
return 0; return 0;
......
...@@ -492,10 +492,6 @@ static int serial_open (struct tty_struct *tty, struct file * filp) ...@@ -492,10 +492,6 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
static void serial_close(struct tty_struct *tty, struct file * filp) 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_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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -520,12 +516,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp) ...@@ -520,12 +516,8 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count) 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_port *port = (struct usb_serial_port *) tty->driver_data;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL; int retval = -EINVAL;
if (!serial)
return -ENODEV;
dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
if (!port->open_count) { if (!port->open_count) {
...@@ -534,7 +526,7 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned ...@@ -534,7 +526,7 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned
} }
/* pass on to the driver specific version of this function */ /* 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: exit:
return retval; return retval;
...@@ -543,12 +535,8 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned ...@@ -543,12 +535,8 @@ static int serial_write (struct tty_struct * tty, int from_user, const unsigned
static int serial_write_room (struct tty_struct *tty) static int serial_write_room (struct tty_struct *tty)
{ {
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL; int retval = -EINVAL;
if (!serial)
return -ENODEV;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!port->open_count) { if (!port->open_count) {
...@@ -557,7 +545,7 @@ static int serial_write_room (struct tty_struct *tty) ...@@ -557,7 +545,7 @@ static int serial_write_room (struct tty_struct *tty)
} }
/* pass on to the driver specific version of this function */ /* pass on to the driver specific version of this function */
retval = serial->type->write_room(port); retval = port->serial->type->write_room(port);
exit: exit:
return retval; return retval;
...@@ -566,12 +554,8 @@ static int serial_write_room (struct tty_struct *tty) ...@@ -566,12 +554,8 @@ static int serial_write_room (struct tty_struct *tty)
static int serial_chars_in_buffer (struct tty_struct *tty) 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_port *port = (struct usb_serial_port *) tty->driver_data;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -EINVAL; int retval = -EINVAL;
if (!serial)
return -ENODEV;
dbg("%s = port %d", __FUNCTION__, port->number); dbg("%s = port %d", __FUNCTION__, port->number);
if (!port->open_count) { if (!port->open_count) {
...@@ -580,7 +564,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty) ...@@ -580,7 +564,7 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
} }
/* pass on to the driver specific version of this function */ /* 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: exit:
return retval; return retval;
...@@ -589,10 +573,6 @@ static int serial_chars_in_buffer (struct tty_struct *tty) ...@@ -589,10 +573,6 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
static void serial_throttle (struct tty_struct * tty) static void serial_throttle (struct tty_struct * tty)
{ {
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; 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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -602,8 +582,8 @@ static void serial_throttle (struct tty_struct * tty) ...@@ -602,8 +582,8 @@ static void serial_throttle (struct tty_struct * tty)
} }
/* pass on to the driver specific version of this function */ /* pass on to the driver specific version of this function */
if (serial->type->throttle) if (port->serial->type->throttle)
serial->type->throttle(port); port->serial->type->throttle(port);
exit: exit:
; ;
...@@ -612,10 +592,6 @@ static void serial_throttle (struct tty_struct * tty) ...@@ -612,10 +592,6 @@ static void serial_throttle (struct tty_struct * tty)
static void serial_unthrottle (struct tty_struct * tty) static void serial_unthrottle (struct tty_struct * tty)
{ {
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; 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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -625,8 +601,8 @@ static void serial_unthrottle (struct tty_struct * tty) ...@@ -625,8 +601,8 @@ static void serial_unthrottle (struct tty_struct * tty)
} }
/* pass on to the driver specific version of this function */ /* pass on to the driver specific version of this function */
if (serial->type->unthrottle) if (port->serial->type->unthrottle)
serial->type->unthrottle(port); port->serial->type->unthrottle(port);
exit: exit:
; ;
...@@ -635,12 +611,8 @@ static void serial_unthrottle (struct tty_struct * tty) ...@@ -635,12 +611,8 @@ static void serial_unthrottle (struct tty_struct * tty)
static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg) 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_port *port = (struct usb_serial_port *) tty->driver_data;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int retval = -ENODEV; int retval = -ENODEV;
if (!serial)
return -ENODEV;
dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
if (!port->open_count) { if (!port->open_count) {
...@@ -649,8 +621,8 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in ...@@ -649,8 +621,8 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
} }
/* pass on to the driver specific version of this function if it is available */ /* pass on to the driver specific version of this function if it is available */
if (serial->type->ioctl) if (port->serial->type->ioctl)
retval = serial->type->ioctl(port, file, cmd, arg); retval = port->serial->type->ioctl(port, file, cmd, arg);
else else
retval = -ENOIOCTLCMD; retval = -ENOIOCTLCMD;
...@@ -661,10 +633,6 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in ...@@ -661,10 +633,6 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
static void serial_set_termios (struct tty_struct *tty, struct termios * old) 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_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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -674,8 +642,8 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old) ...@@ -674,8 +642,8 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old)
} }
/* pass on to the driver specific version of this function if it is available */ /* pass on to the driver specific version of this function if it is available */
if (serial->type->set_termios) if (port->serial->type->set_termios)
serial->type->set_termios(port, old); port->serial->type->set_termios(port, old);
exit: exit:
; ;
...@@ -684,10 +652,6 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old) ...@@ -684,10 +652,6 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old)
static void serial_break (struct tty_struct *tty, int break_state) 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_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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -697,8 +661,8 @@ static void serial_break (struct tty_struct *tty, int break_state) ...@@ -697,8 +661,8 @@ static void serial_break (struct tty_struct *tty, int break_state)
} }
/* pass on to the driver specific version of this function if it is available */ /* pass on to the driver specific version of this function if it is available */
if (serial->type->break_ctl) if (port->serial->type->break_ctl)
serial->type->break_ctl(port, break_state); port->serial->type->break_ctl(port, break_state);
exit: exit:
; ;
...@@ -757,10 +721,6 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int ...@@ -757,10 +721,6 @@ static int serial_read_proc (char *page, char **start, off_t off, int count, int
static int serial_tiocmget (struct tty_struct *tty, struct file *file) 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_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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -769,8 +729,8 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) ...@@ -769,8 +729,8 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
goto exit; goto exit;
} }
if (serial->type->tiocmget) if (port->serial->type->tiocmget)
return serial->type->tiocmget(port, file); return port->serial->type->tiocmget(port, file);
exit: exit:
return -EINVAL; return -EINVAL;
...@@ -780,10 +740,6 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, ...@@ -780,10 +740,6 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; 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); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -792,8 +748,8 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, ...@@ -792,8 +748,8 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
goto exit; goto exit;
} }
if (serial->type->tiocmset) if (port->serial->type->tiocmset)
return serial->type->tiocmset(port, file, set, clear); return port->serial->type->tiocmset(port, file, set, clear);
exit: exit:
return -EINVAL; return -EINVAL;
...@@ -802,7 +758,6 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, ...@@ -802,7 +758,6 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
void usb_serial_port_softint(void *private) void usb_serial_port_softint(void *private)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)private; struct usb_serial_port *port = (struct usb_serial_port *)private;
struct usb_serial *serial;
struct tty_struct *tty; struct tty_struct *tty;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
...@@ -810,10 +765,6 @@ void usb_serial_port_softint(void *private) ...@@ -810,10 +765,6 @@ void usb_serial_port_softint(void *private)
if (!port) if (!port)
return; return;
serial = get_usb_serial (port, __FUNCTION__);
if (!serial)
return;
tty = port->tty; tty = port->tty;
if (!tty) if (!tty)
return; return;
......
...@@ -294,19 +294,6 @@ extern struct usb_serial_device_type usb_serial_generic_device; ...@@ -294,19 +294,6 @@ extern struct usb_serial_device_type usb_serial_generic_device;
extern struct bus_type usb_serial_bus_type; extern struct bus_type usb_serial_bus_type;
extern struct tty_driver *usb_serial_tty_driver; 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) static inline void usb_serial_debug_data (const char *file, const char *function, int size, const unsigned char *data)
{ {
int i; int i;
......
...@@ -443,15 +443,10 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) ...@@ -443,15 +443,10 @@ static int visor_open (struct usb_serial_port *port, struct file *filp)
static void visor_close (struct usb_serial_port *port, struct file * filp) static void visor_close (struct usb_serial_port *port, struct file * filp)
{ {
struct usb_serial *serial;
unsigned char *transfer_buffer; unsigned char *transfer_buffer;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
serial = get_usb_serial (port, __FUNCTION__);
if (!serial)
return;
/* shutdown our urbs */ /* shutdown our urbs */
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
if (port->interrupt_in_urb) if (port->interrupt_in_urb)
...@@ -460,8 +455,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp) ...@@ -460,8 +455,8 @@ static void visor_close (struct usb_serial_port *port, struct file * filp)
/* Try to send shutdown message, if the device is gone, this will just fail. */ /* Try to send shutdown message, if the device is gone, this will just fail. */
transfer_buffer = kmalloc (0x12, GFP_KERNEL); transfer_buffer = kmalloc (0x12, GFP_KERNEL);
if (transfer_buffer) { if (transfer_buffer) {
usb_control_msg (serial->dev, usb_control_msg (port->serial->dev,
usb_rcvctrlpipe(serial->dev, 0), usb_rcvctrlpipe(port->serial->dev, 0),
VISOR_CLOSE_NOTIFICATION, 0xc2, VISOR_CLOSE_NOTIFICATION, 0xc2,
0x0000, 0x0000, 0x0000, 0x0000,
transfer_buffer, 0x12, 300); transfer_buffer, 0x12, 300);
...@@ -578,7 +573,6 @@ static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -578,7 +573,6 @@ static void visor_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty; struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int i; int i;
...@@ -586,11 +580,6 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -586,11 +580,6 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return; return;
...@@ -613,9 +602,9 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs) ...@@ -613,9 +602,9 @@ static void visor_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
bytes_in += urb->actual_length; bytes_in += urb->actual_length;
/* Continue trying to always read */ /* Continue trying to always read */
usb_fill_bulk_urb (port->read_urb, serial->dev, usb_fill_bulk_urb (port->read_urb, port->serial->dev,
usb_rcvbulkpipe (serial->dev, usb_rcvbulkpipe(port->serial->dev,
port->bulk_in_endpointAddress), port->bulk_in_endpointAddress),
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer,
port->read_urb->transfer_buffer_length, port->read_urb->transfer_buffer_length,
visor_read_bulk_callback, port); visor_read_bulk_callback, port);
......
...@@ -984,7 +984,6 @@ static void command_port_write_callback (struct urb *urb, struct pt_regs *regs) ...@@ -984,7 +984,6 @@ static void command_port_write_callback (struct urb *urb, struct pt_regs *regs)
static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) 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_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; struct whiteheat_command_private *command_info;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
int result; int result;
...@@ -997,11 +996,6 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) ...@@ -997,11 +996,6 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
return; return;
} }
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
command_info = usb_get_serial_port_data(command_port); command_info = usb_get_serial_port_data(command_port);
...@@ -1029,7 +1023,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) ...@@ -1029,7 +1023,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
} }
/* Continue trying to always read */ /* 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); result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
spin_unlock_irqrestore(&command_info->lock, flags); spin_unlock_irqrestore(&command_info->lock, flags);
if (result) if (result)
...@@ -1040,7 +1034,6 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs) ...@@ -1040,7 +1034,6 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) 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_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
unsigned char *data = urb->transfer_buffer; unsigned char *data = urb->transfer_buffer;
struct whiteheat_private *info = usb_get_serial_port_data(port); struct whiteheat_private *info = usb_get_serial_port_data(port);
...@@ -1057,14 +1050,6 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1057,14 +1050,6 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs)
list_del(&wrap->list); list_del(&wrap->list);
spin_unlock(&info->lock); 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) { if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
spin_lock(&info->lock); spin_lock(&info->lock);
...@@ -1091,7 +1076,6 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1091,7 +1076,6 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs)
static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) 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_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_private *info = usb_get_serial_port_data(port);
struct whiteheat_urb_wrap *wrap; struct whiteheat_urb_wrap *wrap;
...@@ -1108,11 +1092,6 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs) ...@@ -1108,11 +1092,6 @@ static void whiteheat_write_callback(struct urb *urb, struct pt_regs *regs)
list_add(&wrap->list, &info->tx_urbs_free); list_add(&wrap->list, &info->tx_urbs_free);
spin_unlock(&info->lock); spin_unlock(&info->lock);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
}
if (urb->status) { if (urb->status) {
dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment