Linux Serial subsystem development
 help / color / mirror / Atom feed
* Re: [PATCH 1/9] tty: make receive_buf() return the amout of bytes received
From: Alan Cox @ 2012-03-05 10:40 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: linux-serial, Felipe Balbi, Toby Gray, Stefan Bigler
In-Reply-To: <1330883960-8563-2-git-send-email-castet.matthieu@free.fr>

> For a first step, will always return that we received everything.
> This make sure to we don't break anything when we will check receive_buf
> return value.


What about recursive calls ? We have some of those due to bugs elsewhere
in the code - eg selection.c. I don't wish to throw spanners in the works
of this effort but you can't actually make it work until you fix

selection.c
tty_io.c: tiocsti
n_tty: n_tty_set_room

The first two are unsafe recursive calls, the third one is totally broken
on any port with low latency set and can result in all kinds of
interesting failure cases.

Basically you've got to actually address the fact that code is calling
the ldisc methods wrongly, in parallel, without locking, and in an unsafe
fashion that in some cases can arbitarily recurse.

Until that is done you are never going to be able to debug the changes
because it'll crash anyway if you poke it the right way.

Alan

^ permalink raw reply

* [PATCH 00/68] TTY buffer in tty_port -- prep no. 1
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby

Hi,
								      
this is the first series of patches which allow tty buffers to be
moved from tty_struct (present from open to close/hangup) to tty_port
(present as long as the device). This will allow us to get rid of the
tty refcounting in the interrupt service routines and other hot paths
after we are done. This is because we won't need to handle races among
ISRs, timers, hangups and others, because tty_port lives as long as an
interrupt/timer tick may occur. Unlike tty_struct.

In this series, only first few drivers are converted to use
tty_port. The rest is to come later.

The first few patches are simple fixes/cleanups which emerged during
the code investigation here and there. Further serialP header removal
happens there. Finally, some drivers are forced to use tty_port, which
will become a necessity in the future.

Simserial (ia64) and standard x86 stuff were runtime-tested. The rest
is only checked to be compilation-errors free.

Final remark: simserial stuff depends on 4 patches sent to Tony Luck
last week. They are in hist tree and -next already.

Jiri Slaby (68):
  USB: cdc-acm, use tty_standard_install
  TTY: tty_io, remove buffer re-assignments
  TTY: let alloc_tty_driver deduce the owner automatically
  TTY: remove minor_num from tty_driver
  TTY: remove re-assignments to tty_driver members
  TTY: simplify tty_driver_lookup_tty a bit
  TTY: remove tty driver re-set from tty_reopen
  TTY: serial, simplify ASYNC_USR_MASK
  TTY: tty_driver, document tty->ops->shutdown limitation
  ALPHA: srmcons, use timer functions
  ALPHA: srmcons, fix racy singleton structure
  TTY: srmcons, convert to use tty_port
  TTY: serialP, remove DECLARE_WAITQUEUE check
  TTY: remove unneeded tty->index checks
  TTY: ipwireless, fix tty->index handling
  NET: pc300, do not zero global variables
  NET: pc300, show version info from module init
  XTENSA: iss/console, use setup_timer
  XTENSA: iss/console, fix potential deadlock
  TTY: iss/console, use tty_port
  TTY: serial, use atomic_inc_return in ioc4_serial
  TTY: serial, include pci.h in m32r_sio
  TTY: remove serialP.h inclusion from some files
  TTY: speakup, do not use serialP
  TTY: serialP, remove unused material
  TTY: amiserial, remove tasklet for tty_wakeup
  TTY: amiserial, use only one copy of async flags
  TTY: simserial, use only one copy of async flags
  TTY: simserial/amiserial, use one instance of other members
  TTY: simserial, remove support of shared interrupts
  TTY: simserial, remove IRQ_T
  TTY: amiserial, remove IRQ_ports
  TTY: serialP, merge serial_state and async_struct
  TTY: amiserial, simplify set_serial_info
  TTY: amiserial, pass tty down to functions
  TTY: simserial, pass tty down to functions
  TTY: amiserial/simserial, use tty_port
  TTY: amiserial/simserial, use close delays from tty_port
  TTY: amiserial/simserial, use count from tty_port
  TTY: amiserial/simserial, use flags from tty_port
  TTY: simserial, remove static initialization
  TTY: simserial, remove tmp_buf
  TTY: simserial, stop using serial_state->{line,icount}
  TTY: simserial no longer needs serialP
  TTY: simserial, define local tty_port pointer
  TTY: simserial, remove some tty ops
  TTY: simserial, use tty_port_close_end
  TTY: simserial, use tty_port_close_start
  TTY: simserial, properly refcount tty_port->tty
  TTY: simserial, use tty_port_open
  TTY: simserial, use tty_port_hangup
  TTY: simserial, remove useless comments
  TTY: simserial, fix includes
  TTY: simserial, reindent some code
  TTY: simserial, final cleanup
  TTY: amiserial, define local tty_port pointer
  TTY: amiserial, stop using serial_state->{irq,type,line}
  TTY: amiserial no longer needs serialP
  TTY: amiserial, provide carrier helpers
  TTY: amiserial, use tty_port_block_til_ready
  TTY: amiserial, use tty_port_close_end
  TTY: amiserial, use tty_port_close_start
  TTY: pdc_cons, fix racy tty test
  TTY: pdc_cons, fix open vs timer race
  TTY: pdc_cons, fix open vs pdc_console_tty_driver race
  TTY: pdc_cons, use tty_port
  TTY: isdn/gigaset, do not set tty->driver_data to NULL
  TTY: isdn/gigaset, use tty_port

 arch/alpha/kernel/srmcons.c         |   78 ++--
 arch/ia64/hp/sim/simserial.c        |  687 +++++++-------------------------
 arch/m68k/emu/nfcon.c               |    1 -
 arch/parisc/kernel/pdc_cons.c       |   59 ++-
 arch/xtensa/platforms/iss/console.c |   22 +-
 drivers/char/pcmcia/synclink_cs.c   |    3 +-
 drivers/char/ttyprintk.c            |    2 -
 drivers/isdn/capi/capi.c            |    4 +-
 drivers/isdn/gigaset/common.c       |    5 +-
 drivers/isdn/gigaset/gigaset.h      |    3 +-
 drivers/isdn/gigaset/interface.c    |  158 ++------
 drivers/isdn/i4l/isdn_tty.c         |    7 +-
 drivers/misc/pti.c                  |    6 +-
 drivers/mmc/card/sdio_uart.c        |    1 -
 drivers/net/usb/hso.c               |    2 -
 drivers/net/wan/pc300_drv.c         |   13 +-
 drivers/net/wan/pc300_tty.c         |   18 -
 drivers/s390/char/con3215.c         |    9 +-
 drivers/s390/char/sclp_tty.c        |    1 -
 drivers/s390/char/sclp_vt220.c      |    1 -
 drivers/s390/char/tty3270.c         |    1 -
 drivers/staging/speakup/serialio.c  |   11 +-
 drivers/staging/speakup/serialio.h  |   13 +-
 drivers/staging/speakup/spk_priv.h  |    2 +-
 drivers/staging/speakup/synth.c     |    2 +-
 drivers/tty/amiserial.c             |  730 +++++++++++------------------------
 drivers/tty/bfin_jtag_comm.c        |    1 -
 drivers/tty/cyclades.c              |    7 +-
 drivers/tty/ehv_bytechan.c          |    1 -
 drivers/tty/hvc/hvc_console.c       |    1 -
 drivers/tty/hvc/hvcs.c              |   26 +-
 drivers/tty/hvc/hvsi.c              |    6 +-
 drivers/tty/ipwireless/tty.c        |   37 +-
 drivers/tty/isicom.c                |    3 -
 drivers/tty/moxa.c                  |    1 -
 drivers/tty/mxser.c                 |    5 -
 drivers/tty/n_gsm.c                 |    1 -
 drivers/tty/nozomi.c                |    1 -
 drivers/tty/pty.c                   |    4 -
 drivers/tty/rocket.c                |    7 +-
 drivers/tty/serial/68328serial.c    |    9 +-
 drivers/tty/serial/crisv10.c        |   15 +-
 drivers/tty/serial/ifx6x60.c        |    3 -
 drivers/tty/serial/ioc4_serial.c    |    3 +-
 drivers/tty/serial/m32r_sio.c       |    1 -
 drivers/tty/serial/m32r_sio.h       |    1 +
 drivers/tty/serial/msm_smd_tty.c    |    1 -
 drivers/tty/serial/serial_core.c    |    1 -
 drivers/tty/synclink.c              |    3 +-
 drivers/tty/synclink_gt.c           |    3 +-
 drivers/tty/synclinkmp.c            |    3 +-
 drivers/tty/tty_io.c                |   12 +-
 drivers/tty/vt/vt.c                 |    2 +-
 drivers/usb/class/cdc-acm.c         |    8 +-
 drivers/usb/gadget/u_serial.c       |    4 -
 drivers/usb/serial/usb-serial.c     |    1 -
 include/linux/serial.h              |    4 +-
 include/linux/serialP.h             |  142 -------
 include/linux/tty_driver.h          |    8 +-
 net/bluetooth/rfcomm/tty.c          |    1 -
 net/irda/ircomm/ircomm_tty.c        |    7 +-
 61 files changed, 542 insertions(+), 1630 deletions(-)
 delete mode 100644 include/linux/serialP.h

-- 
1.7.9.2

^ permalink raw reply

* [PATCH 04/68] TTY: remove minor_num from tty_driver
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

It was added back in 2004 and never used for anything real. Remove the
only assignment in the tree as well.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/misc/pti.c         |    1 -
 include/linux/tty_driver.h |    1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 471ff4c..9a35db3 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -920,7 +920,6 @@ static int __init pti_init(void)
 	pti_tty_driver->name			= TTYNAME;
 	pti_tty_driver->major			= 0;
 	pti_tty_driver->minor_start		= PTITTY_MINOR_START;
-	pti_tty_driver->minor_num		= PTITTY_MINOR_NUM;
 	pti_tty_driver->num			= PTITTY_MINOR_NUM;
 	pti_tty_driver->type			= TTY_DRIVER_TYPE_SYSTEM;
 	pti_tty_driver->subtype			= SYSTEM_TYPE_SYSCONS;
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 6e65493..e064f17 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -299,7 +299,6 @@ struct tty_driver {
 	int	name_base;	/* offset of printed name */
 	int	major;		/* major device number */
 	int	minor_start;	/* start of minor device number */
-	int	minor_num;	/* number of *possible* devices */
 	int	num;		/* number of devices allocated */
 	short	type;		/* type of tty driver */
 	short	subtype;	/* subtype of tty driver */
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 05/68] TTY: remove re-assignments to tty_driver members
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

All num, magic and owner are set by alloc_tty_driver. No need to
re-set them on each allocation site.

