All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] Char: moxa, remove unused allocated page
@ 2006-12-31  1:04 Jiri Slaby
  2006-12-31  1:04 ` [PATCH 2/8] Char: moxa, do not initialize global static Jiri Slaby
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, remove unused allocated page

moxaXmitBuff is almost unused -- only one byte from the whole PAGE_SIZE
bytes is used. Do not alloc so much space for almost anything. Also remove
lock protecting this page allocation.

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

---
commit fdcf97c855168c011b18ff68930bcc93e6c625c6
tree a87c0cef9ad40eb3ff2a981ecaa7ac08711809ac
parent c614729fee9638269d0881cf6ab895f19122225a
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:08:54 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:08:54 +0059

 drivers/char/moxa.c |   24 +-----------------------
 1 files changed, 1 insertions(+), 23 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index f391a24..4db1dc4 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -212,12 +212,10 @@ module_param(verbose, bool, 0644);
 
 static struct tty_driver *moxaDriver;
 static struct moxa_str moxaChannels[MAX_PORTS];
-static unsigned char *moxaXmitBuff;
 static int moxaTimer_on;
 static struct timer_list moxaTimer;
 static int moxaEmptyTimer_on[MAX_PORTS];
 static struct timer_list moxaEmptyTimer[MAX_PORTS];
-static struct semaphore moxaBuffSem;
 
 /*
  * static functions:
@@ -343,7 +341,6 @@ static int __init moxa_init(void)
 	if (!moxaDriver)
 		return -ENOMEM;
 
-	init_MUTEX(&moxaBuffSem);
 	moxaDriver->owner = THIS_MODULE;
 	moxaDriver->name = "ttyMX";
 	moxaDriver->major = ttymajor;
@@ -360,8 +357,6 @@ static int __init moxa_init(void)
 	moxaDriver->flags = TTY_DRIVER_REAL_RAW;
 	tty_set_operations(moxaDriver, &moxa_ops);
 
-	moxaXmitBuff = NULL;
-
 	for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
 		ch->type = PORT_16550A;
 		ch->port = i;
@@ -533,7 +528,6 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
 	struct moxa_str *ch;
 	int port;
 	int retval;
-	unsigned long page;
 
 	port = PORTNO(tty);
 	if (port == MAX_PORTS) {
@@ -543,21 +537,6 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
 		tty->driver_data = NULL;
 		return (-ENODEV);
 	}
-	down(&moxaBuffSem);
-	if (!moxaXmitBuff) {
-		page = get_zeroed_page(GFP_KERNEL);
-		if (!page) {
-			up(&moxaBuffSem);
-			return (-ENOMEM);
-		}
-		/* This test is guarded by the BuffSem so no longer needed
-		   delete me in 2.5 */
-		if (moxaXmitBuff)
-			free_page(page);
-		else
-			moxaXmitBuff = (unsigned char *) page;
-	}
-	up(&moxaBuffSem);
 
 	ch = &moxaChannels[port];
 	ch->count++;
@@ -739,8 +718,7 @@ static void moxa_put_char(struct tty_struct *tty, unsigned char c)
 		return;
 	port = ch->port;
 	spin_lock_irqsave(&moxa_lock, flags);
-	moxaXmitBuff[0] = c;
-	MoxaPortWriteData(port, moxaXmitBuff, 1);
+	MoxaPortWriteData(port, &c, 1);
 	spin_unlock_irqrestore(&moxa_lock, flags);
 	/************************************************
 	if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/8] Char: moxa, do not initialize global static
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
@ 2006-12-31  1:04 ` Jiri Slaby
  2006-12-31  1:04 ` [PATCH 3/8] Char: moxa, timers cleanup Jiri Slaby
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, do not initialize global static

Remove useless initialization of variables a) statically b) dynamically
at module_init c) dynamically after kzalloc (those with '= 0/NULL')

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

---
commit bc5dff44602d67db9d08ae1735e6f29162264704
tree 02ad9d888e7a5f274d04214a52bb176b3c3ec89a
parent fdcf97c855168c011b18ff68930bcc93e6c625c6
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:37:23 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:37:23 +0059

 drivers/char/moxa.c |   24 ++++--------------------
 1 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 4db1dc4..80a2bdf 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -194,9 +194,9 @@ static int verbose = 0;
 static int ttymajor = MOXAMAJOR;
 /* Variables for insmod */
 #ifdef MODULE
-static int baseaddr[] 	= 	{0, 0, 0, 0};
-static int type[]	=	{0, 0, 0, 0};
-static int numports[] 	=	{0, 0, 0, 0};
+static int baseaddr[4];
+static int type[4];
+static int numports[4];
 #endif
 
 MODULE_AUTHOR("William Chen");
@@ -348,10 +348,7 @@ static int __init moxa_init(void)
 	moxaDriver->type = TTY_DRIVER_TYPE_SERIAL;
 	moxaDriver->subtype = SERIAL_TYPE_NORMAL;
 	moxaDriver->init_termios = tty_std_termios;
-	moxaDriver->init_termios.c_iflag = 0;
-	moxaDriver->init_termios.c_oflag = 0;
 	moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
-	moxaDriver->init_termios.c_lflag = 0;
 	moxaDriver->init_termios.c_ispeed = 9600;
 	moxaDriver->init_termios.c_ospeed = 9600;
 	moxaDriver->flags = TTY_DRIVER_REAL_RAW;
@@ -361,25 +358,13 @@ static int __init moxa_init(void)
 		ch->type = PORT_16550A;
 		ch->port = i;
 		INIT_WORK(&ch->tqueue, do_moxa_softint);
-		ch->tty = NULL;
 		ch->close_delay = 5 * HZ / 10;
 		ch->closing_wait = 30 * HZ;
-		ch->count = 0;
-		ch->blocked_open = 0;
 		ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
 		init_waitqueue_head(&ch->open_wait);
 		init_waitqueue_head(&ch->close_wait);
 	}
 
-	for (i = 0; i < MAX_BOARDS; i++) {
-		moxa_boards[i].boardType = 0;
-		moxa_boards[i].numPorts = 0;
-		moxa_boards[i].baseAddr = 0;
-		moxa_boards[i].busType = 0;
-		moxa_boards[i].pciInfo.busNum = 0;
-		moxa_boards[i].pciInfo.devNum = 0;
-	}
-	MoxaDriverInit();
 	printk("Tty devices major number = %d\n", ttymajor);
 
 	if (tty_register_driver(moxaDriver)) {
@@ -391,7 +376,6 @@ static int __init moxa_init(void)
 		init_timer(&moxaEmptyTimer[i]);
 		moxaEmptyTimer[i].function = check_xmit_empty;
 		moxaEmptyTimer[i].data = (unsigned long) & moxaChannels[i];
-		moxaEmptyTimer_on[i] = 0;
 	}
 
 	init_timer(&moxaTimer);
@@ -1470,7 +1454,7 @@ static char moxaLowChkFlag[MAX_PORTS];
 static int moxaLowWaterChk;
 static int moxaCard;
 static mon_st moxaLog;
-static int moxaFuncTout;
+static int moxaFuncTout = HZ / 2;
 static ushort moxaBreakCnt[MAX_PORTS];
 
 static void moxadelay(int);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/8] Char: moxa, timers cleanup
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
  2006-12-31  1:04 ` [PATCH 2/8] Char: moxa, do not initialize global static Jiri Slaby
