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 <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
80f02d5424
commit
d41861ca19
@@ -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) {
|
||||
|
Reference in New Issue
Block a user