Skip to content

Commit 95da310

Browse files
Alan Coxtorvalds
authored andcommitted
usb_serial: API all change
USB serial likes to use port->tty back pointers for the real work it does and to do so without any actual locking. Unfortunately when you consider hangup events, hangup/parallel reopen or even worse hangup followed by parallel close events the tty->port and port->tty pointers are not guaranteed to be the same as port->tty is the active tty while tty->port is the port the tty may or may not still be attached to. So rework the entire API to pass the tty struct. For console cases we need to pass both for now. This shows up multiple drivers that immediately crash with USB console some of which have been fixed in the process. Longer term we need a proper tty as console abstraction Signed-off-by: Alan Cox <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 1aa3692 commit 95da310

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1820
-1720
lines changed

drivers/usb/serial/aircable.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static void aircable_read(struct work_struct *work)
272272
* 64 bytes, to ensure I do not get throttled.
273273
* Ask USB mailing list for better aproach.
274274
*/
275-
tty = port->tty;
275+
tty = port->port.tty;
276276

277277
if (!tty) {
278278
schedule_work(&priv->rx_work);
@@ -378,13 +378,14 @@ static void aircable_shutdown(struct usb_serial *serial)
378378
}
379379
}
380380

381-
static int aircable_write_room(struct usb_serial_port *port)
381+
static int aircable_write_room(struct tty_struct *tty)
382382
{
383+
struct usb_serial_port *port = tty->driver_data;
383384
struct aircable_private *priv = usb_get_serial_port_data(port);
384385
return serial_buf_data_avail(priv->tx_buf);
385386
}
386387

387-
static int aircable_write(struct usb_serial_port *port,
388+
static int aircable_write(struct tty_struct *tty, struct usb_serial_port *port,
388389
const unsigned char *source, int count)
389390
{
390391
struct aircable_private *priv = usb_get_serial_port_data(port);
@@ -466,7 +467,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
466467

467468
if (status) {
468469
dbg("%s - urb status = %d", __func__, status);
469-
if (!port->open_count) {
470+
if (!port->port.count) {
470471
dbg("%s - port is closed, exiting.", __func__);
471472
return;
472473
}
@@ -494,7 +495,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
494495
usb_serial_debug_data(debug, &port->dev, __func__,
495496
urb->actual_length, urb->transfer_buffer);
496497

497-
tty = port->tty;
498+
tty = port->port.tty;
498499
if (tty && urb->actual_length) {
499500
if (urb->actual_length <= 2) {
500501
/* This is an incomplete package */
@@ -528,7 +529,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
528529
}
529530

530531
/* Schedule the next read _if_ we are still open */
531-
if (port->open_count) {
532+
if (port->port.count) {
532533
usb_fill_bulk_urb(port->read_urb, port->serial->dev,
533534
usb_rcvbulkpipe(port->serial->dev,
534535
port->bulk_in_endpointAddress),
@@ -547,8 +548,9 @@ static void aircable_read_bulk_callback(struct urb *urb)
547548
}
548549

549550
/* Based on ftdi_sio.c throttle */
550-
static void aircable_throttle(struct usb_serial_port *port)
551+
static void aircable_throttle(struct tty_struct *tty)
551552
{
553+
struct usb_serial_port *port = tty->driver_data;
552554
struct aircable_private *priv = usb_get_serial_port_data(port);
553555
unsigned long flags;
554556

@@ -560,8 +562,9 @@ static void aircable_throttle(struct usb_serial_port *port)
560562
}
561563

562564
/* Based on ftdi_sio.c unthrottle */
563-
static void aircable_unthrottle(struct usb_serial_port *port)
565+
static void aircable_unthrottle(struct tty_struct *tty)
564566
{
567+
struct usb_serial_port *port = tty->driver_data;
565568
struct aircable_private *priv = usb_get_serial_port_data(port);
566569
int actually_throttled;
567570
unsigned long flags;

0 commit comments

Comments
 (0)