mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <alan@lxorguk.ukuu.org.uk>,
	Oyvind Aabling <Oyvind.Aabling@uni-c.dk>,
	Jiri Slaby <jirislaby@gmail.com>
Subject: [PATCH 10/19] Char: moxa, timer cleanup
Date: Fri, 22 Feb 2008 15:46:37 +0100	[thread overview]
Message-ID: <1203691606-9310-10-git-send-email-jirislaby@gmail.com> (raw)
In-Reply-To: <1203691606-9310-1-git-send-email-jirislaby@gmail.com>

- schedule timer even after some card is installed, not after insmod
- cleanup timer functions

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Tested-by: Oyvind Aabling <Oyvind.Aabling@uni-c.dk>
---
 drivers/char/moxa.c |   62 +++++++++++++++++---------------------------------
 1 files changed, 21 insertions(+), 41 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index e2e8580..8c2b72e 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -215,7 +215,6 @@ static void moxa_receive_data(struct moxa_port *);
  */
 static int MoxaDriverIoctl(struct tty_struct *, unsigned int, unsigned long);
 static int MoxaDriverPoll(void);
-static int MoxaPortsOfCard(int);
 static void MoxaPortEnable(struct moxa_port *);
 static void MoxaPortDisable(struct moxa_port *);
 static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t);
@@ -715,6 +714,9 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
 
 	brd->ready = 1;
 
+	if (!timer_pending(&moxaTimer))
+		mod_timer(&moxaTimer, jiffies + HZ / 50);
+
 	return 0;
 err_free:
 	kfree(brd->ports);
@@ -856,8 +858,6 @@ static int __init moxa_init(void)
 		return -1;
 	}
 
