From: Alan Cox <alan@linux.intel.com>
To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
arnd@arndb.de
Subject: [PATCH 20/20] serial: Use block_til_ready helper
Date: Wed, 05 May 2010 11:03:33 +0100 [thread overview]
Message-ID: <20100505100332.3595.32453.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100505100144.3595.65633.stgit@localhost.localdomain>
Our code now rather closely resembles the helper, so switch to it.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/serial/serial_core.c | 87 ------------------------------------------
1 files changed, 1 insertions(+), 86 deletions(-)
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 0603e0d..a55751a 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1526,91 +1526,6 @@ static void uart_dtr_rts(struct tty_port *port, int onoff)
uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
}
-/*
- * Block the open until the port is ready. We must be called with
- * the per-port semaphore held.
- */
-static int
-uart_block_til_ready(struct file *filp, struct uart_state *state)
-{
- DECLARE_WAITQUEUE(wait, current);
- struct tty_port *port = &state->port;
- unsigned long flags;
-
- spin_lock_irqsave(&port->lock, flags);
- if (!tty_hung_up_p(filp))
- port->count--;
- port->blocked_open++;
- spin_unlock_irqrestore(&port->lock, flags);
-
- add_wait_queue(&port->open_wait, &wait);
- while (1) {
- set_current_state(TASK_INTERRUPTIBLE);
-
- /*
- * If we have been hung up, tell userspace/restart open.
- */
- if (tty_hung_up_p(filp) || port->tty == NULL)
- break;
-
- /*
- * If the port has been closed, tell userspace/restart open.
- */
- if (!(port->flags & ASYNC_INITIALIZED))
- break;
-
- /*
- * If non-blocking mode is set, or CLOCAL mode is set,
- * we don't want to wait for the modem status lines to
- * indicate that the port is ready.
- *
- * Also, if the port is not enabled/configured, we want
- * to allow the open to succeed here. Note that we will
- * have set TTY_IO_ERROR for a non-existant port.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (port->tty->termios->c_cflag & CLOCAL) ||
- (port->tty->flags & (1 << TTY_IO_ERROR)))
- break;
-
- /*
- * Set DTR to allow modem to know we're waiting. Do
- * not set RTS here - we want to make sure we catch
- * the data from the modem.
- */
- if (port->tty->termios->c_cflag & CBAUD)
- tty_port_raise_dtr_rts(port);
-
- /*
- * and wait for the carrier to indicate that the
- * modem is ready for us.
- */
- if (tty_port_carrier_raised(port))
- break;
-
- schedule();
-
- if (signal_pending(current))
- break;
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&port->open_wait, &wait);
-
- spin_lock_irqsave(&port->lock, flags);
- if (!tty_hung_up_p(filp))
- port->count++;
- port->blocked_open--;
- spin_unlock_irqrestore(&port->lock, flags);
-
- if (signal_pending(current))
- return -ERESTARTSYS;
-
- if (!port->tty || tty_hung_up_p(filp))
- return -EAGAIN;
-
- return 0;
-}
-
static struct uart_state *uart_get(struct uart_driver *drv, int line)
{
struct uart_state *state;
@@ -1719,7 +1634,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
*/
mutex_unlock(&port->mutex);
if (retval == 0)
- retval = uart_block_til_ready(filp, state);
+ retval = tty_port_block_til_ready(port, tty, filp);
/*
* If this is the first open to succeed, adjust things to suit.
prev parent reply other threads:[~2010-05-05 10:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 10:01 [PATCH 01/20] stallion: prune lock_kernel calls Alan Cox
2010-05-05 10:01 ` [PATCH 02/20] istallion: use bit ops for the board flags Alan Cox
2010-05-05 10:01 ` [PATCH 03/20] riscom8: kill use of lock_kernel Alan Cox
2010-05-05 10:02 ` [PATCH 04/20] isicom: kill off the BKL Alan Cox
2010-05-05 10:02 ` [PATCH 05/20] rocket: kill BKL Alan Cox
2010-05-05 10:02 ` [PATCH 06/20] synclink: kill the big kernel lock Alan Cox
2010-05-05 10:02 ` [PATCH 07/20] cyclades: Kill off BKL usage Alan Cox
2010-05-05 10:02 ` [PATCH 08/20] epca: Kill the big kernel lock Alan Cox
2010-05-05 10:02 ` [PATCH 09/20] specialix; Kill the BKL Alan Cox
2010-05-05 10:02 ` [PATCH 10/20] synclink: reworking locking a bit Alan Cox
2010-05-05 10:02 ` [PATCH 11/20] tty: serial - fix various misuses/mishandlings of port->tty Alan Cox
2010-05-05 10:02 ` [PATCH 12/20] tty: serial - fix tty back references in termios Alan Cox
2010-05-05 10:02 ` [PATCH 13/20] tty: serial - fix tty referencing in set_ldisc Alan Cox
2010-05-05 10:02 ` [PATCH 14/20] vc: Locking clean up Alan Cox
2010-05-05 10:03 ` [PATCH 15/20] tty: Make vt's have a tty_port Alan Cox
2010-05-05 10:03 ` [PATCH 16/20] tty: Move the vt_tty field from the vc_data into the standard tty_port Alan Cox
2010-05-05 10:03 ` [PATCH 17/20] serial: Change the wait for carrier locking Alan Cox
2010-05-05 10:03 ` [PATCH 18/20] serial: add port helpers Alan Cox
2010-05-05 10:03 ` [PATCH 19/20] serial: trim locking on the helpers Alan Cox
2010-05-05 10:03 ` Alan Cox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100505100332.3595.32453.stgit@localhost.localdomain \
--to=alan@linux.intel.com \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).