mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: <linux-kernel@vger.kernel.org>
Cc: Frank Seidel <fseidel@suse.de>
Subject: [RFC 2/13] Char: nozomi, expand some functions
Date: Fri, 9 Nov 2007 18:44:11 -0500	[thread overview]
Message-ID: <457510094309335479.slaby@pripojeni.net> (raw)
In-Reply-To: <10551261882075921134.slaby@pripojeni.net>

nozomi, expand some functions

nozomi_setup_interrupt and tty_do_close are used only in one place and has
no pros of being in separate functions. move tty_do_close contents into
ntty_close (it contained only tty_do_close call before) and
nozomi_setup_interrupt (only request_irq) into nozomi_card_init.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>

---
commit 29335b619cc5ee27417d50982f029d440570f67c
tree 9cef37ef05e53453cd4d245a34c038ca12433253
parent 79aeb51662902086507927cb7fcd682ae319630a
author Jiri Slaby <jirislaby@gmail.com> Sun, 28 Oct 2007 11:06:05 +0100
committer Jiri Slaby <jirislaby@gmail.com> Fri, 09 Nov 2007 22:54:16 +0100

 drivers/char/nozomi.c |   75 +++++++++++++++++++------------------------------
 1 files changed, 29 insertions(+), 46 deletions(-)

diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 458e70b..2e2cbc5 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -1478,20 +1478,6 @@ none:
 	return IRQ_NONE;
 }
 