pti driver sets something different to what it passes to
alloc_tty_driver. It is not a bug, since we don't use the lines
parameter in any way. Anyway this is fixed, and now we do the right
thing.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/ia64/hp/sim/simserial.c        |    1 -
 arch/m68k/emu/nfcon.c               |    1 -
 arch/xtensa/platforms/iss/console.c |    1 -
 drivers/char/pcmcia/synclink_cs.c   |    1 -
 drivers/char/ttyprintk.c            |    2 --
 drivers/isdn/capi/capi.c            |    1 -
 drivers/isdn/gigaset/interface.c    |    7 +------
 drivers/misc/pti.c                  |    5 +----
 drivers/mmc/card/sdio_uart.c        |    1 -
 drivers/net/usb/hso.c               |    2 --
 drivers/s390/char/con3215.c         |    1 -
 drivers/s390/char/sclp_tty.c        |    1 -
 drivers/s390/char/sclp_vt220.c      |    1 -
 drivers/s390/char/tty3270.c         |    1 -
 drivers/tty/amiserial.c             |    1 -
 drivers/tty/bfin_jtag_comm.c        |    1 -
 drivers/tty/cyclades.c              |    1 -
 drivers/tty/ehv_bytechan.c          |    1 -
 drivers/tty/hvc/hvc_console.c       |    1 -
 drivers/tty/hvc/hvcs.c              |    2 --
 drivers/tty/hvc/hvsi.c              |    1 -
 drivers/tty/ipwireless/tty.c        |    1 -
 drivers/tty/isicom.c                |    1 -
 drivers/tty/moxa.c                  |    1 -
 drivers/tty/mxser.c                 |    3 ---
 drivers/tty/n_gsm.c                 |    1 -
 drivers/tty/nozomi.c                |    1 -
 drivers/tty/pty.c                   |    4 ----
 drivers/tty/rocket.c                |    1 -
 drivers/tty/serial/ifx6x60.c        |    3 ---
 drivers/tty/serial/msm_smd_tty.c    |    1 -
 drivers/tty/serial/serial_core.c    |    1 -
 drivers/tty/synclink.c              |    1 -
 drivers/tty/synclink_gt.c           |    1 -
 drivers/tty/synclinkmp.c            |    1 -
 drivers/tty/vt/vt.c                 |    2 +-
 drivers/usb/class/cdc-acm.c         |    1 -
 drivers/usb/gadget/u_serial.c       |    1 -
 drivers/usb/serial/usb-serial.c     |    1 -
 net/bluetooth/rfcomm/tty.c          |    1 -
 net/irda/ircomm/ircomm_tty.c        |    1 -
 41 files changed, 3 insertions(+), 59 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 60c9093..9c9c634 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -919,7 +919,6 @@ simrs_init (void)
 
 	/* Initialize the tty_driver structure */
 
-	hp_simserial_driver->owner = THIS_MODULE;
 	hp_simserial_driver->driver_name = "simserial";
 	hp_simserial_driver->name = "ttyS";
 	hp_simserial_driver->major = TTY_MAJOR;
diff --git a/arch/m68k/emu/nfcon.c b/arch/m68k/emu/nfcon.c
index ab20dc0..8db25e8 100644
--- a/arch/m68k/emu/nfcon.c
+++ b/arch/m68k/emu/nfcon.c
@@ -127,7 +127,6 @@ static int __init nfcon_init(void)
 	if (!nfcon_tty_driver)
 		return -ENOMEM;
 
-	nfcon_tty_driver->owner = THIS_MODULE;
 	nfcon_tty_driver->driver_name = "nfcon";
 	nfcon_tty_driver->name = "nfcon";
 	nfcon_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 2c723e8..247e9d4 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -216,7 +216,6 @@ int __init rs_init(void)
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->owner = THIS_MODULE;
 	serial_driver->driver_name = "iss_serial";
 	serial_driver->name = "ttyS";
 	serial_driver->major = TTY_MAJOR;
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 07f6a5a..c3bcb12 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2836,7 +2836,6 @@ static int __init synclink_cs_init(void)
 
     /* Initialize the tty_driver structure */
 
-    serial_driver->owner = THIS_MODULE;
     serial_driver->driver_name = "synclink_cs";
     serial_driver->name = "ttySLP";
     serial_driver->major = ttymajor;
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index eedd547..46b77ed 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -184,12 +184,10 @@ static int __init ttyprintk_init(void)
 	if (!ttyprintk_driver)
 		return ret;
 
-	ttyprintk_driver->owner = THIS_MODULE;
 	ttyprintk_driver->driver_name = "ttyprintk";
 	ttyprintk_driver->name = "ttyprintk";
 	ttyprintk_driver->major = TTYAUX_MAJOR;
 	ttyprintk_driver->minor_start = 3;
-	ttyprintk_driver->num = 1;
 	ttyprintk_driver->type = TTY_DRIVER_TYPE_CONSOLE;
 	ttyprintk_driver->init_termios = tty_std_termios;
 	ttyprintk_driver->init_termios.c_oflag = OPOST | OCRNL | ONOCR | ONLRET;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 0d47ebc..41a5644 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1287,7 +1287,6 @@ static int __init capinc_tty_init(void)
 		kfree(capiminors);
 		return -ENOMEM;
 	}
-	drv->owner = THIS_MODULE;
 	drv->driver_name = "capi_nc";
 	drv->name = "capi";
 	drv->major = 0;
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index b826dac..7e54577 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -669,17 +669,15 @@ EXPORT_SYMBOL_GPL(gigaset_if_receive);
 void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
 			   const char *devname)
 {
-	unsigned minors = drv->minors;
 	int ret;
 	struct tty_driver *tty;
 
 	drv->have_tty = 0;
 
-	drv->tty = tty = alloc_tty_driver(minors);
+	drv->tty = tty = alloc_tty_driver(drv->minors);
 	if (tty == NULL)
 		goto enomem;
 
-	tty->magic =		TTY_DRIVER_MAGIC;
 	tty->type =		TTY_DRIVER_TYPE_SERIAL;
 	tty->subtype =		SERIAL_TYPE_NORMAL;
 	tty->flags =		TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
@@ -687,9 +685,6 @@ void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
 	tty->driver_name =	procname;
 	tty->name =		devname;
 	tty->minor_start =	drv->minor;
-	tty->num =		drv->minors;
-
-	tty->owner =		THIS_MODULE;
 
 	tty->init_termios          = tty_std_termios;
 	tty->init_termios.c_cflag  = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c
index 9a35db3..383133b 100644
--- a/drivers/misc/pti.c
+++ b/drivers/misc/pti.c
@@ -907,20 +907,17 @@ static int __init pti_init(void)
 
 	/* First register module as tty device */
 
-	pti_tty_driver = alloc_tty_driver(1);
+	pti_tty_driver = alloc_tty_driver(PTITTY_MINOR_NUM);
 	if (pti_tty_driver == NULL) {
 		pr_err("%s(%d): Memory allocation failed for ptiTTY driver\n",
 			__func__, __LINE__);
 		return -ENOMEM;
 	}
 
-	pti_tty_driver->owner			= THIS_MODULE;
-	pti_tty_driver->magic			= TTY_DRIVER_MAGIC;
 	pti_tty_driver->driver_name		= DRIVERNAME;
 	pti_tty_driver->name			= TTYNAME;
 	pti_tty_driver->major			= 0;
 	pti_tty_driver->minor_start		= PTITTY_MINOR_START;
-	pti_tty_driver->num			= PTITTY_MINOR_NUM;
 	pti_tty_driver->type			= TTY_DRIVER_TYPE_SYSTEM;
 	pti_tty_driver->subtype			= SYSTEM_TYPE_SYSCONS;
 	pti_tty_driver->flags			= TTY_DRIVER_REAL_RAW |
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c
index bd4a67c..5a2cbfa 100644
--- a/drivers/mmc/card/sdio_uart.c
+++ b/drivers/mmc/card/sdio_uart.c
@@ -1175,7 +1175,6 @@ static int __init sdio_uart_init(void)
 	if (!tty_drv)
 		return -ENOMEM;
 
-	tty_drv->owner = THIS_MODULE;
 	tty_drv->driver_name = "sdio_uart";
 	tty_drv->name =   "ttySDIO";
 	tty_drv->major = 0;  /* dynamically allocated */
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index e1324b4..2d2a688 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -3313,7 +3313,6 @@ static int __init hso_init(void)
 
 	/* fill in all needed values */
 	tty_drv->magic = TTY_DRIVER_MAGIC;
-	tty_drv->owner = THIS_MODULE;
 	tty_drv->driver_name = driver_name;
 	tty_drv->name = tty_filename;
 
@@ -3322,7 +3321,6 @@ static int __init hso_init(void)
 		tty_drv->major = tty_major;
 
 	tty_drv->minor_start = 0;
-	tty_drv->num = HSO_SERIAL_TTY_MINORS;
 	tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
 	tty_drv->subtype = SERIAL_TYPE_NORMAL;
 	tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index e71a50d..176e07c 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -1145,7 +1145,6 @@ static int __init tty3215_init(void)
 	 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
 	 */
 
-	driver->owner = THIS_MODULE;
 	driver->driver_name = "tty3215";
 	driver->name = "ttyS";
 	driver->major = TTY_MAJOR;
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index a879c13..40a9d69 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -551,7 +551,6 @@ sclp_tty_init(void)
 		return rc;
 	}
 
-	driver->owner = THIS_MODULE;
 	driver->driver_name = "sclp_line";
 	driver->name = "sclp_line";
 	driver->major = TTY_MAJOR;
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index 5d706e6..b635472 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -685,7 +685,6 @@ static int __init sclp_vt220_tty_init(void)
 	if (rc)
 		goto out_driver;
 
-	driver->owner = THIS_MODULE;
 	driver->driver_name = SCLP_VT220_DRIVER_NAME;
 	driver->name = SCLP_VT220_DEVICE_NAME;
 	driver->major = SCLP_VT220_MAJOR;
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 2db1482..b43445a 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -1784,7 +1784,6 @@ static int __init tty3270_init(void)
 	 * Entries in tty3270_driver that are NOT initialized:
 	 * proc_entry, set_termios, flush_buffer, set_ldisc, write_proc
 	 */
-	driver->owner = THIS_MODULE;
 	driver->driver_name = "ttyTUB";
 	driver->name = "ttyTUB";
 	driver->major = IBM_TTY3270_MAJOR;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index b84c834..b42f00d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1974,7 +1974,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->owner = THIS_MODULE;
 	serial_driver->driver_name = "amiserial";
 	serial_driver->name = "ttyS";
 	serial_driver->major = TTY_MAJOR;
diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c
index 3a99776..946f799 100644
--- a/drivers/tty/bfin_jtag_comm.c
+++ b/drivers/tty/bfin_jtag_comm.c
@@ -257,7 +257,6 @@ static int __init bfin_jc_init(void)
 	if (!bfin_jc_driver)
 		goto err_driver;
 
-	bfin_jc_driver->owner        = THIS_MODULE;
 	bfin_jc_driver->driver_name  = DRV_NAME;
 	bfin_jc_driver->name         = DEV_NAME;
 	bfin_jc_driver->type         = TTY_DRIVER_TYPE_SERIAL;
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index c9bf779..98a1b8b 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -4090,7 +4090,6 @@ static int __init cy_init(void)
 
 	/* Initialize the tty_driver structure */
 
-	cy_serial_driver->owner = THIS_MODULE;
 	cy_serial_driver->driver_name = "cyclades";
 	cy_serial_driver->name = "ttyC";
 	cy_serial_driver->major = CYCLADES_MAJOR;
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index 1595dba..4813684 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -825,7 +825,6 @@ static int __init ehv_bc_init(void)
 		goto error;
 	}
 
-	ehv_bc_driver->owner = THIS_MODULE;
 	ehv_bc_driver->driver_name = "ehv-bc";
 	ehv_bc_driver->name = ehv_bc_console.name;
 	ehv_bc_driver->type = TTY_DRIVER_TYPE_CONSOLE;
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index b6b2d18..8880adf 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -917,7 +917,6 @@ static int hvc_init(void)
 		goto out;
 	}
 
-	drv->owner = THIS_MODULE;
 	drv->driver_name = "hvc";
 	drv->name = "hvc";
 	drv->major = HVC_MAJOR;
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index df7e7a0..da0aa47 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1499,8 +1499,6 @@ static int __devinit hvcs_initialize(void)
 		goto index_fail;
 	}
 
-	hvcs_tty_driver->owner = THIS_MODULE;
-
 	hvcs_tty_driver->driver_name = hvcs_driver_name;
 	hvcs_tty_driver->name = hvcs_device_node;
 
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 1b5f28b..60bc451 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -1088,7 +1088,6 @@ static int __init hvsi_init(void)
 	if (!hvsi_driver)
 		return -ENOMEM;
 
-	hvsi_driver->owner = THIS_MODULE;
 	hvsi_driver->driver_name = "hvsi";
 	hvsi_driver->name = "hvsi";
 	hvsi_driver->major = HVSI_MAJOR;
diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index ef92869..6990b3b 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -614,7 +614,6 @@ int ipwireless_tty_init(void)
 	if (!ipw_tty_driver)
 		return -ENOMEM;
 
