Skip to contentSkip to conversation

Implment a tty port structure and supporting logic

PATCH In review Alan Cox 5 participants 32 messages May 19, 2008 – May 27, 2008

Subsystems (5)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

cover Implment a tty port structure and supporting logic

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

---

Alan Cox (20):
whiteheat: fix bugs found in the tidy and audit
whiteheat: coding style
tty: add more tty_port fields
riscom8: remove bogus checks
usb_serial: API all change
serial: use tty_port
gs: use tty_port
cyclades: use tty_port
stallion: use tty_port
istallion: use tty_port
esp: use tty_port
synclink: use tty_port
rocket: use tty_port
riscom8: use tty_port
mxser: use tty_port
moxa: use tty_port
isicom: use tty_port
epca: use tty_port
tty: Clean up tiocmset
tty: Introduce a tty_port common structure

 MAINTAINERS                           |   72 +
 drivers/char/cyclades.c               |  341 +++---
 drivers/char/epca.c                   |  106 +-
 drivers/char/epca.h                   |    7 
 drivers/char/esp.c                    |  272 ++---
 drivers/char/generic_serial.c         |  158 +--
 drivers/char/isicom.c                 |  207 ++--
 drivers/char/istallion.c              |  116 +-
 drivers/char/moxa.c                   |   93 +-
 drivers/char/mxser.c                  |  284 ++---
 drivers/char/rio/rio_linux.c          |   20 
 drivers/char/rio/riocmd.c             |   10 
 drivers/char/rio/riointr.c            |   10 
 drivers/char/rio/rioparam.c           |    2 
 drivers/char/rio/riotty.c             |   16 
 drivers/char/riscom8.c                |  187 +--
 drivers/char/riscom8.h                |   10 
 drivers/char/rocket.c                 |  139 +-
 drivers/char/rocket.h                 |    4 
 drivers/char/rocket_int.h             |   11 
 drivers/char/specialix.c              |  153 +--
 drivers/char/specialix_io8.h          |    8 
 drivers/char/stallion.c               |  160 +--
 drivers/char/sx.c                     |  115 +-
 drivers/char/synclink.c               |  209 ++--
 drivers/char/synclink_gt.c            |  215 ++--
 drivers/char/synclinkmp.c             |  215 ++--
 drivers/char/tty_io.c                 |   87 +
 drivers/serial/8250.c                 |    2 
 drivers/serial/jsm/jsm_neo.c          |    2 
 drivers/serial/jsm/jsm_tty.c          |    8 
 drivers/serial/serial_core.c          |   80 +
 drivers/usb/serial/Kconfig            |    8 
 drivers/usb/serial/aircable.c         |   19 
 drivers/usb/serial/airprime.c         |   16 
 drivers/usb/serial/ark3116.c          |   32 -
 drivers/usb/serial/belkin_sa.c        |   69 -
 drivers/usb/serial/ch341.c            |   10 
 drivers/usb/serial/console.c          |   34 -
 drivers/usb/serial/cp2101.c           |   73 +
 drivers/usb/serial/cyberjack.c        |   47 -
 drivers/usb/serial/cypress_m8.c       |  117 +-
 drivers/usb/serial/digi_acceleport.c  |  127 +-
 drivers/usb/serial/empeg.c            |   78 +
 drivers/usb/serial/ezusb.c            |   22 
 drivers/usb/serial/ftdi_sio.c         |  213 ++--
 drivers/usb/serial/garmin_gps.c       |   58 -
 drivers/usb/serial/generic.c          |   39 -
 drivers/usb/serial/io_edgeport.c      |  175 +--
 drivers/usb/serial/io_fw_down3.h      |   11 
 drivers/usb/serial/io_ti.c            | 1924 +++++++++++++++------------------
 drivers/usb/serial/ipaq.c             |   48 -
 drivers/usb/serial/ipw.c              |   15 
 drivers/usb/serial/ir-usb.c           |   35 -
 drivers/usb/serial/iuu_phoenix.c      |   43 -
 drivers/usb/serial/keyspan.c          |  138 +-
 drivers/usb/serial/keyspan.h          |   39 -
 drivers/usb/serial/keyspan_pda.c      |   69 -
 drivers/usb/serial/kl5kusb105.c       |   74 +
 drivers/usb/serial/kobil_sct.c        |   80 +
 drivers/usb/serial/mct_u232.c         |  121 +-
 drivers/usb/serial/mos7720.c          |   87 +
 drivers/usb/serial/mos7840.c          |  165 +--
 drivers/usb/serial/navman.c           |   10 
 drivers/usb/serial/omninet.c          |   26 
 drivers/usb/serial/option.c           |  105 +-
 drivers/usb/serial/oti6858.c          |  119 +-
 drivers/usb/serial/pl2303.c           |   76 +
 drivers/usb/serial/safe_serial.c      |   14 
 drivers/usb/serial/sierra.c           |   93 --
 drivers/usb/serial/spcp8x5.c          |   69 +
 drivers/usb/serial/ti_fw_3410.h       |    4 
 drivers/usb/serial/ti_fw_5052.h       |    5 
 drivers/usb/serial/ti_usb_3410_5052.c |  214 ++--
 drivers/usb/serial/usb-serial.c       |   82 +
 drivers/usb/serial/visor.c            |   66 -
 drivers/usb/serial/whiteheat.c        |  446 ++++----
 drivers/usb/serial/whiteheat.h        |   78 +
 include/linux/cyclades.h              |   13 
 include/linux/generic_serial.h        |    8 
 include/linux/hayesesp.h              |    9 
 include/linux/istallion.h             |    6 
 include/linux/serial_core.h           |   26 
 include/linux/stallion.h              |    6 
 include/linux/tty.h                   |   31 +
 include/linux/usb/serial.h            |   56 +
 86 files changed, 4252 insertions(+), 4615 deletions(-)
Signature · 1 line
/dev/pithy_wit: End of file
author
#1 lore raw

PATCH 1/20 tty: Introduce a tty_port common structure

From: Alan Cox <[email protected]>

Every tty driver has its own concept of a port structure and because they all differ we cannot extract commonality. Begin fixing this by creating a structure drivers can elect to use so that over time we can push fields into this and create commonality and then introduce common methods.
---

 drivers/char/tty_io.c |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/tty.h   |   29 +++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
drivers/char/tty_io.c +37 -0
index 49c1a22..fb17b18 100644
@@ -2004,6 +2004,43 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
 	return tty_write(file, buf, count, ppos);
 }
 
+void tty_port_init(struct tty_port *port)
+{
+	memset(port, 0, sizeof(*port));
+	init_waitqueue_head(&port->open_wait);
+	init_waitqueue_head(&port->close_wait);
+	mutex_init(&port->mutex);
+}
+
+EXPORT_SYMBOL(tty_port_init);
+
+int tty_port_alloc_xmit_buf(struct tty_port *port)
+{
+	/* We may sleep in get_zeroed_page() */
+	mutex_lock(&port->mutex);
+	if (port->xmit_buf == NULL)
+		port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL);
+	mutex_unlock(&port->mutex);
+	if (port->xmit_buf == NULL)
+		return -ENOMEM;
+	return 0;
+}
+
+EXPORT_SYMBOL(tty_port_alloc_xmit_buf);
+
+void tty_port_free_xmit_buf(struct tty_port *port)
+{
+	mutex_lock(&port->mutex);
+	if (port->xmit_buf != NULL) {
+		free_page((unsigned long)port->xmit_buf);
+		port->xmit_buf = NULL;
+	}
+	mutex_unlock(&port->mutex);
+}
+
+EXPORT_SYMBOL(tty_port_free_xmit_buf);
+
+
 static char ptychar[] = "pqrstuvwxyzabcde";
 
 /**
include/linux/tty.h +29 -0
index 7f7121f..a5dc3e9 100644
@@ -166,6 +166,30 @@ struct tty_bufhead {
 
 struct device;
 struct signal_struct;
+
+/*
+ * Port level information. Each device keeps its own port level information
+ * so provide a common structure for those ports wanting to use common support
+ * routines.
+ *
+ * The tty port has a different lifetime to the tty so must be kept apart.
+ * In addition be careful as tty -> port mappings are valid for the life
+ * of the tty object but in many cases port -> tty mappings are valid only
+ * until a hangup so don't use the wrong path.
+ */
+ 
+struct tty_port
+{
+	struct tty_struct	*tty;		/* Back pointer */
+	int			blocked_open;	/* Waiting to open */
+	int			count;		/* Usage count */
+	wait_queue_head_t	open_wait;	/* Open waiters */
+	wait_queue_head_t	close_wait;	/* Close waiters */
+	unsigned long		flags;		/* TTY flags ASY_*/
+	struct mutex		mutex;		/* Locking */
+	unsigned char		*xmit_buf;	/* Optional buffer */
+};
+
 /*
  * Where all of the state associated with a tty is kept while the tty
  * is open.  Since the termios state should be kept even if the tty
@@ -241,6 +265,7 @@ struct tty_struct {
 	spinlock_t read_lock;
 	/* If the tty has a pending do_SAK, queue it here - akpm */
 	struct work_struct SAK_work;
+	struct tty_port *port;
 };
 
 /* tty magic number */
@@ -351,6 +376,10 @@ extern void tty_write_unlock(struct tty_struct *tty);
 extern int tty_write_lock(struct tty_struct *tty, int ndelay);
 #define tty_is_writelocked(tty)  (mutex_is_locked(&tty->atomic_write_lock))
 
+extern void tty_port_init(struct tty_port *port);
+extern int tty_port_alloc_xmit_buf(struct tty_port *port);
+extern void tty_port_free_xmit_buf(struct tty_port *port);
+
 
 
 /* n_tty.c */
#2 lore raw

Re: [PATCH 01/20] tty: Introduce a tty_port common structure

Hi Alan.

Quoted 20 lines · Alan Cox

From: Alan Cox <[email protected]>

Every tty driver has its own concept of a port structure and because they all differ we cannot extract commonality. Begin fixing this by creating a structure drivers can elect to use so that over time we can push fields into this and create commonality and then introduce common methods.
---

 drivers/char/tty_io.c |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/tty.h   |   29 +++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
drivers/char/tty_io.c +0 -0
index 49c1a22..fb17b18 100644
@@ -2004,6 +2004,43 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
 	return tty_write(file, buf, count, ppos);
 }

drivers/char/tty_io.c ssize_t redirected_tty_write(struct file *file, const char __user *buf, · line 2015

Quoted 10 lines
drivers/char/tty_io.c +9 -0
 
+void tty_port_init(struct tty_port *port)
+{
+	memset(port, 0, sizeof(*port));
+	init_waitqueue_head(&port->open_wait);
+	init_waitqueue_head(&port->close_wait);
+	mutex_init(&port->mutex);
+}
+
+EXPORT_SYMBOL(tty_port_init);

A small nitpick...
The typical style is to let the EXPORT_SYMBOL follow the closing brace with no extra empty line.

Sam

#3 lore raw

Re: [PATCH 01/20] tty: Introduce a tty_port common structure

Quoted 24 lines · Sam Ravnborg

Hi Alan.

Quoted 21 lines · Alan Cox

From: Alan Cox <[email protected]>

Every tty driver has its own concept of a port structure and because they all differ we cannot extract commonality. Begin fixing this by creating a structure drivers can elect to use so that over time we can push fields into this and create commonality and then introduce common methods.
---

 drivers/char/tty_io.c |   37 +++++++++++++++++++++++++++++++++++++
 include/linux/tty.h   |   29 +++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
drivers/char/tty_io.c +0 -0
index 49c1a22..fb17b18 100644
@@ -2004,6 +2004,43 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
 	return tty_write(file, buf, count, ppos);
 }
 
Quoted 12 lines

drivers/char/tty_io.c ssize_t redirected_tty_write(struct file *file, const char __user *buf, · line 2015

Quoted 9 lines
drivers/char/tty_io.c +9 -0
+void tty_port_init(struct tty_port *port)
+{
+	memset(port, 0, sizeof(*port));
+	init_waitqueue_head(&port->open_wait);
+	init_waitqueue_head(&port->close_wait);
+	mutex_init(&port->mutex);
+}
+
+EXPORT_SYMBOL(tty_port_init);

A small nitpick...
The typical style is to let the EXPORT_SYMBOL follow the closing brace with no extra empty line.

I'll run them through checkpatch.pl and fix up any minor things like this before sending them off, that's part of my normal patch-queue process :)

thanks,

greg k-h

author
#4 lore raw

Re: [PATCH 01/20] tty: Introduce a tty_port common structure

Quoted 7 lines · On Mon, 19 May 2008 10:51:21 -0700 Greg KH <[email protected]> wrote:
Quoted 3 lines · Sam Ravnborg

Hi Alan.

On Mon, May 19, 2008 at 03:50:13PM +0100, Alan Cox wrote:

I'll run them through checkpatch.pl and fix up any minor things like this before sending them off, that's part of my normal patch-queue process :)

Please do *NOT* do that. It messes up resolving them against pending and further patches that are not upstream. If you insist on doing that then I will submit the patches myself via a different tree which does not.

By all means report cases where checkpatch isn't clean on them and send me diffs to go back via my devel tree however.

Alan

#5 lore raw

Re: [PATCH 01/20] tty: Introduce a tty_port common structure

Quoted 11 lines · Alan Cox
Quoted 7 lines · On Mon, 19 May 2008 10:51:21 -0700 Greg KH <[email protected]> wrote:
Quoted 3 lines · Sam Ravnborg

Hi Alan.

On Mon, May 19, 2008 at 03:50:13PM +0100, Alan Cox wrote:

I'll run them through checkpatch.pl and fix up any minor things like this before sending them off, that's part of my normal patch-queue process :)

Quoted 6 lines

Please do *NOT* do that. It messes up resolving them against pending and further patches that are not upstream. If you insist on doing that then I will submit the patches myself via a different tree which does not.

By all means report cases where checkpatch isn't clean on them and send me diffs to go back via my devel tree however.

Ok, will do, I understand. I think that one mention of an exported symbol will be flagged, I'll let you know about any further ones.

thanks,

greg k-h

author
#6 lore raw

PATCH 2/20 tty: Clean up tiocmset

In reply to Alan Cox

From: Alan Cox <[email protected]>

Reverse the order of one test and it gets much more readable
---

 drivers/char/tty_io.c |   48 ++++++++++++++++++++++--------------------------
 1 files changed, 22 insertions(+), 26 deletions(-)
drivers/char/tty_io.c +22 -26
index fb17b18..31ab8f0 100644
@@ -3402,35 +3402,31 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
 static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd,
 	     unsigned __user *p)
 {
-	int retval = -EINVAL;
-
-	if (tty->ops->tiocmset) {
-		unsigned int set, clear, val;
-
-		retval = get_user(val, p);
-		if (retval)
-			return retval;
-
-		set = clear = 0;
-		switch (cmd) {
-		case TIOCMBIS:
-			set = val;
-			break;
-		case TIOCMBIC:
-			clear = val;
-			break;
-		case TIOCMSET:
-			set = val;
-			clear = ~val;
-			break;
-		}
+	int retval;
+	unsigned int set, clear, val;
 
-		set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
-		clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+	if (tty->ops->tiocmset == NULL)
+		return -EINVAL;
 
-		retval = tty->ops->tiocmset(tty, file, set, clear);
+	retval = get_user(val, p);
+	if (retval)
+		return retval;
+	set = clear = 0;
+	switch (cmd) {
+	case TIOCMBIS:
+		set = val;
+		break;
+	case TIOCMBIC:
+		clear = val;
+		break;
+	case TIOCMSET:
+		set = val;
+		clear = ~val;
+		break;
 	}
-	return retval;
+	set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+	clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+	return tty->ops->tiocmset(tty, file, set, clear);
 }
 
 /*
author
#7 lore raw

PATCH 3/20 epca: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch the EPCA driver to include and begin using a tty_port structure
---

 drivers/char/epca.c |  106 ++++++++++++++++++++++++++-------------------------
 drivers/char/epca.h |    7 ---
 2 files changed, 54 insertions(+), 59 deletions(-)
drivers/char/epca.c +53 -53
index 60a4df7..d26752b 100644
@@ -432,7 +432,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
 			spin_unlock_irqrestore(&epca_lock, flags);
 			return;
 		}
-		if (ch->count-- > 1)  {
+		if (ch->port.count-- > 1)  {
 			/* Begin channel is open more than once */
 			/*
 			 * Return without doing anything. Someone might still
@@ -442,19 +442,19 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
 			return;
 		}
 		/* Port open only once go ahead with shutdown & reset */
-		BUG_ON(ch->count < 0);
+		BUG_ON(ch->port.count < 0);
 
 		/*
 		 * Let the rest of the driver know the channel is being closed.
 		 * This becomes important if an open is attempted before close
 		 * is finished.
 		 */
-		ch->asyncflags |= ASYNC_CLOSING;
+		ch->port.flags |= ASYNC_CLOSING;
 		tty->closing = 1;
 
 		spin_unlock_irqrestore(&epca_lock, flags);
 
-		if (ch->asyncflags & ASYNC_INITIALIZED)  {
+		if (ch->port.flags & ASYNC_INITIALIZED)  {
 			/* Setup an event to indicate when the
 			   transmit buffer empties */
 			setup_empty_event(tty, ch);
@@ -469,17 +469,17 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
 		spin_lock_irqsave(&epca_lock, flags);
 		tty->closing = 0;
 		ch->event = 0;
-		ch->tty = NULL;
+		ch->port.tty = NULL;
 		spin_unlock_irqrestore(&epca_lock, flags);
 
-		if (ch->blocked_open) {
+		if (ch->port.blocked_open) {
 			if (ch->close_delay)
 				msleep_interruptible(jiffies_to_msecs(ch->close_delay));
-			wake_up_interruptible(&ch->open_wait);
+			wake_up_interruptible(&ch->port.open_wait);
 		}
-		ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
+		ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
 					ASYNC_CLOSING);
-		wake_up_interruptible(&ch->close_wait);
+		wake_up_interruptible(&ch->port.close_wait);
 	}
 }
 
@@ -489,7 +489,7 @@ static void shutdown(struct channel *ch)
 	struct tty_struct *tty;
 	struct board_chan __iomem *bc;
 
-	if (!(ch->asyncflags & ASYNC_INITIALIZED))
+	if (!(ch->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	spin_lock_irqsave(&epca_lock, flags);
@@ -504,7 +504,7 @@ static void shutdown(struct channel *ch)
 	 */
 	if (bc)
 		writeb(0, &bc->idata);
-	tty = ch->tty;
+	tty = ch->port.tty;
 
 	/* If we're a modem control device and HUPCL is on, drop RTS & DTR. */
 	if (tty->termios->c_cflag & HUPCL)  {
@@ -518,7 +518,7 @@ static void shutdown(struct channel *ch)
 	 * will have to reinitialized. Set a flag to indicate this.
 	 */
 	/* Prevent future Digi programmed interrupts from coming active */
-	ch->asyncflags &= ~ASYNC_INITIALIZED;
+	ch->port.flags &= ~ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&epca_lock, flags);
 }
 
@@ -538,12 +538,12 @@ static void pc_hangup(struct tty_struct *tty)
 		shutdown(ch);
 
 		spin_lock_irqsave(&epca_lock, flags);
-		ch->tty   = NULL;
+		ch->port.tty   = NULL;
 		ch->event = 0;
-		ch->count = 0;
-		ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
+		ch->port.count = 0;
+		ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED);
 		spin_unlock_irqrestore(&epca_lock, flags);
-		wake_up_interruptible(&ch->open_wait);
+		wake_up_interruptible(&ch->port.open_wait);
 	}
 }
 
