Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 289668
b: refs/heads/master
c: 5db51b5
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Mar 8, 2012
1 parent 0ab2a06 commit 6d03f6c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8111e4ecf9373f6d76504416b0e76b18372f3598
refs/heads/master: 5db51b50c10f3bf56d5c636832c5556ead90562d
78 changes: 44 additions & 34 deletions trunk/drivers/usb/serial/metro-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void metrousb_read_int_callback(struct urb *urb)
int result = 0;
unsigned long flags = 0;

dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(&port->dev, "%s\n", __func__);

switch (urb->status) {
case 0:
Expand All @@ -76,20 +76,23 @@ static void metrousb_read_int_callback(struct urb *urb)
case -ENOENT:
case -ESHUTDOWN:
/* urb has been terminated. */
dbg("METRO-USB - %s - urb shutting down, port number=%d, error code=%d",
__FUNCTION__, port->number, result);
dev_dbg(&port->dev,
"%s - urb shutting down, error code=%d\n",
__func__, result);
return;
default:
dbg("METRO-USB - %s - non-zero urb received, port number=%d, error code=%d",
__FUNCTION__, port->number, result);
dev_dbg(&port->dev,
"%s - non-zero urb received, error code=%d\n",
__func__, result);
goto exit;
}


/* Set the data read from the usb port into the serial port buffer. */
tty = tty_port_tty_get(&port->port);
if (!tty) {
dbg("%s - bad tty pointer - exiting", __func__);
dev_dbg(&port->dev, "%s - bad tty pointer - exiting\n",
__func__);
return;
}

Expand Down Expand Up @@ -117,25 +120,25 @@ static void metrousb_read_int_callback(struct urb *urb)

result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);

if (result) {
dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
__FUNCTION__, port->number, result);
}
if (result)
dev_dbg(&port->dev,
"%s - failed submitting interrupt in urb, error code=%d\n",
__func__, result);
}
return;

exit:
/* Try to resubmit the urb. */
result = usb_submit_urb(urb, GFP_ATOMIC);
if (result) {
dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
__FUNCTION__, port->number, result);
}
if (result)
dev_dbg(&port->dev,
"%s - failed submitting interrupt in urb, error code=%d\n",
__func__, result);
}

static void metrousb_cleanup(struct usb_serial_port *port)
{
dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(&port->dev, "%s\n", __func__);

if (port->serial->dev) {
/* Shutdown any interrupt in urbs. */
Expand All @@ -153,11 +156,12 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
unsigned long flags = 0;
int result = 0;

dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(&port->dev, "%s\n", __func__);

/* Make sure the urb is initialized. */
if (!port->interrupt_in_urb) {
dbg("METRO-USB - %s - interrupt urb not initialized for port number=%d", __FUNCTION__, port->number);
dev_dbg(&port->dev, "%s - interrupt urb not initialized\n",
__func__);
return -ENODEV;
}

Expand Down Expand Up @@ -187,12 +191,13 @@ static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);

if (result) {
dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d"
, __FUNCTION__, port->number, result);
dev_dbg(&port->dev,
"%s - failed submitting interrupt in urb, error code=%d\n",
__func__, result);
goto exit;
}