-	ipw_tty_driver->owner = THIS_MODULE;
 	ipw_tty_driver->driver_name = IPWIRELESS_PCCARD_NAME;
 	ipw_tty_driver->name = "ttyIPWp";
 	ipw_tty_driver->major = 0;
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index e5c295a..b3a28b5 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -1678,7 +1678,6 @@ static int __init isicom_init(void)
 		goto error;
 	}
 
-	isicom_normal->owner			= THIS_MODULE;
 	isicom_normal->name 			= "ttyM";
 	isicom_normal->major			= ISICOM_NMAJOR;
 	isicom_normal->minor_start		= 0;
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index d15a071..4a26323 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -1036,7 +1036,6 @@ static int __init moxa_init(void)
 	if (!moxaDriver)
 		return -ENOMEM;
 
-	moxaDriver->owner = THIS_MODULE;
 	moxaDriver->name = "ttyMX";
 	moxaDriver->major = ttymajor;
 	moxaDriver->minor_start = 0;
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 8998d52..260d031 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -2658,12 +2658,9 @@ static int __init mxser_module_init(void)
 		MXSER_VERSION);
 
 	/* Initialize the tty_driver structure */
-	mxvar_sdriver->owner = THIS_MODULE;
-	mxvar_sdriver->magic = TTY_DRIVER_MAGIC;
 	mxvar_sdriver->name = "ttyMI";
 	mxvar_sdriver->major = ttymajor;
 	mxvar_sdriver->minor_start = 0;
-	mxvar_sdriver->num = MXSER_PORTS + 1;
 	mxvar_sdriver->type = TTY_DRIVER_TYPE_SERIAL;
 	mxvar_sdriver->subtype = SERIAL_TYPE_NORMAL;
 	mxvar_sdriver->init_termios = tty_std_termios;
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index fc7bbba..c43b683 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -3120,7 +3120,6 @@ static int __init gsm_init(void)
 		pr_err("gsm_init: tty allocation failed.\n");
 		return -EINVAL;
 	}
-	gsm_tty_driver->owner	= THIS_MODULE;
 	gsm_tty_driver->driver_name	= "gsmtty";
 	gsm_tty_driver->name		= "gsmtty";
 	gsm_tty_driver->major		= 0;	/* Dynamic */
diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index 580da78..e7592f9 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -1916,7 +1916,6 @@ static __init int nozomi_init(void)
 	if (!ntty_driver)
 		return -ENOMEM;
 
-	ntty_driver->owner = THIS_MODULE;
 	ntty_driver->driver_name = NOZOMI_NAME_TTY;
 	ntty_driver->name = "noz";
 	ntty_driver->major = 0;
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index d505837..f96ecae 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -393,7 +393,6 @@ static void __init legacy_pty_init(void)
 	if (!pty_slave_driver)
 		panic("Couldn't allocate pty slave driver");
 
-	pty_driver->owner = THIS_MODULE;
 	pty_driver->driver_name = "pty_master";
 	pty_driver->name = "pty";
 	pty_driver->major = PTY_MASTER_MAJOR;
@@ -411,7 +410,6 @@ static void __init legacy_pty_init(void)
 	pty_driver->other = pty_slave_driver;
 	tty_set_operations(pty_driver, &master_pty_ops_bsd);
 
-	pty_slave_driver->owner = THIS_MODULE;
 	pty_slave_driver->driver_name = "pty_slave";
 	pty_slave_driver->name = "ttyp";
 	pty_slave_driver->major = PTY_SLAVE_MAJOR;
@@ -671,7 +669,6 @@ static void __init unix98_pty_init(void)
 	if (!pts_driver)
 		panic("Couldn't allocate Unix98 pts driver");
 
-	ptm_driver->owner = THIS_MODULE;
 	ptm_driver->driver_name = "pty_master";
 	ptm_driver->name = "ptm";
 	ptm_driver->major = UNIX98_PTY_MASTER_MAJOR;
@@ -690,7 +687,6 @@ static void __init unix98_pty_init(void)
 	ptm_driver->other = pts_driver;
 	tty_set_operations(ptm_driver, &ptm_unix98_ops);
 
-	pts_driver->owner = THIS_MODULE;
 	pts_driver->driver_name = "pty_slave";
 	pts_driver->name = "pts";
 	pts_driver->major = UNIX98_PTY_SLAVE_MAJOR;
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index de88aa5..b088e1e 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -2277,7 +2277,6 @@ static int __init rp_init(void)
 	 * driver with the tty layer.
 	 */
 
-	rocket_driver->owner = THIS_MODULE;
 	rocket_driver->flags = TTY_DRIVER_DYNAMIC_DEV;
 	rocket_driver->name = "ttyR";
 	rocket_driver->driver_name = "Comtrol RocketPort";
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 7e925e2..144cd39 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -1375,12 +1375,9 @@ static int __init ifx_spi_init(void)
 		return -ENOMEM;
 	}
 
-	tty_drv->magic = TTY_DRIVER_MAGIC;
-	tty_drv->owner = THIS_MODULE;
 	tty_drv->driver_name = DRVNAME;
 	tty_drv->name = TTYNAME;
 	tty_drv->minor_start = IFX_SPI_TTY_ID;
-	tty_drv->num = 1;
 	tty_drv->type = TTY_DRIVER_TYPE_SERIAL;
 	tty_drv->subtype = SERIAL_TYPE_NORMAL;
 	tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
diff --git a/drivers/tty/serial/msm_smd_tty.c b/drivers/tty/serial/msm_smd_tty.c
index 4f41dcd..b25e6ee 100644
--- a/drivers/tty/serial/msm_smd_tty.c
+++ b/drivers/tty/serial/msm_smd_tty.c
@@ -203,7 +203,6 @@ static int __init smd_tty_init(void)
 	if (smd_tty_driver == 0)
 		return -ENOMEM;
 
-	smd_tty_driver->owner = THIS_MODULE;
 	smd_tty_driver->driver_name = "smd_tty_driver";
 	smd_tty_driver->name = "smd";
 	smd_tty_driver->major = 0;
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c8ad546..ccfbc2a2 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2196,7 +2196,6 @@ int uart_register_driver(struct uart_driver *drv)
 
 	drv->tty_driver = normal;
 
-	normal->owner		= drv->owner;
 	normal->driver_name	= drv->driver_name;
 	normal->name		= drv->dev_name;
 	normal->major		= drv->major;
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index ff8017f..2b2988c 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -4333,7 +4333,6 @@ static int mgsl_init_tty(void)
 	if (!serial_driver)
 		return -ENOMEM;
 	
-	serial_driver->owner = THIS_MODULE;
 	serial_driver->driver_name = "synclink";
 	serial_driver->name = "ttySL";
 	serial_driver->major = ttymajor;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 01a1ff4..32f8eda 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -3795,7 +3795,6 @@ static int __init slgt_init(void)
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->owner = THIS_MODULE;
 	serial_driver->driver_name = tty_driver_name;
 	serial_driver->name = tty_dev_prefix;
 	serial_driver->major = ttymajor;
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index a7efe53..ddabb61 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -3977,7 +3977,6 @@ static int __init synclinkmp_init(void)
 
 	/* Initialize the tty_driver structure */
 
-	serial_driver->owner = THIS_MODULE;
 	serial_driver->driver_name = "synclinkmp";
 	serial_driver->name = "ttySLM";
 	serial_driver->major = ttymajor;
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index e716839..1caec8b 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -2991,7 +2991,7 @@ int __init vty_init(const struct file_operations *console_fops)
 	console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
 	if (!console_driver)
 		panic("Couldn't allocate console driver\n");
-	console_driver->owner = THIS_MODULE;
+
 	console_driver->name = "tty";
 	console_driver->name_base = 1;
 	console_driver->major = TTY_MAJOR;
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index b3fd449..b32ccb4 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1698,7 +1698,6 @@ static int __init acm_init(void)
 	acm_tty_driver = alloc_tty_driver(ACM_TTY_MINORS);
 	if (!acm_tty_driver)
 		return -ENOMEM;
-	acm_tty_driver->owner = THIS_MODULE,
 	acm_tty_driver->driver_name = "acm",
 	acm_tty_driver->name = "ttyACM",
 	acm_tty_driver->major = ACM_TTY_MAJOR,
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 6597a68..490b01d 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -1087,7 +1087,6 @@ int __init gserial_setup(struct usb_gadget *g, unsigned count)
 	if (!gs_tty_driver)
 		return -ENOMEM;
 
-	gs_tty_driver->owner = THIS_MODULE;
 	gs_tty_driver->driver_name = "g_serial";
 	gs_tty_driver->name = PREFIX;
 	/* uses dynamically assigned dev_t values */
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a9c5e67..69230f0 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -1235,7 +1235,6 @@ static int __init usb_serial_init(void)
 		goto exit_bus;
 	}
 
-	usb_serial_tty_driver->owner = THIS_MODULE;
 	usb_serial_tty_driver->driver_name = "usbserial";
 	usb_serial_tty_driver->name = "ttyUSB";
 	usb_serial_tty_driver->major = SERIAL_TTY_MAJOR;
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index a2d4f51..7adb03c 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -1157,7 +1157,6 @@ int __init rfcomm_init_ttys(void)
 	if (!rfcomm_tty_driver)
 		return -ENOMEM;
 
-	rfcomm_tty_driver->owner	= THIS_MODULE;
 	rfcomm_tty_driver->driver_name	= "rfcomm";
 	rfcomm_tty_driver->name		= "rfcomm";
 	rfcomm_tty_driver->major	= RFCOMM_TTY_MAJOR;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 253695d..828f886 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -122,7 +122,6 @@ static int __init ircomm_tty_init(void)
 		return -ENOMEM;
 	}
 
-	driver->owner		= THIS_MODULE;
 	driver->driver_name     = "ircomm";
 	driver->name            = "ircomm";
 	driver->major           = IRCOMM_TTY_MAJOR;
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 06/68] TTY: simplify tty_driver_lookup_tty a bit
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

Remove the useless local variable and return the value itself.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/tty_io.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index bd95cea..d0d3d1f 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1230,13 +1230,10 @@ static void tty_line_name(struct tty_driver *driver, int index, char *p)
 static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
 		struct inode *inode, int idx)
 {
-	struct tty_struct *tty;
-
 	if (driver->ops->lookup)
 		return driver->ops->lookup(driver, inode, idx);
 
-	tty = driver->ttys[idx];
-	return tty;
+	return driver->ttys[idx];
 }
 
 /**
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 07/68] TTY: remove tty driver re-set from tty_reopen
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

This is from tty_reopen:
    struct tty_driver *driver = tty->driver;
    ...
    tty->driver = driver;
and it doesn't make sense at all. The driver is intended to be set in
initialize_tty_struct from tty_init_dev (initial open). So this set in
tty_reopen is not needed.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/tty_io.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index d0d3d1f..dd8a938 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1348,7 +1348,6 @@ static int tty_reopen(struct tty_struct *tty)
 		tty->link->count++;
 	}
 	tty->count++;
-	tty->driver = driver; /* N.B. why do this every time?? */
 
 	mutex_lock(&tty->ldisc_mutex);
 	WARN_ON(!test_bit(TTY_LDISC, &tty->flags));
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 08/68] TTY: serial, simplify ASYNC_USR_MASK
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

By using ASYNC_SPD_MASK instead of the single speed bits.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/serial.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/serial.h b/include/linux/serial.h
index 3d86517..441980e 100644
--- a/include/linux/serial.h
+++ b/include/linux/serial.h
@@ -152,8 +152,8 @@ struct serial_uart_config {
 #define ASYNC_AUTOPROBE		(1U << ASYNCB_AUTOPROBE)
 
 #define ASYNC_FLAGS		((1U << (ASYNCB_LAST_USER + 1)) - 1)
-#define ASYNC_USR_MASK		(ASYNC_SPD_HI|ASYNC_SPD_VHI| \
-		ASYNC_CALLOUT_NOHUP|ASYNC_SPD_SHI|ASYNC_LOW_LATENCY)
+#define ASYNC_USR_MASK		(ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \
+		ASYNC_LOW_LATENCY)
 #define ASYNC_SPD_CUST		(ASYNC_SPD_HI|ASYNC_SPD_VHI)
 #define ASYNC_SPD_WARP		(ASYNC_SPD_HI|ASYNC_SPD_SHI)
 #define ASYNC_SPD_MASK		(ASYNC_SPD_HI|ASYNC_SPD_VHI|ASYNC_SPD_SHI)
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 11/68] ALPHA: srmcons, fix racy singleton structure
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, Richard Henderson,
	Ivan Kokshaysky, Matt Turner
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

