diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2016-04-09 20:53:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-04-30 12:26:55 -0400 |
commit | 807c8d81f4ec441241cafa3034c58df721fee869 (patch) | |
tree | 83402ad7f36b135d15d1aa6686ff26aa186b3dec /net/irda | |
parent | 5604a98e2f95d6221852960a3363588f40d78e22 (diff) |
tty: Replace ASYNC_NORMAL_ACTIVE bit and update atomically
Replace ASYNC_NORMAL_ACTIVE bit in the tty_port::flags field with
TTY_PORT_ACTIVE bit in the tty_port::iflags field. Introduce helpers
tty_port_set_active() and tty_port_active() to abstract atomic bit ops.
Extract state changes from port lock sections, as this usage is
broken and confused; the state transitions are protected by the
tty lock (which mutually excludes parallel open/close/hangup),
and no user tests the active state while holding the port lock.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/irda')
-rw-r--r-- | net/irda/ircomm/ircomm_tty.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 840b82f760ba..681fe0bfe558 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c | |||
@@ -281,7 +281,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
281 | * then make the check up front and then exit. | 281 | * then make the check up front and then exit. |
282 | */ | 282 | */ |
283 | if (tty_io_error(tty)) { | 283 | if (tty_io_error(tty)) { |
284 | port->flags |= ASYNC_NORMAL_ACTIVE; | 284 | tty_port_set_active(port, 1); |
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
@@ -289,7 +289,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
289 | /* nonblock mode is set */ | 289 | /* nonblock mode is set */ |
290 | if (C_BAUD(tty)) | 290 | if (C_BAUD(tty)) |
291 | tty_port_raise_dtr_rts(port); | 291 | tty_port_raise_dtr_rts(port); |
292 | port->flags |= ASYNC_NORMAL_ACTIVE; | 292 | tty_port_set_active(port, 1); |
293 | pr_debug("%s(), O_NONBLOCK requested!\n", __func__); | 293 | pr_debug("%s(), O_NONBLOCK requested!\n", __func__); |
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
@@ -365,7 +365,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, | |||
365 | __FILE__, __LINE__, tty->driver->name, port->count); | 365 | __FILE__, __LINE__, tty->driver->name, port->count); |
366 | 366 | ||
367 | if (!retval) | 367 | if (!retval) |
368 | port->flags |= ASYNC_NORMAL_ACTIVE; | 368 | tty_port_set_active(port, 1); |
369 | 369 | ||
370 | return retval; | 370 | return retval; |
371 | } | 371 | } |
@@ -925,7 +925,6 @@ static void ircomm_tty_hangup(struct tty_struct *tty) | |||
925 | ircomm_tty_shutdown(self); | 925 | ircomm_tty_shutdown(self); |
926 | 926 | ||
927 | spin_lock_irqsave(&port->lock, flags); | 927 | spin_lock_irqsave(&port->lock, flags); |
928 | port->flags &= ~ASYNC_NORMAL_ACTIVE; | ||
929 | if (port->tty) { | 928 | if (port->tty) { |
930 | set_bit(TTY_IO_ERROR, &port->tty->flags); | 929 | set_bit(TTY_IO_ERROR, &port->tty->flags); |
931 | tty_kref_put(port->tty); | 930 | tty_kref_put(port->tty); |
@@ -933,6 +932,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty) | |||
933 | port->tty = NULL; | 932 | port->tty = NULL; |
934 | port->count = 0; | 933 | port->count = 0; |
935 | spin_unlock_irqrestore(&port->lock, flags); | 934 | spin_unlock_irqrestore(&port->lock, flags); |
935 | tty_port_set_active(port, 0); | ||
936 | 936 | ||
937 | wake_up_interruptible(&port->open_wait); | 937 | wake_up_interruptible(&port->open_wait); |
938 | } | 938 | } |
@@ -1267,7 +1267,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m) | |||
1267 | seq_printf(m, "%cASYNC_LOW_LATENCY", sep); | 1267 | seq_printf(m, "%cASYNC_LOW_LATENCY", sep); |
1268 | sep = '|'; | 1268 | sep = '|'; |
1269 | } | 1269 | } |
1270 | if (self->port.flags & ASYNC_NORMAL_ACTIVE) { | 1270 | if (tty_port_active(&self->port)) { |
1271 | seq_printf(m, "%cASYNC_NORMAL_ACTIVE", sep); | 1271 | seq_printf(m, "%cASYNC_NORMAL_ACTIVE", sep); |
1272 | sep = '|'; | 1272 | sep = '|'; |
1273 | } | 1273 | } |