dbg("METRO-USB - %s - port open for port number=%d", __FUNCTION__, port->number);
dev_dbg(&port->dev, "%s - port open\n", __func__);
exit:
return result;
}
Expand All @@ -202,7 +207,8 @@ static int metrousb_set_modem_ctrl(struct usb_serial *serial, unsigned int contr
int retval = 0;
unsigned char mcr = METROUSB_MCR_NONE;

dbg("METRO-USB - %s - control state=%d", __FUNCTION__, control_state);
dev_dbg(&serial->dev->dev, "%s - control state = %d\n",
__func__, control_state);

/* Set the modem control value. */
if (control_state & TIOCM_DTR)
Expand All @@ -215,7 +221,9 @@ static int metrousb_set_modem_ctrl(struct usb_serial *serial, unsigned int contr
METROUSB_SET_REQUEST_TYPE, METROUSB_SET_MODEM_CTRL_REQUEST,
control_state, 0, NULL, 0, WDR_TIMEOUT);
if (retval < 0)
dbg("METRO-USB - %s - set modem ctrl=0x%x failed, error code=%d", __FUNCTION__, mcr, retval);
dev_dbg(&serial->dev->dev,
"%s - set modem ctrl=0x%x failed, error code=%d\n",
__func__, mcr, retval);

return retval;
}
Expand All @@ -224,7 +232,7 @@ static void metrousb_shutdown(struct usb_serial *serial)
{
int i = 0;

dbg("METRO-USB - %s", __FUNCTION__);
dev_dbg(&serial->dev->dev, "%s\n", __func__);

/* Stop reading and writing on all ports. */
for (i = 0; i < serial->num_ports; ++i) {
Expand All @@ -235,7 +243,8 @@ static void metrousb_shutdown(struct usb_serial *serial)
kfree(usb_get_serial_port_data(serial->port[i]));
usb_set_serial_port_data(serial->port[i], NULL);

dbg("METRO-USB - %s - freed port number=%d", __FUNCTION__, serial->port[i]->number);
dev_dbg(&serial->dev->dev, "%s - freed port number=%d\n",
__func__, serial->port[i]->number);
}
}

Expand All @@ -245,7 +254,7 @@ static int metrousb_startup(struct usb_serial *serial)
struct usb_serial_port *port;
int i = 0;

dbg("METRO-USB - %s", __FUNCTION__);
dev_dbg(&serial->dev->dev, "%s\n", __func__);

/* Loop through the serial ports setting up the private structures.
* Currently we only use one port. */
Expand All @@ -261,7 +270,8 @@ static int metrousb_startup(struct usb_serial *serial)
spin_lock_init(&metro_priv->lock);
usb_set_serial_port_data(port, metro_priv);

dbg("METRO-USB - %s - port number=%d.", __FUNCTION__, port->number);
dev_dbg(&serial->dev->dev, "%s - port number=%d\n ",
__func__, port->number);
}

return 0;
Expand All @@ -273,7 +283,7 @@ static void metrousb_throttle(struct tty_struct *tty)
struct metrousb_private *metro_priv = usb_get_serial_port_data(port);
unsigned long flags = 0;

dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(tty->dev, "%s\n", __func__);

/* Set the private information for the port to stop reading data. */
spin_lock_irqsave(&metro_priv->lock, flags);
Expand All @@ -288,7 +298,7 @@ static int metrousb_tiocmget(struct tty_struct *tty)
struct metrousb_private *metro_priv = usb_get_serial_port_data(port);
unsigned long flags = 0;

dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(tty->dev, "%s\n", __func__);

spin_lock_irqsave(&metro_priv->lock, flags);
control_state = metro_priv->control_state;
Expand All @@ -306,7 +316,7 @@ static int metrousb_tiocmset(struct tty_struct *tty,
unsigned long flags = 0;
unsigned long control_state = 0;

dbg("METRO-USB - %s - port number=%d, set=%d, clear=%d", __FUNCTION__, port->number, set, clear);
dev_dbg(tty->dev, "%s - set=%d, clear=%d\n", __func__, set, clear);

spin_lock_irqsave(&metro_priv->lock, flags);
control_state = metro_priv->control_state;
Expand All @@ -333,7 +343,7 @@ static void metrousb_unthrottle(struct tty_struct *tty)
unsigned long flags = 0;
int result = 0;

dbg("METRO-USB - %s - port number=%d", __FUNCTION__, port->number);
dev_dbg(tty->dev, "%s\n", __func__);

/* Set the private information for the port to resume reading data. */
spin_lock_irqsave(&metro_priv->lock, flags);
Expand All @@ -343,10 +353,10 @@ static void metrousb_unthrottle(struct tty_struct *tty)
/* Submit the urb to read from the port. */
port->interrupt_in_urb->dev = port->serial->dev;
result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
if (result) {
dbg("METRO-USB - %s - failed submitting interrupt in urb for port number=%d, error code=%d",
__FUNCTION__, port->number, result);
}
if (result)
dev_dbg(tty->dev,
"failed submitting interrupt in urb error code=%d\n",
result);
}

static struct usb_driver metrousb_driver = {
Expand Down

0 comments on commit 6d03f6c

Please sign in to comment.