mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
tty: Replace ASYNC_INITIALIZED bit and update atomically
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers tty_port_set_initialized() and tty_port_initialized() to abstract atomic bit ops. Note: the transforms for test_and_set_bit() and test_and_clear_bit() are unnecessary as the state transitions are already mutually exclusive; the tty lock prevents concurrent open/close/hangup. Signed-off-by: Peter Hurley <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
80f02d5424
commit
d41861ca19
27 changed files with 157 additions and 150 deletions
|
|
@ -1680,7 +1680,7 @@ static int acm_resume(struct usb_interface *intf)
|
|||
if (--acm->susp_count)
|
||||
goto out;
|
||||
|
||||
if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags)) {
|
||||
if (tty_port_initialized(&acm->port)) {
|
||||
rv = usb_submit_urb(acm->ctrlurb, GFP_ATOMIC);
|
||||
|
||||
for (;;) {
|
||||
|
|
@ -1710,7 +1710,7 @@ static int acm_reset_resume(struct usb_interface *intf)
|
|||
{
|
||||
struct acm *acm = usb_get_intfdata(intf);
|
||||
|
||||
if (test_bit(ASYNCB_INITIALIZED, &acm->port.flags))
|
||||
if (tty_port_initialized(&acm->port))
|
||||
tty_port_tty_hangup(&acm->port, false);
|
||||
|
||||
return acm_resume(intf);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ static int usb_console_setup(struct console *co, char *options)
|
|||
info->port = port;
|
||||
|
||||
++port->port.count;
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
|
||||
if (!tty_port_initialized(&port->port)) {
|
||||
if (serial->type->set_termios) {
|
||||
/*
|
||||
* allocate a fake tty so the driver can initialize
|
||||
|
|
@ -168,7 +168,7 @@ static int usb_console_setup(struct console *co, char *options)
|
|||
tty_port_tty_set(&port->port, NULL);
|
||||
tty_kref_put(tty);
|
||||
}
|
||||
set_bit(ASYNCB_INITIALIZED, &port->port.flags);
|
||||
tty_port_set_initialized(&port->port, 1);
|
||||
}
|
||||
/* Now that any required fake tty operations are completed restore
|
||||
* the tty port count */
|
||||
|
|
|
|||
|
|
@ -473,7 +473,7 @@ static bool usb_serial_generic_msr_changed(struct tty_struct *tty,
|
|||
* Use tty-port initialised flag to detect all hangups including the
|
||||
* one generated at USB-device disconnect.
|
||||
*/
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!tty_port_initialized(&port->port))
|
||||
return true;
|
||||
|
||||
spin_lock_irqsave(&port->lock, flags);
|
||||
|
|
@ -503,7 +503,7 @@ int usb_serial_generic_tiocmiwait(struct tty_struct *tty, unsigned long arg)
|
|||
|
||||
ret = wait_event_interruptible(port->port.delta_msr_wait,
|
||||
usb_serial_generic_msr_changed(tty, arg, &cnow));
|
||||
if (!ret && !test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!ret && !tty_port_initialized(&port->port))
|
||||
ret = -EIO;
|
||||
|
||||
return ret;
|
||||
|
|
@ -606,7 +606,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)
|
|||
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port = serial->port[i];
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!tty_port_initialized(&port->port))
|
||||
continue;
|
||||
|
||||
if (port->bulk_in_size) {
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ static void mxuport_process_read_urb_demux_data(struct urb *urb)
|
|||
return;
|
||||
}
|
||||
|
||||
if (test_bit(ASYNCB_INITIALIZED, &demux_port->port.flags)) {
|
||||
if (tty_port_initialized(&demux_port->port)) {
|
||||
ch = data + HEADER_SIZE;
|
||||
mxuport_process_read_urb_data(demux_port, ch, rcv_len);
|
||||
} else {
|
||||
|
|
@ -544,7 +544,7 @@ static void mxuport_process_read_urb_demux_event(struct urb *urb)
|
|||
}
|
||||
|
||||
demux_port = serial->port[rcv_port];
|
||||
if (test_bit(ASYNCB_INITIALIZED, &demux_port->port.flags)) {
|
||||
if (tty_port_initialized(&demux_port->port)) {
|
||||
ch = data + HEADER_SIZE;
|
||||
rcv_event = get_unaligned_be16(data + 2);
|
||||
mxuport_process_read_urb_event(demux_port, ch,
|
||||
|
|
@ -1339,7 +1339,7 @@ static int mxuport_resume(struct usb_serial *serial)
|
|||
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port = serial->port[i];
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!tty_port_initialized(&port->port))
|
||||
continue;
|
||||
|
||||
r = usb_serial_generic_write_start(port, GFP_NOIO);
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ static void sierra_close(struct usb_serial_port *port)
|
|||
|
||||
/*
|
||||
* Need to take susp_lock to make sure port is not already being
|
||||
* resumed, but no need to hold it due to ASYNC_INITIALIZED.
|
||||
* resumed, but no need to hold it due to initialized
|
||||
*/
|
||||
spin_lock_irq(&intfdata->susp_lock);
|
||||
if (--intfdata->open_ports == 0)
|
||||
|
|
@ -1039,7 +1039,7 @@ static int sierra_resume(struct usb_serial *serial)
|
|||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port = serial->port[i];
|
||||
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!tty_port_initialized(&port->port))
|
||||
continue;
|
||||
|
||||
err = sierra_submit_delayed_urbs(port);
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
|
|||
*
|
||||
* Shut down a USB serial port. Serialized against activate by the
|
||||
* tport mutex and kept to matching open/close pairs
|
||||
* of calls by the ASYNCB_INITIALIZED flag.
|
||||
* of calls by the initialized flag.
|
||||
*
|
||||
* Not called if tty is console.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ void usb_wwan_close(struct usb_serial_port *port)
|
|||
|
||||
/*
|
||||
* Need to take susp_lock to make sure port is not already being
|
||||
* resumed, but no need to hold it due to ASYNC_INITIALIZED.
|
||||
* resumed, but no need to hold it due to initialized
|
||||
*/
|
||||
spin_lock_irq(&intfdata->susp_lock);
|
||||
if (--intfdata->open_ports == 0)
|
||||
|
|
@ -682,7 +682,7 @@ int usb_wwan_resume(struct usb_serial *serial)
|
|||
for (i = 0; i < serial->num_ports; i++) {
|
||||
port = serial->port[i];
|
||||
|
||||
if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
|
||||
if (!tty_port_initialized(&port->port))
|
||||
continue;
|
||||
|
||||
portdata = usb_get_serial_port_data(port);
|
||||
|
|
|
|||
Loading…
Reference in a new issue