@ 2006-12-31  1:04 ` Jiri Slaby
  2006-12-31  1:04 ` [PATCH 4/8] Char: moxa, remove hangup bottomhalf Jiri Slaby
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, timers cleanup

Use kernel macros and functions for timer encapsulation -- do not access
fileds directly. Also del_timer on inactive is legal, so that noting if it
runs is senseless, delete these variables.

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

---
commit 8171e38961018ef16df52084d1356f891f43ba6f
tree 0001e745280d863e774609d428afa2154bfba487
parent bc5dff44602d67db9d08ae1735e6f29162264704
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:40:02 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:40:02 +0059

 drivers/char/moxa.c |   54 +++++++++++++--------------------------------------
 1 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 80a2bdf..84797a0 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -210,13 +210,6 @@ module_param_array(numports, int, NULL, 0);
 module_param(ttymajor, int, 0);
 module_param(verbose, bool, 0644);
 
-static struct tty_driver *moxaDriver;
-static struct moxa_str moxaChannels[MAX_PORTS];
-static int moxaTimer_on;
-static struct timer_list moxaTimer;
-static int moxaEmptyTimer_on[MAX_PORTS];
-static struct timer_list moxaEmptyTimer[MAX_PORTS];
-
 /*
  * static functions:
  */
@@ -300,6 +293,10 @@ static const struct tty_operations moxa_ops = {
 	.tiocmset = moxa_tiocmset,
 };
 
+static struct tty_driver *moxaDriver;
+static struct moxa_str moxaChannels[MAX_PORTS];
+static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
+static struct timer_list moxaEmptyTimer[MAX_PORTS];
 static DEFINE_SPINLOCK(moxa_lock);
 
 #ifdef CONFIG_PCI
@@ -372,17 +369,11 @@ static int __init moxa_init(void)
 		put_tty_driver(moxaDriver);
 		return -1;
 	}
-	for (i = 0; i < MAX_PORTS; i++) {
-		init_timer(&moxaEmptyTimer[i]);
-		moxaEmptyTimer[i].function = check_xmit_empty;
-		moxaEmptyTimer[i].data = (unsigned long) & moxaChannels[i];
-	}
+	for (i = 0; i < MAX_PORTS; i++)
+		setup_timer(&moxaEmptyTimer[i], check_xmit_empty,
+				(unsigned long)&moxaChannels[i]);
 
-	init_timer(&moxaTimer);
-	moxaTimer.function = moxa_poll;
-	moxaTimer.expires = jiffies + (HZ / 50);
-	moxaTimer_on = 1;
-	add_timer(&moxaTimer);
+	mod_timer(&moxaTimer, jiffies + HZ / 50);
 
 	/* Find the boards defined in source code */
 	numBoards = 0;
@@ -468,12 +459,10 @@ static void __exit moxa_exit(void)
 	if (verbose)
 		printk("Unloading module moxa ...\n");
 
-	if (moxaTimer_on)
-		del_timer(&moxaTimer);
+	del_timer(&moxaTimer);
 
 	for (i = 0; i < MAX_PORTS; i++)
-		if (moxaEmptyTimer_on[i])
-			del_timer(&moxaEmptyTimer[i]);
+		del_timer(&moxaEmptyTimer[i]);
 
 	if (tty_unregister_driver(moxaDriver))
 		printk("Couldn't unregister MOXA Intellio family serial driver\n");
@@ -589,7 +578,6 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
 	if (ch->asyncflags & ASYNC_INITIALIZED) {
 		setup_empty_event(tty);
 		tty_wait_until_sent(tty, 30 * HZ);	/* 30 seconds timeout */
-		moxaEmptyTimer_on[ch->port] = 0;
 		del_timer(&moxaEmptyTimer[ch->port]);
 	}
 	shut_down(ch);
@@ -885,14 +873,10 @@ static void moxa_poll(unsigned long ignored)
 	struct tty_struct *tp;
 	int i, ports;
 
-	moxaTimer_on = 0;
 	del_timer(&moxaTimer);
 
 	if (MoxaDriverPoll() < 0) {
-		moxaTimer.function = moxa_poll;
-		moxaTimer.expires = jiffies + (HZ / 50);
-		moxaTimer_on = 1;
-		add_timer(&moxaTimer);
+		mod_timer(&moxaTimer, jiffies + HZ / 50);
 		return;
 	}
 	for (card = 0; card < MAX_BOARDS; card++) {
@@ -932,10 +916,7 @@ static void moxa_poll(unsigned long ignored)
 		}
 	}
 
-	moxaTimer.function = moxa_poll;
-	moxaTimer.expires = jiffies + (HZ / 50);
-	moxaTimer_on = 1;
-	add_timer(&moxaTimer);
+	mod_timer(&moxaTimer, jiffies + HZ / 50);
 }
 
 /******************************************************************************/
@@ -1062,11 +1043,7 @@ static void setup_empty_event(struct tty_struct *tty)
 
 	spin_lock_irqsave(&moxa_lock, flags);
 	ch->statusflags |= EMPTYWAIT;
-	moxaEmptyTimer_on[ch->port] = 0;
-	del_timer(&moxaEmptyTimer[ch->port]);
-	moxaEmptyTimer[ch->port].expires = jiffies + HZ;
-	moxaEmptyTimer_on[ch->port] = 1;
-	add_timer(&moxaEmptyTimer[ch->port]);
+	mod_timer(&moxaEmptyTimer[ch->port], jiffies + HZ);
 	spin_unlock_irqrestore(&moxa_lock, flags);
 }
 
@@ -1075,7 +1052,6 @@ static void check_xmit_empty(unsigned long data)
 	struct moxa_str *ch;
 
 	ch = (struct moxa_str *) data;
-	moxaEmptyTimer_on[ch->port] = 0;
 	del_timer(&moxaEmptyTimer[ch->port]);
 	if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
 		if (MoxaPortTxQueue(ch->port) == 0) {
@@ -1083,9 +1059,7 @@ static void check_xmit_empty(unsigned long data)
 			tty_wakeup(ch->tty);
 			return;
 		}
-		moxaEmptyTimer[ch->port].expires = jiffies + HZ;
-		moxaEmptyTimer_on[ch->port] = 1;
-		add_timer(&moxaEmptyTimer[ch->port]);
+		mod_timer(&moxaEmptyTimer[ch->port], jiffies + HZ);
 	} else
 		ch->statusflags &= ~EMPTYWAIT;
 }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/8] Char: moxa, remove hangup bottomhalf
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
  2006-12-31  1:04 ` [PATCH 2/8] Char: moxa, do not initialize global static Jiri Slaby
  2006-12-31  1:04 ` [PATCH 3/8] Char: moxa, timers cleanup Jiri Slaby
@ 2006-12-31  1:04 ` Jiri Slaby
  2006-12-31  1:05 ` [PATCH 5/8] Char: moxa, remove unused functions Jiri Slaby
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, remove hangup bottomhalf

call tty_hangup directly, we do not need a bottomhalf for this.

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