@@ -795,7 +795,7 @@ static int block_til_ready(struct tty_struct *tty,
 	unsigned long flags;
 
 	if (tty_hung_up_p(filp)) {
-		if (ch->asyncflags & ASYNC_HUP_NOTIFY)
+		if (ch->port.flags & ASYNC_HUP_NOTIFY)
 			retval = -EAGAIN;
 		else
 			retval = -ERESTARTSYS;
@@ -806,10 +806,10 @@ static int block_til_ready(struct tty_struct *tty,
 	 * If the device is in the middle of being closed, then block until
 	 * it's done, and then try again.
 	 */
-	if (ch->asyncflags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&ch->close_wait);
+	if (ch->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&ch->port.close_wait);
 
-		if (ch->asyncflags & ASYNC_HUP_NOTIFY)
+		if (ch->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		else
 			return -ERESTARTSYS;
@@ -820,7 +820,7 @@ static int block_til_ready(struct tty_struct *tty,
 		 * If non-blocking mode is set, then make the check up front
 		 * and then exit.
 		 */
-		ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
+		ch->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 	if (tty->termios->c_cflag & CLOCAL)
@@ -828,24 +828,24 @@ static int block_til_ready(struct tty_struct *tty,
 	/* Block waiting for the carrier detect and the line to become free */
 
 	retval = 0;
-	add_wait_queue(&ch->open_wait, &wait);
+	add_wait_queue(&ch->port.open_wait, &wait);
 
 	spin_lock_irqsave(&epca_lock, flags);
 	/* We dec count so that pc_close will know when to free things */
 	if (!tty_hung_up_p(filp))
-		ch->count--;
-	ch->blocked_open++;
+		ch->port.count--;
+	ch->port.blocked_open++;
 	while (1) {
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (tty_hung_up_p(filp) ||
-				!(ch->asyncflags & ASYNC_INITIALIZED)) {
-			if (ch->asyncflags & ASYNC_HUP_NOTIFY)
+				!(ch->port.flags & ASYNC_INITIALIZED)) {
+			if (ch->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
 			break;
 		}
-		if (!(ch->asyncflags & ASYNC_CLOSING) &&
+		if (!(ch->port.flags & ASYNC_CLOSING) &&
 			  (do_clocal || (ch->imodem & ch->dcd)))
 			break;
 		if (signal_pending(current)) {
@@ -864,17 +864,17 @@ static int block_til_ready(struct tty_struct *tty,
 	}
 
 	__set_current_state(TASK_RUNNING);
-	remove_wait_queue(&ch->open_wait, &wait);
+	remove_wait_queue(&ch->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp))
-		ch->count++;
-	ch->blocked_open--;
+		ch->port.count++;
+	ch->port.blocked_open--;
 
 	spin_unlock_irqrestore(&epca_lock, flags);
 
 	if (retval)
 		return retval;
 
-	ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
+	ch->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -933,7 +933,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
 	 * necessary because we do not wish to flush and shutdown the channel
 	 * until the last app holding the channel open, closes it.
 	 */
-	ch->count++;
+	ch->port.count++;
 	/*
 	 * Set a kernel structures pointer to our local channel structure. This
 	 * way we can get to it when passed only a tty struct.
@@ -957,14 +957,14 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
 	writew(head, &bc->rout);
 
 	/* Set the channels associated tty structure */
-	ch->tty = tty;
+	ch->port.tty = tty;
 
 	/*
 	 * The below routine generally sets up parity, baud, flow control
 	 * issues, etc.... It effect both control flags and input flags.
 	 */
 	epcaparam(tty, ch);
-	ch->asyncflags |= ASYNC_INITIALIZED;
+	ch->port.flags |= ASYNC_INITIALIZED;
 	memoff(ch);
 	spin_unlock_irqrestore(&epca_lock, flags);
 
@@ -976,7 +976,7 @@ static int pc_open(struct tty_struct *tty, struct file *filp)
 	 * waiting for the line...
 	 */
 	spin_lock_irqsave(&epca_lock, flags);
-	ch->tty = tty;
+	ch->port.tty = tty;
 	globalwinon(ch);
 	/* Enable Digi Data events */
 	writeb(1, &bc->idata);
@@ -1017,8 +1017,8 @@ static void __exit epca_module_exit(void)
 		}
 		ch = card_ptr[crd];
 		for (count = 0; count < bd->numports; count++, ch++) {
-			if (ch && ch->tty)
-				tty_hangup(ch->tty);
+			if (ch && ch->port.tty)
+				tty_hangup(ch->port.tty);
 		}
 	}
 	pci_unregister_driver(&epca_driver);
@@ -1427,7 +1427,7 @@ static void post_fep_init(unsigned int crd)
 		ch->boardnum   = crd;
 		ch->channelnum = i;
 		ch->magic      = EPCA_MAGIC;
-		ch->tty        = NULL;
+		ch->port.tty        = NULL;
 
 		if (shrinkmem) {
 			fepcmd(ch, SETBUFFER, 32, 0, 0, 0);
@@ -1510,10 +1510,10 @@ static void post_fep_init(unsigned int crd)
 		ch->fepstopca = 0;
 
 		ch->close_delay = 50;
-		ch->count = 0;
-		ch->blocked_open = 0;
-		init_waitqueue_head(&ch->open_wait);
-		init_waitqueue_head(&ch->close_wait);
+		ch->port.count = 0;
+		ch->port.blocked_open = 0;
+		init_waitqueue_head(&ch->port.open_wait);
+		init_waitqueue_head(&ch->port.close_wait);
 
 		spin_unlock_irqrestore(&epca_lock, flags);
 	}
@@ -1633,15 +1633,15 @@ static void doevent(int crd)
 		if (event & MODEMCHG_IND) {
 			/* A modem signal change has been indicated */
 			ch->imodem = mstat;
-			if (ch->asyncflags & ASYNC_CHECK_CD) {
+			if (ch->port.flags & ASYNC_CHECK_CD) {
 				/* We are now receiving dcd */
 				if (mstat & ch->dcd)
-					wake_up_interruptible(&ch->open_wait);
+					wake_up_interruptible(&ch->port.open_wait);
 				else	/* No dcd; hangup */
 					pc_sched_event(ch, EPCA_EVENT_HANGUP);
 			}
 		}
-		tty = ch->tty;
+		tty = ch->port.tty;
 		if (tty) {
 			if (event & BREAK_IND) {
 				/* A break has been indicated */
@@ -1880,9 +1880,9 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
 		 * that the driver will wait on carrier detect.
 		 */
 		if (ts->c_cflag & CLOCAL)
-			ch->asyncflags &= ~ASYNC_CHECK_CD;
+			ch->port.flags &= ~ASYNC_CHECK_CD;
 		else
-			ch->asyncflags |= ASYNC_CHECK_CD;
+			ch->port.flags |= ASYNC_CHECK_CD;
 		mval = ch->m_dtr | ch->m_rts;
 	} /* End CBAUD not detected */
 	iflag = termios2digi_i(ch, ts->c_iflag);
@@ -1972,7 +1972,7 @@ static void receive_data(struct channel *ch)
 	globalwinon(ch);
 	if (ch->statusflags & RXSTOPPED)
 		return;
-	tty = ch->tty;
+	tty = ch->port.tty;
 	if (tty)
 		ts = tty->termios;
 	bc = ch->brdchan;
@@ -2032,7 +2032,7 @@ static void receive_data(struct channel *ch)
 	globalwinon(ch);
 	writew(tail, &bc->rout);
 	/* Must be called with global data */
-	tty_schedule_flip(ch->tty);
+	tty_schedule_flip(ch->port.tty);
 }
 
 static int info_ioctl(struct tty_struct *tty, struct file *file,
@@ -2376,7 +2376,7 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 
 		if (!(old_termios->c_cflag & CLOCAL) &&
 			 (tty->termios->c_cflag & CLOCAL))
-			wake_up_interruptible(&ch->open_wait);
+			wake_up_interruptible(&ch->port.open_wait);
 
 	} /* End if channel valid */
 }
@@ -2386,13 +2386,13 @@ static void do_softint(struct work_struct *work)
 	struct channel *ch = container_of(work, struct channel, tqueue);
 	/* Called in response to a modem change event */
 	if (ch && ch->magic == EPCA_MAGIC) {
-		struct tty_struct *tty = ch->tty;
+		struct tty_struct *tty = ch->port.tty;
 
 		if (tty && tty->driver_data) {
 			if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
 				tty_hangup(tty);
-				wake_up_interruptible(&ch->open_wait);
-				ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
+				wake_up_interruptible(&ch->port.open_wait);
+				ch->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 			}
 		}
 	}
drivers/char/epca.h +1 -6
index 3c77c02..d414bf2 100644
@@ -84,6 +84,7 @@ static char *board_desc[] =
 struct channel 
 {
 	long   magic;
+	struct tty_port port;
 	unsigned char boardnum;
 	unsigned char channelnum;
 	unsigned char omodem;         /* FEP output modem status     */
@@ -117,10 +118,7 @@ struct channel
 	unsigned short rxbufhead;
 	unsigned short rxbufsize;
 	int    close_delay;
-	int    count;
-	int    blocked_open;
 	unsigned long  event;
-	int    asyncflags;
 	uint   dev;
 	unsigned long  statusflags;
 	unsigned long  c_iflag;
@@ -132,9 +130,6 @@ struct channel
 	struct board_info           *board;
 	struct board_chan	    __iomem *brdchan;
 	struct digi_struct          digiext;
-	struct tty_struct           *tty;
-	wait_queue_head_t           open_wait;
-	wait_queue_head_t           close_wait;
 	struct work_struct          tqueue;
 	struct global_data 	    __iomem *mailbox;
 };
author
#8 lore raw

PATCH 4/20 isicom: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch isicom to use a tty_port structure for some fields
---

 drivers/char/isicom.c |  181 +++++++++++++++++++++----------------------------
 1 files changed, 79 insertions(+), 102 deletions(-)
drivers/char/isicom.c +79 -102
index 4f3cefa..20be56f 100644
@@ -198,17 +198,12 @@ struct	isi_board {
 
 struct	isi_port {
 	unsigned short		magic;
-	unsigned int		flags;
-	int			count;
-	int			blocked_open;
+	struct tty_port		port;
 	int			close_delay;
 	u16			channel;
 	u16			status;
 	u16			closing_wait;
 	struct isi_board	*card;
-	struct tty_struct 	*tty;
-	wait_queue_head_t	close_wait;
-	wait_queue_head_t	open_wait;
 	unsigned char		*xmit_buf;
 	int			xmit_head;
 	int			xmit_tail;
@@ -430,11 +425,11 @@ static void isicom_tx(unsigned long _data)
 
 	for (; count > 0; count--, port++) {
 		/* port not active or tx disabled to force flow control */
-		if (!(port->flags & ASYNC_INITIALIZED) ||
+		if (!(port->port.flags & ASYNC_INITIALIZED) ||
 				!(port->status & ISI_TXOK))
 			continue;
 
-		tty = port->tty;
+		tty = port->port.tty;
 
 		if (tty == NULL)
 			continue;
@@ -458,7 +453,7 @@ static void isicom_tx(unsigned long _data)
 			if (residue == YES) {
 				residue = NO;
 				if (cnt > 0) {
-					wrd |= (port->xmit_buf[port->xmit_tail]
+					wrd |= (port->port.xmit_buf[port->xmit_tail]
 									<< 8);
 					port->xmit_tail = (port->xmit_tail + 1)
 						& (SERIAL_XMIT_SIZE - 1);
@@ -474,14 +469,14 @@ static void isicom_tx(unsigned long _data)
 			if (cnt <= 0)
 				break;
 			word_count = cnt >> 1;
-			outsw(base, port->xmit_buf+port->xmit_tail, word_count);
+			outsw(base, port->port.xmit_buf+port->xmit_tail, word_count);
 			port->xmit_tail = (port->xmit_tail
 				+ (word_count << 1)) & (SERIAL_XMIT_SIZE - 1);
 			txcount -= (word_count << 1);
 			port->xmit_cnt -= (word_count << 1);
 			if (cnt & 0x0001) {
 				residue = YES;
-				wrd = port->xmit_buf[port->xmit_tail];
+				wrd = port->port.xmit_buf[port->xmit_tail];
 				port->xmit_tail = (port->xmit_tail + 1)
 					& (SERIAL_XMIT_SIZE - 1);
 				port->xmit_cnt--;
@@ -548,13 +543,13 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 		return IRQ_HANDLED;
 	}
 	port = card->ports + channel;
-	if (!(port->flags & ASYNC_INITIALIZED)) {
+	if (!(port->port.flags & ASYNC_INITIALIZED)) {
 		outw(0x0000, base+0x04); /* enable interrupts */
 		spin_unlock(&card->card_lock);
 		return IRQ_HANDLED;
 	}
 
-	tty = port->tty;
+	tty = port->port.tty;
 	if (tty == NULL) {
 		word_count = byte_count >> 1;
 		while (byte_count > 1) {
@@ -572,7 +567,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 		header = inw(base);
 		switch (header & 0xff) {
 		case 0:	/* Change in EIA signals */
-			if (port->flags & ASYNC_CHECK_CD) {
+			if (port->port.flags & ASYNC_CHECK_CD) {
 				if (port->status & ISI_DCD) {
 					if (!(header & ISI_DCD)) {
 					/* Carrier has been lost  */
@@ -585,7 +580,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 				/* Carrier has been detected */
 					pr_dbg("interrupt: DCD->high.\n");
 					port->status |= ISI_DCD;
-					wake_up_interruptible(&port->open_wait);
+					wake_up_interruptible(&port->port.open_wait);
 				}
 			} else {
 				if (header & ISI_DCD)
@@ -594,17 +589,17 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 					port->status &= ~ISI_DCD;
 			}
 
-			if (port->flags & ASYNC_CTS_FLOW) {
-				if (port->tty->hw_stopped) {
+			if (port->port.flags & ASYNC_CTS_FLOW) {
+				if (port->port.tty->hw_stopped) {
 					if (header & ISI_CTS) {
-						port->tty->hw_stopped = 0;
+						port->port.tty->hw_stopped = 0;
 						/* start tx ing */
 						port->status |= (ISI_TXOK
 							| ISI_CTS);
 						tty_wakeup(tty);
 					}
 				} else if (!(header & ISI_CTS)) {
-					port->tty->hw_stopped = 1;
+					port->port.tty->hw_stopped = 1;
 					/* stop tx ing */
 					port->status &= ~(ISI_TXOK | ISI_CTS);
 				}
@@ -629,7 +624,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
 
 		case 1:	/* Received Break !!! */
 			tty_insert_flip_char(tty, 0, TTY_BREAK);
-			if (port->flags & ASYNC_SAK)
+			if (port->port.flags & ASYNC_SAK)
 				do_SAK(tty);
 			tty_flip_buffer_push(tty);
 			break;
@@ -681,7 +676,7 @@ static void isicom_config_port(struct isi_port *port)
 		shift_count = card->shift_count;
 	unsigned char flow_ctrl;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	if (tty == NULL)
 		return;
@@ -697,7 +692,7 @@ static void isicom_config_port(struct isi_port *port)
 
 		/* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */
 		if (baud < 1 || baud > 4)
-			port->tty->termios->c_cflag &= ~CBAUDEX;
+			port->port.tty->termios->c_cflag &= ~CBAUDEX;
 		else
 			baud += 15;
 	}
@@ -708,13 +703,13 @@ static void isicom_config_port(struct isi_port *port)
 		 *  the 'setserial' utility.
 		 */
 
-		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			baud++; /*  57.6 Kbps */
-		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			baud += 2; /*  115  Kbps */
-		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			baud += 3; /* 230 kbps*/
-		if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			baud += 4; /* 460 kbps*/
 	}
 	if (linuxb_to_isib[baud] == -1) {
@@ -754,15 +749,15 @@ static void isicom_config_port(struct isi_port *port)
 		InterruptTheCard(base);
 	}
 	if (C_CLOCAL(tty))
-		port->flags &= ~ASYNC_CHECK_CD;
+		port->port.flags &= ~ASYNC_CHECK_CD;
 	else
-		port->flags |= ASYNC_CHECK_CD;
+		port->port.flags |= ASYNC_CHECK_CD;
 
 	/* flow control settings ...*/
 	flow_ctrl = 0;
-	port->flags &= ~ASYNC_CTS_FLOW;
+	port->port.flags &= ~ASYNC_CTS_FLOW;
 	if (C_CRTSCTS(tty)) {
-		port->flags |= ASYNC_CTS_FLOW;
+		port->port.flags |= ASYNC_CTS_FLOW;
 		flow_ctrl |= ISICOM_CTSRTS;
 	}
 	if (I_IXON(tty))
@@ -809,23 +804,15 @@ static int isicom_setup_port(struct isi_port *port)
 	struct isi_board *card = port->card;
 	unsigned long flags;
 
-	if (port->flags & ASYNC_INITIALIZED)
+	if (port->port.flags & ASYNC_INITIALIZED)
 		return 0;
-	if (!port->xmit_buf) {
-		/* Relies on BKL */
-		unsigned long page  = get_zeroed_page(GFP_KERNEL);
-		if (page == 0)
-			return -ENOMEM;
-		if (port->xmit_buf)
-			free_page(page);
-		else
-			port->xmit_buf = (unsigned char *) page;
-	}
+	if (tty_port_alloc_xmit_buf(&port->port) < 0)
+		return -ENOMEM;
 
 	spin_lock_irqsave(&card->card_lock, flags);
-	if (port->tty)
-		clear_bit(TTY_IO_ERROR, &port->tty->flags);
-	if (port->count == 1)
+	if (port->port.tty)
+		clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
+	if (port->port.count == 1)
 		card->count++;
 
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
@@ -839,7 +826,7 @@ static int isicom_setup_port(struct isi_port *port)
 	}
 
 	isicom_config_port(port);
-	port->flags |= ASYNC_INITIALIZED;
+	port->port.flags |= ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
 	return 0;
@@ -855,10 +842,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
 	/* block if port is in the process of being closed */
 
-	if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
+	if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
 		pr_dbg("block_til_ready: close in progress.\n");
-		interruptible_sleep_on(&port->close_wait);
-		if (port->flags & ASYNC_HUP_NOTIFY)
+		interruptible_sleep_on(&port->port.close_wait);
+		if (port->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		else
 			return -ERESTARTSYS;
@@ -869,7 +856,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	if ((filp->f_flags & O_NONBLOCK) ||
 			(tty->flags & (1 << TTY_IO_ERROR))) {
 		pr_dbg("block_til_ready: non-block mode.\n");
-		port->flags |= ASYNC_NORMAL_ACTIVE;
+		port->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -879,26 +866,26 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	/* block waiting for DCD to be asserted, and while
 						callout dev is busy */
 	retval = 0;
-	add_wait_queue(&port->open_wait, &wait);
+	add_wait_queue(&port->port.open_wait, &wait);
 
 	spin_lock_irqsave(&card->card_lock, flags);
 	if (!tty_hung_up_p(filp))
-		port->count--;
-	port->blocked_open++;
+		port->port.count--;
+	port->port.blocked_open++;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
 	while (1) {
 		raise_dtr_rts(port);
 
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
-			if (port->flags & ASYNC_HUP_NOTIFY)
+		if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) {
+			if (port->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
 			break;
 		}
-		if (!(port->flags & ASYNC_CLOSING) &&
+		if (!(port->port.flags & ASYNC_CLOSING) &&
 				(do_clocal || (port->status & ISI_DCD))) {
 			break;
 		}
@@ -909,15 +896,15 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		schedule();
 	}
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&port->open_wait, &wait);
+	remove_wait_queue(&port->port.open_wait, &wait);
 	spin_lock_irqsave(&card->card_lock, flags);
 	if (!tty_hung_up_p(filp))
-		port->count++;
-	port->blocked_open--;
+		port->port.count++;
+	port->port.blocked_open--;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 	if (retval)
 		return retval;
-	port->flags |= ASYNC_NORMAL_ACTIVE;
+	port->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -947,9 +934,9 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
 
 	isicom_setup_board(card);
 
-	port->count++;
+	port->port.count++;
 	tty->driver_data = port;
-	port->tty = tty;
+	port->port.tty = tty;
 	error = isicom_setup_port(port);
 	if (error == 0)
 		error = block_til_ready(tty, filp, port);
@@ -970,18 +957,15 @@ static void isicom_shutdown_port(struct isi_port *port)
 	struct isi_board *card = port->card;
 	struct tty_struct *tty;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
-	if (!(port->flags & ASYNC_INITIALIZED))
+	if (!(port->port.flags & ASYNC_INITIALIZED))
 		return;
 
-	if (port->xmit_buf) {
-		free_page((unsigned long) port->xmit_buf);
-		port->xmit_buf = NULL;
-	}
-	port->flags &= ~ASYNC_INITIALIZED;
+	tty_port_free_xmit_buf(&port->port);
+	port->port.flags &= ~ASYNC_INITIALIZED;
 	/* 3rd October 2000 : Vinayak P Risbud */
-	port->tty = NULL;
+	port->port.tty = NULL;
 
 	/*Fix done by Anil .S on 30-04-2001
 	remote login through isi port has dtr toggle problem
@@ -1046,24 +1030,24 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 		return;
 	}
 
-	if (tty->count == 1 && port->count != 1) {
+	if (tty->count == 1 && port->port.count != 1) {
 		printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port "
 			"count tty->count = 1 port count = %d.\n",
-			card->base, port->count);
-		port->count = 1;
+			card->base, port->port.count);
+		port->port.count = 1;
 	}
-	if (--port->count < 0) {
+	if (--port->port.count < 0) {
 		printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port "
 			"count for channel%d = %d", card->base, port->channel,
-			port->count);
-		port->count = 0;
+			port->port.count);
+		port->port.count = 0;
 	}
 
-	if (port->count) {
+	if (port->port.count) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
 		return;
 	}
-	port->flags |= ASYNC_CLOSING;
+	port->port.flags |= ASYNC_CLOSING;
 	tty->closing = 1;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
@@ -1072,7 +1056,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 	/* indicate to the card that no more data can be received
 	   on this port */
 	spin_lock_irqsave(&card->card_lock, flags);
-	if (port->flags & ASYNC_INITIALIZED) {
+	if (port->port.flags & ASYNC_INITIALIZED) {
 		card->port_status &= ~(1 << port->channel);
 		outw(card->port_status, card->base + 0x02);
 	}
@@ -1085,7 +1069,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 	spin_lock_irqsave(&card->card_lock, flags);
 	tty->closing = 0;
 
-	if (port->blocked_open) {
+	if (port->port.blocked_open) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
 		if (port->close_delay) {
 			pr_dbg("scheduling until time out.\n");
@@ -1093,10 +1077,10 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 				jiffies_to_msecs(port->close_delay));
 		}
 		spin_lock_irqsave(&card->card_lock, flags);
-		wake_up_interruptible(&port->open_wait);
+		wake_up_interruptible(&port->port.open_wait);
 	}
-	port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
-	wake_up_interruptible(&port->close_wait);
+	port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
+	wake_up_interruptible(&port->port.close_wait);
 	spin_unlock_irqrestore(&card->card_lock, flags);
 }
 
@@ -1112,9 +1096,6 @@ static int isicom_write(struct tty_struct *tty,	const unsigned char *buf,
 	if (isicom_paranoia_check(port, tty->name, "isicom_write"))
 		return 0;
 
-	if (!port->xmit_buf)
-		return 0;
-
 	spin_lock_irqsave(&card->card_lock, flags);
 
 	while (1) {
@@ -1123,7 +1104,7 @@ static int isicom_write(struct tty_struct *tty,	const unsigned char *buf,
 		if (cnt <= 0)
 			break;
 
-		memcpy(port->xmit_buf + port->xmit_head, buf, cnt);
+		memcpy(port->port.xmit_buf + port->xmit_head, buf, cnt);
 		port->xmit_head = (port->xmit_head + cnt) & (SERIAL_XMIT_SIZE
 			- 1);
 		port->xmit_cnt += cnt;
@@ -1147,16 +1128,13 @@ static int isicom_put_char(struct tty_struct *tty, unsigned char ch)
 	if (isicom_paranoia_check(port, tty->name, "isicom_put_char"))
 		return 0;
 
-	if (!port->xmit_buf)
-		return 0;
-
 	spin_lock_irqsave(&card->card_lock, flags);
 	if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
 		return 0;
 	}
 
-	port->xmit_buf[port->xmit_head++] = ch;
+	port->port.xmit_buf[port->xmit_head++] = ch;
 	port->xmit_head &= (SERIAL_XMIT_SIZE - 1);
 	port->xmit_cnt++;
 	spin_unlock_irqrestore(&card->card_lock, flags);
@@ -1172,7 +1150,7 @@ static void isicom_flush_chars(struct tty_struct *tty)
 		return;
 
 	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-			!port->xmit_buf)
+			!port->port.xmit_buf)
 		return;
 
 	/* this tells the transmitter to consider this port for
@@ -1274,23 +1252,23 @@ static int isicom_set_serial_info(struct isi_port *port,
 
 	lock_kernel();
 
-	reconfig_port = ((port->flags & ASYNC_SPD_MASK) !=
+	reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) !=
 		(newinfo.flags & ASYNC_SPD_MASK));
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((newinfo.close_delay != port->close_delay) ||
 				(newinfo.closing_wait != port->closing_wait) ||
 				((newinfo.flags & ~ASYNC_USR_MASK) !=
-				(port->flags & ~ASYNC_USR_MASK))) {
+				(port->port.flags & ~ASYNC_USR_MASK))) {
 			unlock_kernel();
 			return -EPERM;
 		}
-		port->flags = ((port->flags & ~ASYNC_USR_MASK) |
+		port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
 				(newinfo.flags & ASYNC_USR_MASK));
 	} else {
 		port->close_delay = newinfo.close_delay;
 		port->closing_wait = newinfo.closing_wait;
-		port->flags = ((port->flags & ~ASYNC_FLAGS) |
+		port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
 				(newinfo.flags & ASYNC_FLAGS));
 	}
 	if (reconfig_port) {
@@ -1314,7 +1292,7 @@ static int isicom_get_serial_info(struct isi_port *port,
 	out_info.line = port - isi_ports;
 	out_info.port = port->card->base;
 	out_info.irq = port->card->irq;
-	out_info.flags = port->flags;
+	out_info.flags = port->port.flags;
 /*	out_info.baud_base = ? */
 	out_info.close_delay = port->close_delay;
 	out_info.closing_wait = port->closing_wait;
@@ -1454,10 +1432,10 @@ static void isicom_hangup(struct tty_struct *tty)
 	isicom_shutdown_port(port);
 	spin_unlock_irqrestore(&port->card->card_lock, flags);
 
-	port->count = 0;
-	port->flags &= ~ASYNC_NORMAL_ACTIVE;
-	port->tty = NULL;
-	wake_up_interruptible(&port->open_wait);
+	port->port.count = 0;
+	port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	port->port.tty = NULL;
+	wake_up_interruptible(&port->port.open_wait);
 }
 
 
@@ -1824,8 +1802,7 @@ static int __init isicom_init(void)
 			port->close_delay = 50 * HZ/100;
 			port->closing_wait = 3000 * HZ/100;
 			port->status = 0;
-			init_waitqueue_head(&port->open_wait);
-			init_waitqueue_head(&port->close_wait);
+			tty_port_init(&port->port);
 			/*  . . .  */
 		}
 		isi_card[idx].base = 0;
author
#9 lore raw

PATCH 5/20 moxa: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch MOXA to use the new tty_port structure
---

 drivers/char/moxa.c |   87 +++++++++++++++++++++++++--------------------------
 1 files changed, 42 insertions(+), 45 deletions(-)
drivers/char/moxa.c +42 -45
index d57d3a6..bb9bcff 100644
@@ -130,17 +130,14 @@ struct moxaq_str {
 };
 
 struct moxa_port {
+	struct tty_port port;
 	struct moxa_board_conf *board;
-	struct tty_struct *tty;
 	void __iomem *tableAddr;
 
 	int type;
 	int close_delay;
-	unsigned int count;
-	int asyncflags;
 	int cflag;
 	unsigned long statusflags;
-	wait_queue_head_t open_wait;
 
 	u8 DCDState;
 	u8 lineCtrl;
@@ -348,10 +345,10 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
 				if (status & 4)
 					tmp.dcd = 1;
 
-				if (!p->tty || !p->tty->termios)
+				if (!p->port.tty || !p->port.tty->termios)
 					tmp.cflag = p->cflag;
 				else
-					tmp.cflag = p->tty->termios->c_cflag;
+					tmp.cflag = p->port.tty->termios->c_cflag;
 copy:
 				if (copy_to_user(argm, &tmp, sizeof(tmp))) {
 					mutex_unlock(&moxa_openlock);
@@ -828,7 +825,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
 		p->type = PORT_16550A;
 		p->close_delay = 5 * HZ / 10;
 		p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
-		init_waitqueue_head(&p->open_wait);
+		tty_port_init(&p->port);
 	}
 
 	switch (brd->boardType) {
@@ -884,12 +881,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)
 
 	/* pci hot-un-plug support */
 	for (a = 0; a < brd->numPorts; a++)
-		if (brd->ports[a].asyncflags & ASYNC_INITIALIZED)
-			tty_hangup(brd->ports[a].tty);
+		if (brd->ports[a].port.flags & ASYNC_INITIALIZED)
+			tty_hangup(brd->ports[a].port.tty);
 	while (1) {
 		opened = 0;
 		for (a = 0; a < brd->numPorts; a++)
-			if (brd->ports[a].asyncflags & ASYNC_INITIALIZED)
+			if (brd->ports[a].port.flags & ASYNC_INITIALIZED)
 				opened++;
 		mutex_unlock(&moxa_openlock);
 		if (!opened)
@@ -1104,9 +1101,9 @@ static void moxa_close_port(struct moxa_port *ch)
 {
 	moxa_shut_down(ch);
 	MoxaPortFlushData(ch, 2);
-	ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
-	ch->tty->driver_data = NULL;
-	ch->tty = NULL;
+	ch->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	ch->port.tty->driver_data = NULL;
+	ch->port.tty = NULL;
 }
 
 static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
@@ -1117,7 +1114,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
 	u8 dcd;
 
 	while (1) {
-		prepare_to_wait(&ch->open_wait, &wait, TASK_INTERRUPTIBLE);
+		prepare_to_wait(&ch->port.open_wait, &wait, TASK_INTERRUPTIBLE);
 		if (tty_hung_up_p(filp)) {
 #ifdef SERIAL_DO_RESTART
 			retval = -ERESTARTSYS;
@@ -1138,7 +1135,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
 		}
 		schedule();
 	}
-	finish_wait(&ch->open_wait, &wait);
+	finish_wait(&ch->port.open_wait, &wait);
 
 	return retval;
 }
@@ -1163,16 +1160,16 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
 	}
 
 	ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
-	ch->count++;
+	ch->port.count++;
 	tty->driver_data = ch;
-	ch->tty = tty;
-	if (!(ch->asyncflags & ASYNC_INITIALIZED)) {
+	ch->port.tty = tty;
+	if (!(ch->port.flags & ASYNC_INITIALIZED)) {
 		ch->statusflags = 0;
 		moxa_set_tty_param(tty, tty->termios);
 		MoxaPortLineCtrl(ch, 1, 1);
 		MoxaPortEnable(ch);
 		MoxaSetFifo(ch, ch->type == PORT_16550A);
-		ch->asyncflags |= ASYNC_INITIALIZED;
+		ch->port.flags |= ASYNC_INITIALIZED;
 	}
 	mutex_unlock(&moxa_openlock);
 
@@ -1181,11 +1178,11 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
 		retval = moxa_block_till_ready(tty, filp, ch);
 	mutex_lock(&moxa_openlock);
 	if (retval) {
-		if (ch->count) /* 0 means already hung up... */
-			if (--ch->count == 0)
+		if (ch->port.count) /* 0 means already hung up... */
+			if (--ch->port.count == 0)
 				moxa_close_port(ch);
 	} else
-		ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
+		ch->port.flags |= ASYNC_NORMAL_ACTIVE;
 	mutex_unlock(&moxa_openlock);
 
 	return retval;
@@ -1204,21 +1201,21 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
 	ch = tty->driver_data;
 	if (ch == NULL)
 		goto unlock;
-	if (tty->count == 1 && ch->count != 1) {
+	if (tty->count == 1 && ch->port.count != 1) {
 		printk(KERN_WARNING "moxa_close: bad serial port count; "
-			"tty->count is 1, ch->count is %d\n", ch->count);
-		ch->count = 1;
+			"tty->count is 1, ch->port.count is %d\n", ch->port.count);
+		ch->port.count = 1;
 	}
-	if (--ch->count < 0) {
+	if (--ch->port.count < 0) {
 		printk(KERN_WARNING "moxa_close: bad serial port count, "
 			"device=%s\n", tty->name);
-		ch->count = 0;
+		ch->port.count = 0;
 	}
-	if (ch->count)
+	if (ch->port.count)
 		goto unlock;
 
 	ch->cflag = tty->termios->c_cflag;
-	if (ch->asyncflags & ASYNC_INITIALIZED) {
+	if (ch->port.flags & ASYNC_INITIALIZED) {
 		moxa_setup_empty_event(tty);
 		tty_wait_until_sent(tty, 30 * HZ);	/* 30 seconds timeout */
 	}
@@ -1374,7 +1371,7 @@ static void moxa_set_termios(struct tty_struct *tty,
 		return;
 	moxa_set_tty_param(tty, old_termios);
 	if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty))
-		wake_up_interruptible(&ch->open_wait);
+		wake_up_interruptible(&ch->port.open_wait);
 }
 
 static void moxa_stop(struct tty_struct *tty)
@@ -1412,20 +1409,20 @@ static void moxa_hangup(struct tty_struct *tty)
 		mutex_unlock(&moxa_openlock);
 		return;
 	}
-	ch->count = 0;
+	ch->port.count = 0;
 	moxa_close_port(ch);
 	mutex_unlock(&moxa_openlock);
 
-	wake_up_interruptible(&ch->open_wait);
+	wake_up_interruptible(&ch->port.open_wait);
 }
 
 static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
 {
 	dcd = !!dcd;
 
-	if (dcd != p->DCDState && p->tty && C_CLOCAL(p->tty)) {
+	if (dcd != p->DCDState && p->port.tty && C_CLOCAL(p->port.tty)) {
 		if (!dcd)
-			tty_hangup(p->tty);
+			tty_hangup(p->port.tty);
 	}
 	p->DCDState = dcd;
 }
@@ -1433,9 +1430,9 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
 static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
 		u16 __iomem *ip)
 {
-	struct tty_struct *tty = p->tty;
+	struct tty_struct *tty = p->port.tty;
 	void __iomem *ofsAddr;
-	unsigned int inited = p->asyncflags & ASYNC_INITIALIZED;
+	unsigned int inited = p->port.flags & ASYNC_INITIALIZED;
 	u16 intr;
 
 	if (tty) {
@@ -1566,9 +1563,9 @@ static void moxa_setup_empty_event(struct tty_struct *tty)
 
 static void moxa_shut_down(struct moxa_port *ch)
 {
-	struct tty_struct *tp = ch->tty;
+	struct tty_struct *tp = ch->port.tty;
 
-	if (!(ch->asyncflags & ASYNC_INITIALIZED))
+	if (!(ch->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	MoxaPortDisable(ch);
@@ -1580,7 +1577,7 @@ static void moxa_shut_down(struct moxa_port *ch)
 		MoxaPortLineCtrl(ch, 0, 0);
 
 	spin_lock_bh(&moxa_lock);
-	ch->asyncflags &= ~ASYNC_INITIALIZED;
+	ch->port.flags &= ~ASYNC_INITIALIZED;
 	spin_unlock_bh(&moxa_lock);
 }
 
@@ -1975,7 +1972,7 @@ static int MoxaPortWriteData(struct moxa_port *port,
 	c = (head > tail) ? (head - tail - 1) : (head - tail + tx_mask);
 	if (c > len)
 		c = len;
-	moxaLog.txcnt[port->tty->index] += c;
+	moxaLog.txcnt[port->port.tty->index] += c;
 	total = c;
 	if (spage == epage) {
 		bufhead = readw(ofsAddr + Ofs_txb);
@@ -2017,7 +2014,7 @@ static int MoxaPortWriteData(struct moxa_port *port,
 
 static int MoxaPortReadData(struct moxa_port *port)
 {
-	struct tty_struct *tty = port->tty;
+	struct tty_struct *tty = port->port.tty;
 	unsigned char *dst;
 	void __iomem *baseAddr, *ofsAddr, *ofs;
 	unsigned int count, len, total;
@@ -2124,8 +2121,8 @@ static int moxa_get_serial_info(struct moxa_port *info,
 {
 	struct serial_struct tmp = {
 		.type = info->type,
-		.line = info->tty->index,
-		.flags = info->asyncflags,
+		.line = info->port.tty->index,
+		.flags = info->port.flags,
 		.baud_base = 921600,
 		.close_delay = info->close_delay
 	};
@@ -2148,13 +2145,13 @@ static int moxa_set_serial_info(struct moxa_port *info,
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if (((new_serial.flags & ~ASYNC_USR_MASK) !=
-		     (info->asyncflags & ~ASYNC_USR_MASK)))
+		     (info->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
 	} else
 		info->close_delay = new_serial.close_delay * HZ / 100;
 
 	new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
-	new_serial.flags |= (info->asyncflags & ASYNC_FLAGS);
+	new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
 
 	MoxaSetFifo(info, new_serial.type == PORT_16550A);
 
author
#10 lore raw

PATCH 6/20 mxser: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch mxser to use the new tty_port structure
---

 drivers/char/mxser.c |  257 +++++++++++++++++++++++++-------------------------
 1 files changed, 126 insertions(+), 131 deletions(-)
drivers/char/mxser.c +126 -131
index 4b81a85..e83ccee 100644
@@ -222,8 +222,8 @@ struct mxser_mon_ext {
 struct mxser_board;
 
 struct mxser_port {
+	struct tty_port port;
 	struct mxser_board *board;
-	struct tty_struct *tty;
 
 	unsigned long ioaddr;
 	unsigned long opmode_ioaddr;
@@ -234,7 +234,6 @@ struct mxser_port {
 	int rx_low_water;
 	int baud_base;		/* max. speed */
 	int type;		/* UART type */
-	int flags;		/* defined in tty.h */
 
 	int x_char;		/* xon/xoff character */
 	int IER;		/* Interrupt Enable Register */
@@ -249,15 +248,12 @@ struct mxser_port {
 	unsigned char err_shadow;
 	unsigned long event;
 
-	int count;		/* # of fd on device */
-	int blocked_open;	/* # of blocked opens */
 	struct async_icount icount; /* kernel counters for 4 input interrupts */
 	int timeout;
 
 	int read_status_mask;
 	int ignore_status_mask;
 	int xmit_fifo_size;
-	unsigned char *xmit_buf;
 	int xmit_head;
 	int xmit_tail;
 	int xmit_cnt;
@@ -267,7 +263,6 @@ struct mxser_port {
 	struct mxser_mon mon_data;
 
 	spinlock_t slock;
-	wait_queue_head_t open_wait;
 	wait_queue_head_t delta_msr_wait;
 };
 
@@ -575,7 +570,7 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
 	 */
 	if ((filp->f_flags & O_NONBLOCK) ||
 			test_bit(TTY_IO_ERROR, &tty->flags)) {
-		port->flags |= ASYNC_NORMAL_ACTIVE;
+		port->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -585,32 +580,32 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
 	/*
 	 * Block waiting for the carrier detect and the line to become
 	 * free (i.e., not in use by the callout).  While we are in
-	 * this loop, port->count is dropped by one, so that
+	 * this loop, port->port.count is dropped by one, so that
 	 * mxser_close() knows when to free things.  We restore it upon
 	 * exit, either normal or abnormal.
 	 */
 	retval = 0;
-	add_wait_queue(&port->open_wait, &wait);
+	add_wait_queue(&port->port.open_wait, &wait);
 
 	spin_lock_irqsave(&port->slock, flags);
 	if (!tty_hung_up_p(filp))
-		port->count--;
+		port->port.count--;
 	spin_unlock_irqrestore(&port->slock, flags);
-	port->blocked_open++;
+	port->port.blocked_open++;
 	while (1) {
 		spin_lock_irqsave(&port->slock, flags);
 		outb(inb(port->ioaddr + UART_MCR) |
 			UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR);
 		spin_unlock_irqrestore(&port->slock, flags);
 		set_current_state(TASK_INTERRUPTIBLE);
-		if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) {
-			if (port->flags & ASYNC_HUP_NOTIFY)
+		if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) {
+			if (port->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
 			break;
 		}
-		if (!(port->flags & ASYNC_CLOSING) &&
+		if (!(port->port.flags & ASYNC_CLOSING) &&
 				(do_clocal ||
 				(inb(port->ioaddr + UART_MSR) & UART_MSR_DCD)))
 			break;
@@ -621,13 +616,13 @@ static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp,
 		schedule();
 	}
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&port->open_wait, &wait);
+	remove_wait_queue(&port->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp))
-		port->count++;
-	port->blocked_open--;
+		port->port.count++;
+	port->port.blocked_open--;
 	if (retval)
 		return retval;
-	port->flags |= ASYNC_NORMAL_ACTIVE;
+	port->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -636,7 +631,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
 	int quot = 0, baud;
 	unsigned char cval;
 
-	if (!info->tty || !info->tty->termios)
+	if (!info->port.tty || !info->port.tty->termios)
 		return -1;
 
 	if (!(info->ioaddr))
@@ -647,13 +642,13 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
 
 	if (newspd == 134) {
 		quot = 2 * info->baud_base / 269;
-		tty_encode_baud_rate(info->tty, 134, 134);
+		tty_encode_baud_rate(info->port.tty, 134, 134);
 	} else if (newspd) {
 		quot = info->baud_base / newspd;
 		if (quot == 0)
 			quot = 1;
 		baud = info->baud_base/quot;
-		tty_encode_baud_rate(info->tty, baud, baud);
+		tty_encode_baud_rate(info->port.tty, baud, baud);
 	} else {
 		quot = 0;
 	}
@@ -679,7 +674,7 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
 	outb(cval, info->ioaddr + UART_LCR);	/* reset DLAB */
 
 #ifdef BOTHER
-	if (C_BAUD(info->tty) == BOTHER) {
+	if (C_BAUD(info->port.tty) == BOTHER) {
 		quot = info->baud_base % newspd;
 		quot *= 8;
 		if (quot % newspd > newspd / 2) {
@@ -707,14 +702,14 @@ static int mxser_change_speed(struct mxser_port *info,
 	int ret = 0;
 	unsigned char status;
 
-	if (!info->tty || !info->tty->termios)
+	if (!info->port.tty || !info->port.tty->termios)
 		return ret;
-	cflag = info->tty->termios->c_cflag;
+	cflag = info->port.tty->termios->c_cflag;
 	if (!(info->ioaddr))
 		return ret;
 
-	if (mxser_set_baud_method[info->tty->index] == 0)
-		mxser_set_baud(info, tty_get_baud_rate(info->tty));
+	if (mxser_set_baud_method[info->port.tty->index] == 0)
+		mxser_set_baud(info, tty_get_baud_rate(info->port.tty));
 
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
@@ -777,15 +772,15 @@ static int mxser_change_speed(struct mxser_port *info,
 	info->IER &= ~UART_IER_MSI;
 	info->MCR &= ~UART_MCR_AFE;
 	if (cflag & CRTSCTS) {
-		info->flags |= ASYNC_CTS_FLOW;
+		info->port.flags |= ASYNC_CTS_FLOW;
 		info->IER |= UART_IER_MSI;
 		if ((info->type == PORT_16550A) || (info->board->chip_flag)) {
 			info->MCR |= UART_MCR_AFE;
 		} else {
 			status = inb(info->ioaddr + UART_MSR);
-			if (info->tty->hw_stopped) {
+			if (info->port.tty->hw_stopped) {
 				if (status & UART_MSR_CTS) {
-					info->tty->hw_stopped = 0;
+					info->port.tty->hw_stopped = 0;
 					if (info->type != PORT_16550A &&
 							!info->board->chip_flag) {
 						outb(info->IER & ~UART_IER_THRI,
@@ -795,11 +790,11 @@ static int mxser_change_speed(struct mxser_port *info,
 						outb(info->IER, info->ioaddr +
 								UART_IER);
 					}
-					tty_wakeup(info->tty);
+					tty_wakeup(info->port.tty);
 				}
 			} else {
 				if (!(status & UART_MSR_CTS)) {
-					info->tty->hw_stopped = 1;
+					info->port.tty->hw_stopped = 1;
 					if ((info->type != PORT_16550A) &&
 							(!info->board->chip_flag)) {
 						info->IER &= ~UART_IER_THRI;
@@ -810,13 +805,13 @@ static int mxser_change_speed(struct mxser_port *info,
 			}
 		}
 	} else {
-		info->flags &= ~ASYNC_CTS_FLOW;
+		info->port.flags &= ~ASYNC_CTS_FLOW;
 	}
 	outb(info->MCR, info->ioaddr + UART_MCR);
 	if (cflag & CLOCAL) {
-		info->flags &= ~ASYNC_CHECK_CD;
+		info->port.flags &= ~ASYNC_CHECK_CD;
 	} else {
-		info->flags |= ASYNC_CHECK_CD;
+		info->port.flags |= ASYNC_CHECK_CD;
 		info->IER |= UART_IER_MSI;
 	}
 	outb(info->IER, info->ioaddr + UART_IER);
@@ -825,21 +820,21 @@ static int mxser_change_speed(struct mxser_port *info,
 	 * Set up parity check flag
 	 */
 	info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
-	if (I_INPCK(info->tty))
+	if (I_INPCK(info->port.tty))
 		info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
-	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
 		info->read_status_mask |= UART_LSR_BI;
 
 	info->ignore_status_mask = 0;
 
-	if (I_IGNBRK(info->tty)) {
+	if (I_IGNBRK(info->port.tty)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		info->read_status_mask |= UART_LSR_BI;
 		/*
 		 * If we're ignore parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->tty)) {
+		if (I_IGNPAR(info->port.tty)) {
 			info->ignore_status_mask |=
 						UART_LSR_OE |
 						UART_LSR_PE |
@@ -851,16 +846,16 @@ static int mxser_change_speed(struct mxser_port *info,
 		}
 	}
 	if (info->board->chip_flag) {
-		mxser_set_must_xon1_value(info->ioaddr, START_CHAR(info->tty));
-		mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(info->tty));
-		if (I_IXON(info->tty)) {
+		mxser_set_must_xon1_value(info->ioaddr, START_CHAR(info->port.tty));
+		mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(info->port.tty));
+		if (I_IXON(info->port.tty)) {
 			mxser_enable_must_rx_software_flow_control(
 					info->ioaddr);
 		} else {
 			mxser_disable_must_rx_software_flow_control(
 					info->ioaddr);
 		}
-		if (I_IXOFF(info->tty)) {
+		if (I_IXOFF(info->port.tty)) {
 			mxser_enable_must_tx_software_flow_control(
 					info->ioaddr);
 		} else {
@@ -890,15 +885,15 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
 	port->mon_data.modem_status = status;
 	wake_up_interruptible(&port->delta_msr_wait);
 
-	if ((port->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
+	if ((port->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
 		if (status & UART_MSR_DCD)
-			wake_up_interruptible(&port->open_wait);
+			wake_up_interruptible(&port->port.open_wait);
 	}
 
-	if (port->flags & ASYNC_CTS_FLOW) {
-		if (port->tty->hw_stopped) {
+	if (port->port.flags & ASYNC_CTS_FLOW) {
+		if (port->port.tty->hw_stopped) {
 			if (status & UART_MSR_CTS) {
-				port->tty->hw_stopped = 0;
+				port->port.tty->hw_stopped = 0;
 
 				if ((port->type != PORT_16550A) &&
 						(!port->board->chip_flag)) {
@@ -908,11 +903,11 @@ static void mxser_check_modem_status(struct mxser_port *port, int status)
 					outb(port->IER, port->ioaddr +
 							UART_IER);
 				}
-				tty_wakeup(port->tty);
+				tty_wakeup(port->port.tty);
 			}
 		} else {
 			if (!(status & UART_MSR_CTS)) {
-				port->tty->hw_stopped = 1;
+				port->port.tty->hw_stopped = 1;
 				if (port->type != PORT_16550A &&
 						!port->board->chip_flag) {
 					port->IER &= ~UART_IER_THRI;
@@ -935,23 +930,23 @@ static int mxser_startup(struct mxser_port *info)
 
 	spin_lock_irqsave(&info->slock, flags);
 
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
 		free_page(page);
 		spin_unlock_irqrestore(&info->slock, flags);
 		return 0;
 	}
 
 	if (!info->ioaddr || !info->type) {
-		if (info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
+		if (info->port.tty)
+			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		free_page(page);
 		spin_unlock_irqrestore(&info->slock, flags);
 		return 0;
 	}
-	if (info->xmit_buf)
+	if (info->port.xmit_buf)
 		free_page(page);
 	else
-		info->xmit_buf = (unsigned char *) page;
+		info->port.xmit_buf = (unsigned char *) page;
 
 	/*
 	 * Clear the FIFO buffers and disable them
@@ -973,8 +968,8 @@ static int mxser_startup(struct mxser_port *info)
 	if (inb(info->ioaddr + UART_LSR) == 0xff) {
 		spin_unlock_irqrestore(&info->slock, flags);
 		if (capable(CAP_SYS_ADMIN)) {
-			if (info->tty)
-				set_bit(TTY_IO_ERROR, &info->tty->flags);
+			if (info->port.tty)
+				set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 			return 0;
 		} else
 			return -ENODEV;
@@ -1012,15 +1007,15 @@ static int mxser_startup(struct mxser_port *info)
 	(void) inb(info->ioaddr + UART_IIR);
 	(void) inb(info->ioaddr + UART_MSR);
 
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 
 	/*
 	 * and set the speed of the serial port
 	 */
 	mxser_change_speed(info, NULL);
-	info->flags |= ASYNC_INITIALIZED;
+	info->port.flags |= ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&info->slock, flags);
 
 	return 0;
@@ -1034,7 +1029,7 @@ static void mxser_shutdown(struct mxser_port *info)
 {
 	unsigned long flags;
 
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	spin_lock_irqsave(&info->slock, flags);
@@ -1048,15 +1043,15 @@ static void mxser_shutdown(struct mxser_port *info)
 	/*
 	 * Free the IRQ, if necessary
 	 */
-	if (info->xmit_buf) {
-		free_page((unsigned long) info->xmit_buf);
-		info->xmit_buf = NULL;
+	if (info->port.xmit_buf) {
+		free_page((unsigned long) info->port.xmit_buf);
+		info->port.xmit_buf = NULL;
 	}
 
 	info->IER = 0;
 	outb(0x00, info->ioaddr + UART_IER);
 
-	if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+	if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
 		info->MCR &= ~(UART_MCR_DTR | UART_MCR_RTS);
 	outb(info->MCR, info->ioaddr + UART_MCR);
 
@@ -1072,10 +1067,10 @@ static void mxser_shutdown(struct mxser_port *info)
 	/* read data port to reset things */
 	(void) inb(info->ioaddr + UART_RX);
 
-	if (info->tty)
-		set_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 
-	info->flags &= ~ASYNC_INITIALIZED;
+	info->port.flags &= ~ASYNC_INITIALIZED;
 
 	if (info->board->chip_flag)
 		SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
@@ -1105,12 +1100,12 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
 		return -ENODEV;
 
 	tty->driver_data = info;
-	info->tty = tty;
+	info->port.tty = tty;
 	/*
 	 * Start up serial port
 	 */
 	spin_lock_irqsave(&info->slock, flags);
-	info->count++;
+	info->port.count++;
 	spin_unlock_irqrestore(&info->slock, flags);
 	retval = mxser_startup(info);
 	if (retval)
@@ -1170,34 +1165,34 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
-	if ((tty->count == 1) && (info->count != 1)) {
+	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
+		 * structure will be freed.  Info->port.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 "mxser_close: bad serial port count; "
-			"tty->count is 1, info->count is %d\n", info->count);
-		info->count = 1;
+			"tty->count is 1, info->port.count is %d\n", info->port.count);
+		info->port.count = 1;
 	}
-	if (--info->count < 0) {
+	if (--info->port.count < 0) {
 		printk(KERN_ERR "mxser_close: bad serial port count for "
-			"ttys%d: %d\n", tty->index, info->count);
-		info->count = 0;
+			"ttys%d: %d\n", tty->index, info->port.count);
+		info->port.count = 0;
 	}
-	if (info->count) {
+	if (info->port.count) {
 		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
-	info->flags |= ASYNC_CLOSING;
+	info->port.flags |= ASYNC_CLOSING;
 	spin_unlock_irqrestore(&info->slock, flags);
 	/*
 	 * Save the termios structure, since this port may have
 	 * separate termios for callout and dialin.
 	 */
-	if (info->flags & ASYNC_NORMAL_ACTIVE)
+	if (info->port.flags & ASYNC_NORMAL_ACTIVE)
 		info->normal_termios = *tty->termios;
 	/*
 	 * Now we wait for the transmit buffer to clear; and we notify
@@ -1216,7 +1211,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 	if (info->board->chip_flag)
 		info->IER &= ~MOXA_MUST_RECV_ISR;
 
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
 		outb(info->IER, info->ioaddr + UART_IER);
 		/*
 		 * Before we drop DTR, make sure the UART transmitter
@@ -1237,14 +1232,14 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 
 	tty->closing = 0;
 	info->event = 0;
-	info->tty = NULL;
-	if (info->blocked_open) {
+	info->port.tty = NULL;
+	if (info->port.blocked_open) {
 		if (info->close_delay)
 			schedule_timeout_interruptible(info->close_delay);
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	}
 
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
+	info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
 }
 
 static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -1253,7 +1248,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 	struct mxser_port *info = tty->driver_data;
 	unsigned long flags;
 
-	if (!info->xmit_buf)
+	if (!info->port.xmit_buf)
 		return 0;
 
 	while (1) {
@@ -1262,7 +1257,7 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
 		if (c <= 0)
 			break;
 
-		memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->port.xmit_buf + info->xmit_head, buf, c);
 		spin_lock_irqsave(&info->slock, flags);
 		info->xmit_head = (info->xmit_head + c) &
 				  (SERIAL_XMIT_SIZE - 1);
@@ -1294,14 +1289,14 @@ static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
 	struct mxser_port *info = tty->driver_data;
 	unsigned long flags;
 
-	if (!info->xmit_buf)
+	if (!info->port.xmit_buf)
 		return 0;
 
 	if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
 		return 0;
 
 	spin_lock_irqsave(&info->slock, flags);
-	info->xmit_buf[info->xmit_head++] = ch;
+	info->port.xmit_buf[info->xmit_head++] = ch;
 	info->xmit_head &= SERIAL_XMIT_SIZE - 1;
 	info->xmit_cnt++;
 	spin_unlock_irqrestore(&info->slock, flags);
@@ -1327,7 +1322,7 @@ static void mxser_flush_chars(struct tty_struct *tty)
 
 	if (info->xmit_cnt <= 0 ||
 			tty->stopped ||
-			!info->xmit_buf ||
+			!info->port.xmit_buf ||
 			(tty->hw_stopped &&
 			 (info->type != PORT_16550A) &&
 			 (!info->board->chip_flag)
@@ -1370,10 +1365,10 @@ static int mxser_get_serial_info(struct mxser_port *info,
 {
 	struct serial_struct tmp = {
 		.type = info->type,
-		.line = info->tty->index,
+		.line = info->port.tty->index,
 		.port = info->ioaddr,
 		.irq = info->board->irq,
-		.flags = info->flags,
+		.flags = info->port.flags,
 		.baud_base = info->baud_base,
 		.close_delay = info->close_delay,
 		.closing_wait = info->closing_wait,
@@ -1403,33 +1398,33 @@ static int mxser_set_serial_info(struct mxser_port *info,
 			new_serial.port != info->ioaddr)
 		return -EINVAL;
 
-	flags = info->flags & ASYNC_SPD_MASK;
+	flags = info->port.flags & ASYNC_SPD_MASK;
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((new_serial.baud_base != info->baud_base) ||
 				(new_serial.close_delay != info->close_delay) ||
-				((new_serial.flags & ~ASYNC_USR_MASK) != (info->flags & ~ASYNC_USR_MASK)))
+				((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
-		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+		info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
 				(new_serial.flags & ASYNC_USR_MASK));
 	} else {
 		/*
 		 * OK, past this point, all the error checking has been done.
 		 * At this point, we start making changes.....
 		 */
-		info->flags = ((info->flags & ~ASYNC_FLAGS) |
+		info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
 				(new_serial.flags & ASYNC_FLAGS));
 		info->close_delay = new_serial.close_delay * HZ / 100;
 		info->closing_wait = new_serial.closing_wait * HZ / 100;
-		info->tty->low_latency =
-				(info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-		info->tty->low_latency = 0;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
+		info->port.tty->low_latency =
+				(info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+		info->port.tty->low_latency = 0;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
 				(new_serial.baud_base != info->baud_base ||
 				new_serial.custom_divisor !=
 				info->custom_divisor)) {
 			baud = new_serial.baud_base / new_serial.custom_divisor;
-			tty_encode_baud_rate(info->tty, baud, baud);
+			tty_encode_baud_rate(info->port.tty, baud, baud);
 		}
 	}
 
@@ -1437,8 +1432,8 @@ static int mxser_set_serial_info(struct mxser_port *info,
 
 	process_txrx_fifo(info);
 
-	if (info->flags & ASYNC_INITIALIZED) {
-		if (flags != (info->flags & ASYNC_SPD_MASK)) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
+		if (flags != (info->port.flags & ASYNC_SPD_MASK)) {
 			spin_lock_irqsave(&info->slock, sl_flags);
 			mxser_change_speed(info, NULL);
 			spin_unlock_irqrestore(&info->slock, sl_flags);
@@ -1693,12 +1688,12 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 					continue;
 				}
 
-				if (!port->tty || !port->tty->termios)
+				if (!port->port.tty || !port->port.tty->termios)
 					GMStatus[i].cflag =
 						port->normal_termios.c_cflag;
 				else
 					GMStatus[i].cflag =
-						port->tty->termios->c_cflag;
+						port->port.tty->termios->c_cflag;
 
 				status = inb(port->ioaddr + UART_MSR);
 				if (status & 0x80 /*UART_MSR_DCD */ )
@@ -1755,14 +1750,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
 				mon_data_ext.modem_status[i] =
 					port->mon_data.modem_status;
 				mon_data_ext.baudrate[i] =
-					tty_get_baud_rate(port->tty);
+					tty_get_baud_rate(port->port.tty);
 
-				if (!port->tty || !port->tty->termios) {
+				if (!port->port.tty || !port->port.tty->termios) {
 					cflag = port->normal_termios.c_cflag;
 					iflag = port->normal_termios.c_iflag;
 				} else {
-					cflag = port->tty->termios->c_cflag;
-					iflag = port->tty->termios->c_iflag;
+					cflag = port->port.tty->termios->c_cflag;
+					iflag = port->port.tty->termios->c_iflag;
 				}
 
 				mon_data_ext.databits[i] = cflag & CSIZE;
@@ -1989,7 +1984,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
 		else
 			info->mon_data.hold_reason |= NPPI_NOTIFY_XOFFXENT;
 
-		if (info->tty->hw_stopped)
+		if (info->port.tty->hw_stopped)
 			info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
 		else
 			info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
@@ -2038,7 +2033,7 @@ static void mxser_stoprx(struct tty_struct *tty)
 		}
 	}
 
-	if (info->tty->termios->c_cflag & CRTSCTS) {
+	if (info->port.tty->termios->c_cflag & CRTSCTS) {
 		info->MCR &= ~UART_MCR_RTS;
 		outb(info->MCR, info->ioaddr + UART_MCR);
 	}
@@ -2075,7 +2070,7 @@ static void mxser_unthrottle(struct tty_struct *tty)
 		}
 	}
 
-	if (info->tty->termios->c_cflag & CRTSCTS) {
+	if (info->port.tty->termios->c_cflag & CRTSCTS) {
 		info->MCR |= UART_MCR_RTS;
 		outb(info->MCR, info->ioaddr + UART_MCR);
 	}
@@ -2106,7 +2101,7 @@ static void mxser_start(struct tty_struct *tty)
 	unsigned long flags;
 
 	spin_lock_irqsave(&info->slock, flags);
-	if (info->xmit_cnt && info->xmit_buf) {
+	if (info->xmit_cnt && info->port.xmit_buf) {
 		outb(info->IER & ~UART_IER_THRI, info->ioaddr + UART_IER);
 		info->IER |= UART_IER_THRI;
 		outb(info->IER, info->ioaddr + UART_IER);
@@ -2220,10 +2215,10 @@ static void mxser_hangup(struct tty_struct *tty)
 	mxser_flush_buffer(tty);
 	mxser_shutdown(info);
 	info->event = 0;
-	info->count = 0;
-	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	info->tty = NULL;
-	wake_up_interruptible(&info->open_wait);
+	info->port.count = 0;
+	info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	info->port.tty = NULL;
+	wake_up_interruptible(&info->port.open_wait);
 }
 
 /*
@@ -2246,7 +2241,7 @@ static void mxser_rs_break(struct tty_struct *tty, int break_state)
 
 static void mxser_receive_chars(struct mxser_port *port, int *status)
 {
-	struct tty_struct *tty = port->tty;
+	struct tty_struct *tty = port->port.tty;
 	unsigned char ch, gdl;
 	int ignored = 0;
 	int cnt = 0;
@@ -2302,7 +2297,7 @@ intr_old:
 					flag = TTY_BREAK;
 					port->icount.brk++;
 
-					if (port->flags & ASYNC_SAK)
+					if (port->port.flags & ASYNC_SAK)
 						do_SAK(tty);
 				} else if (*status & UART_LSR_PE) {
 					flag = TTY_PARITY;
@@ -2333,7 +2328,7 @@ intr_old:
 	} while (*status & UART_LSR_DR);
 
 end_intr:
-	mxvar_log.rxcnt[port->tty->index] += cnt;
+	mxvar_log.rxcnt[port->port.tty->index] += cnt;
 	port->mon_data.rxcnt += cnt;
 	port->mon_data.up_rxcnt += cnt;
 
@@ -2354,18 +2349,18 @@ static void mxser_transmit_chars(struct mxser_port *port)
 	if (port->x_char) {
 		outb(port->x_char, port->ioaddr + UART_TX);
 		port->x_char = 0;
-		mxvar_log.txcnt[port->tty->index]++;
+		mxvar_log.txcnt[port->port.tty->index]++;
 		port->mon_data.txcnt++;
 		port->mon_data.up_txcnt++;
 		port->icount.tx++;
 		return;
 	}
 
-	if (port->xmit_buf == NULL)
+	if (port->port.xmit_buf == NULL)
 		return;
 
-	if ((port->xmit_cnt <= 0) || port->tty->stopped ||
-			(port->tty->hw_stopped &&
+	if ((port->xmit_cnt <= 0) || port->port.tty->stopped ||
+			(port->port.tty->hw_stopped &&
 			(port->type != PORT_16550A) &&
 			(!port->board->chip_flag))) {
 		port->IER &= ~UART_IER_THRI;
@@ -2376,20 +2371,20 @@ static void mxser_transmit_chars(struct mxser_port *port)
 	cnt = port->xmit_cnt;
 	count = port->xmit_fifo_size;
 	do {
-		outb(port->xmit_buf[port->xmit_tail++],
+		outb(port->port.xmit_buf[port->xmit_tail++],
 			port->ioaddr + UART_TX);
 		port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE - 1);
 		if (--port->xmit_cnt <= 0)
 			break;
 	} while (--count > 0);
-	mxvar_log.txcnt[port->tty->index] += (cnt - port->xmit_cnt);
+	mxvar_log.txcnt[port->port.tty->index] += (cnt - port->xmit_cnt);
 
 	port->mon_data.txcnt += (cnt - port->xmit_cnt);
 	port->mon_data.up_txcnt += (cnt - port->xmit_cnt);
 	port->icount.tx += (cnt - port->xmit_cnt);
 
 	if (port->xmit_cnt < WAKEUP_CHARS)
-		tty_wakeup(port->tty);
+		tty_wakeup(port->port.tty);
 
 	if (port->xmit_cnt <= 0) {
 		port->IER &= ~UART_IER_THRI;
@@ -2440,9 +2435,9 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id)
 				if (iir & UART_IIR_NO_INT)
 					break;
 				iir &= MOXA_MUST_IIR_MASK;
-				if (!port->tty ||
-						(port->flags & ASYNC_CLOSING) ||
-						!(port->flags &
+				if (!port->port.tty ||
+						(port->port.flags & ASYNC_CLOSING) ||
+						!(port->port.flags &
 							ASYNC_INITIALIZED)) {
 					status = inb(port->ioaddr + UART_LSR);
 					outb(0x27, port->ioaddr + UART_FCR);
@@ -2558,7 +2553,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
 		if (brd->chip_flag != MOXA_OTHER_UART)
 			mxser_enable_must_enchance_mode(info->ioaddr);
 
-		info->flags = ASYNC_SHARE_IRQ;
+		info->port.flags = ASYNC_SHARE_IRQ;
 		info->type = brd->uart_type;
 
 		process_txrx_fifo(info);
@@ -2567,7 +2562,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
 		info->close_delay = 5 * HZ / 10;
 		info->closing_wait = 30 * HZ;
 		info->normal_termios = mxvar_sdriver->init_termios;
-		init_waitqueue_head(&info->open_wait);
+		tty_port_init(&info->port);
 		init_waitqueue_head(&info->delta_msr_wait);
 		memset(&info->mon_data, 0, sizeof(struct mxser_mon));
 		info->err_shadow = 0;
author
#11 lore raw

PATCH 7/20 riscom8: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch riscom8 to use the new tty_port structure
---

 drivers/char/riscom8.c |  145 ++++++++++++++++++++++--------------------------
 drivers/char/riscom8.h |    8 ---
 2 files changed, 68 insertions(+), 85 deletions(-)
drivers/char/riscom8.c +67 -78
index f073c71..b0ba241 100644
@@ -322,7 +322,7 @@ static struct riscom_port *rc_get_port(struct riscom_board const *bp,
 	channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
 	if (channel < CD180_NCH)  {
 		port = &rc_port[board_No(bp) * RC_NPORT + channel];
-		if (port->flags & ASYNC_INITIALIZED)
+		if (port->port.flags & ASYNC_INITIALIZED)
 			return port;
 	}
 	printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
@@ -341,7 +341,7 @@ static void rc_receive_exc(struct riscom_board const *bp)
 	if (port == NULL)
 		return;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 #ifdef RC_REPORT_OVERRUN
 	status = rc_in(bp, CD180_RCSR);
@@ -364,7 +364,7 @@ static void rc_receive_exc(struct riscom_board const *bp)
 		printk(KERN_INFO "rc%d: port %d: Handling break...\n",
 		       board_No(bp), port_No(port));
 		flag = TTY_BREAK;
-		if (port->flags & ASYNC_SAK)
+		if (port->port.flags & ASYNC_SAK)
 			do_SAK(tty);
 
 	} else if (status & RCSR_PE)
@@ -392,7 +392,7 @@ static void rc_receive(struct riscom_board const *bp)
 	if (port == NULL)
 		return;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	count = rc_in(bp, CD180_RDCR);
 
@@ -422,7 +422,7 @@ static void rc_transmit(struct riscom_board const *bp)
 	if (port == NULL)
 		return;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	if (port->IER & IER_TXEMPTY) {
 		/* FIFO drained */
@@ -467,7 +467,7 @@ static void rc_transmit(struct riscom_board const *bp)
 
 	count = CD180_NFIFO;
 	do {
-		rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
+		rc_out(bp, CD180_TDR, port->port.xmit_buf[port->xmit_tail++]);
 		port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
 		if (--port->xmit_cnt <= 0)
 			break;
@@ -492,12 +492,12 @@ static void rc_check_modem(struct riscom_board const *bp)
 	if (port == NULL)
 		return;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	mcr = rc_in(bp, CD180_MCR);
 	if (mcr & MCR_CDCHG) {
 		if (rc_in(bp, CD180_MSVR) & MSVR_CD)
-			wake_up_interruptible(&port->open_wait);
+			wake_up_interruptible(&port->port.open_wait);
 		else
 			tty_hangup(tty);
 	}
@@ -632,7 +632,7 @@ static void rc_shutdown_board(struct riscom_board *bp)
  */
 static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
 {
-	struct tty_struct *tty = port->tty;
+	struct tty_struct *tty = port->port.tty;
 	unsigned long baud;
 	long tmp;
 	unsigned char cor1 = 0, cor3 = 0;
@@ -786,28 +786,21 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
 {
 	unsigned long flags;
 
-	if (port->flags & ASYNC_INITIALIZED)
+	if (port->port.flags & ASYNC_INITIALIZED)
 		return 0;
 
-	if (!port->xmit_buf) {
-		/* We may sleep in get_zeroed_page() */
-		unsigned long tmp = get_zeroed_page(GFP_KERNEL);
-		if (tmp == 0)
-			return -ENOMEM;
-		if (port->xmit_buf)
-			free_page(tmp);
-		else
-			port->xmit_buf = (unsigned char *) tmp;
-	}
+	if (tty_port_alloc_xmit_buf(&port->port) < 0)
+		return -ENOMEM;
+
 	spin_lock_irqsave(&riscom_lock, flags);
 
-	if (port->tty)
-		clear_bit(TTY_IO_ERROR, &port->tty->flags);
-	if (port->count == 1)
+	if (port->port.tty)
+		clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
+	if (port->port.count == 1)
 		bp->count++;
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
 	rc_change_speed(bp, port);
-	port->flags |= ASYNC_INITIALIZED;
+	port->port.flags |= ASYNC_INITIALIZED;
 
 	spin_unlock_irqrestore(&riscom_lock, flags);
 	return 0;
@@ -818,7 +811,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
 {
 	struct tty_struct *tty;
 
-	if (!(port->flags & ASYNC_INITIALIZED))
+	if (!(port->port.flags & ASYNC_INITIALIZED))
 		return;
 
 #ifdef RC_REPORT_OVERRUN
@@ -836,12 +829,9 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
 		printk("].\n");
 	}
 #endif
-	if (port->xmit_buf)  {
-		free_page((unsigned long) port->xmit_buf);
-		port->xmit_buf = NULL;
-	}
+	tty_port_free_xmit_buf(&port->port);
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	if (tty == NULL || C_HUPCL(tty)) {
 		/* Drop DTR */
@@ -860,7 +850,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
 
 	if (tty)
 		set_bit(TTY_IO_ERROR, &tty->flags);
-	port->flags &= ~ASYNC_INITIALIZED;
+	port->port.flags &= ~ASYNC_INITIALIZED;
 
 	if (--bp->count < 0)  {
 		printk(KERN_INFO "rc%d: rc_shutdown_port: "
@@ -890,9 +880,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	 * If the device is in the middle of being closed, then block
 	 * until it's done, and then try again.
 	 */
-	if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&port->close_wait);
-		if (port->flags & ASYNC_HUP_NOTIFY)
+	if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&port->port.close_wait);
+		if (port->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		else
 			return -ERESTARTSYS;
@@ -904,7 +894,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	 */
 	if ((filp->f_flags & O_NONBLOCK) ||
 	    (tty->flags & (1 << TTY_IO_ERROR))) {
-		port->flags |= ASYNC_NORMAL_ACTIVE;
+		port->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -919,16 +909,16 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	 * exit, either normal or abnormal.
 	 */
 	retval = 0;
-	add_wait_queue(&port->open_wait, &wait);
+	add_wait_queue(&port->port.open_wait, &wait);
 
 	spin_lock_irqsave(&riscom_lock, flags);
 
 	if (!tty_hung_up_p(filp))
-		port->count--;
+		port->port.count--;
 
 	spin_unlock_irqrestore(&riscom_lock, flags);
 
-	port->blocked_open++;
+	port->port.blocked_open++;
 	while (1) {
 		spin_lock_irqsave(&riscom_lock, flags);
 
@@ -942,14 +932,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (tty_hung_up_p(filp) ||
-		    !(port->flags & ASYNC_INITIALIZED)) {
-			if (port->flags & ASYNC_HUP_NOTIFY)
+		    !(port->port.flags & ASYNC_INITIALIZED)) {
+			if (port->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
 			break;
 		}
-		if (!(port->flags & ASYNC_CLOSING) &&
+		if (!(port->port.flags & ASYNC_CLOSING) &&
 		    (do_clocal || CD))
 			break;
 		if (signal_pending(current)) {
@@ -959,14 +949,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		schedule();
 	}
 	__set_current_state(TASK_RUNNING);
-	remove_wait_queue(&port->open_wait, &wait);
+	remove_wait_queue(&port->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp))
-		port->count++;
-	port->blocked_open--;
+		port->port.count++;
+	port->port.blocked_open--;
 	if (retval)
 		return retval;
 
-	port->flags |= ASYNC_NORMAL_ACTIVE;
+	port->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -990,9 +980,9 @@ static int rc_open(struct tty_struct *tty, struct file *filp)
 	if (error)
 		return error;
 
-	port->count++;
+	port->port.count++;
 	tty->driver_data = port;
-	port->tty = tty;
+	port->port.tty = tty;
 
 	error = rc_setup_port(bp, port);
 	if (error == 0)
@@ -1031,21 +1021,21 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 		goto out;
 
 	bp = port_Board(port);
-	if ((tty->count == 1) && (port->count != 1))  {
+	if ((tty->count == 1) && (port->port.count != 1))  {
 		printk(KERN_INFO "rc%d: rc_close: bad port count;"
 		       " tty->count is 1, port count is %d\n",
-		       board_No(bp), port->count);
-		port->count = 1;
+		       board_No(bp), port->port.count);
+		port->port.count = 1;
 	}
-	if (--port->count < 0)  {
+	if (--port->port.count < 0)  {
 		printk(KERN_INFO "rc%d: rc_close: bad port count "
 				 "for tty%d: %d\n",
-		       board_No(bp), port_No(port), port->count);
-		port->count = 0;
+		       board_No(bp), port_No(port), port->port.count);
+		port->port.count = 0;
 	}
-	if (port->count)
+	if (port->port.count)
 		goto out;
-	port->flags |= ASYNC_CLOSING;
+	port->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.
@@ -1060,7 +1050,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 	 * line status register.
 	 */
 	port->IER &= ~IER_RXD;
-	if (port->flags & ASYNC_INITIALIZED) {
+	if (port->port.flags & ASYNC_INITIALIZED) {
 		port->IER &= ~IER_TXRDY;
 		port->IER |= IER_TXEMPTY;
 		rc_out(bp, CD180_CAR, port_No(port));
@@ -1082,14 +1072,14 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 	tty_ldisc_flush(tty);
 
 	tty->closing = 0;
-	port->tty = NULL;
-	if (port->blocked_open) {
+	port->port.tty = NULL;
+	if (port->port.blocked_open) {
 		if (port->close_delay)
 			msleep_interruptible(jiffies_to_msecs(port->close_delay));
-		wake_up_interruptible(&port->open_wait);
+		wake_up_interruptible(&port->port.open_wait);
 	}
-	port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	wake_up_interruptible(&port->close_wait);
+	port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	wake_up_interruptible(&port->port.close_wait);
 
 out:
 	spin_unlock_irqrestore(&riscom_lock, flags);
@@ -1108,7 +1098,7 @@ static int rc_write(struct tty_struct *tty,
 
 	bp = port_Board(port);
 
-	if (!tty || !port->xmit_buf)
+	if (!tty || !port->port.xmit_buf)
 		return 0;
 
 	while (1) {
@@ -1119,7 +1109,7 @@ static int rc_write(struct tty_struct *tty,
 		if (c <= 0)
 			break;	/* lock continues to be held */
 
-		memcpy(port->xmit_buf + port->xmit_head, buf, c);
+		memcpy(port->port.xmit_buf + port->xmit_head, buf, c);
 		port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
 		port->xmit_cnt += c;
 
@@ -1151,7 +1141,7 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
 	if (rc_paranoia_check(port, tty->name, "rc_put_char"))
 		return 0;
 
-	if (!tty || !port->xmit_buf)
+	if (!tty || !port->port.xmit_buf)
 		return 0;
 
 	spin_lock_irqsave(&riscom_lock, flags);
@@ -1159,7 +1149,7 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
 	if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
 		goto out;
 
-	port->xmit_buf[port->xmit_head++] = ch;
+	port->port.xmit_buf[port->xmit_head++] = ch;
 	port->xmit_head &= SERIAL_XMIT_SIZE - 1;
 	port->xmit_cnt++;
 	ret = 1;
@@ -1178,7 +1168,7 @@ static void rc_flush_chars(struct tty_struct *tty)
 		return;
 
 	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-	    !port->xmit_buf)
+	    !port->port.xmit_buf)
 		return;
 
 	spin_lock_irqsave(&riscom_lock, flags);
@@ -1317,19 +1307,19 @@ static int rc_set_serial_info(struct riscom_port *port,
 		return -EINVAL;
 #endif
 
-	change_speed = ((port->flags & ASYNC_SPD_MASK) !=
+	change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
 			(tmp.flags & ASYNC_SPD_MASK));
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((tmp.close_delay != port->close_delay) ||
 		    (tmp.closing_wait != port->closing_wait) ||
 		    ((tmp.flags & ~ASYNC_USR_MASK) !=
-		     (port->flags & ~ASYNC_USR_MASK)))
+		     (port->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
-		port->flags = ((port->flags & ~ASYNC_USR_MASK) |
+		port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
 			       (tmp.flags & ASYNC_USR_MASK));
 	} else  {
-		port->flags = ((port->flags & ~ASYNC_FLAGS) |
+		port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
 			       (tmp.flags & ASYNC_FLAGS));
 		port->close_delay = tmp.close_delay;
 		port->closing_wait = tmp.closing_wait;
@@ -1355,7 +1345,7 @@ static int rc_get_serial_info(struct riscom_port *port,
 	tmp.line = port - rc_port;
 	tmp.port = bp->base;
 	tmp.irq  = bp->irq;
-	tmp.flags = port->flags;
+	tmp.flags = port->port.flags;
 	tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
 	tmp.close_delay = port->close_delay * HZ/100;
 	tmp.closing_wait = port->closing_wait * HZ/100;
@@ -1480,7 +1470,7 @@ static void rc_start(struct tty_struct *tty)
 
 	spin_lock_irqsave(&riscom_lock, flags);
 
-	if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
+	if (port->xmit_cnt && port->port.xmit_buf && !(port->IER & IER_TXRDY)) {
 		port->IER |= IER_TXRDY;
 		rc_out(bp, CD180_CAR, port_No(port));
 		rc_out(bp, CD180_IER, port->IER);
@@ -1499,10 +1489,10 @@ static void rc_hangup(struct tty_struct *tty)
 	bp = port_Board(port);
 
 	rc_shutdown_port(bp, port);
-	port->count = 0;
-	port->flags &= ~ASYNC_NORMAL_ACTIVE;
-	port->tty = NULL;
-	wake_up_interruptible(&port->open_wait);
+	port->port.count = 0;
+	port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	port->port.tty = NULL;
+	wake_up_interruptible(&port->port.open_wait);
 }
 
 static void rc_set_termios(struct tty_struct *tty,
@@ -1578,8 +1568,7 @@ static int __init rc_init_drivers(void)
 		rc_port[i].magic = RISCOM8_MAGIC;
 		rc_port[i].close_delay = 50 * HZ / 100;
 		rc_port[i].closing_wait = 3000 * HZ / 100;
-		init_waitqueue_head(&rc_port[i].open_wait);
-		init_waitqueue_head(&rc_port[i].close_wait);
+		tty_port_init(&rc_port[i].port);
 	}
 	return 0;
 }
drivers/char/riscom8.h +1 -7
index cdfdf43..29ddbab 100644
@@ -66,20 +66,14 @@ struct riscom_board {
 	
 struct riscom_port {
 	int			magic;
+	struct			tty_port port;
 	int			baud_base;
-	int			flags;
-	struct tty_struct 	* tty;
-	int			count;
-	int			blocked_open;
 	int			timeout;
 	int			close_delay;
-	unsigned char 		* xmit_buf;
 	int			custom_divisor;
 	int			xmit_head;
 	int			xmit_tail;
 	int			xmit_cnt;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
 	short			wakeup_chars;
 	short			break_length;
 	unsigned short		closing_wait;
author
#12 lore raw

PATCH 8/20 rocket: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch the rocketport to use the new tty_port structure
---

 drivers/char/rocket.c     |  116 +++++++++++++++++++++++----------------------
 drivers/char/rocket_int.h |    9 +--
 2 files changed, 61 insertions(+), 64 deletions(-)
drivers/char/rocket.c +58 -58
index 743dc80..ab04adb 100644
@@ -434,15 +434,15 @@ static void rp_do_transmit(struct r_port *info)
 #endif
 	if (!info)
 		return;
-	if (!info->tty) {
+	if (!info->port.tty) {
 		printk(KERN_WARNING "rp: WARNING %s called with "
-				"info->tty==NULL\n", __func__);
+				"info->port.tty==NULL\n", __func__);
 		clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
 		return;
 	}
 
 	spin_lock_irqsave(&info->slock, flags);
-	tty = info->tty;
+	tty = info->port.tty;
 	info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp);
 
 	/*  Loop sending data to FIFO until done or FIFO full */
@@ -502,13 +502,13 @@ static void rp_handle_port(struct r_port *info)
 				"info->flags & NOT_INIT\n");
 		return;
 	}
-	if (!info->tty) {
+	if (!info->port.tty) {
 		printk(KERN_WARNING "rp: WARNING: rp_handle_port called with "
-				"info->tty==NULL\n");
+				"info->port.tty==NULL\n");
 		return;
 	}
 	cp = &info->channel;
-	tty = info->tty;
+	tty = info->port.tty;
 
 	IntMask = sGetChanIntID(cp) & info->intmask;
 #ifdef ROCKET_DEBUG_INTR
@@ -530,7 +530,7 @@ static void rp_handle_port(struct r_port *info)
 			tty_hangup(tty);
 		}
 		info->cd_status = (ChanStatus & CD_ACT) ? 1 : 0;
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	}
 #ifdef ROCKET_DEBUG_INTR
 	if (IntMask & DELTA_CTS) {	/* CTS change */
@@ -650,7 +650,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
 	info->chan = chan;
 	info->closing_wait = 3000;
 	info->close_delay = 50;
-	init_waitqueue_head(&info->open_wait);
+	init_waitqueue_head(&info->port.open_wait);
 	init_completion(&info->close_wait);
 	info->flags &= ~ROCKET_MODE_MASK;
 	switch (pc104[board][line]) {
@@ -717,7 +717,7 @@ static void configure_r_port(struct r_port *info,
 	unsigned rocketMode;
 	int bits, baud, divisor;
 	CHANNEL_t *cp;
-	struct ktermios *t = info->tty->termios;
+	struct ktermios *t = info->port.tty->termios;
 
 	cp = &info->channel;
 	cflag = t->c_cflag;
@@ -750,7 +750,7 @@ static void configure_r_port(struct r_port *info,
 	}
 
 	/* baud rate */
-	baud = tty_get_baud_rate(info->tty);
+	baud = tty_get_baud_rate(info->port.tty);
 	if (!baud)
 		baud = 9600;
 	divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1;
@@ -768,7 +768,7 @@ static void configure_r_port(struct r_port *info,
 	sSetBaud(cp, divisor);
 
 	/* FIXME: Should really back compute a baud rate from the divisor */
-	tty_encode_baud_rate(info->tty, baud, baud);
+	tty_encode_baud_rate(info->port.tty, baud, baud);
 
 	if (cflag & CRTSCTS) {
 		info->intmask |= DELTA_CTS;
@@ -793,15 +793,15 @@ static void configure_r_port(struct r_port *info,
 	 * Handle software flow control in the board
 	 */
 #ifdef ROCKET_SOFT_FLOW
-	if (I_IXON(info->tty)) {
+	if (I_IXON(info->port.tty)) {
 		sEnTxSoftFlowCtl(cp);
-		if (I_IXANY(info->tty)) {
+		if (I_IXANY(info->port.tty)) {
 			sEnIXANY(cp);
 		} else {
 			sDisIXANY(cp);
 		}
-		sSetTxXONChar(cp, START_CHAR(info->tty));
-		sSetTxXOFFChar(cp, STOP_CHAR(info->tty));
+		sSetTxXONChar(cp, START_CHAR(info->port.tty));
+		sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty));
 	} else {
 		sDisTxSoftFlowCtl(cp);
 		sDisIXANY(cp);
@@ -813,24 +813,24 @@ static void configure_r_port(struct r_port *info,
 	 * Set up ignore/read mask words
 	 */
 	info->read_status_mask = STMRCVROVRH | 0xFF;
-	if (I_INPCK(info->tty))
+	if (I_INPCK(info->port.tty))
 		info->read_status_mask |= STMFRAMEH | STMPARITYH;
-	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
 		info->read_status_mask |= STMBREAKH;
 
 	/*
 	 * Characters to ignore
 	 */
 	info->ignore_status_mask = 0;
-	if (I_IGNPAR(info->tty))
+	if (I_IGNPAR(info->port.tty))
 		info->ignore_status_mask |= STMFRAMEH | STMPARITYH;
-	if (I_IGNBRK(info->tty)) {
+	if (I_IGNBRK(info->port.tty)) {
 		info->ignore_status_mask |= STMBREAKH;
 		/*
 		 * If we're ignoring parity and break indicators,
 		 * ignore overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->tty))
+		if (I_IGNPAR(info->port.tty))
 			info->ignore_status_mask |= STMRCVROVRH;
 	}
 
@@ -863,7 +863,7 @@ static void configure_r_port(struct r_port *info,
 	}
 }
 
-/*  info->count is considered critical, protected by spinlocks.  */
+/*  info->port.count is considered critical, protected by spinlocks.  */
 static int block_til_ready(struct tty_struct *tty, struct file *filp,
 			   struct r_port *info)
 {
@@ -897,13 +897,13 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 
 	/*
 	 * Block waiting for the carrier detect and the line to become free.  While we are in
-	 * this loop, info->count is dropped by one, so that rp_close() knows when to free things.  
+	 * this loop, info->port.count is dropped by one, so that rp_close() knows when to free things.  
          * We restore it upon exit, either normal or abnormal.
 	 */
 	retval = 0;
-	add_wait_queue(&info->open_wait, &wait);
+	add_wait_queue(&info->port.open_wait, &wait);
 #ifdef ROCKET_DEBUG_OPEN
-	printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->count);
+	printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->port.count);
 #endif
 	spin_lock_irqsave(&info->slock, flags);
 
@@ -912,10 +912,10 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 #else
 	if (!tty_hung_up_p(filp)) {
 		extra_count = 1;
-		info->count--;
+		info->port.count--;
 	}
 #endif
-	info->blocked_open++;
+	info->port.blocked_open++;
 
 	spin_unlock_irqrestore(&info->slock, flags);
 
@@ -940,24 +940,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		}
 #ifdef ROCKET_DEBUG_OPEN
 		printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n",
-		     info->line, info->count, info->flags);
+		     info->line, info->port.count, info->flags);
 #endif
 		schedule();	/*  Don't hold spinlock here, will hang PC */
 	}
 	__set_current_state(TASK_RUNNING);
-	remove_wait_queue(&info->open_wait, &wait);
+	remove_wait_queue(&info->port.open_wait, &wait);
 
 	spin_lock_irqsave(&info->slock, flags);
 
 	if (extra_count)
-		info->count++;
-	info->blocked_open--;
+		info->port.count++;
+	info->port.blocked_open--;
 
 	spin_unlock_irqrestore(&info->slock, flags);
 
 #ifdef ROCKET_DEBUG_OPEN
 	printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n",
-	       info->line, info->count);
+	       info->line, info->port.count);
 #endif
 	if (retval)
 		return retval;
@@ -1001,9 +1001,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 		info->xmit_buf = (unsigned char *) page;
 
 	tty->driver_data = info;
-	info->tty = tty;
+	info->port.tty = tty;
 
-	if (info->count++ == 0) {
+	if (info->port.count++ == 0) {
 		atomic_inc(&rp_num_ports_open);
 
 #ifdef ROCKET_DEBUG_OPEN
@@ -1012,7 +1012,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 #endif
 	}
 #ifdef ROCKET_DEBUG_OPEN
-	printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->count);
+	printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
 #endif
 
 	/*
@@ -1048,13 +1048,13 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 		 * Set up the tty->alt_speed kludge
 		 */
 		if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
-			info->tty->alt_speed = 57600;
+			info->port.tty->alt_speed = 57600;
 		if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
-			info->tty->alt_speed = 115200;
+			info->port.tty->alt_speed = 115200;
 		if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
-			info->tty->alt_speed = 230400;
+			info->port.tty->alt_speed = 230400;
 		if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
-			info->tty->alt_speed = 460800;
+			info->port.tty->alt_speed = 460800;
 
 		configure_r_port(info, NULL);
 		if (tty->termios->c_cflag & CBAUD) {
@@ -1076,7 +1076,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 }
 
 /*
- *  Exception handler that closes a serial port. info->count is considered critical. 
+ *  Exception handler that closes a serial port. info->port.count is considered critical. 
  */
 static void rp_close(struct tty_struct *tty, struct file *filp)
 {
@@ -1089,14 +1089,14 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 		return;
 
 #ifdef ROCKET_DEBUG_OPEN
-	printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->count);
+	printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->port.count);
 #endif
 
 	if (tty_hung_up_p(filp))
 		return;
 	spin_lock_irqsave(&info->slock, flags);
 
-	if ((tty->count == 1) && (info->count != 1)) {
+	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
@@ -1105,15 +1105,15 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 		 * serial port won't be shutdown.
 		 */
 		printk(KERN_WARNING "rp_close: bad serial port count; "
-			"tty->count is 1, info->count is %d\n", info->count);
-		info->count = 1;
+			"tty->count is 1, info->port.count is %d\n", info->port.count);
+		info->port.count = 1;
 	}
-	if (--info->count < 0) {
+	if (--info->port.count < 0) {
 		printk(KERN_WARNING "rp_close: bad serial port count for "
-				"ttyR%d: %d\n", info->line, info->count);
-		info->count = 0;
+				"ttyR%d: %d\n", info->line, info->port.count);
+		info->port.count = 0;
 	}
-	if (info->count) {
+	if (info->port.count) {
 		spin_unlock_irqrestore(&info->slock, flags);
 		return;
 	}
@@ -1167,11 +1167,11 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 
 	clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
 
-	if (info->blocked_open) {
+	if (info->port.blocked_open) {
 		if (info->close_delay) {
 			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	} else {
 		if (info->xmit_buf) {
 			free_page((unsigned long) info->xmit_buf);
@@ -1357,13 +1357,13 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
 	info->closing_wait = new_serial.closing_wait;
 
 	if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
-		info->tty->alt_speed = 57600;
+		info->port.tty->alt_speed = 57600;
 	if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
-		info->tty->alt_speed = 115200;
+		info->port.tty->alt_speed = 115200;
 	if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
-		info->tty->alt_speed = 230400;
+		info->port.tty->alt_speed = 230400;
 	if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
-		info->tty->alt_speed = 460800;
+		info->port.tty->alt_speed = 460800;
 
 	configure_r_port(info, NULL);
 	return 0;
@@ -1636,13 +1636,13 @@ static void rp_hangup(struct tty_struct *tty)
 	rp_flush_buffer(tty);
 	if (info->flags & ROCKET_CLOSING)
 		return;
-	if (info->count) 
+	if (info->port.count) 
 		atomic_dec(&rp_num_ports_open);
 	clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
 
-	info->count = 0;
+	info->port.count = 0;
 	info->flags &= ~ROCKET_NORMAL_ACTIVE;
-	info->tty = NULL;
+	info->port.tty = NULL;
 
 	cp = &info->channel;
 	sDisRxFIFO(cp);
@@ -1653,7 +1653,7 @@ static void rp_hangup(struct tty_struct *tty)
 	sClrTxXOFF(cp);
 	info->flags &= ~ROCKET_INITIALIZED;
 
-	wake_up_interruptible(&info->open_wait);
+	wake_up_interruptible(&info->port.open_wait);
 }
 
 /*
@@ -1762,7 +1762,7 @@ static int rp_write(struct tty_struct *tty,
 
 	/*  Write remaining data into the port's xmit_buf */
 	while (1) {
-		if (!info->tty)		/* Seemingly obligatory check... */
+		if (!info->port.tty)		/* Seemingly obligatory check... */
 			goto end;
 		c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
 		c = min(c, XMIT_BUF_SIZE - info->xmit_head);
drivers/char/rocket_int.h +3 -6
index 143cc43..3affc48 100644
@@ -1125,11 +1125,9 @@ Warnings: This function writes the data byte without checking to see if
 
 struct r_port {
 	int magic;
+	struct tty_port port;
 	int line;
-	int flags;
-	int count;
-	int blocked_open;
-	struct tty_struct *tty;
+	int flags;		/* Don't yet match the ASY_ flags!! */
 	unsigned int board:3;
 	unsigned int aiop:2;
 	unsigned int chan:3;
@@ -1148,8 +1146,7 @@ struct r_port {
 	int read_status_mask;
 	int cps;
 
-	wait_queue_head_t open_wait;
-	struct completion close_wait;
+	struct completion close_wait;	/* Not yet matching the core */
 	spinlock_t slock;
 	struct mutex write_mtx;
 };
author
#13 lore raw

PATCH 9/20 synclink: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch the synclink ports to use the new tty_port structure
---

 drivers/char/synclink.c    |  195 ++++++++++++++++++++----------------------
 drivers/char/synclink_gt.c |  201 +++++++++++++++++++++-----------------------
 drivers/char/synclinkmp.c  |  203 +++++++++++++++++++++-----------------------
 3 files changed, 289 insertions(+), 310 deletions(-)
drivers/char/synclink.c +94 -101
index ac5080d..0678f61 100644
@@ -180,8 +180,7 @@ struct tx_holding_buffer {
  
 struct mgsl_struct {
 	int			magic;
-	int			flags;
-	int			count;		/* count of opens */
+	struct tty_port		port;
 	int			line;
 	int                     hw_version;
 	unsigned short		close_delay;
@@ -189,10 +188,8 @@ struct mgsl_struct {
 	
 	struct mgsl_icount	icount;
 	
-	struct tty_struct 	*tty;
 	int			timeout;
 	int			x_char;		/* xon/xoff character */
-	int			blocked_open;	/* # of blocked opens */
 	u16			read_status_mask;
 	u16			ignore_status_mask;	
 	unsigned char 		*xmit_buf;
@@ -200,9 +197,6 @@ struct mgsl_struct {
 	int			xmit_tail;
 	int			xmit_cnt;
 	
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
-	
 	wait_queue_head_t	status_event_wait_q;
 	wait_queue_head_t	event_wait_q;
 	struct timer_list	tx_timer;	/* HDLC transmit timeout timer */
@@ -1134,7 +1128,7 @@ static void mgsl_bh_receive(struct mgsl_struct *info)
 
 static void mgsl_bh_transmit(struct mgsl_struct *info)
 {
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	unsigned long flags;
 	
 	if ( debug_level >= DEBUG_LEVEL_BH )
@@ -1276,7 +1270,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
 	else 
 #endif
 	{
-		if (info->tty->stopped || info->tty->hw_stopped) {
+		if (info->port.tty->stopped || info->port.tty->hw_stopped) {
 			usc_stop_transmitter(info);
 			return;
 		}
@@ -1357,29 +1351,29 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
 		wake_up_interruptible(&info->status_event_wait_q);
 		wake_up_interruptible(&info->event_wait_q);
 
-		if ( (info->flags & ASYNC_CHECK_CD) && 
+		if ( (info->port.flags & ASYNC_CHECK_CD) && 
 		     (status & MISCSTATUS_DCD_LATCHED) ) {
 			if ( debug_level >= DEBUG_LEVEL_ISR )
 				printk("%s CD now %s...", info->device_name,
 				       (status & MISCSTATUS_DCD) ? "on" : "off");
 			if (status & MISCSTATUS_DCD)
-				wake_up_interruptible(&info->open_wait);
+				wake_up_interruptible(&info->port.open_wait);
 			else {
 				if ( debug_level >= DEBUG_LEVEL_ISR )
 					printk("doing serial hangup...");
-				if (info->tty)
-					tty_hangup(info->tty);
+				if (info->port.tty)
+					tty_hangup(info->port.tty);
 			}
 		}
 	
-		if ( (info->flags & ASYNC_CTS_FLOW) && 
+		if ( (info->port.flags & ASYNC_CTS_FLOW) && 
 		     (status & MISCSTATUS_CTS_LATCHED) ) {
-			if (info->tty->hw_stopped) {
+			if (info->port.tty->hw_stopped) {
 				if (status & MISCSTATUS_CTS) {
 					if ( debug_level >= DEBUG_LEVEL_ISR )
 						printk("CTS tx start...");
-					if (info->tty)
-						info->tty->hw_stopped = 0;
+					if (info->port.tty)
+						info->port.tty->hw_stopped = 0;
 					usc_start_transmitter(info);
 					info->pending_bh |= BH_TRANSMIT;
 					return;
@@ -1388,8 +1382,8 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
 				if (!(status & MISCSTATUS_CTS)) {
 					if ( debug_level >= DEBUG_LEVEL_ISR )
 						printk("CTS tx stop...");
-					if (info->tty)
-						info->tty->hw_stopped = 1;
+					if (info->port.tty)
+						info->port.tty->hw_stopped = 1;
 					usc_stop_transmitter(info);
 				}
 			}
@@ -1423,7 +1417,7 @@ static void mgsl_isr_transmit_data( struct mgsl_struct *info )
 			
 	usc_ClearIrqPendingBits( info, TRANSMIT_DATA );
 	
-	if (info->tty->stopped || info->tty->hw_stopped) {
+	if (info->port.tty->stopped || info->port.tty->hw_stopped) {
 		usc_stop_transmitter(info);
 		return;
 	}
@@ -1453,7 +1447,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
 	u16 status;
 	int work = 0;
 	unsigned char DataByte;
- 	struct tty_struct *tty = info->tty;
+ 	struct tty_struct *tty = info->port.tty;
  	struct	mgsl_icount *icount = &info->icount;
 	
 	if ( debug_level >= DEBUG_LEVEL_ISR )	
@@ -1514,7 +1508,7 @@ static void mgsl_isr_receive_data( struct mgsl_struct *info )
 		
 			if (status & RXSTATUS_BREAK_RECEIVED) {
 				flag = TTY_BREAK;
-				if (info->flags & ASYNC_SAK)
+				if (info->port.flags & ASYNC_SAK)
 					do_SAK(tty);
 			} else if (status & RXSTATUS_PARITY_ERROR)
 				flag = TTY_PARITY;
@@ -1771,7 +1765,7 @@ static int startup(struct mgsl_struct * info)
 	if ( debug_level >= DEBUG_LEVEL_INFO )
 		printk("%s(%d):mgsl_startup(%s)\n",__FILE__,__LINE__,info->device_name);
 		
-	if (info->flags & ASYNC_INITIALIZED)
+	if (info->port.flags & ASYNC_INITIALIZED)
 		return 0;
 	
 	if (!info->xmit_buf) {
@@ -1798,8 +1792,8 @@ static int startup(struct mgsl_struct * info)
 		retval = mgsl_adapter_test(info);
 		
 	if ( retval ) {
-  		if (capable(CAP_SYS_ADMIN) && info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
+  		if (capable(CAP_SYS_ADMIN) && info->port.tty)
+			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		mgsl_release_resources(info);
   		return retval;
   	}
@@ -1807,10 +1801,10 @@ static int startup(struct mgsl_struct * info)
 	/* program hardware for current parameters */
 	mgsl_change_params(info);
 	
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 
-	info->flags |= ASYNC_INITIALIZED;
+	info->port.flags |= ASYNC_INITIALIZED;
 	
 	return 0;
 	
@@ -1827,7 +1821,7 @@ static void shutdown(struct mgsl_struct * info)
 {
 	unsigned long flags;
 	
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	if (debug_level >= DEBUG_LEVEL_INFO)
@@ -1864,7 +1858,7 @@ static void shutdown(struct mgsl_struct * info)
 	/* on the ISA adapter. This has no effect for the PCI adapter */
 	usc_OutReg(info, PCR, (u16)((usc_InReg(info, PCR) | BIT13) | BIT12));
 	
- 	if (!info->tty || info->tty->termios->c_cflag & HUPCL) {
+ 	if (!info->port.tty || info->port.tty->termios->c_cflag & HUPCL) {
  		info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS);
 		usc_set_serial_signals(info);
 	}
@@ -1873,10 +1867,10 @@ static void shutdown(struct mgsl_struct * info)
 
 	mgsl_release_resources(info);	
 	
-	if (info->tty)
-		set_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 
-	info->flags &= ~ASYNC_INITIALIZED;
+	info->port.flags &= ~ASYNC_INITIALIZED;
 	
 }	/* end of shutdown() */
 
@@ -1908,7 +1902,7 @@ static void mgsl_program_hw(struct mgsl_struct *info)
 	usc_EnableInterrupts(info, IO_PIN);
 	usc_get_serial_signals(info);
 		
-	if (info->netcount || info->tty->termios->c_cflag & CREAD)
+	if (info->netcount || info->port.tty->termios->c_cflag & CREAD)
 		usc_start_receiver(info);
 		
 	spin_unlock_irqrestore(&info->irq_spinlock,flags);
@@ -1921,14 +1915,14 @@ static void mgsl_change_params(struct mgsl_struct *info)
 	unsigned cflag;
 	int bits_per_char;
 
-	if (!info->tty || !info->tty->termios)
+	if (!info->port.tty || !info->port.tty->termios)
 		return;
 		
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_change_params(%s)\n",
 			 __FILE__,__LINE__, info->device_name );
 			 
-	cflag = info->tty->termios->c_cflag;
+	cflag = info->port.tty->termios->c_cflag;
 
 	/* if B0 rate (hangup) specified then negate DTR and RTS */
 	/* otherwise assert DTR and RTS */
@@ -1976,7 +1970,7 @@ static void mgsl_change_params(struct mgsl_struct *info)
 	 * current data rate.
 	 */
 	if (info->params.data_rate <= 460800)
-		info->params.data_rate = tty_get_baud_rate(info->tty);
+		info->params.data_rate = tty_get_baud_rate(info->port.tty);
 	
 	if ( info->params.data_rate ) {
 		info->timeout = (32*HZ*bits_per_char) / 
@@ -1985,31 +1979,31 @@ static void mgsl_change_params(struct mgsl_struct *info)
 	info->timeout += HZ/50;		/* Add .02 seconds of slop */
 
 	if (cflag & CRTSCTS)
-		info->flags |= ASYNC_CTS_FLOW;
+		info->port.flags |= ASYNC_CTS_FLOW;
 	else
-		info->flags &= ~ASYNC_CTS_FLOW;
+		info->port.flags &= ~ASYNC_CTS_FLOW;
 		
 	if (cflag & CLOCAL)
-		info->flags &= ~ASYNC_CHECK_CD;
+		info->port.flags &= ~ASYNC_CHECK_CD;
 	else
-		info->flags |= ASYNC_CHECK_CD;
+		info->port.flags |= ASYNC_CHECK_CD;
 
 	/* process tty input control flags */
 	
 	info->read_status_mask = RXSTATUS_OVERRUN;
-	if (I_INPCK(info->tty))
+	if (I_INPCK(info->port.tty))
 		info->read_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
- 	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+ 	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
  		info->read_status_mask |= RXSTATUS_BREAK_RECEIVED;
 	
-	if (I_IGNPAR(info->tty))
+	if (I_IGNPAR(info->port.tty))
 		info->ignore_status_mask |= RXSTATUS_PARITY_ERROR | RXSTATUS_FRAMING_ERROR;
-	if (I_IGNBRK(info->tty)) {
+	if (I_IGNBRK(info->port.tty)) {
 		info->ignore_status_mask |= RXSTATUS_BREAK_RECEIVED;
 		/* If ignoring parity and break indicators, ignore 
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->tty))
+		if (I_IGNPAR(info->port.tty))
 			info->ignore_status_mask |= RXSTATUS_OVERRUN;
 	}
 
@@ -3113,32 +3107,32 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
-			 __FILE__,__LINE__, info->device_name, info->count);
+			 __FILE__,__LINE__, info->device_name, info->port.count);
 			 
-	if (!info->count)
+	if (!info->port.count)
 		return;
 
 	if (tty_hung_up_p(filp))
 		goto cleanup;
 			
-	if ((tty->count == 1) && (info->count != 1)) {
+	if ((tty->count == 1) && (info->port.count != 1)) {
 		/*
 		 * tty->count is 1 and the tty structure will be freed.
-		 * info->count should be one in this case.
+		 * info->port.count should be one in this case.
 		 * if it's not, correct it so that the port is shutdown.
 		 */
 		printk("mgsl_close: bad refcount; tty->count is 1, "
-		       "info->count is %d\n", info->count);
-		info->count = 1;
+		       "info->port.count is %d\n", info->port.count);
+		info->port.count = 1;
 	}
 	
-	info->count--;
+	info->port.count--;
 	
 	/* if at least one open remaining, leave hardware active */
-	if (info->count)
+	if (info->port.count)
 		goto cleanup;
 	
-	info->flags |= ASYNC_CLOSING;
+	info->port.flags |= ASYNC_CLOSING;
 	
 	/* set tty->closing to notify line discipline to 
 	 * only process XON/XOFF characters. Only the N_TTY
@@ -3155,7 +3149,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
 		tty_wait_until_sent(tty, info->closing_wait);
 	}
 		
- 	if (info->flags & ASYNC_INITIALIZED)
+ 	if (info->port.flags & ASYNC_INITIALIZED)
  		mgsl_wait_until_sent(tty, info->timeout);
 
 	mgsl_flush_buffer(tty);
@@ -3165,23 +3159,23 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
 	shutdown(info);
 	
 	tty->closing = 0;
-	info->tty = NULL;
+	info->port.tty = NULL;
 	
-	if (info->blocked_open) {
+	if (info->port.blocked_open) {
 		if (info->close_delay) {
 			msleep_interruptible(jiffies_to_msecs(info->close_delay));
 		}
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	}
 	
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
 			 
-	wake_up_interruptible(&info->close_wait);
+	wake_up_interruptible(&info->port.close_wait);
 	
 cleanup:			
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
-			tty->driver->name, info->count);
+			tty->driver->name, info->port.count);
 			
 }	/* end of mgsl_close() */
 
@@ -3211,7 +3205,7 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
 	if (mgsl_paranoia_check(info, tty->name, "mgsl_wait_until_sent"))
 		return;
 
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		goto exit;
 	 
 	orig_jiffies = jiffies;
@@ -3283,11 +3277,11 @@ static void mgsl_hangup(struct tty_struct *tty)
 	mgsl_flush_buffer(tty);
 	shutdown(info);
 	
-	info->count = 0;	
-	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	info->tty = NULL;
+	info->port.count = 0;	
+	info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	info->port.tty = NULL;
 
-	wake_up_interruptible(&info->open_wait);
+	wake_up_interruptible(&info->port.open_wait);
 	
 }	/* end of mgsl_hangup() */
 
@@ -3319,7 +3313,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 
 	if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
 		/* nonblock mode is set or port is not enabled */
-		info->flags |= ASYNC_NORMAL_ACTIVE;
+		info->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -3328,25 +3322,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 
 	/* Wait for carrier detect and the line to become
 	 * free (i.e., not in use by the callout).  While we are in
-	 * this loop, info->count is dropped by one, so that
+	 * this loop, info->port.count is dropped by one, so that
 	 * mgsl_close() knows when to free things.  We restore it upon
 	 * exit, either normal or abnormal.
 	 */
 	 
 	retval = 0;
-	add_wait_queue(&info->open_wait, &wait);
+	add_wait_queue(&info->port.open_wait, &wait);
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready before block on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver->name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->port.count );
 
 	spin_lock_irqsave(&info->irq_spinlock, flags);
 	if (!tty_hung_up_p(filp)) {
 		extra_count = true;
-		info->count--;
+		info->port.count--;
 	}
 	spin_unlock_irqrestore(&info->irq_spinlock, flags);
-	info->blocked_open++;
+	info->port.blocked_open++;
 	
 	while (1) {
 		if (tty->termios->c_cflag & CBAUD) {
@@ -3358,8 +3352,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 		
 		set_current_state(TASK_INTERRUPTIBLE);
 		
-		if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){
-			retval = (info->flags & ASYNC_HUP_NOTIFY) ?
+		if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){
+			retval = (info->port.flags & ASYNC_HUP_NOTIFY) ?
 					-EAGAIN : -ERESTARTSYS;
 			break;
 		}
@@ -3368,7 +3362,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 	 	usc_get_serial_signals(info);
 		spin_unlock_irqrestore(&info->irq_spinlock,flags);
 		
- 		if (!(info->flags & ASYNC_CLOSING) &&
+ 		if (!(info->port.flags & ASYNC_CLOSING) &&
  		    (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) {
  			break;
 		}
@@ -3380,24 +3374,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 		
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):block_til_ready blocking on %s count=%d\n",
-				 __FILE__,__LINE__, tty->driver->name, info->count );
+				 __FILE__,__LINE__, tty->driver->name, info->port.count );
 				 
 		schedule();
 	}
 	
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&info->open_wait, &wait);
+	remove_wait_queue(&info->port.open_wait, &wait);
 	
 	if (extra_count)
-		info->count++;
-	info->blocked_open--;
+		info->port.count++;
+	info->port.blocked_open--;
 	
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
-			 __FILE__,__LINE__, tty->driver->name, info->count );
+			 __FILE__,__LINE__, tty->driver->name, info->port.count );
 			 
 	if (!retval)
-		info->flags |= ASYNC_NORMAL_ACTIVE;
+		info->port.flags |= ASYNC_NORMAL_ACTIVE;
 		
 	return retval;
 	
@@ -3435,22 +3429,22 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
 		return -ENODEV;
 	
 	tty->driver_data = info;
-	info->tty = tty;
+	info->port.tty = tty;
 		
 	if (debug_level >= DEBUG_LEVEL_INFO)
 		printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
-			 __FILE__,__LINE__,tty->driver->name, info->count);
+			 __FILE__,__LINE__,tty->driver->name, info->port.count);
 
 	/* If port is closing, signal caller to try again */
-	if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){
-		if (info->flags & ASYNC_CLOSING)
-			interruptible_sleep_on(&info->close_wait);
-		retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
+	if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
+		if (info->port.flags & ASYNC_CLOSING)
+			interruptible_sleep_on(&info->port.close_wait);
+		retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
 			-EAGAIN : -ERESTARTSYS);
 		goto cleanup;
 	}
 	
-	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+	info->port.tty->low_latency = (info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
 	spin_lock_irqsave(&info->netlock, flags);
 	if (info->netcount) {
@@ -3458,10 +3452,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
 		spin_unlock_irqrestore(&info->netlock, flags);
 		goto cleanup;
 	}
-	info->count++;
+	info->port.count++;
 	spin_unlock_irqrestore(&info->netlock, flags);
 
-	if (info->count == 1) {
+	if (info->port.count == 1) {
 		/* 1st open on this device, init hardware */
 		retval = startup(info);
 		if (retval < 0)
@@ -3484,9 +3478,9 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
 cleanup:			
 	if (retval) {
 		if (tty->count == 1)
-			info->tty = NULL; /* tty layer will release tty struct */
-		if(info->count)
-			info->count--;
+			info->port.tty = NULL; /* tty layer will release tty struct */
+		if(info->port.count)
+			info->port.count--;
 	}
 	
 	return retval;
@@ -4337,8 +4331,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
 		info->max_frame_size = 4096;
 		info->close_delay = 5*HZ/10;
 		info->closing_wait = 30*HZ;
-		init_waitqueue_head(&info->open_wait);
-		init_waitqueue_head(&info->close_wait);
+		tty_port_init(&info->port);
 		init_waitqueue_head(&info->status_event_wait_q);
 		init_waitqueue_head(&info->event_wait_q);
 		spin_lock_init(&info->irq_spinlock);
@@ -6575,7 +6568,7 @@ static bool mgsl_get_rx_frame(struct mgsl_struct *info)
 	unsigned int framesize = 0;
 	bool ReturnCode = false;
 	unsigned long flags;
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	bool return_frame = false;
 	
 	/*
@@ -6774,7 +6767,7 @@ static bool mgsl_get_raw_rx_frame(struct mgsl_struct *info)
 	unsigned int framesize = 0;
 	bool ReturnCode = false;
 	unsigned long flags;
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 
 	/*
  	 * current_rx_buffer points to the 1st buffer of the next available
@@ -7711,7 +7704,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
 	unsigned short new_crctype;
 
 	/* return error if TTY interface open */
-	if (info->count)
+	if (info->port.count)
 		return -EBUSY;
 
 	switch (encoding)
@@ -7808,7 +7801,7 @@ static int hdlcdev_open(struct net_device *dev)
 
 	/* arbitrate between network and tty opens */
 	spin_lock_irqsave(&info->netlock, flags);
-	if (info->count != 0 || info->netcount != 0) {
+	if (info->port.count != 0 || info->netcount != 0) {
 		printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
 		spin_unlock_irqrestore(&info->netlock, flags);
 		return -EBUSY;
@@ -7894,7 +7887,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 		printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
 
 	/* return error if TTY interface open */
-	if (info->count)
+	if (info->port.count)
 		return -EBUSY;
 
 	if (cmd != SIOCWANDEV)
drivers/char/synclink_gt.c +97 -104

552 lines not on this page · raw message

drivers/char/synclinkmp.c +98 -105

569 lines not on this page · raw message

author
#14 lore raw

PATCH 10/20 esp: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch esp to use the new tty_port structures
---

 drivers/char/esp.c       |  272 +++++++++++++++++++++++-----------------------
 include/linux/hayesesp.h |    9 --
 2 files changed, 138 insertions(+), 143 deletions(-)
drivers/char/esp.c +136 -136
index 84840ba..2eaf09f 100644
@@ -128,9 +128,9 @@ static struct tty_driver *esp_driver;
 
 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
 #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
-				tty->name, info->flags, \
+				tty->name, info->port.flags, \
 				serial_driver.refcount, \
-				info->count, tty->count, s)
+				info->port.count, tty->count, s)
 #else
 #define DBG_CNT(s)
 #endif
@@ -172,13 +172,13 @@ static inline int serial_paranoia_check(struct esp_struct *info,
 
 static inline unsigned int serial_in(struct esp_struct *info, int offset)
 {
-	return inb(info->port + offset);
+	return inb(info->io_port + offset);
 }
 
 static inline void serial_out(struct esp_struct *info, int offset,
 			      unsigned char value)
 {
-	outb(value, info->port+offset);
+	outb(value, info->io_port+offset);
 }
 
 /*
@@ -273,7 +273,7 @@ static inline void release_pio_buffer(struct esp_pio_buffer *buf)
 
 static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
 {
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	int i;
 	struct esp_pio_buffer *pio_buf;
 	struct esp_pio_buffer *err_buf;
@@ -295,7 +295,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
 
 	for (i = 0; i < num_bytes - 1; i += 2) {
 		*((unsigned short *)(pio_buf->data + i)) =
-			inw(info->port + UART_ESI_RX);
+			inw(info->io_port + UART_ESI_RX);
 		err_buf->data[i] = serial_in(info, UART_ESI_RWS);
 		err_buf->data[i + 1] = (err_buf->data[i] >> 3) & status_mask;
 		err_buf->data[i] &= status_mask;
@@ -308,7 +308,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
 	}
 
 	/* make sure everything is still ok since interrupts were enabled */
-	tty = info->tty;
+	tty = info->port.tty;
 
 	if (!tty) {
 		release_pio_buffer(pio_buf);
@@ -325,7 +325,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
 
 			if (err_buf->data[i] & 0x04) {
 				flag = TTY_BREAK;
-				if (info->flags & ASYNC_SAK)
+				if (info->port.flags & ASYNC_SAK)
 					do_SAK(tty);
 			} else if (err_buf->data[i] & 0x02)
 				flag = TTY_FRAME;
@@ -370,7 +370,7 @@ static void receive_chars_dma(struct esp_struct *info, int num_bytes)
 static inline void receive_chars_dma_done(struct esp_struct *info,
 					    int status)
 {
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	int num_bytes;
 	unsigned long flags;
 
@@ -396,7 +396,7 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
 			if (status & 0x10) {
 				statflag = TTY_BREAK;
 				(info->icount.brk)++;
-				if (info->flags & ASYNC_SAK)
+				if (info->port.flags & ASYNC_SAK)
 					do_SAK(tty);
 			} else if (status & 0x08) {
 				statflag = TTY_FRAME;
@@ -451,7 +451,7 @@ static inline void transmit_chars_pio(struct esp_struct *info,
 
 		for (i = 0; i < space_avail - 1; i += 2) {
 			outw(*((unsigned short *)(pio_buf->data + i)),
-			     info->port + UART_ESI_TX);
+			     info->io_port + UART_ESI_TX);
 		}
 
 		if (space_avail & 0x0001)
@@ -470,8 +470,8 @@ static inline void transmit_chars_pio(struct esp_struct *info,
 	}
 
 	if (info->xmit_cnt < WAKEUP_CHARS) {
-		if (info->tty)
-			tty_wakeup(info->tty);
+		if (info->port.tty)
+			tty_wakeup(info->port.tty);
 
 #ifdef SERIAL_DEBUG_INTR
 		printk("THRE...");
@@ -507,8 +507,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes)
 	info->xmit_tail = (info->xmit_tail + dma_bytes) & (ESP_XMIT_SIZE - 1);
 
 	if (info->xmit_cnt < WAKEUP_CHARS) {
-		if (info->tty)
-			tty_wakeup(info->tty);
+		if (info->port.tty)
+			tty_wakeup(info->port.tty);
 
 #ifdef SERIAL_DEBUG_INTR
 		printk("THRE...");
@@ -575,18 +575,18 @@ static void check_modem_status(struct esp_struct *info)
 		wake_up_interruptible(&info->delta_msr_wait);
 	}
 
-	if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
+	if ((info->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
 		printk("ttys%d CD now %s...", info->line,
 		       (status & UART_MSR_DCD) ? "on" : "off");
 #endif
 		if (status & UART_MSR_DCD)
-			wake_up_interruptible(&info->open_wait);
+			wake_up_interruptible(&info->port.open_wait);
 		else {
 #ifdef SERIAL_DEBUG_OPEN
 			printk("scheduling hangup...");
 #endif
-			tty_hangup(info->tty);
+			tty_hangup(info->port.tty);
 		}
 	}
 }
@@ -609,7 +609,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
 
 	spin_lock(&info->lock);
 
-	if (!info->tty) {
+	if (!info->port.tty) {
 		spin_unlock(&info->lock);
 		return IRQ_NONE;
 	}
@@ -647,7 +647,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
 		num_bytes = serial_in(info, UART_ESI_STAT1) << 8;
 		num_bytes |= serial_in(info, UART_ESI_STAT2);
 
-		num_bytes = tty_buffer_request_room(info->tty, num_bytes);
+		num_bytes = tty_buffer_request_room(info->port.tty, num_bytes);
 
 		if (num_bytes) {
 			if (dma_bytes ||
@@ -661,7 +661,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
 
 	if (!(info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) &&
 	    (scratch & 0x02) && (info->IER & UART_IER_THRI)) {
-		if ((info->xmit_cnt <= 0) || info->tty->stopped) {
+		if ((info->xmit_cnt <= 0) || info->port.tty->stopped) {
 			info->IER &= ~UART_IER_THRI;
 			serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
 			serial_out(info, UART_ESI_CMD2, info->IER);
@@ -782,7 +782,7 @@ static int startup(struct esp_struct *info)
 
 	spin_lock_irqsave(&info->lock, flags);
 
-	if (info->flags & ASYNC_INITIALIZED)
+	if (info->port.flags & ASYNC_INITIALIZED)
 		goto out;
 
 	if (!info->xmit_buf) {
@@ -806,7 +806,7 @@ static int startup(struct esp_struct *info)
 	num_chars |= serial_in(info, UART_ESI_STAT2);
 
 	while (num_chars > 1) {
-		inw(info->port + UART_ESI_RX);
+		inw(info->io_port + UART_ESI_RX);
 		num_chars -= 2;
 	}
 
@@ -834,9 +834,9 @@ static int startup(struct esp_struct *info)
 
 	if (retval) {
 		if (capable(CAP_SYS_ADMIN)) {
-			if (info->tty)
+			if (info->port.tty)
 				set_bit(TTY_IO_ERROR,
-					&info->tty->flags);
+					&info->port.tty->flags);
 			retval = 0;
 		}
 		goto out_unlocked;
@@ -874,30 +874,30 @@ static int startup(struct esp_struct *info)
 	serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
 	serial_out(info, UART_ESI_CMD2, info->IER);
 
-	if (info->tty)
-		clear_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 	spin_unlock_irqrestore(&info->lock, flags);
 
 	/*
 	 * Set up the tty->alt_speed kludge
 	 */
-	if (info->tty) {
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-			info->tty->alt_speed = 57600;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-			info->tty->alt_speed = 115200;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-			info->tty->alt_speed = 230400;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-			info->tty->alt_speed = 460800;
+	if (info->port.tty) {
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+			info->port.tty->alt_speed = 57600;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+			info->port.tty->alt_speed = 115200;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+			info->port.tty->alt_speed = 230400;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+			info->port.tty->alt_speed = 460800;
 	}
 
 	/*
 	 * set the speed of the serial port
 	 */
 	change_speed(info);
-	info->flags |= ASYNC_INITIALIZED;
+	info->port.flags |= ASYNC_INITIALIZED;
 	return 0;
 
 out:
@@ -914,7 +914,7 @@ static void shutdown(struct esp_struct *info)
 {
 	unsigned long	flags, f;
 
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		return;
 
 #ifdef SERIAL_DEBUG_OPEN
@@ -951,7 +951,7 @@ static void shutdown(struct esp_struct *info)
 
 		while (current_port) {
 			if ((current_port != info) &&
-			    (current_port->flags & ASYNC_INITIALIZED))
+			    (current_port->port.flags & ASYNC_INITIALIZED))
 				break;
 
 			current_port = current_port->next_port;
@@ -974,7 +974,7 @@ static void shutdown(struct esp_struct *info)
 	serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
 	serial_out(info, UART_ESI_CMD2, 0x00);
 
-	if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+	if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL))
 		info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
 
 	info->MCR &= ~UART_MCR_OUT2;
@@ -982,10 +982,10 @@ static void shutdown(struct esp_struct *info)
 	serial_out(info, UART_ESI_CMD2, UART_MCR);
 	serial_out(info, UART_ESI_CMD2, info->MCR);
 
-	if (info->tty)
-		set_bit(TTY_IO_ERROR, &info->tty->flags);
+	if (info->port.tty)
+		set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 
-	info->flags &= ~ASYNC_INITIALIZED;
+	info->port.flags &= ~ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&info->lock, flags);
 }
 
@@ -1002,10 +1002,10 @@ static void change_speed(struct esp_struct *info)
 	unsigned char flow1 = 0, flow2 = 0;
 	unsigned long flags;
 
-	if (!info->tty || !info->tty->termios)
+	if (!info->port.tty || !info->port.tty->termios)
 		return;
-	cflag = info->tty->termios->c_cflag;
-	port = info->port;
+	cflag = info->port.tty->termios->c_cflag;
+	port = info->io_port;
 
 	/* byte size and parity */
 	switch (cflag & CSIZE) {
@@ -1029,9 +1029,9 @@ static void change_speed(struct esp_struct *info)
 	if (cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
 #endif
-	baud = tty_get_baud_rate(info->tty);
+	baud = tty_get_baud_rate(info->port.tty);
 	if (baud == 38400 &&
-		((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+		((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
 		quot = info->custom_divisor;
 	else {
 		if (baud == 134) /* Special case since 134 is really 134.5 */
@@ -1046,49 +1046,49 @@ static void change_speed(struct esp_struct *info)
 	if (baud) {
 		/* Actual rate */
 		baud = BASE_BAUD/quot;
-		tty_encode_baud_rate(info->tty, baud, baud);
+		tty_encode_baud_rate(info->port.tty, baud, baud);
 	}
 	info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50);
 
 	/* CTS flow control flag and modem status interrupts */
 	/* info->IER &= ~UART_IER_MSI; */
 	if (cflag & CRTSCTS) {
-		info->flags |= ASYNC_CTS_FLOW;
+		info->port.flags |= ASYNC_CTS_FLOW;
 		/* info->IER |= UART_IER_MSI; */
 		flow1 = 0x04;
 		flow2 = 0x10;
 	} else
-		info->flags &= ~ASYNC_CTS_FLOW;
+		info->port.flags &= ~ASYNC_CTS_FLOW;
 	if (cflag & CLOCAL)
-		info->flags &= ~ASYNC_CHECK_CD;
+		info->port.flags &= ~ASYNC_CHECK_CD;
 	else
-		info->flags |= ASYNC_CHECK_CD;
+		info->port.flags |= ASYNC_CHECK_CD;
 
 	/*
 	 * Set up parity check flag
 	 */
 	info->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
-	if (I_INPCK(info->tty))
+	if (I_INPCK(info->port.tty))
 		info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
-	if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+	if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
 		info->read_status_mask |= UART_LSR_BI;
 
 	info->ignore_status_mask = 0;
 #if 0
 	/* This should be safe, but for some broken bits of hardware... */
-	if (I_IGNPAR(info->tty)) {
+	if (I_IGNPAR(info->port.tty)) {
 		info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
 		info->read_status_mask |= UART_LSR_PE | UART_LSR_FE;
 	}
 #endif
-	if (I_IGNBRK(info->tty)) {
+	if (I_IGNBRK(info->port.tty)) {
 		info->ignore_status_mask |= UART_LSR_BI;
 		info->read_status_mask |= UART_LSR_BI;
 		/*
 		 * If we're ignore parity and break indicators, ignore
 		 * overruns too.  (For real raw support).
 		 */
-		if (I_IGNPAR(info->tty)) {
+		if (I_IGNPAR(info->port.tty)) {
 			info->ignore_status_mask |= UART_LSR_OE | \
 				UART_LSR_PE | UART_LSR_FE;
 			info->read_status_mask |= UART_LSR_OE | \
@@ -1096,7 +1096,7 @@ static void change_speed(struct esp_struct *info)
 		}
 	}
 
-	if (I_IXOFF(info->tty))
+	if (I_IXOFF(info->port.tty))
 		flow1 |= 0x81;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -1116,10 +1116,10 @@ static void change_speed(struct esp_struct *info)
 	serial_out(info, UART_ESI_CMD2, flow2);
 
 	/* set flow control characters (XON/XOFF only) */
-	if (I_IXOFF(info->tty)) {
+	if (I_IXOFF(info->port.tty)) {
 		serial_out(info, UART_ESI_CMD1, ESI_SET_FLOW_CHARS);
-		serial_out(info, UART_ESI_CMD2, START_CHAR(info->tty));
-		serial_out(info, UART_ESI_CMD2, STOP_CHAR(info->tty));
+		serial_out(info, UART_ESI_CMD2, START_CHAR(info->port.tty));
+		serial_out(info, UART_ESI_CMD2, STOP_CHAR(info->port.tty));
 		serial_out(info, UART_ESI_CMD2, 0x10);
 		serial_out(info, UART_ESI_CMD2, 0x21);
 		switch (cflag & CSIZE) {
@@ -1355,9 +1355,9 @@ static int get_serial_info(struct esp_struct *info,
 	memset(&tmp, 0, sizeof(tmp));
 	tmp.type = PORT_16550A;
 	tmp.line = info->line;
-	tmp.port = info->port;
+	tmp.port = info->io_port;
 	tmp.irq = info->irq;
-	tmp.flags = info->flags;
+	tmp.flags = info->port.flags;
 	tmp.xmit_fifo_size = 1024;
 	tmp.baud_base = BASE_BAUD;
 	tmp.close_delay = info->close_delay;
@@ -1407,7 +1407,7 @@ static int set_serial_info(struct esp_struct *info,
 
 	if ((new_serial.type != PORT_16550A) ||
 	    (new_serial.hub6) ||
-	    (info->port != new_serial.port) ||
+	    (info->io_port != new_serial.port) ||
 	    (new_serial.baud_base != BASE_BAUD) ||
 	    (new_serial.irq > 15) ||
 	    (new_serial.irq < 2) ||
@@ -1425,9 +1425,9 @@ static int set_serial_info(struct esp_struct *info,
 		if (change_irq ||
 		    (new_serial.close_delay != info->close_delay) ||
 		    ((new_serial.flags & ~ASYNC_USR_MASK) !=
-		     (info->flags & ~ASYNC_USR_MASK)))
+		     (info->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
-		info->flags = ((info->flags & ~ASYNC_USR_MASK) |
+		info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
 			       (new_serial.flags & ASYNC_USR_MASK));
 		info->custom_divisor = new_serial.custom_divisor;
 	} else {
@@ -1441,9 +1441,9 @@ static int set_serial_info(struct esp_struct *info,
 				if ((current_async->line >= info->line) &&
 				    (current_async->line < (info->line + 8))) {
 					if (current_async == info) {
-						if (current_async->count > 1)
+						if (current_async->port.count > 1)
 							return -EBUSY;
-					} else if (current_async->count)
+					} else if (current_async->port.count)
 						return -EBUSY;
 				}
 
@@ -1456,7 +1456,7 @@ static int set_serial_info(struct esp_struct *info,
 		 * At this point, we start making changes.....
 		 */
 
-		info->flags = ((info->flags & ~ASYNC_FLAGS) |
+		info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
 			       (new_serial.flags & ASYNC_FLAGS));
 		info->custom_divisor = new_serial.custom_divisor;
 		info->close_delay = new_serial.close_delay * HZ/100;
@@ -1487,18 +1487,18 @@ static int set_serial_info(struct esp_struct *info,
 		}
 	}
 
-	if (info->flags & ASYNC_INITIALIZED) {
-		if (((old_info.flags & ASYNC_SPD_MASK) !=
-		     (info->flags & ASYNC_SPD_MASK)) ||
+	if (info->port.flags & ASYNC_INITIALIZED) {
+		if (((old_info.port.flags & ASYNC_SPD_MASK) !=
+		     (info->port.flags & ASYNC_SPD_MASK)) ||
 		    (old_info.custom_divisor != info->custom_divisor)) {
-			if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-				info->tty->alt_speed = 57600;
-			if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-				info->tty->alt_speed = 115200;
-			if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-				info->tty->alt_speed = 230400;
-			if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-				info->tty->alt_speed = 460800;
+			if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+				info->port.tty->alt_speed = 57600;
+			if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+				info->port.tty->alt_speed = 115200;
+			if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+				info->port.tty->alt_speed = 230400;
+			if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+				info->port.tty->alt_speed = 460800;
 			change_speed(info);
 		}
 	} else
@@ -1554,9 +1554,9 @@ static int set_esp_config(struct esp_struct *info,
 
 			while (current_async) {
 				if (current_async == info) {
-					if (current_async->count > 1)
+					if (current_async->port.count > 1)
 						return -EBUSY;
-				} else if (current_async->count)
+				} else if (current_async->port.count)
 					return -EBUSY;
 
 				current_async = current_async->next_port;
@@ -1578,7 +1578,7 @@ static int set_esp_config(struct esp_struct *info,
 			spin_unlock_irqrestore(&info->lock, flags);
 		} else {
 			/* DMA mode to PIO mode only */
-			if (info->count > 1)
+			if (info->port.count > 1)
 				return -EBUSY;
 
 			shutdown(info);
@@ -1634,7 +1634,7 @@ static int set_esp_config(struct esp_struct *info,
 		spin_unlock_irqrestore(&info->lock, flags);
 	}
 
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		retval = startup(info);
 
 	return retval;
@@ -1917,9 +1917,9 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 
 #ifdef SERIAL_DEBUG_OPEN
 	printk(KERN_DEBUG "rs_close ttys%d, count = %d\n",
-						info->line, info->count);
+						info->line, info->port.count);
 #endif
-	if (tty->count == 1 && info->count != 1) {
+	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
@@ -1927,19 +1927,19 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 		 * one, we've got real problems, since it means the
 		 * serial port won't be shutdown.
 		 */
-		printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count);
-		info->count = 1;
+		printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->port.count is %d\n", info->port.count);
+		info->port.count = 1;
 	}
-	if (--info->count < 0) {
+	if (--info->port.count < 0) {
 		printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
-		       info->line, info->count);
-		info->count = 0;
+		       info->line, info->port.count);
+		info->port.count = 0;
 	}
-	if (info->count) {
+	if (info->port.count) {
 		DBG_CNT("before DEC-2");
 		goto out;
 	}
-	info->flags |= ASYNC_CLOSING;
+	info->port.flags |= ASYNC_CLOSING;
 
 	spin_unlock_irqrestore(&info->lock, flags);
 	/*
@@ -1958,7 +1958,7 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 	/* info->IER &= ~UART_IER_RLSI; */
 	info->IER &= ~UART_IER_RDI;
 	info->read_status_mask &= ~UART_LSR_DR;
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
 
 		spin_lock_irqsave(&info->lock, flags);
 		serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
@@ -1981,15 +1981,15 @@ static void rs_close(struct tty_struct *tty, struct file *filp)
 	rs_flush_buffer(tty);
 	tty_ldisc_flush(tty);
 	tty->closing = 0;
-	info->tty = NULL;
+	info->port.tty = NULL;
 
-	if (info->blocked_open) {
+	if (info->port.blocked_open) {
 		if (info->close_delay)
 			msleep_interruptible(jiffies_to_msecs(info->close_delay));
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	}
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	wake_up_interruptible(&info->close_wait);
+	info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	wake_up_interruptible(&info->port.close_wait);
 	return;
 
 out:
@@ -2047,10 +2047,10 @@ static void esp_hangup(struct tty_struct *tty)
 
 	rs_flush_buffer(tty);
 	shutdown(info);
-	info->count = 0;
-	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	info->tty = NULL;
-	wake_up_interruptible(&info->open_wait);
+	info->port.count = 0;
+	info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	info->port.tty = NULL;
+	wake_up_interruptible(&info->port.open_wait);
 }
 
 /*
@@ -2071,11 +2071,11 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	 * until it's done, and then try again.
 	 */
 	if (tty_hung_up_p(filp) ||
-	    (info->flags & ASYNC_CLOSING)) {
-		if (info->flags & ASYNC_CLOSING)
-			interruptible_sleep_on(&info->close_wait);
+	    (info->port.flags & ASYNC_CLOSING)) {
+		if (info->port.flags & ASYNC_CLOSING)
+			interruptible_sleep_on(&info->port.close_wait);
 #ifdef SERIAL_DO_RESTART
-		if (info->flags & ASYNC_HUP_NOTIFY)
+		if (info->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		else
 			return -ERESTARTSYS;
@@ -2090,7 +2090,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	 */
 	if ((filp->f_flags & O_NONBLOCK) ||
 	    (tty->flags & (1 << TTY_IO_ERROR))) {
-		info->flags |= ASYNC_NORMAL_ACTIVE;
+		info->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -2100,20 +2100,20 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 	/*
 	 * Block waiting for the carrier detect and the line to become
 	 * free (i.e., not in use by the callout).  While we are in
-	 * this loop, info->count is dropped by one, so that
+	 * this loop, info->port.count is dropped by one, so that
 	 * rs_close() knows when to free things.  We restore it upon
 	 * exit, either normal or abnormal.
 	 */
 	retval = 0;
-	add_wait_queue(&info->open_wait, &wait);
+	add_wait_queue(&info->port.open_wait, &wait);
 #ifdef SERIAL_DEBUG_OPEN
 	printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n",
-	       info->line, info->count);
+	       info->line, info->port.count);
 #endif
 	spin_lock_irqsave(&info->lock, flags);
 	if (!tty_hung_up_p(filp))
-		info->count--;
-	info->blocked_open++;
+		info->port.count--;
+	info->port.blocked_open++;
 	while (1) {
 		if ((tty->termios->c_cflag & CBAUD)) {
 			unsigned int scratch;
@@ -2128,9 +2128,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		}
 		set_current_state(TASK_INTERRUPTIBLE);
 		if (tty_hung_up_p(filp) ||
-		    !(info->flags & ASYNC_INITIALIZED)) {
+		    !(info->port.flags & ASYNC_INITIALIZED)) {
 #ifdef SERIAL_DO_RESTART
-			if (info->flags & ASYNC_HUP_NOTIFY)
+			if (info->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
@@ -2144,7 +2144,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD)
 			do_clocal = 1;
 
-		if (!(info->flags & ASYNC_CLOSING) &&
+		if (!(info->port.flags & ASYNC_CLOSING) &&
 		    (do_clocal))
 			break;
 		if (signal_pending(current)) {
@@ -2153,25 +2153,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
 		}
 #ifdef SERIAL_DEBUG_OPEN
 		printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n",
-		       info->line, info->count);
+		       info->line, info->port.count);
 #endif
 		spin_unlock_irqrestore(&info->lock, flags);
 		schedule();
 		spin_lock_irqsave(&info->lock, flags);
 	}
 	set_current_state(TASK_RUNNING);
-	remove_wait_queue(&info->open_wait, &wait);
+	remove_wait_queue(&info->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp))
-		info->count++;
-	info->blocked_open--;
+		info->port.count++;
+	info->port.blocked_open--;
 	spin_unlock_irqrestore(&info->lock, flags);
 #ifdef SERIAL_DEBUG_OPEN
 	printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n",
-	       info->line, info->count);
+	       info->line, info->port.count);
 #endif
 	if (retval)
 		return retval;
-	info->flags |= ASYNC_NORMAL_ACTIVE;
+	info->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -2204,12 +2204,12 @@ static int esp_open(struct tty_struct *tty, struct file *filp)
 	}
 
 #ifdef SERIAL_DEBUG_OPEN
-	printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count);
+	printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->port.count);
 #endif
 	spin_lock_irqsave(&info->lock, flags);
-	info->count++;
+	info->port.count++;
 	tty->driver_data = info;
-	info->tty = tty;
+	info->port.tty = tty;
 
 	spin_unlock_irqrestore(&info->lock, flags);
 
@@ -2263,7 +2263,7 @@ static int autoconfig(struct esp_struct *info)
 	int port_detected = 0;
 	unsigned long flags;
 
-	if (!request_region(info->port, REGION_SIZE, "esp serial"))
+	if (!request_region(info->io_port, REGION_SIZE, "esp serial"))
 		return -EIO;
 
 	spin_lock_irqsave(&info->lock, flags);
@@ -2300,7 +2300,7 @@ static int autoconfig(struct esp_struct *info)
 		}
 	}
 	if (!port_detected)
-		release_region(info->port, REGION_SIZE);
+		release_region(info->io_port, REGION_SIZE);
 
 	spin_unlock_irqrestore(&info->lock, flags);
 	return (port_detected);
@@ -2414,7 +2414,7 @@ static int __init espserial_init(void)
 	offset = 0;
 
 	do {
-		info->port = esp[i] + offset;
+		info->io_port = esp[i] + offset;
 		info->irq = irq[i];
 		info->line = (i * 8) + (offset / 8);
 
@@ -2425,9 +2425,9 @@ static int __init espserial_init(void)
 		}
 
 		info->custom_divisor = (divisor[i] >> (offset / 2)) & 0xf;
-		info->flags = STD_COM_FLAGS;
+		info->port.flags = STD_COM_FLAGS;
 		if (info->custom_divisor)
-			info->flags |= ASYNC_SPD_CUST;
+			info->port.flags |= ASYNC_SPD_CUST;
 		info->magic = ESP_MAGIC;
 		info->close_delay = 5*HZ/10;
 		info->closing_wait = 30*HZ;
@@ -2436,13 +2436,13 @@ static int __init espserial_init(void)
 		info->config.flow_off = flow_off;
 		info->config.pio_threshold = pio_threshold;
 		info->next_port = ports;
-		init_waitqueue_head(&info->open_wait);
-		init_waitqueue_head(&info->close_wait);
+		init_waitqueue_head(&info->port.open_wait);
+		init_waitqueue_head(&info->port.close_wait);
 		init_waitqueue_head(&info->delta_msr_wait);
 		init_waitqueue_head(&info->break_wait);
 		ports = info;
 		printk(KERN_INFO "ttyP%d at 0x%04x (irq = %d) is an ESP ",
-			info->line, info->port, info->irq);
+			info->line, info->io_port, info->irq);
 
 		if (info->line % 8) {
 			printk("secondary port\n");
@@ -2498,8 +2498,8 @@ static void __exit espserial_exit(void)
 	put_tty_driver(esp_driver);
 
 	while (ports) {
-		if (ports->port)
-			release_region(ports->port, REGION_SIZE);
+		if (ports->io_port)
+			release_region(ports->io_port, REGION_SIZE);
 		temp_async = ports->next_port;
 		kfree(ports);
 		ports = temp_async;
include/linux/hayesesp.h +2 -7
index 2177ee5..940aeb5 100644
@@ -76,11 +76,10 @@ struct hayes_esp_config {
 
 struct esp_struct {
 	int			magic;
+	struct tty_port		port;
 	spinlock_t		lock;
-	int			port;
+	int			io_port;
 	int			irq;
-	int			flags; 		/* defined in tty.h */
-	struct tty_struct 	*tty;
 	int			read_status_mask;
 	int			ignore_status_mask;
 	int			timeout;
@@ -93,14 +92,10 @@ struct esp_struct {
 	int			MCR; 	/* Modem control register */
 	unsigned long		last_active;
 	int			line;
-	int			count;	    /* # of fd on device */
-	int			blocked_open; /* # of blocked opens */
 	unsigned char 		*xmit_buf;
 	int			xmit_head;
 	int			xmit_tail;
 	int			xmit_cnt;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
 	wait_queue_head_t	delta_msr_wait;
 	wait_queue_head_t	break_wait;
 	struct async_icount	icount;	/* kernel counters for the 4 input interrupts */
author
#15 lore raw

PATCH 11/20 istallion: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch istallion to use the new tty_port structure
---

 drivers/char/istallion.c  |  116 +++++++++++++++++++++++----------------------
 include/linux/istallion.h |    6 --
 2 files changed, 59 insertions(+), 63 deletions(-)
drivers/char/istallion.c +58 -58
index 7c8b62f..6ef1c56 100644
@@ -735,8 +735,8 @@ static void stli_cleanup_ports(struct stlibrd *brdp)
 	for (j = 0; j < STL_MAXPORTS; j++) {
 		portp = brdp->ports[j];
 		if (portp != NULL) {
-			if (portp->tty != NULL)
-				tty_hangup(portp->tty);
+			if (portp->port.tty != NULL)
+				tty_hangup(portp->port.tty);
 			kfree(portp);
 		}
 	}
@@ -811,9 +811,9 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
  *	The sleep here does not need interrupt protection since the wakeup
  *	for it is done with the same context.
  */
-	if (portp->flags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&portp->close_wait);
-		if (portp->flags & ASYNC_HUP_NOTIFY)
+	if (portp->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&portp->port.close_wait);
+		if (portp->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		return -ERESTARTSYS;
 	}
@@ -824,7 +824,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
  *	requires several commands to the board we will need to wait for any
  *	other open that is already initializing the port.
  */
-	portp->tty = tty;
+	portp->port.tty = tty;
 	tty->driver_data = portp;
 	portp->refcount++;
 
@@ -833,10 +833,10 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
 	if (signal_pending(current))
 		return -ERESTARTSYS;
 
-	if ((portp->flags & ASYNC_INITIALIZED) == 0) {
+	if ((portp->port.flags & ASYNC_INITIALIZED) == 0) {
 		set_bit(ST_INITIALIZING, &portp->state);
 		if ((rc = stli_initopen(brdp, portp)) >= 0) {
-			portp->flags |= ASYNC_INITIALIZED;
+			portp->port.flags |= ASYNC_INITIALIZED;
 			clear_bit(TTY_IO_ERROR, &tty->flags);
 		}
 		clear_bit(ST_INITIALIZING, &portp->state);
@@ -851,9 +851,9 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
  *	The sleep here does not need interrupt protection since the wakeup
  *	for it is done with the same context.
  */
-	if (portp->flags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&portp->close_wait);
-		if (portp->flags & ASYNC_HUP_NOTIFY)
+	if (portp->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&portp->port.close_wait);
+		if (portp->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		return -ERESTARTSYS;
 	}
@@ -867,7 +867,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
 		if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
 			return rc;
 	}
-	portp->flags |= ASYNC_NORMAL_ACTIVE;
+	portp->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }
 
@@ -895,7 +895,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
 		return;
 	}
 
-	portp->flags |= ASYNC_CLOSING;
+	portp->port.flags |= ASYNC_CLOSING;
 
 /*
  *	May want to wait for data to drain before closing. The BUSY flag
@@ -911,7 +911,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
 	if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
 		tty_wait_until_sent(tty, portp->closing_wait);
 
-	portp->flags &= ~ASYNC_INITIALIZED;
+	portp->port.flags &= ~ASYNC_INITIALIZED;
 	brdp = stli_brds[portp->brdnr];
 	stli_rawclose(brdp, portp, 0, 0);
 	if (tty->termios->c_cflag & HUPCL) {
@@ -931,16 +931,16 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
 	stli_flushbuffer(tty);
 
 	tty->closing = 0;
-	portp->tty = NULL;
+	portp->port.tty = NULL;
 
 	if (portp->openwaitcnt) {
 		if (portp->close_delay)
 			msleep_interruptible(jiffies_to_msecs(portp->close_delay));
-		wake_up_interruptible(&portp->open_wait);
+		wake_up_interruptible(&portp->port.open_wait);
 	}
 
-	portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	wake_up_interruptible(&portp->close_wait);
+	portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	wake_up_interruptible(&portp->port.close_wait);
 }
 
 /*****************************************************************************/
@@ -970,7 +970,7 @@ static int stli_initopen(struct stlibrd *brdp, struct stliport *portp)
 	    sizeof(asynotify_t), 0)) < 0)
 		return rc;
 
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return -ENODEV;
 	stli_mkasyport(portp, &aport, tty->termios);
@@ -1169,7 +1169,7 @@ static int stli_setport(struct stliport *portp)
 
 	if (portp == NULL)
 		return -ENODEV;
-	if (portp->tty == NULL)
+	if (portp->port.tty == NULL)
 		return -ENODEV;
 	if (portp->brdnr >= stli_nrbrds)
 		return -ENODEV;
@@ -1177,7 +1177,7 @@ static int stli_setport(struct stliport *portp)
 	if (brdp == NULL)
 		return -ENODEV;
 
-	stli_mkasyport(portp, &aport, portp->tty->termios);
+	stli_mkasyport(portp, &aport, portp->port.tty->termios);
 	return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
 }
 
@@ -1196,7 +1196,7 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct
 	rc = 0;
 	doclocal = 0;
 
-	if (portp->tty->termios->c_cflag & CLOCAL)
+	if (portp->port.tty->termios->c_cflag & CLOCAL)
 		doclocal++;
 
 	spin_lock_irqsave(&stli_lock, flags);
@@ -1211,14 +1211,14 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct
 		    &portp->asig, sizeof(asysigs_t), 0)) < 0)
 			break;
 		if (tty_hung_up_p(filp) ||
-		    ((portp->flags & ASYNC_INITIALIZED) == 0)) {
-			if (portp->flags & ASYNC_HUP_NOTIFY)
+		    ((portp->port.flags & ASYNC_INITIALIZED) == 0)) {
+			if (portp->port.flags & ASYNC_HUP_NOTIFY)
 				rc = -EBUSY;
 			else
 				rc = -ERESTARTSYS;
 			break;
 		}
-		if (((portp->flags & ASYNC_CLOSING) == 0) &&
+		if (((portp->port.flags & ASYNC_CLOSING) == 0) &&
 		    (doclocal || (portp->sigs & TIOCM_CD))) {
 			break;
 		}
@@ -1226,7 +1226,7 @@ static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct
 			rc = -ERESTARTSYS;
 			break;
 		}
-		interruptible_sleep_on(&portp->open_wait);
+		interruptible_sleep_on(&portp->port.open_wait);
 	}
 
 	spin_lock_irqsave(&stli_lock, flags);
@@ -1548,7 +1548,7 @@ static int stli_getserial(struct stliport *portp, struct serial_struct __user *s
 	sio.type = PORT_UNKNOWN;
 	sio.line = portp->portnr;
 	sio.irq = 0;
-	sio.flags = portp->flags;
+	sio.flags = portp->port.flags;
 	sio.baud_base = portp->baud_base;
 	sio.close_delay = portp->close_delay;
 	sio.closing_wait = portp->closing_wait;
@@ -1583,11 +1583,11 @@ static int stli_setserial(struct stliport *portp, struct serial_struct __user *s
 		if ((sio.baud_base != portp->baud_base) ||
 		    (sio.close_delay != portp->close_delay) ||
 		    ((sio.flags & ~ASYNC_USR_MASK) !=
-		    (portp->flags & ~ASYNC_USR_MASK)))
+		    (portp->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
 	} 
 
-	portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
+	portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) |
 		(sio.flags & ASYNC_USR_MASK);
 	portp->baud_base = sio.baud_base;
 	portp->close_delay = sio.close_delay;
@@ -1751,7 +1751,7 @@ static void stli_settermios(struct tty_struct *tty, struct ktermios *old)
 	if ((old->c_cflag & CRTSCTS) && ((tiosp->c_cflag & CRTSCTS) == 0))
 		tty->hw_stopped = 0;
 	if (((old->c_cflag & CLOCAL) == 0) && (tiosp->c_cflag & CLOCAL))
-		wake_up_interruptible(&portp->open_wait);
+		wake_up_interruptible(&portp->port.open_wait);
 }
 
 /*****************************************************************************/
@@ -1834,7 +1834,7 @@ static void stli_hangup(struct tty_struct *tty)
 	if (brdp == NULL)
 		return;
 
-	portp->flags &= ~ASYNC_INITIALIZED;
+	portp->port.flags &= ~ASYNC_INITIALIZED;
 
 	if (!test_bit(ST_CLOSING, &portp->state))
 		stli_rawclose(brdp, portp, 0, 0);
@@ -1855,12 +1855,12 @@ static void stli_hangup(struct tty_struct *tty)
 	clear_bit(ST_TXBUSY, &portp->state);
 	clear_bit(ST_RXSTOP, &portp->state);
 	set_bit(TTY_IO_ERROR, &tty->flags);
-	portp->tty = NULL;
-	portp->flags &= ~ASYNC_NORMAL_ACTIVE;
+	portp->port.tty = NULL;
+	portp->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 	portp->refcount = 0;
 	spin_unlock_irqrestore(&stli_lock, flags);
 
-	wake_up_interruptible(&portp->open_wait);
+	wake_up_interruptible(&portp->port.open_wait);
 }
 
 /*****************************************************************************/
@@ -2188,7 +2188,7 @@ static void stli_read(struct stlibrd *brdp, struct stliport *portp)
 
 	if (test_bit(ST_RXSTOP, &portp->state))
 		return;
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return;
 
@@ -2362,7 +2362,7 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
 	if (ap->notify) {
 		nt = ap->changed;
 		ap->notify = 0;
-		tty = portp->tty;
+		tty = portp->port.tty;
 
 		if (nt.signal & SG_DCD) {
 			oldsigs = portp->sigs;
@@ -2370,10 +2370,10 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
 			clear_bit(ST_GETSIGS, &portp->state);
 			if ((portp->sigs & TIOCM_CD) &&
 			    ((oldsigs & TIOCM_CD) == 0))
-				wake_up_interruptible(&portp->open_wait);
+				wake_up_interruptible(&portp->port.open_wait);
 			if ((oldsigs & TIOCM_CD) &&
 			    ((portp->sigs & TIOCM_CD) == 0)) {
-				if (portp->flags & ASYNC_CHECK_CD) {
+				if (portp->port.flags & ASYNC_CHECK_CD) {
 					if (tty)
 						tty_hangup(tty);
 				}
@@ -2392,7 +2392,7 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp)
 		if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
 			if (tty != NULL) {
 				tty_insert_flip_char(tty, 0, TTY_BREAK);
-				if (portp->flags & ASYNC_SAK) {
+				if (portp->port.flags & ASYNC_SAK) {
 					do_SAK(tty);
 					EBRDENABLE(brdp);
 				}
@@ -2542,17 +2542,17 @@ static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermio
 /*
  *	Start of by setting the baud, char size, parity and stop bit info.
  */
-	pp->baudout = tty_get_baud_rate(portp->tty);
+	pp->baudout = tty_get_baud_rate(portp->port.tty);
 	if ((tiosp->c_cflag & CBAUD) == B38400) {
-		if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			pp->baudout = 57600;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			pp->baudout = 115200;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			pp->baudout = 230400;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			pp->baudout = 460800;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
 			pp->baudout = (portp->baud_base / portp->custom_divisor);
 	}
 	if (pp->baudout > STL_MAXBAUD)
@@ -2625,9 +2625,9 @@ static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermio
  *	Set up clocal processing as required.
  */
 	if (tiosp->c_cflag & CLOCAL)
-		portp->flags &= ~ASYNC_CHECK_CD;
+		portp->port.flags &= ~ASYNC_CHECK_CD;
 	else
-		portp->flags |= ASYNC_CHECK_CD;
+		portp->port.flags |= ASYNC_CHECK_CD;
 
 /*
  *	Transfer any persistent flags into the asyport structure.
@@ -2703,8 +2703,8 @@ static int stli_initports(struct stlibrd *brdp)
 		portp->baud_base = STL_BAUDBASE;
 		portp->close_delay = STL_CLOSEDELAY;
 		portp->closing_wait = 30 * HZ;
-		init_waitqueue_head(&portp->open_wait);
-		init_waitqueue_head(&portp->close_wait);
+		init_waitqueue_head(&portp->port.open_wait);
+		init_waitqueue_head(&portp->port.close_wait);
 		init_waitqueue_head(&portp->raw_wait);
 		panelport++;
 		if (panelport >= brdp->panels[panelnr]) {
@@ -4246,18 +4246,18 @@ static int stli_portcmdstats(struct stliport *portp)
 	stli_comstats.panel = portp->panelnr;
 	stli_comstats.port = portp->portnr;
 	stli_comstats.state = portp->state;
-	stli_comstats.flags = portp->flags;
+	stli_comstats.flags = portp->port.flag;
 
 	spin_lock_irqsave(&brd_lock, flags);
-	if (portp->tty != NULL) {
-		if (portp->tty->driver_data == portp) {
-			stli_comstats.ttystate = portp->tty->flags;
+	if (portp->port.tty != NULL) {
+		if (portp->port.tty->driver_data == portp) {
+			stli_comstats.ttystate = portp->port.tty->flags;
 			stli_comstats.rxbuffered = -1;
-			if (portp->tty->termios != NULL) {
-				stli_comstats.cflags = portp->tty->termios->c_cflag;
-				stli_comstats.iflags = portp->tty->termios->c_iflag;
-				stli_comstats.oflags = portp->tty->termios->c_oflag;
-				stli_comstats.lflags = portp->tty->termios->c_lflag;
+			if (portp->port.tty->termios != NULL) {
+				stli_comstats.cflags = portp->port.tty->termios->c_cflag;
+				stli_comstats.iflags = portp->port.tty->termios->c_iflag;
+				stli_comstats.oflags = portp->port.tty->termios->c_oflag;
+				stli_comstats.lflags = portp->port.tty->termios->c_lflag;
 			}
 		}
 	}
include/linux/istallion.h +1 -5
index 5a84fe9..0d18407 100644
@@ -51,25 +51,21 @@
  */
 struct stliport {
 	unsigned long		magic;
+	struct tty_port		port;
 	unsigned int		portnr;
 	unsigned int		panelnr;
 	unsigned int		brdnr;
 	unsigned long		state;
 	unsigned int		devnr;
-	int			flags;
 	int			baud_base;
 	int			custom_divisor;
 	int			close_delay;
 	int			closing_wait;
-	int			refcount;
 	int			openwaitcnt;
 	int			rc;
 	int			argsize;
 	void			*argp;
 	unsigned int		rxmarkmsk;
-	struct tty_struct	*tty;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
 	wait_queue_head_t	raw_wait;
 	struct asysigs		asig;
 	unsigned long		addr;
author
#16 lore raw

PATCH 12/20 stallion: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch the stallion driver to use the tty_port structure
---

 drivers/char/stallion.c  |  160 +++++++++++++++++++++++-----------------------
 include/linux/stallion.h |    6 --
 2 files changed, 81 insertions(+), 85 deletions(-)
drivers/char/stallion.c +80 -80
index d17be10..0243efb 100644
@@ -613,17 +613,17 @@ static void stl_cd_change(struct stlport *portp)
 {
 	unsigned int oldsigs = portp->sigs;
 
-	if (!portp->tty)
+	if (!portp->port.tty)
 		return;
 
 	portp->sigs = stl_getsignals(portp);
 
 	if ((portp->sigs & TIOCM_CD) && ((oldsigs & TIOCM_CD) == 0))
-		wake_up_interruptible(&portp->open_wait);
+		wake_up_interruptible(&portp->port.open_wait);
 
 	if ((oldsigs & TIOCM_CD) && ((portp->sigs & TIOCM_CD) == 0))
-		if (portp->flags & ASYNC_CHECK_CD)
-			tty_hangup(portp->tty);
+		if (portp->port.flags & ASYNC_CHECK_CD)
+			tty_hangup(portp->port.tty);
 }
 
 /*
@@ -734,11 +734,11 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
  *	On the first open of the device setup the port hardware, and
  *	initialize the per port data structure.
  */
-	portp->tty = tty;
+	portp->port.tty = tty;
 	tty->driver_data = portp;
-	portp->refcount++;
+	portp->port.count++;
 
-	if ((portp->flags & ASYNC_INITIALIZED) == 0) {
+	if ((portp->port.flags & ASYNC_INITIALIZED) == 0) {
 		if (!portp->tx.buf) {
 			portp->tx.buf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL);
 			if (!portp->tx.buf)
@@ -752,7 +752,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
 		stl_enablerxtx(portp, 1, 1);
 		stl_startrxtx(portp, 1, 0);
 		clear_bit(TTY_IO_ERROR, &tty->flags);
-		portp->flags |= ASYNC_INITIALIZED;
+		portp->port.flags |= ASYNC_INITIALIZED;
 	}
 
 /*
@@ -761,9 +761,9 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
  *	The sleep here does not need interrupt protection since the wakeup
  *	for it is done with the same context.
  */
-	if (portp->flags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&portp->close_wait);
-		if (portp->flags & ASYNC_HUP_NOTIFY)
+	if (portp->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&portp->port.close_wait);
+		if (portp->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		return -ERESTARTSYS;
 	}
@@ -777,7 +777,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp)
 		if ((rc = stl_waitcarrier(portp, filp)) != 0)
 			return rc;
 
-	portp->flags |= ASYNC_NORMAL_ACTIVE;
+	portp->port.flags |= ASYNC_NORMAL_ACTIVE;
 
 	return 0;
 }
@@ -801,25 +801,25 @@ static int stl_waitcarrier(struct stlport *portp, struct file *filp)
 
 	spin_lock_irqsave(&stallion_lock, flags);
 
-	if (portp->tty->termios->c_cflag & CLOCAL)
+	if (portp->port.tty->termios->c_cflag & CLOCAL)
 		doclocal++;
 
 	portp->openwaitcnt++;
 	if (! tty_hung_up_p(filp))
-		portp->refcount--;
+		portp->port.count--;
 
 	for (;;) {
 		/* Takes brd_lock internally */
 		stl_setsignals(portp, 1, 1);
 		if (tty_hung_up_p(filp) ||
-		    ((portp->flags & ASYNC_INITIALIZED) == 0)) {
-			if (portp->flags & ASYNC_HUP_NOTIFY)
+		    ((portp->port.flags & ASYNC_INITIALIZED) == 0)) {
+			if (portp->port.flags & ASYNC_HUP_NOTIFY)
 				rc = -EBUSY;
 			else
 				rc = -ERESTARTSYS;
 			break;
 		}
-		if (((portp->flags & ASYNC_CLOSING) == 0) &&
+		if (((portp->port.flags & ASYNC_CLOSING) == 0) &&
 		    (doclocal || (portp->sigs & TIOCM_CD)))
 			break;
 		if (signal_pending(current)) {
@@ -827,11 +827,11 @@ static int stl_waitcarrier(struct stlport *portp, struct file *filp)
 			break;
 		}
 		/* FIXME */
-		interruptible_sleep_on(&portp->open_wait);
+		interruptible_sleep_on(&portp->port.open_wait);
 	}
 
 	if (! tty_hung_up_p(filp))
-		portp->refcount++;
+		portp->port.count++;
 	portp->openwaitcnt--;
 	spin_unlock_irqrestore(&stallion_lock, flags);
 
@@ -904,15 +904,15 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
 		spin_unlock_irqrestore(&stallion_lock, flags);
 		return;
 	}
-	if ((tty->count == 1) && (portp->refcount != 1))
-		portp->refcount = 1;
-	if (portp->refcount-- > 1) {
+	if ((tty->count == 1) && (portp->port.count != 1))
+		portp->port.count = 1;
+	if (portp->port.count-- > 1) {
 		spin_unlock_irqrestore(&stallion_lock, flags);
 		return;
 	}
 
-	portp->refcount = 0;
-	portp->flags |= ASYNC_CLOSING;
+	portp->port.count = 0;
+	portp->port.flags |= ASYNC_CLOSING;
 
 /*
  *	May want to wait for any data to drain before closing. The BUSY
@@ -930,7 +930,7 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
 
 
 	spin_lock_irqsave(&stallion_lock, flags);
-	portp->flags &= ~ASYNC_INITIALIZED;
+	portp->port.flags &= ~ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&stallion_lock, flags);
 
 	stl_disableintrs(portp);
@@ -949,16 +949,16 @@ static void stl_close(struct tty_struct *tty, struct file *filp)
 	tty_ldisc_flush(tty);
 
 	tty->closing = 0;
-	portp->tty = NULL;
+	portp->port.tty = NULL;
 
 	if (portp->openwaitcnt) {
 		if (portp->close_delay)
 			msleep_interruptible(jiffies_to_msecs(portp->close_delay));
-		wake_up_interruptible(&portp->open_wait);
+		wake_up_interruptible(&portp->port.open_wait);
 	}
 
-	portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
-	wake_up_interruptible(&portp->close_wait);
+	portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	wake_up_interruptible(&portp->port.close_wait);
 }
 
 /*****************************************************************************/
@@ -1153,7 +1153,7 @@ static int stl_getserial(struct stlport *portp, struct serial_struct __user *sp)
 	memset(&sio, 0, sizeof(struct serial_struct));
 	sio.line = portp->portnr;
 	sio.port = portp->ioaddr;
-	sio.flags = portp->flags;
+	sio.flags = portp->port.flags;
 	sio.baud_base = portp->baud_base;
 	sio.close_delay = portp->close_delay;
 	sio.closing_wait = portp->closing_wait;
@@ -1194,17 +1194,17 @@ static int stl_setserial(struct stlport *portp, struct serial_struct __user *sp)
 		if ((sio.baud_base != portp->baud_base) ||
 		    (sio.close_delay != portp->close_delay) ||
 		    ((sio.flags & ~ASYNC_USR_MASK) !=
-		    (portp->flags & ~ASYNC_USR_MASK)))
+		    (portp->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
 	} 
 
-	portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
+	portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) |
 		(sio.flags & ASYNC_USR_MASK);
 	portp->baud_base = sio.baud_base;
 	portp->close_delay = sio.close_delay;
 	portp->closing_wait = sio.closing_wait;
 	portp->custom_divisor = sio.custom_divisor;
-	stl_setport(portp, portp->tty->termios);
+	stl_setport(portp, portp->port.tty->termios);
 	return 0;
 }
 
@@ -1353,7 +1353,7 @@ static void stl_settermios(struct tty_struct *tty, struct ktermios *old)
 		stl_start(tty);
 	}
 	if (((old->c_cflag & CLOCAL) == 0) && (tiosp->c_cflag & CLOCAL))
-		wake_up_interruptible(&portp->open_wait);
+		wake_up_interruptible(&portp->port.open_wait);
 }
 
 /*****************************************************************************/
@@ -1438,7 +1438,7 @@ static void stl_hangup(struct tty_struct *tty)
 	if (portp == NULL)
 		return;
 
-	portp->flags &= ~ASYNC_INITIALIZED;
+	portp->port.flags &= ~ASYNC_INITIALIZED;
 	stl_disableintrs(portp);
 	if (tty->termios->c_cflag & HUPCL)
 		stl_setsignals(portp, 0, 0);
@@ -1452,10 +1452,10 @@ static void stl_hangup(struct tty_struct *tty)
 		portp->tx.head = NULL;
 		portp->tx.tail = NULL;
 	}
-	portp->tty = NULL;
-	portp->flags &= ~ASYNC_NORMAL_ACTIVE;
-	portp->refcount = 0;
-	wake_up_interruptible(&portp->open_wait);
+	portp->port.tty = NULL;
+	portp->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	portp->port.count = 0;
+	wake_up_interruptible(&portp->port.open_wait);
 }
 
 /*****************************************************************************/
@@ -1814,8 +1814,8 @@ static int __devinit stl_initports(struct stlbrd *brdp, struct stlpanel *panelp)
 		portp->baud_base = STL_BAUDBASE;
 		portp->close_delay = STL_CLOSEDELAY;
 		portp->closing_wait = 30 * HZ;
-		init_waitqueue_head(&portp->open_wait);
-		init_waitqueue_head(&portp->close_wait);
+		init_waitqueue_head(&portp->port.open_wait);
+		init_waitqueue_head(&portp->port.close_wait);
 		portp->stats.brd = portp->brdnr;
 		portp->stats.panel = portp->panelnr;
 		portp->stats.port = portp->portnr;
@@ -1840,8 +1840,8 @@ static void stl_cleanup_panels(struct stlbrd *brdp)
 			portp = panelp->ports[k];
 			if (portp == NULL)
 				continue;
-			if (portp->tty != NULL)
-				stl_hangup(portp->tty);
+			if (portp->port.tty != NULL)
+				stl_hangup(portp->port.tty);
 			kfree(portp->tx.buf);
 			kfree(portp);
 		}
@@ -2513,7 +2513,7 @@ static int stl_getportstats(struct stlport *portp, comstats_t __user *cp)
 	}
 
 	portp->stats.state = portp->istate;
-	portp->stats.flags = portp->flags;
+	portp->stats.flags = portp->port.flags;
 	portp->stats.hwid = portp->hwid;
 
 	portp->stats.ttystate = 0;
@@ -2524,16 +2524,16 @@ static int stl_getportstats(struct stlport *portp, comstats_t __user *cp)
 	portp->stats.rxbuffered = 0;
 
 	spin_lock_irqsave(&stallion_lock, flags);
-	if (portp->tty != NULL)
-		if (portp->tty->driver_data == portp) {
-			portp->stats.ttystate = portp->tty->flags;
+	if (portp->port.tty != NULL)
+		if (portp->port.tty->driver_data == portp) {
+			portp->stats.ttystate = portp->port.tty->flags;
 			/* No longer available as a statistic */
-			portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */
-			if (portp->tty->termios != NULL) {
-				portp->stats.cflags = portp->tty->termios->c_cflag;
-				portp->stats.iflags = portp->tty->termios->c_iflag;
-				portp->stats.oflags = portp->tty->termios->c_oflag;
-				portp->stats.lflags = portp->tty->termios->c_lflag;
+			portp->stats.rxbuffered = 1; /*portp->port.tty->flip.count; */
+			if (portp->port.tty->termios != NULL) {
+				portp->stats.cflags = portp->port.tty->termios->c_cflag;
+				portp->stats.iflags = portp->port.tty->termios->c_iflag;
+				portp->stats.oflags = portp->port.tty->termios->c_oflag;
+				portp->stats.lflags = portp->port.tty->termios->c_lflag;
 			}
 		}
 	spin_unlock_irqrestore(&stallion_lock, flags);
@@ -2939,15 +2939,15 @@ static void stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp)
 	}
 	baudrate = stl_baudrates[baudrate];
 	if ((tiosp->c_cflag & CBAUD) == B38400) {
-		if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			baudrate = 57600;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			baudrate = 115200;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			baudrate = 230400;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			baudrate = 460800;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
 			baudrate = (portp->baud_base / portp->custom_divisor);
 	}
 	if (baudrate > STL_CD1400MAXBAUD)
@@ -2969,9 +2969,9 @@ static void stl_cd1400setport(struct stlport *portp, struct ktermios *tiosp)
 		mcor1 |= MCOR1_DCD;
 		mcor2 |= MCOR2_DCD;
 		sreron |= SRER_MODEM;
-		portp->flags |= ASYNC_CHECK_CD;
+		portp->port.flags |= ASYNC_CHECK_CD;
 	} else
-		portp->flags &= ~ASYNC_CHECK_CD;
+		portp->port.flags &= ~ASYNC_CHECK_CD;
 
 /*
  *	Setup cd1400 enhanced modes if we can. In particular we want to
@@ -3242,7 +3242,7 @@ static void stl_cd1400flowctrl(struct stlport *portp, int state)
 
 	if (portp == NULL)
 		return;
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return;
 
@@ -3304,7 +3304,7 @@ static void stl_cd1400sendflow(struct stlport *portp, int state)
 
 	if (portp == NULL)
 		return;
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return;
 
@@ -3503,8 +3503,8 @@ static void stl_cd1400txisr(struct stlpanel *panelp, int ioaddr)
 	if ((len == 0) || ((len < STL_TXBUFLOW) &&
 	    (test_bit(ASYI_TXLOW, &portp->istate) == 0))) {
 		set_bit(ASYI_TXLOW, &portp->istate);
-		if (portp->tty)
-			tty_wakeup(portp->tty);
+		if (portp->port.tty)
+			tty_wakeup(portp->port.tty);
 	}
 
 	if (len == 0) {
@@ -3568,7 +3568,7 @@ static void stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr)
 		return;
 	}
 	portp = panelp->ports[(ioack >> 3)];
-	tty = portp->tty;
+	tty = portp->port.tty;
 
 	if ((ioack & ACK_TYPMASK) == ACK_TYPRXGOOD) {
 		outb((RDCR + portp->uartaddr), ioaddr);
@@ -3613,7 +3613,7 @@ static void stl_cd1400rxisr(struct stlpanel *panelp, int ioaddr)
 			if (portp->rxmarkmsk & status) {
 				if (status & ST_BREAK) {
 					status = TTY_BREAK;
-					if (portp->flags & ASYNC_SAK) {
+					if (portp->port.flags & ASYNC_SAK) {
 						do_SAK(tty);
 						BRDENABLE(portp->brdnr, portp->pagenr);
 					}
@@ -3899,15 +3899,15 @@ static void stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp)
 	}
 	baudrate = stl_baudrates[baudrate];
 	if ((tiosp->c_cflag & CBAUD) == B38400) {
-		if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			baudrate = 57600;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			baudrate = 115200;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			baudrate = 230400;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			baudrate = 460800;
-		else if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
+		else if ((portp->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
 			baudrate = (portp->baud_base / portp->custom_divisor);
 	}
 	if (baudrate > STL_SC26198MAXBAUD)
@@ -3922,11 +3922,11 @@ static void stl_sc26198setport(struct stlport *portp, struct ktermios *tiosp)
  *	Check what form of modem signaling is required and set it up.
  */
 	if (tiosp->c_cflag & CLOCAL) {
-		portp->flags &= ~ASYNC_CHECK_CD;
+		portp->port.flags &= ~ASYNC_CHECK_CD;
 	} else {
 		iopr |= IOPR_DCDCOS;
 		imron |= IR_IOPORT;
-		portp->flags |= ASYNC_CHECK_CD;
+		portp->port.flags |= ASYNC_CHECK_CD;
 	}
 
 /*
@@ -4174,7 +4174,7 @@ static void stl_sc26198flowctrl(struct stlport *portp, int state)
 
 	if (portp == NULL)
 		return;
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return;
 
@@ -4243,7 +4243,7 @@ static void stl_sc26198sendflow(struct stlport *portp, int state)
 
 	if (portp == NULL)
 		return;
-	tty = portp->tty;
+	tty = portp->port.tty;
 	if (tty == NULL)
 		return;
 
@@ -4421,8 +4421,8 @@ static void stl_sc26198txisr(struct stlport *portp)
 	if ((len == 0) || ((len < STL_TXBUFLOW) &&
 	    (test_bit(ASYI_TXLOW, &portp->istate) == 0))) {
 		set_bit(ASYI_TXLOW, &portp->istate);
-		if (portp->tty)
-			tty_wakeup(portp->tty);
+		if (portp->port.tty)
+			tty_wakeup(portp->port.tty);
 	}
 
 	if (len == 0) {
@@ -4475,7 +4475,7 @@ static void stl_sc26198rxisr(struct stlport *portp, unsigned int iack)
 
 	pr_debug("stl_sc26198rxisr(portp=%p,iack=%x)\n", portp, iack);
 
-	tty = portp->tty;
+	tty = portp->port.tty;
 	ioaddr = portp->ioaddr;
 	outb(GIBCR, (ioaddr + XP_ADDR));
 	len = inb(ioaddr + XP_DATA) + 1;
@@ -4527,7 +4527,7 @@ static void stl_sc26198rxbadch(struct stlport *portp, unsigned char status, char
 	struct tty_struct	*tty;
 	unsigned int		ioaddr;
 
-	tty = portp->tty;
+	tty = portp->port.tty;
 	ioaddr = portp->ioaddr;
 
 	if (status & SR_RXPARITY)
@@ -4544,7 +4544,7 @@ static void stl_sc26198rxbadch(struct stlport *portp, unsigned char status, char
 		if (portp->rxmarkmsk & status) {
 			if (status & SR_RXBREAK) {
 				status = TTY_BREAK;
-				if (portp->flags & ASYNC_SAK) {
+				if (portp->port.flags & ASYNC_SAK) {
 					do_SAK(tty);
 					BRDENABLE(portp->brdnr, portp->pagenr);
 				}
include/linux/stallion.h +1 -5
index 0424d75..336af33 100644
@@ -69,6 +69,7 @@ struct stlrq {
  */
 struct stlport {
 	unsigned long		magic;
+	struct tty_port		port;
 	unsigned int		portnr;
 	unsigned int		panelnr;
 	unsigned int		brdnr;
@@ -76,12 +77,10 @@ struct stlport {
 	int			uartaddr;
 	unsigned int		pagenr;
 	unsigned long		istate;
-	int			flags;
 	int			baud_base;
 	int			custom_divisor;
 	int			close_delay;
 	int			closing_wait;
-	int			refcount;
 	int			openwaitcnt;
 	int			brklen;
 	unsigned int		sigs;
@@ -92,9 +91,6 @@ struct stlport {
 	unsigned long		clk;
 	unsigned long		hwid;
 	void			*uartp;
-	struct tty_struct	*tty;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
 	comstats_t		stats;
 	struct stlrq		tx;
 };
author
#17 lore raw

PATCH 13/20 cyclades: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch cyclades to use the new tty_port structure
---

 drivers/char/cyclades.c  |  315 +++++++++++++++++++++++-----------------------
 include/linux/cyclades.h |    7 -
 2 files changed, 158 insertions(+), 164 deletions(-)
drivers/char/cyclades.c +157 -158
index ef73e72..44fda9b 100644
@@ -762,7 +762,7 @@ static int cy_next_channel;	/* next minor available */
 /*
  * This is used to look up the divisor speeds and the timeouts
  * We're normally limited to 15 distinct baud rates.  The extra
- * are accessed via settings in info->flags.
+ * are accessed via settings in info->port.flags.
  *      0,     1,     2,     3,     4,     5,     6,     7,     8,     9,
  *     10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
  *                                               HI            VHI
@@ -1003,7 +1003,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
 	cy_writeb(base_addr + (CyCAR << index), save_xir);
 
 	/* if there is nowhere to put the data, discard it */
-	if (info->tty == NULL) {
+	if (info->port.tty == NULL) {
 		if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
 				CyIVRRxEx) {	/* exception */
 			data = readb(base_addr + (CyRDSR << index));
@@ -1015,7 +1015,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
 		goto end;
 	}
 	/* there is an open port for this data */
-	tty = info->tty;
+	tty = info->port.tty;
 	if ((readb(base_addr + (CyRIVR << index)) & CyIVRMask) ==
 			CyIVRRxEx) {	/* exception */
 		data = readb(base_addr + (CyRDSR << index));
@@ -1041,7 +1041,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
 						readb(base_addr + (CyRDSR <<
 							index)), TTY_BREAK);
 					info->icount.rx++;
-					if (info->flags & ASYNC_SAK)
+					if (info->port.flags & ASYNC_SAK)
 						do_SAK(tty);
 				} else if (data & CyFRAME) {
 					tty_insert_flip_char(tty,
@@ -1145,7 +1145,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
 		goto end;
 	}
 	info = &cinfo->ports[channel + chip * 4];
-	if (info->tty == NULL) {
+	if (info->port.tty == NULL) {
 		cy_writeb(base_addr + (CySRER << index),
 			  readb(base_addr + (CySRER << index)) & ~CyTxRdy);
 		goto end;
@@ -1190,13 +1190,13 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
 			}
 			goto done;
 		}
-		if (info->xmit_buf == NULL) {
+		if (info->port.xmit_buf == NULL) {
 			cy_writeb(base_addr + (CySRER << index),
 				readb(base_addr + (CySRER << index)) &
 					~CyTxRdy);
 			goto done;
 		}
-		if (info->tty->stopped || info->tty->hw_stopped) {
+		if (info->port.tty->stopped || info->port.tty->hw_stopped) {
 			cy_writeb(base_addr + (CySRER << index),
 				readb(base_addr + (CySRER << index)) &
 					~CyTxRdy);
@@ -1211,7 +1211,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
 		 * character. This is necessary because there may not be room
 		 * for the two chars needed to send a NULL.)
 		 */
-		outch = info->xmit_buf[info->xmit_tail];
+		outch = info->port.xmit_buf[info->xmit_tail];
 		if (outch) {
 			info->xmit_cnt--;
 			info->xmit_tail = (info->xmit_tail + 1) &
@@ -1232,7 +1232,7 @@ static void cyy_chip_tx(struct cyclades_card *cinfo, unsigned int chip,
 	}
 
 done:
-	tty_wakeup(info->tty);
+	tty_wakeup(info->port.tty);
 end:
 	/* end of service */
 	cy_writeb(base_addr + (CyTIR << index), save_xir & 0x3f);
@@ -1256,7 +1256,7 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
 	mdm_change = readb(base_addr + (CyMISR << index));
 	mdm_status = readb(base_addr + (CyMSVR1 << index));
 
-	if (!info->tty)
+	if (!info->port.tty)
 		goto end;
 
 	if (mdm_change & CyANY_DELTA) {
@@ -1273,29 +1273,29 @@ static void cyy_chip_modem(struct cyclades_card *cinfo, int chip,
 		wake_up_interruptible(&info->delta_msr_wait);
 	}
 
-	if ((mdm_change & CyDCD) && (info->flags & ASYNC_CHECK_CD)) {
+	if ((mdm_change & CyDCD) && (info->port.flags & ASYNC_CHECK_CD)) {
 		if (!(mdm_status & CyDCD)) {
-			tty_hangup(info->tty);
-			info->flags &= ~ASYNC_NORMAL_ACTIVE;
+			tty_hangup(info->port.tty);
+			info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 		}
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 	}
-	if ((mdm_change & CyCTS) && (info->flags & ASYNC_CTS_FLOW)) {
-		if (info->tty->hw_stopped) {
+	if ((mdm_change & CyCTS) && (info->port.flags & ASYNC_CTS_FLOW)) {
+		if (info->port.tty->hw_stopped) {
 			if (mdm_status & CyCTS) {
 				/* cy_start isn't used
 				   because... !!! */
-				info->tty->hw_stopped = 0;
+				info->port.tty->hw_stopped = 0;
 				cy_writeb(base_addr + (CySRER << index),
 					readb(base_addr + (CySRER << index)) |
 						CyTxRdy);
-				tty_wakeup(info->tty);
+				tty_wakeup(info->port.tty);
 			}
 		} else {
 			if (!(mdm_status & CyCTS)) {
 				/* cy_stop isn't used
 				   because ... !!! */
-				info->tty->hw_stopped = 1;
+				info->port.tty->hw_stopped = 1;
 				cy_writeb(base_addr + (CySRER << index),
 					readb(base_addr + (CySRER << index)) &
 						~CyTxRdy);
@@ -1449,7 +1449,7 @@ static void cyz_handle_rx(struct cyclades_port *info,
 		struct BUF_CTRL __iomem *buf_ctrl)
 {
 	struct cyclades_card *cinfo = info->card;
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	unsigned int char_count;
 	int len;
 #ifdef BLOCKMOVE
@@ -1542,7 +1542,7 @@ static void cyz_handle_tx(struct cyclades_port *info,
 		struct BUF_CTRL __iomem *buf_ctrl)
 {
 	struct cyclades_card *cinfo = info->card;
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 	u8 data;
 	unsigned int char_count;
 #ifdef BLOCKMOVE
@@ -1585,7 +1585,7 @@ static void cyz_handle_tx(struct cyclades_port *info,
 
 			memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr +
 					tx_put),
-					&info->xmit_buf[info->xmit_tail],
+					&info->port.xmit_buf[info->xmit_tail],
 					small_count);
 
 			tx_put = (tx_put + small_count) & (tx_bufsize - 1);
@@ -1597,7 +1597,7 @@ static void cyz_handle_tx(struct cyclades_port *info,
 		}
 #else
 		while (info->xmit_cnt && char_count) {
-			data = info->xmit_buf[info->xmit_tail];
+			data = info->port.xmit_buf[info->xmit_tail];
 			info->xmit_cnt--;
 			info->xmit_tail = (info->xmit_tail + 1) &
 					(SERIAL_XMIT_SIZE - 1);
@@ -1642,7 +1642,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
 		special_count = 0;
 		delta_count = 0;
 		info = &cinfo->ports[channel];
-		tty = info->tty;
+		tty = info->port.tty;
 		if (tty == NULL)
 			continue;
 
@@ -1668,15 +1668,15 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
 		case C_CM_MDCD:
 			info->icount.dcd++;
 			delta_count++;
-			if (info->flags & ASYNC_CHECK_CD) {
+			if (info->port.flags & ASYNC_CHECK_CD) {
 				if ((fw_ver > 241 ? ((u_long) param) :
 						readl(&ch_ctrl->rs_status)) &
 						C_RS_DCD) {
-					wake_up_interruptible(&info->open_wait);
+					wake_up_interruptible(&info->port.open_wait);
 				} else {
-					tty_hangup(info->tty);
-					wake_up_interruptible(&info->open_wait);
-					info->flags &= ~ASYNC_NORMAL_ACTIVE;
+					tty_hangup(info->port.tty);
+					wake_up_interruptible(&info->port.open_wait);
+					info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 				}
 			}
 			break;
@@ -1814,7 +1814,7 @@ static void cyz_poll(unsigned long arg)
 
 		for (port = 0; port < cinfo->nports; port++) {
 			info = &cinfo->ports[port];
-			tty = info->tty;
+			tty = info->port.tty;
 			buf_ctrl = &(zfw_ctrl->buf_ctrl[port]);
 
 			if (!info->throttle)
@@ -1853,22 +1853,22 @@ static int startup(struct cyclades_port *info)
 
 	spin_lock_irqsave(&card->card_lock, flags);
 
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
 		free_page(page);
 		goto errout;
 	}
 
 	if (!info->type) {
-		if (info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
+		if (info->port.tty)
+			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		free_page(page);
 		goto errout;
 	}
 
-	if (info->xmit_buf)
+	if (info->port.xmit_buf)
 		free_page(page);
 	else
-		info->xmit_buf = (unsigned char *)page;
+		info->port.xmit_buf = (unsigned char *)page;
 
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
@@ -1909,10 +1909,10 @@ static int startup(struct cyclades_port *info)
 
 		cy_writeb(base_addr + (CySRER << index),
 			readb(base_addr + (CySRER << index)) | CyRxData);
-		info->flags |= ASYNC_INITIALIZED;
+		info->port.flags |= ASYNC_INITIALIZED;
 
-		if (info->tty)
-			clear_bit(TTY_IO_ERROR, &info->tty->flags);
+		if (info->port.tty)
+			clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 		info->breakon = info->breakoff = 0;
 		memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -1994,9 +1994,9 @@ static int startup(struct cyclades_port *info)
 
 		/* enable send, recv, modem !!! */
 
-		info->flags |= ASYNC_INITIALIZED;
-		if (info->tty)
-			clear_bit(TTY_IO_ERROR, &info->tty->flags);
+		info->port.flags |= ASYNC_INITIALIZED;
+		if (info->port.tty)
+			clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
 		info->breakon = info->breakoff = 0;
 		memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -2065,7 +2065,7 @@ static void shutdown(struct cyclades_port *info)
 	void __iomem *base_addr;
 	int chip, channel, index;
 
-	if (!(info->flags & ASYNC_INITIALIZED))
+	if (!(info->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	card = info->card;
@@ -2087,14 +2087,14 @@ static void shutdown(struct cyclades_port *info)
 		/* Clear delta_msr_wait queue to avoid mem leaks. */
 		wake_up_interruptible(&info->delta_msr_wait);
 
-		if (info->xmit_buf) {
+		if (info->port.xmit_buf) {
 			unsigned char *temp;
-			temp = info->xmit_buf;
-			info->xmit_buf = NULL;
+			temp = info->port.xmit_buf;
+			info->port.xmit_buf = NULL;
 			free_page((unsigned long)temp);
 		}
 		cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-		if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+		if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
 			cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
 			cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
 #ifdef CY_DEBUG_DTR
@@ -2108,9 +2108,9 @@ static void shutdown(struct cyclades_port *info)
 		/* it may be appropriate to clear _XMIT at
 		   some later date (after testing)!!! */
 
-		if (info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
-		info->flags &= ~ASYNC_INITIALIZED;
+		if (info->port.tty)
+			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		info->port.flags &= ~ASYNC_INITIALIZED;
 		spin_unlock_irqrestore(&card->card_lock, flags);
 	} else {
 		struct FIRM_ID __iomem *firm_id;
@@ -2136,14 +2136,14 @@ static void shutdown(struct cyclades_port *info)
 
 		spin_lock_irqsave(&card->card_lock, flags);
 
-		if (info->xmit_buf) {
+		if (info->port.xmit_buf) {
 			unsigned char *temp;
-			temp = info->xmit_buf;
-			info->xmit_buf = NULL;
+			temp = info->port.xmit_buf;
+			info->port.xmit_buf = NULL;
 			free_page((unsigned long)temp);
 		}
 
-		if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
+		if (!info->port.tty || (info->port.tty->termios->c_cflag & HUPCL)) {
 			cy_writel(&ch_ctrl[channel].rs_control,
 				(__u32)(readl(&ch_ctrl[channel].rs_control) &
 					~(C_RS_RTS | C_RS_DTR)));
@@ -2158,9 +2158,9 @@ static void shutdown(struct cyclades_port *info)
 #endif
 		}
 
-		if (info->tty)
-			set_bit(TTY_IO_ERROR, &info->tty->flags);
-		info->flags &= ~ASYNC_INITIALIZED;
+		if (info->port.tty)
+			set_bit(TTY_IO_ERROR, &info->port.tty->flags);
+		info->port.flags &= ~ASYNC_INITIALIZED;
 
 		spin_unlock_irqrestore(&card->card_lock, flags);
 	}
@@ -2194,10 +2194,10 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 	 * If the device is in the middle of being closed, then block
 	 * until it's done, and then try again.
 	 */
-	if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
-		wait_event_interruptible(info->close_wait,
-				!(info->flags & ASYNC_CLOSING));
-		return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
+	if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
+		wait_event_interruptible(info->port.close_wait,
+				!(info->port.flags & ASYNC_CLOSING));
+		return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
 	}
 
 	/*
@@ -2206,32 +2206,32 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 	 */
 	if ((filp->f_flags & O_NONBLOCK) ||
 					(tty->flags & (1 << TTY_IO_ERROR))) {
-		info->flags |= ASYNC_NORMAL_ACTIVE;
+		info->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
 	/*
 	 * Block waiting for the carrier detect and the line to become
 	 * free (i.e., not in use by the callout).  While we are in
-	 * this loop, info->count is dropped by one, so that
+	 * this loop, info->port.count is dropped by one, so that
 	 * cy_close() knows when to free things.  We restore it upon
 	 * exit, either normal or abnormal.
 	 */
 	retval = 0;
-	add_wait_queue(&info->open_wait, &wait);
+	add_wait_queue(&info->port.open_wait, &wait);
 #ifdef CY_DEBUG_OPEN
 	printk(KERN_DEBUG "cyc block_til_ready before block: ttyC%d, "
-		"count = %d\n", info->line, info->count);
+		"count = %d\n", info->line, info->port.count);
 #endif
 	spin_lock_irqsave(&cinfo->card_lock, flags);
 	if (!tty_hung_up_p(filp))
-		info->count--;
+		info->port.count--;
 	spin_unlock_irqrestore(&cinfo->card_lock, flags);
 #ifdef CY_DEBUG_COUNT
 	printk(KERN_DEBUG "cyc block_til_ready: (%d): decrementing count to "
-		"%d\n", current->pid, info->count);
+		"%d\n", current->pid, info->port.count);
 #endif
-	info->blocked_open++;
+	info->port.blocked_open++;
 
 	if (!IS_CYC_Z(*cinfo)) {
 		chip = channel >> 2;
@@ -2260,8 +2260,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 
 			set_current_state(TASK_INTERRUPTIBLE);
 			if (tty_hung_up_p(filp) ||
-					!(info->flags & ASYNC_INITIALIZED)) {
-				retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
+					!(info->port.flags & ASYNC_INITIALIZED)) {
+				retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
 					  -EAGAIN : -ERESTARTSYS);
 				break;
 			}
@@ -2269,7 +2269,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 			spin_lock_irqsave(&cinfo->card_lock, flags);
 			cy_writeb(base_addr + (CyCAR << index),
 				  (u_char) channel);
-			if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
+			if (!(info->port.flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
 					(readb(base_addr +
 						(CyMSVR1 << index)) & CyDCD))) {
 				spin_unlock_irqrestore(&cinfo->card_lock, flags);
@@ -2284,7 +2284,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 #ifdef CY_DEBUG_OPEN
 			printk(KERN_DEBUG "cyc block_til_ready blocking: "
 				"ttyC%d, count = %d\n",
-				info->line, info->count);
+				info->line, info->port.count);
 #endif
 			schedule();
 		}
@@ -2298,7 +2298,7 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 		firm_id = base_addr + ID_ADDRESS;
 		if (!ISZLOADED(*cinfo)) {
 			__set_current_state(TASK_RUNNING);
-			remove_wait_queue(&info->open_wait, &wait);
+			remove_wait_queue(&info->port.open_wait, &wait);
 			return -EINVAL;
 		}
 
@@ -2327,12 +2327,12 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 
 			set_current_state(TASK_INTERRUPTIBLE);
 			if (tty_hung_up_p(filp) ||
-					!(info->flags & ASYNC_INITIALIZED)) {
-				retval = ((info->flags & ASYNC_HUP_NOTIFY) ?
+					!(info->port.flags & ASYNC_INITIALIZED)) {
+				retval = ((info->port.flags & ASYNC_HUP_NOTIFY) ?
 					  -EAGAIN : -ERESTARTSYS);
 				break;
 			}
-			if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
+			if (!(info->port.flags & ASYNC_CLOSING) && (C_CLOCAL(tty) ||
 					(readl(&ch_ctrl[channel].rs_status) &
 						C_RS_DCD))) {
 				break;
@@ -2344,28 +2344,28 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
 #ifdef CY_DEBUG_OPEN
 			printk(KERN_DEBUG "cyc block_til_ready blocking: "
 				"ttyC%d, count = %d\n",
-				info->line, info->count);
+				info->line, info->port.count);
 #endif
 			schedule();
 		}
 	}
 	__set_current_state(TASK_RUNNING);
-	remove_wait_queue(&info->open_wait, &wait);
+	remove_wait_queue(&info->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp)) {
-		info->count++;
+		info->port.count++;
 #ifdef CY_DEBUG_COUNT
 		printk(KERN_DEBUG "cyc:block_til_ready (%d): incrementing "
-			"count to %d\n", current->pid, info->count);
+			"count to %d\n", current->pid, info->port.count);
 #endif
 	}
-	info->blocked_open--;
+	info->port.blocked_open--;
 #ifdef CY_DEBUG_OPEN
 	printk(KERN_DEBUG "cyc:block_til_ready after blocking: ttyC%d, "
-		"count = %d\n", info->line, info->count);
+		"count = %d\n", info->line, info->port.count);
 #endif
 	if (retval)
 		return retval;
-	info->flags |= ASYNC_NORMAL_ACTIVE;
+	info->port.flags |= ASYNC_NORMAL_ACTIVE;
 	return 0;
 }				/* block_til_ready */
 
@@ -2456,27 +2456,27 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
 	printk(KERN_DEBUG "cyc:cy_open ttyC%d\n", info->line);
 #endif
 	tty->driver_data = info;
-	info->tty = tty;
+	info->port.tty = tty;
 	if (serial_paranoia_check(info, tty->name, "cy_open"))
 		return -ENODEV;
 
 #ifdef CY_DEBUG_OPEN
 	printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
-			info->count);
+			info->port.count);
 #endif
-	info->count++;
+	info->port.count++;
 #ifdef CY_DEBUG_COUNT
 	printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
-		current->pid, info->count);
+		current->pid, info->port.count);
 #endif
 
 	/*
 	 * If the port is the middle of closing, bail out now
 	 */
-	if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
-		wait_event_interruptible(info->close_wait,
-				!(info->flags & ASYNC_CLOSING));
-		return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
+	if (tty_hung_up_p(filp) || (info->port.flags & ASYNC_CLOSING)) {
+		wait_event_interruptible(info->port.close_wait,
+				!(info->port.flags & ASYNC_CLOSING));
+		return (info->port.flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS;
 	}
 
 	/*
@@ -2641,9 +2641,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 	}
 #ifdef CY_DEBUG_OPEN
 	printk(KERN_DEBUG "cyc:cy_close ttyC%d, count = %d\n", info->line,
-		info->count);
+		info->port.count);
 #endif
-	if ((tty->count == 1) && (info->count != 1)) {
+	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
@@ -2652,24 +2652,24 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 		 * serial port won't be shutdown.
 		 */
 		printk(KERN_ERR "cyc:cy_close: bad serial port count; "
-			"tty->count is 1, info->count is %d\n", info->count);
-		info->count = 1;
+			"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->count - 1);
+		current->pid, info->port.count - 1);
 #endif
-	if (--info->count < 0) {
+	if (--info->port.count < 0) {
 #ifdef CY_DEBUG_COUNT
 		printk(KERN_DEBUG "cyc:cyc_close setting count to 0\n");
 #endif
-		info->count = 0;
+		info->port.count = 0;
 	}
-	if (info->count) {
+	if (info->port.count) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
 		return;
 	}
-	info->flags |= ASYNC_CLOSING;
+	info->port.flags |= ASYNC_CLOSING;
 
 	/*
 	 * Now we wait for the transmit buffer to clear; and we notify
@@ -2692,7 +2692,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 		cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
 		cy_writeb(base_addr + (CySRER << index),
 			  readb(base_addr + (CySRER << index)) & ~CyRxData);
-		if (info->flags & ASYNC_INITIALIZED) {
+		if (info->port.flags & ASYNC_INITIALIZED) {
 			/* Waiting for on-board buffers to be empty before
 			   closing the port */
 			spin_unlock_irqrestore(&card->card_lock, flags);
@@ -2731,18 +2731,18 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 	spin_lock_irqsave(&card->card_lock, flags);
 
 	tty->closing = 0;
-	info->tty = NULL;
-	if (info->blocked_open) {
+	info->port.tty = NULL;
+	if (info->port.blocked_open) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
 		if (info->close_delay) {
 			msleep_interruptible(jiffies_to_msecs
 						(info->close_delay));
 		}
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 		spin_lock_irqsave(&card->card_lock, flags);
 	}
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING);
-	wake_up_interruptible(&info->close_wait);
+	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");
@@ -2777,7 +2777,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 	if (serial_paranoia_check(info, tty->name, "cy_write"))
 		return 0;
 
-	if (!info->xmit_buf)
+	if (!info->port.xmit_buf)
 		return 0;
 
 	spin_lock_irqsave(&info->card->card_lock, flags);
@@ -2788,7 +2788,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
 		if (c <= 0)
 			break;
 
-		memcpy(info->xmit_buf + info->xmit_head, buf, c);
+		memcpy(info->port.xmit_buf + info->xmit_head, buf, c);
 		info->xmit_head = (info->xmit_head + c) &
 			(SERIAL_XMIT_SIZE - 1);
 		info->xmit_cnt += c;
@@ -2826,7 +2826,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)
 	if (serial_paranoia_check(info, tty->name, "cy_put_char"))
 		return 0;
 
-	if (!info->xmit_buf)
+	if (!info->port.xmit_buf)
 		return 0;
 
 	spin_lock_irqsave(&info->card->card_lock, flags);
@@ -2835,7 +2835,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)
 		return 0;
 	}
 
-	info->xmit_buf[info->xmit_head++] = ch;
+	info->port.xmit_buf[info->xmit_head++] = ch;
 	info->xmit_head &= SERIAL_XMIT_SIZE - 1;
 	info->xmit_cnt++;
 	info->idle_stats.xmit_bytes++;
@@ -2860,7 +2860,7 @@ static void cy_flush_chars(struct tty_struct *tty)
 		return;
 
 	if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-			!info->xmit_buf)
+			!info->port.xmit_buf)
 		return;
 
 	start_xmit(info);
@@ -2988,27 +2988,27 @@ static void set_line_char(struct cyclades_port *info)
 	int baud, baud_rate = 0;
 	int i;
 
-	if (!info->tty || !info->tty->termios)
+	if (!info->port.tty || !info->port.tty->termios)
 		return;
 
 	if (info->line == -1)
 		return;
 
-	cflag = info->tty->termios->c_cflag;
-	iflag = info->tty->termios->c_iflag;
+	cflag = info->port.tty->termios->c_cflag;
+	iflag = info->port.tty->termios->c_iflag;
 
 	/*
 	 * Set up the tty->alt_speed kludge
 	 */
-	if (info->tty) {
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
-			info->tty->alt_speed = 57600;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
-			info->tty->alt_speed = 115200;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
-			info->tty->alt_speed = 230400;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
-			info->tty->alt_speed = 460800;
+	if (info->port.tty) {
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+			info->port.tty->alt_speed = 57600;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+			info->port.tty->alt_speed = 115200;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+			info->port.tty->alt_speed = 230400;
+		if ((info->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+			info->port.tty->alt_speed = 460800;
 	}
 
 	card = info->card;
@@ -3020,8 +3020,8 @@ static void set_line_char(struct cyclades_port *info)
 		index = card->bus_index;
 
 		/* baud rate */
-		baud = tty_get_baud_rate(info->tty);
-		if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+		baud = tty_get_baud_rate(info->port.tty);
+		if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
 				ASYNC_SPD_CUST) {
 			if (info->custom_divisor)
 				baud_rate = info->baud / info->custom_divisor;
@@ -3038,7 +3038,7 @@ static void set_line_char(struct cyclades_port *info)
 		if (i == 20)
 			i = 19;	/* CD1400_MAX_SPEED */
 
-		if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+		if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
 				ASYNC_SPD_CUST) {
 			cyy_baud_calc(info, baud_rate);
 		} else {
@@ -3059,7 +3059,7 @@ static void set_line_char(struct cyclades_port *info)
 			/* get it right for 134.5 baud */
 			info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
 					2;
-		} else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+		} else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
 				ASYNC_SPD_CUST) {
 			info->timeout = (info->xmit_fifo_size * HZ * 15 /
 					baud_rate) + 2;
@@ -3108,16 +3108,16 @@ static void set_line_char(struct cyclades_port *info)
 
 		/* CTS flow control flag */
 		if (cflag & CRTSCTS) {
-			info->flags |= ASYNC_CTS_FLOW;
+			info->port.flags |= ASYNC_CTS_FLOW;
 			info->cor2 |= CyCtsAE;
 		} else {
-			info->flags &= ~ASYNC_CTS_FLOW;
+			info->port.flags &= ~ASYNC_CTS_FLOW;
 			info->cor2 &= ~CyCtsAE;
 		}
 		if (cflag & CLOCAL)
-			info->flags &= ~ASYNC_CHECK_CD;
+			info->port.flags &= ~ASYNC_CHECK_CD;
 		else
-			info->flags |= ASYNC_CHECK_CD;
+			info->port.flags |= ASYNC_CHECK_CD;
 
 	 /***********************************************
 	    The hardware option, CyRtsAO, presents RTS when
@@ -3146,8 +3146,8 @@ static void set_line_char(struct cyclades_port *info)
 		/* set line characteristics  according configuration */
 
 		cy_writeb(base_addr + (CySCHR1 << index),
-			  START_CHAR(info->tty));
-		cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->tty));
+			  START_CHAR(info->port.tty));
+		cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->port.tty));
 		cy_writeb(base_addr + (CyCOR1 << index), info->cor1);
 		cy_writeb(base_addr + (CyCOR2 << index), info->cor2);
 		cy_writeb(base_addr + (CyCOR3 << index), info->cor3);
@@ -3163,7 +3163,7 @@ static void set_line_char(struct cyclades_port *info)
 			(info->default_timeout ? info->default_timeout : 0x02));
 		/* 10ms rx timeout */
 
-		if (C_CLOCAL(info->tty)) {
+		if (C_CLOCAL(info->port.tty)) {
 			/* without modem intr */
 			cy_writeb(base_addr + (CySRER << index),
 				readb(base_addr + (CySRER << index)) | CyMdmCh);
@@ -3226,8 +3226,8 @@ static void set_line_char(struct cyclades_port *info)
 #endif
 		}
 
-		if (info->tty)
-			clear_bit(TTY_IO_ERROR, &info->tty->flags);
+		if (info->port.tty)
+			clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 		spin_unlock_irqrestore(&card->card_lock, flags);
 
 	} else {
@@ -3250,8 +3250,8 @@ static void set_line_char(struct cyclades_port *info)
 		buf_ctrl = &zfw_ctrl->buf_ctrl[channel];
 
 		/* baud rate */
-		baud = tty_get_baud_rate(info->tty);
-		if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+		baud = tty_get_baud_rate(info->port.tty);
+		if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
 				ASYNC_SPD_CUST) {
 			if (info->custom_divisor)
 				baud_rate = info->baud / info->custom_divisor;
@@ -3266,7 +3266,7 @@ static void set_line_char(struct cyclades_port *info)
 			/* get it right for 134.5 baud */
 			info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) +
 					2;
-		} else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
+		} else if (baud == 38400 && (info->port.flags & ASYNC_SPD_MASK) ==
 				ASYNC_SPD_CUST) {
 			info->timeout = (info->xmit_fifo_size * HZ * 15 /
 					baud_rate) + 2;
@@ -3318,7 +3318,7 @@ static void set_line_char(struct cyclades_port *info)
 		}
 		/* As the HW flow control is done in firmware, the driver
 		   doesn't need to care about it */
-		info->flags &= ~ASYNC_CTS_FLOW;
+		info->port.flags &= ~ASYNC_CTS_FLOW;
 
 		/* XON/XOFF/XANY flow control flags */
 		sw_flow = 0;
@@ -3337,9 +3337,9 @@ static void set_line_char(struct cyclades_port *info)
 
 		/* CD sensitivity */
 		if (cflag & CLOCAL)
-			info->flags &= ~ASYNC_CHECK_CD;
+			info->port.flags &= ~ASYNC_CHECK_CD;
 		else
-			info->flags |= ASYNC_CHECK_CD;
+			info->port.flags |= ASYNC_CHECK_CD;
 
 		if (baud == 0) {	/* baud rate is zero, turn off line */
 			cy_writel(&ch_ctrl->rs_control,
@@ -3361,8 +3361,8 @@ static void set_line_char(struct cyclades_port *info)
 				"was %x\n", info->line, retval);
 		}
 
-		if (info->tty)
-			clear_bit(TTY_IO_ERROR, &info->tty->flags);
+		if (info->port.tty)
+			clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
 	}
 }				/* set_line_char */
 
@@ -3381,7 +3381,7 @@ get_serial_info(struct cyclades_port *info,
 	tmp.port = (info->card - cy_card) * 0x100 + info->line -
 		cinfo->first_line;
 	tmp.irq = cinfo->irq;
-	tmp.flags = info->flags;
+	tmp.flags = info->port.flags;
 	tmp.close_delay = info->close_delay;
 	tmp.closing_wait = info->closing_wait;
 	tmp.baud_base = info->baud;
@@ -3406,9 +3406,9 @@ set_serial_info(struct cyclades_port *info,
 				new_serial.baud_base != info->baud ||
 				(new_serial.flags & ASYNC_FLAGS &
 					~ASYNC_USR_MASK) !=
-				(info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
+				(info->port.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))
 			return -EPERM;
-		info->flags = (info->flags & ~ASYNC_USR_MASK) |
+		info->port.flags = (info->port.flags & ~ASYNC_USR_MASK) |
 				(new_serial.flags & ASYNC_USR_MASK);
 		info->baud = new_serial.baud_base;
 		info->custom_divisor = new_serial.custom_divisor;
@@ -3422,13 +3422,13 @@ set_serial_info(struct cyclades_port *info,
 
 	info->baud = new_serial.baud_base;
 	info->custom_divisor = new_serial.custom_divisor;
-	info->flags = (info->flags & ~ASYNC_FLAGS) |
+	info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
 			(new_serial.flags & ASYNC_FLAGS);
 	info->close_delay = new_serial.close_delay * HZ / 100;
 	info->closing_wait = new_serial.closing_wait * HZ / 100;
 
 check_and_exit:
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (info->port.flags & ASYNC_INITIALIZED) {
 		set_line_char(info);
 		return 0;
 	} else {
@@ -4097,7 +4097,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 	 */
 	if (!(old_termios->c_cflag & CLOCAL) &&
 	    (tty->termios->c_cflag & CLOCAL))
-		wake_up_interruptible(&info->open_wait);
+		wake_up_interruptible(&info->port.open_wait);
 #endif
 }				/* cy_set_termios */
 
@@ -4326,14 +4326,14 @@ static void cy_hangup(struct tty_struct *tty)
 
 	cy_flush_buffer(tty);
 	shutdown(info);
-	info->count = 0;
+	info->port.count = 0;
 #ifdef CY_DEBUG_COUNT
 	printk(KERN_DEBUG "cyc:cy_hangup (%d): setting count to 0\n",
 		current->pid);
 #endif
-	info->tty = NULL;
-	info->flags &= ~ASYNC_NORMAL_ACTIVE;
-	wake_up_interruptible(&info->open_wait);
+	info->port.tty = NULL;
+	info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
+	wake_up_interruptible(&info->port.open_wait);
 }				/* cy_hangup */
 
 /*
@@ -4379,12 +4379,11 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
 		info->magic = CYCLADES_MAGIC;
 		info->card = cinfo;
 		info->line = port;
-		info->flags = STD_COM_FLAGS;
 		info->closing_wait = CLOSING_WAIT_DELAY;
 		info->close_delay = 5 * HZ / 10;
 
-		init_waitqueue_head(&info->open_wait);
-		init_waitqueue_head(&info->close_wait);
+		tty_port_init(&info->port);
+		info->port.flags = STD_COM_FLAGS;
 		init_completion(&info->shutdown_wait);
 		init_waitqueue_head(&info->delta_msr_wait);
 
@@ -5237,7 +5236,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
 		for (j = 0; j < cy_card[i].nports; j++) {
 			info = &cy_card[i].ports[j];
 
-			if (info->count)
+			if (info->port.count)
 				size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
 					"%10lu %8lu %9lu %6ld\n", info->line,
 					(cur_jifs - info->idle_stats.in_use) /
@@ -5246,7 +5245,7 @@ cyclades_get_proc_info(char *buf, char **start, off_t offset, int length,
 					HZ, info->idle_stats.recv_bytes,
 					(cur_jifs - info->idle_stats.recv_idle)/
 					HZ, info->idle_stats.overruns,
-					(long)info->tty->ldisc.num);
+					(long)info->port.tty->ldisc.num);
 			else
 				size = sprintf(buf + len, "%3d %8lu %10lu %8lu "
 					"%10lu %8lu %9lu %6ld\n",
include/linux/cyclades.h +1 -6
index 504cb2c..a982b74 100644
@@ -550,11 +550,11 @@ struct cyclades_icount {
 
 struct cyclades_port {
 	int                     magic;
+	struct tty_port		port;
 	struct cyclades_card	*card;
 	int			line;
 	int			flags; 		/* defined in tty.h */
 	int                     type;		/* UART type */
-	struct tty_struct 	*tty;
 	int			read_status_mask;
 	int			ignore_status_mask;
 	int			timeout;
@@ -569,11 +569,8 @@ struct cyclades_port {
 	u8			x_char; /* to be pushed out ASAP */
 	int			close_delay;
 	unsigned short		closing_wait;
-	int			count;	/* # of fd on device */
 	int                     breakon;
 	int                     breakoff;
-	int			blocked_open; /* # of blocked opens */
-	unsigned char 		*xmit_buf;
 	int			xmit_head;
 	int			xmit_tail;
 	int			xmit_cnt;
@@ -583,8 +580,6 @@ struct cyclades_port {
 	struct cyclades_monitor	mon;
 	struct cyclades_idle_stats	idle_stats;
 	struct cyclades_icount	icount;
-	wait_queue_head_t       open_wait;
-	wait_queue_head_t       close_wait;
 	struct completion       shutdown_wait;
 	wait_queue_head_t       delta_msr_wait;
 	int throttle;
author
#18 lore raw

PATCH 14/20 gs: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch drivers using the old "generic serial" driver to use the tty_port structures
---

 drivers/char/generic_serial.c  |  158 ++++++++++++++++++++--------------------
 drivers/char/rio/rio_linux.c   |   20 +++--
 drivers/char/rio/riocmd.c      |   10 +--
 drivers/char/rio/riointr.c     |   10 +--
 drivers/char/rio/rioparam.c    |    2 -
 drivers/char/rio/riotty.c      |   16 ++--
 drivers/char/sx.c              |  115 ++++++++++++++---------------
 include/linux/generic_serial.h |    8 +-
 8 files changed, 166 insertions(+), 173 deletions(-)
drivers/char/generic_serial.c +79 -79
index 252f73e..4bde737 100644
@@ -60,7 +60,7 @@ int gs_put_char(struct tty_struct * tty, unsigned char ch)
 
 	if (!port) return 0;
 
-	if (! (port->flags & ASYNC_INITIALIZED)) return 0;
+	if (! (port->port.flags & ASYNC_INITIALIZED)) return 0;
 
 	/* Take a lock on the serial tranmit buffer! */
 	mutex_lock(& port->port_write_mutex);
@@ -103,7 +103,7 @@ int gs_write(struct tty_struct * tty,
 
 	if (!port) return 0;
 
-	if (! (port->flags & ASYNC_INITIALIZED))
+	if (! (port->port.flags & ASYNC_INITIALIZED))
 		return 0;
 
 	/* get exclusive "write" access to this port (problem 3) */
@@ -141,13 +141,13 @@ int gs_write(struct tty_struct * tty,
 	mutex_unlock(& port->port_write_mutex);
 
 	gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n", 
-	            (port->flags & GS_TX_INTEN)?"enabled": "disabled"); 
+	            (port->port.flags & GS_TX_INTEN)?"enabled": "disabled"); 
 
 	if (port->xmit_cnt && 
 	    !tty->stopped && 
 	    !tty->hw_stopped &&
-	    !(port->flags & GS_TX_INTEN)) {
-		port->flags |= GS_TX_INTEN;
+	    !(port->port.flags & GS_TX_INTEN)) {
+		port->port.flags |= GS_TX_INTEN;
 		port->rd->enable_tx_interrupts (port);
 	}
 	func_exit ();
@@ -208,7 +208,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)
 	gs_dprintk (GS_DEBUG_FLUSH, "port=%p.\n", port);
 	if (port) {
 		gs_dprintk (GS_DEBUG_FLUSH, "xmit_cnt=%x, xmit_buf=%p, tty=%p.\n", 
-		port->xmit_cnt, port->xmit_buf, port->tty);
+		port->xmit_cnt, port->xmit_buf, port->port.tty);
 	}
 
 	if (!port || port->xmit_cnt < 0 || !port->xmit_buf) {
@@ -217,7 +217,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)
 		return -EINVAL;  /* This is an error which we don't know how to handle. */
 	}
 
-	rcib = gs_real_chars_in_buffer(port->tty);
+	rcib = gs_real_chars_in_buffer(port->port.tty);
 
 	if(rcib <= 0) {
 		gs_dprintk (GS_DEBUG_FLUSH, "nothing to wait for.\n");
@@ -236,7 +236,7 @@ static int gs_wait_tx_flushed (void * ptr, unsigned long timeout)
 
 	/* the expression is actually jiffies < end_jiffies, but that won't
 	   work around the wraparound. Tricky eh? */
-	while ((charsleft = gs_real_chars_in_buffer (port->tty)) &&
+	while ((charsleft = gs_real_chars_in_buffer (port->port.tty)) &&
 	        time_after (end_jiffies, jiffies)) {
 		/* Units check: 
 		   chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies!
@@ -309,7 +309,7 @@ void gs_flush_chars(struct tty_struct * tty)
 	}
 
 	/* Beats me -- REW */
-	port->flags |= GS_TX_INTEN;
+	port->port.flags |= GS_TX_INTEN;
 	port->rd->enable_tx_interrupts (port);
 	func_exit ();
 }
@@ -329,8 +329,8 @@ void gs_stop(struct tty_struct * tty)
 
 	if (port->xmit_cnt && 
 	    port->xmit_buf && 
-	    (port->flags & GS_TX_INTEN) ) {
-		port->flags &= ~GS_TX_INTEN;
+	    (port->port.flags & GS_TX_INTEN) ) {
+		port->port.flags &= ~GS_TX_INTEN;
 		port->rd->disable_tx_interrupts (port);
 	}
 	func_exit ();
@@ -349,8 +349,8 @@ void gs_start(struct tty_struct * tty)
 
 	if (port->xmit_cnt && 
 	    port->xmit_buf && 
-	    !(port->flags & GS_TX_INTEN) ) {
-		port->flags |= GS_TX_INTEN;
+	    !(port->port.flags & GS_TX_INTEN) ) {
+		port->port.flags |= GS_TX_INTEN;
 		port->rd->enable_tx_interrupts (port);
 	}
 	func_exit ();
@@ -365,7 +365,7 @@ static void gs_shutdown_port (struct gs_port *port)
 	
 	if (!port) return;
 	
-	if (!(port->flags & ASYNC_INITIALIZED))
+	if (!(port->port.flags & ASYNC_INITIALIZED))
 		return;
 
 	spin_lock_irqsave(&port->driver_lock, flags);
@@ -375,12 +375,12 @@ static void gs_shutdown_port (struct gs_port *port)
 		port->xmit_buf = NULL;
 	}
 
-	if (port->tty)
-		set_bit(TTY_IO_ERROR, &port->tty->flags);
+	if (port->port.tty)
+		set_bit(TTY_IO_ERROR, &port->port.tty->flags);
 
 	port->rd->shutdown_port (port);
 
-	port->flags &= ~ASYNC_INITIALIZED;
+	port->port.flags &= ~ASYNC_INITIALIZED;
 	spin_unlock_irqrestore(&port->driver_lock, flags);
 
 	func_exit();
@@ -396,16 +396,16 @@ void gs_hangup(struct tty_struct *tty)
 	if (!tty) return;
 
 	port = tty->driver_data;
-	tty = port->tty;
+	tty = port->port.tty;
 	if (!tty) 
 		return;
 
 	gs_shutdown_port (port);
-	port->flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE);
-	port->tty = NULL;
-	port->count = 0;
+	port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE);
+	port->port.tty = NULL;
+	port->port.count = 0;
 
-	wake_up_interruptible(&port->open_wait);
+	wake_up_interruptible(&port->port.open_wait);
 	func_exit ();
 }
 
@@ -424,7 +424,7 @@ int gs_block_til_ready(void *port_, struct file * filp)
 
 	if (!port) return 0;
 
-	tty = port->tty;
+	tty = port->port.tty;
 
 	if (!tty) return 0;
 
@@ -433,9 +433,9 @@ int gs_block_til_ready(void *port_, struct file * filp)
 	 * If the device is in the middle of being closed, then block
 	 * until it's done, and then try again.
 	 */
-	if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) {
-		interruptible_sleep_on(&port->close_wait);
-		if (port->flags & ASYNC_HUP_NOTIFY)
+	if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
+		interruptible_sleep_on(&port->port.close_wait);
+		if (port->port.flags & ASYNC_HUP_NOTIFY)
 			return -EAGAIN;
 		else
 			return -ERESTARTSYS;
@@ -449,7 +449,7 @@ int gs_block_til_ready(void *port_, struct file * filp)
 	 */
 	if ((filp->f_flags & O_NONBLOCK) ||
 	    (tty->flags & (1 << TTY_IO_ERROR))) {
-		port->flags |= ASYNC_NORMAL_ACTIVE;
+		port->port.flags |= ASYNC_NORMAL_ACTIVE;
 		return 0;
 	}
 
@@ -461,34 +461,34 @@ int gs_block_til_ready(void *port_, struct file * filp)
 	/*
 	 * Block waiting for the carrier detect and the line to become
 	 * free (i.e., not in use by the callout).  While we are in
-	 * this loop, port->count is dropped by one, so that
+	 * this loop, port->port.count is dropped by one, so that
 	 * rs_close() knows when to free things.  We restore it upon
 	 * exit, either normal or abnormal.
 	 */
 	retval = 0;
 
-	add_wait_queue(&port->open_wait, &wait);
+	add_wait_queue(&port->port.open_wait, &wait);
 
 	gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); 
 	spin_lock_irqsave(&port->driver_lock, flags);
 	if (!tty_hung_up_p(filp)) {
-		port->count--;
+		port->port.count--;
 	}
 	spin_unlock_irqrestore(&port->driver_lock, flags);
-	port->blocked_open++;
+	port->port.blocked_open++;
 	while (1) {
 		CD = port->rd->get_CD (port);
 		gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD);
 		set_current_state (TASK_INTERRUPTIBLE);
 		if (tty_hung_up_p(filp) ||
-		    !(port->flags & ASYNC_INITIALIZED)) {
-			if (port->flags & ASYNC_HUP_NOTIFY)
+		    !(port->port.flags & ASYNC_INITIALIZED)) {
+			if (port->port.flags & ASYNC_HUP_NOTIFY)
 				retval = -EAGAIN;
 			else
 				retval = -ERESTARTSYS;
 			break;
 		}
-		if (!(port->flags & ASYNC_CLOSING) &&
+		if (!(port->port.flags & ASYNC_CLOSING) &&
 		    (do_clocal || CD))
 			break;
 		gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n", 
@@ -500,17 +500,17 @@ int gs_block_til_ready(void *port_, struct file * filp)
 		schedule();
 	}
 	gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n",
-		    port->blocked_open);
+		    port->port.blocked_open);
 	set_current_state (TASK_RUNNING);
-	remove_wait_queue(&port->open_wait, &wait);
+	remove_wait_queue(&port->port.open_wait, &wait);
 	if (!tty_hung_up_p(filp)) {
-		port->count++;
+		port->port.count++;
 	}
-	port->blocked_open--;
+	port->port.blocked_open--;
 	if (retval)
 		return retval;
 
-	port->flags |= ASYNC_NORMAL_ACTIVE;
+	port->port.flags |= ASYNC_NORMAL_ACTIVE;
 	func_exit ();
 	return 0;
 }			 
@@ -529,10 +529,10 @@ void gs_close(struct tty_struct * tty, struct file * filp)
 
 	if (!port) return;
 
-	if (!port->tty) {
+	if (!port->port.tty) {
 		/* This seems to happen when this is called from vhangup. */
-		gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->tty is NULL\n");
-		port->tty = tty;
+		gs_dprintk (GS_DEBUG_CLOSE, "gs: Odd: port->port.tty is NULL\n");
+		port->port.tty = tty;
 	}
 
 	spin_lock_irqsave(&port->driver_lock, flags);
@@ -545,23 +545,23 @@ void gs_close(struct tty_struct * tty, struct file * filp)
 		return;
 	}
 
-	if ((tty->count == 1) && (port->count != 1)) {
+	if ((tty->count == 1) && (port->port.count != 1)) {
 		printk(KERN_ERR "gs: gs_close port %p: bad port count;"
-		       " tty->count is 1, port count is %d\n", port, port->count);
-		port->count = 1;
+		       " tty->count is 1, port count is %d\n", port, port->port.count);
+		port->port.count = 1;
 	}
-	if (--port->count < 0) {
-		printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->count);
-		port->count = 0;
+	if (--port->port.count < 0) {
+		printk(KERN_ERR "gs: gs_close port %p: bad port count: %d\n", port, port->port.count);
+		port->port.count = 0;
 	}
 
-	if (port->count) {
-		gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->count);
+	if (port->port.count) {
+		gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->port.count);
 		spin_unlock_irqrestore(&port->driver_lock, flags);
 		func_exit ();
 		return;
 	}
-	port->flags |= ASYNC_CLOSING;
+	port->port.flags |= ASYNC_CLOSING;
 
 	/*
 	 * Now we wait for the transmit buffer to clear; and we notify 
@@ -585,7 +585,7 @@ void gs_close(struct tty_struct * tty, struct file * filp)
 	if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
 		gs_wait_tx_flushed (port, port->closing_wait);
 
-	port->flags &= ~GS_ACTIVE;
+	port->port.flags &= ~GS_ACTIVE;
 
 	gs_flush_buffer(tty);
 
@@ -595,18 +595,18 @@ void gs_close(struct tty_struct * tty, struct file * filp)
 	port->event = 0;
 	port->rd->close (port);
 	port->rd->shutdown_port (port);
-	port->tty = NULL;
+	port->port.tty = NULL;
 
-	if (port->blocked_open) {
+	if (port->port.blocked_open) {
 		if (port->close_delay) {
 			spin_unlock_irqrestore(&port->driver_lock, flags);
 			msleep_interruptible(jiffies_to_msecs(port->close_delay));
 			spin_lock_irqsave(&port->driver_lock, flags);
 		}
-		wake_up_interruptible(&port->open_wait);
+		wake_up_interruptible(&port->port.open_wait);
 	}
-	port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED);
-	wake_up_interruptible(&port->close_wait);
+	port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED);
+	wake_up_interruptible(&port->port.close_wait);
 
 	func_exit ();
 }
@@ -626,10 +626,10 @@ void gs_set_termios (struct tty_struct * tty,
 	port = tty->driver_data;
 
 	if (!port) return;
-	if (!port->tty) {
+	if (!port->port.tty) {
 		/* This seems to happen when this is called after gs_close. */
-		gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->tty is NULL\n");
-		port->tty = tty;
+		gs_dprintk (GS_DEBUG_TERMIOS, "gs: Odd: port->port.tty is NULL\n");
+		port->port.tty = tty;
 	}
 
 
@@ -651,15 +651,15 @@ void gs_set_termios (struct tty_struct * tty,
 	baudrate = tty_get_baud_rate(tty);
 
 	if ((tiosp->c_cflag & CBAUD) == B38400) {
-		if (     (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if (     (port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			baudrate = 57600;
-		else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			baudrate = 115200;
-		else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			baudrate = 230400;
-		else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			baudrate = 460800;
-		else if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
+		else if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
 			baudrate = (port->baud_base / port->custom_divisor);
 	}
 
@@ -715,7 +715,7 @@ int gs_init_port(struct gs_port *port)
 
 	func_enter ();
 
-	if (port->flags & ASYNC_INITIALIZED) {
+	if (port->port.flags & ASYNC_INITIALIZED) {
 		func_exit ();
 		return 0;
 	}
@@ -737,15 +737,15 @@ int gs_init_port(struct gs_port *port)
 	}
 
 	spin_lock_irqsave (&port->driver_lock, flags);
-	if (port->tty) 
-		clear_bit(TTY_IO_ERROR, &port->tty->flags);
+	if (port->port.tty) 
+		clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
 	mutex_init(&port->port_write_mutex);
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
 	spin_unlock_irqrestore(&port->driver_lock, flags);
-	gs_set_termios(port->tty, NULL);
+	gs_set_termios(port->port.tty, NULL);
 	spin_lock_irqsave (&port->driver_lock, flags);
-	port->flags |= ASYNC_INITIALIZED;
-	port->flags &= ~GS_TX_INTEN;
+	port->port.flags |= ASYNC_INITIALIZED;
+	port->port.flags &= ~GS_TX_INTEN;
 
 	spin_unlock_irqrestore(&port->driver_lock, flags);
 	func_exit ();
@@ -764,11 +764,11 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp)
 		if ((sio.baud_base != port->baud_base) ||
 		    (sio.close_delay != port->close_delay) ||
 		    ((sio.flags & ~ASYNC_USR_MASK) !=
-		     (port->flags & ~ASYNC_USR_MASK)))
+		     (port->port.flags & ~ASYNC_USR_MASK)))
 			return(-EPERM);
 	} 
 
-	port->flags = (port->flags & ~ASYNC_USR_MASK) |
+	port->port.flags = (port->port.flags & ~ASYNC_USR_MASK) |
 		(sio.flags & ASYNC_USR_MASK);
   
 	port->baud_base = sio.baud_base;
@@ -776,7 +776,7 @@ int gs_setserial(struct gs_port *port, struct serial_struct __user *sp)
 	port->closing_wait = sio.closing_wait;
 	port->custom_divisor = sio.custom_divisor;
 
-	gs_set_termios (port->tty, NULL);
+	gs_set_termios (port->port.tty, NULL);
 
 	return 0;
 }
@@ -793,7 +793,7 @@ int gs_getserial(struct gs_port *port, struct serial_struct __user *sp)
 	struct serial_struct    sio;
 
 	memset(&sio, 0, sizeof(struct serial_struct));
-	sio.flags = port->flags;
+	sio.flags = port->port.flags;
 	sio.baud_base = port->baud_base;
 	sio.close_delay = port->close_delay;
 	sio.closing_wait = port->closing_wait;
@@ -821,10 +821,10 @@ void gs_got_break(struct gs_port *port)
 {
 	func_enter ();
 
-	tty_insert_flip_char(port->tty, 0, TTY_BREAK);
-	tty_schedule_flip(port->tty);
-	if (port->flags & ASYNC_SAK) {
-		do_SAK (port->tty);
+	tty_insert_flip_char(port->port.tty, 0, TTY_BREAK);
+	tty_schedule_flip(port->port.tty);
+	if (port->port.flags & ASYNC_SAK) {
+		do_SAK (port->port.tty);
 	}
 
 	func_exit ();
drivers/char/rio/rio_linux.c +10 -10
index 412777c..6a828c2 100644
@@ -436,7 +436,7 @@ static void rio_disable_tx_interrupts(void *ptr)
 {
 	func_enter();
 
-	/*  port->gs.flags &= ~GS_TX_INTEN; */
+	/*  port->gs.port.flags &= ~GS_TX_INTEN; */
 
 	func_exit();
 }
@@ -460,7 +460,7 @@ static void rio_enable_tx_interrupts(void *ptr)
 	 * In general we cannot count on "tx empty" interrupts, although
 	 * the interrupt routine seems to be able to tell the difference.
 	 */
-	PortP->gs.flags &= ~GS_TX_INTEN;
+	PortP->gs.port.flags &= ~GS_TX_INTEN;
 
 	func_exit();
 }
@@ -515,7 +515,7 @@ static void rio_shutdown_port(void *ptr)
 	func_enter();
 
 	PortP = (struct Port *) ptr;
-	PortP->gs.tty = NULL;
+	PortP->gs.port.tty = NULL;
 	func_exit();
 }
 
@@ -534,7 +534,7 @@ static void rio_hungup(void *ptr)
 	func_enter();
 
 	PortP = (struct Port *) ptr;
-	PortP->gs.tty = NULL;
+	PortP->gs.port.tty = NULL;
 
 	func_exit();
 }
@@ -554,12 +554,12 @@ static void rio_close(void *ptr)
 
 	riotclose(ptr);
 
-	if (PortP->gs.count) {
-		printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.count);
-		PortP->gs.count = 0;
+	if (PortP->gs.port.count) {
+		printk(KERN_ERR "WARNING port count:%d\n", PortP->gs.port.count);
+		PortP->gs.port.count = 0;
 	}
 
-	PortP->gs.tty = NULL;
+	PortP->gs.port.tty = NULL;
 	func_exit();
 }
 
@@ -854,8 +854,8 @@ static int rio_init_datastructures(void)
 		/*
 		 * Initializing wait queue
 		 */
-		init_waitqueue_head(&port->gs.open_wait);
-		init_waitqueue_head(&port->gs.close_wait);
+		init_waitqueue_head(&port->gs.port.open_wait);
+		init_waitqueue_head(&port->gs.port.close_wait);
 	}
 #else
 	/* We could postpone initializing them to when they are configured. */
drivers/char/rio/riocmd.c +5 -5
index 7b96e08..d940f67 100644
@@ -487,12 +487,12 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
 				 ** If the device is a modem, then check the modem
 				 ** carrier.
 				 */
-				if (PortP->gs.tty == NULL)
+				if (PortP->gs.port.tty == NULL)
 					break;
-				if (PortP->gs.tty->termios == NULL)
+				if (PortP->gs.port.tty->termios == NULL)
 					break;
 
-				if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) {
+				if (!(PortP->gs.port.tty->termios->c_cflag & CLOCAL) && ((PortP->State & (RIO_MOPEN | RIO_WOPEN)))) {
 
 					rio_dprintk(RIO_DEBUG_CMD, "Is there a Carrier?\n");
 					/*
@@ -509,7 +509,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
 							 ** wakeup anyone in WOPEN
 							 */
 							if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
-								wake_up_interruptible(&PortP->gs.open_wait);
+								wake_up_interruptible(&PortP->gs.port.open_wait);
 						}
 					} else {
 						/*
@@ -517,7 +517,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
 						 */
 						if (PortP->State & RIO_CARR_ON) {
 							if (PortP->State & (PORT_ISOPEN | RIO_WOPEN | RIO_MOPEN))
-								tty_hangup(PortP->gs.tty);
+								tty_hangup(PortP->gs.port.tty);
 							PortP->State &= ~RIO_CARR_ON;
 							rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
 						}
drivers/char/rio/riointr.c +5 -5
index ea21686..e9f9db9 100644
@@ -106,7 +106,7 @@ void RIOTxEnable(char *en)
 
 	PortP = (struct Port *) en;
 	p = (struct rio_info *) PortP->p;
-	tty = PortP->gs.tty;
+	tty = PortP->gs.port.tty;
 
 
 	rio_dprintk(RIO_DEBUG_INTR, "tx port %d: %d chars queued.\n", PortP->PortNum, PortP->gs.xmit_cnt);
@@ -162,7 +162,7 @@ void RIOTxEnable(char *en)
 	rio_spin_unlock_irqrestore(&PortP->portSem, flags);
 
 	if (PortP->gs.xmit_cnt <= (PortP->gs.wakeup_chars + 2 * PKT_MAX_DATA_LEN))
-		tty_wakeup(PortP->gs.tty);
+		tty_wakeup(PortP->gs.port.tty);
 
 }
 
@@ -245,7 +245,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
 			 ** find corresponding tty structure. The process of mapping
 			 ** the ports puts these here.
 			 */
-			ttyP = PortP->gs.tty;
+			ttyP = PortP->gs.port.tty;
 
 			/*
 			 ** Lock the port before we begin working on it.
@@ -339,7 +339,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
 			 ** find corresponding tty structure. The process of mapping
 			 ** the ports puts these here.
 			 */
-			ttyP = PortP->gs.tty;
+			ttyP = PortP->gs.port.tty;
 			/* If ttyP is NULL, the port is getting closed. Forget about it. */
 			if (!ttyP) {
 				rio_dprintk(RIO_DEBUG_INTR, "no tty, so skipping.\n");
@@ -546,7 +546,7 @@ static void RIOReceive(struct rio_info *p, struct Port *PortP)
 
 	intCount++;
 
-	TtyP = PortP->gs.tty;
+	TtyP = PortP->gs.port.tty;
 	if (!TtyP) {
 		rio_dprintk(RIO_DEBUG_INTR, "RIOReceive: tty is null. \n");
 		return;
drivers/char/rio/rioparam.c +1 -1
index 4810b84..908f764 100644
@@ -164,7 +164,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
 
 	func_enter();
 
-	TtyP = PortP->gs.tty;
+	TtyP = PortP->gs.port.tty;
 
 	rio_dprintk(RIO_DEBUG_PARAM, "RIOParam: Port:%d cmd:%d Modem:%d SleepFlag:%d Mapped: %d, tty=%p\n", PortP->PortNum, cmd, Modem, SleepFlag, PortP->Mapped, TtyP);
 
drivers/char/rio/riotty.c +8 -8
index c993548..76c7f4f 100644
@@ -144,14 +144,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)
 
 	tty->driver_data = PortP;
 
-	PortP->gs.tty = tty;
-	PortP->gs.count++;
+	PortP->gs.port.tty = tty;
+	PortP->gs.port.count++;
 
 	rio_dprintk(RIO_DEBUG_TTY, "%d bytes in tx buffer\n", PortP->gs.xmit_cnt);
 
 	retval = gs_init_port(&PortP->gs);
 	if (retval) {
-		PortP->gs.count--;
+		PortP->gs.port.count--;
 		return -ENXIO;
 	}
 	/*
@@ -297,7 +297,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
 	 ** insert test for carrier here. -- ???
 	 ** I already see that test here. What's the deal? -- REW
 	 */
-	if ((PortP->gs.tty->termios->c_cflag & CLOCAL) ||
+	if ((PortP->gs.port.tty->termios->c_cflag & CLOCAL) ||
 			(PortP->ModemState & RIOC_MSVR1_CD)) {
 		rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
 		/*
@@ -305,16 +305,16 @@ int riotopen(struct tty_struct *tty, struct file *filp)
 		   wakeup((caddr_t) &tp->tm.c_canq);
 		 */
 		PortP->State |= RIO_CARR_ON;
-		wake_up_interruptible(&PortP->gs.open_wait);
+		wake_up_interruptible(&PortP->gs.port.open_wait);
 	} else {	/* no carrier - wait for DCD */
 			/*
-		   while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
+		   while (!(PortP->gs.port.tty->termios->c_state & CARR_ON) &&
 		   !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
 		 */
 		while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
 				rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
 			/*
-			   PortP->gs.tty->termios->c_state |= WOPEN;
+			   PortP->gs.port.tty->termios->c_state |= WOPEN;
 			 */
 			PortP->State |= RIO_WOPEN;
 			rio_spin_unlock_irqrestore(&PortP->portSem, flags);
@@ -384,7 +384,7 @@ int riotclose(void *ptr)
 	/* PortP = p->RIOPortp[SysPort]; */
 	rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
 	/* tp = PortP->TtyP; *//* Get tty */
-	tty = PortP->gs.tty;
+	tty = PortP->gs.port.tty;
 	rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);
 
 	if (PortP->gs.closing_wait)
drivers/char/sx.c +56 -59

283 lines not on this page · raw message

include/linux/generic_serial.h +2 -6
index 1108336..4cc9139 100644
@@ -14,6 +14,7 @@
 
 #ifdef __KERNEL__
 #include <linux/mutex.h>
+#include <linux/tty.h>
 
 struct real_driver {
   void                    (*disable_tx_interrupts) (void *);
@@ -33,17 +34,12 @@ struct real_driver {
 
 struct gs_port {
   int                     magic;
+  struct tty_port	  port;
   unsigned char           *xmit_buf; 
   int                     xmit_head;
   int                     xmit_tail;
   int                     xmit_cnt;
   struct mutex            port_write_mutex;
-  int                     flags;
-  wait_queue_head_t       open_wait;
-  wait_queue_head_t       close_wait;
-  int                     count;
-  int                     blocked_open;
-  struct tty_struct       *tty;
   unsigned long           event;
   unsigned short          closing_wait;
   int                     close_delay;
author
#19 lore raw

PATCH 15/20 serial: use tty_port

In reply to Alan Cox

From: Alan Cox <[email protected]>

Switch the serial_core based drivers to use the new tty_port structure. We can't quite use all of it yet because of the dynamically allocated extras in the serial_core layer.
---

 drivers/serial/8250.c        |    2 +
 drivers/serial/jsm/jsm_neo.c |    2 +
 drivers/serial/jsm/jsm_tty.c |    8 ++--
 drivers/serial/serial_core.c |   80 ++++++++++++++++++++++--------------------
 include/linux/serial_core.h  |   26 ++++++--------
 5 files changed, 60 insertions(+), 58 deletions(-)
drivers/serial/8250.c +1 -1
index a1ca9b7..56ca93a 100644
@@ -1290,7 +1290,7 @@ static void serial8250_enable_ms(struct uart_port *port)
 static void
 receive_chars(struct uart_8250_port *up, unsigned int *status)
 {
-	struct tty_struct *tty = up->port.info->tty;
+	struct tty_struct *tty = up->port.info->port.tty;
 	unsigned char ch, lsr = *status;
 	int max_count = 256;
 	char flag;
drivers/serial/jsm/jsm_neo.c +1 -1
index b2d6f5b..b7584ca 100644
@@ -998,7 +998,7 @@ static void neo_param(struct jsm_channel *ch)
 			{     50, B50     },
 		};
 
-		cflag = C_BAUD(ch->uart_port.info->tty);
+		cflag = C_BAUD(ch->uart_port.info->port.tty);
 		baud = 9600;
 		for (i = 0; i < ARRAY_SIZE(baud_rates); i++) {
 			if (baud_rates[i].cflag == cflag) {
drivers/serial/jsm/jsm_tty.c +4 -4
index 94ec663..a697914 100644
@@ -145,7 +145,7 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
 	struct ktermios *termios;
 
 	spin_lock_irqsave(&port->lock, lock_flags);
-	termios = port->info->tty->termios;
+	termios = port->info->port.tty->termios;
 	if (ch == termios->c_cc[VSTART])
 		channel->ch_bd->bd_ops->send_start_character(channel);
 
@@ -239,7 +239,7 @@ static int jsm_tty_open(struct uart_port *port)
 	channel->ch_cached_lsr = 0;
 	channel->ch_stops_sent = 0;
 
-	termios = port->info->tty->termios;
+	termios = port->info->port.tty->termios;
 	channel->ch_c_cflag	= termios->c_cflag;
 	channel->ch_c_iflag	= termios->c_iflag;
 	channel->ch_c_oflag	= termios->c_oflag;
@@ -272,7 +272,7 @@ static void jsm_tty_close(struct uart_port *port)
 	jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n");
 
 	bd = channel->ch_bd;
-	ts = channel->uart_port.info->tty->termios;
+	ts = channel->uart_port.info->port.tty->termios;
 
 	channel->ch_flags &= ~(CH_STOPI);
 
@@ -515,7 +515,7 @@ void jsm_input(struct jsm_channel *ch)
 	if (!ch)
 		return;
 
-	tp = ch->uart_port.info->tty;
+	tp = ch->uart_port.info->port.tty;
 
 	bd = ch->ch_bd;
 	if(!bd)
drivers/serial/serial_core.c +42 -38

265 lines not on this page · raw message

include/linux/serial_core.h +12 -14
index d32123a..2fbe004 100644
@@ -342,13 +342,15 @@ typedef unsigned int __bitwise__ uif_t;
  * stuff here.
  */
 struct uart_info {
-	struct tty_struct	*tty;
+	struct tty_port		port;
 	struct circ_buf		xmit;
 	uif_t			flags;
 
 /*
  * Definitions for info->flags.  These are _private_ to serial_core, and
  * are specific to this structure.  They may be queried by low level drivers.
+ *
+ * FIXME: use the ASY_ definitions
  */
 #define UIF_CHECK_CD		((__force uif_t) (1 << 25))
 #define UIF_CTS_FLOW		((__force uif_t) (1 << 26))
@@ -356,11 +358,7 @@ struct uart_info {
 #define UIF_INITIALIZED		((__force uif_t) (1 << 31))
 #define UIF_SUSPENDED		((__force uif_t) (1 << 30))
 
-	int			blocked_open;
-
 	struct tasklet_struct	tlet;
-
-	wait_queue_head_t	open_wait;
 	wait_queue_head_t	delta_msr_wait;
 };
 
@@ -437,8 +435,8 @@ int uart_resume_port(struct uart_driver *reg, struct uart_port *port);
 #define uart_circ_chars_free(circ)	\
 	(CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))
 
-#define uart_tx_stopped(port)		\
-	((port)->info->tty->stopped || (port)->info->tty->hw_stopped)
+#define uart_tx_stopped(portp)		\
+	((portp)->info->port.tty->stopped || (portp)->info->port.tty->hw_stopped)
 
 /*
  * The following are helper functions for the low level drivers.
@@ -449,7 +447,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 #ifdef SUPPORT_SYSRQ
 	if (port->sysrq) {
 		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch, port->info ? port->info->tty : NULL);
+			handle_sysrq(ch, port->info ? port->info->port.tty : NULL);
 			port->sysrq = 0;
 			return 1;
 		}
@@ -478,7 +476,7 @@ static inline int uart_handle_break(struct uart_port *port)
 	}
 #endif
 	if (port->flags & UPF_SAK)
-		do_SAK(info->tty);
+		do_SAK(info->port.tty);
 	return 0;
 }
 
@@ -501,9 +499,9 @@ uart_handle_dcd_change(struct uart_port *port, unsigned int status)
 
 	if (info->flags & UIF_CHECK_CD) {
 		if (status)
-			wake_up_interruptible(&info->open_wait);
-		else if (info->tty)
-			tty_hangup(info->tty);
+			wake_up_interruptible(&info->port.open_wait);
+		else if (info->port.tty)
+			tty_hangup(info->port.tty);
 	}
 }
 
@@ -516,7 +514,7 @@ static inline void
 uart_handle_cts_change(struct uart_port *port, unsigned int status)
 {
 	struct uart_info *info = port->info;
-	struct tty_struct *tty = info->tty;
+	struct tty_struct *tty = info->port.tty;
 
 	port->icount.cts++;
 
@@ -542,7 +540,7 @@ static inline void
 uart_insert_char(struct uart_port *port, unsigned int status,
 		 unsigned int overrun, unsigned int ch, unsigned int flag)
 {
-	struct tty_struct *tty = port->info->tty;
+	struct tty_struct *tty = port->info->port.tty;
 
 	if ((status & port->ignore_status_mask & ~overrun) == 0)
 		tty_insert_flip_char(tty, ch, flag);
author
#20 lore raw

PATCH 17/20 riscom8: remove bogus checks

In reply to Alan Cox

From: Alan Cox <[email protected]>

Chris Malley posted a patch removing a NULL check in the riscom8 driver. Further analysis shows that even more of the tests are irrelevant so we can delete lots of stuff
---

 drivers/char/riscom8.c |   32 ++++++++------------------------
 1 files changed, 8 insertions(+), 24 deletions(-)
drivers/char/riscom8.c +8 -24
index b0ba241..3ca8957 100644
@@ -638,9 +638,6 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
 	unsigned char cor1 = 0, cor3 = 0;
 	unsigned char mcor1 = 0, mcor2 = 0;
 
-	if (tty == NULL || tty->termios == NULL)
-		return;
-
 	port->IER  = 0;
 	port->COR2 = 0;
 	port->MSVR = MSVR_RTS;
@@ -794,8 +791,7 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
 
 	spin_lock_irqsave(&riscom_lock, flags);
 
-	if (port->port.tty)
-		clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
+	clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
 	if (port->port.count == 1)
 		bp->count++;
 	port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
@@ -807,10 +803,9 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
 }
 
 /* Must be called with interrupts disabled */
-static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
+static void rc_shutdown_port(struct tty_struct *tty,
+			struct riscom_board *bp, struct riscom_port *port)
 {
-	struct tty_struct *tty;
-
 	if (!(port->port.flags & ASYNC_INITIALIZED))
 		return;
 
@@ -830,10 +825,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
 	}
 #endif
 	tty_port_free_xmit_buf(&port->port);
-
-	tty = port->port.tty;
-
-	if (tty == NULL || C_HUPCL(tty)) {
+	if (C_HUPCL(tty)) {
 		/* Drop DTR */
 		bp->DTR |= (1u << port_No(port));
 		rc_out(bp, RC_DTR, bp->DTR);
@@ -848,8 +840,7 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
 	port->IER = 0;
 	rc_out(bp, CD180_IER, port->IER);
 
-	if (tty)
-		set_bit(TTY_IO_ERROR, &tty->flags);
+	set_bit(TTY_IO_ERROR, &tty->flags);
 	port->port.flags &= ~ASYNC_INITIALIZED;
 
 	if (--bp->count < 0)  {
@@ -1067,7 +1058,7 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 				break;
 		}
 	}
-	rc_shutdown_port(bp, port);
+	rc_shutdown_port(tty, bp, port);
 	rc_flush_buffer(tty);
 	tty_ldisc_flush(tty);
 
@@ -1098,9 +1089,6 @@ static int rc_write(struct tty_struct *tty,
 
 	bp = port_Board(port);
 
-	if (!tty || !port->port.xmit_buf)
-		return 0;
-
 	while (1) {
 		spin_lock_irqsave(&riscom_lock, flags);
 
@@ -1141,9 +1129,6 @@ static int rc_put_char(struct tty_struct *tty, unsigned char ch)
 	if (rc_paranoia_check(port, tty->name, "rc_put_char"))
 		return 0;
 
-	if (!tty || !port->port.xmit_buf)
-		return 0;
-
 	spin_lock_irqsave(&riscom_lock, flags);
 
 	if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
@@ -1167,8 +1152,7 @@ static void rc_flush_chars(struct tty_struct *tty)
 	if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
 		return;
 
-	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
-	    !port->port.xmit_buf)
+	if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
 		return;
 
 	spin_lock_irqsave(&riscom_lock, flags);
@@ -1488,7 +1472,7 @@ static void rc_hangup(struct tty_struct *tty)
 
 	bp = port_Board(port);
 
-	rc_shutdown_port(bp, port);
+	rc_shutdown_port(tty, bp, port);
 	port->port.count = 0;
 	port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 	port->port.tty = NULL;
author
#21 lore raw

PATCH 18/20 tty: add more tty_port fields

In reply to Alan Cox

From: Alan Cox <[email protected]>

Move more bits into the tty_port structure
---

 drivers/char/cyclades.c      |   28 ++++----
 drivers/char/isicom.c        |   28 ++++----
 drivers/char/moxa.c          |    8 +-
 drivers/char/mxser.c         |   29 +++-----
 drivers/char/riscom8.c       |   24 +++----
 drivers/char/riscom8.h       |    2 -
 drivers/char/rocket.c        |   23 +++---
 drivers/char/rocket.h        |    4 +
 drivers/char/rocket_int.h    |    2 -
 drivers/char/specialix.c     |  153 ++++++++++++++++++++----------------------
 drivers/char/specialix_io8.h |    8 --
 drivers/char/sx.c            |    2 -
 drivers/char/synclink.c      |   16 ++--
 drivers/char/synclink_gt.c   |   16 ++--
 drivers/char/synclinkmp.c    |   14 ++--
 drivers/char/tty_io.c        |    2 +
 include/linux/cyclades.h     |    6 +-
 include/linux/tty.h          |    2 +
 18 files changed, 169 insertions(+), 198 deletions(-)
drivers/char/cyclades.c +14 -14
index 44fda9b..b85f518 100644
@@ -2677,8 +2677,8 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 	 */
 	tty->closing = 1;
 	spin_unlock_irqrestore(&card->card_lock, flags);
-	if (info->closing_wait != CY_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, info->closing_wait);
+	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);
 
@@ -2734,9 +2734,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
 	info->port.tty = NULL;
 	if (info->port.blocked_open) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
-		if (info->close_delay) {
+		if (info->port.close_delay) {
 			msleep_interruptible(jiffies_to_msecs
-						(info->close_delay));
+						(info->port.close_delay));
 		}
 		wake_up_interruptible(&info->port.open_wait);
 		spin_lock_irqsave(&card->card_lock, flags);
@@ -3382,8 +3382,8 @@ get_serial_info(struct cyclades_port *info,
 		cinfo->first_line;
 	tmp.irq = cinfo->irq;
 	tmp.flags = info->port.flags;
-	tmp.close_delay = info->close_delay;
-	tmp.closing_wait = info->closing_wait;
+	tmp.close_delay = info->port.close_delay;
+	tmp.closing_wait = info->port.closing_wait;
 	tmp.baud_base = info->baud;
 	tmp.custom_divisor = info->custom_divisor;
 	tmp.hub6 = 0;		/*!!! */
@@ -3402,7 +3402,7 @@ set_serial_info(struct cyclades_port *info,
 	old_info = *info;
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if (new_serial.close_delay != info->close_delay ||
+		if (new_serial.close_delay != info->port.close_delay ||
 				new_serial.baud_base != info->baud ||
 				(new_serial.flags & ASYNC_FLAGS &
 					~ASYNC_USR_MASK) !=
@@ -3424,8 +3424,8 @@ set_serial_info(struct cyclades_port *info,
 	info->custom_divisor = new_serial.custom_divisor;
 	info->port.flags = (info->port.flags & ~ASYNC_FLAGS) |
 			(new_serial.flags & ASYNC_FLAGS);
-	info->close_delay = new_serial.close_delay * HZ / 100;
-	info->closing_wait = new_serial.closing_wait * HZ / 100;
+	info->port.close_delay = new_serial.close_delay * HZ / 100;
+	info->port.closing_wait = new_serial.closing_wait * HZ / 100;
 
 check_and_exit:
 	if (info->port.flags & ASYNC_INITIALIZED) {
@@ -3971,11 +3971,11 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
 		break;
 #endif				/* CONFIG_CYZ_INTR */
 	case CYSETWAIT:
-		info->closing_wait = (unsigned short)arg * HZ / 100;
+		info->port.closing_wait = (unsigned short)arg * HZ / 100;
 		ret_val = 0;
 		break;
 	case CYGETWAIT:
-		ret_val = info->closing_wait / (HZ / 100);
+		ret_val = info->port.closing_wait / (HZ / 100);
 		break;
 	case TIOCGSERIAL:
 		ret_val = get_serial_info(info, argp);
@@ -4376,13 +4376,13 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
 	for (port = cinfo->first_line; port < cinfo->first_line + nports;
 			port++) {
 		info = &cinfo->ports[port - cinfo->first_line];
+		tty_port_init(&info->port);
 		info->magic = CYCLADES_MAGIC;
 		info->card = cinfo;
 		info->line = port;
-		info->closing_wait = CLOSING_WAIT_DELAY;
-		info->close_delay = 5 * HZ / 10;
 
-		tty_port_init(&info->port);
+		info->port.closing_wait = CLOSING_WAIT_DELAY;
+		info->port.close_delay = 5 * HZ / 10;
 		info->port.flags = STD_COM_FLAGS;
 		init_completion(&info->shutdown_wait);
 		init_waitqueue_head(&info->delta_msr_wait);
drivers/char/isicom.c +13 -15
index 20be56f..fdc9420 100644
@@ -199,10 +199,8 @@ struct	isi_board {
 struct	isi_port {
 	unsigned short		magic;
 	struct tty_port		port;
-	int			close_delay;
 	u16			channel;
 	u16			status;
-	u16			closing_wait;
 	struct isi_board	*card;
 	unsigned char		*xmit_buf;
 	int			xmit_head;
@@ -1051,8 +1049,8 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 	tty->closing = 1;
 	spin_unlock_irqrestore(&card->card_lock, flags);
 
-	if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, port->closing_wait);
+	if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, port->port.closing_wait);
 	/* indicate to the card that no more data can be received
 	   on this port */
 	spin_lock_irqsave(&card->card_lock, flags);
@@ -1071,10 +1069,10 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
 
 	if (port->port.blocked_open) {
 		spin_unlock_irqrestore(&card->card_lock, flags);
-		if (port->close_delay) {
+		if (port->port.close_delay) {
 			pr_dbg("scheduling until time out.\n");
 			msleep_interruptible(
-				jiffies_to_msecs(port->close_delay));
+				jiffies_to_msecs(port->port.close_delay));
 		}
 		spin_lock_irqsave(&card->card_lock, flags);
 		wake_up_interruptible(&port->port.open_wait);
@@ -1256,8 +1254,8 @@ static int isicom_set_serial_info(struct isi_port *port,
 		(newinfo.flags & ASYNC_SPD_MASK));
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if ((newinfo.close_delay != port->close_delay) ||
-				(newinfo.closing_wait != port->closing_wait) ||
+		if ((newinfo.close_delay != port->port.close_delay) ||
+				(newinfo.closing_wait != port->port.closing_wait) ||
 				((newinfo.flags & ~ASYNC_USR_MASK) !=
 				(port->port.flags & ~ASYNC_USR_MASK))) {
 			unlock_kernel();
@@ -1266,8 +1264,8 @@ static int isicom_set_serial_info(struct isi_port *port,
 		port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
 				(newinfo.flags & ASYNC_USR_MASK));
 	} else {
-		port->close_delay = newinfo.close_delay;
-		port->closing_wait = newinfo.closing_wait;
+		port->port.close_delay = newinfo.close_delay;
+		port->port.closing_wait = newinfo.closing_wait;
 		port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
 				(newinfo.flags & ASYNC_FLAGS));
 	}
@@ -1294,8 +1292,8 @@ static int isicom_get_serial_info(struct isi_port *port,
 	out_info.irq = port->card->irq;
 	out_info.flags = port->port.flags;
 /*	out_info.baud_base = ? */
-	out_info.close_delay = port->close_delay;
-	out_info.closing_wait = port->closing_wait;
+	out_info.close_delay = port->port.close_delay;
+	out_info.closing_wait = port->port.closing_wait;
 	unlock_kernel();
 	if (copy_to_user(info, &out_info, sizeof(out_info)))
 		return -EFAULT;
@@ -1796,13 +1794,13 @@ static int __init isicom_init(void)
 		isi_card[idx].ports = port;
 		spin_lock_init(&isi_card[idx].card_lock);
 		for (channel = 0; channel < 16; channel++, port++) {
+			tty_port_init(&port->port);
 			port->magic = ISICOM_MAGIC;
 			port->card = &isi_card[idx];
 			port->channel = channel;
-			port->close_delay = 50 * HZ/100;
-			port->closing_wait = 3000 * HZ/100;
+			port->port.close_delay = 50 * HZ/100;
+			port->port.closing_wait = 3000 * HZ/100;
 			port->status = 0;
-			tty_port_init(&port->port);
 			/*  . . .  */
 		}
 		isi_card[idx].base = 0;
drivers/char/moxa.c +3 -5
index bb9bcff..f8d48ed 100644
@@ -135,7 +135,6 @@ struct moxa_port {
 	void __iomem *tableAddr;
 
 	int type;
-	int close_delay;
 	int cflag;
 	unsigned long statusflags;
 
@@ -822,10 +821,9 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
 	}
 
 	for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) {
+		tty_port_init(&p->port);
 		p->type = PORT_16550A;
-		p->close_delay = 5 * HZ / 10;
 		p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
-		tty_port_init(&p->port);
 	}
 
 	switch (brd->boardType) {
@@ -2124,7 +2122,7 @@ static int moxa_get_serial_info(struct moxa_port *info,
 		.line = info->port.tty->index,
 		.flags = info->port.flags,
 		.baud_base = 921600,
-		.close_delay = info->close_delay
+		.close_delay = info->port.close_delay
 	};
 	return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
 }
@@ -2148,7 +2146,7 @@ static int moxa_set_serial_info(struct moxa_port *info,
 		     (info->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
 	} else
-		info->close_delay = new_serial.close_delay * HZ / 100;
+		info->port.close_delay = new_serial.close_delay * HZ / 100;
 
 	new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
 	new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
drivers/char/mxser.c +12 -17
index e83ccee..6307e30 100644
@@ -243,10 +243,7 @@ struct mxser_port {
 	unsigned char ldisc_stop_rx;
 
 	int custom_divisor;
-	int close_delay;
-	unsigned short closing_wait;
 	unsigned char err_shadow;
-	unsigned long event;
 
 	struct async_icount icount; /* kernel counters for 4 input interrupts */
 	int timeout;
@@ -1199,8 +1196,8 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 	 * the line discipline to only process XON/XOFF characters.
 	 */
 	tty->closing = 1;
-	if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, info->closing_wait);
+	if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, info->port.closing_wait);
 	/*
 	 * At this point we stop accepting input.  To do this, we
 	 * disable the receive line status interrupts, and tell the
@@ -1231,11 +1228,10 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
 	tty_ldisc_flush(tty);
 
 	tty->closing = 0;
-	info->event = 0;
 	info->port.tty = NULL;
 	if (info->port.blocked_open) {
-		if (info->close_delay)
-			schedule_timeout_interruptible(info->close_delay);
+		if (info->port.close_delay)
+			schedule_timeout_interruptible(info->port.close_delay);
 		wake_up_interruptible(&info->port.open_wait);
 	}
 
@@ -1370,8 +1366,8 @@ static int mxser_get_serial_info(struct mxser_port *info,
 		.irq = info->board->irq,
 		.flags = info->port.flags,
 		.baud_base = info->baud_base,
-		.close_delay = info->close_delay,
-		.closing_wait = info->closing_wait,
+		.close_delay = info->port.close_delay,
+		.closing_wait = info->port.closing_wait,
 		.custom_divisor = info->custom_divisor,
 		.hub6 = 0
 	};
@@ -1402,7 +1398,7 @@ static int mxser_set_serial_info(struct mxser_port *info,
 
 	if (!capable(CAP_SYS_ADMIN)) {
 		if ((new_serial.baud_base != info->baud_base) ||
-				(new_serial.close_delay != info->close_delay) ||
+				(new_serial.close_delay != info->port.close_delay) ||
 				((new_serial.flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
 		info->port.flags = ((info->port.flags & ~ASYNC_USR_MASK) |
@@ -1414,8 +1410,8 @@ static int mxser_set_serial_info(struct mxser_port *info,
 		 */
 		info->port.flags = ((info->port.flags & ~ASYNC_FLAGS) |
 				(new_serial.flags & ASYNC_FLAGS));
-		info->close_delay = new_serial.close_delay * HZ / 100;
-		info->closing_wait = new_serial.closing_wait * HZ / 100;
+		info->port.close_delay = new_serial.close_delay * HZ / 100;
+		info->port.closing_wait = new_serial.closing_wait * HZ / 100;
 		info->port.tty->low_latency =
 				(info->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 		info->port.tty->low_latency = 0;
@@ -2214,7 +2210,6 @@ static void mxser_hangup(struct tty_struct *tty)
 
 	mxser_flush_buffer(tty);
 	mxser_shutdown(info);
-	info->event = 0;
 	info->port.count = 0;
 	info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
 	info->port.tty = NULL;
@@ -2545,6 +2540,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
 
 	for (i = 0; i < brd->info->nports; i++) {
 		info = &brd->ports[i];
+		tty_port_init(&info->port);
 		info->board = brd;
 		info->stop_rx = 0;
 		info->ldisc_stop_rx = 0;
@@ -2559,10 +2555,9 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
 		process_txrx_fifo(info);
 
 		info->custom_divisor = info->baud_base * 16;
-		info->close_delay = 5 * HZ / 10;
-		info->closing_wait = 30 * HZ;
+		info->port.close_delay = 5 * HZ / 10;
+		info->port.closing_wait = 30 * HZ;
 		info->normal_termios = mxvar_sdriver->init_termios;
-		tty_port_init(&info->port);
 		init_waitqueue_head(&info->delta_msr_wait);
 		memset(&info->mon_data, 0, sizeof(struct mxser_mon));
 		info->err_shadow = 0;
drivers/char/riscom8.c +11 -13
index 3ca8957..724b2b2 100644
@@ -1032,8 +1032,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 	 * the line discipline to only process XON/XOFF characters.
 	 */
 	tty->closing = 1;
-	if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, port->closing_wait);
+	if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, port->port.closing_wait);
 	/*
 	 * At this point we stop accepting input.  To do this, we
 	 * disable the receive line status interrupts, and tell the
@@ -1065,8 +1065,8 @@ static void rc_close(struct tty_struct *tty, struct file *filp)
 	tty->closing = 0;
 	port->port.tty = NULL;
 	if (port->port.blocked_open) {
-		if (port->close_delay)
-			msleep_interruptible(jiffies_to_msecs(port->close_delay));
+		if (port->port.close_delay)
+			msleep_interruptible(jiffies_to_msecs(port->port.close_delay));
 		wake_up_interruptible(&port->port.open_wait);
 	}
 	port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -1295,8 +1295,8 @@ static int rc_set_serial_info(struct riscom_port *port,
 			(tmp.flags & ASYNC_SPD_MASK));
 
 	if (!capable(CAP_SYS_ADMIN)) {
-		if ((tmp.close_delay != port->close_delay) ||
-		    (tmp.closing_wait != port->closing_wait) ||
+		if ((tmp.close_delay != port->port.close_delay) ||
+		    (tmp.closing_wait != port->port.closing_wait) ||
 		    ((tmp.flags & ~ASYNC_USR_MASK) !=
 		     (port->port.flags & ~ASYNC_USR_MASK)))
 			return -EPERM;
@@ -1305,8 +1305,8 @@ static int rc_set_serial_info(struct riscom_port *port,
 	} else  {
 		port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
 			       (tmp.flags & ASYNC_FLAGS));
-		port->close_delay = tmp.close_delay;
-		port->closing_wait = tmp.closing_wait;
+		port->port.close_delay = tmp.close_delay;
+		port->port.closing_wait = tmp.closing_wait;
 	}
 	if (change_speed)  {
 		unsigned long flags;
@@ -1331,8 +1331,8 @@ static int rc_get_serial_info(struct riscom_port *port,
 	tmp.irq  = bp->irq;
 	tmp.flags = port->port.flags;
 	tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
-	tmp.close_delay = port->close_delay * HZ/100;
-	tmp.closing_wait = port->closing_wait * HZ/100;
+	tmp.close_delay = port->port.close_delay * HZ/100;
+	tmp.closing_wait = port->port.closing_wait * HZ/100;
 	tmp.xmit_fifo_size = CD180_NFIFO;
 	return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
 }
@@ -1549,10 +1549,8 @@ static int __init rc_init_drivers(void)
 	}
 	memset(rc_port, 0, sizeof(rc_port));
 	for (i = 0; i < RC_NPORT * RC_NBOARD; i++)  {
-		rc_port[i].magic = RISCOM8_MAGIC;
-		rc_port[i].close_delay = 50 * HZ / 100;
-		rc_port[i].closing_wait = 3000 * HZ / 100;
 		tty_port_init(&rc_port[i].port);
+		rc_port[i].magic = RISCOM8_MAGIC;
 	}
 	return 0;
 }
drivers/char/riscom8.h +0 -2
index 29ddbab..c9876b3 100644
@@ -69,14 +69,12 @@ struct riscom_port {
 	struct			tty_port port;
 	int			baud_base;
 	int			timeout;
-	int			close_delay;
 	int			custom_divisor;
 	int			xmit_head;
 	int			xmit_tail;
 	int			xmit_cnt;
 	short			wakeup_chars;
 	short			break_length;
-	unsigned short		closing_wait;
 	unsigned char		mark_mask;
 	unsigned char		IER;
 	unsigned char		MSVR;
drivers/char/rocket.c +12 -11
index ab04adb..bdced0e 100644
@@ -72,6 +72,7 @@
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
 #include <linux/tty_flip.h>
+#include <linux/serial.h>
 #include <linux/string.h>
 #include <linux/fcntl.h>
 #include <linux/ptrace.h>
@@ -81,7 +82,7 @@
 #include <linux/completion.h>
 #include <linux/wait.h>
 #include <linux/pci.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
 #include <asm/atomic.h>
 #include <asm/unaligned.h>
 #include <linux/bitops.h>
@@ -648,8 +649,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
 	info->board = board;
 	info->aiop = aiop;
 	info->chan = chan;
-	info->closing_wait = 3000;
-	info->close_delay = 50;
+	info->port.closing_wait = 3000;
+	info->port.close_delay = 50;
 	init_waitqueue_head(&info->port.open_wait);
 	init_completion(&info->close_wait);
 	info->flags &= ~ROCKET_MODE_MASK;
@@ -1137,8 +1138,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 	/*
 	 * Wait for the transmit buffer to clear
 	 */
-	if (info->closing_wait != ROCKET_CLOSING_WAIT_NONE)
-		tty_wait_until_sent(tty, info->closing_wait);
+	if (info->port.closing_wait != ROCKET_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, info->port.closing_wait);
 	/*
 	 * Before we drop DTR, make sure the UART transmitter
 	 * has completely drained; this is especially
@@ -1168,8 +1169,8 @@ static void rp_close(struct tty_struct *tty, struct file *filp)
 	clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
 
 	if (info->port.blocked_open) {
-		if (info->close_delay) {
-			msleep_interruptible(jiffies_to_msecs(info->close_delay));
+		if (info->port.close_delay) {
+			msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
 		}
 		wake_up_interruptible(&info->port.open_wait);
 	} else {
@@ -1327,8 +1328,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo)
 	memset(&tmp, 0, sizeof (tmp));
 	tmp.line = info->line;
 	tmp.flags = info->flags;
-	tmp.close_delay = info->close_delay;
-	tmp.closing_wait = info->closing_wait;
+	tmp.close_delay = info->port.close_delay;
+	tmp.closing_wait = info->port.closing_wait;
 	tmp.port = rcktpt_io_addr[(info->line >> 5) & 3];
 
 	if (copy_to_user(retinfo, &tmp, sizeof (*retinfo)))
@@ -1353,8 +1354,8 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
 	}
 
 	info->flags = ((info->flags & ~ROCKET_FLAGS) | (new_serial.flags & ROCKET_FLAGS));
-	info->close_delay = new_serial.close_delay;
-	info->closing_wait = new_serial.closing_wait;
+	info->port.close_delay = new_serial.close_delay;
+	info->port.closing_wait = new_serial.closing_wait;
 
 	if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI)
 		info->port.tty->alt_speed = 57600;
drivers/char/rocket.h +2 -2
index ae6b04f..a8b0919 100644
@@ -64,8 +64,8 @@ struct rocket_version {
 /*
  * For closing_wait and closing_wait2
  */
-#define ROCKET_CLOSING_WAIT_NONE	65535
-#define ROCKET_CLOSING_WAIT_INF		0
+#define ROCKET_CLOSING_WAIT_NONE	ASYNC_CLOSING_WAIT_NONE
+#define ROCKET_CLOSING_WAIT_INF		ASYNC_CLOSING_WAIT_INF
 
 /*
  * Rocketport ioctls -- "RP"
drivers/char/rocket_int.h +0 -2
index 3affc48..21f3ff5 100644
@@ -1133,8 +1133,6 @@ struct r_port {
 	unsigned int chan:3;
 	CONTROLLER_t *ctlp;
 	CHANNEL_t channel;
-	int closing_wait;
-	int close_delay;
 	int intmask;
 	int xmit_fifo_room;	/* room in xmit fifo */
 	unsigned char *xmit_buf;
drivers/char/specialix.c +73 -80

410 lines not on this page · raw message

drivers/char/specialix_io8.h +1 -7
index 3f2f85b..c630052 100644
@@ -107,23 +107,17 @@ struct specialix_board {
 
 struct specialix_port {
 	int			magic;
+	struct tty_port		port;
 	int			baud_base;
 	int			flags;
-	struct tty_struct 	* tty;
-	int			count;
-	int			blocked_open;
 	int			timeout;
-	int			close_delay;
 	unsigned char 		* xmit_buf;
 	int			custom_divisor;
 	int			xmit_head;
 	int			xmit_tail;
 	int			xmit_cnt;
-	wait_queue_head_t	open_wait;
-	wait_queue_head_t	close_wait;
 	short			wakeup_chars;
 	short			break_length;
-	unsigned short		closing_wait;
 	unsigned char		mark_mask;
 	unsigned char		IER;
 	unsigned char		MSVR;
drivers/char/sx.c +1 -1
index b1239ee..d5cffcd 100644
@@ -2395,6 +2395,7 @@ static int sx_init_portstructs(int nboards, int nports)
 		board->ports = port;
 		for (j = 0; j < boards[i].nports; j++) {
 			sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j);
+			tty_port_init(&port->gs.port);
 			port->gs.magic = SX_MAGIC;
 			port->gs.close_delay = HZ / 2;
 			port->gs.closing_wait = 30 * HZ;
@@ -2407,7 +2408,6 @@ static int sx_init_portstructs(int nboards, int nports)
 			/*
 			 * Initializing wait queue
 			 */
-			tty_port_init(&port->gs.port);
 			port++;
 		}
 	}
drivers/char/synclink.c +7 -9
index 0678f61..4625f66 100644
@@ -183,8 +183,6 @@ struct mgsl_struct {
 	struct tty_port		port;
 	int			line;
 	int                     hw_version;
-	unsigned short		close_delay;
-	unsigned short		closing_wait;	/* time to wait before closing */
 	
 	struct mgsl_icount	icount;
 	
@@ -3142,11 +3140,11 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
 	
 	/* wait for transmit data to clear all layers */
 	
-	if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
+	if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n",
 				 __FILE__,__LINE__, info->device_name );
-		tty_wait_until_sent(tty, info->closing_wait);
+		tty_wait_until_sent(tty, info->port.closing_wait);
 	}
 		
  	if (info->port.flags & ASYNC_INITIALIZED)
@@ -3162,8 +3160,8 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
 	info->port.tty = NULL;
 	
 	if (info->port.blocked_open) {
-		if (info->close_delay) {
-			msleep_interruptible(jiffies_to_msecs(info->close_delay));
+		if (info->port.close_delay) {
+			msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
 		}
 		wake_up_interruptible(&info->port.open_wait);
 	}
@@ -4326,12 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)
 	if (!info) {
 		printk("Error can't allocate device instance data\n");
 	} else {
+		tty_port_init(&info->port);
 		info->magic = MGSL_MAGIC;
 		INIT_WORK(&info->task, mgsl_bh_handler);
 		info->max_frame_size = 4096;
-		info->close_delay = 5*HZ/10;
-		info->closing_wait = 30*HZ;
-		tty_port_init(&info->port);
+		info->port.close_delay = 5*HZ/10;
+		info->port.closing_wait = 30*HZ;
 		init_waitqueue_head(&info->status_event_wait_q);
 		init_waitqueue_head(&info->event_wait_q);
 		spin_lock_init(&info->irq_spinlock);
drivers/char/synclink_gt.c +7 -9
index 220eb04..61594dd 100644
@@ -261,8 +261,6 @@ struct slgt_info {
 	struct slgt_info *port_array[SLGT_MAX_PORTS];
 
 	int			line;		/* tty line instance number */
-	unsigned short		close_delay;
-	unsigned short		closing_wait;	/* time to wait before closing */
 
 	struct mgsl_icount	icount;
 
@@ -758,9 +756,9 @@ static void close(struct tty_struct *tty, struct file *filp)
 
 	/* wait for transmit data to clear all layers */
 
-	if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
+	if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
 		DBGINFO(("%s call tty_wait_until_sent\n", info->device_name));
-		tty_wait_until_sent(tty, info->closing_wait);
+		tty_wait_until_sent(tty, info->port.closing_wait);
 	}
 
  	if (info->port.flags & ASYNC_INITIALIZED)
@@ -774,8 +772,8 @@ static void close(struct tty_struct *tty, struct file *filp)
 	info->port.tty = NULL;
 
 	if (info->port.blocked_open) {
-		if (info->close_delay) {
-			msleep_interruptible(jiffies_to_msecs(info->close_delay));
+		if (info->port.close_delay) {
+			msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
 		}
 		wake_up_interruptible(&info->port.open_wait);
 	}
@@ -3448,13 +3446,13 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
 		DBGERR(("%s device alloc failed adapter=%d port=%d\n",
 			driver_name, adapter_num, port_num));
 	} else {
+		tty_port_init(&info->port);
 		info->magic = MGSL_MAGIC;
 		INIT_WORK(&info->task, bh_handler);
 		info->max_frame_size = 4096;
 		info->raw_rx_size = DMABUFSIZE;
-		info->close_delay = 5*HZ/10;
-		info->closing_wait = 30*HZ;
-		tty_port_init(&info->port);
+		info->port.close_delay = 5*HZ/10;
+		info->port.closing_wait = 30*HZ;
 		init_waitqueue_head(&info->status_event_wait_q);
 		init_waitqueue_head(&info->event_wait_q);
 		spin_lock_init(&info->netlock);
drivers/char/synclinkmp.c +7 -7
index 5952925..16fd2e6 100644
@@ -846,11 +846,11 @@ static void close(struct tty_struct *tty, struct file *filp)
 
 	/* wait for transmit data to clear all layers */
 
-	if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) {
+	if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) {
 		if (debug_level >= DEBUG_LEVEL_INFO)
 			printk("%s(%d):%s close() calling tty_wait_until_sent\n",
 				 __FILE__,__LINE__, info->device_name );
-		tty_wait_until_sent(tty, info->closing_wait);
+		tty_wait_until_sent(tty, info->port.closing_wait);
 	}
 
  	if (info->port.flags & ASYNC_INITIALIZED)
@@ -866,8 +866,8 @@ static void close(struct tty_struct *tty, struct file *filp)
 	info->port.tty = NULL;
 
 	if (info->port.blocked_open) {
-		if (info->close_delay) {
-			msleep_interruptible(jiffies_to_msecs(info->close_delay));
+		if (info->port.close_delay) {
+			msleep_interruptible(jiffies_to_msecs(info->port.close_delay));
 		}
 		wake_up_interruptible(&info->port.open_wait);
 	}
@@ -3802,12 +3802,12 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
 		printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
 			__FILE__,__LINE__, adapter_num, port_num);
 	} else {
+		tty_port_init(&info->port);
 		info->magic = MGSL_MAGIC;
 		INIT_WORK(&info->task, bh_handler);
 		info->max_frame_size = 4096;
-		info->close_delay = 5*HZ/10;
-		info->closing_wait = 30*HZ;
-		tty_port_init(&info->port);
+		info->port.close_delay = 5*HZ/10;
+		info->port.closing_wait = 30*HZ;
 		init_waitqueue_head(&info->status_event_wait_q);
 		init_waitqueue_head(&info->event_wait_q);
 		spin_lock_init(&info->netlock);
drivers/char/tty_io.c +2 -0
index 31ab8f0..401d5b2 100644
@@ -2010,6 +2010,8 @@ void tty_port_init(struct tty_port *port)
 	init_waitqueue_head(&port->open_wait);
 	init_waitqueue_head(&port->close_wait);
 	mutex_init(&port->mutex);
+	port->close_delay = (50 * HZ) / 100;
+	port->closing_wait = (3000 * HZ) / 100;
 }
 
 EXPORT_SYMBOL(tty_port_init);
include/linux/cyclades.h +2 -4
index a982b74..2d3d1e0 100644
@@ -567,8 +567,6 @@ struct cyclades_port {
 	int			chip_rev;
 	int			custom_divisor;
 	u8			x_char; /* to be pushed out ASAP */
-	int			close_delay;
-	unsigned short		closing_wait;
 	int                     breakon;
 	int                     breakoff;
 	int			xmit_head;
@@ -586,8 +584,8 @@ struct cyclades_port {
 };
 
 #define	CLOSING_WAIT_DELAY	30*HZ
-#define CY_CLOSING_WAIT_NONE	65535
-#define CY_CLOSING_WAIT_INF	0
+#define CY_CLOSING_WAIT_NONE	ASYNC_CLOSING_WAIT_NONE
+#define CY_CLOSING_WAIT_INF	ASYNC_CLOSING_WAIT_INF
 
 
 #define CyMAX_CHIPS_PER_CARD	8
include/linux/tty.h +2 -0
index a5dc3e9..a74b873 100644
@@ -188,6 +188,8 @@ struct tty_port
 	unsigned long		flags;		/* TTY flags ASY_*/
 	struct mutex		mutex;		/* Locking */
 	unsigned char		*xmit_buf;	/* Optional buffer */
+	int			close_delay;	/* Close port delay */
+	int			closing_wait;	/* Delay for output */
 };
 
 /*
author
#22 lore raw

PATCH 19/20 whiteheat: coding style

In reply to Alan Cox

From: Alan Cox <[email protected]>

Bring ezusb and whiteheat into line with the coding style
---

 drivers/usb/serial/ezusb.c     |   22 +-
 drivers/usb/serial/whiteheat.c |  390 ++++++++++++++++++++++------------------
 drivers/usb/serial/whiteheat.h |   78 +++++---
 3 files changed, 280 insertions(+), 210 deletions(-)
drivers/usb/serial/ezusb.c +12 -10
index cc4fbd9..711e84f 100644
@@ -20,7 +20,8 @@
 /* EZ-USB Control and Status Register.  Bit 0 controls 8051 reset */
 #define CPUCS_REG    0x7F92
 
-int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest)
+int ezusb_writememory(struct usb_serial *serial, int address,
+				unsigned char *data, int length, __u8 request)
 {
 	int result;
 	unsigned char *transfer_buffer;
@@ -33,26 +34,27 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
 
 	transfer_buffer = kmemdup(data, length, GFP_KERNEL);
 	if (!transfer_buffer) {
-		dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __func__, length);
+		dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
+							__func__, length);
 		return -ENOMEM;
 	}
-	result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
-	kfree (transfer_buffer);
+	result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+		     request, 0x40, address, 0, transfer_buffer, length, 3000);
+	kfree(transfer_buffer);
 	return result;
 }
+EXPORT_SYMBOL_GPL(ezusb_writememory);
 
-int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit)
+int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit)
 {
 	int response;
 
 	/* dbg("%s - %d", __func__, reset_bit); */
-	response = ezusb_writememory (serial, CPUCS_REG, &reset_bit, 1, 0xa0);
+	response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
 	if (response < 0)
-		dev_err(&serial->dev->dev, "%s- %d failed\n", __func__, reset_bit);
+		dev_err(&serial->dev->dev, "%s- %d failed\n",
+						__func__, reset_bit);
 	return response;
 }
-
-
-EXPORT_SYMBOL_GPL(ezusb_writememory);
 EXPORT_SYMBOL_GPL(ezusb_set_reset);
 
drivers/usb/serial/whiteheat.c +217 -173

831 lines not on this page · raw message

drivers/usb/serial/whiteheat.h +51 -27

143 lines not on this page · raw message

author
#23 lore raw

PATCH 20/20 whiteheat: fix bugs found in the tidy and audit

In reply to Alan Cox

From: Alan Cox <[email protected]>

Termios tidy up, plus fix break and DTR.
---

 drivers/usb/serial/whiteheat.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/usb/serial/whiteheat.c +4 -8
index 957ebda..58d4693 100644
@@ -651,11 +651,8 @@ static int whiteheat_open(struct tty_struct *tty,
 		goto exit;
 	}
 
-	if (tty) {
-		old_term.c_cflag = ~tty->termios->c_cflag;
-		old_term.c_iflag = ~tty->termios->c_iflag;
-		whiteheat_set_termios(tty, port, &old_term);
-	}
+	if (tty)
+		firm_setup_port(tty);
 
 	/* Work around HCD bugs */
 	usb_clear_halt(port->serial->dev, port->read_urb->pipe);
@@ -905,7 +902,6 @@ static int whiteheat_ioctl(struct tty_struct *tty, struct file * file, unsigned
 static void whiteheat_set_termios(struct tty_struct *tty,
 	struct usb_serial_port *port, struct ktermios *old_termios)
 {
-	/* FIXME */
 	firm_setup_port(tty);
 }
 
@@ -1298,7 +1294,7 @@ static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff)
 
 	dtr_command.port = port->number - port->serial->minor + 1;
 	dtr_command.state = onoff;
-	return firm_send_command(port, WHITEHEAT_SET_RTS,
+	return firm_send_command(port, WHITEHEAT_SET_DTR,
 			(__u8 *)&dtr_command, sizeof(dtr_command));
 }
 
@@ -1309,7 +1305,7 @@ static int firm_set_break(struct usb_serial_port *port, __u8 onoff)
 
 	break_command.port = port->number - port->serial->minor + 1;
 	break_command.state = onoff;
-	return firm_send_command(port, WHITEHEAT_SET_RTS,
+	return firm_send_command(port, WHITEHEAT_SET_BREAK,
 			(__u8 *)&break_command, sizeof(break_command));
 }
 
#24 lore raw
In reply to Alan Cox
Quoted 7 lines · Alan Cox

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

Very nice.

If you don't mind, I'll be glad to take this through my tree as you are touching the usb-serial drivers so much. Andrew, any objection to this?

Quoted 1 line
 MAINTAINERS                           |   72 +

Odd, I don't see you modifing this file in your patch series...

thanks,

greg k-h

author
#25 lore raw
Quoted 2 lines

If you don't mind, I'll be glad to take this through my tree as you are touching the usb-serial drivers so much. Andrew, any objection to this?

Seems sensible to me.

Quoted 3 lines
Quoted 1 line
 MAINTAINERS                           |   72 +

Odd, I don't see you modifing this file in your patch series...

stgit is being a bit flaky it seems.

Alan

#26 lore raw
In reply to Greg KH
Quoted 9 lines · On Mon, 19 May 2008 09:50:49 -0700 Greg KH <[email protected]> wrote:
Quoted 7 lines · Alan Cox

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

Quoted 4 lines

Very nice.

If you don't mind, I'll be glad to take this through my tree as you are touching the usb-serial drivers so much. Andrew, any objection to this?

A lot depends on what else Alan is brewing up. I only have a single tty-related patch at present (remove-is_tty.patch) and a handful of possibly-related char driver patches (proper-extern-for-mwave_s_mdd.patch, if-0-hpet_unregister.patch and riscom8-remove-redundant-null-pointer-test.patch).

But if a great mountain of tty- and/or char-related patches is forthcoming, that mountain will probably have a depencency upon your tree. And that's OK too, as long as you don't go and bugger up your tree and get it dropped from linux-next! Because if that happens I'll need to temporarily drop all the dependent patches and remember to restore them, which is always a bit sad.

#27 lore raw
Quoted 22 lines · Andrew Morton
Quoted 9 lines · On Mon, 19 May 2008 09:50:49 -0700 Greg KH <[email protected]> wrote:
Quoted 7 lines · Alan Cox

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

Quoted 4 lines

Very nice.

If you don't mind, I'll be glad to take this through my tree as you are touching the usb-serial drivers so much. Andrew, any objection to this?

A lot depends on what else Alan is brewing up. I only have a single tty-related patch at present (remove-is_tty.patch) and a handful of possibly-related char driver patches (proper-extern-for-mwave_s_mdd.patch, if-0-hpet_unregister.patch and riscom8-remove-redundant-null-pointer-test.patch).

Quoted 6 lines

But if a great mountain of tty- and/or char-related patches is forthcoming, that mountain will probably have a depencency upon your tree. And that's OK too, as long as you don't go and bugger up your tree and get it dropped from linux-next! Because if that happens I'll need to temporarily drop all the dependent patches and remember to restore them, which is always a bit sad.

That's up to Alan, I don't know what he has brewing for 2.6.27.

Alan?

thanks,

greg k-h

author
#28 lore raw
Quoted 8 lines
Quoted 6 lines

But if a great mountain of tty- and/or char-related patches is forthcoming, that mountain will probably have a depencency upon your tree. And that's OK too, as long as you don't go and bugger up your tree and get it dropped from linux-next! Because if that happens I'll need to temporarily drop all the dependent patches and remember to restore them, which is always a bit sad.

That's up to Alan, I don't know what he has brewing for 2.6.27.

I'm trying to work in sensible testable stages. Whats brewing at the moment is thoughts tty_get() and tty_put() but I don't have a bootable usable tree for that yet and there is work to be done.

#29 lore raw
In reply to Alan Cox

Alan,

Quoted 7 lines

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

do you have your tty/serial rework tree available in some server?

Signature · 1 line
Aristeu
author
#30 lore raw
Quoted 9 lines · On Mon, 19 May 2008 18:39:43 -0400 Aristeu Rozanski <[email protected]> wrote:

Alan,

Quoted 7 lines

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

do you have your tty/serial rework tree available in some server?

Not currently. Its on my todo list to sort that out hence testign stuff like stgit at the moment.

Alan

#31 lore raw
In reply to Alan Cox
Quoted 7 lines · Alan Cox

Right now each tty has its own port level structure which means we can share no code between ports. Introduce a structure and some initial minor helper routines so that we can move towards commonality. In doing this the USB serial code gets a bit of shake up as it kept using port->tty unsafely. Fixing that means changing the API of all the USB serial drivers. On the bright side the API now looks far more like the tty layer API which will become useful later on.

On all of these patches, you did not add a "Signed-off-by:". Was that on purpose and you do not want these patches applied, or unintentional?

thanks,

greg k-h