Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 188751
b: refs/heads/master
c: eb8878a
h: refs/heads/master
i:
  188749: b2a43d4
  188747: 320fa94
  188743: c4faea3
  188735: dec4c42
v: v3
  • Loading branch information
Johan Hovold authored and Greg Kroah-Hartman committed Mar 19, 2010
1 parent d3fc0a0 commit f425ad8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 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: 6313620228624ff4dcb78b1dbd459d0c208df126
refs/heads/master: eb8878a881c306ff3eab6e741ab8fc94096f4e1a
30 changes: 19 additions & 11 deletions trunk/drivers/usb/serial/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int usb_serial_generic_open(struct tty_struct *tty, struct usb_serial_port *port
spin_unlock_irqrestore(&port->lock, flags);

/* if we have a bulk endpoint, start reading from it */
if (serial->num_bulk_in) {
if (port->bulk_in_size) {
/* Start reading from the device */
usb_fill_bulk_urb(port->read_urb, serial->dev,
usb_rcvbulkpipe(serial->dev,
Expand Down Expand Up @@ -159,10 +159,10 @@ static void generic_cleanup(struct usb_serial_port *port)
dbg("%s - port %d", __func__, port->number);

if (serial->dev) {
/* shutdown any bulk reads that might be going on */
if (serial->num_bulk_out)
/* shutdown any bulk transfers that might be going on */
if (port->bulk_out_size)
usb_kill_urb(port->write_urb);
if (serial->num_bulk_in)
if (port->bulk_in_size)
usb_kill_urb(port->read_urb);
}
}
Expand Down Expand Up @@ -333,15 +333,15 @@ int usb_serial_generic_write(struct tty_struct *tty,

dbg("%s - port %d", __func__, port->number);

/* only do something if we have a bulk out endpoint */
if (!port->bulk_out_size)
return -ENODEV;

if (count == 0) {
dbg("%s - write request of 0 bytes", __func__);
return 0;
}

/* only do something if we have a bulk out endpoint */
if (!serial->num_bulk_out)
return 0;

if (serial->type->max_in_flight_urbs)
return usb_serial_multi_urb_write(tty, port,
buf, count);
Expand All @@ -364,14 +364,19 @@ int usb_serial_generic_write_room(struct tty_struct *tty)
int room = 0;

dbg("%s - port %d", __func__, port->number);

if (!port->bulk_out_size)
return 0;

spin_lock_irqsave(&port->lock, flags);
if (serial->type->max_in_flight_urbs) {
if (port->urbs_in_flight < serial->type->max_in_flight_urbs)
room = port->bulk_out_size *
(serial->type->max_in_flight_urbs -
port->urbs_in_flight);
} else if (serial->num_bulk_out)
} else {
room = kfifo_avail(&port->write_fifo);
}
spin_unlock_irqrestore(&port->lock, flags);

dbg("%s - returns %d", __func__, room);
Expand All @@ -382,15 +387,18 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty)
{
struct usb_serial_port *port = tty->driver_data;
struct usb_serial *serial = port->serial;
int chars = 0;
unsigned long flags;
int chars;

dbg("%s - port %d", __func__, port->number);

if (!port->bulk_out_size)
return 0;

spin_lock_irqsave(&port->lock, flags);
if (serial->type->max_in_flight_urbs)
chars = port->tx_bytes_flight;
else if (serial->num_bulk_out)
else
chars = kfifo_len(&port->write_fifo);
spin_unlock_irqrestore(&port->lock, flags);

Expand Down

0 comments on commit f425ad8

Please sign in to comment.