The test and the assignment were racy. Make it really a singleton.
This is achieved by one global variable initialized at the module
init.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
---
 arch/alpha/kernel/srmcons.c |   40 +++++-----------------------------------
 1 file changed, 5 insertions(+), 35 deletions(-)

diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index f1fdf17..2c89ce5c 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -33,7 +33,7 @@ struct srmcons_private {
 	struct tty_struct *tty;
 	struct timer_list timer;
 	spinlock_t lock;
-};
+} srmcons_singleton;
 
 typedef union _srmcons_result {
 	struct {
@@ -154,43 +154,10 @@ srmcons_chars_in_buffer(struct tty_struct *tty)
 }
 
 static int
-srmcons_get_private_struct(struct srmcons_private **ps)
-{
-	static struct srmcons_private *srmconsp = NULL;
-	static DEFINE_SPINLOCK(srmconsp_lock);
-	unsigned long flags;
-	int retval = 0;
-
-	if (srmconsp == NULL) {
-		srmconsp = kmalloc(sizeof(*srmconsp), GFP_KERNEL);
-		spin_lock_irqsave(&srmconsp_lock, flags);
-
-		if (srmconsp == NULL)
-			retval = -ENOMEM;
-		else {
-			srmconsp->tty = NULL;
-			spin_lock_init(&srmconsp->lock);
-			setup_timer(&srmconsp->timer, srmcons_receive_chars,
-					(unsigned long)srmconsp);
-		}
-
-		spin_unlock_irqrestore(&srmconsp_lock, flags);
-	}
-
-	*ps = srmconsp;
-	return retval;
-}
-
-static int
 srmcons_open(struct tty_struct *tty, struct file *filp)
 {
-	struct srmcons_private *srmconsp;
+	struct srmcons_private *srmconsp = &srmcons_singleton;
 	unsigned long flags;
-	int retval;
-
-	retval = srmcons_get_private_struct(&srmconsp);
-	if (retval)
-		return retval;
 
 	spin_lock_irqsave(&srmconsp->lock, flags);
 
@@ -236,6 +203,9 @@ static const struct tty_operations srmcons_ops = {
 static int __init
 srmcons_init(void)
 {
+	spin_lock_init(&srmcons_singleton.lock);
+	setup_timer(&srmcons_singleton.timer, srmcons_receive_chars,
+			(unsigned long)&srmcons_singleton);
 	if (srm_is_registered_console) {
 		struct tty_driver *driver;
 		int err;
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 13/68] TTY: serialP, remove DECLARE_WAITQUEUE check
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

The macro is always defined now. This was there only for historical
reasons.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 include/linux/serialP.h |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index e811a61..ec27b34 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -79,15 +79,9 @@ struct async_struct {
 	int			io_type;
 	struct work_struct			work;
 	struct tasklet_struct	tlet;
-#ifdef DECLARE_WAITQUEUE
 	wait_queue_head_t	open_wait;
 	wait_queue_head_t	close_wait;
 	wait_queue_head_t	delta_msr_wait;
-#else	
-	struct wait_queue	*open_wait;
-	struct wait_queue	*close_wait;
-	struct wait_queue	*delta_msr_wait;
-#endif	
 	struct async_struct	*next_port; /* For the linked list */
 	struct async_struct	*prev_port;
 };
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 14/68] TTY: remove unneeded tty->index checks
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

Checking if tty->index is in bounds is not needed. The tty has the
index set in the initial open. This is done in get_tty_driver. And it
can be only in interval <0,driver->num).

So remove the tests which check exactly this interval. Some are
left untouched as they check against the current backing device count.
(Leaving apart that the check is racy in most of the cases.)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 arch/ia64/hp/sim/simserial.c        |    9 +++------
 arch/xtensa/platforms/iss/console.c |    8 ++------
 drivers/char/pcmcia/synclink_cs.c   |    2 +-
 drivers/isdn/capi/capi.c            |    3 +--
 drivers/isdn/gigaset/common.c       |    2 --
 drivers/isdn/i4l/isdn_tty.c         |    7 ++-----
 drivers/s390/char/con3215.c         |    8 ++------
 drivers/tty/amiserial.c             |   10 +++-------
 drivers/tty/cyclades.c              |    6 +-----
 drivers/tty/hvc/hvcs.c              |   24 ++++++++++--------------
 drivers/tty/hvc/hvsi.c              |    5 +----
 drivers/tty/isicom.c                |    2 --
 drivers/tty/mxser.c                 |    2 --
 drivers/tty/rocket.c                |    6 +++---
 drivers/tty/serial/68328serial.c    |    9 ++-------
 drivers/tty/serial/crisv10.c        |   15 +++------------
 drivers/tty/synclink.c              |    2 +-
 drivers/tty/synclink_gt.c           |    2 +-
 drivers/tty/synclinkmp.c            |    2 +-
 drivers/usb/gadget/u_serial.c       |    3 ---
 net/irda/ircomm/ircomm_tty.c        |    6 +-----
 21 files changed, 38 insertions(+), 95 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 9c9c634..164b73d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -760,13 +760,10 @@ errout:
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
 	struct async_struct	*info;
-	int			retval, line;
+	int			retval;
 	unsigned long		page;
 
-	line = tty->index;
-	if ((line < 0) || (line >= NR_PORTS))
-		return -ENODEV;
-	retval = get_async_struct(line, &info);
+	retval = get_async_struct(tty->index, &info);
 	if (retval)
 		return retval;
 	tty->driver_data = info;
@@ -911,7 +908,7 @@ simrs_init (void)
 	if (!ia64_platform_is("hpsim"))
 		return -ENODEV;
 
-	hp_simserial_driver = alloc_tty_driver(1);
+	hp_simserial_driver = alloc_tty_driver(NR_PORTS);
 	if (!hp_simserial_driver)
 		return -ENOMEM;
 
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 247e9d4..19a802a 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -68,11 +68,6 @@ static void rs_poll(unsigned long);
 
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
-	int line = tty->index;
-
-	if ((line < 0) || (line >= SERIAL_MAX_NUM_LINES))
-		return -ENODEV;
-
 	spin_lock(&timer_lock);
 
 	if (tty->count == 1) {
@@ -101,6 +96,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 {
 	spin_lock(&timer_lock);
 	if (tty->count == 1)
+		/* this will cause a deadlock if the timer ticks right now */
 		del_timer_sync(&serial_timer);
 	spin_unlock(&timer_lock);
 }
@@ -210,7 +206,7 @@ static const struct tty_operations serial_ops = {
 
 int __init rs_init(void)
 {
-	serial_driver = alloc_tty_driver(1);
+	serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
 
 	printk ("%s %s\n", serial_name, serial_version);
 
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index c3bcb12..f6453df 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -2484,7 +2484,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
 
 	/* verify range of specified line number */
 	line = tty->index;
-	if ((line < 0) || (line >= mgslpc_device_count)) {
+	if (line >= mgslpc_device_count) {
 		printk("%s(%d):mgslpc_open with invalid line #%d.\n",
 			__FILE__,__LINE__,line);
 		return -ENODEV;
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 41a5644..df8fd88 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1013,8 +1013,7 @@ static const struct file_operations capi_fops =
 static int
 capinc_tty_install(struct tty_driver *driver, struct tty_struct *tty)
 {
-	int idx = tty->index;
-	struct capiminor *mp = capiminor_get(idx);
+	struct capiminor *mp = capiminor_get(tty->index);
 	int ret = tty_standard_install(driver, tty);
 
 	if (ret == 0)
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index e55aabf..db6e434 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -1051,8 +1051,6 @@ static struct cardstate *gigaset_get_cs_by_minor(unsigned minor)
 
 struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty)
 {
-	if (tty->index < 0 || tty->index >= tty->driver->num)
-		return NULL;
 	return gigaset_get_cs_by_minor(tty->index + tty->driver->minor_start);
 }
 
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 89a2887..3831abd 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1590,12 +1590,9 @@ static int
 isdn_tty_open(struct tty_struct *tty, struct file *filp)
 {
 	modem_info *info;
-	int retval, line;
+	int retval;
 
-	line = tty->index;
-	if (line < 0 || line >= ISDN_MAX_CHANNELS)
-		return -ENODEV;
-	info = &dev->mdm.info[line];
+	info = &dev->mdm.info[tty->index];
 	if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open"))
 		return -ENODEV;
 	if (!try_module_get(info->owner)) {
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 176e07c..4f9f1dc 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -933,13 +933,9 @@ console_initcall(con3215_init);
 static int tty3215_open(struct tty_struct *tty, struct file * filp)
 {
 	struct raw3215_info *raw;
-	int retval, line;
+	int retval;
 
-	line = tty->index;
-	if ((line < 0) || (line >= NR_3215))
-		return -ENODEV;
-
-	raw = raw3215[line];
+	raw = raw3215[tty->index];
 	if (raw == NULL)
 		return -ENODEV;
 
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index b42f00d..7532862 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1768,13 +1768,9 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
 	struct async_struct	*info;
-	int 			retval, line;
+	int retval;
 
-	line = tty->index;
-	if ((line < 0) || (line >= NR_PORTS)) {
-		return -ENODEV;
-	}
-	retval = get_async_struct(line, &info);
+	retval = get_async_struct(tty->index, &info);
 	if (retval) {
 		return retval;
 	}
@@ -1964,7 +1960,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	struct serial_state * state;
 	int error;
 
-	serial_driver = alloc_tty_driver(1);
+	serial_driver = alloc_tty_driver(NR_PORTS);
 	if (!serial_driver)
 		return -ENOMEM;
 
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
index 98a1b8b..765d1a9 100644
--- a/drivers/tty/cyclades.c
+++ b/drivers/tty/cyclades.c
@@ -1515,13 +1515,9 @@ static void cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)
 static int cy_open(struct tty_struct *tty, struct file *filp)
 {
 	struct cyclades_port *info;
-	unsigned int i, line;
+	unsigned int i, line = tty->index;
 	int retval;
 
-	line = tty->index;
-	if (tty->index < 0 || NR_PORTS <= line)
-		return -ENODEV;
-
 	for (i = 0; i < NR_CARDS; i++)
 		if (line < cy_card[i].first_line + cy_card[i].nports &&
 				line >= cy_card[i].first_line)
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index da0aa47..d237591 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -1090,27 +1090,23 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
  */
 static struct hvcs_struct *hvcs_get_by_index(int index)
 {
-	struct hvcs_struct *hvcsd = NULL;
+	struct hvcs_struct *hvcsd;
 	unsigned long flags;
 
 	spin_lock(&hvcs_structs_lock);
-	/* We can immediately discard OOB requests */
-	if (index >= 0 && index < HVCS_MAX_SERVER_ADAPTERS) {
-		list_for_each_entry(hvcsd, &hvcs_structs, next) {
-			spin_lock_irqsave(&hvcsd->lock, flags);
-			if (hvcsd->index == index) {
-				kref_get(&hvcsd->kref);
-				spin_unlock_irqrestore(&hvcsd->lock, flags);
-				spin_unlock(&hvcs_structs_lock);
-				return hvcsd;
-			}
+	list_for_each_entry(hvcsd, &hvcs_structs, next) {
+		spin_lock_irqsave(&hvcsd->lock, flags);
+		if (hvcsd->index == index) {
+			kref_get(&hvcsd->kref);
 			spin_unlock_irqrestore(&hvcsd->lock, flags);
+			spin_unlock(&hvcs_structs_lock);
+			return hvcsd;
 		}
-		hvcsd = NULL;
+		spin_unlock_irqrestore(&hvcsd->lock, flags);
 	}
-
 	spin_unlock(&hvcs_structs_lock);
-	return hvcsd;
+
+	return NULL;
 }
 
 /*
diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
index 60bc451..a7488b7 100644
--- a/drivers/tty/hvc/hvsi.c
+++ b/drivers/tty/hvc/hvsi.c
@@ -737,14 +737,11 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
 {
 	struct hvsi_struct *hp;
 	unsigned long flags;
-	int line = tty->index;
 	int ret;
 
 	pr_debug("%s\n", __func__);
 
-	if (line < 0 || line >= hvsi_count)
-		return -ENODEV;
-	hp = &hvsi_ports[line];
+	hp = &hvsi_ports[tty->index];
 
 	tty->driver_data = hp;
 
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c
index b3a28b5..03c1497 100644
--- a/drivers/tty/isicom.c
+++ b/drivers/tty/isicom.c
@@ -849,8 +849,6 @@ static struct tty_port *isicom_find_port(struct tty_struct *tty)
 	unsigned int board;
 	int line = tty->index;
 
-	if (line < 0 || line > PORT_COUNT-1)
-		return NULL;
 	board = BOARD(line);
 	card = &isi_card[board];
 
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 260d031..17ff377 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1010,8 +1010,6 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
 	line = tty->index;
 	if (line == MXSER_PORTS)
 		return 0;
-	if (line < 0 || line > MXSER_PORTS)
-		return -ENODEV;
 	info = &mxser_boards[line / MXSER_PORTS_PER_BOARD].ports[line % MXSER_PORTS_PER_BOARD];
 	if (!info->ioaddr)
 		return -ENODEV;
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
index b088e1e..777d5f9 100644
--- a/drivers/tty/rocket.c
+++ b/drivers/tty/rocket.c
@@ -892,12 +892,12 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
 {
 	struct r_port *info;
 	struct tty_port *port;
-	int line = 0, retval;
+	int retval;
 	CHANNEL_t *cp;
 	unsigned long page;
 
-	line = tty->index;
-	if (line < 0 || line >= MAX_RP_PORTS || ((info = rp_table[line]) == NULL))
+	info = rp_table[tty->index];
+	if (info == NULL)
 		return -ENXIO;
 	port = &info->port;
 	
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index a88ef97..7398390 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -1190,14 +1190,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
 int rs_open(struct tty_struct *tty, struct file * filp)
 {
 	struct m68k_serial	*info;
-	int 			retval, line;
-
-	line = tty->index;
-	
-	if (line >= NR_PORTS || line < 0) /* we have exactly one */
-		return -ENODEV;
+	int retval;
 
-	info = &m68k_soft[line];
+	info = &m68k_soft[tty->index];
 
 	if (serial_paranoia_check(info, tty->name, "rs_open"))
 		return -ENODEV;
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c
index 1dfba7b..23d7916 100644
--- a/drivers/tty/serial/crisv10.c
+++ b/drivers/tty/serial/crisv10.c
@@ -4105,20 +4105,11 @@ static int
 rs_open(struct tty_struct *tty, struct file * filp)
 {
 	struct e100_serial	*info;
-	int 			retval, line;
+	int 			retval;
 	unsigned long           page;
 	int                     allocated_resources = 0;
 
-	/* find which port we want to open */
-	line = tty->index;
-
-	if (line < 0 || line >= NR_PORTS)
-		return -ENODEV;
-
-	/* find the corresponding e100_serial struct in the table */
-	info = rs_table + line;
-
-	/* don't allow the opening of ports that are not enabled in the HW config */
+	info = rs_table + tty->index;
 	if (!info->enabled)
 		return -ENODEV;
 
@@ -4131,7 +4122,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
 	tty->driver_data = info;
 	info->port.tty = tty;
 
-	info->port.tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+	tty->low_latency = !!(info->flags & ASYNC_LOW_LATENCY);
 
 	if (!tmp_buf) {
 		page = get_zeroed_page(GFP_KERNEL);
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
index 2b2988c..8e518da 100644
--- a/drivers/tty/synclink.c
+++ b/drivers/tty/synclink.c
@@ -3381,7 +3381,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
 
 	/* verify range of specified line number */	
 	line = tty->index;
-	if ((line < 0) || (line >= mgsl_device_count)) {
+	if (line >= mgsl_device_count) {
 		printk("%s(%d):mgsl_open with invalid line #%d.\n",
 			__FILE__,__LINE__,line);
 		return -ENODEV;
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 32f8eda..34b1a3c 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -654,7 +654,7 @@ static int open(struct tty_struct *tty, struct file *filp)
 	unsigned long flags;
 
 	line = tty->index;
-	if ((line < 0) || (line >= slgt_device_count)) {
+	if (line >= slgt_device_count) {
 		DBGERR(("%s: open with invalid line #%d.\n", driver_name, line));
 		return -ENODEV;
 	}
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
index ddabb61..4fb6c4b 100644
--- a/drivers/tty/synclinkmp.c
+++ b/drivers/tty/synclinkmp.c
@@ -721,7 +721,7 @@ static int open(struct tty_struct *tty, struct file *filp)
 	unsigned long flags;
 
 	line = tty->index;
-	if ((line < 0) || (line >= synclinkmp_device_count)) {
+	if (line >= synclinkmp_device_count) {
 		printk("%s(%d): open with invalid line #%d.\n",
 			__FILE__,__LINE__,line);
 		return -ENODEV;
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 490b01d..6c23938 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -725,9 +725,6 @@ static int gs_open(struct tty_struct *tty, struct file *file)
 	struct gs_port	*port;
 	int		status;
 
-	if (port_num < 0 || port_num >= n_ports)
-		return -ENXIO;
-
 	do {
 		mutex_lock(&ports[port_num].lock);
 		port = ports[port_num].port;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 828f886..6b9d5a0 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -365,16 +365,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
 static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
 {
 	struct ircomm_tty_cb *self;
-	unsigned int line;
+	unsigned int line = tty->index;
 	unsigned long	flags;
 	int ret;
 
 	IRDA_DEBUG(2, "%s()\n", __func__ );
 
-	line = tty->index;
-	if (line >= IRCOMM_TTY_PORTS)
-		return -ENODEV;
-
 	/* Check if instance already exists */
 	self = hashbin_lock_find(ircomm_tty, line, NULL);
 	if (!self) {
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 15/68] TTY: ipwireless, fix tty->index handling
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, Jiri Kosina,
	David Sterba
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

* do not test if tty->index is in bounds. It is always.
* tty->index is not a minor! Fix that.

>From now on, let's assume that the parameter of the function is tty
index with base being zero. This makes also the code more readable.

Factually, there is no real change as tty_driver->minor_start is zero,
so the tests are equivalent. But it did not make sense. And if this
had changed eventually, it would have caused troubles.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: David Sterba <dsterba@suse.cz>
---
 drivers/tty/ipwireless/tty.c |   36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
index 6990b3b..77ceaa9 100644
--- a/drivers/tty/ipwireless/tty.c
+++ b/drivers/tty/ipwireless/tty.c
@@ -90,33 +90,23 @@ static void report_deregistering(struct ipw_tty *tty)
 	       tty->index);
 }
 
-static struct ipw_tty *get_tty(int minor)
+static struct ipw_tty *get_tty(int index)
 {
-	if (minor < ipw_tty_driver->minor_start
-			|| minor >= ipw_tty_driver->minor_start +
-			IPWIRELESS_PCMCIA_MINORS)
+	/*
+	 * The 'ras_raw' channel is only available when 'loopback' mode
+	 * is enabled.
+	 * Number of minor starts with 16 (_RANGE * _RAS_RAW).
+	 */
+	if (!ipwireless_loopback && index >=
+			 IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW)
 		return NULL;
-	else {
-		int minor_offset = minor - ipw_tty_driver->minor_start;
-
-		/*
-		 * The 'ras_raw' channel is only available when 'loopback' mode
-		 * is enabled.
-		 * Number of minor starts with 16 (_RANGE * _RAS_RAW).
-		 */
-		if (!ipwireless_loopback &&
-				minor_offset >=
-				 IPWIRELESS_PCMCIA_MINOR_RANGE * TTYTYPE_RAS_RAW)
-			return NULL;
-
-		return ttys[minor_offset];
-	}
+
+	return ttys[index];
 }
 
 static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
 {
-	int minor = linux_tty->index;
-	struct ipw_tty *tty = get_tty(minor);
+	struct ipw_tty *tty = get_tty(linux_tty->index);
 
 	if (!tty)
 		return -ENODEV;
@@ -510,7 +500,7 @@ static int add_tty(int j,
 		ipwireless_associate_network_tty(network,
 						 secondary_channel_idx,
 						 ttys[j]);
-	if (get_tty(j + ipw_tty_driver->minor_start) == ttys[j])
+	if (get_tty(j) == ttys[j])
 		report_registering(ttys[j]);
 	return 0;
 }
@@ -570,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
 
 		if (ttyj) {
 			mutex_lock(&ttyj->ipw_tty_mutex);
-			if (get_tty(j + ipw_tty_driver->minor_start) == ttyj)
+			if (get_tty(j) == ttyj)
 				report_deregistering(ttyj);
 			ttyj->closing = 1;
 			if (ttyj->linux_tty != NULL) {
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 16/68] NET: pc300, do not zero global variables
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, netdev
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

They are in .bss which is initialized to zeros when the module is
loaded/kernel booted.

What a strange way to do the initialization once in the pci probe
routine...

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: netdev@vger.kernel.org
---
 drivers/net/wan/pc300_drv.c |    4 ----
 drivers/net/wan/pc300_tty.c |   18 ------------------
 2 files changed, 22 deletions(-)

diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 1eeedd6..a6dd00d 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -299,7 +299,6 @@ void cpc_tty_init(pc300dev_t * dev);
 void cpc_tty_unregister_service(pc300dev_t * pc300dev);
 void cpc_tty_receive(pc300dev_t * pc300dev);
 void cpc_tty_trigger_poll(pc300dev_t * pc300dev);
-void cpc_tty_reset_var(void);
 #endif
 
 /************************/
@@ -3421,9 +3420,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (first_time) {
 		first_time = 0;
 		show_version();
-#ifdef CONFIG_PC300_MLPPP
-		cpc_tty_reset_var();
-#endif
 	}
 
 	if ((err = pci_enable_device(pdev)) < 0)
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index d47d2cd..4709f42 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -139,7 +139,6 @@ void cpc_tty_init(pc300dev_t *dev);
 void cpc_tty_unregister_service(pc300dev_t *pc300dev);
 void cpc_tty_receive(pc300dev_t *pc300dev);
 void cpc_tty_trigger_poll(pc300dev_t *pc300dev);
-void cpc_tty_reset_var(void);
 
 /*
  * PC300 TTY clear "signal"
@@ -1078,20 +1077,3 @@ void cpc_tty_trigger_poll(pc300dev_t *pc300dev)
 	}
 	schedule_work(&(cpc_tty->tty_tx_work)); 
 } 
-
-/*
- * PC300 TTY reset var routine
- * This routine is called by pc300driver to init the TTY area. 
- */
-
-void cpc_tty_reset_var(void)
-{
-	int i ; 
-
-	CPC_TTY_DBG("hdlcX-tty: reset variables\n");
-	/* reset  the tty_driver structure - serial_drv */ 
-	memset(&serial_drv, 0, sizeof(struct tty_driver));
-	for (i=0; i < CPC_TTY_NPORTS; i++){
-		memset(&cpc_tty_area[i],0, sizeof(st_cpc_tty_area)); 
-	}
-}
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 17/68] NET: pc300, show version info from module init
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, netdev
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

Again, no need to do that from the pci probe function.

Hmm, I noticed this driver is marked as BROKEN. Won't touch it more,
it has to be converted to dynamic tty driver allocation first.

Perhaps it is time to move it to staging?

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: netdev@vger.kernel.org
---
 drivers/net/wan/pc300_drv.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index a6dd00d..cb0f8d9 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3231,7 +3231,7 @@ static void plx_init(pc300_t * card)
 
 }
 
-static inline void show_version(void)
+static void show_version(void)
 {
 	char *rcsvers, *rcsdate, *tmp;
 
@@ -3412,16 +3412,10 @@ static void cpc_init_card(pc300_t * card)
 static int __devinit
 cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	static int first_time = 1;
 	int err, eeprom_outdated = 0;
 	u16 device_id;
 	pc300_t *card;
 
-	if (first_time) {
-		first_time = 0;
-		show_version();
-	}
-
 	if ((err = pci_enable_device(pdev)) < 0)
 		return err;
 
@@ -3657,6 +3651,7 @@ static struct pci_driver cpc_driver = {
 
 static int __init cpc_init(void)
 {
+	show_version();
 	return pci_register_driver(&cpc_driver);
 }
 
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 18/68] XTENSA: iss/console, use setup_timer
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

Use setup_timer instead of explicit assignments.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/platforms/iss/console.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 19a802a..01842e4 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -69,11 +69,8 @@ static void rs_poll(unsigned long);
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
 	spin_lock(&timer_lock);
-
 	if (tty->count == 1) {
-		init_timer(&serial_timer);
-		serial_timer.data = (unsigned long) tty;
-		serial_timer.function = rs_poll;
+		setup_timer(&serial_timer, rs_poll, (unsigned long)tty);
 		mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
 	}
 	spin_unlock(&timer_lock);
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 19/68] XTENSA: iss/console, fix potential deadlock
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

If the timer ticks while we are holding the spinlock, the system
deadlocks. It is due to synchronous del_timer.

So to fix that, use spinlocks that properly disable bottom halves.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/platforms/iss/console.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 01842e4..94ab8ec 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -91,11 +91,10 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
  */
 static void rs_close(struct tty_struct *tty, struct file * filp)
 {
-	spin_lock(&timer_lock);
+	spin_lock_bh(&timer_lock);
 	if (tty->count == 1)
-		/* this will cause a deadlock if the timer ticks right now */
 		del_timer_sync(&serial_timer);
-	spin_unlock(&timer_lock);
+	spin_unlock_bh(&timer_lock);
 }
 
 
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 20/68] TTY: iss/console, use tty_port
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

Even though the port is not used for anything real there yet, this
will change as tty buffers will be in tty_port in the near future. So
the port will be needed in all drivers.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Chris Zankel <chris@zankel.net>
---
 arch/xtensa/platforms/iss/console.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 94ab8ec..d1a7861 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -37,6 +37,7 @@
 #define SERIAL_TIMER_VALUE (20 * HZ)
 
 static struct tty_driver *serial_driver;
+static struct tty_port serial_port;
 static struct timer_list serial_timer;
 
 static DEFINE_SPINLOCK(timer_lock);
@@ -68,6 +69,7 @@ static void rs_poll(unsigned long);
 
 static int rs_open(struct tty_struct *tty, struct file * filp)
 {
+	tty->port = &serial_port;
 	spin_lock(&timer_lock);
 	if (tty->count == 1) {
 		setup_timer(&serial_timer, rs_poll, (unsigned long)tty);
@@ -202,6 +204,8 @@ static const struct tty_operations serial_ops = {
 
 int __init rs_init(void)
 {
+	tty_port_init(&serial_port);
+
 	serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
 
 	printk ("%s %s\n", serial_name, serial_version);
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 21/68] TTY: serial, use atomic_inc_return in ioc4_serial
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

We want to know the value of the atomic variable in intr_connect after
the increment. But atomic_inc doesn't, per definition, return the
value.  It is just a pure coincidence that ia64 defines atomic_inc as
atomic_inc_return.

So fix this mistake by using atomic_inc_return properly.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/serial/ioc4_serial.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index 6b36c15..dfec69a 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -975,7 +975,7 @@ intr_connect(struct ioc4_soft *soft, int type,
 	BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
 	       || (type == IOC4_OTHER_INTR_TYPE)));
 
-	i = atomic_inc(&soft-> is_intr_type[type].is_num_intrs) - 1;
+	i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
 	BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
 
 	/* Save off the lower level interrupt handler */
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 22/68] TTY: serial, include pci.h in m32r_sio
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

It uses pointers to pci_dev, but compiler complains it doesn't know
it:
In file included from .../m32r_sio.c:53:
.../m32r_sio.h:21: warning: "struct pci_dev" declared inside parameter list
.../m32r_sio.h:21: warning: its scope is only this definition or declaration, which is probably not what you want
.../m32r_sio.h:22: warning: "struct pci_dev" declared inside parameter list

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/tty/serial/m32r_sio.h |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/serial/m32r_sio.h b/drivers/tty/serial/m32r_sio.h
index e9b7e11..8129824 100644
--- a/drivers/tty/serial/m32r_sio.h
+++ b/drivers/tty/serial/m32r_sio.h
@@ -15,6 +15,7 @@
  * (at your option) any later version.
  */
 
+#include <linux/pci.h>
 
 struct m32r_sio_probe {
 	struct module	*owner;
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 24/68] TTY: speakup, do not use serialP
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, William Hubbs,
	Chris Brannon, Kirk Reiser, Samuel Thibault
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

The structures there are going away. And speakup has enough troubles
already.

So define a structure similar to what 8250 does: old_serial_port.
There define an array of speed, port base and so on needed for
configuration. Then use this structure instead of serial_state defined
in serialP.h.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: William Hubbs <w.d.hubbs@gmail.com>
Cc: Chris Brannon <chris@the-brannons.com>
Cc: Kirk Reiser <kirk@braille.uwo.ca>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 drivers/staging/speakup/serialio.c |   11 +++++------
 drivers/staging/speakup/serialio.h |   13 ++++++++++++-
 drivers/staging/speakup/spk_priv.h |    2 +-
 drivers/staging/speakup/synth.c    |    2 +-
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/speakup/serialio.c b/drivers/staging/speakup/serialio.c
index 7f3d87b..a97d3d5 100644
--- a/drivers/staging/speakup/serialio.c
+++ b/drivers/staging/speakup/serialio.c
@@ -8,21 +8,20 @@
 
 static void start_serial_interrupt(int irq);
 
-static struct serial_state rs_table[] = {
+static const struct old_serial_port rs_table[] = {
 	SERIAL_PORT_DFNS
 };
-static struct serial_state *serstate;
+static const struct old_serial_port *serstate;
 static int timeouts;
 
-struct serial_state *spk_serial_init(int index)
+const struct old_serial_port *spk_serial_init(int index)
 {
 	int baud = 9600, quot = 0;
 	unsigned int cval = 0;
 	int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
-	struct serial_state *ser = NULL;
+	const struct old_serial_port *ser = rs_table + index;
 	int err;
 
-	ser = rs_table + index;
 	/*	Divisor, bytesize and parity */
 	quot = ser->baud_base / baud;
 	cval = cflag & (CSIZE | CSTOPB);
@@ -41,7 +40,7 @@ struct serial_state *spk_serial_init(int index)
 		__release_region(&ioport_resource, ser->port, 8);
 		err = synth_request_region(ser->port, 8);
 		if (err) {
-			pr_warn("Unable to allocate port at %lx, errno %i",
+			pr_warn("Unable to allocate port at %x, errno %i",
 				ser->port, err);
 			return NULL;
 		}
diff --git a/drivers/staging/speakup/serialio.h b/drivers/staging/speakup/serialio.h
index d785b1f..614271f 100644
--- a/drivers/staging/speakup/serialio.h
+++ b/drivers/staging/speakup/serialio.h
@@ -4,11 +4,22 @@
 #include <linux/serial.h>	/* for rs_table, serial constants &
 				   serial_uart_config */
 #include <linux/serial_reg.h>	/* for more serial constants */
-#include <linux/serialP.h>	/* for struct serial_state */
 #ifndef __sparc__
 #include <asm/serial.h>
 #endif
 
+/*
+ * this is cut&paste from 8250.h. Get rid of the structure, the definitions
+ * and this whole broken driver.
+ */
+struct old_serial_port {
+	unsigned int uart; /* unused */
+	unsigned int baud_base;
+	unsigned int port;
+	unsigned int irq;
+	unsigned int flags; /* unused */
+};
+
 /* countdown values for serial timeouts in us */
 #define SPK_SERIAL_TIMEOUT 100000
 /* countdown values transmitter/dsr timeouts in us */
diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h
index 16ace4a..a47c5b7 100644
--- a/drivers/staging/speakup/spk_priv.h
+++ b/drivers/staging/speakup/spk_priv.h
@@ -44,7 +44,7 @@
 
 #define KT_SPKUP 15
 
-extern struct serial_state *spk_serial_init(int index);
+extern const struct old_serial_port *spk_serial_init(int index);
 extern void stop_serial_interrupt(void);
 extern int wait_for_xmitr(void);
 extern unsigned char spk_serial_in(void);
diff --git a/drivers/staging/speakup/synth.c b/drivers/staging/speakup/synth.c
index 2222d691..331eae7 100644
--- a/drivers/staging/speakup/synth.c
+++ b/drivers/staging/speakup/synth.c
@@ -34,7 +34,7 @@ static int do_synth_init(struct spk_synth *in_synth);
 
 int serial_synth_probe(struct spk_synth *synth)
 {
-	struct serial_state *ser;
+	const struct old_serial_port *ser;
 	int failed = 0;
 
 	if ((synth->ser >= SPK_LO_TTY) && (synth->ser <= SPK_HI_TTY)) {
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 25/68] TTY: serialP, remove unused material
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
	Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

First, remove unused macro and rs_multiport_struct structure. Nobody
uses them at all.

Further, the 2 drivers (they are below) which use the rest of
structures from serialP.h (async_struct and serial_state) do not use
all the members. Remove the members:
* which are unused or
* which are only initialized and never used for something real.

Everybody should avoid the structures with a looong distance.

Finally, remove the ALPHA kludge MCR quirks. They are 1:1 copy from
8250.h. No need to redefine them here.

The 2 promised users of the structures:
arch/ia64/hp/sim/simserial.c
drivers/tty/amiserial.c

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/hp/sim/simserial.c |   10 +------
 drivers/tty/amiserial.c      |    6 -----
 include/linux/serialP.h      |   59 ------------------------------------------
 3 files changed, 1 insertion(+), 74 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 164b73d..c8e728bf 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -70,7 +70,7 @@ static char *serial_version = "0.6";
  */
 static struct serial_state rs_table[NR_PORTS]={
   /* UART CLK   PORT IRQ     FLAGS        */
-  { 0, BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS,0,PORT_16550 }  /* ttyS0 */
+  { BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS, PORT_16550 }  /* ttyS0 */
 };
 
 /*
@@ -192,11 +192,6 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
  * -------------------------------------------------------------------
  */
 
-static void do_softint(struct work_struct *private_)
-{
-	printk(KERN_ERR "simserial: do_softint called\n");
-}
-
 static int rs_put_char(struct tty_struct *tty, unsigned char ch)
 {
 	struct async_struct *info = (struct async_struct *)tty->driver_data;
@@ -639,13 +634,10 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	}
 	init_waitqueue_head(&info->open_wait);
 	init_waitqueue_head(&info->close_wait);
-	init_waitqueue_head(&info->delta_msr_wait);
-	info->magic = SERIAL_MAGIC;
 	info->port = sstate->port;
 	info->flags = sstate->flags;
 	info->xmit_fifo_size = sstate->xmit_fifo_size;
 	info->line = line;
-	INIT_WORK(&info->work, do_softint);
 	info->state = sstate;
 	if (sstate->info) {
 		kfree(info);
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7532862..c6d8913 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -473,7 +473,6 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	receive_chars(info);
-	info->last_active = jiffies;
 #ifdef SERIAL_DEBUG_INTR
 	printk("end.\n");
 #endif
@@ -494,7 +493,6 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
 		return IRQ_NONE;
 
 	  transmit_chars(info);
-	  info->last_active = jiffies;
 #ifdef SERIAL_DEBUG_INTR
 	  printk("end.\n");
 #endif
@@ -828,7 +826,6 @@ static void change_speed(struct async_struct *info,
 	mb();
 	}
 
-	info->LCR = cval;				/* Save LCR */
 	local_irq_restore(flags);
 }
 
@@ -1743,7 +1740,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	init_waitqueue_head(&info->close_wait);
 	init_waitqueue_head(&info->delta_msr_wait);
 #endif
-	info->magic = SERIAL_MAGIC;
 	info->port = sstate->port;
 	info->flags = sstate->flags;
 	info->xmit_fifo_size = sstate->xmit_fifo_size;
@@ -1840,7 +1836,6 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
 	if (!info) {
 		info = &scr_info;	/* This is just for serial_{in,out} */
 
-		info->magic = SERIAL_MAGIC;
 		info->flags = state->flags;
 		info->quot = 0;
 		info->tty = NULL;
@@ -1987,7 +1982,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 		goto fail_put_tty_driver;
 
 	state = rs_table;
-	state->magic = SSTATE_MAGIC;
 	state->port = (int)&custom.serdatr; /* Just to give it a value */
 	state->line = 0;
 	state->custom_divisor = 0;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index ec27b34..c1acdb2 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -26,32 +26,23 @@
 #include <linux/wait.h>
 
 struct serial_state {
-	int	magic;
 	int	baud_base;
 	unsigned long	port;
 	int	irq;
 	int	flags;
-	int	hub6;
 	int	type;
 	int	line;
-	int	revision;	/* Chip revision (950) */
 	int	xmit_fifo_size;
 	int	custom_divisor;
 	int	count;
-	u8	*iomem_base;
-	u16	iomem_reg_shift;
 	unsigned short	close_delay;
 	unsigned short	closing_wait; /* time to wait before closing */
 	struct async_icount	icount;	
-	int	io_type;
 	struct async_struct *info;
-	struct pci_dev	*dev;
 };
 
 struct async_struct {
-	int			magic;
 	unsigned long		port;
-	int			hub6;
 	int			flags;
 	int			xmit_fifo_size;
 	struct serial_state	*state;
@@ -63,21 +54,12 @@ struct async_struct {
 	int			x_char;	/* xon/xoff character */
 	int			close_delay;
 	unsigned short		closing_wait;
-	unsigned short		closing_wait2; /* obsolete */
 	int			IER; 	/* Interrupt Enable Register */
 	int			MCR; 	/* Modem control register */
-	int			LCR; 	/* Line control register */
-	int			ACR;	 /* 16950 Additional Control Reg. */
 	unsigned long		event;
-	unsigned long		last_active;
 	int			line;
 	int			blocked_open; /* # of blocked opens */
  	struct circ_buf		xmit;
- 	spinlock_t		xmit_lock;
-	u8			*iomem_base;
-	u16			iomem_reg_shift;
-	int			io_type;
-	struct work_struct			work;
 	struct tasklet_struct	tlet;
 	wait_queue_head_t	open_wait;
 	wait_queue_head_t	close_wait;
@@ -86,51 +68,10 @@ struct async_struct {
 	struct async_struct	*prev_port;
 };
 
-#define CONFIGURED_SERIAL_PORT(info) ((info)->port || ((info)->iomem_base))
-
-#define SERIAL_MAGIC 0x5301
-#define SSTATE_MAGIC 0x5302
-
 /*
  * Events are used to schedule things to happen at timer-interrupt
  * time, instead of at rs interrupt time.
  */
 #define RS_EVENT_WRITE_WAKEUP	0
 
-/*
- * Multiport serial configuration structure --- internal structure
- */
-struct rs_multiport_struct {
-	int		port1;
-	unsigned char	mask1, match1;
-	int		port2;
-	unsigned char	mask2, match2;
-	int		port3;
-	unsigned char	mask3, match3;
-	int		port4;
-	unsigned char	mask4, match4;
-	int		port_monitor;
-};
-
-#if defined(__alpha__) && !defined(CONFIG_PCI)
-/*
- * Digital did something really horribly wrong with the OUT1 and OUT2
- * lines on at least some ALPHA's.  The failure mode is that if either
- * is cleared, the machine locks up with endless interrupts.
- *
- * This is still used by arch/mips/au1000/common/serial.c for some weird
- * reason (mips != alpha!)
- */
-#define ALPHA_KLUDGE_MCR  (UART_MCR_OUT2 | UART_MCR_OUT1)
-#elif defined(CONFIG_SBC8560)
-/*
- * WindRiver did something similarly broken on their SBC8560 board. The
- * UART tristates its IRQ output while OUT2 is clear, but they pulled
- * the interrupt line _up_ instead of down, so if we register the IRQ
- * while the UART is in that state, we die in an IRQ storm. */
-#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2)
-#else
-#define ALPHA_KLUDGE_MCR 0
-#endif
-
 #endif /* _LINUX_SERIAL_H */
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 26/68] TTY: amiserial, remove tasklet for tty_wakeup
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
	Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

tty_wakeup is safe to be called from all contexts. No need to schedule
a tasklet for that. Let's call it directly like in other drivers.

This allows us to kill another member of async_struct structure. (If
we remove the dummy uses in simserial.)

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/hp/sim/simserial.c |    2 --
 drivers/tty/amiserial.c      |   42 ++----------------------------------------
 include/linux/serialP.h      |    8 --------
 3 files changed, 2 insertions(+), 50 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index c8e728bf..8f68972 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -570,7 +570,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	shutdown(info);
 	rs_flush_buffer(tty);
 	tty_ldisc_flush(tty);
-	info->event = 0;
 	info->tty = NULL;
 	if (info->blocked_open) {
 		if (info->close_delay)
@@ -608,7 +607,6 @@ static void rs_hangup(struct tty_struct *tty)
 		return;
 	shutdown(info);
 
-	info->event = 0;
 	state->count = 0;
 	info->flags &= ~ASYNC_NORMAL_ACTIVE;
 	info->tty = NULL;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index c6d8913..d5fac86 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -231,17 +231,6 @@ static void rs_start(struct tty_struct *tty)
  * -----------------------------------------------------------------------
  */
 
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static void rs_sched_event(struct async_struct *info,
-			   int event)
-{
-	info->event |= 1 << event;
-	tasklet_schedule(&info->tlet);
-}
-
 static void receive_chars(struct async_struct *info)
 {
         int status;
@@ -359,7 +348,7 @@ static void transmit_chars(struct async_struct *info)
 	if (CIRC_CNT(info->xmit.head,
 		     info->xmit.tail,
 		     SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
-		rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+		tty_wakeup(info->tty);
 
 #ifdef SERIAL_DEBUG_INTR
 	printk("THRE...");
@@ -427,7 +416,7 @@ static void check_modem_status(struct async_struct *info)
 				/* set a pending Tx Interrupt, transmitter should restart now */
 				custom.intreq = IF_SETCLR | IF_TBE;
 				mb();
-				rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
+				tty_wakeup(info->tty);
 				return;
 			}
 		} else {
@@ -507,29 +496,6 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
  */
 
 /*
- * This routine is used to handle the "bottom half" processing for the
- * serial driver, known also the "software interrupt" processing.
- * This processing is done at the kernel interrupt level, after the
- * rs_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
- * is where time-consuming activities which can not be done in the
- * interrupt driver proper are done; the interrupt driver schedules
- * them using rs_sched_event(), and they get done here.
- */
-
-static void do_softint(unsigned long private_)
-{
-	struct async_struct	*info = (struct async_struct *) private_;
-	struct tty_struct	*tty;
-
-	tty = info->tty;
-	if (!tty)
-		return;
-
-	if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
-		tty_wakeup(tty);
-}
-
-/*
  * ---------------------------------------------------------------
  * Low level utility subroutines for the serial driver:  routines to
  * figure out the appropriate timeout for an interrupt chain, routines
@@ -1506,7 +1472,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 		
 	tty_ldisc_flush(tty);
 	tty->closing = 0;
-	info->event = 0;
 	info->tty = NULL;
 	if (info->blocked_open) {
 		if (info->close_delay) {
@@ -1597,7 +1562,6 @@ static void rs_hangup(struct tty_struct *tty)
 
 	rs_flush_buffer(tty);
 	shutdown(info);
-	info->event = 0;
 	state->count = 0;
 	info->flags &= ~ASYNC_NORMAL_ACTIVE;
 	info->tty = NULL;
@@ -1744,7 +1708,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	info->flags = sstate->flags;
 	info->xmit_fifo_size = sstate->xmit_fifo_size;
 	info->line = line;
-	tasklet_init(&info->tlet, do_softint, (unsigned long)info);
 	info->state = sstate;
 	if (sstate->info) {
 		kfree(info);
@@ -2050,7 +2013,6 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
 	struct async_struct *info = state->info;
 
 	/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
-	tasklet_kill(&info->tlet);
 	if ((error = tty_unregister_driver(serial_driver)))
 		printk("SERIAL: failed to unregister serial driver (%d)\n",
 		       error);
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index c1acdb2..beaf39f 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -56,11 +56,9 @@ struct async_struct {
 	unsigned short		closing_wait;
 	int			IER; 	/* Interrupt Enable Register */
 	int			MCR; 	/* Modem control register */
-	unsigned long		event;
 	int			line;
 	int			blocked_open; /* # of blocked opens */
  	struct circ_buf		xmit;
-	struct tasklet_struct	tlet;
 	wait_queue_head_t	open_wait;
 	wait_queue_head_t	close_wait;
 	wait_queue_head_t	delta_msr_wait;
@@ -68,10 +66,4 @@ struct async_struct {
 	struct async_struct	*prev_port;
 };
 
-/*
- * Events are used to schedule things to happen at timer-interrupt
- * time, instead of at rs interrupt time.
- */
-#define RS_EVENT_WRITE_WAKEUP	0
-
 #endif /* _LINUX_SERIAL_H */
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 28/68] TTY: simserial, use only one copy of async flags
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
	Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

The same as for amiserial. Use only one instance of the flags.

Also remove them from async_struct now. Nobody else uses them.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/hp/sim/simserial.c |   48 ++++++++++++++++++++----------------------
 include/linux/serialP.h      |    1 -
 2 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 8f68972..a08a53f 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -46,7 +46,7 @@
 
 #define NR_PORTS	1	/* only one port for now */
 
-#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
+#define IRQ_T(state) ((state->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
 
 static char *serial_name = "SimSerial driver";
 static char *serial_version = "0.6";
@@ -455,12 +455,11 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 static void shutdown(struct async_struct * info)
 {
 	unsigned long	flags;
-	struct serial_state *state;
+	struct serial_state *state = info->state;
 	int		retval;
 
-	if (!(info->flags & ASYNC_INITIALIZED)) return;
-
-	state = info->state;
+	if (!(state->flags & ASYNC_INITIALIZED))
+		return;
 
 #ifdef SIMSERIAL_DEBUG
 	printk("Shutting down serial port %d (irq %d)....", info->line,
@@ -487,7 +486,8 @@ static void shutdown(struct async_struct * info)
 			if (IRQ_ports[state->irq]) {
 				free_irq(state->irq, NULL);
 				retval = request_irq(state->irq, rs_interrupt_single,
-						     IRQ_T(info), "serial", NULL);
+						     IRQ_T(state), "serial",
+						     NULL);
 
 				if (retval)
 					printk(KERN_ERR "serial shutdown: request_irq: error %d"
@@ -503,7 +503,7 @@ static void shutdown(struct async_struct * info)
 
 		if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
 
-		info->flags &= ~ASYNC_INITIALIZED;
+		state->flags &= ~ASYNC_INITIALIZED;
 	}
 	local_irq_restore(flags);
 }
@@ -560,7 +560,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 		local_irq_restore(flags);
 		return;
 	}
-	info->flags |= ASYNC_CLOSING;
+	state->flags |= ASYNC_CLOSING;
 	local_irq_restore(flags);
 
 	/*
@@ -576,7 +576,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 			schedule_timeout_interruptible(info->close_delay);
 		wake_up_interruptible(&info->open_wait);
 	}
-	info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+	state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
 	wake_up_interruptible(&info->close_wait);
 }
 
@@ -600,15 +600,13 @@ static void rs_hangup(struct tty_struct *tty)
 	printk("rs_hangup: called\n");
 #endif
 
-	state = info->state;
-
 	rs_flush_buffer(tty);
-	if (info->flags & ASYNC_CLOSING)
+	if (state->flags & ASYNC_CLOSING)
 		return;
 	shutdown(info);
 
 	state->count = 0;
-	info->flags &= ~ASYNC_NORMAL_ACTIVE;
+	state->flags &= ~ASYNC_NORMAL_ACTIVE;
 	info->tty = NULL;
 	wake_up_interruptible(&info->open_wait);
 }
@@ -633,7 +631,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	init_waitqueue_head(&info->open_wait);
 	init_waitqueue_head(&info->close_wait);
 	info->port = sstate->port;
-	info->flags = sstate->flags;
 	info->xmit_fifo_size = sstate->xmit_fifo_size;
 	info->line = line;
 	info->state = sstate;
@@ -661,7 +658,7 @@ startup(struct async_struct *info)
 
 	local_irq_save(flags);
 
-	if (info->flags & ASYNC_INITIALIZED) {
+	if (state->flags & ASYNC_INITIALIZED) {
 		free_page(page);
 		goto errout;
 	}
@@ -691,7 +688,8 @@ startup(struct async_struct *info)
 		} else
 			handler = rs_interrupt_single;
 
-		retval = request_irq(state->irq, handler, IRQ_T(info), "simserial", NULL);
+		retval = request_irq(state->irq, handler, IRQ_T(state),
+				"simserial", NULL);
 		if (retval)
 			goto errout;
 	}
@@ -721,17 +719,17 @@ startup(struct async_struct *info)
 	 * Set up the tty->alt_speed kludge
 	 */
 	if (info->tty) {
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+		if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
 			info->tty->alt_speed = 57600;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+		if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
 			info->tty->alt_speed = 115200;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+		if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
 			info->tty->alt_speed = 230400;
-		if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+		if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
 			info->tty->alt_speed = 460800;
 	}
 
-	info->flags |= ASYNC_INITIALIZED;
+	state->flags |= ASYNC_INITIALIZED;
 	local_irq_restore(flags);
 	return 0;
 
@@ -762,7 +760,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
 #ifdef SIMSERIAL_DEBUG
 	printk("rs_open %s, count = %d\n", tty->name, info->state->count);
 #endif
-	info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+	info->tty->low_latency = (info->state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
 
 	if (!tmp_buf) {
 		page = get_zeroed_page(GFP_KERNEL);
@@ -778,11 +776,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
 	 * If the port is the middle of closing, bail out now
 	 */
 	if (tty_hung_up_p(filp) ||
-	    (info->flags & ASYNC_CLOSING)) {
-		if (info->flags & ASYNC_CLOSING)
+	    (info->state->flags & ASYNC_CLOSING)) {
+		if (info->state->flags & ASYNC_CLOSING)
 			interruptible_sleep_on(&info->close_wait);
 #ifdef SERIAL_DO_RESTART
-		return ((info->flags & ASYNC_HUP_NOTIFY) ?
+		return ((info->state->flags & ASYNC_HUP_NOTIFY) ?
 			-EAGAIN : -ERESTARTSYS);
 #else
 		return -EAGAIN;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index beaf39f..6741f57 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -43,7 +43,6 @@ struct serial_state {
 
 struct async_struct {
 	unsigned long		port;
-	int			flags;
 	int			xmit_fifo_size;
 	struct serial_state	*state;
 	struct tty_struct 	*tty;
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 29/68] TTY: simserial/amiserial, use one instance of other members
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh
  Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
	Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

This means:
* close_delay
* closing_wait
* line
* port
* xmit_fifo_size

This actually fixes a bug in amiserial. It initializes one and uses
the other of the close delays. Yes, duplicating structure members is
evil.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/hp/sim/simserial.c |    9 +++------
 drivers/tty/amiserial.c      |   19 ++++++++-----------
 include/linux/serialP.h      |    5 -----
 3 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index a08a53f..d32b759 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -553,7 +553,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	}
 	if (--state->count < 0) {
 		printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
-		       info->line, state->count);
+		       state->line, state->count);
 		state->count = 0;
 	}
 	if (state->count) {
@@ -572,8 +572,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	tty_ldisc_flush(tty);
 	info->tty = NULL;
 	if (info->blocked_open) {
-		if (info->close_delay)
-			schedule_timeout_interruptible(info->close_delay);
+		if (state->close_delay)
+			schedule_timeout_interruptible(state->close_delay);
 		wake_up_interruptible(&info->open_wait);
 	}
 	state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -630,9 +630,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	}
 	init_waitqueue_head(&info->open_wait);
 	init_waitqueue_head(&info->close_wait);
-	info->port = sstate->port;
-	info->xmit_fifo_size = sstate->xmit_fifo_size;
-	info->line = line;
 	info->state = sstate;
 	if (sstate->info) {
 		kfree(info);
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 8556ca0..5540216 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -723,7 +723,7 @@ static void change_speed(struct async_struct *info,
 	if (!quot)
 		quot = baud_base / 9600;
 	info->quot = quot;
-	info->timeout = ((info->xmit_fifo_size*HZ*bits*quot) / baud_base);
+	info->timeout = ((info->state->xmit_fifo_size*HZ*bits*quot) / baud_base);
 	info->timeout += HZ/50;		/* Add .02 seconds of slop */
 
 	/* CTS flow control flag and modem status interrupts */
@@ -1425,7 +1425,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	}
 	if (--state->count < 0) {
 		printk("rs_close: bad serial port count for ttys%d: %d\n",
-		       info->line, state->count);
+		       state->line, state->count);
 		state->count = 0;
 	}
 	if (state->count) {
@@ -1439,8 +1439,8 @@ static void rs_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 (state->closing_wait != ASYNC_CLOSING_WAIT_NONE)
+		tty_wait_until_sent(tty, state->closing_wait);
 	/*
 	 * At this point we stop accepting input.  To do this, we
 	 * disable the receive line status interrupts, and tell the
@@ -1470,8 +1470,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
 	tty->closing = 0;
 	info->tty = NULL;
 	if (info->blocked_open) {
-		if (info->close_delay) {
-			msleep_interruptible(jiffies_to_msecs(info->close_delay));
+		if (state->close_delay) {
+			msleep_interruptible(jiffies_to_msecs(state->close_delay));
 		}
 		wake_up_interruptible(&info->open_wait);
 	}
@@ -1492,7 +1492,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
 	if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
 		return;
 
-	if (info->xmit_fifo_size == 0)
+	if (info->state->xmit_fifo_size == 0)
 		return; /* Just in case.... */
 
 	orig_jiffies = jiffies;
@@ -1505,7 +1505,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
 	 * Note: we have to use pretty tight timings here to satisfy
 	 * the NIST-PCTS.
 	 */
-	char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
+	char_time = (info->timeout - HZ/50) / info->state->xmit_fifo_size;
 	char_time = char_time / 5;
 	if (char_time == 0)
 		char_time = 1;
@@ -1700,9 +1700,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
 	init_waitqueue_head(&info->close_wait);
 	init_waitqueue_head(&info->delta_msr_wait);
 #endif
-	info->port = sstate->port;
-	info->xmit_fifo_size = sstate->xmit_fifo_size;
-	info->line = line;
 	info->state = sstate;
 	if (sstate->info) {
 		kfree(info);
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 6741f57..6ce488c 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -42,8 +42,6 @@ struct serial_state {
 };
 
 struct async_struct {
-	unsigned long		port;
-	int			xmit_fifo_size;
 	struct serial_state	*state;
 	struct tty_struct 	*tty;
 	int			read_status_mask;
@@ -51,11 +49,8 @@ struct async_struct {
 	int			timeout;
 	int			quot;
 	int			x_char;	/* xon/xoff character */
-	int			close_delay;
-	unsigned short		closing_wait;
 	int			IER; 	/* Interrupt Enable Register */
 	int			MCR; 	/* Modem control register */
-	int			line;
 	int			blocked_open; /* # of blocked opens */
  	struct circ_buf		xmit;
 	wait_queue_head_t	open_wait;
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 31/68] TTY: simserial, remove IRQ_T
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
	Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

We do not set ASYNC_SHARE_IRQ anywhere. And since IRQF_DISABLED is a
noop, pass zero to request_irq directly instead of this ugly macro.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
---
 arch/ia64/hp/sim/simserial.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index c35552d..8b5a134 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -46,8 +46,6 @@
 
 #define NR_PORTS	1	/* only one port for now */
 
-#define IRQ_T(state) ((state->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
-
 static char *serial_name = "SimSerial driver";
 static char *serial_version = "0.6";
 
@@ -644,8 +642,8 @@ startup(struct async_struct *info)
 	 * Allocate the IRQ if necessary
 	 */
 	if (state->irq) {
-		retval = request_irq(state->irq, rs_interrupt_single,
-				IRQ_T(state), "simserial", info);
+		retval = request_irq(state->irq, rs_interrupt_single, 0,
+				"simserial", info);
 		if (retval)
 			goto errout;
 	}
-- 
1.7.9.2

^ permalink raw reply related

* [PATCH 32/68] TTY: amiserial, remove IRQ_ports
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
  To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>

They used to work as a storage for 'info' pointer used in ISRs.  They
are not really needed. Just pass the pointer through request_irq to
the handlers.

It was set to NULL and tested in the ISRs, but we do not need the
tests as we disable all the interrupts at the same places where NULL
sets were.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/tty/amiserial.c |   18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5540216..7607c6e 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -100,8 +100,6 @@ static struct tty_driver *serial_driver;
 /* number of characters left in xmit buffer before we ask for more */
 #define WAKEUP_CHARS 256
 
-static struct async_struct *IRQ_ports;
-
 static unsigned char current_ctl_bits;
 
 static void change_speed(struct async_struct *info, struct ktermios *old);
@@ -439,7 +437,7 @@ static void check_modem_status(struct async_struct *info)
 static irqreturn_t ser_vbl_int( int irq, void *data)
 {
         /* vbl is just a periodic interrupt we tie into to update modem status */
-	struct async_struct * info = IRQ_ports;
+	struct async_struct *info = data;
 	/*
 	 * TBD - is it better to unregister from this interrupt or to
 	 * ignore it if MSI is clear ?
@@ -451,13 +449,13 @@ static irqreturn_t ser_vbl_int( int irq, void *data)
 
 static irqreturn_t ser_rx_int(int irq, void *dev_id)
 {
-	struct async_struct * info;
+	struct serial_state *state = dev_id;
+	struct async_struct *info = state->info;
 
 #ifdef SERIAL_DEBUG_INTR
 	printk("ser_rx_int...");
 #endif
 
-	info = IRQ_ports;
 	if (!info || !info->tty)
 		return IRQ_NONE;
 
@@ -470,14 +468,14 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
 
 static irqreturn_t ser_tx_int(int irq, void *dev_id)
 {
-	struct async_struct * info;
+	struct serial_state *state = dev_id;
+	struct async_struct *info = state->info;
 
 	if (custom.serdatr & SDR_TBE) {
 #ifdef SERIAL_DEBUG_INTR
 	  printk("ser_tx_int...");
 #endif
 
-	  info = IRQ_ports;
 	  if (!info || !info->tty)
 		return IRQ_NONE;
 
@@ -554,8 +552,6 @@ static int startup(struct async_struct * info)
 	/* remember current state of the DCD and CTS bits */
 	current_ctl_bits = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
 
-	IRQ_ports = info;
-
 	info->MCR = 0;
 	if (info->tty->termios->c_cflag & CBAUD)
 	  info->MCR = SER_DTR | SER_RTS;
@@ -619,8 +615,6 @@ static void shutdown(struct async_struct * info)
 	 */
 	wake_up_interruptible(&info->delta_msr_wait);
 
-	IRQ_ports = NULL;
-
 	/*
 	 * Free the IRQ, if necessary
 	 */
@@ -1913,8 +1907,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
 	if (!serial_driver)
 		return -ENOMEM;
 
-	IRQ_ports = NULL;
-
 	show_serial_version();
 
 	/* Initialize the tty_driver structure */
-- 
1.7.9.2

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox