public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Alan Cox <alan@linux.intel.com>, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 33/68] serial: Use block_til_ready helper
Date: Tue, 10 Aug 2010 14:58:55 -0700	[thread overview]
Message-ID: <1281477570-18944-33-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20100810214425.GB17385@kroah.com>

From: Alan Cox <alan@linux.intel.com>

Our code now rather closely resembles the helper, so switch to it.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 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.
-- 
1.7.2


  parent reply	other threads:[~2010-08-10 22:08 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-10 21:44 [GIT PATCH] TTY patches for 2.6.36, try 2 Greg KH
2010-08-10 21:58 ` [PATCH 01/68] n_gsm.c: removed duplicated #includes Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 02/68] serial: There's no config CONSOLE Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 03/68] vt: clean up the code - use kernel library Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 04/68] serial: add UART_CAP_EFR and UART_CAP_SLEEP flags to 16C950 UARTs definition Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 05/68] mrst_max3110: add UART driver for Max3110 on Moorestown Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 06/68] max3110 sanity check a register Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 07/68] serial: replace open coded mutex with a real mutex in mrst_max3110.c Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 08/68] serial: fix wakup races in the mrst_max3110 driver Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 09/68] tty: Remove Hayes ESP ioctls Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 10/68] tty: remove remaining " Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 11/68] tty: Add EXTPROC support for LINEMODE Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 12/68] vt/console: try harder to print output when panicing Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 13/68] stallion: prune lock_kernel calls Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 14/68] istallion: use bit ops for the board flags Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 15/68] riscom8: kill use of lock_kernel Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 16/68] isicom: kill off the BKL Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 17/68] rocket: kill BKL Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 18/68] synclink: kill the big kernel lock Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 19/68] cyclades: Kill off BKL usage Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 20/68] epca: Kill the big kernel lock Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 21/68] specialix: Kill the BKL Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 22/68] tty: Fix the digi acceleport driver NULL checks Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 23/68] synclink: reworking locking a bit Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 24/68] tty: serial - fix various misuses/mishandlings of port->tty Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 25/68] tty: serial - fix tty back references in termios Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 26/68] tty: serial - fix tty referencing in set_ldisc Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 27/68] vc: Locking clean up Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 28/68] tty: Make vt's have a tty_port Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 29/68] tty: Move the vt_tty field from the vc_data into the standard tty_port Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 30/68] serial: Change the wait for carrier locking Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 31/68] serial: add port helpers Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 32/68] serial: trim locking on the helpers Greg Kroah-Hartman
2010-08-10 21:58 ` Greg Kroah-Hartman [this message]
2010-08-10 21:58 ` [PATCH 34/68] serial: fix termios settings in open Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 35/68] tty: replace BKL with a new tty_lock Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 36/68] tty: never hold BTM while getting tty_mutex Greg Kroah-Hartman
2010-08-10 21:58 ` [PATCH 37/68] tty: fix console_sem lock order Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 38/68] cdc-acm: remove dead code Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 39/68] tty: introduce wait_event_interruptible_tty Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 40/68] tty: reorder ldisc locking Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 41/68] tty: untangle locking of wait_until_sent Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 42/68] tty: remove tty_lock_nested Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 43/68] tty: implement BTM as mutex instead of BKL Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 44/68] tty: release BTM while sleeping in block_til_ready Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 45/68] 8250: fix set_ldisc operation Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 46/68] tty: avoid recursive BTM in pty_close Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 47/68] serial: max3107: introduce a max3107 driver Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 48/68] serial: max3107: Abstract out the platform specific bits Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 49/68] tty_io: remove casts from void* Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 50/68] vt: Fix warning: statement with no effect due to vt_kern.h Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 51/68] serial: crisv10: formatting of pointers in printk() Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 52/68] serial: "altera_uart: simplify altera_uart_console_putc()" checkpatch fixes Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 53/68] serial: fix missing bit coverage of ASYNC_FLAGS Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 54/68] serial: general fixes in the serial_rs485 structure Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 55/68] serial: mcf: don't take spinlocks in already protected functions Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 56/68] serial: MMIO32 support for 8250_early.c Greg Kroah-Hartman
2010-08-12 18:43   ` Tony Luck
2010-08-12 18:46     ` Greg KH
2010-08-12 19:16       ` [PATCH] print early console device address in hex Luck, Tony
2010-08-10 21:59 ` [PATCH 57/68] timbuart: use __devinit and __devexit macros for probe and remove Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 58/68] serial: 68328serial.c: remove dead (ALMA_ANS | DRAGONIXVZ | M68EZ328ADS) Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 59/68] serial: add support for OX16PCI958 card Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 60/68] mxser: remove unnesesary NULL check Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 61/68] hsu: driver for Medfield High Speed UART device Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 62/68] hsu: add a periodic timer to check dma rx channel Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 63/68] hsu: some code cleanup Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 64/68] hsu: call PCI pm hooks in suspend/resume function Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 65/68] serial: max3107: Fix gpiolib support Greg Kroah-Hartman
2010-08-10 21:59 ` [PATCH 68/68] U6715 16550A serial driver support Greg Kroah-Hartman

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=1281477570-18944-33-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=alan@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@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