---
commit 9146480faf6469f789229e4f09d99a90b3e05c26
tree 58eb5f2f3943a17ad05b3fd869ab987e63a4fe14
parent 8171e38961018ef16df52084d1356f891f43ba6f
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:42:55 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:42:55 +0059

 drivers/char/moxa.c |   25 +++----------------------
 1 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 84797a0..ef2558f 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -159,7 +159,6 @@ struct moxa_str {
 	int cflag;
 	wait_queue_head_t open_wait;
 	wait_queue_head_t close_wait;
-	struct work_struct tqueue;
 };
 
 struct mxser_mstatus {
@@ -178,9 +177,6 @@ static struct mxser_mstatus GMStatus[MAX_PORTS];
 #define EMPTYWAIT	0x4
 #define THROTTLE	0x8
 
-/* event */
-#define MOXA_EVENT_HANGUP	1
-
 #define SERIAL_DO_RESTART
 
 
@@ -213,7 +209,6 @@ module_param(verbose, bool, 0644);
 /*
  * static functions:
  */
-static void do_moxa_softint(struct work_struct *);
 static int moxa_open(struct tty_struct *, struct file *);
 static void moxa_close(struct tty_struct *, struct file *);
 static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -354,7 +349,6 @@ static int __init moxa_init(void)
 	for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
 		ch->type = PORT_16550A;
 		ch->port = i;
-		INIT_WORK(&ch->tqueue, do_moxa_softint);
 		ch->close_delay = 5 * HZ / 10;
 		ch->closing_wait = 30 * HZ;
 		ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
@@ -482,20 +476,6 @@ static void __exit moxa_exit(void)
 module_init(moxa_init);
 module_exit(moxa_exit);
 
-static void do_moxa_softint(struct work_struct *work)
-{
-	struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
-	struct tty_struct *tty;
-
-	if (ch && (tty = ch->tty)) {
-		if (test_and_clear_bit(MOXA_EVENT_HANGUP, &ch->event)) {
-			tty_hangup(tty);	/* FIXME: module removal race here - AKPM */
-			wake_up_interruptible(&ch->open_wait);
-			ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
-		}
-	}
-}
-
 static int moxa_open(struct tty_struct *tty, struct file *filp)
 {
 	struct moxa_str *ch;
@@ -908,8 +888,9 @@ static void moxa_poll(unsigned long ignored)
 					if (MoxaPortDCDON(ch->port))
 						wake_up_interruptible(&ch->open_wait);
 					else {
-						set_bit(MOXA_EVENT_HANGUP, &ch->event);
-						schedule_work(&ch->tqueue);
+						tty_hangup(tp);
+						wake_up_interruptible(&ch->open_wait);
+						ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
 					}
 				}
 			}

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/8] Char: moxa, remove unused functions
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
                   ` (2 preceding siblings ...)
  2006-12-31  1:04 ` [PATCH 4/8] Char: moxa, remove hangup bottomhalf Jiri Slaby
@ 2006-12-31  1:05 ` Jiri Slaby
  2006-12-31  1:05 ` [PATCH 6/8] Char: moxa, devids cleanup Jiri Slaby
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, remove unused functions

Remove ifdeffed functions and cleanup comments including too long license
terms.

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

---
commit c2eee5df210da17dfdea909b89f5db31b577f92a
tree cace45a59508ef209c42e662836ba861ecd06e81
parent 9146480faf6469f789229e4f09d99a90b3e05c26
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:50:23 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:50:23 +0059

 drivers/char/moxa.c |  245 ---------------------------------------------------
 1 files changed, 0 insertions(+), 245 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index ef2558f..3c8858c 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -11,15 +11,6 @@
  *      it under the terms of the GNU General Public License as published by
  *      the Free Software Foundation; either version 2 of the License, or
  *      (at your option) any later version.