-/* Request a shared IRQ from system */
-static int nozomi_setup_interrupt(struct nozomi_devices *ndev)
-{
-	int rval;
-
-	rval = request_irq(ndev->my_dev->pdev->irq, &interrupt_handler,
-				IRQF_SHARED, NOZOMI_NAME, ndev);
-	if (unlikely(rval))
-		dev_err(&ndev->my_dev->pdev->dev, "Cannot open because IRQ %d "
-			"is already in use.\n", ndev->my_dev->pdev->irq);
-
-	return rval;
-}
-
 static void nozomi_get_card_type(struct nozomi *dc)
 {
 	int i;
@@ -1635,9 +1621,10 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
 	dc->last_ier = 0;
 	writew(dc->last_ier, dc->reg_ier);
 
-	/* Setup interrupt handler */
-	if (nozomi_setup_interrupt(newdev)) {
-		ret = -EIO;
+	ret = request_irq(pdev->irq, &interrupt_handler, IRQF_SHARED,
+			NOZOMI_NAME, newdev);
+	if (unlikely(ret)) {
+		dev_err(&pdev->dev, "can't request irq\n");
 		goto err_disable_regions;
 	}
 
@@ -1694,34 +1681,6 @@ err_disable_device:
 	return ret;
 }
 
-static void tty_do_close(struct nozomi *dc, struct port *port)
-{
-	unsigned long flags;
-
-	if (!dc || !port)
-		return;
-
-	if (down_interruptible(&port->tty_sem))
-		return;
-
-	if (!port->tty_open_count)
-		goto exit;
-
-	dc->open_ttys--;
-	port->tty_open_count--;
-
-	if (port->tty_open_count == 0) {
-		DBG1("close: %d", port->token_dl);
-		spin_lock_irqsave(&dc->spin_mutex, flags);
-		dc->last_ier &= ~(port->token_dl);
-		writew(dc->last_ier, dc->reg_ier);
-		spin_unlock_irqrestore(&dc->spin_mutex, flags);
-	}
-
-exit:
-	up(&port->tty_sem);
-}
-
 static void __devexit tty_exit(struct nozomi_devices *ndev)
 {
 	struct nozomi *dc = ndev->my_dev;
@@ -1874,7 +1833,31 @@ static int ntty_open(struct tty_struct *tty, struct file *file)
 static void ntty_close(struct tty_struct *tty, struct file *file)
 {
 	struct nozomi *dc = get_dc_by_tty(tty);
-	tty_do_close(dc, (struct port *)tty->driver_data);
+	struct port *port = tty->driver_data;
+	unsigned long flags;
+
+	if (!dc || !port)
+		return;
+
+	if (down_interruptible(&port->tty_sem))
+		return;
+
+	if (!port->tty_open_count)
+		goto exit;
+
+	dc->open_ttys--;
+	port->tty_open_count--;
+
+	if (port->tty_open_count == 0) {
+		DBG1("close: %d", port->token_dl);
+		spin_lock_irqsave(&dc->spin_mutex, flags);
+		dc->last_ier &= ~(port->token_dl);
+		writew(dc->last_ier, dc->reg_ier);
+		spin_unlock_irqrestore(&dc->spin_mutex, flags);
+	}
+
+exit:
+	up(&port->tty_sem);
 }
 
 /*

  reply	other threads:[~2007-11-09 23:44 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-09 23:43 [RFC 1/13] Char: nozomi, remove unneded stuff Jiri Slaby
2007-11-09 23:44 ` Jiri Slaby [this message]
2007-11-10 15:41   ` [RFC 2/13] Char: nozomi, expand some functions Frank Seidel
2007-11-09 23:44 ` [RFC 3/13] Char: nozomi, fix fail paths Jiri Slaby
2007-11-10 15:41   ` Frank Seidel
2007-11-09 23:45 ` [RFC 4/13] Char: nozomi, tty index cleanup Jiri Slaby
2007-11-10 15:41   ` Frank Seidel
2007-11-10 15:50     ` Jiri Slaby
2007-11-09 23:46 ` [RFC 5/13] Char: nozomi, ioctls cleanup Jiri Slaby
2007-11-10 15:41   ` Frank Seidel
2007-11-09 23:46 ` [RFC 6/13] Char: nozomi, reorder and cleanup probe, remove Jiri Slaby
2007-11-10 15:42   ` Frank Seidel
2007-11-09 23:47 ` [RFC 7/13] Char: nozomi, remove struct irq Jiri Slaby
2007-11-10 15:42   ` Frank Seidel
2007-11-12 15:11   ` Frank Seidel
2007-11-09 23:48 ` [RFC 8/13] Char: nozomi, tty cleanup Jiri Slaby
2007-11-10 15:42   ` Frank Seidel
2007-11-12 18:43   ` Frank Seidel
2007-11-09 23:48 ` [RFC 9/13] Char: nozomi, lock cleanup Jiri Slaby
2007-11-10 15:42   ` Frank Seidel
2007-11-09 23:49 ` [RFC! 10/13] Char: nozomi, fix tty_flip_buffer_push Jiri Slaby
2007-11-10 15:43   ` Frank Seidel
2007-11-09 23:50 ` [RFC 11/13] Char: nozomi, remove unused includes Jiri Slaby
2007-11-10 15:43   ` Frank Seidel
2007-11-09 23:50 ` [RFC 12/13] Char: nozomi, remove void acc char2 char3 more mp mp.c mp.yy m1 nozomi2 proto rej slock1 casts Jiri Slaby
2007-11-10 15:43   ` Frank Seidel
2007-11-09 23:51 ` [RFC 13/13] Char: nozomi, cleanup read and write Jiri Slaby
2007-11-10 15:43   ` Frank Seidel
2007-11-10 16:15   ` Adrian Bunk
2007-11-10 22:04     ` Jiri Slaby
2007-11-11  2:37       ` Frank Seidel
2007-11-11 16:02         ` Frank Seidel
2007-11-12  7:54       ` Adrian Bunk
2007-11-12  9:43         ` Frank Seidel
2007-11-10 15:41 ` [RFC 1/13] Char: nozomi, remove unneded stuff Frank Seidel
2007-11-10 15:55   ` Jiri Slaby

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=457510094309335479.slaby@pripojeni.net \
    --to=jirislaby@gmail.com \
    --cc=fseidel@suse.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

all inboxes | Powered by JetHome®