From: Jiri Slaby <jirislaby@gmail.com>
To: alan@lxorguk.ukuu.org.uk
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Jiri Slaby <jirislaby@gmail.com>
Subject: [PATCH 05/13] Char: cyclades, close cleanup
Date: Thu, 18 Jun 2009 09:41:40 +0200 [thread overview]
Message-ID: <1245310908-27691-5-git-send-email-jirislaby@gmail.com> (raw)
In-Reply-To: <1245310908-27691-1-git-send-email-jirislaby@gmail.com>
Use new tty helpers for close, which allows much code removal.
The only real change is locking. card_lock for protecting was
used inappropriately (just to have a critical section, no matter
which lock is used), so the change to port->lock is fine.
Remove also useless debug printks while being there.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
drivers/char/cyclades.c | 70 +---------------------------------------------
1 files changed, 2 insertions(+), 68 deletions(-)
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index 44bd42d..67f1739 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -2360,61 +2360,13 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
struct cyclades_card *card;
unsigned long flags;
-#ifdef CY_DEBUG_OTHER
- printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line);
-#endif
-
if (!info || serial_paranoia_check(info, tty->name, "cy_close"))
return;
card = info->card;
- spin_lock_irqsave(&card->card_lock, flags);
- /* If the TTY is being hung up, nothing to do */
- if (tty_hung_up_p(filp)) {
- spin_unlock_irqrestore(&card->card_lock, flags);
+ if (!tty_port_close_start(&info->port, tty, filp))
return;
- }
-#ifdef CY_DEBUG_OPEN
- printk(KERN_DEBUG "cyc:cy_close ttyC%d, count = %d\n", info->line,
- info->port.count);
-#endif
- if ((tty->count == 1) && (info->port.count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. Info->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk(KERN_ERR "cyc:cy_close: bad serial port count; "
- "tty->count is 1, info->port.count is %d\n", info->port.count);
- info->port.count = 1;
- }
-#ifdef CY_DEBUG_COUNT
- printk(KERN_DEBUG "cyc:cy_close at (%d): decrementing count to %d\n",
- current->pid, info->port.count - 1);
-#endif
- if (--info->port.count < 0) {
-#ifdef CY_DEBUG_COUNT
- printk(KERN_DEBUG "cyc:cyc_close setting count to 0\n");
-#endif
- info->port.count = 0;
- }
- if (info->port.count) {
- spin_unlock_irqrestore(&card->card_lock, flags);
- return;
- }
- info->port.flags |= ASYNC_CLOSING;
-
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
- spin_unlock_irqrestore(&card->card_lock, flags);
- if (info->port.closing_wait != CY_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, info->port.closing_wait);
spin_lock_irqsave(&card->card_lock, flags);
@@ -2459,28 +2411,10 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
spin_unlock_irqrestore(&card->card_lock, flags);
cy_shutdown(info, tty);
cy_flush_buffer(tty);
- tty_ldisc_flush(tty);
- spin_lock_irqsave(&card->card_lock, flags);
- tty->closing = 0;
tty_port_tty_set(&info->port, NULL);
- if (info->port.blocked_open) {
- spin_unlock_irqrestore(&card->card_lock, flags);
- if (info->port.close_delay) {
- msleep_interruptible(jiffies_to_msecs
- (info->port.close_delay));
- }
- wake_up_interruptible(&info->port.open_wait);
- spin_lock_irqsave(&card->card_lock, flags);
- }
- info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
- wake_up_interruptible(&info->port.close_wait);
-#ifdef CY_DEBUG_OTHER
- printk(KERN_DEBUG "cyc:cy_close done\n");
-#endif
-
- spin_unlock_irqrestore(&card->card_lock, flags);
+ tty_port_close_end(&info->port, tty);
} /* cy_close */
/* This routine gets called when tty_write has put something into
--
1.6.3.2
next prev parent reply other threads:[~2009-06-18 7:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-18 7:41 [PATCH 01/13] Char: cyclades, add tty refcounting Jiri Slaby
2009-06-18 7:41 ` [PATCH 02/13] Char: cyclades, remove block_til_ready Jiri Slaby
2009-06-18 7:41 ` [PATCH 03/13] Char: cyclades, avoid addresses recomputation Jiri Slaby
2009-06-18 7:41 ` [PATCH 04/13] Char: cyclades, switch to tty_port_hangup Jiri Slaby
2009-06-18 7:41 ` Jiri Slaby [this message]
2009-06-18 7:41 ` [PATCH 06/13] Char: cyclades, overall cleanup Jiri Slaby
2009-06-18 7:41 ` [PATCH 07/13] Char: cyclades, sleep instead busy-wait Jiri Slaby
2009-06-18 7:41 ` [PATCH 08/13] Char: cyclades, use dtr_rts helpers Jiri Slaby
2009-06-18 7:41 ` [PATCH 09/13] Char: cyclades, merge cy_startup tails Jiri Slaby
2009-06-18 7:41 ` [PATCH 10/13] Char: cyclades, ioctls cleanup Jiri Slaby
2009-06-18 7:41 ` [PATCH 11/13] Char: cyclades, tiocm cleanup Jiri Slaby
2009-06-18 7:41 ` [PATCH 12/13] Char: cyclades, introduce cyy_readb/writeb Jiri Slaby
2009-06-18 7:41 ` [PATCH 13/13] Char: cyclades, remove more duplicated code Jiri Slaby
2009-06-18 13:17 ` [PATCH 01/13] Char: cyclades, add tty refcounting Alan Cox
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=1245310908-27691-5-git-send-email-jirislaby@gmail.com \
--to=jirislaby@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--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
all inboxes | Powered by JetHome®