- *
- *      This program is distributed in the hope that it will be useful,
- *      but WITHOUT ANY WARRANTY; without even the implied warranty of
- *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *      GNU General Public License for more details.
- *
- *      You should have received a copy of the GNU General Public License
- *      along with this program; if not, write to the Free Software
- *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 /*
@@ -1684,9 +1675,7 @@ int MoxaPortsOfCard(int cardno)
  *	2.  MoxaPortEnable(int port);					     *
  *	3.  MoxaPortDisable(int port);					     *
  *	4.  MoxaPortGetMaxBaud(int port);				     *
- *	5.  MoxaPortGetCurBaud(int port);				     *
  *	6.  MoxaPortSetBaud(int port, long baud);			     *
- *	7.  MoxaPortSetMode(int port, int databit, int stopbit, int parity); *
  *	8.  MoxaPortSetTermio(int port, unsigned char *termio); 	     *
  *	9.  MoxaPortGetLineOut(int port, int *dtrState, int *rtsState);      *
  *	10. MoxaPortLineCtrl(int port, int dtrState, int rtsState);	     *
@@ -1697,18 +1686,12 @@ int MoxaPortsOfCard(int cardno)
  *	15. MoxaPortFlushData(int port, int mode);	                     *
  *	16. MoxaPortWriteData(int port, unsigned char * buffer, int length); *
  *	17. MoxaPortReadData(int port, struct tty_struct *tty); 	     *
- *	18. MoxaPortTxBufSize(int port);				     *
- *	19. MoxaPortRxBufSize(int port);				     *
  *	20. MoxaPortTxQueue(int port);					     *
  *	21. MoxaPortTxFree(int port);					     *
  *	22. MoxaPortRxQueue(int port);					     *
- *	23. MoxaPortRxFree(int port);					     *
  *	24. MoxaPortTxDisable(int port);				     *
  *	25. MoxaPortTxEnable(int port); 				     *
- *	26. MoxaPortGetBrkCnt(int port);				     *
  *	27. MoxaPortResetBrkCnt(int port);				     *
- *	28. MoxaPortSetXonXoff(int port, int xonValue, int xoffValue);	     *
- *	29. MoxaPortIsTxHold(int port); 				     *
  *	30. MoxaPortSendBreak(int port, int ticks);			     *
  *****************************************************************************/
 /*
@@ -1795,15 +1778,6 @@ int MoxaPortsOfCard(int cardno)
  *                      38400/57600/115200 bps
  *
  *
- *      Function 9:     Get the current baud rate of this port.
- *      Syntax:
- *      long MoxaPortGetCurBaud(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0       : this port is invalid
- *                      50 - 115200 bps
- *
- *
  *      Function 10:    Setting baud rate of this port.
  *      Syntax:
  *      long MoxaPortSetBaud(int port, long baud);
@@ -1817,18 +1791,6 @@ int MoxaPortsOfCard(int cardno)
  *                                    baud rate will be the maximun baud rate.
  *
  *
- *      Function 11:    Setting the data-bits/stop-bits/parity of this port
- *      Syntax:
- *      int  MoxaPortSetMode(int port, int databits, int stopbits, int parity);
- *           int port           : port number (0 - 127)
- *           int databits       : data bits (8/7/6/5)
- *           int stopbits       : stop bits (2/1/0, 0 show 1.5 stop bits)
- int parity     : parity (0:None,1:Odd,2:Even,3:Mark,4:Space)
- *
- *           return:    -1      : invalid parameter
- *                      0       : setting O.K.
- *
- *
  *      Function 12:    Configure the port.
  *      Syntax:
  *      int  MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud);
@@ -1933,22 +1895,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    0 - length      : real read data length
  *
  *
- *      Function 22:    Get the Tx buffer size of this port
- *      Syntax:
- *      int  MoxaPortTxBufSize(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Tx buffer size
- *
- *
- *      Function 23:    Get the Rx buffer size of this port
- *      Syntax:
- *      int  MoxaPortRxBufSize(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Rx buffer size
- *
- *
  *      Function 24:    Get the Tx buffer current queued data bytes
  *      Syntax:
  *      int  MoxaPortTxQueue(int port);
@@ -1973,14 +1919,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    ..      : Rx buffer current queued data bytes
  *
  *
- *      Function 27:    Get the Rx buffer current free space
- *      Syntax:
- *      int  MoxaPortRxFree(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    ..      : Rx buffer current free space
- *
- *
  *      Function 28:    Disable port data transmission.
  *      Syntax:
  *      void MoxaPortTxDisable(int port);
@@ -1993,14 +1931,6 @@ int MoxaPortsOfCard(int cardno)
  *           int port           : port number (0 - 127)
  *
  *
- *      Function 30:    Get the received BREAK signal count.
- *      Syntax:
- *      int  MoxaPortGetBrkCnt(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0 - ..  : BREAK signal count
- *
- *
  *      Function 31:    Get the received BREAK signal count and reset it.
  *      Syntax:
  *      int  MoxaPortResetBrkCnt(int port);
@@ -2009,25 +1939,6 @@ int MoxaPortsOfCard(int cardno)
  *           return:    0 - ..  : BREAK signal count
  *
  *
- *      Function 32:    Set the S/W flow control new XON/XOFF value, default
- *                      XON is 0x11 & XOFF is 0x13.
- *      Syntax:
- *      void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue);
- *           int port           : port number (0 - 127)
- *           int xonValue       : new XON value (0 - 255)
- *           int xoffValue      : new XOFF value (0 - 255)
- *
- *
- *      Function 33:    Check this port's transmission is hold by remote site
- *                      because the flow control.
- *      Syntax:
- *      int  MoxaPortIsTxHold(int port);
- *           int port           : port number (0 - 127)
- *
- *           return:    0       : normal
- *                      1       : hold by remote site
- *
- *
  *      Function 34:    Send out a BREAK signal.
  *      Syntax:
  *      void MoxaPortSendBreak(int port, int ms100);
@@ -2276,23 +2187,6 @@ int MoxaPortDCDON(int port)
 	return (n);
 }
 
-
-/*
-   int MoxaDumpMem(int port, unsigned char * buffer, int len)
-   {
-   int          i;
-   unsigned long                baseAddr,ofsAddr,ofs;
-
-   baseAddr = moxaBaseAddr[port / MAX_PORTS_PER_BOARD];
-   ofs = baseAddr + DynPage_addr + pageofs;
-   if (len > 0x2000L)
-   len = 0x2000L;
-   for (i = 0; i < len; i++)
-   buffer[i] = readb(ofs+i);
-   }
- */
-
-
 int MoxaPortWriteData(int port, unsigned char * buffer, int len)
 {
 	int c, total, i;
@@ -2944,16 +2838,6 @@ static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPor
 	return (0);
 }
 