-	mod_timer(&moxaTimer, jiffies + HZ / 50);
-
 	/* Find the boards defined from module args. */
 #ifdef MODULE
 	{
@@ -1284,10 +1284,10 @@ static void moxa_hangup(struct tty_struct *tty)
 
 static void moxa_poll(unsigned long ignored)
 {
-	register int card;
 	struct moxa_port *ch;
-	struct tty_struct *tp;
-	int i, ports;
+	struct tty_struct *tty;
+	unsigned int card;
+	int i;
 
 	del_timer(&moxaTimer);
 
@@ -1295,36 +1295,38 @@ static void moxa_poll(unsigned long ignored)
 		mod_timer(&moxaTimer, jiffies + HZ / 50);
 		return;
 	}
+
 	for (card = 0; card < MAX_BOARDS; card++) {
-		if ((ports = MoxaPortsOfCard(card)) <= 0)
+		if (!moxa_boards[card].ready)
 			continue;
 		ch = moxa_boards[card].ports;
-		for (i = 0; i < ports; i++, ch++) {
+		for (i = 0; i < moxa_boards[card].numPorts; i++, ch++) {
 			if ((ch->asyncflags & ASYNC_INITIALIZED) == 0)
 				continue;
 			if (!(ch->statusflags & THROTTLE) &&
 			    (MoxaPortRxQueue(ch) > 0))
 				moxa_receive_data(ch);
-			if ((tp = ch->tty) == 0)
+			tty = ch->tty;
+			if (tty == NULL)
 				continue;
 			if (ch->statusflags & LOWWAIT) {
 				if (MoxaPortTxQueue(ch) <= WAKEUP_CHARS) {
-					if (!tp->stopped) {
+					if (!tty->stopped) {
 						ch->statusflags &= ~LOWWAIT;
-						tty_wakeup(tp);
+						tty_wakeup(tty);
 					}
 				}
 			}
-			if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch) > 0)) {
-				tty_insert_flip_char(tp, 0, TTY_BREAK);
-				tty_schedule_flip(tp);
+			if (!I_IGNBRK(tty) && (MoxaPortResetBrkCnt(ch) > 0)) {
+				tty_insert_flip_char(tty, 0, TTY_BREAK);
+				tty_schedule_flip(tty);
 			}
 			if (MoxaPortDCDChange(ch)) {
 				if (ch->asyncflags & ASYNC_CHECK_CD) {
 					if (MoxaPortDCDON(ch))
 						wake_up_interruptible(&ch->open_wait);
 					else {
-						tty_hangup(tp);
+						tty_hangup(tty);
 						wake_up_interruptible(&ch->open_wait);
 						ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
 					}
@@ -1670,15 +1672,14 @@ copy:
 	return -ENOIOCTLCMD;
 }
 
-int MoxaDriverPoll(void)
+static int MoxaDriverPoll(void)
 {
 	struct moxa_board_conf *brd;
 	struct moxa_port *p;
-	register ushort temp;
-	register int card;
 	void __iomem *ofsAddr;
 	void __iomem *ip;
-	int port, ports;
+	unsigned int port, ports, card;
+	ushort temp;
 
 	for (card = 0; card < MAX_BOARDS; card++) {
 		brd = &moxa_boards[card];
@@ -1728,19 +1729,8 @@ int MoxaDriverPoll(void)
 		}
 	}
 	moxaLowWaterChk = 0;
-	return (0);
-}
 
-/*****************************************************************************
- *	Card level function:						     *
- *	1. MoxaPortsOfCard(int cardno); 				     *
- *****************************************************************************/
-int MoxaPortsOfCard(int cardno)
-{
-
-	if (moxa_boards[cardno].boardType == 0)
-		return (0);
-	return (moxa_boards[cardno].numPorts);
+	return 0;
 }
 
 /*****************************************************************************
@@ -1811,16 +1801,6 @@ int MoxaPortsOfCard(int cardno)
  *                      -1      : no any Moxa card.             
  *
  *
- *      Function 4:     Get the ports of this card.
- *      Syntax:
- *      int  MoxaPortsOfCard(int cardno);
- *
- *           int cardno         : card number (0 - 3)
- *
- *           return:    0       : this card is invalid
- *                      8/16/24/32
- *
- *
  *      Function 6:     Enable this port to start Tx/Rx data.
  *      Syntax:
  *      void MoxaPortEnable(int port);
-- 
1.5.4.1


  parent reply	other threads:[~2008-02-22 14:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-22 14:46 [PATCH 01/19] Char: moxa, remove static isa support Jiri Slaby
2008-02-22 14:46 ` [PATCH 02/19] Char: moxa, cleanup module-param passed isa init Jiri Slaby
2008-02-22 14:46 ` [PATCH 03/19] Char: moxa, pci io space fixup Jiri Slaby
2008-02-22 14:46 ` [PATCH 04/19] Char: moxa, fix TIOC(G/S)SOFTCAR param Jiri Slaby
2008-02-22 14:46 ` [PATCH 05/19] Char: moxa, add firmware loading Jiri Slaby
2008-02-22 14:46 ` [PATCH 06/19] Char: moxa, merge c2xx and c320 " Jiri Slaby
2008-02-22 14:46 ` [PATCH 07/19] Char: moxa, remove port->port Jiri Slaby
2008-02-22 14:46 ` [PATCH 08/19] Char: moxa, remove unused port entries Jiri Slaby
2008-02-22 14:46 ` [PATCH 09/19] Char: moxa, centralize board readiness Jiri Slaby
2008-02-22 14:46 ` Jiri Slaby [this message]
2008-02-22 14:46 ` [PATCH 11/19] Char: moxa, ioctl cleanup Jiri Slaby
2008-02-22 14:46 ` [PATCH 12/19] Char: moxa, merge 2 poll functions Jiri Slaby
2008-02-22 14:46 ` [PATCH 13/19] Char: moxa, cleanup rx/tx Jiri Slaby
2008-02-22 14:46 ` [PATCH 14/19] Char: moxa, serialise timer Jiri Slaby
2008-02-22 14:46 ` [PATCH 15/19] Char: moxa, rework open/close Jiri Slaby
2008-02-22 14:46 ` [PATCH 16/19] Char: moxa, little cleanup Jiri Slaby
2008-02-22 14:46 ` [PATCH 17/19] Char: moxa, remove useless tty functions Jiri Slaby
2008-02-22 14:46 ` [PATCH 18/19] Char: moxa, introduce MOXA_IS_320 macro Jiri Slaby
2008-02-22 14:46 ` [PATCH 19/19] Char: moxa, notify about board readiness Jiri Slaby
2008-02-22 20:09 ` [PATCH 20/21] Char: moxa, update credits Jiri Slaby
2008-02-22 20:09 ` [PATCH 21/21] Char: moxa, add firmware loading fix 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=1203691606-9310-10-git-send-email-jirislaby@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=Oyvind.Aabling@uni-c.dk \
    --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

Powered by JetHome