-#if 0
-long MoxaPortGetCurBaud(int port)
-{
-
-	if (moxaChkPort[port] == 0)
-		return (0);
-	return (moxaCurBaud[port]);
-}
-#endif  /*  0  */
-
 static void MoxaSetFifo(int port, int enable)
 {
 	void __iomem *ofsAddr = moxaTableAddr[port];
@@ -2966,132 +2850,3 @@ static void MoxaSetFifo(int port, int enable)
 		moxafunc(ofsAddr, FC_SetTxFIFOCnt, 16);
 	}
 }
-
-#if 0
-int MoxaPortSetMode(int port, int databits, int stopbits, int parity)
-{
-	void __iomem *ofsAddr;
-	int val;
-
-	val = 0;
-	switch (databits) {
-	case 5:
-		val |= 0;
-		break;
-	case 6:
-		val |= 1;
-		break;
-	case 7:
-		val |= 2;
-		break;
-	case 8:
-		val |= 3;
-		break;
-	default:
-		return (-1);
-	}
-	switch (stopbits) {
-	case 0:
-		val |= 0;
-		break;		/* stop bits 1.5 */
-	case 1:
-		val |= 0;
-		break;
-	case 2:
-		val |= 4;
-		break;
-	default:
-		return (-1);
-	}
-	switch (parity) {
-	case 0:
-		val |= 0x00;
-		break;		/* None  */
-	case 1:
-		val |= 0x08;
-		break;		/* Odd   */
-	case 2:
-		val |= 0x18;
-		break;		/* Even  */
-	case 3:
-		val |= 0x28;
-		break;		/* Mark  */
-	case 4:
-		val |= 0x38;
-		break;		/* Space */
-	default:
-		return (-1);
-	}
-	ofsAddr = moxaTableAddr[port];
-	moxafunc(ofsAddr, FC_SetMode, val);
-	return (0);
-}
-
-int MoxaPortTxBufSize(int port)
-{
-	void __iomem *ofsAddr;
-	int size;
-
-	ofsAddr = moxaTableAddr[port];
-	size = readw(ofsAddr + TX_mask);
-	return (size);
-}
-
-int MoxaPortRxBufSize(int port)
-{
-	void __iomem *ofsAddr;
-	int size;
-
-	ofsAddr = moxaTableAddr[port];
-	size = readw(ofsAddr + RX_mask);
-	return (size);
-}
-
-int MoxaPortRxFree(int port)
-{
-	void __iomem *ofsAddr;
-	ushort rptr, wptr, mask;
-	int len;
-
-	ofsAddr = moxaTableAddr[port];
-	rptr = readw(ofsAddr + RXrptr);
-	wptr = readw(ofsAddr + RXwptr);
-	mask = readw(ofsAddr + RX_mask);
-	len = mask - ((wptr - rptr) & mask);
-	return (len);
-}
-int MoxaPortGetBrkCnt(int port)
-{
-	return (moxaBreakCnt[port]);
-}
-
-void MoxaPortSetXonXoff(int port, int xonValue, int xoffValue)
-{
-	void __iomem *ofsAddr;
-
-	ofsAddr = moxaTableAddr[port];
-	writew(xonValue, ofsAddr + FuncArg);
-	writew(xoffValue, ofsAddr + FuncArg1);
-	writew(FC_SetXonXoff, ofsAddr + FuncCode);
-	wait_finish(ofsAddr);
-}
-
-int MoxaPortIsTxHold(int port)
-{
-	void __iomem *ofsAddr;
-	int val;
-
-	ofsAddr = moxaTableAddr[port];
-	if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
-	    (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
-		moxafunc(ofsAddr, FC_GetCCSR, 0);
-		val = readw(ofsAddr + FuncArg);
-		if (val & 0x04)
-			return (1);
-	} else {
-		if (readw(ofsAddr + FlagStat) & Tx_flowOff)
-			return (1);
-	}
-	return (0);
-}
-#endif

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/8] Char: moxa, devids cleanup
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
                   ` (3 preceding siblings ...)
  2006-12-31  1:05 ` [PATCH 5/8] Char: moxa, remove unused functions Jiri Slaby
@ 2006-12-31  1:05 ` Jiri Slaby
  2006-12-31  1:05 ` [PATCH 7/8] Char: moxa, use PCI_DEVICE Jiri Slaby
  2006-12-31  1:05 ` [PATCH 8/8] Char: moxa, eliminate typedefs Jiri Slaby
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, devids cleanup

Move them to pci_ids.h

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

---
commit 9e4d8826dd1dbaa7bb9d520b02da25a5a5cefa13
tree 09ff5e387adce87a70c388e83af678fd5552062b
parent c2eee5df210da17dfdea909b89f5db31b577f92a
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:54:13 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:54:13 +0059

 drivers/char/moxa.c     |   19 +++----------------
 include/linux/pci_ids.h |    3 +++
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 3c8858c..5c0c0e6 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -64,19 +64,6 @@
 #define MOXA_BUS_TYPE_ISA		0
 #define MOXA_BUS_TYPE_PCI		1
 
-#ifndef	PCI_VENDOR_ID_MOXA
-#define	PCI_VENDOR_ID_MOXA	0x1393
-#endif
-#ifndef PCI_DEVICE_ID_CP204J
-#define PCI_DEVICE_ID_CP204J	0x2040
-#endif
-#ifndef PCI_DEVICE_ID_C218
-#define PCI_DEVICE_ID_C218	0x2180
-#endif
-#ifndef PCI_DEVICE_ID_C320
-#define PCI_DEVICE_ID_C320	0x3200
-#endif
-
 enum {
 	MOXA_BOARD_C218_PCI = 1,
 	MOXA_BOARD_C218_ISA,
@@ -96,11 +83,11 @@ static char *moxa_brdname[] =
 
 #ifdef CONFIG_PCI
 static struct pci_device_id moxa_pcibrds[] = {
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C218, PCI_ANY_ID, PCI_ANY_ID, 
+	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218, PCI_ANY_ID, PCI_ANY_ID, 
 	  0, 0, MOXA_BOARD_C218_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_C320, PCI_ANY_ID, PCI_ANY_ID, 
+	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320, PCI_ANY_ID, PCI_ANY_ID, 
 	  0, 0, MOXA_BOARD_C320_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_CP204J, PCI_ANY_ID, PCI_ANY_ID, 
+	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP204J, PCI_ANY_ID, PCI_ANY_ID, 
 	  0, 0, MOXA_BOARD_CP204J },
 	{ 0 }
 };
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 52d1e41..b9bf441 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1809,6 +1809,9 @@
 #define PCI_DEVICE_ID_MOXA_C168		0x1680
 #define PCI_DEVICE_ID_MOXA_CP168U	0x1681
 #define PCI_DEVICE_ID_MOXA_CP168EL	0x1682
+#define PCI_DEVICE_ID_MOXA_CP204J	0x2040
+#define PCI_DEVICE_ID_MOXA_C218		0x2180
+#define PCI_DEVICE_ID_MOXA_C320		0x3200
 
 #define PCI_VENDOR_ID_CCD		0x1397
 #define PCI_DEVICE_ID_CCD_2BD0		0x2bd0

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/8] Char: moxa, use PCI_DEVICE
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
                   ` (4 preceding siblings ...)
  2006-12-31  1:05 ` [PATCH 6/8] Char: moxa, devids cleanup Jiri Slaby
@ 2006-12-31  1:05 ` Jiri Slaby
  2006-12-31  1:05 ` [PATCH 8/8] Char: moxa, eliminate typedefs Jiri Slaby
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, use PCI_DEVICE

Use PCI_DEVICE macro in pci_device_id list.

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

---
commit 5b7f53b3500ebd3aa2cc25bb68fdcd88af3643c0
tree 8392124992e5eeb1eaad6f652468f1b1caa65dac
parent 9e4d8826dd1dbaa7bb9d520b02da25a5a5cefa13
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:56:01 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:56:01 +0059

 drivers/char/moxa.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 5c0c0e6..a0eb088 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -83,12 +83,12 @@ static char *moxa_brdname[] =
 
 #ifdef CONFIG_PCI
 static struct pci_device_id moxa_pcibrds[] = {
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218, PCI_ANY_ID, PCI_ANY_ID, 
-	  0, 0, MOXA_BOARD_C218_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320, PCI_ANY_ID, PCI_ANY_ID, 
-	  0, 0, MOXA_BOARD_C320_PCI },
-	{ PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP204J, PCI_ANY_ID, PCI_ANY_ID, 
-	  0, 0, MOXA_BOARD_CP204J },
+	{ PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218),
+		.driver_data = MOXA_BOARD_C218_PCI },
+	{ PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320),
+		.driver_data = MOXA_BOARD_C320_PCI },
+	{ PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP204J),
+		.driver_data = MOXA_BOARD_CP204J },
 	{ 0 }
 };
 MODULE_DEVICE_TABLE(pci, moxa_pcibrds);

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 8/8] Char: moxa, eliminate typedefs
  2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
                   ` (5 preceding siblings ...)
  2006-12-31  1:05 ` [PATCH 7/8] Char: moxa, use PCI_DEVICE Jiri Slaby
@ 2006-12-31  1:05 ` Jiri Slaby
  6 siblings, 0 replies; 8+ messages in thread
From: Jiri Slaby @ 2006-12-31  1:05 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

moxa, eliminate typedefs

Do not use typedefs, use directly struct <something> instead.

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

---
commit 5eb77a193f47ab2a0ed35c7f949f103e740b24dc
tree a815e0033c9707e5df2ebee36c9acf32cf7cf6f8
parent 5b7f53b3500ebd3aa2cc25bb68fdcd88af3643c0
author Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:59:54 +0059
committer Jiri Slaby <jirislaby@gmail.com> Sun, 31 Dec 2006 01:59:54 +0059

 drivers/char/moxa.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index a0eb088..42de5bf 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -94,32 +94,32 @@ static struct pci_device_id moxa_pcibrds[] = {
 MODULE_DEVICE_TABLE(pci, moxa_pcibrds);
 #endif /* CONFIG_PCI */
 
-typedef struct _moxa_isa_board_conf {
+struct moxa_isa_board_conf {
 	int boardType;
 	int numPorts;
 	unsigned long baseAddr;
-} moxa_isa_board_conf;
+};
 
-static moxa_isa_board_conf moxa_isa_boards[] =
+static struct moxa_isa_board_conf moxa_isa_boards[] =
 {
 /*       {MOXA_BOARD_C218_ISA,8,0xDC000}, */
 };
 
-typedef struct _moxa_pci_devinfo {
+struct moxa_pci_devinfo {
 	ushort busNum;
 	ushort devNum;
 	struct pci_dev *pdev;
-} moxa_pci_devinfo;
+};
 
-typedef struct _moxa_board_conf {
+struct moxa_board_conf {
 	int boardType;
 	int numPorts;
 	unsigned long baseAddr;
 	int busType;
-	moxa_pci_devinfo pciInfo;
-} moxa_board_conf;
+	struct moxa_pci_devinfo pciInfo;
+};
 
-static moxa_board_conf moxa_boards[MAX_BOARDS];
+static struct moxa_board_conf moxa_boards[MAX_BOARDS];
 static void __iomem *moxaBaseAddr[MAX_BOARDS];
 static int loadstat[MAX_BOARDS];
 
@@ -273,7 +273,8 @@ static struct timer_list moxaEmptyTimer[MAX_PORTS];
 static DEFINE_SPINLOCK(moxa_lock);
 
 #ifdef CONFIG_PCI
-static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf * board)
+static int moxa_get_PCI_conf(struct pci_dev *p, int board_type,
+		struct moxa_board_conf *board)
 {
 	board->baseAddr = pci_resource_start (p, 2);
 	board->boardType = board_type;
@@ -1369,7 +1370,6 @@ struct mon_str {
 	int rxcnt[MAX_PORTS];
 	int txcnt[MAX_PORTS];
 };
-typedef struct mon_str mon_st;
 
 #define 	DCD_changed	0x01
 #define 	DCD_oldstate	0x80
@@ -1386,7 +1386,7 @@ static char moxaDCDState[MAX_PORTS];
 static char moxaLowChkFlag[MAX_PORTS];
 static int moxaLowWaterChk;
 static int moxaCard;
-static mon_st moxaLog;
+static struct mon_str moxaLog;
 static int moxaFuncTout = HZ / 2;
 static ushort moxaBreakCnt[MAX_PORTS];
 
@@ -1485,7 +1485,8 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
 	}
 	switch (cmd) {
 	case MOXA_GET_CONF:
-		if(copy_to_user(argp, &moxa_boards, MAX_BOARDS * sizeof(moxa_board_conf)))
+		if(copy_to_user(argp, &moxa_boards, MAX_BOARDS *
+				sizeof(struct moxa_board_conf)))
 			return -EFAULT;
 		return (0);
 	case MOXA_INIT_DRIVER:
@@ -1494,7 +1495,7 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
 		return (0);
 	case MOXA_GETDATACOUNT:
 		moxaLog.tick = jiffies;
-		if(copy_to_user(argp, &moxaLog, sizeof(mon_st)))
+		if(copy_to_user(argp, &moxaLog, sizeof(struct mon_str)))
 			return -EFAULT;
 		return (0);
 	case MOXA_FLUSH_QUEUE:

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-12-31  1:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-31  1:04 [PATCH 1/8] Char: moxa, remove unused allocated page Jiri Slaby
2006-12-31  1:04 ` [PATCH 2/8] Char: moxa, do not initialize global static Jiri Slaby
2006-12-31  1:04 ` [PATCH 3/8] Char: moxa, timers cleanup Jiri Slaby
2006-12-31  1:04 ` [PATCH 4/8] Char: moxa, remove hangup bottomhalf Jiri Slaby
2006-12-31  1:05 ` [PATCH 5/8] Char: moxa, remove unused functions Jiri Slaby
2006-12-31  1:05 ` [PATCH 6/8] Char: moxa, devids cleanup Jiri Slaby
2006-12-31  1:05 ` [PATCH 7/8] Char: moxa, use PCI_DEVICE Jiri Slaby
2006-12-31  1:05 ` [PATCH 8/8] Char: moxa, eliminate typedefs Jiri Slaby

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.