* [PATCH 00/68] TTY buffer in tty_port -- prep no. 1
@ 2012-03-05 13:51 Jiri Slaby
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
` (69 more replies)
0 siblings, 70 replies; 79+ messages in thread
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 [flat|nested] 79+ messages in thread
* [PATCH 01/68] USB: cdc-acm, use tty_standard_install
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 14:03 ` Jiri Slaby
2012-03-05 23:39 ` Alan Cox
2012-03-05 13:51 ` [PATCH 02/68] TTY: tty_io, remove buffer re-assignments Jiri Slaby
` (68 subsequent siblings)
69 siblings, 2 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
This is a piece I missed the last time.
Do not copy the functionality all over the tree. Instead, use the
helper the tty layer provides us with.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/usb/class/cdc-acm.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 6dcc3a3..b3fd449 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -509,17 +509,12 @@ static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
if (!acm)
return -ENODEV;
- retval = tty_init_termios(tty);
+ retval = tty_standard_install(driver, tty);
if (retval)
goto error_init_termios;
tty->driver_data = acm;
- /* Final install (we use the default method) */
- tty_driver_kref_get(driver);
- tty->count++;
- driver->ttys[tty->index] = tty;
-
return 0;
error_init_termios:
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 02/68] TTY: tty_io, remove buffer re-assignments
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 03/68] TTY: let alloc_tty_driver deduce the owner automatically Jiri Slaby
` (67 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
TTY buffer head and tail are initialized in tty_buffer_init. No need
to do it once again in initialize_tty_struct where tty_buffer_init is
called.
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 44736f9..f105ce5 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2933,7 +2933,6 @@ void initialize_tty_struct(struct tty_struct *tty,
tty->session = NULL;
tty->pgrp = NULL;
tty->overrun_time = jiffies;
- tty->buf.head = tty->buf.tail = NULL;
tty_buffer_init(tty);
mutex_init(&tty->termios_mutex);
mutex_init(&tty->ldisc_mutex);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 03/68] TTY: let alloc_tty_driver deduce the owner automatically
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
2012-03-05 13:51 ` [PATCH 02/68] TTY: tty_io, remove buffer re-assignments Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 04/68] TTY: remove minor_num from tty_driver Jiri Slaby
` (66 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
Like the rest of the kernel, make a stub from alloc_tty_driver which
calls __alloc_tty_driver with proper owner. This will save us one more
assignment on the driver side.
Also this fixes some drivers which didn't set the owner. This allowed
user to remove the module from the system even though a tty from the
driver is still open.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/tty/tty_io.c | 5 +++--
include/linux/tty_driver.h | 5 ++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index f105ce5..bd95cea 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3049,7 +3049,7 @@ void tty_unregister_device(struct tty_driver *driver, unsigned index)
}
EXPORT_SYMBOL(tty_unregister_device);
-struct tty_driver *alloc_tty_driver(int lines)
+struct tty_driver *__alloc_tty_driver(int lines, struct module *owner)
{
struct tty_driver *driver;
@@ -3058,11 +3058,12 @@ struct tty_driver *alloc_tty_driver(int lines)
kref_init(&driver->kref);
driver->magic = TTY_DRIVER_MAGIC;
driver->num = lines;
+ driver->owner = owner;
/* later we'll move allocation of tables here */
}
return driver;
}
-EXPORT_SYMBOL(alloc_tty_driver);
+EXPORT_SYMBOL(__alloc_tty_driver);
static void destruct_tty_driver(struct kref *kref)
{
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 5cf6850..6e65493 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -234,6 +234,7 @@
* if provided (otherwise EINVAL will be returned).
*/
+#include <linux/export.h>
#include <linux/fs.h>
#include <linux/list.h>
#include <linux/cdev.h>
@@ -324,7 +325,7 @@ struct tty_driver {
extern struct list_head tty_drivers;
-extern struct tty_driver *alloc_tty_driver(int lines);
+extern struct tty_driver *__alloc_tty_driver(int lines, struct module *owner);
extern void put_tty_driver(struct tty_driver *driver);
extern void tty_set_operations(struct tty_driver *driver,
const struct tty_operations *op);
@@ -332,6 +333,8 @@ extern struct tty_driver *tty_find_polling_driver(char *name, int *line);
extern void tty_driver_kref_put(struct tty_driver *driver);
+#define alloc_tty_driver(lines) __alloc_tty_driver(lines, THIS_MODULE)
+
static inline struct tty_driver *tty_driver_kref_get(struct tty_driver *d)
{
kref_get(&d->kref);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 04/68] TTY: remove minor_num from tty_driver
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (2 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 03/68] TTY: let alloc_tty_driver deduce the owner automatically Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 05/68] TTY: remove re-assignments to tty_driver members Jiri Slaby
` (65 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 05/68] TTY: remove re-assignments to tty_driver members
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (3 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 04/68] TTY: remove minor_num from tty_driver Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-06 23:49 ` Tilman Schmidt
2012-03-05 13:51 ` [PATCH 06/68] TTY: simplify tty_driver_lookup_tty a bit Jiri Slaby
` (64 subsequent siblings)
69 siblings, 1 reply; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 06/68] TTY: simplify tty_driver_lookup_tty a bit
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (4 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 05/68] TTY: remove re-assignments to tty_driver members Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 07/68] TTY: remove tty driver re-set from tty_reopen Jiri Slaby
` (63 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 07/68] TTY: remove tty driver re-set from tty_reopen
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (5 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 06/68] TTY: simplify tty_driver_lookup_tty a bit Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 08/68] TTY: serial, simplify ASYNC_USR_MASK Jiri Slaby
` (62 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 08/68] TTY: serial, simplify ASYNC_USR_MASK
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (6 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 07/68] TTY: remove tty driver re-set from tty_reopen Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 09/68] TTY: tty_driver, document tty->ops->shutdown limitation Jiri Slaby
` (61 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 09/68] TTY: tty_driver, document tty->ops->shutdown limitation
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (7 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 08/68] TTY: serial, simplify ASYNC_USR_MASK Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 10/68] ALPHA: srmcons, use timer functions Jiri Slaby
` (60 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:51 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
Note that tty->ops->shutdown is called from whatever context the user
drops the last tty reference from. E.g. if one takes a reference in
an ISR, tty close happens on other CPU and the final tty put is from
the ISR, tty->ops->shutdown will be called from that hard irq context.
We would have a problem in vt if we start using tty refcounting from
other contexts than user there. It is because vt's shutdown uses
mutexes. This is yet to be fixed.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Reported-by: Al Viro <viro@zeniv.linux.org.uk>
---
include/linux/tty_driver.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index e064f17..6e6dbb7 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -50,6 +50,8 @@
* Note that tty_shutdown() is not called if ops->shutdown is defined.
* This means one is responsible to take care of calling ops->remove (e.g.
* via tty_driver_remove_tty) and releasing tty->termios.
+ * Note that this hook may be called from *all* the contexts where one
+ * uses tty refcounting (e.g. tty_port_tty_get).
*
*
* void (*cleanup)(struct tty_struct * tty);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 10/68] ALPHA: srmcons, use timer functions
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (8 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 09/68] TTY: tty_driver, document tty->ops->shutdown limitation Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 11/68] ALPHA: srmcons, fix racy singleton structure Jiri Slaby
` (59 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
It makes the code more readable. We move the setup to the allocation
location because we need to initialize timers only once.
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 | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 783f4e5..f1fdf17 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -79,10 +79,8 @@ srmcons_receive_chars(unsigned long data)
}
spin_lock(&srmconsp->lock);
- if (srmconsp->tty) {
- srmconsp->timer.expires = jiffies + incr;
- add_timer(&srmconsp->timer);
- }
+ if (srmconsp->tty)
+ mod_timer(&srmconsp->timer, jiffies + incr);
spin_unlock(&srmconsp->lock);
local_irq_restore(flags);
@@ -172,7 +170,8 @@ srmcons_get_private_struct(struct srmcons_private **ps)
else {
srmconsp->tty = NULL;
spin_lock_init(&srmconsp->lock);
- init_timer(&srmconsp->timer);
+ setup_timer(&srmconsp->timer, srmcons_receive_chars,
+ (unsigned long)srmconsp);
}
spin_unlock_irqrestore(&srmconsp_lock, flags);
@@ -199,10 +198,7 @@ srmcons_open(struct tty_struct *tty, struct file *filp)
tty->driver_data = srmconsp;
srmconsp->tty = tty;
- srmconsp->timer.function = srmcons_receive_chars;
- srmconsp->timer.data = (unsigned long)srmconsp;
- srmconsp->timer.expires = jiffies + 10;
- add_timer(&srmconsp->timer);
+ mod_timer(&srmconsp->timer, jiffies + 10);
}
spin_unlock_irqrestore(&srmconsp->lock, flags);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 11/68] ALPHA: srmcons, fix racy singleton structure
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (9 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 10/68] ALPHA: srmcons, use timer functions Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:51 ` [PATCH 12/68] TTY: srmcons, convert to use tty_port Jiri Slaby
` (58 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
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 [flat|nested] 79+ messages in thread
* [PATCH 12/68] TTY: srmcons, convert to use tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (10 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 11/68] ALPHA: srmcons, fix racy singleton structure Jiri Slaby
@ 2012-03-05 13:51 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 13/68] TTY: serialP, remove DECLARE_WAITQUEUE check Jiri Slaby
` (57 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
This is needed because the tty buffer will become a tty_port member
later. That will help us to wipe out most of the races and checks for
the tty pointer in hot paths.
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 | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/arch/alpha/kernel/srmcons.c b/arch/alpha/kernel/srmcons.c
index 2c89ce5c..3ea8094 100644
--- a/arch/alpha/kernel/srmcons.c
+++ b/arch/alpha/kernel/srmcons.c
@@ -30,9 +30,8 @@ static int srm_is_registered_console = 0;
#define MAX_SRM_CONSOLE_DEVICES 1 /* only support 1 console device */
struct srmcons_private {
- struct tty_struct *tty;
+ struct tty_port port;
struct timer_list timer;
- spinlock_t lock;
} srmcons_singleton;
typedef union _srmcons_result {
@@ -68,20 +67,21 @@ static void
srmcons_receive_chars(unsigned long data)
{
struct srmcons_private *srmconsp = (struct srmcons_private *)data;
+ struct tty_port *port = &srmconsp->port;
unsigned long flags;
int incr = 10;
local_irq_save(flags);
if (spin_trylock(&srmcons_callback_lock)) {
- if (!srmcons_do_receive_chars(srmconsp->tty))
+ if (!srmcons_do_receive_chars(port->tty))
incr = 100;
spin_unlock(&srmcons_callback_lock);
}
- spin_lock(&srmconsp->lock);
- if (srmconsp->tty)
+ spin_lock(&port->lock);
+ if (port->tty)
mod_timer(&srmconsp->timer, jiffies + incr);
- spin_unlock(&srmconsp->lock);
+ spin_unlock(&port->lock);
local_irq_restore(flags);
}
@@ -157,18 +157,19 @@ static int
srmcons_open(struct tty_struct *tty, struct file *filp)
{
struct srmcons_private *srmconsp = &srmcons_singleton;
+ struct tty_port *port = &srmconsp->port;
unsigned long flags;
- spin_lock_irqsave(&srmconsp->lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
- if (!srmconsp->tty) {
+ if (!port->tty) {
tty->driver_data = srmconsp;
-
- srmconsp->tty = tty;
+ tty->port = port;
+ port->tty = tty; /* XXX proper refcounting */
mod_timer(&srmconsp->timer, jiffies + 10);
}
- spin_unlock_irqrestore(&srmconsp->lock, flags);
+ spin_unlock_irqrestore(&port->lock, flags);
return 0;
}
@@ -177,16 +178,17 @@ static void
srmcons_close(struct tty_struct *tty, struct file *filp)
{
struct srmcons_private *srmconsp = tty->driver_data;
+ struct tty_port *port = &srmconsp->port;
unsigned long flags;
- spin_lock_irqsave(&srmconsp->lock, flags);
+ spin_lock_irqsave(&port->lock, flags);
if (tty->count == 1) {
- srmconsp->tty = NULL;
+ port->tty = NULL;
del_timer(&srmconsp->timer);
}
- spin_unlock_irqrestore(&srmconsp->lock, flags);
+ spin_unlock_irqrestore(&port->lock, flags);
}
@@ -203,7 +205,7 @@ static const struct tty_operations srmcons_ops = {
static int __init
srmcons_init(void)
{
- spin_lock_init(&srmcons_singleton.lock);
+ tty_port_init(&srmcons_singleton.port);
setup_timer(&srmcons_singleton.timer, srmcons_receive_chars,
(unsigned long)&srmcons_singleton);
if (srm_is_registered_console) {
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 13/68] TTY: serialP, remove DECLARE_WAITQUEUE check
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (11 preceding siblings ...)
2012-03-05 13:51 ` [PATCH 12/68] TTY: srmcons, convert to use tty_port Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 14/68] TTY: remove unneeded tty->index checks Jiri Slaby
` (56 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 14/68] TTY: remove unneeded tty->index checks
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (12 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 13/68] TTY: serialP, remove DECLARE_WAITQUEUE check Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 15/68] TTY: ipwireless, fix tty->index handling Jiri Slaby
` (55 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 15/68] TTY: ipwireless, fix tty->index handling
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (13 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 14/68] TTY: remove unneeded tty->index checks Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 14:03 ` Jiri Kosina
2012-03-05 13:52 ` [PATCH 16/68] NET: pc300, do not zero global variables Jiri Slaby
` (54 subsequent siblings)
69 siblings, 1 reply; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Jiri Kosina,
David Sterba
* 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 [flat|nested] 79+ messages in thread
* [PATCH 16/68] NET: pc300, do not zero global variables
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (14 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 15/68] TTY: ipwireless, fix tty->index handling Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 17/68] NET: pc300, show version info from module init Jiri Slaby
` (53 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, netdev
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 [flat|nested] 79+ messages in thread
* [PATCH 17/68] NET: pc300, show version info from module init
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (15 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 16/68] NET: pc300, do not zero global variables Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 18/68] XTENSA: iss/console, use setup_timer Jiri Slaby
` (52 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, netdev
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 [flat|nested] 79+ messages in thread
* [PATCH 18/68] XTENSA: iss/console, use setup_timer
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (16 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 17/68] NET: pc300, show version info from module init Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 19/68] XTENSA: iss/console, fix potential deadlock Jiri Slaby
` (51 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
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 [flat|nested] 79+ messages in thread
* [PATCH 19/68] XTENSA: iss/console, fix potential deadlock
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (17 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 18/68] XTENSA: iss/console, use setup_timer Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 20/68] TTY: iss/console, use tty_port Jiri Slaby
` (50 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
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 [flat|nested] 79+ messages in thread
* [PATCH 20/68] TTY: iss/console, use tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (18 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 19/68] XTENSA: iss/console, fix potential deadlock Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 21/68] TTY: serial, use atomic_inc_return in ioc4_serial Jiri Slaby
` (49 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Chris Zankel
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 [flat|nested] 79+ messages in thread
* [PATCH 21/68] TTY: serial, use atomic_inc_return in ioc4_serial
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (19 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 20/68] TTY: iss/console, use tty_port Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 22/68] TTY: serial, include pci.h in m32r_sio Jiri Slaby
` (48 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 22/68] TTY: serial, include pci.h in m32r_sio
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (20 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 21/68] TTY: serial, use atomic_inc_return in ioc4_serial Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 23/68] TTY: remove serialP.h inclusion from some files Jiri Slaby
` (47 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
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 [flat|nested] 79+ messages in thread
* [PATCH 23/68] TTY: remove serialP.h inclusion from some files
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (21 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 22/68] TTY: serial, include pci.h in m32r_sio Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 24/68] TTY: speakup, do not use serialP Jiri Slaby
` (46 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby
All of them do not use the ugly interface defined in that header.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
arch/xtensa/platforms/iss/console.c | 1 -
drivers/tty/serial/ioc4_serial.c | 1 -
drivers/tty/serial/m32r_sio.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index d1a7861..f9726f6 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -19,7 +19,6 @@
#include <linux/param.h>
#include <linux/seq_file.h>
#include <linux/serial.h>
-#include <linux/serialP.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
index dfec69a..e16894f 100644
--- a/drivers/tty/serial/ioc4_serial.c
+++ b/drivers/tty/serial/ioc4_serial.c
@@ -16,7 +16,6 @@
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/serial.h>
-#include <linux/serialP.h>
#include <linux/circ_buf.h>
#include <linux/serial_reg.h>
#include <linux/module.h>
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c
index e465dda..a070362 100644
--- a/drivers/tty/serial/m32r_sio.c
+++ b/drivers/tty/serial/m32r_sio.c
@@ -38,7 +38,6 @@
#include <linux/console.h>
#include <linux/sysrq.h>
#include <linux/serial.h>
-#include <linux/serialP.h>
#include <linux/delay.h>
#include <asm/m32r.h>
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 24/68] TTY: speakup, do not use serialP
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (22 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 23/68] TTY: remove serialP.h inclusion from some files Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 25/68] TTY: serialP, remove unused material Jiri Slaby
` (45 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
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 [flat|nested] 79+ messages in thread
* [PATCH 25/68] TTY: serialP, remove unused material
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (23 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 24/68] TTY: speakup, do not use serialP Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 26/68] TTY: amiserial, remove tasklet for tty_wakeup Jiri Slaby
` (44 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
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 [flat|nested] 79+ messages in thread
* [PATCH 26/68] TTY: amiserial, remove tasklet for tty_wakeup
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (24 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 25/68] TTY: serialP, remove unused material Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 27/68] TTY: amiserial, use only one copy of async flags Jiri Slaby
` (43 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
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 [flat|nested] 79+ messages in thread
* [PATCH 27/68] TTY: amiserial, use only one copy of async flags
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (25 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 26/68] TTY: amiserial, remove tasklet for tty_wakeup Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 28/68] TTY: simserial, " Jiri Slaby
` (42 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
Huh, why would one want to store two copies of them? Get rid of the
one from async_struct. That structure is going away as a whole soon.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 82 ++++++++++++++++++++++-------------------------
1 file changed, 38 insertions(+), 44 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index d5fac86..8556ca0 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -45,7 +45,7 @@
#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
+ tty->name, (info->state->flags), serial_driver->refcount,info->count,tty->count,s)
#else
#define DBG_CNT(s)
#endif
@@ -297,7 +297,7 @@ static void receive_chars(struct async_struct *info)
printk("handling break....");
#endif
flag = TTY_BREAK;
- if (info->flags & ASYNC_SAK)
+ if (info->state->flags & ASYNC_SAK)
do_SAK(tty);
} else if (status & UART_LSR_PE)
flag = TTY_PARITY;
@@ -378,7 +378,7 @@ static void check_modem_status(struct async_struct *info)
if (dstatus & SER_DCD) {
icount->dcd++;
#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
+ if ((info->state->flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD))
hardpps();
#endif
@@ -388,7 +388,7 @@ static void check_modem_status(struct async_struct *info)
wake_up_interruptible(&info->delta_msr_wait);
}
- if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+ if ((info->state->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off");
@@ -403,7 +403,7 @@ static void check_modem_status(struct async_struct *info)
tty_hangup(info->tty);
}
}
- if (info->flags & ASYNC_CTS_FLOW) {
+ if (info->state->flags & ASYNC_CTS_FLOW) {
if (info->tty->hw_stopped) {
if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
@@ -516,7 +516,7 @@ static int startup(struct async_struct * info)
local_irq_save(flags);
- if (info->flags & ASYNC_INITIALIZED) {
+ if (info->state->flags & ASYNC_INITIALIZED) {
free_page(page);
goto errout;
}
@@ -569,13 +569,13 @@ static int 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 ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
info->tty->alt_speed = 57600;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
info->tty->alt_speed = 115200;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
info->tty->alt_speed = 230400;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
info->tty->alt_speed = 460800;
}
@@ -584,7 +584,7 @@ static int startup(struct async_struct * info)
*/
change_speed(info, NULL);
- info->flags |= ASYNC_INITIALIZED;
+ info->state->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
return 0;
@@ -602,7 +602,7 @@ static void shutdown(struct async_struct * info)
unsigned long flags;
struct serial_state *state;
- if (!(info->flags & ASYNC_INITIALIZED))
+ if (!(info->state->flags & ASYNC_INITIALIZED))
return;
state = info->state;
@@ -646,7 +646,7 @@ static void shutdown(struct async_struct * info)
if (info->tty)
set_bit(TTY_IO_ERROR, &info->tty->flags);
- info->flags &= ~ASYNC_INITIALIZED;
+ info->state->flags &= ~ASYNC_INITIALIZED;
local_irq_restore(flags);
}
@@ -691,7 +691,7 @@ static void change_speed(struct async_struct *info,
baud = 9600; /* B0 transition handled in rs_set_termios */
baud_base = info->state->baud_base;
if (baud == 38400 &&
- ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
quot = info->state->custom_divisor;
else {
if (baud == 134)
@@ -709,7 +709,7 @@ static void change_speed(struct async_struct *info,
if (!baud)
baud = 9600;
if (baud == 38400 &&
- ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
quot = info->state->custom_divisor;
else {
if (baud == 134)
@@ -728,17 +728,17 @@ static void change_speed(struct async_struct *info,
/* CTS flow control flag and modem status interrupts */
info->IER &= ~UART_IER_MSI;
- if (info->flags & ASYNC_HARDPPS_CD)
+ if (info->state->flags & ASYNC_HARDPPS_CD)
info->IER |= UART_IER_MSI;
if (cflag & CRTSCTS) {
- info->flags |= ASYNC_CTS_FLOW;
+ info->state->flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI;
} else
- info->flags &= ~ASYNC_CTS_FLOW;
+ info->state->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL)
- info->flags &= ~ASYNC_CHECK_CD;
+ info->state->flags &= ~ASYNC_CHECK_CD;
else {
- info->flags |= ASYNC_CHECK_CD;
+ info->state->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI;
}
/* TBD:
@@ -1080,8 +1080,6 @@ static int set_serial_info(struct async_struct * info,
return -EPERM;
state->flags = ((state->flags & ~ASYNC_USR_MASK) |
(new_serial.flags & ASYNC_USR_MASK));
- info->flags = ((info->flags & ~ASYNC_USR_MASK) |
- (new_serial.flags & ASYNC_USR_MASK));
state->custom_divisor = new_serial.custom_divisor;
goto check_and_exit;
}
@@ -1099,15 +1097,13 @@ static int set_serial_info(struct async_struct * info,
state->baud_base = new_serial.baud_base;
state->flags = ((state->flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS));
- info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) |
- (info->flags & ASYNC_INTERNAL_FLAGS));
state->custom_divisor = new_serial.custom_divisor;
state->close_delay = new_serial.close_delay * HZ/100;
state->closing_wait = new_serial.closing_wait * HZ/100;
- info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ info->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit:
- if (info->flags & ASYNC_INITIALIZED) {
+ if (state->flags & ASYNC_INITIALIZED) {
if (((old_state.flags & ASYNC_SPD_MASK) !=
(state->flags & ASYNC_SPD_MASK)) ||
(old_state.custom_divisor != state->custom_divisor)) {
@@ -1437,7 +1433,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;
/*
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
@@ -1452,7 +1448,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* line status register.
*/
info->read_status_mask &= ~UART_LSR_DR;
- if (info->flags & ASYNC_INITIALIZED) {
+ if (state->flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */
custom.intena = IF_RBF;
mb();
@@ -1479,7 +1475,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
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);
local_irq_restore(flags);
}
@@ -1563,7 +1559,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty);
shutdown(info);
state->count = 0;
- info->flags &= ~ASYNC_NORMAL_ACTIVE;
+ state->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = NULL;
wake_up_interruptible(&info->open_wait);
}
@@ -1591,11 +1587,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
* until it's done, and then try again.
*/
if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
+ (state->flags & ASYNC_CLOSING)) {
+ if (state->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ return ((state->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -1608,7 +1604,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
*/
if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
- info->flags |= ASYNC_NORMAL_ACTIVE;
+ state->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1642,9 +1638,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
- !(info->flags & ASYNC_INITIALIZED)) {
+ !(state->flags & ASYNC_INITIALIZED)) {
#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
+ if (state->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
@@ -1653,7 +1649,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif
break;
}
- if (!(info->flags & ASYNC_CLOSING) &&
+ if (!(state->flags & ASYNC_CLOSING) &&
(do_clocal || (!(ciab.pra & SER_DCD)) ))
break;
if (signal_pending(current)) {
@@ -1679,7 +1675,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif
if (retval)
return retval;
- info->flags |= ASYNC_NORMAL_ACTIVE;
+ state->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1705,7 +1701,6 @@ static int get_async_struct(int line, struct async_struct **ret_info)
init_waitqueue_head(&info->delta_msr_wait);
#endif
info->port = sstate->port;
- info->flags = sstate->flags;
info->xmit_fifo_size = sstate->xmit_fifo_size;
info->line = line;
info->state = sstate;
@@ -1741,17 +1736,17 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#ifdef SERIAL_DEBUG_OPEN
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 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;
@@ -1799,7 +1794,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->flags = state->flags;
info->quot = 0;
info->tty = NULL;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 28/68] TTY: simserial, use only one copy of async flags
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (26 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 27/68] TTY: amiserial, use only one copy of async flags Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 29/68] TTY: simserial/amiserial, use one instance of other members Jiri Slaby
` (41 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
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 [flat|nested] 79+ messages in thread
* [PATCH 29/68] TTY: simserial/amiserial, use one instance of other members
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (27 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 28/68] TTY: simserial, " Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 30/68] TTY: simserial, remove support of shared interrupts Jiri Slaby
` (40 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
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 [flat|nested] 79+ messages in thread
* [PATCH 30/68] TTY: simserial, remove support of shared interrupts
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (28 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 29/68] TTY: simserial/amiserial, use one instance of other members Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 31/68] TTY: simserial, remove IRQ_T Jiri Slaby
` (39 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
It never worked there. The ISR was never written for that kind of
stuff. So remove all that crap with a hash of linked lists and pass
the pointer directly to the ISR.
BTW this answers the question there:
* I don't know exactly why they don't use the dev_id opaque data
* pointer instead of this extra lookup table
-> Because they thought they will support more devices bound to a
single interrupt w/o IRQF_SHARED. They would need exactly the hash
there.
What I don't understand is rebinding of the interrupt in the shutdown
path. They perhaps meant to do just synchronize_irq? In any case, this
is all gone and free_irq there properly.
By removing the hash we save some bits (exactly NR_IRQS * 8 bytes of
.bss and over a kilo of .text):
before:
text data bss dec hex filename
19600 320 8227 28147 6df3 ../a/ia64/arch/ia64/hp/sim/simserial.o
after:
text data bss dec hex filename
18568 320 28 18916 49e4 ../a/ia64/arch/ia64/hp/sim/simserial.o
Note that a shared interrupt could not work too. request_irq requires
data parameter to be non-NULL. So the whole IRQ_T exercise was
pointless.
Finally, this helps us remove another two members of async_struct :).
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 | 64 +++++-------------------------------------
include/linux/serialP.h | 2 --
2 files changed, 7 insertions(+), 59 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index d32b759..c35552d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -92,8 +92,6 @@ static struct serial_uart_config uart_config[] = {
struct tty_driver *hp_simserial_driver;
-static struct async_struct *IRQ_ports[NR_IRQS];
-
static struct console *console;
static unsigned char *tmp_buf;
@@ -167,14 +165,9 @@ static void receive_chars(struct tty_struct *tty)
*/
static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
- struct async_struct * info;
+ struct async_struct *info = dev_id;
- /*
- * I don't know exactly why they don't use the dev_id opaque data
- * pointer instead of this extra lookup table
- */
- info = IRQ_ports[irq];
- if (!info || !info->tty) {
+ if (!info->tty) {
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
return IRQ_NONE;
}
@@ -456,7 +449,6 @@ static void shutdown(struct async_struct * info)
{
unsigned long flags;
struct serial_state *state = info->state;
- int retval;
if (!(state->flags & ASYNC_INITIALIZED))
return;
@@ -468,33 +460,8 @@ static void shutdown(struct async_struct * info)
local_irq_save(flags);
{
- /*
- * First unlink the serial port from the IRQ chain...
- */
- if (info->next_port)
- info->next_port->prev_port = info->prev_port;
- if (info->prev_port)
- info->prev_port->next_port = info->next_port;
- else
- IRQ_ports[state->irq] = info->next_port;
-
- /*
- * Free the IRQ, if necessary
- */
- if (state->irq && (!IRQ_ports[state->irq] ||
- !IRQ_ports[state->irq]->next_port)) {
- if (IRQ_ports[state->irq]) {
- free_irq(state->irq, NULL);
- retval = request_irq(state->irq, rs_interrupt_single,
- IRQ_T(state), "serial",
- NULL);
-
- if (retval)
- printk(KERN_ERR "serial shutdown: request_irq: error %d"
- " Couldn't reacquire IRQ.\n", retval);
- } else
- free_irq(state->irq, NULL);
- }
+ if (state->irq)
+ free_irq(state->irq, info);
if (info->xmit.buf) {
free_page((unsigned long) info->xmit.buf);
@@ -645,7 +612,6 @@ startup(struct async_struct *info)
{
unsigned long flags;
int retval=0;
- irq_handler_t handler;
struct serial_state *state= info->state;
unsigned long page;
@@ -677,29 +643,13 @@ startup(struct async_struct *info)
/*
* Allocate the IRQ if necessary
*/
- if (state->irq && (!IRQ_ports[state->irq] ||
- !IRQ_ports[state->irq]->next_port)) {
- if (IRQ_ports[state->irq]) {
- retval = -EBUSY;
- goto errout;
- } else
- handler = rs_interrupt_single;
-
- retval = request_irq(state->irq, handler, IRQ_T(state),
- "simserial", NULL);
+ if (state->irq) {
+ retval = request_irq(state->irq, rs_interrupt_single,
+ IRQ_T(state), "simserial", info);
if (retval)
goto errout;
}
- /*
- * Insert serial port into IRQ chain.
- */
- info->prev_port = NULL;
- info->next_port = IRQ_ports[state->irq];
- if (info->next_port)
- info->next_port->prev_port = info;
- IRQ_ports[state->irq] = info;
-
if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags);
info->xmit.head = info->xmit.tail = 0;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 6ce488c..b8543f9 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -56,8 +56,6 @@ struct async_struct {
wait_queue_head_t open_wait;
wait_queue_head_t close_wait;
wait_queue_head_t delta_msr_wait;
- struct async_struct *next_port; /* For the linked list */
- struct async_struct *prev_port;
};
#endif /* _LINUX_SERIAL_H */
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 31/68] TTY: simserial, remove IRQ_T
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (29 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 30/68] TTY: simserial, remove support of shared interrupts Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 32/68] TTY: amiserial, remove IRQ_ports Jiri Slaby
` (38 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
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 [flat|nested] 79+ messages in thread
* [PATCH 32/68] TTY: amiserial, remove IRQ_ports
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (30 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 31/68] TTY: simserial, remove IRQ_T Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 33/68] TTY: serialP, merge serial_state and async_struct Jiri Slaby
` (37 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
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 [flat|nested] 79+ messages in thread
* [PATCH 33/68] TTY: serialP, merge serial_state and async_struct
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (31 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 32/68] TTY: amiserial, remove IRQ_ports Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 34/68] TTY: amiserial, simplify set_serial_info Jiri Slaby
` (36 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
This is the final step to get rid of the one of the structures. A
further cleanup will follow. And I struct serial_state deserves cease
to exist after a switch to tty_port too.
While changing the lines, it removes also pointless tty->driver_data
casts.
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 | 160 +++++++++-------------
drivers/tty/amiserial.c | 301 +++++++++++++++++-------------------------
include/linux/serialP.h | 14 +-
3 files changed, 191 insertions(+), 284 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 8b5a134..7b6e60e 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -163,7 +163,7 @@ static void receive_chars(struct tty_struct *tty)
*/
static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
- struct async_struct *info = dev_id;
+ struct serial_state *info = dev_id;
if (!info->tty) {
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
@@ -185,7 +185,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
static int rs_put_char(struct tty_struct *tty, unsigned char ch)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (!tty || !info->xmit.buf)
@@ -202,12 +202,11 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
return 1;
}
-static void transmit_chars(struct async_struct *info, int *intr_done)
+static void transmit_chars(struct serial_state *info, int *intr_done)
{
int count;
unsigned long flags;
-
local_irq_save(flags);
if (info->x_char) {
@@ -215,7 +214,7 @@ static void transmit_chars(struct async_struct *info, int *intr_done)
console->write(console, &c, 1);
- info->state->icount.tx++;
+ info->icount.tx++;
info->x_char = 0;
goto out;
@@ -256,7 +255,7 @@ out:
static void rs_flush_chars(struct tty_struct *tty)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
if (info->xmit.head == info->xmit.tail || tty->stopped || tty->hw_stopped ||
!info->xmit.buf)
@@ -269,8 +268,8 @@ static void rs_flush_chars(struct tty_struct *tty)
static int rs_write(struct tty_struct * tty,
const unsigned char *buf, int count)
{
+ struct serial_state *info = tty->driver_data;
int c, ret = 0;
- struct async_struct *info = (struct async_struct *)tty->driver_data;
unsigned long flags;
if (!tty || !info->xmit.buf || !tmp_buf) return 0;
@@ -303,21 +302,21 @@ static int rs_write(struct tty_struct * tty,
static int rs_write_room(struct tty_struct *tty)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
}
static int rs_chars_in_buffer(struct tty_struct *tty)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
}
static void rs_flush_buffer(struct tty_struct *tty)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
local_irq_save(flags);
@@ -333,7 +332,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
*/
static void rs_send_xchar(struct tty_struct *tty, char ch)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
info->x_char = ch;
if (ch) {
@@ -362,7 +361,7 @@ static void rs_throttle(struct tty_struct * tty)
static void rs_unthrottle(struct tty_struct * tty)
{
- struct async_struct *info = (struct async_struct *)tty->driver_data;
+ struct serial_state *info = tty->driver_data;
if (I_IXOFF(tty)) {
if (info->x_char)
@@ -443,23 +442,22 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/
-static void shutdown(struct async_struct * info)
+static void shutdown(struct serial_state *info)
{
unsigned long flags;
- struct serial_state *state = info->state;
- if (!(state->flags & ASYNC_INITIALIZED))
+ if (!(info->flags & ASYNC_INITIALIZED))
return;
#ifdef SIMSERIAL_DEBUG
- printk("Shutting down serial port %d (irq %d)....", info->line,
- state->irq);
+ printk("Shutting down serial port %d (irq %d)...\n", info->line,
+ info->irq);
#endif
local_irq_save(flags);
{
- if (state->irq)
- free_irq(state->irq, info);
+ if (info->irq)
+ free_irq(info->irq, info);
if (info->xmit.buf) {
free_page((unsigned long) info->xmit.buf);
@@ -468,7 +466,7 @@ static void shutdown(struct async_struct * info)
if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
- state->flags &= ~ASYNC_INITIALIZED;
+ info->flags &= ~ASYNC_INITIALIZED;
}
local_irq_restore(flags);
}
@@ -485,13 +483,11 @@ static void shutdown(struct async_struct * info)
*/
static void rs_close(struct tty_struct *tty, struct file * filp)
{
- struct async_struct * info = (struct async_struct *)tty->driver_data;
- struct serial_state *state;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
- if (!info ) return;
-
- state = info->state;
+ if (!info)
+ return;
local_irq_save(flags);
if (tty_hung_up_p(filp)) {
@@ -502,30 +498,30 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
return;
}
#ifdef SIMSERIAL_DEBUG
- printk("rs_close ttys%d, count = %d\n", info->line, state->count);
+ printk("rs_close ttys%d, count = %d\n", info->line, info->count);
#endif
- if ((tty->count == 1) && (state->count != 1)) {
+ if ((tty->count == 1) && (info->count != 1)) {
/*
* Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->count should always
+ * structure will be freed. info->count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
- "state->count is %d\n", state->count);
- state->count = 1;
+ "info->count is %d\n", info->count);
+ info->count = 1;
}
- if (--state->count < 0) {
+ if (--info->count < 0) {
printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
- state->line, state->count);
- state->count = 0;
+ info->line, info->count);
+ info->count = 0;
}
- if (state->count) {
+ if (info->count) {
local_irq_restore(flags);
return;
}
- state->flags |= ASYNC_CLOSING;
+ info->flags |= ASYNC_CLOSING;
local_irq_restore(flags);
/*
@@ -537,11 +533,11 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty);
info->tty = NULL;
if (info->blocked_open) {
- if (state->close_delay)
- schedule_timeout_interruptible(state->close_delay);
+ if (info->close_delay)
+ schedule_timeout_interruptible(info->close_delay);
wake_up_interruptible(&info->open_wait);
}
- state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+ info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->close_wait);
}
@@ -558,59 +554,28 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
*/
static void rs_hangup(struct tty_struct *tty)
{
- struct async_struct * info = (struct async_struct *)tty->driver_data;
- struct serial_state *state = info->state;
+ struct serial_state *info = tty->driver_data;
#ifdef SIMSERIAL_DEBUG
printk("rs_hangup: called\n");
#endif
rs_flush_buffer(tty);
- if (state->flags & ASYNC_CLOSING)
+ if (info->flags & ASYNC_CLOSING)
return;
shutdown(info);
- state->count = 0;
- state->flags &= ~ASYNC_NORMAL_ACTIVE;
+ info->count = 0;
+ info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = NULL;
wake_up_interruptible(&info->open_wait);
}
-static int get_async_struct(int line, struct async_struct **ret_info)
-{
- struct async_struct *info;
- struct serial_state *sstate;
-
- sstate = rs_table + line;
- sstate->count++;
- if (sstate->info) {
- *ret_info = sstate->info;
- return 0;
- }
- info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
- if (!info) {
- sstate->count--;
- return -ENOMEM;
- }
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- info->state = sstate;
- if (sstate->info) {
- kfree(info);
- *ret_info = sstate->info;
- return 0;
- }
- *ret_info = sstate->info = info;
- return 0;
-}
-
-static int
-startup(struct async_struct *info)
+static int startup(struct serial_state *state)
{
unsigned long flags;
int retval=0;
- struct serial_state *state= info->state;
unsigned long page;
page = get_zeroed_page(GFP_KERNEL);
@@ -625,17 +590,18 @@ startup(struct async_struct *info)
}
if (!state->port || !state->type) {
- if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
+ if (state->tty)
+ set_bit(TTY_IO_ERROR, &state->tty->flags);
free_page(page);
goto errout;
}
- if (info->xmit.buf)
+ if (state->xmit.buf)
free_page(page);
else
- info->xmit.buf = (unsigned char *) page;
+ state->xmit.buf = (unsigned char *) page;
#ifdef SIMSERIAL_DEBUG
- printk("startup: ttys%d (irq %d)...", info->line, state->irq);
+ printk("startup: ttys%d (irq %d)...", state->line, state->irq);
#endif
/*
@@ -643,14 +609,15 @@ startup(struct async_struct *info)
*/
if (state->irq) {
retval = request_irq(state->irq, rs_interrupt_single, 0,
- "simserial", info);
+ "simserial", state);
if (retval)
goto errout;
}
- if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags);
+ if (state->tty)
+ clear_bit(TTY_IO_ERROR, &state->tty->flags);
- info->xmit.head = info->xmit.tail = 0;
+ state->xmit.head = state->xmit.tail = 0;
#if 0
/*
@@ -663,15 +630,15 @@ startup(struct async_struct *info)
/*
* Set up the tty->alt_speed kludge
*/
- if (info->tty) {
+ if (state->tty) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
+ state->tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
+ state->tty->alt_speed = 115200;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
+ state->tty->alt_speed = 230400;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
+ state->tty->alt_speed = 460800;
}
state->flags |= ASYNC_INITIALIZED;
@@ -692,20 +659,18 @@ errout:
*/
static int rs_open(struct tty_struct *tty, struct file * filp)
{
- struct async_struct *info;
+ struct serial_state *info = rs_table + tty->index;
int retval;
unsigned long page;
- retval = get_async_struct(tty->index, &info);
- if (retval)
- return retval;
- tty->driver_data = info;
+ info->count++;
info->tty = tty;
+ tty->driver_data = info;
#ifdef SIMSERIAL_DEBUG
- printk("rs_open %s, count = %d\n", tty->name, info->state->count);
+ printk("rs_open %s, count = %d\n", tty->name, info->count);
#endif
- info->tty->low_latency = (info->state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
if (!tmp_buf) {
page = get_zeroed_page(GFP_KERNEL);
@@ -720,12 +685,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->state->flags & ASYNC_CLOSING)) {
- if (info->state->flags & ASYNC_CLOSING)
+ if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
+ if (info->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->state->flags & ASYNC_HUP_NOTIFY) ?
+ return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -865,6 +829,8 @@ simrs_init (void)
* Let's have a little bit of fun !
*/
for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
+ init_waitqueue_head(&state->open_wait);
+ init_waitqueue_head(&state->close_wait);
if (state->type == PORT_UNKNOWN) continue;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7607c6e..410e8e7 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -45,7 +45,7 @@
#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- tty->name, (info->state->flags), serial_driver->refcount,info->count,tty->count,s)
+ tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
#else
#define DBG_CNT(s)
#endif
@@ -102,7 +102,7 @@ static struct tty_driver *serial_driver;
static unsigned char current_ctl_bits;
-static void change_speed(struct async_struct *info, struct ktermios *old);
+static void change_speed(struct serial_state *info, struct ktermios *old);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -115,7 +115,7 @@ static struct serial_state rs_table[1];
#define serial_isroot() (capable(CAP_SYS_ADMIN))
-static inline int serial_paranoia_check(struct async_struct *info,
+static inline int serial_paranoia_check(struct serial_state *info,
char *name, const char *routine)
{
#ifdef SERIAL_PARANOIA_CHECK
@@ -168,7 +168,7 @@ static __inline__ void rtsdtr_ctrl(int bits)
*/
static void rs_stop(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_stop"))
@@ -188,7 +188,7 @@ static void rs_stop(struct tty_struct *tty)
static void rs_start(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_start"))
@@ -229,7 +229,7 @@ static void rs_start(struct tty_struct *tty)
* -----------------------------------------------------------------------
*/
-static void receive_chars(struct async_struct *info)
+static void receive_chars(struct serial_state *info)
{
int status;
int serdatr;
@@ -238,7 +238,7 @@ static void receive_chars(struct async_struct *info)
struct async_icount *icount;
int oe = 0;
- icount = &info->state->icount;
+ icount = &info->icount;
status = UART_LSR_DR; /* We obviously have a character! */
serdatr = custom.serdatr;
@@ -295,7 +295,7 @@ static void receive_chars(struct async_struct *info)
printk("handling break....");
#endif
flag = TTY_BREAK;
- if (info->state->flags & ASYNC_SAK)
+ if (info->flags & ASYNC_SAK)
do_SAK(tty);
} else if (status & UART_LSR_PE)
flag = TTY_PARITY;
@@ -318,14 +318,14 @@ out:
return;
}
-static void transmit_chars(struct async_struct *info)
+static void transmit_chars(struct serial_state *info)
{
custom.intreq = IF_TBE;
mb();
if (info->x_char) {
custom.serdat = info->x_char | 0x100;
mb();
- info->state->icount.tx++;
+ info->icount.tx++;
info->x_char = 0;
return;
}
@@ -341,7 +341,7 @@ static void transmit_chars(struct async_struct *info)
custom.serdat = info->xmit.buf[info->xmit.tail++] | 0x100;
mb();
info->xmit.tail = info->xmit.tail & (SERIAL_XMIT_SIZE-1);
- info->state->icount.tx++;
+ info->icount.tx++;
if (CIRC_CNT(info->xmit.head,
info->xmit.tail,
@@ -358,7 +358,7 @@ static void transmit_chars(struct async_struct *info)
}
}
-static void check_modem_status(struct async_struct *info)
+static void check_modem_status(struct serial_state *info)
{
unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
unsigned char dstatus;
@@ -369,14 +369,14 @@ static void check_modem_status(struct async_struct *info)
current_ctl_bits = status;
if (dstatus) {
- icount = &info->state->icount;
+ icount = &info->icount;
/* update input line counters */
if (dstatus & SER_DSR)
icount->dsr++;
if (dstatus & SER_DCD) {
icount->dcd++;
#ifdef CONFIG_HARD_PPS
- if ((info->state->flags & ASYNC_HARDPPS_CD) &&
+ if ((info->flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD))
hardpps();
#endif
@@ -386,7 +386,7 @@ static void check_modem_status(struct async_struct *info)
wake_up_interruptible(&info->delta_msr_wait);
}
- if ((info->state->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+ if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off");
@@ -401,7 +401,7 @@ static void check_modem_status(struct async_struct *info)
tty_hangup(info->tty);
}
}
- if (info->state->flags & ASYNC_CTS_FLOW) {
+ if (info->flags & ASYNC_CTS_FLOW) {
if (info->tty->hw_stopped) {
if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
@@ -437,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 = data;
+ struct serial_state *info = data;
/*
* TBD - is it better to unregister from this interrupt or to
* ignore it if MSI is clear ?
@@ -449,14 +449,13 @@ static irqreturn_t ser_vbl_int( int irq, void *data)
static irqreturn_t ser_rx_int(int irq, void *dev_id)
{
- struct serial_state *state = dev_id;
- struct async_struct *info = state->info;
+ struct serial_state *info = dev_id;
#ifdef SERIAL_DEBUG_INTR
printk("ser_rx_int...");
#endif
- if (!info || !info->tty)
+ if (!info->tty)
return IRQ_NONE;
receive_chars(info);
@@ -468,15 +467,14 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
static irqreturn_t ser_tx_int(int irq, void *dev_id)
{
- struct serial_state *state = dev_id;
- struct async_struct *info = state->info;
+ struct serial_state *info = dev_id;
if (custom.serdatr & SDR_TBE) {
#ifdef SERIAL_DEBUG_INTR
printk("ser_tx_int...");
#endif
- if (!info || !info->tty)
+ if (!info->tty)
return IRQ_NONE;
transmit_chars(info);
@@ -502,7 +500,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
* ---------------------------------------------------------------
*/
-static int startup(struct async_struct * info)
+static int startup(struct serial_state *info)
{
unsigned long flags;
int retval=0;
@@ -514,7 +512,7 @@ static int startup(struct async_struct * info)
local_irq_save(flags);
- if (info->state->flags & ASYNC_INITIALIZED) {
+ if (info->flags & ASYNC_INITIALIZED) {
free_page(page);
goto errout;
}
@@ -565,13 +563,13 @@ static int startup(struct async_struct * info)
* Set up the tty->alt_speed kludge
*/
if (info->tty) {
- if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
info->tty->alt_speed = 57600;
- if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
info->tty->alt_speed = 115200;
- if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
info->tty->alt_speed = 230400;
- if ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
info->tty->alt_speed = 460800;
}
@@ -580,7 +578,7 @@ static int startup(struct async_struct * info)
*/
change_speed(info, NULL);
- info->state->flags |= ASYNC_INITIALIZED;
+ info->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
return 0;
@@ -593,15 +591,15 @@ errout:
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/
-static void shutdown(struct async_struct * info)
+static void shutdown(struct serial_state *info)
{
unsigned long flags;
struct serial_state *state;
- if (!(info->state->flags & ASYNC_INITIALIZED))
+ if (!(info->flags & ASYNC_INITIALIZED))
return;
- state = info->state;
+ state = info;
#ifdef SERIAL_DEBUG_OPEN
printk("Shutting down serial port %d ....\n", info->line);
@@ -640,7 +638,7 @@ static void shutdown(struct async_struct * info)
if (info->tty)
set_bit(TTY_IO_ERROR, &info->tty->flags);
- info->state->flags &= ~ASYNC_INITIALIZED;
+ info->flags &= ~ASYNC_INITIALIZED;
local_irq_restore(flags);
}
@@ -649,7 +647,7 @@ static void shutdown(struct async_struct * info)
* This routine is called to set the UART divisor registers to match
* the specified baud rate for a serial port.
*/
-static void change_speed(struct async_struct *info,
+static void change_speed(struct serial_state *info,
struct ktermios *old_termios)
{
int quot = 0, baud_base, baud;
@@ -683,10 +681,10 @@ static void change_speed(struct async_struct *info,
baud = tty_get_baud_rate(info->tty);
if (!baud)
baud = 9600; /* B0 transition handled in rs_set_termios */
- baud_base = info->state->baud_base;
+ baud_base = info->baud_base;
if (baud == 38400 &&
- ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
- quot = info->state->custom_divisor;
+ ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ quot = info->custom_divisor;
else {
if (baud == 134)
/* Special case since 134 is really 134.5 */
@@ -703,8 +701,8 @@ static void change_speed(struct async_struct *info,
if (!baud)
baud = 9600;
if (baud == 38400 &&
- ((info->state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
- quot = info->state->custom_divisor;
+ ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ quot = info->custom_divisor;
else {
if (baud == 134)
/* Special case since 134 is really 134.5 */
@@ -717,22 +715,22 @@ static void change_speed(struct async_struct *info,
if (!quot)
quot = baud_base / 9600;
info->quot = quot;
- info->timeout = ((info->state->xmit_fifo_size*HZ*bits*quot) / baud_base);
+ info->timeout = ((info->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 */
info->IER &= ~UART_IER_MSI;
- if (info->state->flags & ASYNC_HARDPPS_CD)
+ if (info->flags & ASYNC_HARDPPS_CD)
info->IER |= UART_IER_MSI;
if (cflag & CRTSCTS) {
- info->state->flags |= ASYNC_CTS_FLOW;
+ info->flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI;
} else
- info->state->flags &= ~ASYNC_CTS_FLOW;
+ info->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL)
- info->state->flags &= ~ASYNC_CHECK_CD;
+ info->flags &= ~ASYNC_CHECK_CD;
else {
- info->state->flags |= ASYNC_CHECK_CD;
+ info->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI;
}
/* TBD:
@@ -791,7 +789,7 @@ static void change_speed(struct async_struct *info,
static int rs_put_char(struct tty_struct *tty, unsigned char ch)
{
- struct async_struct *info;
+ struct serial_state *info;
unsigned long flags;
info = tty->driver_data;
@@ -818,7 +816,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
static void rs_flush_chars(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
@@ -843,11 +841,9 @@ static void rs_flush_chars(struct tty_struct *tty)
static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count)
{
int c, ret = 0;
- struct async_struct *info;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
- info = tty->driver_data;
-
if (serial_paranoia_check(info, tty->name, "rs_write"))
return 0;
@@ -891,7 +887,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count
static int rs_write_room(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
if (serial_paranoia_check(info, tty->name, "rs_write_room"))
return 0;
@@ -900,7 +896,7 @@ static int rs_write_room(struct tty_struct *tty)
static int rs_chars_in_buffer(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
return 0;
@@ -909,7 +905,7 @@ static int rs_chars_in_buffer(struct tty_struct *tty)
static void rs_flush_buffer(struct tty_struct *tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
@@ -926,7 +922,7 @@ static void rs_flush_buffer(struct tty_struct *tty)
*/
static void rs_send_xchar(struct tty_struct *tty, char ch)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_send_char"))
@@ -961,7 +957,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
*/
static void rs_throttle(struct tty_struct * tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE
char buf[64];
@@ -986,7 +982,7 @@ static void rs_throttle(struct tty_struct * tty)
static void rs_unthrottle(struct tty_struct * tty)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE
char buf[64];
@@ -1017,11 +1013,10 @@ static void rs_unthrottle(struct tty_struct * tty)
* ------------------------------------------------------------
*/
-static int get_serial_info(struct async_struct * info,
+static int get_serial_info(struct serial_state *state,
struct serial_struct __user * retinfo)
{
struct serial_struct tmp;
- struct serial_state *state = info->state;
if (!retinfo)
return -EFAULT;
@@ -1043,11 +1038,11 @@ static int get_serial_info(struct async_struct * info,
return 0;
}
-static int set_serial_info(struct async_struct * info,
+static int set_serial_info(struct serial_state *state,
struct serial_struct __user * new_info)
{
struct serial_struct new_serial;
- struct serial_state old_state, *state;
+ struct serial_state old_state;
unsigned int change_irq,change_port;
int retval = 0;
@@ -1055,7 +1050,6 @@ static int set_serial_info(struct async_struct * info,
return -EFAULT;
tty_lock();
- state = info->state;
old_state = *state;
change_irq = new_serial.irq != state->irq;
@@ -1094,7 +1088,7 @@ static int set_serial_info(struct async_struct * info,
state->custom_divisor = new_serial.custom_divisor;
state->close_delay = new_serial.close_delay * HZ/100;
state->closing_wait = new_serial.closing_wait * HZ/100;
- info->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ state->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit:
if (state->flags & ASYNC_INITIALIZED) {
@@ -1102,17 +1096,17 @@ check_and_exit:
(state->flags & ASYNC_SPD_MASK)) ||
(old_state.custom_divisor != state->custom_divisor)) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
+ state->tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
+ state->tty->alt_speed = 115200;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
+ state->tty->alt_speed = 230400;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
- change_speed(info, NULL);
+ state->tty->alt_speed = 460800;
+ change_speed(state, NULL);
}
} else
- retval = startup(info);
+ retval = startup(state);
tty_unlock();
return retval;
}
@@ -1128,7 +1122,7 @@ check_and_exit:
* transmit holding register is empty. This functionality
* allows an RS485 driver to be written in user space.
*/
-static int get_lsr_info(struct async_struct * info, unsigned int __user *value)
+static int get_lsr_info(struct serial_state *info, unsigned int __user *value)
{
unsigned char status;
unsigned int result;
@@ -1147,7 +1141,7 @@ static int get_lsr_info(struct async_struct * info, unsigned int __user *value)
static int rs_tiocmget(struct tty_struct *tty)
{
- struct async_struct * info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned char control, status;
unsigned long flags;
@@ -1170,7 +1164,7 @@ static int rs_tiocmget(struct tty_struct *tty)
static int rs_tiocmset(struct tty_struct *tty, unsigned int set,
unsigned int clear)
{
- struct async_struct * info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
@@ -1197,7 +1191,7 @@ static int rs_tiocmset(struct tty_struct *tty, unsigned int set,
*/
static int rs_break(struct tty_struct *tty, int break_state)
{
- struct async_struct * info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
if (serial_paranoia_check(info, tty->name, "rs_break"))
@@ -1222,12 +1216,12 @@ static int rs_break(struct tty_struct *tty, int break_state)
static int rs_get_icount(struct tty_struct *tty,
struct serial_icounter_struct *icount)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
struct async_icount cnow;
unsigned long flags;
local_irq_save(flags);
- cnow = info->state->icount;
+ cnow = info->icount;
local_irq_restore(flags);
icount->cts = cnow.cts;
icount->dsr = cnow.dsr;
@@ -1247,7 +1241,7 @@ static int rs_get_icount(struct tty_struct *tty,
static int rs_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
- struct async_struct * info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
struct async_icount cprev, cnow; /* kernel counter temps */
void __user *argp = (void __user *)arg;
unsigned long flags;
@@ -1275,7 +1269,7 @@ static int rs_ioctl(struct tty_struct *tty,
case TIOCSERGSTRUCT:
if (copy_to_user(argp,
- info, sizeof(struct async_struct)))
+ info, sizeof(struct serial_state)))
return -EFAULT;
return 0;
@@ -1288,7 +1282,7 @@ static int rs_ioctl(struct tty_struct *tty,
case TIOCMIWAIT:
local_irq_save(flags);
/* note the counters on entry */
- cprev = info->state->icount;
+ cprev = info->icount;
local_irq_restore(flags);
while (1) {
interruptible_sleep_on(&info->delta_msr_wait);
@@ -1296,7 +1290,7 @@ static int rs_ioctl(struct tty_struct *tty,
if (signal_pending(current))
return -ERESTARTSYS;
local_irq_save(flags);
- cnow = info->state->icount; /* atomic copy */
+ cnow = info->icount; /* atomic copy */
local_irq_restore(flags);
if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
@@ -1325,7 +1319,7 @@ static int rs_ioctl(struct tty_struct *tty,
static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
{
- struct async_struct *info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long flags;
unsigned int cflag = tty->termios->c_cflag;
@@ -1385,15 +1379,12 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
*/
static void rs_close(struct tty_struct *tty, struct file * filp)
{
- struct async_struct * info = tty->driver_data;
- struct serial_state *state;
+ struct serial_state *state = tty->driver_data;
unsigned long flags;
- if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
+ if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
return;
- state = info->state;
-
local_irq_save(flags);
if (tty_hung_up_p(filp)) {
@@ -1403,7 +1394,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", info->line, state->count);
+ printk("rs_close ttys%d, count = %d\n", state->line, state->count);
#endif
if ((tty->count == 1) && (state->count != 1)) {
/*
@@ -1441,7 +1432,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* interrupt driver to stop checking the data ready bit in the
* line status register.
*/
- info->read_status_mask &= ~UART_LSR_DR;
+ state->read_status_mask &= ~UART_LSR_DR;
if (state->flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */
custom.intena = IF_RBF;
@@ -1455,22 +1446,22 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* has completely drained; this is especially
* important if there is a transmit FIFO!
*/
- rs_wait_until_sent(tty, info->timeout);
+ rs_wait_until_sent(tty, state->timeout);
}
- shutdown(info);
+ shutdown(state);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
tty->closing = 0;
- info->tty = NULL;
- if (info->blocked_open) {
+ state->tty = NULL;
+ if (state->blocked_open) {
if (state->close_delay) {
msleep_interruptible(jiffies_to_msecs(state->close_delay));
}
- wake_up_interruptible(&info->open_wait);
+ wake_up_interruptible(&state->open_wait);
}
state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&info->close_wait);
+ wake_up_interruptible(&state->close_wait);
local_irq_restore(flags);
}
@@ -1479,14 +1470,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
*/
static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
{
- struct async_struct * info = tty->driver_data;
+ struct serial_state *info = tty->driver_data;
unsigned long orig_jiffies, char_time;
int lsr;
if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
return;
- if (info->state->xmit_fifo_size == 0)
+ if (info->xmit_fifo_size == 0)
return; /* Just in case.... */
orig_jiffies = jiffies;
@@ -1499,7 +1490,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->state->xmit_fifo_size;
+ char_time = (info->timeout - HZ/50) / info->xmit_fifo_size;
char_time = char_time / 5;
if (char_time == 0)
char_time = 1;
@@ -1542,18 +1533,15 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
*/
static void rs_hangup(struct tty_struct *tty)
{
- struct async_struct * info = tty->driver_data;
- struct serial_state *state = info->state;
+ struct serial_state *info = tty->driver_data;
if (serial_paranoia_check(info, tty->name, "rs_hangup"))
return;
- state = info->state;
-
rs_flush_buffer(tty);
shutdown(info);
- state->count = 0;
- state->flags &= ~ASYNC_NORMAL_ACTIVE;
+ info->count = 0;
+ info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = NULL;
wake_up_interruptible(&info->open_wait);
}
@@ -1564,14 +1552,13 @@ static void rs_hangup(struct tty_struct *tty)
* ------------------------------------------------------------
*/
static int block_til_ready(struct tty_struct *tty, struct file * filp,
- struct async_struct *info)
+ struct serial_state *info)
{
#ifdef DECLARE_WAITQUEUE
DECLARE_WAITQUEUE(wait, current);
#else
struct wait_queue wait = { current, NULL };
#endif
- struct serial_state *state = info->state;
int retval;
int do_clocal = 0, extra_count = 0;
unsigned long flags;
@@ -1581,11 +1568,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
* until it's done, and then try again.
*/
if (tty_hung_up_p(filp) ||
- (state->flags & ASYNC_CLOSING)) {
- if (state->flags & ASYNC_CLOSING)
+ (info->flags & ASYNC_CLOSING)) {
+ if (info->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((state->flags & ASYNC_HUP_NOTIFY) ?
+ return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -1598,7 +1585,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
*/
if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
- state->flags |= ASYNC_NORMAL_ACTIVE;
+ info->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1608,7 +1595,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
- * this loop, state->count is dropped by one, so that
+ * this loop, info->count is dropped by one, so that
* rs_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/
@@ -1616,12 +1603,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
add_wait_queue(&info->open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: ttys%d, count = %d\n",
- state->line, state->count);
+ info->line, info->count);
#endif
local_irq_save(flags);
if (!tty_hung_up_p(filp)) {
extra_count = 1;
- state->count--;
+ info->count--;
}
local_irq_restore(flags);
info->blocked_open++;
@@ -1632,9 +1619,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
- !(state->flags & ASYNC_INITIALIZED)) {
+ !(info->flags & ASYNC_INITIALIZED)) {
#ifdef SERIAL_DO_RESTART
- if (state->flags & ASYNC_HUP_NOTIFY)
+ if (info->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
@@ -1643,7 +1630,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif
break;
}
- if (!(state->flags & ASYNC_CLOSING) &&
+ if (!(info->flags & ASYNC_CLOSING) &&
(do_clocal || (!(ciab.pra & SER_DCD)) ))
break;
if (signal_pending(current)) {
@@ -1652,7 +1639,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
}
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, state->count);
+ info->line, info->count);
#endif
tty_unlock();
schedule();
@@ -1661,46 +1648,15 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
__set_current_state(TASK_RUNNING);
remove_wait_queue(&info->open_wait, &wait);
if (extra_count)
- state->count++;
+ info->count++;
info->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, state->count);
+ info->line, info->count);
#endif
if (retval)
return retval;
- state->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
-}
-
-static int get_async_struct(int line, struct async_struct **ret_info)
-{
- struct async_struct *info;
- struct serial_state *sstate;
-
- sstate = rs_table + line;
- sstate->count++;
- if (sstate->info) {
- *ret_info = sstate->info;
- return 0;
- }
- info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
- if (!info) {
- sstate->count--;
- return -ENOMEM;
- }
-#ifdef DECLARE_WAITQUEUE
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- init_waitqueue_head(&info->delta_msr_wait);
-#endif
- info->state = sstate;
- if (sstate->info) {
- kfree(info);
- *ret_info = sstate->info;
- return 0;
- }
- *ret_info = sstate->info = info;
+ info->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1712,32 +1668,29 @@ 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;
+ struct serial_state *info = rs_table + tty->index;
int retval;
- retval = get_async_struct(tty->index, &info);
- if (retval) {
- return retval;
- }
- tty->driver_data = info;
+ info->count++;
info->tty = tty;
+ tty->driver_data = info;
if (serial_paranoia_check(info, tty->name, "rs_open"))
return -ENODEV;
#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s, count = %d\n", tty->name, info->state->count);
+ printk("rs_open %s, count = %d\n", tty->name, info->count);
#endif
- info->tty->low_latency = (info->state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
* If the port is the middle of closing, bail out now
*/
if (tty_hung_up_p(filp) ||
- (info->state->flags & ASYNC_CLOSING)) {
- if (info->state->flags & ASYNC_CLOSING)
+ (info->flags & ASYNC_CLOSING)) {
+ if (info->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->state->flags & ASYNC_HUP_NOTIFY) ?
+ return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -1773,24 +1726,14 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
static inline void line_info(struct seq_file *m, struct serial_state *state)
{
- struct async_struct *info = state->info, scr_info;
char stat_buf[30], control, status;
unsigned long flags;
seq_printf(m, "%d: uart:amiga_builtin",state->line);
- /*
- * Figure out the current RS-232 lines
- */
- if (!info) {
- info = &scr_info; /* This is just for serial_{in,out} */
-
- info->quot = 0;
- info->tty = NULL;
- }
local_irq_save(flags);
status = ciab.pra;
- control = info ? info->MCR : status;
+ control = (state->flags & ASYNC_INITIALIZED) ? state->MCR : status;
local_irq_restore(flags);
stat_buf[0] = 0;
@@ -1806,9 +1749,8 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
if(!(status & SER_DCD))
strcat(stat_buf, "|CD");
- if (info->quot) {
- seq_printf(m, " baud:%d", state->baud_base / info->quot);
- }
+ if (state->quot)
+ seq_printf(m, " baud:%d", state->baud_base / state->quot);
seq_printf(m, " tx:%d rx:%d", state->icount.tx, state->icount.rx);
@@ -1938,6 +1880,9 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state->icount.rx = state->icount.tx = 0;
state->icount.frame = state->icount.parity = 0;
state->icount.overrun = state->icount.brk = 0;
+ init_waitqueue_head(&state->open_wait);
+ init_waitqueue_head(&state->close_wait);
+ init_waitqueue_head(&state->delta_msr_wait);
printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
state->line);
@@ -1993,7 +1938,6 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
{
int error;
struct serial_state *state = platform_get_drvdata(pdev);
- struct async_struct *info = state->info;
/* printk("Unloading %s: version %s\n", serial_name, serial_version); */
if ((error = tty_unregister_driver(serial_driver)))
@@ -2001,11 +1945,8 @@ static int __exit amiga_serial_remove(struct platform_device *pdev)
error);
put_tty_driver(serial_driver);
- rs_table[0].info = NULL;
- kfree(info);
-
- free_irq(IRQ_AMIGA_TBE, rs_table);
- free_irq(IRQ_AMIGA_RBF, rs_table);
+ free_irq(IRQ_AMIGA_TBE, state);
+ free_irq(IRQ_AMIGA_RBF, state);
platform_set_drvdata(pdev, NULL);
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index b8543f9..984f5ba 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -38,24 +38,24 @@ struct serial_state {
unsigned short close_delay;
unsigned short closing_wait; /* time to wait before closing */
struct async_icount icount;
- struct async_struct *info;
-};
-struct async_struct {
- struct serial_state *state;
- struct tty_struct *tty;
+ /* amiserial */
int read_status_mask;
int ignore_status_mask;
int timeout;
int quot;
- int x_char; /* xon/xoff character */
int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */
+ wait_queue_head_t delta_msr_wait;
+ /* simserial */
+ int x_char; /* xon/xoff character */
int blocked_open; /* # of blocked opens */
struct circ_buf xmit;
wait_queue_head_t open_wait;
wait_queue_head_t close_wait;
- wait_queue_head_t delta_msr_wait;
+ struct tty_struct *tty;
+ /* /simserial */
+ /* /amiserial */
};
#endif /* _LINUX_SERIAL_H */
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 34/68] TTY: amiserial, simplify set_serial_info
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (32 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 33/68] TTY: serialP, merge serial_state and async_struct Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 35/68] TTY: amiserial, pass tty down to functions Jiri Slaby
` (35 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
Do not copy whole serial_state. We only need to know whether the speed
is to be changed. Hence store the info in advance and use it later.
A simple bool is enough.
Also remove reduntant assignments and move the tests directly to the
'if'.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 410e8e7..165cd79 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1042,21 +1042,19 @@ static int set_serial_info(struct serial_state *state,
struct serial_struct __user * new_info)
{
struct serial_struct new_serial;
- struct serial_state old_state;
- unsigned int change_irq,change_port;
+ bool change_spd;
int retval = 0;
if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
return -EFAULT;
tty_lock();
- old_state = *state;
-
- change_irq = new_serial.irq != state->irq;
- change_port = (new_serial.port != state->port);
- if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) {
- tty_unlock();
- return -EINVAL;
+ change_spd = ((new_serial.flags ^ state->flags) & ASYNC_SPD_MASK) ||
+ new_serial.custom_divisor != state->custom_divisor;
+ if (new_serial.irq != state->irq || new_serial.port != state->port ||
+ new_serial.xmit_fifo_size != state->xmit_fifo_size) {
+ tty_unlock();
+ return -EINVAL;
}
if (!serial_isroot()) {
@@ -1092,9 +1090,7 @@ static int set_serial_info(struct serial_state *state,
check_and_exit:
if (state->flags & ASYNC_INITIALIZED) {
- if (((old_state.flags & ASYNC_SPD_MASK) !=
- (state->flags & ASYNC_SPD_MASK)) ||
- (old_state.custom_divisor != state->custom_divisor)) {
+ if (change_spd) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
state->tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 35/68] TTY: amiserial, pass tty down to functions
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (33 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 34/68] TTY: amiserial, simplify set_serial_info Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 36/68] TTY: simserial, " Jiri Slaby
` (34 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
This avoids pain with tty refcounting and touching tty_port in the
future. It allows us to remove some info->tty tests because the tty
passed down to them can never be NULL.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 91 ++++++++++++++++++++++-------------------------
1 file changed, 42 insertions(+), 49 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 165cd79..5b87744 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -102,7 +102,8 @@ static struct tty_driver *serial_driver;
static unsigned char current_ctl_bits;
-static void change_speed(struct serial_state *info, struct ktermios *old);
+static void change_speed(struct tty_struct *tty, struct serial_state *info,
+ struct ktermios *old);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -500,7 +501,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
* ---------------------------------------------------------------
*/
-static int startup(struct serial_state *info)
+static int startup(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
int retval=0;
@@ -534,9 +535,7 @@ static int startup(struct serial_state *info)
retval = request_irq(IRQ_AMIGA_VERTB, ser_vbl_int, 0, "serial status", info);
if (retval) {
if (serial_isroot()) {
- if (info->tty)
- set_bit(TTY_IO_ERROR,
- &info->tty->flags);
+ set_bit(TTY_IO_ERROR, &tty->flags);
retval = 0;
}
goto errout;
@@ -551,32 +550,29 @@ static int startup(struct serial_state *info)
current_ctl_bits = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
info->MCR = 0;
- if (info->tty->termios->c_cflag & CBAUD)
+ if (C_BAUD(tty))
info->MCR = SER_DTR | SER_RTS;
rtsdtr_ctrl(info->MCR);
- if (info->tty)
- clear_bit(TTY_IO_ERROR, &info->tty->flags);
+ clear_bit(TTY_IO_ERROR, &tty->flags);
info->xmit.head = info->xmit.tail = 0;
/*
* Set up the tty->alt_speed kludge
*/
- if (info->tty) {
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
- }
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ tty->alt_speed = 57600;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ tty->alt_speed = 115200;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ tty->alt_speed = 230400;
+ if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ tty->alt_speed = 460800;
/*
* and set the speed of the serial port
*/
- change_speed(info, NULL);
+ change_speed(tty, info, NULL);
info->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
@@ -591,7 +587,7 @@ errout:
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/
-static void shutdown(struct serial_state *info)
+static void shutdown(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
struct serial_state *state;
@@ -631,12 +627,11 @@ static void shutdown(struct serial_state *info)
custom.adkcon = AC_UARTBRK;
mb();
- if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+ if (tty->termios->c_cflag & HUPCL)
info->MCR &= ~(SER_DTR|SER_RTS);
rtsdtr_ctrl(info->MCR);
- if (info->tty)
- set_bit(TTY_IO_ERROR, &info->tty->flags);
+ set_bit(TTY_IO_ERROR, &tty->flags);
info->flags &= ~ASYNC_INITIALIZED;
local_irq_restore(flags);
@@ -647,7 +642,7 @@ static void shutdown(struct serial_state *info)
* This routine is called to set the UART divisor registers to match
* the specified baud rate for a serial port.
*/
-static void change_speed(struct serial_state *info,
+static void change_speed(struct tty_struct *tty, struct serial_state *info,
struct ktermios *old_termios)
{
int quot = 0, baud_base, baud;
@@ -655,9 +650,7 @@ static void change_speed(struct serial_state *info,
int bits;
unsigned long flags;
- if (!info->tty || !info->tty->termios)
- return;
- cflag = info->tty->termios->c_cflag;
+ cflag = tty->termios->c_cflag;
/* Byte size is always 8 bits plus parity bit if requested */
@@ -678,7 +671,7 @@ static void change_speed(struct serial_state *info,
#endif
/* Determine divisor based on baud rate */
- baud = tty_get_baud_rate(info->tty);
+ baud = tty_get_baud_rate(tty);
if (!baud)
baud = 9600; /* B0 transition handled in rs_set_termios */
baud_base = info->baud_base;
@@ -695,9 +688,9 @@ static void change_speed(struct serial_state *info,
/* If the quotient is zero refuse the change */
if (!quot && old_termios) {
/* FIXME: Will need updating for new tty in the end */
- info->tty->termios->c_cflag &= ~CBAUD;
- info->tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
- baud = tty_get_baud_rate(info->tty);
+ tty->termios->c_cflag &= ~CBAUD;
+ tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
+ baud = tty_get_baud_rate(tty);
if (!baud)
baud = 9600;
if (baud == 38400 &&
@@ -742,24 +735,24 @@ static void change_speed(struct serial_state *info,
*/
info->read_status_mask = UART_LSR_OE | UART_LSR_DR;
- if (I_INPCK(info->tty))
+ if (I_INPCK(tty))
info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
- if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
+ if (I_BRKINT(tty) || I_PARMRK(tty))
info->read_status_mask |= UART_LSR_BI;
/*
* Characters to ignore
*/
info->ignore_status_mask = 0;
- if (I_IGNPAR(info->tty))
+ if (I_IGNPAR(tty))
info->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
- if (I_IGNBRK(info->tty)) {
+ if (I_IGNBRK(tty)) {
info->ignore_status_mask |= UART_LSR_BI;
/*
* If we're ignore parity and break indicators, ignore
* overruns too. (For real raw support).
*/
- if (I_IGNPAR(info->tty))
+ if (I_IGNPAR(tty))
info->ignore_status_mask |= UART_LSR_OE;
}
/*
@@ -1038,7 +1031,7 @@ static int get_serial_info(struct serial_state *state,
return 0;
}
-static int set_serial_info(struct serial_state *state,
+static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
struct serial_struct __user * new_info)
{
struct serial_struct new_serial;
@@ -1086,23 +1079,23 @@ static int set_serial_info(struct serial_state *state,
state->custom_divisor = new_serial.custom_divisor;
state->close_delay = new_serial.close_delay * HZ/100;
state->closing_wait = new_serial.closing_wait * HZ/100;
- state->tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit:
if (state->flags & ASYNC_INITIALIZED) {
if (change_spd) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- state->tty->alt_speed = 57600;
+ tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- state->tty->alt_speed = 115200;
+ tty->alt_speed = 115200;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- state->tty->alt_speed = 230400;
+ tty->alt_speed = 230400;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- state->tty->alt_speed = 460800;
- change_speed(state, NULL);
+ tty->alt_speed = 460800;
+ change_speed(tty, state, NULL);
}
} else
- retval = startup(state);
+ retval = startup(tty, state);
tty_unlock();
return retval;
}
@@ -1256,7 +1249,7 @@ static int rs_ioctl(struct tty_struct *tty,
case TIOCGSERIAL:
return get_serial_info(info, argp);
case TIOCSSERIAL:
- return set_serial_info(info, argp);
+ return set_serial_info(tty, info, argp);
case TIOCSERCONFIG:
return 0;
@@ -1319,7 +1312,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
unsigned long flags;
unsigned int cflag = tty->termios->c_cflag;
- change_speed(info, old_termios);
+ change_speed(tty, info, old_termios);
/* Handle transition to B0 status */
if ((old_termios->c_cflag & CBAUD) &&
@@ -1444,7 +1437,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
*/
rs_wait_until_sent(tty, state->timeout);
}
- shutdown(state);
+ shutdown(tty, state);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
@@ -1535,7 +1528,7 @@ static void rs_hangup(struct tty_struct *tty)
return;
rs_flush_buffer(tty);
- shutdown(info);
+ shutdown(tty, info);
info->count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tty = NULL;
@@ -1696,7 +1689,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
/*
* Start up serial port
*/
- retval = startup(info);
+ retval = startup(tty, info);
if (retval) {
return retval;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 36/68] TTY: simserial, pass tty down to functions
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (34 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 35/68] TTY: amiserial, pass tty down to functions Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 37/68] TTY: amiserial/simserial, use tty_port Jiri Slaby
` (33 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
This avoids pain with tty refcounting and touching tty_port in the
future. It allows us to remove some state->tty tests because the tty
passed down to them can never be NULL.
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 | 50 ++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 7b6e60e..a76a27e 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -202,7 +202,8 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
return 1;
}
-static void transmit_chars(struct serial_state *info, int *intr_done)
+static void transmit_chars(struct tty_struct *tty, struct serial_state *info,
+ int *intr_done)
{
int count;
unsigned long flags;
@@ -220,10 +221,11 @@ static void transmit_chars(struct serial_state *info, int *intr_done)
goto out;
}
- if (info->xmit.head == info->xmit.tail || info->tty->stopped || info->tty->hw_stopped) {
+ if (info->xmit.head == info->xmit.tail || tty->stopped ||
+ tty->hw_stopped) {
#ifdef SIMSERIAL_DEBUG
printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
- info->xmit.head, info->xmit.tail, info->tty->stopped);
+ info->xmit.head, info->xmit.tail, tty->stopped);
#endif
goto out;
}
@@ -261,7 +263,7 @@ static void rs_flush_chars(struct tty_struct *tty)
!info->xmit.buf)
return;
- transmit_chars(info, NULL);
+ transmit_chars(tty, info, NULL);
}
@@ -295,7 +297,7 @@ static int rs_write(struct tty_struct * tty,
*/
if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
&& !tty->stopped && !tty->hw_stopped) {
- transmit_chars(info, NULL);
+ transmit_chars(tty, info, NULL);
}
return ret;
}
@@ -340,7 +342,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
* I guess we could call console->write() directly but
* let's do that for now.
*/
- transmit_chars(info, NULL);
+ transmit_chars(tty, info, NULL);
}
}
@@ -442,7 +444,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/
-static void shutdown(struct serial_state *info)
+static void shutdown(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
@@ -464,7 +466,7 @@ static void shutdown(struct serial_state *info)
info->xmit.buf = NULL;
}
- if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
+ set_bit(TTY_IO_ERROR, &tty->flags);
info->flags &= ~ASYNC_INITIALIZED;
}
@@ -528,7 +530,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
*/
- shutdown(info);
+ shutdown(tty, info);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
info->tty = NULL;
@@ -563,7 +565,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty);
if (info->flags & ASYNC_CLOSING)
return;
- shutdown(info);
+ shutdown(tty, info);
info->count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
@@ -572,7 +574,7 @@ static void rs_hangup(struct tty_struct *tty)
}
-static int startup(struct serial_state *state)
+static int startup(struct tty_struct *tty, struct serial_state *state)
{
unsigned long flags;
int retval=0;
@@ -590,8 +592,7 @@ static int startup(struct serial_state *state)
}
if (!state->port || !state->type) {
- if (state->tty)
- set_bit(TTY_IO_ERROR, &state->tty->flags);
+ set_bit(TTY_IO_ERROR, &tty->flags);
free_page(page);
goto errout;
}
@@ -614,8 +615,7 @@ static int startup(struct serial_state *state)
goto errout;
}
- if (state->tty)
- clear_bit(TTY_IO_ERROR, &state->tty->flags);
+ clear_bit(TTY_IO_ERROR, &tty->flags);
state->xmit.head = state->xmit.tail = 0;
@@ -630,16 +630,14 @@ static int startup(struct serial_state *state)
/*
* Set up the tty->alt_speed kludge
*/
- if (state->tty) {
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- state->tty->alt_speed = 57600;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- state->tty->alt_speed = 115200;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- state->tty->alt_speed = 230400;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- state->tty->alt_speed = 460800;
- }
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ tty->alt_speed = 57600;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ tty->alt_speed = 115200;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ tty->alt_speed = 230400;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ tty->alt_speed = 460800;
state->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
@@ -699,7 +697,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
/*
* Start up serial port
*/
- retval = startup(info);
+ retval = startup(tty, info);
if (retval) {
return retval;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 37/68] TTY: amiserial/simserial, use tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (35 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 36/68] TTY: simserial, " Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 38/68] TTY: amiserial/simserial, use close delays from tty_port Jiri Slaby
` (32 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
Add tty_port to serial_state and start using common tty port members
from tty_port in amiserial and simserial. The rest will follow one by
one.
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 | 24 ++++++++--------
drivers/tty/amiserial.c | 63 +++++++++++++++++++++---------------------
include/linux/serialP.h | 7 ++---
3 files changed, 45 insertions(+), 49 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index a76a27e..614c091 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -165,7 +165,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
struct serial_state *info = dev_id;
- if (!info->tty) {
+ if (!info->tport.tty) {
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
return IRQ_NONE;
}
@@ -173,7 +173,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
* pretty simple in our case, because we only get interrupts
* on inbound traffic
*/
- receive_chars(info->tty);
+ receive_chars(info->tport.tty);
return IRQ_HANDLED;
}
@@ -533,14 +533,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
shutdown(tty, info);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
- info->tty = NULL;
- if (info->blocked_open) {
+ info->tport.tty = NULL;
+ if (info->tport.blocked_open) {
if (info->close_delay)
schedule_timeout_interruptible(info->close_delay);
- wake_up_interruptible(&info->open_wait);
+ wake_up_interruptible(&info->tport.open_wait);
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&info->close_wait);
+ wake_up_interruptible(&info->tport.close_wait);
}
/*
@@ -569,8 +569,8 @@ static void rs_hangup(struct tty_struct *tty)
info->count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
- info->tty = NULL;
- wake_up_interruptible(&info->open_wait);
+ info->tport.tty = NULL;
+ wake_up_interruptible(&info->tport.open_wait);
}
@@ -662,8 +662,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
unsigned long page;
info->count++;
- info->tty = tty;
+ info->tport.tty = tty;
tty->driver_data = info;
+ tty->port = &info->tport;
#ifdef SIMSERIAL_DEBUG
printk("rs_open %s, count = %d\n", tty->name, info->count);
@@ -685,7 +686,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
*/
if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
+ interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
@@ -827,8 +828,7 @@ simrs_init (void)
* Let's have a little bit of fun !
*/
for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
- init_waitqueue_head(&state->open_wait);
- init_waitqueue_head(&state->close_wait);
+ tty_port_init(&state->tport);
if (state->type == PORT_UNKNOWN) continue;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5b87744..71d3331 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -234,7 +234,7 @@ static void receive_chars(struct serial_state *info)
{
int status;
int serdatr;
- struct tty_struct *tty = info->tty;
+ struct tty_struct *tty = info->tport.tty;
unsigned char ch, flag;
struct async_icount *icount;
int oe = 0;
@@ -331,8 +331,8 @@ static void transmit_chars(struct serial_state *info)
return;
}
if (info->xmit.head == info->xmit.tail
- || info->tty->stopped
- || info->tty->hw_stopped) {
+ || info->tport.tty->stopped
+ || info->tport.tty->hw_stopped) {
info->IER &= ~UART_IER_THRI;
custom.intena = IF_TBE;
mb();
@@ -347,7 +347,7 @@ static void transmit_chars(struct serial_state *info)
if (CIRC_CNT(info->xmit.head,
info->xmit.tail,
SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
- tty_wakeup(info->tty);
+ tty_wakeup(info->tport.tty);
#ifdef SERIAL_DEBUG_INTR
printk("THRE...");
@@ -384,7 +384,7 @@ static void check_modem_status(struct serial_state *info)
}
if (dstatus & SER_CTS)
icount->cts++;
- wake_up_interruptible(&info->delta_msr_wait);
+ wake_up_interruptible(&info->tport.delta_msr_wait);
}
if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
@@ -393,29 +393,29 @@ static void check_modem_status(struct serial_state *info)
(!(status & SER_DCD)) ? "on" : "off");
#endif
if (!(status & SER_DCD))
- wake_up_interruptible(&info->open_wait);
+ wake_up_interruptible(&info->tport.open_wait);
else {
#ifdef SERIAL_DEBUG_OPEN
printk("doing serial hangup...");
#endif
- if (info->tty)
- tty_hangup(info->tty);
+ if (info->tport.tty)
+ tty_hangup(info->tport.tty);
}
}
if (info->flags & ASYNC_CTS_FLOW) {
- if (info->tty->hw_stopped) {
+ if (info->tport.tty->hw_stopped) {
if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx start...");
#endif
- info->tty->hw_stopped = 0;
+ info->tport.tty->hw_stopped = 0;
info->IER |= UART_IER_THRI;
custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
custom.intreq = IF_SETCLR | IF_TBE;
mb();
- tty_wakeup(info->tty);
+ tty_wakeup(info->tport.tty);
return;
}
} else {
@@ -423,7 +423,7 @@ static void check_modem_status(struct serial_state *info)
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx stop...");
#endif
- info->tty->hw_stopped = 1;
+ info->tport.tty->hw_stopped = 1;
info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */
custom.intena = IF_TBE;
@@ -456,7 +456,7 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
printk("ser_rx_int...");
#endif
- if (!info->tty)
+ if (!info->tport.tty)
return IRQ_NONE;
receive_chars(info);
@@ -475,7 +475,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
printk("ser_tx_int...");
#endif
- if (!info->tty)
+ if (!info->tport.tty)
return IRQ_NONE;
transmit_chars(info);
@@ -607,7 +607,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
* clear delta_msr_wait queue to avoid mem leaks: we may free the irq
* here so the queue might never be waken up
*/
- wake_up_interruptible(&info->delta_msr_wait);
+ wake_up_interruptible(&info->tport.delta_msr_wait);
/*
* Free the IRQ, if necessary
@@ -1274,7 +1274,7 @@ static int rs_ioctl(struct tty_struct *tty,
cprev = info->icount;
local_irq_restore(flags);
while (1) {
- interruptible_sleep_on(&info->delta_msr_wait);
+ interruptible_sleep_on(&info->tport.delta_msr_wait);
/* see if a signal did it */
if (signal_pending(current))
return -ERESTARTSYS;
@@ -1442,15 +1442,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty);
tty->closing = 0;
- state->tty = NULL;
- if (state->blocked_open) {
+ state->tport.tty = NULL;
+ if (state->tport.blocked_open) {
if (state->close_delay) {
msleep_interruptible(jiffies_to_msecs(state->close_delay));
}
- wake_up_interruptible(&state->open_wait);
+ wake_up_interruptible(&state->tport.open_wait);
}
state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&state->close_wait);
+ wake_up_interruptible(&state->tport.close_wait);
local_irq_restore(flags);
}
@@ -1531,8 +1531,8 @@ static void rs_hangup(struct tty_struct *tty)
shutdown(tty, info);
info->count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
- info->tty = NULL;
- wake_up_interruptible(&info->open_wait);
+ info->tport.tty = NULL;
+ wake_up_interruptible(&info->tport.open_wait);
}
/*
@@ -1559,7 +1559,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
if (tty_hung_up_p(filp) ||
(info->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
+ interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
@@ -1589,7 +1589,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
* exit, either normal or abnormal.
*/
retval = 0;
- add_wait_queue(&info->open_wait, &wait);
+ add_wait_queue(&info->tport.open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: ttys%d, count = %d\n",
info->line, info->count);
@@ -1600,7 +1600,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
info->count--;
}
local_irq_restore(flags);
- info->blocked_open++;
+ info->tport.blocked_open++;
while (1) {
local_irq_save(flags);
if (tty->termios->c_cflag & CBAUD)
@@ -1635,10 +1635,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
tty_lock();
}
__set_current_state(TASK_RUNNING);
- remove_wait_queue(&info->open_wait, &wait);
+ remove_wait_queue(&info->tport.open_wait, &wait);
if (extra_count)
info->count++;
- info->blocked_open--;
+ info->tport.blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: ttys%d, count = %d\n",
info->line, info->count);
@@ -1661,8 +1661,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
int retval;
info->count++;
- info->tty = tty;
+ info->tport.tty = tty;
tty->driver_data = info;
+ tty->port = &info->tport;
if (serial_paranoia_check(info, tty->name, "rs_open"))
return -ENODEV;
@@ -1677,7 +1678,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
if (tty_hung_up_p(filp) ||
(info->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
+ interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
@@ -1869,9 +1870,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state->icount.rx = state->icount.tx = 0;
state->icount.frame = state->icount.parity = 0;
state->icount.overrun = state->icount.brk = 0;
- init_waitqueue_head(&state->open_wait);
- init_waitqueue_head(&state->close_wait);
- init_waitqueue_head(&state->delta_msr_wait);
+ tty_port_init(&state->tport);
printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
state->line);
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 984f5ba..32d45b8 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -23,6 +23,7 @@
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#include <linux/circ_buf.h>
+#include <linux/tty.h>
#include <linux/wait.h>
struct serial_state {
@@ -38,6 +39,7 @@ struct serial_state {
unsigned short close_delay;
unsigned short closing_wait; /* time to wait before closing */
struct async_icount icount;
+ struct tty_port tport;
/* amiserial */
int read_status_mask;
@@ -46,14 +48,9 @@ struct serial_state {
int quot;
int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */
- wait_queue_head_t delta_msr_wait;
/* simserial */
int x_char; /* xon/xoff character */
- int blocked_open; /* # of blocked opens */
struct circ_buf xmit;
- wait_queue_head_t open_wait;
- wait_queue_head_t close_wait;
- struct tty_struct *tty;
/* /simserial */
/* /amiserial */
};
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 38/68] TTY: amiserial/simserial, use close delays from tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (36 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 37/68] TTY: amiserial/simserial, use tty_port Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 39/68] TTY: amiserial/simserial, use count " Jiri Slaby
` (31 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
Note that previously simserial set the delay to 0. So we preserve
that. BUT, is it correct?
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 | 5 +++--
drivers/tty/amiserial.c | 20 +++++++++-----------
include/linux/serialP.h | 2 --
3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 614c091..fb324b3 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -535,8 +535,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty);
info->tport.tty = NULL;
if (info->tport.blocked_open) {
- if (info->close_delay)
- schedule_timeout_interruptible(info->close_delay);
+ if (info->tport.close_delay)
+ schedule_timeout_interruptible(info->tport.close_delay);
wake_up_interruptible(&info->tport.open_wait);
}
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -829,6 +829,7 @@ simrs_init (void)
*/
for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
tty_port_init(&state->tport);
+ state->tport.close_delay = 0; /* XXX really 0? */
if (state->type == PORT_UNKNOWN) continue;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 71d3331..06e3a09 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1022,8 +1022,8 @@ static int get_serial_info(struct serial_state *state,
tmp.flags = state->flags;
tmp.xmit_fifo_size = state->xmit_fifo_size;
tmp.baud_base = state->baud_base;
- tmp.close_delay = state->close_delay;
- tmp.closing_wait = state->closing_wait;
+ tmp.close_delay = state->tport.close_delay;
+ tmp.closing_wait = state->tport.closing_wait;
tmp.custom_divisor = state->custom_divisor;
tty_unlock();
if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
@@ -1052,7 +1052,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
if (!serial_isroot()) {
if ((new_serial.baud_base != state->baud_base) ||
- (new_serial.close_delay != state->close_delay) ||
+ (new_serial.close_delay != state->tport.close_delay) ||
(new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
((new_serial.flags & ~ASYNC_USR_MASK) !=
(state->flags & ~ASYNC_USR_MASK)))
@@ -1077,8 +1077,8 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
state->flags = ((state->flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS));
state->custom_divisor = new_serial.custom_divisor;
- state->close_delay = new_serial.close_delay * HZ/100;
- state->closing_wait = new_serial.closing_wait * HZ/100;
+ state->tport.close_delay = new_serial.close_delay * HZ/100;
+ state->tport.closing_wait = new_serial.closing_wait * HZ/100;
tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit:
@@ -1413,8 +1413,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 (state->closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, state->closing_wait);
+ if (state->tport.closing_wait != ASYNC_CLOSING_WAIT_NONE)
+ tty_wait_until_sent(tty, state->tport.closing_wait);
/*
* At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the
@@ -1444,8 +1444,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty->closing = 0;
state->tport.tty = NULL;
if (state->tport.blocked_open) {
- if (state->close_delay) {
- msleep_interruptible(jiffies_to_msecs(state->close_delay));
+ if (state->tport.close_delay) {
+ msleep_interruptible(jiffies_to_msecs(state->tport.close_delay));
}
wake_up_interruptible(&state->tport.open_wait);
}
@@ -1863,8 +1863,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state->port = (int)&custom.serdatr; /* Just to give it a value */
state->line = 0;
state->custom_divisor = 0;
- state->close_delay = 5*HZ/10;
- state->closing_wait = 30*HZ;
state->icount.cts = state->icount.dsr =
state->icount.rng = state->icount.dcd = 0;
state->icount.rx = state->icount.tx = 0;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 32d45b8..997edd0 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -36,8 +36,6 @@ struct serial_state {
int xmit_fifo_size;
int custom_divisor;
int count;
- unsigned short close_delay;
- unsigned short closing_wait; /* time to wait before closing */
struct async_icount icount;
struct tty_port tport;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 39/68] TTY: amiserial/simserial, use count from tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (37 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 38/68] TTY: amiserial/simserial, use close delays from tty_port Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 40/68] TTY: amiserial/simserial, use flags " Jiri Slaby
` (30 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
Nothing special. Just remove count from serial_state and change all
users to use tty_port.
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 | 24 ++++++++++++------------
drivers/tty/amiserial.c | 34 +++++++++++++++++-----------------
include/linux/serialP.h | 1 -
3 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index fb324b3..baa2b1e 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -500,26 +500,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
return;
}
#ifdef SIMSERIAL_DEBUG
- printk("rs_close ttys%d, count = %d\n", info->line, info->count);
+ printk("rs_close ttys%d, count = %d\n", info->line, info->tport.count);
#endif
- if ((tty->count == 1) && (info->count != 1)) {
+ if ((tty->count == 1) && (info->tport.count != 1)) {
/*
* Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. info->count should always
+ * structure will be freed. info->tport.count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
- "info->count is %d\n", info->count);
- info->count = 1;
+ "info->tport.count is %d\n", info->tport.count);
+ info->tport.count = 1;
}
- if (--info->count < 0) {
+ if (--info->tport.count < 0) {
printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
- info->line, info->count);
- info->count = 0;
+ info->line, info->tport.count);
+ info->tport.count = 0;
}
- if (info->count) {
+ if (info->tport.count) {
local_irq_restore(flags);
return;
}
@@ -567,7 +567,7 @@ static void rs_hangup(struct tty_struct *tty)
return;
shutdown(tty, info);
- info->count = 0;
+ info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait);
@@ -661,13 +661,13 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
int retval;
unsigned long page;
- info->count++;
+ info->tport.count++;
info->tport.tty = tty;
tty->driver_data = info;
tty->port = &info->tport;
#ifdef SIMSERIAL_DEBUG
- printk("rs_open %s, count = %d\n", tty->name, info->count);
+ printk("rs_open %s, count = %d\n", tty->name, info->tport.count);
#endif
tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 06e3a09..8ad64a0 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1383,26 +1383,26 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", state->line, state->count);
+ printk("rs_close ttys%d, count = %d\n", state->line, state->tport.count);
#endif
- if ((tty->count == 1) && (state->count != 1)) {
+ if ((tty->count == 1) && (state->tport.count != 1)) {
/*
* Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->count should always
+ * structure will be freed. state->tport.count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
printk("rs_close: bad serial port count; tty->count is 1, "
- "state->count is %d\n", state->count);
- state->count = 1;
+ "state->tport.count is %d\n", state->tport.count);
+ state->tport.count = 1;
}
- if (--state->count < 0) {
+ if (--state->tport.count < 0) {
printk("rs_close: bad serial port count for ttys%d: %d\n",
- state->line, state->count);
- state->count = 0;
+ state->line, state->tport.count);
+ state->tport.count = 0;
}
- if (state->count) {
+ if (state->tport.count) {
DBG_CNT("before DEC-2");
local_irq_restore(flags);
return;
@@ -1529,7 +1529,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty);
shutdown(tty, info);
- info->count = 0;
+ info->tport.count = 0;
info->flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait);
@@ -1584,7 +1584,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
- * this loop, info->count is dropped by one, so that
+ * this loop, info->tport.count is dropped by one, so that
* rs_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/
@@ -1592,12 +1592,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
add_wait_queue(&info->tport.open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: ttys%d, count = %d\n",
- info->line, info->count);
+ info->line, info->tport.count);
#endif
local_irq_save(flags);
if (!tty_hung_up_p(filp)) {
extra_count = 1;
- info->count--;
+ info->tport.count--;
}
local_irq_restore(flags);
info->tport.blocked_open++;
@@ -1628,7 +1628,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
}
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, info->count);
+ info->line, info->tport.count);
#endif
tty_unlock();
schedule();
@@ -1637,11 +1637,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
__set_current_state(TASK_RUNNING);
remove_wait_queue(&info->tport.open_wait, &wait);
if (extra_count)
- info->count++;
+ info->tport.count++;
info->tport.blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, info->count);
+ info->line, info->tport.count);
#endif
if (retval)
return retval;
@@ -1660,7 +1660,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
struct serial_state *info = rs_table + tty->index;
int retval;
- info->count++;
+ info->tport.count++;
info->tport.tty = tty;
tty->driver_data = info;
tty->port = &info->tport;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 997edd0..a6612b9 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -35,7 +35,6 @@ struct serial_state {
int line;
int xmit_fifo_size;
int custom_divisor;
- int count;
struct async_icount icount;
struct tty_port tport;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 40/68] TTY: amiserial/simserial, use flags from tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (38 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 39/68] TTY: amiserial/simserial, use count " Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 41/68] TTY: simserial, remove static initialization Jiri Slaby
` (29 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
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
This changes flags' type to ulong which is appropriate for all the
set/clear_bits performed in the drivers..
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 | 33 +++++------
drivers/tty/amiserial.c | 129 +++++++++++++++++++++---------------------
include/linux/serialP.h | 1 -
3 files changed, 83 insertions(+), 80 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index baa2b1e..c65c49d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -448,7 +448,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
- if (!(info->flags & ASYNC_INITIALIZED))
+ if (!(info->tport.flags & ASYNC_INITIALIZED))
return;
#ifdef SIMSERIAL_DEBUG
@@ -468,7 +468,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
set_bit(TTY_IO_ERROR, &tty->flags);
- info->flags &= ~ASYNC_INITIALIZED;
+ info->tport.flags &= ~ASYNC_INITIALIZED;
}
local_irq_restore(flags);
}
@@ -523,7 +523,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
local_irq_restore(flags);
return;
}
- info->flags |= ASYNC_CLOSING;
+ info->tport.flags |= ASYNC_CLOSING;
local_irq_restore(flags);
/*
@@ -539,7 +539,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
schedule_timeout_interruptible(info->tport.close_delay);
wake_up_interruptible(&info->tport.open_wait);
}
- info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+ info->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&info->tport.close_wait);
}
@@ -563,12 +563,12 @@ static void rs_hangup(struct tty_struct *tty)
#endif
rs_flush_buffer(tty);
- if (info->flags & ASYNC_CLOSING)
+ if (info->tport.flags & ASYNC_CLOSING)
return;
shutdown(tty, info);
info->tport.count = 0;
- info->flags &= ~ASYNC_NORMAL_ACTIVE;
+ info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait);
}
@@ -576,6 +576,7 @@ static void rs_hangup(struct tty_struct *tty)
static int startup(struct tty_struct *tty, struct serial_state *state)
{
+ struct tty_port *port = &state->tport;
unsigned long flags;
int retval=0;
unsigned long page;
@@ -586,7 +587,7 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
local_irq_save(flags);
- if (state->flags & ASYNC_INITIALIZED) {
+ if (port->flags & ASYNC_INITIALIZED) {
free_page(page);
goto errout;
}
@@ -630,16 +631,16 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
/*
* Set up the tty->alt_speed kludge
*/
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800;
- state->flags |= ASYNC_INITIALIZED;
+ port->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
return 0;
@@ -669,7 +670,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->tport.count);
#endif
- tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
if (!tmp_buf) {
page = get_zeroed_page(GFP_KERNEL);
@@ -684,11 +685,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)
+ if (tty_hung_up_p(filp) || (info->tport.flags & ASYNC_CLOSING)) {
+ if (info->tport.flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 8ad64a0..7d79826 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -45,7 +45,7 @@
#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
- tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
+ tty->name, (info->tport.flags), serial_driver->refcount,info->count,tty->count,s)
#else
#define DBG_CNT(s)
#endif
@@ -296,7 +296,7 @@ static void receive_chars(struct serial_state *info)
printk("handling break....");
#endif
flag = TTY_BREAK;
- if (info->flags & ASYNC_SAK)
+ if (info->tport.flags & ASYNC_SAK)
do_SAK(tty);
} else if (status & UART_LSR_PE)
flag = TTY_PARITY;
@@ -377,7 +377,7 @@ static void check_modem_status(struct serial_state *info)
if (dstatus & SER_DCD) {
icount->dcd++;
#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
+ if ((info->tport.flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD))
hardpps();
#endif
@@ -387,7 +387,7 @@ static void check_modem_status(struct serial_state *info)
wake_up_interruptible(&info->tport.delta_msr_wait);
}
- if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+ if ((info->tport.flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off");
@@ -402,7 +402,7 @@ static void check_modem_status(struct serial_state *info)
tty_hangup(info->tport.tty);
}
}
- if (info->flags & ASYNC_CTS_FLOW) {
+ if (info->tport.flags & ASYNC_CTS_FLOW) {
if (info->tport.tty->hw_stopped) {
if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
@@ -503,6 +503,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
static int startup(struct tty_struct *tty, struct serial_state *info)
{
+ struct tty_port *port = &info->tport;
unsigned long flags;
int retval=0;
unsigned long page;
@@ -513,7 +514,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
local_irq_save(flags);
- if (info->flags & ASYNC_INITIALIZED) {
+ if (port->flags & ASYNC_INITIALIZED) {
free_page(page);
goto errout;
}
@@ -560,13 +561,13 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
/*
* Set up the tty->alt_speed kludge
*/
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800;
/*
@@ -574,7 +575,7 @@ static int startup(struct tty_struct *tty, struct serial_state *info)
*/
change_speed(tty, info, NULL);
- info->flags |= ASYNC_INITIALIZED;
+ port->flags |= ASYNC_INITIALIZED;
local_irq_restore(flags);
return 0;
@@ -592,7 +593,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
unsigned long flags;
struct serial_state *state;
- if (!(info->flags & ASYNC_INITIALIZED))
+ if (!(info->tport.flags & ASYNC_INITIALIZED))
return;
state = info;
@@ -633,7 +634,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
set_bit(TTY_IO_ERROR, &tty->flags);
- info->flags &= ~ASYNC_INITIALIZED;
+ info->tport.flags &= ~ASYNC_INITIALIZED;
local_irq_restore(flags);
}
@@ -645,6 +646,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
static void change_speed(struct tty_struct *tty, struct serial_state *info,
struct ktermios *old_termios)
{
+ struct tty_port *port = &info->tport;
int quot = 0, baud_base, baud;
unsigned cflag, cval = 0;
int bits;
@@ -675,8 +677,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if (!baud)
baud = 9600; /* B0 transition handled in rs_set_termios */
baud_base = info->baud_base;
- if (baud == 38400 &&
- ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ if (baud == 38400 && (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
quot = info->custom_divisor;
else {
if (baud == 134)
@@ -694,7 +695,7 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
if (!baud)
baud = 9600;
if (baud == 38400 &&
- ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ (port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)
quot = info->custom_divisor;
else {
if (baud == 134)
@@ -713,17 +714,17 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
/* CTS flow control flag and modem status interrupts */
info->IER &= ~UART_IER_MSI;
- if (info->flags & ASYNC_HARDPPS_CD)
+ if (port->flags & ASYNC_HARDPPS_CD)
info->IER |= UART_IER_MSI;
if (cflag & CRTSCTS) {
- info->flags |= ASYNC_CTS_FLOW;
+ port->flags |= ASYNC_CTS_FLOW;
info->IER |= UART_IER_MSI;
} else
- info->flags &= ~ASYNC_CTS_FLOW;
+ port->flags &= ~ASYNC_CTS_FLOW;
if (cflag & CLOCAL)
- info->flags &= ~ASYNC_CHECK_CD;
+ port->flags &= ~ASYNC_CHECK_CD;
else {
- info->flags |= ASYNC_CHECK_CD;
+ port->flags |= ASYNC_CHECK_CD;
info->IER |= UART_IER_MSI;
}
/* TBD:
@@ -1019,7 +1020,7 @@ static int get_serial_info(struct serial_state *state,
tmp.line = state->line;
tmp.port = state->port;
tmp.irq = state->irq;
- tmp.flags = state->flags;
+ tmp.flags = state->tport.flags;
tmp.xmit_fifo_size = state->xmit_fifo_size;
tmp.baud_base = state->baud_base;
tmp.close_delay = state->tport.close_delay;
@@ -1034,6 +1035,7 @@ static int get_serial_info(struct serial_state *state,
static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
struct serial_struct __user * new_info)
{
+ struct tty_port *port = &state->tport;
struct serial_struct new_serial;
bool change_spd;
int retval = 0;
@@ -1042,7 +1044,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
return -EFAULT;
tty_lock();
- change_spd = ((new_serial.flags ^ state->flags) & ASYNC_SPD_MASK) ||
+ change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
new_serial.custom_divisor != state->custom_divisor;
if (new_serial.irq != state->irq || new_serial.port != state->port ||
new_serial.xmit_fifo_size != state->xmit_fifo_size) {
@@ -1052,12 +1054,12 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
if (!serial_isroot()) {
if ((new_serial.baud_base != state->baud_base) ||
- (new_serial.close_delay != state->tport.close_delay) ||
+ (new_serial.close_delay != port->close_delay) ||
(new_serial.xmit_fifo_size != state->xmit_fifo_size) ||
((new_serial.flags & ~ASYNC_USR_MASK) !=
- (state->flags & ~ASYNC_USR_MASK)))
+ (port->flags & ~ASYNC_USR_MASK)))
return -EPERM;
- state->flags = ((state->flags & ~ASYNC_USR_MASK) |
+ port->flags = ((port->flags & ~ASYNC_USR_MASK) |
(new_serial.flags & ASYNC_USR_MASK));
state->custom_divisor = new_serial.custom_divisor;
goto check_and_exit;
@@ -1074,23 +1076,23 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
*/
state->baud_base = new_serial.baud_base;
- state->flags = ((state->flags & ~ASYNC_FLAGS) |
+ port->flags = ((port->flags & ~ASYNC_FLAGS) |
(new_serial.flags & ASYNC_FLAGS));
state->custom_divisor = new_serial.custom_divisor;
- state->tport.close_delay = new_serial.close_delay * HZ/100;
- state->tport.closing_wait = new_serial.closing_wait * HZ/100;
- tty->low_latency = (state->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ port->close_delay = new_serial.close_delay * HZ/100;
+ port->closing_wait = new_serial.closing_wait * HZ/100;
+ tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
check_and_exit:
- if (state->flags & ASYNC_INITIALIZED) {
+ if (port->flags & ASYNC_INITIALIZED) {
if (change_spd) {
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
tty->alt_speed = 115200;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
tty->alt_speed = 230400;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800;
change_speed(tty, state, NULL);
}
@@ -1407,7 +1409,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
local_irq_restore(flags);
return;
}
- state->flags |= ASYNC_CLOSING;
+ state->tport.flags |= ASYNC_CLOSING;
/*
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
@@ -1422,7 +1424,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* line status register.
*/
state->read_status_mask &= ~UART_LSR_DR;
- if (state->flags & ASYNC_INITIALIZED) {
+ if (state->tport.flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */
custom.intena = IF_RBF;
mb();
@@ -1449,7 +1451,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
wake_up_interruptible(&state->tport.open_wait);
}
- state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+ state->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&state->tport.close_wait);
local_irq_restore(flags);
}
@@ -1530,7 +1532,7 @@ static void rs_hangup(struct tty_struct *tty)
rs_flush_buffer(tty);
shutdown(tty, info);
info->tport.count = 0;
- info->flags &= ~ASYNC_NORMAL_ACTIVE;
+ info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
info->tport.tty = NULL;
wake_up_interruptible(&info->tport.open_wait);
}
@@ -1548,6 +1550,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#else
struct wait_queue wait = { current, NULL };
#endif
+ struct tty_port *port = &info->tport;
int retval;
int do_clocal = 0, extra_count = 0;
unsigned long flags;
@@ -1557,11 +1560,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
* until it's done, and then try again.
*/
if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->tport.close_wait);
+ (port->flags & ASYNC_CLOSING)) {
+ if (port->flags & ASYNC_CLOSING)
+ interruptible_sleep_on(&port->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -1574,7 +1577,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
*/
if ((filp->f_flags & O_NONBLOCK) ||
(tty->flags & (1 << TTY_IO_ERROR))) {
- info->flags |= ASYNC_NORMAL_ACTIVE;
+ port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1584,23 +1587,23 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
/*
* Block waiting for the carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in
- * this loop, info->tport.count is dropped by one, so that
+ * this loop, port->count is dropped by one, so that
* rs_close() knows when to free things. We restore it upon
* exit, either normal or abnormal.
*/
retval = 0;
- add_wait_queue(&info->tport.open_wait, &wait);
+ add_wait_queue(&port->open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready before block: ttys%d, count = %d\n",
- info->line, info->tport.count);
+ info->line, port->count);
#endif
local_irq_save(flags);
if (!tty_hung_up_p(filp)) {
extra_count = 1;
- info->tport.count--;
+ port->count--;
}
local_irq_restore(flags);
- info->tport.blocked_open++;
+ port->blocked_open++;
while (1) {
local_irq_save(flags);
if (tty->termios->c_cflag & CBAUD)
@@ -1608,9 +1611,9 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
local_irq_restore(flags);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
- !(info->flags & ASYNC_INITIALIZED)) {
+ !(port->flags & ASYNC_INITIALIZED)) {
#ifdef SERIAL_DO_RESTART
- if (info->flags & ASYNC_HUP_NOTIFY)
+ if (port->flags & ASYNC_HUP_NOTIFY)
retval = -EAGAIN;
else
retval = -ERESTARTSYS;
@@ -1619,7 +1622,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
#endif
break;
}
- if (!(info->flags & ASYNC_CLOSING) &&
+ if (!(port->flags & ASYNC_CLOSING) &&
(do_clocal || (!(ciab.pra & SER_DCD)) ))
break;
if (signal_pending(current)) {
@@ -1628,24 +1631,24 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
}
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, info->tport.count);
+ info->line, port->count);
#endif
tty_unlock();
schedule();
tty_lock();
}
__set_current_state(TASK_RUNNING);
- remove_wait_queue(&info->tport.open_wait, &wait);
+ remove_wait_queue(&port->open_wait, &wait);
if (extra_count)
- info->tport.count++;
- info->tport.blocked_open--;
+ port->count++;
+ port->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, info->tport.count);
+ info->line, port->count);
#endif
if (retval)
return retval;
- info->flags |= ASYNC_NORMAL_ACTIVE;
+ port->flags |= ASYNC_NORMAL_ACTIVE;
return 0;
}
@@ -1670,17 +1673,17 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#ifdef SERIAL_DEBUG_OPEN
printk("rs_open %s, count = %d\n", tty->name, info->count);
#endif
- tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
* 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->tport.flags & ASYNC_CLOSING)) {
+ if (info->tport.flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->tport.close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->flags & ASYNC_HUP_NOTIFY) ?
+ return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -1723,7 +1726,7 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
local_irq_save(flags);
status = ciab.pra;
- control = (state->flags & ASYNC_INITIALIZED) ? state->MCR : status;
+ control = (state->tport.flags & ASYNC_INITIALIZED) ? state->MCR : status;
local_irq_restore(flags);
stat_buf[0] = 0;
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index a6612b9..e5e8442 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -30,7 +30,6 @@ struct serial_state {
int baud_base;
unsigned long port;
int irq;
- int flags;
int type;
int line;
int xmit_fifo_size;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 41/68] TTY: simserial, remove static initialization
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (39 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 40/68] TTY: amiserial/simserial, use flags " Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 42/68] TTY: simserial, remove tmp_buf Jiri Slaby
` (28 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
We do not use any of the preinitialized rs_state members for something
real. So there is no need to initialize them. At the places we used
them for printing, just print the values.
And since only one port is supported, get rid of the loop. This
simplifies simrs_init a heap. Thus we can handle fail paths in a
standard way without panicing.
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 | 94 ++++++++++++------------------------------
1 file changed, 27 insertions(+), 67 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index c65c49d..64ab004 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -49,44 +49,7 @@
static char *serial_name = "SimSerial driver";
static char *serial_version = "0.6";
-/*
- * This has been extracted from asm/serial.h. We need one eventually but
- * I don't know exactly what we're going to put in it so just fake one
- * for now.
- */
-#define BASE_BAUD ( 1843200 / 16 )
-
-#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
-
-/*
- * Most of the values here are meaningless to this particular driver.
- * However some values must be preserved for the code (leveraged from serial.c
- * to work correctly).
- * port must not be 0
- * type must not be UNKNOWN
- * So I picked arbitrary (guess from where?) values instead
- */
-static struct serial_state rs_table[NR_PORTS]={
- /* UART CLK PORT IRQ FLAGS */
- { BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS, PORT_16550 } /* ttyS0 */
-};
-
-/*
- * Just for the fun of it !
- */
-static struct serial_uart_config uart_config[] = {
- { "unknown", 1, 0 },
- { "8250", 1, 0 },
- { "16450", 1, 0 },
- { "16550", 1, 0 },
- { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
- { "cirrus", 1, 0 },
- { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
- { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO |
- UART_STARTECH },
- { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO},
- { NULL, 0}
-};
+static struct serial_state rs_table[NR_PORTS];
struct tty_driver *hp_simserial_driver;
@@ -592,11 +555,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
goto errout;
}
- if (!state->port || !state->type) {
- set_bit(TTY_IO_ERROR, &tty->flags);
- free_page(page);
- goto errout;
- }
if (state->xmit.buf)
free_page(page);
else
@@ -725,9 +683,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
static inline void line_info(struct seq_file *m, struct serial_state *state)
{
- seq_printf(m, "%d: uart:%s port:%lX irq:%d\n",
- state->line, uart_config[state->type].name,
- state->port, state->irq);
+ seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
+ state->line, state->irq);
}
static int rs_proc_show(struct seq_file *m, void *v)
@@ -796,11 +753,10 @@ static const struct tty_operations hp_ops = {
/*
* The serial driver boot-time initialization code!
*/
-static int __init
-simrs_init (void)
+static int __init simrs_init(void)
{
- int i, rc;
- struct serial_state *state;
+ struct serial_state *state;
+ int retval;
if (!ia64_platform_is("hpsim"))
return -ENODEV;
@@ -828,29 +784,33 @@ simrs_init (void)
/*
* Let's have a little bit of fun !
*/
- for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
- tty_port_init(&state->tport);
- state->tport.close_delay = 0; /* XXX really 0? */
+ state = rs_table;
+ tty_port_init(&state->tport);
+ state->tport.close_delay = 0; /* XXX really 0? */
+
+ retval = hpsim_get_irq(KEYBOARD_INTR);
+ if (retval < 0) {
+ printk(KERN_ERR "%s: out of interrupt vectors!\n",
+ __func__);
+ goto err_free_tty;
+ }
- if (state->type == PORT_UNKNOWN) continue;
+ state->irq = retval;
- if (!state->irq) {
- if ((rc = hpsim_get_irq(KEYBOARD_INTR)) < 0)
- panic("%s: out of interrupt vectors!\n",
- __func__);
- state->irq = rc;
- }
+ /* the port is imaginary */
+ printk(KERN_INFO "ttyS%d at 0x03f8 (irq = %d) is a 16550\n",
+ state->line, state->irq);
- printk(KERN_INFO "ttyS%d at 0x%04lx (irq = %d) is a %s\n",
- state->line,
- state->port, state->irq,
- uart_config[state->type].name);
+ retval = tty_register_driver(hp_simserial_driver);
+ if (retval) {
+ printk(KERN_ERR "Couldn't register simserial driver\n");
+ goto err_free_tty;
}
- if (tty_register_driver(hp_simserial_driver))
- panic("Couldn't register simserial driver\n");
-
return 0;
+err_free_tty:
+ put_tty_driver(hp_simserial_driver);
+ return retval;
}
#ifndef MODULE
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 42/68] TTY: simserial, remove tmp_buf
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (40 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 41/68] TTY: simserial, remove static initialization Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 43/68] TTY: simserial, stop using serial_state->{line,icount} Jiri Slaby
` (27 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
It is totally unused.
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 | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 64ab004..45df0f4 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -55,8 +55,6 @@ struct tty_driver *hp_simserial_driver;
static struct console *console;
-static unsigned char *tmp_buf;
-
extern struct console *console_drivers; /* from kernel/printk.c */
/*
@@ -237,7 +235,8 @@ static int rs_write(struct tty_struct * tty,
int c, ret = 0;
unsigned long flags;
- if (!tty || !info->xmit.buf || !tmp_buf) return 0;
+ if (!tty || !info->xmit.buf)
+ return 0;
local_irq_save(flags);
while (1) {
@@ -618,7 +617,6 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = rs_table + tty->index;
int retval;
- unsigned long page;
info->tport.count++;
info->tport.tty = tty;
@@ -630,16 +628,6 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
#endif
tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
- if (!tmp_buf) {
- page = get_zeroed_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
- if (tmp_buf)
- free_page(page);
- else
- tmp_buf = (unsigned char *) page;
- }
-
/*
* If the port is the middle of closing, bail out now
*/
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 43/68] TTY: simserial, stop using serial_state->{line,icount}
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (41 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 42/68] TTY: simserial, remove tmp_buf Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 44/68] TTY: simserial no longer needs serialP Jiri Slaby
` (26 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
* instead of line, use tty->index or an iterator
* icount is not made public, only the tx path increments it
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 | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 45df0f4..3698a2f 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -176,7 +176,6 @@ static void transmit_chars(struct tty_struct *tty, struct serial_state *info,
console->write(console, &c, 1);
- info->icount.tx++;
info->x_char = 0;
goto out;
@@ -478,7 +477,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
if (--info->tport.count < 0) {
printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
- info->line, info->tport.count);
+ tty->index, info->tport.count);
info->tport.count = 0;
}
if (info->tport.count) {
@@ -669,19 +668,14 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
* /proc fs routines....
*/
-static inline void line_info(struct seq_file *m, struct serial_state *state)
-{
- seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
- state->line, state->irq);
-}
-
static int rs_proc_show(struct seq_file *m, void *v)
{
int i;
seq_printf(m, "simserinfo:1.0 driver:%s\n", serial_version);
for (i = 0; i < NR_PORTS; i++)
- line_info(m, &rs_table[i]);
+ seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
+ i, rs_table[i].irq);
return 0;
}
@@ -786,8 +780,7 @@ static int __init simrs_init(void)
state->irq = retval;
/* the port is imaginary */
- printk(KERN_INFO "ttyS%d at 0x03f8 (irq = %d) is a 16550\n",
- state->line, state->irq);
+ printk(KERN_INFO "ttyS0 at 0x03f8 (irq = %d) is a 16550\n", state->irq);
retval = tty_register_driver(hp_simserial_driver);
if (retval) {
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 44/68] TTY: simserial no longer needs serialP
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (42 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 43/68] TTY: simserial, stop using serial_state->{line,icount} Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 45/68] TTY: simserial, define local tty_port pointer Jiri Slaby
` (25 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
Let's do a spin-off of serial_state structure with only needed
elements.
And remove serialP crap from includes.
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 | 9 ++++++++-
include/linux/serialP.h | 2 --
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 3698a2f..120aad4 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -27,10 +27,10 @@
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/capability.h>
+#include <linux/circ_buf.h>
#include <linux/console.h>
#include <linux/module.h>
#include <linux/serial.h>
-#include <linux/serialP.h>
#include <linux/sysrq.h>
#include <asm/irq.h>
@@ -46,6 +46,13 @@
#define NR_PORTS 1 /* only one port for now */
+struct serial_state {
+ struct tty_port tport;
+ struct circ_buf xmit;
+ int irq;
+ int x_char;
+};
+
static char *serial_name = "SimSerial driver";
static char *serial_version = "0.6";
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index e5e8442..9a04dec 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -44,10 +44,8 @@ struct serial_state {
int quot;
int IER; /* Interrupt Enable Register */
int MCR; /* Modem control register */
- /* simserial */
int x_char; /* xon/xoff character */
struct circ_buf xmit;
- /* /simserial */
/* /amiserial */
};
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 45/68] TTY: simserial, define local tty_port pointer
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (43 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 44/68] TTY: simserial no longer needs serialP Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 46/68] TTY: simserial, remove some tty ops Jiri Slaby
` (24 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
And use it to make the code more readable.
Since tport doesn't conflict with port anymore and there are not many
tport accessors left, do also s/\<tport\>/port/g.
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 | 84 ++++++++++++++++++++++--------------------
1 file changed, 44 insertions(+), 40 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 120aad4..909357e 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -47,7 +47,7 @@
#define NR_PORTS 1 /* only one port for now */
struct serial_state {
- struct tty_port tport;
+ struct tty_port port;
struct circ_buf xmit;
int irq;
int x_char;
@@ -132,8 +132,9 @@ static void receive_chars(struct tty_struct *tty)
static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
struct serial_state *info = dev_id;
+ struct tty_struct *tty = info->port.tty;
- if (!info->tport.tty) {
+ if (!tty) {
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
return IRQ_NONE;
}
@@ -141,7 +142,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
* pretty simple in our case, because we only get interrupts
* on inbound traffic
*/
- receive_chars(info->tport.tty);
+ receive_chars(tty);
return IRQ_HANDLED;
}
@@ -416,7 +417,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
{
unsigned long flags;
- if (!(info->tport.flags & ASYNC_INITIALIZED))
+ if (!(info->port.flags & ASYNC_INITIALIZED))
return;
#ifdef SIMSERIAL_DEBUG
@@ -436,7 +437,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
set_bit(TTY_IO_ERROR, &tty->flags);
- info->tport.flags &= ~ASYNC_INITIALIZED;
+ info->port.flags &= ~ASYNC_INITIALIZED;
}
local_irq_restore(flags);
}
@@ -454,6 +455,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
static void rs_close(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = tty->driver_data;
+ struct tty_port *port = &info->port;
unsigned long flags;
if (!info)
@@ -468,30 +470,30 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
return;
}
#ifdef SIMSERIAL_DEBUG
- printk("rs_close ttys%d, count = %d\n", info->line, info->tport.count);
+ printk("rs_close ttys%d, count = %d\n", info->line, port->count);
#endif
- if ((tty->count == 1) && (info->tport.count != 1)) {
+ if ((tty->count == 1) && (port->count != 1)) {
/*
* Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. info->tport.count should always
+ * structure will be freed. port->count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
- "info->tport.count is %d\n", info->tport.count);
- info->tport.count = 1;
+ "port->count is %d\n", port->count);
+ port->count = 1;
}
- if (--info->tport.count < 0) {
+ if (--port->count < 0) {
printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
- tty->index, info->tport.count);
- info->tport.count = 0;
+ tty->index, port->count);
+ port->count = 0;
}
- if (info->tport.count) {
+ if (port->count) {
local_irq_restore(flags);
return;
}
- info->tport.flags |= ASYNC_CLOSING;
+ port->flags |= ASYNC_CLOSING;
local_irq_restore(flags);
/*
@@ -501,14 +503,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
shutdown(tty, info);
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
- info->tport.tty = NULL;
- if (info->tport.blocked_open) {
- if (info->tport.close_delay)
- schedule_timeout_interruptible(info->tport.close_delay);
- wake_up_interruptible(&info->tport.open_wait);
+ port->tty = NULL;
+ if (port->blocked_open) {
+ if (port->close_delay)
+ schedule_timeout_interruptible(port->close_delay);
+ wake_up_interruptible(&port->open_wait);
}
- info->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&info->tport.close_wait);
+ port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+ wake_up_interruptible(&port->close_wait);
}
/*
@@ -525,26 +527,27 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
static void rs_hangup(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
+ struct tty_port *port = &info->port;
#ifdef SIMSERIAL_DEBUG
printk("rs_hangup: called\n");
#endif
rs_flush_buffer(tty);
- if (info->tport.flags & ASYNC_CLOSING)
+ if (port->flags & ASYNC_CLOSING)
return;
shutdown(tty, info);
- info->tport.count = 0;
- info->tport.flags &= ~ASYNC_NORMAL_ACTIVE;
- info->tport.tty = NULL;
- wake_up_interruptible(&info->tport.open_wait);
+ port->count = 0;
+ port->flags &= ~ASYNC_NORMAL_ACTIVE;
+ port->tty = NULL;
+ wake_up_interruptible(&port->open_wait);
}
static int startup(struct tty_struct *tty, struct serial_state *state)
{
- struct tty_port *port = &state->tport;
+ struct tty_port *port = &state->port;
unsigned long flags;
int retval=0;
unsigned long page;
@@ -622,26 +625,27 @@ errout:
static int rs_open(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = rs_table + tty->index;
- int retval;
+ struct tty_port *port = &info->port;
+ int retval;
- info->tport.count++;
- info->tport.tty = tty;
+ port->count++;
+ port->tty = tty;
tty->driver_data = info;
- tty->port = &info->tport;
+ tty->port = port;
#ifdef SIMSERIAL_DEBUG
- printk("rs_open %s, count = %d\n", tty->name, info->tport.count);
+ printk("rs_open %s, count = %d\n", tty->name, port->count);
#endif
- tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
* If the port is the middle of closing, bail out now
*/
- if (tty_hung_up_p(filp) || (info->tport.flags & ASYNC_CLOSING)) {
- if (info->tport.flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->tport.close_wait);
+ if (tty_hung_up_p(filp) || (port->flags & ASYNC_CLOSING)) {
+ if (port->flags & ASYNC_CLOSING)
+ interruptible_sleep_on(&port->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
+ return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
@@ -774,8 +778,8 @@ static int __init simrs_init(void)
* Let's have a little bit of fun !
*/
state = rs_table;
- tty_port_init(&state->tport);
- state->tport.close_delay = 0; /* XXX really 0? */
+ tty_port_init(&state->port);
+ state->port.close_delay = 0; /* XXX really 0? */
retval = hpsim_get_irq(KEYBOARD_INTR);
if (retval < 0) {
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 46/68] TTY: simserial, remove some tty ops
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (44 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 45/68] TTY: simserial, define local tty_port pointer Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 48/68] TTY: simserial, use tty_port_close_start Jiri Slaby
` (23 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
All ->start, ->stop and ->wait_until_sent are empty and need not be
defined. The time to remove them is now.
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 | 39 +--------------------------------------
1 file changed, 1 insertion(+), 38 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 909357e..d173dba 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -64,32 +64,7 @@ static struct console *console;
extern struct console *console_drivers; /* from kernel/printk.c */
-/*
- * ------------------------------------------------------------
- * rs_stop() and rs_start()
- *
- * This routines are called before setting or resetting tty->stopped.
- * They enable or disable transmitter interrupts, as necessary.
- * ------------------------------------------------------------
- */
-static void rs_stop(struct tty_struct *tty)
-{
-#ifdef SIMSERIAL_DEBUG
- printk("rs_stop: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
- tty->stopped, tty->hw_stopped, tty->flow_stopped);
-#endif
-
-}
-
-static void rs_start(struct tty_struct *tty)
-{
-#ifdef SIMSERIAL_DEBUG
- printk("rs_start: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
- tty->stopped, tty->hw_stopped, tty->flow_stopped);
-#endif
-}
-
-static void receive_chars(struct tty_struct *tty)
+static void receive_chars(struct tty_struct *tty)
{
unsigned char ch;
static unsigned char seen_esc = 0;
@@ -406,7 +381,6 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
if ((old_termios->c_cflag & CRTSCTS) &&
!(tty->termios->c_cflag & CRTSCTS)) {
tty->hw_stopped = 0;
- rs_start(tty);
}
}
/*
@@ -514,14 +488,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
/*
- * rs_wait_until_sent() --- wait until the transmitter is empty
- */
-static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
-{
-}
-
-
-/*
* rs_hangup() --- called by tty_hangup() when a hangup is signaled.
*/
static void rs_hangup(struct tty_struct *tty)
@@ -736,10 +702,7 @@ static const struct tty_operations hp_ops = {
.unthrottle = rs_unthrottle,
.send_xchar = rs_send_xchar,
.set_termios = rs_set_termios,
- .stop = rs_stop,
- .start = rs_start,
.hangup = rs_hangup,
- .wait_until_sent = rs_wait_until_sent,
.proc_fops = &rs_proc_fops,
};
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 48/68] TTY: simserial, use tty_port_close_start
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (45 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 46/68] TTY: simserial, remove some tty ops Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 49/68] TTY: simserial, properly refcount tty_port->tty Jiri Slaby
` (22 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
I.e. remove more copied bloat.
The only change is that we wait_until_sent now. Which is what we
really should do.
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 | 36 +-----------------------------------
1 file changed, 1 insertion(+), 35 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 53db99a..2cd6d23 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -430,45 +430,12 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = tty->driver_data;
struct tty_port *port = &info->port;
- unsigned long flags;
if (!info)
return;
- local_irq_save(flags);
- if (tty_hung_up_p(filp)) {
-#ifdef SIMSERIAL_DEBUG
- printk("rs_close: hung_up\n");
-#endif
- local_irq_restore(flags);
- return;
- }
-#ifdef SIMSERIAL_DEBUG
- printk("rs_close ttys%d, count = %d\n", info->line, port->count);
-#endif
- if ((tty->count == 1) && (port->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. port->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
- "port->count is %d\n", port->count);
- port->count = 1;
- }
- if (--port->count < 0) {
- printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
- tty->index, port->count);
- port->count = 0;
- }
- if (port->count) {
- local_irq_restore(flags);
+ if (tty_port_close_start(port, tty, filp) == 0)
return;
- }
- port->flags |= ASYNC_CLOSING;
- local_irq_restore(flags);
/*
* Now we wait for the transmit buffer to clear; and we notify
@@ -476,7 +443,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
*/
shutdown(tty, info);
rs_flush_buffer(tty);
- tty_ldisc_flush(tty);
port->tty = NULL;
tty_port_close_end(port, tty);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 49/68] TTY: simserial, properly refcount tty_port->tty
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (46 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 48/68] TTY: simserial, use tty_port_close_start Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 50/68] TTY: simserial, use tty_port_open Jiri Slaby
` (21 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
So that we will not be surprised in the ISR anymore.
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 | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 2cd6d23..b3ec91c 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -107,7 +107,7 @@ static void receive_chars(struct tty_struct *tty)
static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
{
struct serial_state *info = dev_id;
- struct tty_struct *tty = info->port.tty;
+ struct tty_struct *tty = tty_port_tty_get(&info->port);
if (!tty) {
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
@@ -118,6 +118,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
* on inbound traffic
*/
receive_chars(tty);
+ tty_kref_put(tty);
return IRQ_HANDLED;
}
@@ -443,9 +444,9 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
*/
shutdown(tty, info);
rs_flush_buffer(tty);
- port->tty = NULL;
tty_port_close_end(port, tty);
+ tty_port_tty_set(port, NULL);
}
/*
@@ -467,7 +468,7 @@ static void rs_hangup(struct tty_struct *tty)
port->count = 0;
port->flags &= ~ASYNC_NORMAL_ACTIVE;
- port->tty = NULL;
+ tty_port_tty_set(port, NULL);
wake_up_interruptible(&port->open_wait);
}
@@ -556,7 +557,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
int retval;
port->count++;
- port->tty = tty;
+ tty_port_tty_set(port, tty);
tty->driver_data = info;
tty->port = port;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 50/68] TTY: simserial, use tty_port_open
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (47 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 49/68] TTY: simserial, properly refcount tty_port->tty Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 51/68] TTY: simserial, use tty_port_hangup Jiri Slaby
` (20 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
So now we convert startup to be ->activate of tty_port. This means we
no longer care about INITIALIZED and TTY_IO_ERROR flags.
After we have ->activate much of the code may go as it duplicates what
tty_port_open does. In this case tty_port_open adds block_til_ready to
the path. But we do not define carrier hooks, so it is a noop.
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 | 64 ++++--------------------------------------
1 file changed, 5 insertions(+), 59 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index b3ec91c..e9c5fb7 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -473,9 +473,10 @@ static void rs_hangup(struct tty_struct *tty)
}
-static int startup(struct tty_struct *tty, struct serial_state *state)
+static int activate(struct tty_port *port, struct tty_struct *tty)
{
- struct tty_port *port = &state->port;
+ struct serial_state *state = container_of(port, struct serial_state,
+ port);
unsigned long flags;
int retval=0;
unsigned long page;
@@ -486,20 +487,11 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
local_irq_save(flags);
- if (port->flags & ASYNC_INITIALIZED) {
- free_page(page);
- goto errout;
- }
-
if (state->xmit.buf)
free_page(page);
else
state->xmit.buf = (unsigned char *) page;
-#ifdef SIMSERIAL_DEBUG
- printk("startup: ttys%d (irq %d)...", state->line, state->irq);
-#endif
-
/*
* Allocate the IRQ if necessary
*/
@@ -510,18 +502,8 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
goto errout;
}
- clear_bit(TTY_IO_ERROR, &tty->flags);
-
state->xmit.head = state->xmit.tail = 0;
-#if 0
- /*
- * Set up serial timers...
- */
- timer_table[RS_TIMER].expires = jiffies + 2*HZ/100;
- timer_active |= 1 << RS_TIMER;
-#endif
-
/*
* Set up the tty->alt_speed kludge
*/
@@ -534,10 +516,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
tty->alt_speed = 460800;
- port->flags |= ASYNC_INITIALIZED;
- local_irq_restore(flags);
- return 0;
-
errout:
local_irq_restore(flags);
return retval;
@@ -554,41 +532,11 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = rs_table + tty->index;
struct tty_port *port = &info->port;
- int retval;
- port->count++;
- tty_port_tty_set(port, tty);
tty->driver_data = info;
- tty->port = port;
-
-#ifdef SIMSERIAL_DEBUG
- printk("rs_open %s, count = %d\n", tty->name, port->count);
-#endif
tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
- * If the port is the middle of closing, bail out now
- */
- if (tty_hung_up_p(filp) || (port->flags & ASYNC_CLOSING)) {
- if (port->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&port->close_wait);
-#ifdef SERIAL_DO_RESTART
- return ((port->flags & ASYNC_HUP_NOTIFY) ?
- -EAGAIN : -ERESTARTSYS);
-#else
- return -EAGAIN;
-#endif
- }
-
- /*
- * Start up serial port
- */
- retval = startup(tty, info);
- if (retval) {
- return retval;
- }
-
- /*
* figure out which console to use (should be one already)
*/
console = console_drivers;
@@ -597,10 +545,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
console = console->next;
}
-#ifdef SIMSERIAL_DEBUG
- printk("rs_open ttys%d successful\n", info->line);
-#endif
- return 0;
+ return tty_port_open(port, tty, filp);
}
/*
@@ -669,6 +614,7 @@ static const struct tty_operations hp_ops = {
};
static const struct tty_port_operations hp_port_ops = {
+ .activate = activate,
};
/*
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 51/68] TTY: simserial, use tty_port_hangup
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (48 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 50/68] TTY: simserial, use tty_port_open Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 52/68] TTY: simserial, remove useless comments Jiri Slaby
` (19 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
Convert shutdown to be tty_port_operations->shutdown. Then we can use
tty_port_hangup. (And we have to use tty_port_close.)
This means we no longer touch ASYNC_INITIALIZED, TTY_IO_ERROR. Also we
do not need to do any peculiar TTY logic in the file now.
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 | 64 +++++-------------------------------------
1 file changed, 7 insertions(+), 57 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index e9c5fb7..323c932 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -388,17 +388,11 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
* This routine will shutdown a serial port; interrupts are disabled, and
* DTR is dropped if the hangup on close termio flag is on.
*/
-static void shutdown(struct tty_struct *tty, struct serial_state *info)
+static void shutdown(struct tty_port *port)
{
- unsigned long flags;
-
- if (!(info->port.flags & ASYNC_INITIALIZED))
- return;
-
-#ifdef SIMSERIAL_DEBUG
- printk("Shutting down serial port %d (irq %d)...\n", info->line,
- info->irq);
-#endif
+ struct serial_state *info = container_of(port, struct serial_state,
+ port);
+ unsigned long flags;
local_irq_save(flags);
{
@@ -409,70 +403,25 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
free_page((unsigned long) info->xmit.buf);
info->xmit.buf = NULL;
}
-
- set_bit(TTY_IO_ERROR, &tty->flags);
-
- info->port.flags &= ~ASYNC_INITIALIZED;
}
local_irq_restore(flags);
}
-/*
- * ------------------------------------------------------------
- * rs_close()
- *
- * This routine is called when the serial port gets closed. First, we
- * wait for the last remaining data to be sent. Then, we unlink its
- * async structure from the interrupt chain if necessary, and we free
- * that IRQ if nothing is left in the chain.
- * ------------------------------------------------------------
- */
static void rs_close(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = tty->driver_data;
- struct tty_port *port = &info->port;
-
- if (!info)
- return;
-
- if (tty_port_close_start(port, tty, filp) == 0)
- return;
-
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- shutdown(tty, info);
- rs_flush_buffer(tty);
- tty_port_close_end(port, tty);
- tty_port_tty_set(port, NULL);
+ tty_port_close(&info->port, tty, filp);
}
-/*
- * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
- */
static void rs_hangup(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
- struct tty_port *port = &info->port;
-
-#ifdef SIMSERIAL_DEBUG
- printk("rs_hangup: called\n");
-#endif
rs_flush_buffer(tty);
- if (port->flags & ASYNC_CLOSING)
- return;
- shutdown(tty, info);
-
- port->count = 0;
- port->flags &= ~ASYNC_NORMAL_ACTIVE;
- tty_port_tty_set(port, NULL);
- wake_up_interruptible(&port->open_wait);
+ tty_port_hangup(&info->port);
}
-
static int activate(struct tty_port *port, struct tty_struct *tty)
{
struct serial_state *state = container_of(port, struct serial_state,
@@ -615,6 +564,7 @@ static const struct tty_operations hp_ops = {
static const struct tty_port_operations hp_port_ops = {
.activate = activate,
+ .shutdown = shutdown,
};
/*
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 52/68] TTY: simserial, remove useless comments
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (49 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 51/68] TTY: simserial, use tty_port_hangup Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 53/68] TTY: simserial, fix includes Jiri Slaby
` (18 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
Or the obsolete ones like:
"Let's have a little bit of fun"
I have never had fun with software. For fun, one needs hard-ware.
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 | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 323c932..d8237c3 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -4,16 +4,11 @@
* This driver is mostly used for bringup purposes and will go away.
* It has a strong dependency on the system console. All outputs
* are rerouted to the same facility as the one used by printk which, in our
- * case means sys_sim.c console (goes via the simulator). The code hereafter
- * is completely leveraged from the serial.c driver.
+ * case means sys_sim.c console (goes via the simulator).
*
* Copyright (C) 1999-2000, 2002-2003 Hewlett-Packard Co
* Stephane Eranian <eranian@hpl.hp.com>
* David Mosberger-Tang <davidm@hpl.hp.com>
- *
- * 02/04/00 D. Mosberger Merged in serial.c bug fixes in rs_close().
- * 02/25/00 D. Mosberger Synced up with 2.3.99pre-5 version of serial.c.
- * 07/30/02 D. Mosberger Replace sti()/cli() with explicit spinlocks & local irq masking
*/
#include <linux/init.h>
@@ -441,9 +436,6 @@ static int activate(struct tty_port *port, struct tty_struct *tty)
else
state->xmit.buf = (unsigned char *) page;
- /*
- * Allocate the IRQ if necessary
- */
if (state->irq) {
retval = request_irq(state->irq, rs_interrupt_single, 0,
"simserial", state);
@@ -525,19 +517,6 @@ static const struct file_operations rs_proc_fops = {
.release = single_release,
};
-/*
- * ---------------------------------------------------------------------
- * rs_init() and friends
- *
- * rs_init() is called at boot-time to initialize the serial driver.
- * ---------------------------------------------------------------------
- */
-
-/*
- * This routine prints out the appropriate serial driver version
- * number, and identifies which options were configured into this
- * driver.
- */
static inline void show_serial_version(void)
{
printk(KERN_INFO "%s version %s with", serial_name, serial_version);
@@ -567,9 +546,6 @@ static const struct tty_port_operations hp_port_ops = {
.shutdown = shutdown,
};
-/*
- * The serial driver boot-time initialization code!
- */
static int __init simrs_init(void)
{
struct serial_state *state;
@@ -598,9 +574,6 @@ static int __init simrs_init(void)
hp_simserial_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(hp_simserial_driver, &hp_ops);
- /*
- * Let's have a little bit of fun !
- */
state = rs_table;
tty_port_init(&state->port);
state->port.ops = &hp_port_ops;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 53/68] TTY: simserial, fix includes
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (50 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 52/68] TTY: simserial, remove useless comments Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 54/68] TTY: simserial, reindent some code Jiri Slaby
` (17 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
Use headers from linux/* instead of asm/. Remove declaration of
console_drivers, it's in linux/console.h already.
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 | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index d8237c3..24d6ca0 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -24,14 +24,13 @@
#include <linux/capability.h>
#include <linux/circ_buf.h>
#include <linux/console.h>
+#include <linux/irq.h>
#include <linux/module.h>
#include <linux/serial.h>
#include <linux/sysrq.h>
+#include <linux/uaccess.h>
-#include <asm/irq.h>
#include <asm/hpsim.h>
-#include <asm/hw_irq.h>
-#include <asm/uaccess.h>
#include "hpsim_ssc.h"
@@ -57,8 +56,6 @@ struct tty_driver *hp_simserial_driver;
static struct console *console;
-extern struct console *console_drivers; /* from kernel/printk.c */
-
static void receive_chars(struct tty_struct *tty)
{
unsigned char ch;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 54/68] TTY: simserial, reindent some code
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (51 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 53/68] TTY: simserial, fix includes Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 55/68] TTY: simserial, final cleanup Jiri Slaby
` (16 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
Make the code to conform to the standard. Also make it readable.
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 | 120 ++++++++++++++++--------------------------
1 file changed, 44 insertions(+), 76 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 24d6ca0..516ad09 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -62,28 +62,25 @@ static void receive_chars(struct tty_struct *tty)
static unsigned char seen_esc = 0;
while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
- if ( ch == 27 && seen_esc == 0 ) {
+ if (ch == 27 && seen_esc == 0) {
seen_esc = 1;
continue;
- } else {
- if ( seen_esc==1 && ch == 'O' ) {
- seen_esc = 2;
- continue;
- } else if ( seen_esc == 2 ) {
- if ( ch == 'P' ) /* F1 */
- show_state();
+ } else if (seen_esc == 1 && ch == 'O') {
+ seen_esc = 2;
+ continue;
+ } else if (seen_esc == 2) {
+ if (ch == 'P') /* F1 */
+ show_state();
#ifdef CONFIG_MAGIC_SYSRQ
- if ( ch == 'S' ) { /* F4 */
- do
- ch = ia64_ssc(0, 0, 0, 0,
- SSC_GETCHAR);
- while (!ch);
- handle_sysrq(ch);
- }
-#endif
- seen_esc = 0;
- continue;
+ if (ch == 'S') { /* F4 */
+ do {
+ ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR);
+ } while (!ch);
+ handle_sysrq(ch);
}
+#endif
+ seen_esc = 0;
+ continue;
}
seen_esc = 0;
@@ -195,8 +192,8 @@ static void rs_flush_chars(struct tty_struct *tty)
{
struct serial_state *info = tty->driver_data;
- if (info->xmit.head == info->xmit.tail || tty->stopped || tty->hw_stopped ||
- !info->xmit.buf)
+ if (info->xmit.head == info->xmit.tail || tty->stopped ||
+ tty->hw_stopped || !info->xmit.buf)
return;
transmit_chars(tty, info, NULL);
@@ -232,10 +229,10 @@ static int rs_write(struct tty_struct * tty,
/*
* Hey, we transmit directly from here in our case
*/
- if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
- && !tty->stopped && !tty->hw_stopped) {
+ if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) &&
+ !tty->stopped && !tty->hw_stopped)
transmit_chars(tty, info, NULL);
- }
+
return ret;
}
@@ -293,7 +290,8 @@ static void rs_send_xchar(struct tty_struct *tty, char ch)
*/
static void rs_throttle(struct tty_struct * tty)
{
- if (I_IXOFF(tty)) rs_send_xchar(tty, STOP_CHAR(tty));
+ if (I_IXOFF(tty))
+ rs_send_xchar(tty, STOP_CHAR(tty));
printk(KERN_INFO "simrs_throttle called\n");
}
@@ -322,48 +320,21 @@ static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
}
switch (cmd) {
- case TIOCGSERIAL:
- printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n");
- return 0;
- case TIOCSSERIAL:
- printk(KERN_INFO "simrs_ioctl TIOCSSERIAL called\n");
- return 0;
- case TIOCSERCONFIG:
- printk(KERN_INFO "rs_ioctl: TIOCSERCONFIG called\n");
- return -EINVAL;
-
- case TIOCSERGETLSR: /* Get line status register */
- printk(KERN_INFO "rs_ioctl: TIOCSERGETLSR called\n");
- return -EINVAL;
-
- case TIOCSERGSTRUCT:
- printk(KERN_INFO "rs_ioctl: TIOCSERGSTRUCT called\n");
-#if 0
- if (copy_to_user((struct async_struct *) arg,
- info, sizeof(struct async_struct)))
- return -EFAULT;
-#endif
- return 0;
-
- /*
- * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
- * - mask passed in arg for lines of interest
- * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
- * Caller should use TIOCGICOUNT to see which one it was
- */
- case TIOCMIWAIT:
- printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n");
- return 0;
- case TIOCSERGWILD:
- case TIOCSERSWILD:
- /* "setserial -W" is called in Debian boot */
- printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
- return 0;
-
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
+ case TIOCGSERIAL:
+ case TIOCSSERIAL:
+ case TIOCSERGSTRUCT:
+ case TIOCMIWAIT:
+ return 0;
+ case TIOCSERCONFIG:
+ case TIOCSERGETLSR: /* Get line status register */
+ return -EINVAL;
+ case TIOCSERGWILD:
+ case TIOCSERSWILD:
+ /* "setserial -W" is called in Debian boot */
+ printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
+ return 0;
+ }
+ return -ENOIOCTLCMD;
}
#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
@@ -387,14 +358,12 @@ static void shutdown(struct tty_port *port)
unsigned long flags;
local_irq_save(flags);
- {
- if (info->irq)
- free_irq(info->irq, info);
+ if (info->irq)
+ free_irq(info->irq, info);
- if (info->xmit.buf) {
- free_page((unsigned long) info->xmit.buf);
- info->xmit.buf = NULL;
- }
+ if (info->xmit.buf) {
+ free_page((unsigned long) info->xmit.buf);
+ info->xmit.buf = NULL;
}
local_irq_restore(flags);
}
@@ -418,9 +387,8 @@ static int activate(struct tty_port *port, struct tty_struct *tty)
{
struct serial_state *state = container_of(port, struct serial_state,
port);
- unsigned long flags;
- int retval=0;
- unsigned long page;
+ unsigned long flags, page;
+ int retval = 0;
page = get_zeroed_page(GFP_KERNEL);
if (!page)
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 55/68] TTY: simserial, final cleanup
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (52 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 54/68] TTY: simserial, reindent some code Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 56/68] TTY: amiserial, define local tty_port pointer Jiri Slaby
` (15 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
* remove pointless checks (tty cannot be NULL at that points)
* fix some printks (use __func__, print text directly w/o using global
strings)
* remove some empty lines
This is the last patch for simserial. Overall, the driver is 400 lines
shorter. Being now at 560 lines.
It was tested using ski with a busybox userspace.
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 | 21 +++++----------------
1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 516ad09..c34785d 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -47,9 +47,6 @@ struct serial_state {
int x_char;
};
-static char *serial_name = "SimSerial driver";
-static char *serial_version = "0.6";
-
static struct serial_state rs_table[NR_PORTS];
struct tty_driver *hp_simserial_driver;
@@ -99,7 +96,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
struct tty_struct *tty = tty_port_tty_get(&info->port);
if (!tty) {
- printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
+ printk(KERN_INFO "%s: tty=0 problem\n", __func__);
return IRQ_NONE;
}
/*
@@ -122,7 +119,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch)
struct serial_state *info = tty->driver_data;
unsigned long flags;
- if (!tty || !info->xmit.buf)
+ if (!info->xmit.buf)
return 0;
local_irq_save(flags);
@@ -199,7 +196,6 @@ static void rs_flush_chars(struct tty_struct *tty)
transmit_chars(tty, info, NULL);
}
-
static int rs_write(struct tty_struct * tty,
const unsigned char *buf, int count)
{
@@ -207,7 +203,7 @@ static int rs_write(struct tty_struct * tty,
int c, ret = 0;
unsigned long flags;
- if (!tty || !info->xmit.buf)
+ if (!info->xmit.buf)
return 0;
local_irq_save(flags);
@@ -309,7 +305,6 @@ static void rs_unthrottle(struct tty_struct * tty)
printk(KERN_INFO "simrs_unthrottle called\n");
}
-
static int rs_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
{
if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
@@ -462,7 +457,7 @@ static int rs_proc_show(struct seq_file *m, void *v)
{
int i;
- seq_printf(m, "simserinfo:1.0 driver:%s\n", serial_version);
+ seq_printf(m, "simserinfo:1.0\n");
for (i = 0; i < NR_PORTS; i++)
seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
i, rs_table[i].irq);
@@ -482,12 +477,6 @@ static const struct file_operations rs_proc_fops = {
.release = single_release,
};
-static inline void show_serial_version(void)
-{
- printk(KERN_INFO "%s version %s with", serial_name, serial_version);
- printk(KERN_INFO " no serial options enabled\n");
-}
-
static const struct tty_operations hp_ops = {
.open = rs_open,
.close = rs_close,
@@ -523,7 +512,7 @@ static int __init simrs_init(void)
if (!hp_simserial_driver)
return -ENOMEM;
- show_serial_version();
+ printk(KERN_INFO "SimSerial driver with no serial options enabled\n");
/* Initialize the tty_driver structure */
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 56/68] TTY: amiserial, define local tty_port pointer
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (53 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 55/68] TTY: simserial, final cleanup Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 57/68] TTY: amiserial, stop using serial_state->{irq,type,line} Jiri Slaby
` (14 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
And use it to make the code more readable.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 81 ++++++++++++++++++++++++-----------------------
1 file changed, 42 insertions(+), 39 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7d79826..a9f5da6 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -361,6 +361,7 @@ static void transmit_chars(struct serial_state *info)
static void check_modem_status(struct serial_state *info)
{
+ struct tty_port *port = &info->tport;
unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
unsigned char dstatus;
struct async_icount *icount;
@@ -377,45 +378,45 @@ static void check_modem_status(struct serial_state *info)
if (dstatus & SER_DCD) {
icount->dcd++;
#ifdef CONFIG_HARD_PPS
- if ((info->tport.flags & ASYNC_HARDPPS_CD) &&
+ if ((port->flags & ASYNC_HARDPPS_CD) &&
!(status & SER_DCD))
hardpps();
#endif
}
if (dstatus & SER_CTS)
icount->cts++;
- wake_up_interruptible(&info->tport.delta_msr_wait);
+ wake_up_interruptible(&port->delta_msr_wait);
}
- if ((info->tport.flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
+ if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
printk("ttyS%d CD now %s...", info->line,
(!(status & SER_DCD)) ? "on" : "off");
#endif
if (!(status & SER_DCD))
- wake_up_interruptible(&info->tport.open_wait);
+ wake_up_interruptible(&port->open_wait);
else {
#ifdef SERIAL_DEBUG_OPEN
printk("doing serial hangup...");
#endif
- if (info->tport.tty)
- tty_hangup(info->tport.tty);
+ if (port->tty)
+ tty_hangup(port->tty);
}
}
- if (info->tport.flags & ASYNC_CTS_FLOW) {
- if (info->tport.tty->hw_stopped) {
+ if (port->flags & ASYNC_CTS_FLOW) {
+ if (port->tty->hw_stopped) {
if (!(status & SER_CTS)) {
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx start...");
#endif
- info->tport.tty->hw_stopped = 0;
+ port->tty->hw_stopped = 0;
info->IER |= UART_IER_THRI;
custom.intena = IF_SETCLR | IF_TBE;
mb();
/* set a pending Tx Interrupt, transmitter should restart now */
custom.intreq = IF_SETCLR | IF_TBE;
mb();
- tty_wakeup(info->tport.tty);
+ tty_wakeup(port->tty);
return;
}
} else {
@@ -423,7 +424,7 @@ static void check_modem_status(struct serial_state *info)
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
printk("CTS tx stop...");
#endif
- info->tport.tty->hw_stopped = 1;
+ port->tty->hw_stopped = 1;
info->IER &= ~UART_IER_THRI;
/* disable Tx interrupt and remove any pending interrupts */
custom.intena = IF_TBE;
@@ -1371,6 +1372,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
static void rs_close(struct tty_struct *tty, struct file * filp)
{
struct serial_state *state = tty->driver_data;
+ struct tty_port *port = &state->tport;
unsigned long flags;
if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
@@ -1385,38 +1387,38 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", state->line, state->tport.count);
+ printk("rs_close ttys%d, count = %d\n", state->line, port->count);
#endif
- if ((tty->count == 1) && (state->tport.count != 1)) {
+ if ((tty->count == 1) && (port->count != 1)) {
/*
* Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->tport.count should always
+ * structure will be freed. port->count should always
* be one in these conditions. If it's greater than
* one, we've got real problems, since it means the
* serial port won't be shutdown.
*/
printk("rs_close: bad serial port count; tty->count is 1, "
- "state->tport.count is %d\n", state->tport.count);
- state->tport.count = 1;
+ "port->count is %d\n", state->tport.count);
+ port->count = 1;
}
- if (--state->tport.count < 0) {
+ if (--port->count < 0) {
printk("rs_close: bad serial port count for ttys%d: %d\n",
- state->line, state->tport.count);
- state->tport.count = 0;
+ state->line, port->count);
+ port->count = 0;
}
- if (state->tport.count) {
+ if (port->count) {
DBG_CNT("before DEC-2");
local_irq_restore(flags);
return;
}
- state->tport.flags |= ASYNC_CLOSING;
+ port->flags |= ASYNC_CLOSING;
/*
* Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters.
*/
tty->closing = 1;
- if (state->tport.closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, state->tport.closing_wait);
+ if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
+ tty_wait_until_sent(tty, port->closing_wait);
/*
* At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the
@@ -1424,7 +1426,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* line status register.
*/
state->read_status_mask &= ~UART_LSR_DR;
- if (state->tport.flags & ASYNC_INITIALIZED) {
+ if (port->flags & ASYNC_INITIALIZED) {
/* disable receive interrupts */
custom.intena = IF_RBF;
mb();
@@ -1444,15 +1446,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
tty_ldisc_flush(tty);
tty->closing = 0;
- state->tport.tty = NULL;
- if (state->tport.blocked_open) {
- if (state->tport.close_delay) {
- msleep_interruptible(jiffies_to_msecs(state->tport.close_delay));
+ port->tty = NULL;
+ if (port->blocked_open) {
+ if (port->close_delay) {
+ msleep_interruptible(jiffies_to_msecs(port->close_delay));
}
- wake_up_interruptible(&state->tport.open_wait);
+ wake_up_interruptible(&port->open_wait);
}
- state->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&state->tport.close_wait);
+ port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
+ wake_up_interruptible(&port->close_wait);
local_irq_restore(flags);
}
@@ -1661,29 +1663,30 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
static int rs_open(struct tty_struct *tty, struct file * filp)
{
struct serial_state *info = rs_table + tty->index;
+ struct tty_port *port = &info->tport;
int retval;
- info->tport.count++;
- info->tport.tty = tty;
+ port->count++;
+ port->tty = tty;
tty->driver_data = info;
- tty->port = &info->tport;
+ tty->port = port;
if (serial_paranoia_check(info, tty->name, "rs_open"))
return -ENODEV;
#ifdef SERIAL_DEBUG_OPEN
printk("rs_open %s, count = %d\n", tty->name, info->count);
#endif
- tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
+ tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
/*
* If the port is the middle of closing, bail out now
*/
if (tty_hung_up_p(filp) ||
- (info->tport.flags & ASYNC_CLOSING)) {
- if (info->tport.flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->tport.close_wait);
+ (port->flags & ASYNC_CLOSING)) {
+ if (port->flags & ASYNC_CLOSING)
+ interruptible_sleep_on(&port->close_wait);
#ifdef SERIAL_DO_RESTART
- return ((info->tport.flags & ASYNC_HUP_NOTIFY) ?
+ return ((port->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
#else
return -EAGAIN;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 57/68] TTY: amiserial, stop using serial_state->{irq,type,line}
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (54 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 56/68] TTY: amiserial, define local tty_port pointer Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 58/68] TTY: amiserial no longer needs serialP Jiri Slaby
` (13 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
* instead of line, use tty->index or iterator...
* irq and type are left unset. So get rid of them.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 23 ++++++++++-------------
include/linux/serialP.h | 3 ---
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index a9f5da6..b182bcc 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1008,7 +1008,7 @@ static void rs_unthrottle(struct tty_struct * tty)
* ------------------------------------------------------------
*/
-static int get_serial_info(struct serial_state *state,
+static int get_serial_info(struct tty_struct *tty, struct serial_state *state,
struct serial_struct __user * retinfo)
{
struct serial_struct tmp;
@@ -1017,10 +1017,8 @@ static int get_serial_info(struct serial_state *state,
return -EFAULT;
memset(&tmp, 0, sizeof(tmp));
tty_lock();
- tmp.type = state->type;
- tmp.line = state->line;
+ tmp.line = tty->index;
tmp.port = state->port;
- tmp.irq = state->irq;
tmp.flags = state->tport.flags;
tmp.xmit_fifo_size = state->xmit_fifo_size;
tmp.baud_base = state->baud_base;
@@ -1047,7 +1045,7 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state,
tty_lock();
change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) ||
new_serial.custom_divisor != state->custom_divisor;
- if (new_serial.irq != state->irq || new_serial.port != state->port ||
+ if (new_serial.irq || new_serial.port != state->port ||
new_serial.xmit_fifo_size != state->xmit_fifo_size) {
tty_unlock();
return -EINVAL;
@@ -1250,7 +1248,7 @@ static int rs_ioctl(struct tty_struct *tty,
switch (cmd) {
case TIOCGSERIAL:
- return get_serial_info(info, argp);
+ return get_serial_info(tty, info, argp);
case TIOCSSERIAL:
return set_serial_info(tty, info, argp);
case TIOCSERCONFIG:
@@ -1403,7 +1401,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
}
if (--port->count < 0) {
printk("rs_close: bad serial port count for ttys%d: %d\n",
- state->line, port->count);
+ tty->index, port->count);
port->count = 0;
}
if (port->count) {
@@ -1720,12 +1718,13 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
* /proc fs routines....
*/
-static inline void line_info(struct seq_file *m, struct serial_state *state)
+static inline void line_info(struct seq_file *m, int line,
+ struct serial_state *state)
{
char stat_buf[30], control, status;
unsigned long flags;
- seq_printf(m, "%d: uart:amiga_builtin",state->line);
+ seq_printf(m, "%d: uart:amiga_builtin", line);
local_irq_save(flags);
status = ciab.pra;
@@ -1771,7 +1770,7 @@ static inline void line_info(struct seq_file *m, struct serial_state *state)
static int rs_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "serinfo:1.0 driver:%s\n", serial_version);
- line_info(m, &rs_table[0]);
+ line_info(m, 0, &rs_table[0]);
return 0;
}
@@ -1867,7 +1866,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state = rs_table;
state->port = (int)&custom.serdatr; /* Just to give it a value */
- state->line = 0;
state->custom_divisor = 0;
state->icount.cts = state->icount.dsr =
state->icount.rng = state->icount.dcd = 0;
@@ -1876,8 +1874,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state->icount.overrun = state->icount.brk = 0;
tty_port_init(&state->tport);
- printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
- state->line);
+ printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n");
/* Hardware set up */
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
index 9a04dec..77afbdb 100644
--- a/include/linux/serialP.h
+++ b/include/linux/serialP.h
@@ -29,9 +29,6 @@
struct serial_state {
int baud_base;
unsigned long port;
- int irq;
- int type;
- int line;
int xmit_fifo_size;
int custom_divisor;
struct async_icount icount;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 58/68] TTY: amiserial no longer needs serialP
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (55 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 57/68] TTY: amiserial, stop using serial_state->{irq,type,line} Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 59/68] TTY: amiserial, provide carrier helpers Jiri Slaby
` (12 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
amiserial is the last user of serialP.h. Let's move struct
serial_state directly to amiserial and remove serialP crap from
includes. Finally, remove the header from the tree completely.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 20 ++++++++++++++++++-
include/linux/serialP.h | 49 -----------------------------------------------
2 files changed, 19 insertions(+), 50 deletions(-)
delete mode 100644 include/linux/serialP.h
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index b182bcc..613d6a3 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -58,7 +58,6 @@
#include <linux/types.h>
#include <linux/serial.h>
-#include <linux/serialP.h>
#include <linux/serial_reg.h>
static char *serial_version = "4.30";
@@ -70,6 +69,7 @@ static char *serial_version = "4.30";
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
+#include <linux/circ_buf.h>
#include <linux/console.h>
#include <linux/major.h>
#include <linux/string.h>
@@ -92,6 +92,24 @@ static char *serial_version = "4.30";
#include <asm/amigahw.h>
#include <asm/amigaints.h>
+struct serial_state {
+ struct tty_port tport;
+ struct circ_buf xmit;
+ struct async_icount icount;
+
+ unsigned long port;
+ int baud_base;
+ int xmit_fifo_size;
+ int custom_divisor;
+ int read_status_mask;
+ int ignore_status_mask;
+ int timeout;
+ int quot;
+ int IER; /* Interrupt Enable Register */
+ int MCR; /* Modem control register */
+ int x_char; /* xon/xoff character */
+};
+
#define custom amiga_custom
static char *serial_name = "Amiga-builtin serial driver";
diff --git a/include/linux/serialP.h b/include/linux/serialP.h
deleted file mode 100644
index 77afbdb..0000000
--- a/include/linux/serialP.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Private header file for the (dumb) serial driver
- *
- * Copyright (C) 1997 by Theodore Ts'o.
- *
- * Redistribution of this file is permitted under the terms of the GNU
- * Public License (GPL)
- */
-
-#ifndef _LINUX_SERIALP_H
-#define _LINUX_SERIALP_H
-
-/*
- * This is our internal structure for each serial port's state.
- *
- * Many fields are paralleled by the structure used by the serial_struct
- * structure.
- *
- * For definitions of the flags field, see tty.h
- */
-
-#include <linux/termios.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/circ_buf.h>
-#include <linux/tty.h>
-#include <linux/wait.h>
-
-struct serial_state {
- int baud_base;
- unsigned long port;
- int xmit_fifo_size;
- int custom_divisor;
- struct async_icount icount;
- struct tty_port tport;
-
- /* amiserial */
- int read_status_mask;
- int ignore_status_mask;
- int timeout;
- int quot;
- int IER; /* Interrupt Enable Register */
- int MCR; /* Modem control register */
- int x_char; /* xon/xoff character */
- struct circ_buf xmit;
- /* /amiserial */
-};
-
-#endif /* _LINUX_SERIAL_H */
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 59/68] TTY: amiserial, provide carrier helpers
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (56 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 58/68] TTY: amiserial no longer needs serialP Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 60/68] TTY: amiserial, use tty_port_block_til_ready Jiri Slaby
` (11 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
This is a preparation for a switch to tty_port_block_til_ready. We
need amiga_carrier_raised and amiga_dtr_rts. The implementation is
taken from startup, shutdown and current block_til_ready.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 613d6a3..61d7461 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1623,10 +1623,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
local_irq_restore(flags);
port->blocked_open++;
while (1) {
- local_irq_save(flags);
if (tty->termios->c_cflag & CBAUD)
- rtsdtr_ctrl(SER_DTR|SER_RTS);
- local_irq_restore(flags);
+ tty_port_raise_dtr_rts(port);
set_current_state(TASK_INTERRUPTIBLE);
if (tty_hung_up_p(filp) ||
!(port->flags & ASYNC_INITIALIZED)) {
@@ -1641,7 +1639,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
break;
}
if (!(port->flags & ASYNC_CLOSING) &&
- (do_clocal || (!(ciab.pra & SER_DCD)) ))
+ (do_clocal || tty_port_carrier_raised(port)))
break;
if (signal_pending(current)) {
retval = -ERESTARTSYS;
@@ -1849,6 +1847,32 @@ static const struct tty_operations serial_ops = {
.proc_fops = &rs_proc_fops,
};
+static int amiga_carrier_raised(struct tty_port *port)
+{
+ return !(ciab.pra & SER_DCD);
+}
+
+static void amiga_dtr_rts(struct tty_port *port, int raise)
+{
+ struct serial_state *info = container_of(port, struct serial_state,
+ tport);
+ unsigned long flags;
+
+ if (raise)
+ info->MCR |= SER_DTR|SER_RTS;
+ else
+ info->MCR &= ~(SER_DTR|SER_RTS);
+
+ local_irq_save(flags);
+ rtsdtr_ctrl(info->MCR);
+ local_irq_restore(flags);
+}
+
+static const struct tty_port_operations amiga_port_ops = {
+ .carrier_raised = amiga_carrier_raised,
+ .dtr_rts = amiga_dtr_rts,
+};
+
/*
* The serial driver boot-time initialization code!
*/
@@ -1891,6 +1915,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
state->icount.frame = state->icount.parity = 0;
state->icount.overrun = state->icount.brk = 0;
tty_port_init(&state->tport);
+ state->tport.ops = &amiga_port_ops;
printk(KERN_INFO "ttyS0 is the amiga builtin serial port\n");
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 60/68] TTY: amiserial, use tty_port_block_til_ready
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (57 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 59/68] TTY: amiserial, provide carrier helpers Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 61/68] TTY: amiserial, use tty_port_close_end Jiri Slaby
` (10 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
Hmm, 150 lines of duplicated stuff is gone now.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 148 +----------------------------------------------
1 file changed, 1 insertion(+), 147 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 61d7461..8cc8e15 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1556,119 +1556,6 @@ static void rs_hangup(struct tty_struct *tty)
}
/*
- * ------------------------------------------------------------
- * rs_open() and friends
- * ------------------------------------------------------------
- */
-static int block_til_ready(struct tty_struct *tty, struct file * filp,
- struct serial_state *info)
-{
-#ifdef DECLARE_WAITQUEUE
- DECLARE_WAITQUEUE(wait, current);
-#else
- struct wait_queue wait = { current, NULL };
-#endif
- struct tty_port *port = &info->tport;
- int retval;
- int do_clocal = 0, extra_count = 0;
- unsigned long flags;
-
- /*
- * If the device is in the middle of being closed, then block
- * until it's done, and then try again.
- */
- if (tty_hung_up_p(filp) ||
- (port->flags & ASYNC_CLOSING)) {
- if (port->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&port->close_wait);
-#ifdef SERIAL_DO_RESTART
- return ((port->flags & ASYNC_HUP_NOTIFY) ?
- -EAGAIN : -ERESTARTSYS);
-#else
- return -EAGAIN;
-#endif
- }
-
- /*
- * If non-blocking mode is set, or the port is not enabled,
- * then make the check up front and then exit.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR))) {
- port->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
-
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
-
- /*
- * Block waiting for the carrier detect and the line to become
- * free (i.e., not in use by the callout). While we are in
- * this loop, port->count is dropped by one, so that
- * rs_close() knows when to free things. We restore it upon
- * exit, either normal or abnormal.
- */
- retval = 0;
- add_wait_queue(&port->open_wait, &wait);
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready before block: ttys%d, count = %d\n",
- info->line, port->count);
-#endif
- local_irq_save(flags);
- if (!tty_hung_up_p(filp)) {
- extra_count = 1;
- port->count--;
- }
- local_irq_restore(flags);
- port->blocked_open++;
- while (1) {
- if (tty->termios->c_cflag & CBAUD)
- tty_port_raise_dtr_rts(port);
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(port->flags & ASYNC_INITIALIZED)) {
-#ifdef SERIAL_DO_RESTART
- if (port->flags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
-#else
- retval = -EAGAIN;
-#endif
- break;
- }
- if (!(port->flags & ASYNC_CLOSING) &&
- (do_clocal || tty_port_carrier_raised(port)))
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready blocking: ttys%d, count = %d\n",
- info->line, port->count);
-#endif
- tty_unlock();
- schedule();
- tty_lock();
- }
- __set_current_state(TASK_RUNNING);
- remove_wait_queue(&port->open_wait, &wait);
- if (extra_count)
- port->count++;
- port->blocked_open--;
-#ifdef SERIAL_DEBUG_OPEN
- printk("block_til_ready after blocking: ttys%d, count = %d\n",
- info->line, port->count);
-#endif
- if (retval)
- return retval;
- port->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
-}
-
-/*
* This routine is called whenever a serial port is opened. It
* enables interrupts for a serial port, linking in its async structure into
* the IRQ chain. It also performs the serial-specific
@@ -1687,47 +1574,14 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
if (serial_paranoia_check(info, tty->name, "rs_open"))
return -ENODEV;
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s, count = %d\n", tty->name, info->count);
-#endif
tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
- /*
- * If the port is the middle of closing, bail out now
- */
- if (tty_hung_up_p(filp) ||
- (port->flags & ASYNC_CLOSING)) {
- if (port->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&port->close_wait);
-#ifdef SERIAL_DO_RESTART
- return ((port->flags & ASYNC_HUP_NOTIFY) ?
- -EAGAIN : -ERESTARTSYS);
-#else
- return -EAGAIN;
-#endif
- }
-
- /*
- * Start up serial port
- */
retval = startup(tty, info);
if (retval) {
return retval;
}
- retval = block_til_ready(tty, filp, info);
- if (retval) {
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open returning after block_til_ready with %d\n",
- retval);
-#endif
- return retval;
- }
-
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_open %s successful...", tty->name);
-#endif
- return 0;
+ return tty_port_block_til_ready(port, tty, filp);
}
/*
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 61/68] TTY: amiserial, use tty_port_close_end
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (58 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 60/68] TTY: amiserial, use tty_port_block_til_ready Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 62/68] TTY: amiserial, use tty_port_close_start Jiri Slaby
` (9 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
Hmm, the code was sleeping with interrupts disabled. This was not
good. Fix this by turning interrupts at an appropriate place. (The
race is protected by CLOSING flag.)
After the move, the code is identical to tty_port_close_end, so use
it!
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 8cc8e15..9c8b199 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1433,6 +1433,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
* the line discipline to only process XON/XOFF characters.
*/
tty->closing = 1;
+ local_irq_restore(flags);
if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, port->closing_wait);
/*
@@ -1461,17 +1462,9 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
rs_flush_buffer(tty);
tty_ldisc_flush(tty);
- tty->closing = 0;
port->tty = NULL;
- if (port->blocked_open) {
- if (port->close_delay) {
- msleep_interruptible(jiffies_to_msecs(port->close_delay));
- }
- wake_up_interruptible(&port->open_wait);
- }
- port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
- wake_up_interruptible(&port->close_wait);
- local_irq_restore(flags);
+
+ tty_port_close_end(port, tty);
}
/*
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 62/68] TTY: amiserial, use tty_port_close_start
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (59 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 61/68] TTY: amiserial, use tty_port_close_end Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 63/68] TTY: pdc_cons, fix racy tty test Jiri Slaby
` (8 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
Again, no need to duplicate the code. Let's use the helper.
Amiserial changes are only free of compilation errors. I have no
access to the hardware.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 44 ++------------------------------------------
1 file changed, 2 insertions(+), 42 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 9c8b199..afadcd43d 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -1389,53 +1389,13 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
{
struct serial_state *state = tty->driver_data;
struct tty_port *port = &state->tport;
- unsigned long flags;
- if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
+ if (serial_paranoia_check(state, tty->name, "rs_close"))
return;
- local_irq_save(flags);
-
- if (tty_hung_up_p(filp)) {
- DBG_CNT("before DEC-hung");
- local_irq_restore(flags);
+ if (tty_port_close_start(port, tty, filp) == 0)
return;
- }
-#ifdef SERIAL_DEBUG_OPEN
- printk("rs_close ttys%d, count = %d\n", state->line, port->count);
-#endif
- if ((tty->count == 1) && (port->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. port->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk("rs_close: bad serial port count; tty->count is 1, "
- "port->count is %d\n", state->tport.count);
- port->count = 1;
- }
- if (--port->count < 0) {
- printk("rs_close: bad serial port count for ttys%d: %d\n",
- tty->index, port->count);
- port->count = 0;
- }
- if (port->count) {
- DBG_CNT("before DEC-2");
- local_irq_restore(flags);
- return;
- }
- port->flags |= ASYNC_CLOSING;
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
- local_irq_restore(flags);
- if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, port->closing_wait);
/*
* At this point we stop accepting input. To do this, we
* disable the receive line status interrupts, and tell the
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 63/68] TTY: pdc_cons, fix racy tty test
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (60 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 62/68] TTY: amiserial, use tty_port_close_start Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 64/68] TTY: pdc_cons, fix open vs timer race Jiri Slaby
` (7 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Kyle McMartin,
Helge Deller, James E.J. Bottomley
The tty->count test in the timer was racy. Let's remove the test and
properly delete the timer and wait for the body to finish using _sync
version of del_timer.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
---
arch/parisc/kernel/pdc_cons.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index fc770be..c1db65f 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -103,7 +103,7 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
{
if (!tty->count)
- del_timer(&pdc_console_timer);
+ del_timer_sync(&pdc_console_timer);
}
static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -153,7 +153,7 @@ static void pdc_console_poll(unsigned long unused)
if (count)
tty_flip_buffer_push(tty);
- if (tty->count && (pdc_cons.flags & CON_ENABLED))
+ if (pdc_cons.flags & CON_ENABLED)
mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 64/68] TTY: pdc_cons, fix open vs timer race
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (61 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 63/68] TTY: pdc_cons, fix racy tty test Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 65/68] TTY: pdc_cons, fix open vs pdc_console_tty_driver race Jiri Slaby
` (6 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Kyle McMartin,
Helge Deller, James E.J. Bottomley
The timer is initialized too late. tty->open may fire an invalid
timer. So initialize the timer earlier using DEFINE_TIMER.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
---
arch/parisc/kernel/pdc_cons.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index c1db65f..8ad0521 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -90,7 +90,8 @@ static int pdc_console_setup(struct console *co, char *options)
#define PDC_CONS_POLL_DELAY (30 * HZ / 1000)
-static struct timer_list pdc_console_timer;
+static void pdc_console_poll(unsigned long unused);
+static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
{
@@ -205,10 +206,6 @@ static int __init pdc_console_tty_driver_init(void)
pdc_console_tty_driver = drv;
- /* No need to initialize the pdc_console_timer if tty isn't allocated */
- init_timer(&pdc_console_timer);
- pdc_console_timer.function = pdc_console_poll;
-
return 0;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 65/68] TTY: pdc_cons, fix open vs pdc_console_tty_driver race
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (62 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 64/68] TTY: pdc_cons, fix open vs timer race Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 66/68] TTY: pdc_cons, use tty_port Jiri Slaby
` (5 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Kyle McMartin,
Helge Deller, James E.J. Bottomley
Assign the pointer to pdc_console_tty_driver (a tty_driver) earlier.
Otherwise the timer may dereference NULL.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
---
arch/parisc/kernel/pdc_cons.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index 8ad0521..d14e20f 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -160,9 +160,7 @@ static void pdc_console_poll(unsigned long unused)
static int __init pdc_console_tty_driver_init(void)
{
-
int err;
- struct tty_driver *drv;
/* Check if the console driver is still registered.
* It is unregistered if the pdc console was not selected as the
@@ -184,28 +182,27 @@ static int __init pdc_console_tty_driver_init(void)
printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
pdc_cons.flags &= ~CON_BOOT;
- drv = alloc_tty_driver(1);
+ pdc_console_tty_driver = alloc_tty_driver(1);
- if (!drv)
+ if (!pdc_console_tty_driver)
return -ENOMEM;
- drv->driver_name = "pdc_cons";
- drv->name = "ttyB";
- drv->major = MUX_MAJOR;
- drv->minor_start = 0;
- drv->type = TTY_DRIVER_TYPE_SYSTEM;
- drv->init_termios = tty_std_termios;
- drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
- tty_set_operations(drv, &pdc_console_tty_ops);
-
- err = tty_register_driver(drv);
+ pdc_console_tty_driver->driver_name = "pdc_cons";
+ pdc_console_tty_driver->name = "ttyB";
+ pdc_console_tty_driver->major = MUX_MAJOR;
+ pdc_console_tty_driver->minor_start = 0;
+ pdc_console_tty_driver->type = TTY_DRIVER_TYPE_SYSTEM;
+ pdc_console_tty_driver->init_termios = tty_std_termios;
+ pdc_console_tty_driver->flags = TTY_DRIVER_REAL_RAW |
+ TTY_DRIVER_RESET_TERMIOS;
+ tty_set_operations(pdc_console_tty_driver, &pdc_console_tty_ops);
+
+ err = tty_register_driver(pdc_console_tty_driver);
if (err) {
printk(KERN_ERR "Unable to register the PDC console TTY driver\n");
return err;
}
- pdc_console_tty_driver = drv;
-
return 0;
}
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 66/68] TTY: pdc_cons, use tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (63 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 65/68] TTY: pdc_cons, fix open vs pdc_console_tty_driver race Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL Jiri Slaby
` (4 subsequent siblings)
69 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Kyle McMartin,
Helge Deller, James E.J. Bottomley
Instead of digging a tty out of the tty_driver struct, which is not
defined to work, use tty_port properly. This includes proper tty
refcounting even though there is no possible race currently. But we
will need tty_port for tty buffers in the future anyway.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Helge Deller <deller@gmx.de>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
---
arch/parisc/kernel/pdc_cons.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/arch/parisc/kernel/pdc_cons.c b/arch/parisc/kernel/pdc_cons.c
index d14e20f..4f00459 100644
--- a/arch/parisc/kernel/pdc_cons.c
+++ b/arch/parisc/kernel/pdc_cons.c
@@ -92,10 +92,11 @@ static int pdc_console_setup(struct console *co, char *options)
static void pdc_console_poll(unsigned long unused);
static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
+static struct tty_port tty_port;
static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
{
-
+ tty_port_tty_set(&tty_port, tty);
mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
return 0;
@@ -103,8 +104,10 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
{
- if (!tty->count)
+ if (!tty->count) {
del_timer_sync(&pdc_console_timer);
+ tty_port_tty_set(&tty_port, NULL);
+ }
}
static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
@@ -123,8 +126,6 @@ static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty)
return 0; /* no buffer */
}
-static struct tty_driver *pdc_console_tty_driver;
-
static const struct tty_operations pdc_console_tty_ops = {
.open = pdc_console_tty_open,
.close = pdc_console_tty_close,
@@ -135,10 +136,8 @@ static const struct tty_operations pdc_console_tty_ops = {
static void pdc_console_poll(unsigned long unused)
{
-
int data, count = 0;
-
- struct tty_struct *tty = pdc_console_tty_driver->ttys[0];
+ struct tty_struct *tty = tty_port_tty_get(&tty_port);
if (!tty)
return;
@@ -154,10 +153,14 @@ static void pdc_console_poll(unsigned long unused)
if (count)
tty_flip_buffer_push(tty);
+ tty_kref_put(tty);
+
if (pdc_cons.flags & CON_ENABLED)
mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
}
+static struct tty_driver *pdc_console_tty_driver;
+
static int __init pdc_console_tty_driver_init(void)
{
int err;
@@ -182,6 +185,8 @@ static int __init pdc_console_tty_driver_init(void)
printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
pdc_cons.flags &= ~CON_BOOT;
+ tty_port_init(&tty_port);
+
pdc_console_tty_driver = alloc_tty_driver(1);
if (!pdc_console_tty_driver)
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (64 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 66/68] TTY: pdc_cons, use tty_port Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 17:05 ` Tilman Schmidt
2012-03-05 13:52 ` [PATCH 68/68] TTY: isdn/gigaset, use tty_port Jiri Slaby
` (3 subsequent siblings)
69 siblings, 1 reply; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Hansjoerg Lipp,
Tilman Schmidt, gigaset307x-common
Close the window in open where driver_data is reset to NULL on each
open. It could cause other processes to get invalid retval from the
tty->ops operations because of the checks all over the code.
With this change we may do other cleanups. Now, the only valid check
for tty->driver_data != NULL is in close. This can happen only if open
fails at gigaset_get_cs_by_tty or try_module_get. The rest of checks
in various tty->ops->* are invalid as driver_data cannot be NULL
there. The same holds for cs->open_count. So remove them.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Hansjoerg Lipp <hjlipp@web.de>
Cc: Tilman Schmidt <tilman@imap.cc>
Cc: gigaset307x-common@lists.sourceforge.net
---
drivers/isdn/gigaset/interface.c | 105 +++++---------------------------------
1 file changed, 14 insertions(+), 91 deletions(-)
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 7e54577..040f5f9 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -151,8 +151,6 @@ static int if_open(struct tty_struct *tty, struct file *filp)
gig_dbg(DEBUG_IF, "%d+%d: %s()",
tty->driver->minor_start, tty->index, __func__);
- tty->driver_data = NULL;
-
cs = gigaset_get_cs_by_tty(tty);
if (!cs || !try_module_get(cs->driver->owner))
return -ENODEV;
@@ -178,12 +176,11 @@ static int if_open(struct tty_struct *tty, struct file *filp)
static void if_close(struct tty_struct *tty, struct file *filp)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
unsigned long flags;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
+ if (!cs) { /* happens if we didn't find cs in open */
+ printk(KERN_DEBUG "%s: no cardstate\n", __func__);
return;
}
@@ -211,18 +208,12 @@ static void if_close(struct tty_struct *tty, struct file *filp)
static int if_ioctl(struct tty_struct *tty,
unsigned int cmd, unsigned long arg)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
int retval = -ENODEV;
int int_arg;
unsigned char buf[6];
unsigned version[4];
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return -ENODEV;
- }
-
gig_dbg(DEBUG_IF, "%u: %s(0x%x)", cs->minor_index, __func__, cmd);
if (mutex_lock_interruptible(&cs->mutex))
@@ -231,9 +222,7 @@ static int if_ioctl(struct tty_struct *tty,
if (!cs->connected) {
gig_dbg(DEBUG_IF, "not connected");
retval = -ENODEV;
- } else if (!cs->open_count)
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
- else {
+ } else {
retval = 0;
switch (cmd) {
case GIGASET_REDIR:
@@ -285,15 +274,9 @@ static int if_ioctl(struct tty_struct *tty,
static int if_tiocmget(struct tty_struct *tty)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
int retval;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return -ENODEV;
- }
-
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (mutex_lock_interruptible(&cs->mutex))
@@ -309,16 +292,10 @@ static int if_tiocmget(struct tty_struct *tty)
static int if_tiocmset(struct tty_struct *tty,
unsigned int set, unsigned int clear)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
int retval;
unsigned mc;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return -ENODEV;
- }
-
gig_dbg(DEBUG_IF, "%u: %s(0x%x, 0x%x)",
cs->minor_index, __func__, set, clear);
@@ -341,16 +318,10 @@ static int if_tiocmset(struct tty_struct *tty,
static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
struct cmdbuf_t *cb;
int retval;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return -ENODEV;
- }
-
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (mutex_lock_interruptible(&cs->mutex))
@@ -361,11 +332,6 @@ static int if_write(struct tty_struct *tty, const unsigned char *buf, int count)
retval = -ENODEV;
goto done;
}
- if (!cs->open_count) {
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
- retval = -ENODEV;
- goto done;
- }
if (cs->mstate != MS_LOCKED) {
dev_warn(cs->dev, "can't write to unlocked device\n");
retval = -EBUSY;
@@ -397,15 +363,9 @@ done:
static int if_write_room(struct tty_struct *tty)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
int retval = -ENODEV;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return -ENODEV;
- }
-
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
if (mutex_lock_interruptible(&cs->mutex))
@@ -414,9 +374,7 @@ static int if_write_room(struct tty_struct *tty)
if (!cs->connected) {
gig_dbg(DEBUG_IF, "not connected");
retval = -ENODEV;
- } else if (!cs->open_count)
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
- else if (cs->mstate != MS_LOCKED) {
+ } else if (cs->mstate != MS_LOCKED) {
dev_warn(cs->dev, "can't write to unlocked device\n");
retval = -EBUSY;
} else
@@ -429,23 +387,15 @@ static int if_write_room(struct tty_struct *tty)
static int if_chars_in_buffer(struct tty_struct *tty)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
int retval = 0;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return 0;
- }
-
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
mutex_lock(&cs->mutex);
if (!cs->connected)
gig_dbg(DEBUG_IF, "not connected");
- else if (!cs->open_count)
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
else if (cs->mstate != MS_LOCKED)
dev_warn(cs->dev, "can't write to unlocked device\n");
else
@@ -458,13 +408,7 @@ static int if_chars_in_buffer(struct tty_struct *tty)
static void if_throttle(struct tty_struct *tty)
{
- struct cardstate *cs;
-
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return;
- }
+ struct cardstate *cs = tty->driver_data;
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
@@ -472,8 +416,6 @@ static void if_throttle(struct tty_struct *tty)
if (!cs->connected)
gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
- else if (!cs->open_count)
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
else
gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
@@ -482,13 +424,7 @@ static void if_throttle(struct tty_struct *tty)
static void if_unthrottle(struct tty_struct *tty)
{
- struct cardstate *cs;
-
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return;
- }
+ struct cardstate *cs = tty->driver_data;
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
@@ -496,8 +432,6 @@ static void if_unthrottle(struct tty_struct *tty)
if (!cs->connected)
gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
- else if (!cs->open_count)
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
else
gig_dbg(DEBUG_IF, "%s: not implemented\n", __func__);
@@ -506,18 +440,12 @@ static void if_unthrottle(struct tty_struct *tty)
static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
{
- struct cardstate *cs;
+ struct cardstate *cs = tty->driver_data;
unsigned int iflag;
unsigned int cflag;
unsigned int old_cflag;
unsigned int control_state, new_state;
- cs = (struct cardstate *) tty->driver_data;
- if (!cs) {
- pr_err("%s: no cardstate\n", __func__);
- return;
- }
-
gig_dbg(DEBUG_IF, "%u: %s()", cs->minor_index, __func__);
mutex_lock(&cs->mutex);
@@ -527,11 +455,6 @@ static void if_set_termios(struct tty_struct *tty, struct ktermios *old)
goto out;
}
- if (!cs->open_count) {
- dev_warn(cs->dev, "%s: device not opened\n", __func__);
- goto out;
- }
-
iflag = tty->termios->c_iflag;
cflag = tty->termios->c_cflag;
old_cflag = old ? old->c_cflag : cflag;
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* [PATCH 68/68] TTY: isdn/gigaset, use tty_port
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (65 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL Jiri Slaby
@ 2012-03-05 13:52 ` Jiri Slaby
2012-03-05 17:08 ` Tilman Schmidt
2012-03-08 19:50 ` [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Greg KH
` (2 subsequent siblings)
69 siblings, 1 reply; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Hansjoerg Lipp,
Tilman Schmidt, gigaset307x-common
Let us port the code to use tty_port. We now use open_count and tty
from there. This allows us also to use tty_port_tty_set with tty
refcounting instead of hand-written locking and logic.
Note that tty and open_count are no longer protected by cs->lock. It is
protected by tty_port->lock. But since all the places where they were
used are now switched to the helpers, we are fine.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Hansjoerg Lipp <hjlipp@web.de>
Cc: Tilman Schmidt <tilman@imap.cc>
Cc: gigaset307x-common@lists.sourceforge.net
---
drivers/isdn/gigaset/common.c | 3 +--
drivers/isdn/gigaset/gigaset.h | 3 +--
drivers/isdn/gigaset/interface.c | 46 ++++++++++++++++----------------------
3 files changed, 21 insertions(+), 31 deletions(-)
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index db6e434..7679270 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -720,12 +720,11 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
tasklet_init(&cs->event_tasklet, gigaset_handle_event,
(unsigned long) cs);
+ tty_port_init(&cs->port);
cs->commands_pending = 0;
cs->cur_at_seq = 0;
cs->gotfwver = -1;
- cs->open_count = 0;
cs->dev = NULL;
- cs->tty = NULL;
cs->tty_dev = NULL;
cs->cidmode = cidmode != 0;
cs->tabnocid = gigaset_tab_nocid;
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 8fad99e..1dc2513 100644
--- a/drivers/isdn/gigaset/gigaset.h
+++ b/drivers/isdn/gigaset/gigaset.h
@@ -433,8 +433,7 @@ struct cardstate {
spinlock_t cmdlock;
unsigned curlen, cmdbytes;
- unsigned open_count;
- struct tty_struct *tty;
+ struct tty_port port;
struct tasklet_struct if_wake_tasklet;
unsigned control_state;
diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 040f5f9..b3d6ac1 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -146,7 +146,6 @@ static const struct tty_operations if_ops = {
static int if_open(struct tty_struct *tty, struct file *filp)
{
struct cardstate *cs;
- unsigned long flags;
gig_dbg(DEBUG_IF, "%d+%d: %s()",
tty->driver->minor_start, tty->index, __func__);
@@ -161,12 +160,10 @@ static int if_open(struct tty_struct *tty, struct file *filp)
}
tty->driver_data = cs;
- ++cs->open_count;
+ ++cs->port.count;
- if (cs->open_count == 1) {
- spin_lock_irqsave(&cs->lock, flags);
- cs->tty = tty;
- spin_unlock_irqrestore(&cs->lock, flags);
+ if (cs->port.count == 1) {
+ tty_port_tty_set(&cs->port, tty);
tty->low_latency = 1;
}
@@ -177,7 +174,6 @@ static int if_open(struct tty_struct *tty, struct file *filp)
static void if_close(struct tty_struct *tty, struct file *filp)
{
struct cardstate *cs = tty->driver_data;
- unsigned long flags;
if (!cs) { /* happens if we didn't find cs in open */
printk(KERN_DEBUG "%s: no cardstate\n", __func__);
@@ -190,15 +186,10 @@ static void if_close(struct tty_struct *tty, struct file *filp)
if (!cs->connected)
gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
- else if (!cs->open_count)
+ else if (!cs->port.count)
dev_warn(cs->dev, "%s: device not opened\n", __func__);
- else {
- if (!--cs->open_count) {
- spin_lock_irqsave(&cs->lock, flags);
- cs->tty = NULL;
- spin_unlock_irqrestore(&cs->lock, flags);
- }
- }
+ else if (!--cs->port.count)
+ tty_port_tty_set(&cs->port, NULL);
mutex_unlock(&cs->mutex);
@@ -511,10 +502,13 @@ out:
/* wakeup tasklet for the write operation */
static void if_wake(unsigned long data)
{
- struct cardstate *cs = (struct cardstate *) data;
+ struct cardstate *cs = (struct cardstate *)data;
+ struct tty_struct *tty = tty_port_tty_get(&cs->port);
- if (cs->tty)
- tty_wakeup(cs->tty);
+ if (tty) {
+ tty_wakeup(tty);
+ tty_kref_put(tty);
+ }
}
/*** interface to common ***/
@@ -567,18 +561,16 @@ void gigaset_if_free(struct cardstate *cs)
void gigaset_if_receive(struct cardstate *cs,
unsigned char *buffer, size_t len)
{
- unsigned long flags;
- struct tty_struct *tty;
+ struct tty_struct *tty = tty_port_tty_get(&cs->port);
- spin_lock_irqsave(&cs->lock, flags);
- tty = cs->tty;
- if (tty == NULL)
+ if (tty == NULL) {
gig_dbg(DEBUG_IF, "receive on closed device");
- else {
- tty_insert_flip_string(tty, buffer, len);
- tty_flip_buffer_push(tty);
+ return;
}
- spin_unlock_irqrestore(&cs->lock, flags);
+
+ tty_insert_flip_string(tty, buffer, len);
+ tty_flip_buffer_push(tty);
+ tty_kref_put(tty);
}
EXPORT_SYMBOL_GPL(gigaset_if_receive);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 79+ messages in thread
* Re: [PATCH 15/68] TTY: ipwireless, fix tty->index handling
2012-03-05 13:52 ` [PATCH 15/68] TTY: ipwireless, fix tty->index handling Jiri Slaby
@ 2012-03-05 14:03 ` Jiri Kosina
0 siblings, 0 replies; 79+ messages in thread
From: Jiri Kosina @ 2012-03-05 14:03 UTC (permalink / raw)
To: Jiri Slaby
Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby, David Sterba
On Mon, 5 Mar 2012, Jiri Slaby wrote:
> * 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>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Thanks Jiri.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 01/68] USB: cdc-acm, use tty_standard_install
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
@ 2012-03-05 14:03 ` Jiri Slaby
2012-03-05 14:14 ` Oliver Neukum
2012-03-05 23:39 ` Alan Cox
1 sibling, 1 reply; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 14:03 UTC (permalink / raw)
To: Jiri Slaby
Cc: gregkh, alan, linux-serial, linux-kernel, Oliver Neukum, USB list
Forgot to CC maintainers. Done now.
On 03/05/2012 02:51 PM, Jiri Slaby wrote:
> This is a piece I missed the last time.
>
> Do not copy the functionality all over the tree. Instead, use the
> helper the tty layer provides us with.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
> drivers/usb/class/cdc-acm.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
> index 6dcc3a3..b3fd449 100644
> --- a/drivers/usb/class/cdc-acm.c
> +++ b/drivers/usb/class/cdc-acm.c
> @@ -509,17 +509,12 @@ static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
> if (!acm)
> return -ENODEV;
>
> - retval = tty_init_termios(tty);
> + retval = tty_standard_install(driver, tty);
> if (retval)
> goto error_init_termios;
>
> tty->driver_data = acm;
>
> - /* Final install (we use the default method) */
> - tty_driver_kref_get(driver);
> - tty->count++;
> - driver->ttys[tty->index] = tty;
> -
> return 0;
>
> error_init_termios:
--
js
suse labs
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 01/68] USB: cdc-acm, use tty_standard_install
2012-03-05 14:03 ` Jiri Slaby
@ 2012-03-05 14:14 ` Oliver Neukum
0 siblings, 0 replies; 79+ messages in thread
From: Oliver Neukum @ 2012-03-05 14:14 UTC (permalink / raw)
To: Jiri Slaby
Cc: Jiri Slaby, gregkh, alan, linux-serial, linux-kernel,
Oliver Neukum, USB list
Am Montag, 5. März 2012, 15:03:41 schrieb Jiri Slaby:
> Forgot to CC maintainers. Done now.
>
> On 03/05/2012 02:51 PM, Jiri Slaby wrote:
> > This is a piece I missed the last time.
> >
> > Do not copy the functionality all over the tree. Instead, use the
> > helper the tty layer provides us with.
> >
> > Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Oliver Neukum <oneukum@suse.de>
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL
2012-03-05 13:52 ` [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL Jiri Slaby
@ 2012-03-05 17:05 ` Tilman Schmidt
2012-03-05 17:12 ` Jiri Slaby
0 siblings, 1 reply; 79+ messages in thread
From: Tilman Schmidt @ 2012-03-05 17:05 UTC (permalink / raw)
To: Jiri Slaby
Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby,
Hansjoerg Lipp, gigaset307x-common
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 05.03.2012 14:52, schrieb Jiri Slaby:
> Close the window in open where driver_data is reset to NULL on each
> open. It could cause other processes to get invalid retval from the
> tty->ops operations because of the checks all over the code.
>
> With this change we may do other cleanups. Now, the only valid check
> for tty->driver_data != NULL is in close. This can happen only if open
> fails at gigaset_get_cs_by_tty or try_module_get. The rest of checks
> in various tty->ops->* are invalid as driver_data cannot be NULL
> there. The same holds for cs->open_count. So remove them.
Thanks for that nice cleanup. It's most welcome.
Just one question and a small nit:
> --- a/drivers/isdn/gigaset/interface.c
> +++ b/drivers/isdn/gigaset/interface.c
[...]
> @@ -178,12 +176,11 @@ static int if_open(struct tty_struct *tty, struct file *filp)
>
> static void if_close(struct tty_struct *tty, struct file *filp)
> {
> - struct cardstate *cs;
> + struct cardstate *cs = tty->driver_data;
> unsigned long flags;
>
> - cs = (struct cardstate *) tty->driver_data;
> - if (!cs) {
> - pr_err("%s: no cardstate\n", __func__);
> + if (!cs) { /* happens if we didn't find cs in open */
> + printk(KERN_DEBUG "%s: no cardstate\n", __func__);
> return;
> }
>
Why are you downgrading the error message from KERN_ERR to KERN_DEBUG
here? I would think that condition would warrant a message with
KERN_ERR severity.
Also, the driver does KERN_DEBUG output uniformly through the gig_dbg
macro, so if you are sure it should be turned into a debug message
then please write it as
gig_dbg(DEBUG_IF, "%s: no cardstate", __func__);
like four lines later.
Thanks,
Tilman
- --
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/
iEYEARECAAYFAk9U8nAACgkQQ3+did9BuFsaiwCeKiL8hghkVcjstG5azxYoIXOK
Yl0Anj2FWsaiE4zx3ioVvCo6xgFVKBTk
=i3+X
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 68/68] TTY: isdn/gigaset, use tty_port
2012-03-05 13:52 ` [PATCH 68/68] TTY: isdn/gigaset, use tty_port Jiri Slaby
@ 2012-03-05 17:08 ` Tilman Schmidt
0 siblings, 0 replies; 79+ messages in thread
From: Tilman Schmidt @ 2012-03-05 17:08 UTC (permalink / raw)
To: Jiri Slaby
Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby,
Hansjoerg Lipp, gigaset307x-common
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 05.03.2012 14:52, schrieb Jiri Slaby:
> Let us port the code to use tty_port. We now use open_count and tty
> from there. This allows us also to use tty_port_tty_set with tty
> refcounting instead of hand-written locking and logic.
>
> Note that tty and open_count are no longer protected by cs->lock. It is
> protected by tty_port->lock. But since all the places where they were
> used are now switched to the helpers, we are fine.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Hansjoerg Lipp <hjlipp@web.de>
> Cc: Tilman Schmidt <tilman@imap.cc>
> Cc: gigaset307x-common@lists.sourceforge.net
Very nice. Thanks!
Acked-by: Tilman Schmidt <tilman@imap.cc>
- --
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/
iEYEARECAAYFAk9U8vAACgkQQ3+did9BuFv8RACeLMRSUGhjotg0il1LtWqtfrzR
sakAn0LJr66dYyUXteH44p5+KFQuS5v9
=Is+Q
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL
2012-03-05 17:05 ` Tilman Schmidt
@ 2012-03-05 17:12 ` Jiri Slaby
0 siblings, 0 replies; 79+ messages in thread
From: Jiri Slaby @ 2012-03-05 17:12 UTC (permalink / raw)
To: Tilman Schmidt
Cc: Jiri Slaby, gregkh, alan, linux-serial, linux-kernel,
Hansjoerg Lipp, gigaset307x-common
On 03/05/2012 06:05 PM, Tilman Schmidt wrote:
> Am 05.03.2012 14:52, schrieb Jiri Slaby:
>> Close the window in open where driver_data is reset to NULL on
>> each open. It could cause other processes to get invalid retval
>> from the tty->ops operations because of the checks all over the
>> code.
>
>> With this change we may do other cleanups. Now, the only valid
>> check for tty->driver_data != NULL is in close. This can happen
>> only if open fails at gigaset_get_cs_by_tty or try_module_get.
>> The rest of checks in various tty->ops->* are invalid as
>> driver_data cannot be NULL there. The same holds for
>> cs->open_count. So remove them.
>
> Thanks for that nice cleanup. It's most welcome. Just one question
> and a small nit:
>
>> --- a/drivers/isdn/gigaset/interface.c +++
>> b/drivers/isdn/gigaset/interface.c
> [...]
>> @@ -178,12 +176,11 @@ static int if_open(struct tty_struct *tty,
>> struct file *filp)
>
>> static void if_close(struct tty_struct *tty, struct file *filp)
>> { - struct cardstate *cs; + struct cardstate *cs =
>> tty->driver_data; unsigned long flags;
>
>> - cs = (struct cardstate *) tty->driver_data; - if (!cs) { -
>> pr_err("%s: no cardstate\n", __func__); + if (!cs) { /* happens
>> if we didn't find cs in open */ + printk(KERN_DEBUG "%s: no
>> cardstate\n", __func__); return; }
>
>
> Why are you downgrading the error message from KERN_ERR to
> KERN_DEBUG here? I would think that condition would warrant a
> message with KERN_ERR severity. Also, the driver does KERN_DEBUG
> output uniformly through the gig_dbg macro, so if you are sure it
> should be turned into a debug message then please write it as
>
> gig_dbg(DEBUG_IF, "%s: no cardstate", __func__);
>
> like four lines later.
<citing myself from the commit log>
Now, the only valid check for tty->driver_data != NULL is in close.
This can happen only if open fails at gigaset_get_cs_by_tty or
try_module_get.
</citing>
I.e. when the module behind the device is going away, driver_data can
be NULL. In that case we don't want to threaten the user by ERR messages.
You are maybe right, that we should switch it to gig_dbg or remove the
print completely (as it is a legitimate path). I'll wait until the
patches settles down a bit and fix it. If I, by a chance, forget to do
so, poke me or feel free to do it yourself ;).
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 01/68] USB: cdc-acm, use tty_standard_install
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
2012-03-05 14:03 ` Jiri Slaby
@ 2012-03-05 23:39 ` Alan Cox
1 sibling, 0 replies; 79+ messages in thread
From: Alan Cox @ 2012-03-05 23:39 UTC (permalink / raw)
To: Jiri Slaby; +Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby
On Mon, 5 Mar 2012 14:51:48 +0100
Jiri Slaby <jslaby@suse.cz> wrote:
> This is a piece I missed the last time.
>
> Do not copy the functionality all over the tree. Instead, use the
> helper the tty layer provides us with.
All looks sane to me
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 05/68] TTY: remove re-assignments to tty_driver members
2012-03-05 13:51 ` [PATCH 05/68] TTY: remove re-assignments to tty_driver members Jiri Slaby
@ 2012-03-06 23:49 ` Tilman Schmidt
0 siblings, 0 replies; 79+ messages in thread
From: Tilman Schmidt @ 2012-03-06 23:49 UTC (permalink / raw)
To: Jiri Slaby; +Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
Am 05.03.2012 14:51, schrieb Jiri Slaby:
> All num, magic and owner are set by alloc_tty_driver. No need to
> re-set them on each allocation site.
Nice.
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
For drivers/isdn/gigaset:
Acked-by: Tilman Schmidt <tilman@imap.cc>
> 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;
Thanks,
Tilman
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 00/68] TTY buffer in tty_port -- prep no. 1
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (66 preceding siblings ...)
2012-03-05 13:52 ` [PATCH 68/68] TTY: isdn/gigaset, use tty_port Jiri Slaby
@ 2012-03-08 19:50 ` Greg KH
2012-03-08 20:51 ` Greg KH
2012-03-18 8:56 ` Geert Uytterhoeven
69 siblings, 0 replies; 79+ messages in thread
From: Greg KH @ 2012-03-08 19:50 UTC (permalink / raw)
To: Jiri Slaby; +Cc: alan, linux-serial, linux-kernel, jirislaby
On Mon, Mar 05, 2012 at 02:51:47PM +0100, Jiri Slaby wrote:
> 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.
Where are those patches at specifically? Can you send them to me so I
could include them in my tree? Otherwise I can only apply the first 27
of these patches (which I have now done.)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 00/68] TTY buffer in tty_port -- prep no. 1
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (67 preceding siblings ...)
2012-03-08 19:50 ` [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Greg KH
@ 2012-03-08 20:51 ` Greg KH
2012-03-18 8:56 ` Geert Uytterhoeven
69 siblings, 0 replies; 79+ messages in thread
From: Greg KH @ 2012-03-08 20:51 UTC (permalink / raw)
To: Jiri Slaby; +Cc: alan, linux-serial, linux-kernel, jirislaby
On Mon, Mar 05, 2012 at 02:51:47PM +0100, Jiri Slaby wrote:
> 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.
Very nice work, all queued up now.
greg k-h
^ permalink raw reply [flat|nested] 79+ messages in thread
* Re: [PATCH 00/68] TTY buffer in tty_port -- prep no. 1
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
` (68 preceding siblings ...)
2012-03-08 20:51 ` Greg KH
@ 2012-03-18 8:56 ` Geert Uytterhoeven
69 siblings, 0 replies; 79+ messages in thread
From: Geert Uytterhoeven @ 2012-03-18 8:56 UTC (permalink / raw)
To: Jiri Slaby; +Cc: gregkh, alan, linux-serial, linux-kernel, jirislaby
Hi Jiri,
On Mon, Mar 5, 2012 at 14:51, Jiri Slaby <jslaby@suse.cz> wrote:
> 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.
I had a look at all 19 patches touching amiserial, and they look fine. So
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Thanks for the cleanup!
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 79+ messages in thread
end of thread, other threads:[~2012-03-18 8:56 UTC | newest]
Thread overview: 79+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-05 13:51 [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Jiri Slaby
2012-03-05 13:51 ` [PATCH 01/68] USB: cdc-acm, use tty_standard_install Jiri Slaby
2012-03-05 14:03 ` Jiri Slaby
2012-03-05 14:14 ` Oliver Neukum
2012-03-05 23:39 ` Alan Cox
2012-03-05 13:51 ` [PATCH 02/68] TTY: tty_io, remove buffer re-assignments Jiri Slaby
2012-03-05 13:51 ` [PATCH 03/68] TTY: let alloc_tty_driver deduce the owner automatically Jiri Slaby
2012-03-05 13:51 ` [PATCH 04/68] TTY: remove minor_num from tty_driver Jiri Slaby
2012-03-05 13:51 ` [PATCH 05/68] TTY: remove re-assignments to tty_driver members Jiri Slaby
2012-03-06 23:49 ` Tilman Schmidt
2012-03-05 13:51 ` [PATCH 06/68] TTY: simplify tty_driver_lookup_tty a bit Jiri Slaby
2012-03-05 13:51 ` [PATCH 07/68] TTY: remove tty driver re-set from tty_reopen Jiri Slaby
2012-03-05 13:51 ` [PATCH 08/68] TTY: serial, simplify ASYNC_USR_MASK Jiri Slaby
2012-03-05 13:51 ` [PATCH 09/68] TTY: tty_driver, document tty->ops->shutdown limitation Jiri Slaby
2012-03-05 13:51 ` [PATCH 10/68] ALPHA: srmcons, use timer functions Jiri Slaby
2012-03-05 13:51 ` [PATCH 11/68] ALPHA: srmcons, fix racy singleton structure Jiri Slaby
2012-03-05 13:51 ` [PATCH 12/68] TTY: srmcons, convert to use tty_port Jiri Slaby
2012-03-05 13:52 ` [PATCH 13/68] TTY: serialP, remove DECLARE_WAITQUEUE check Jiri Slaby
2012-03-05 13:52 ` [PATCH 14/68] TTY: remove unneeded tty->index checks Jiri Slaby
2012-03-05 13:52 ` [PATCH 15/68] TTY: ipwireless, fix tty->index handling Jiri Slaby
2012-03-05 14:03 ` Jiri Kosina
2012-03-05 13:52 ` [PATCH 16/68] NET: pc300, do not zero global variables Jiri Slaby
2012-03-05 13:52 ` [PATCH 17/68] NET: pc300, show version info from module init Jiri Slaby
2012-03-05 13:52 ` [PATCH 18/68] XTENSA: iss/console, use setup_timer Jiri Slaby
2012-03-05 13:52 ` [PATCH 19/68] XTENSA: iss/console, fix potential deadlock Jiri Slaby
2012-03-05 13:52 ` [PATCH 20/68] TTY: iss/console, use tty_port Jiri Slaby
2012-03-05 13:52 ` [PATCH 21/68] TTY: serial, use atomic_inc_return in ioc4_serial Jiri Slaby
2012-03-05 13:52 ` [PATCH 22/68] TTY: serial, include pci.h in m32r_sio Jiri Slaby
2012-03-05 13:52 ` [PATCH 23/68] TTY: remove serialP.h inclusion from some files Jiri Slaby
2012-03-05 13:52 ` [PATCH 24/68] TTY: speakup, do not use serialP Jiri Slaby
2012-03-05 13:52 ` [PATCH 25/68] TTY: serialP, remove unused material Jiri Slaby
2012-03-05 13:52 ` [PATCH 26/68] TTY: amiserial, remove tasklet for tty_wakeup Jiri Slaby
2012-03-05 13:52 ` [PATCH 27/68] TTY: amiserial, use only one copy of async flags Jiri Slaby
2012-03-05 13:52 ` [PATCH 28/68] TTY: simserial, " Jiri Slaby
2012-03-05 13:52 ` [PATCH 29/68] TTY: simserial/amiserial, use one instance of other members Jiri Slaby
2012-03-05 13:52 ` [PATCH 30/68] TTY: simserial, remove support of shared interrupts Jiri Slaby
2012-03-05 13:52 ` [PATCH 31/68] TTY: simserial, remove IRQ_T Jiri Slaby
2012-03-05 13:52 ` [PATCH 32/68] TTY: amiserial, remove IRQ_ports Jiri Slaby
2012-03-05 13:52 ` [PATCH 33/68] TTY: serialP, merge serial_state and async_struct Jiri Slaby
2012-03-05 13:52 ` [PATCH 34/68] TTY: amiserial, simplify set_serial_info Jiri Slaby
2012-03-05 13:52 ` [PATCH 35/68] TTY: amiserial, pass tty down to functions Jiri Slaby
2012-03-05 13:52 ` [PATCH 36/68] TTY: simserial, " Jiri Slaby
2012-03-05 13:52 ` [PATCH 37/68] TTY: amiserial/simserial, use tty_port Jiri Slaby
2012-03-05 13:52 ` [PATCH 38/68] TTY: amiserial/simserial, use close delays from tty_port Jiri Slaby
2012-03-05 13:52 ` [PATCH 39/68] TTY: amiserial/simserial, use count " Jiri Slaby
2012-03-05 13:52 ` [PATCH 40/68] TTY: amiserial/simserial, use flags " Jiri Slaby
2012-03-05 13:52 ` [PATCH 41/68] TTY: simserial, remove static initialization Jiri Slaby
2012-03-05 13:52 ` [PATCH 42/68] TTY: simserial, remove tmp_buf Jiri Slaby
2012-03-05 13:52 ` [PATCH 43/68] TTY: simserial, stop using serial_state->{line,icount} Jiri Slaby
2012-03-05 13:52 ` [PATCH 44/68] TTY: simserial no longer needs serialP Jiri Slaby
2012-03-05 13:52 ` [PATCH 45/68] TTY: simserial, define local tty_port pointer Jiri Slaby
2012-03-05 13:52 ` [PATCH 46/68] TTY: simserial, remove some tty ops Jiri Slaby
2012-03-05 13:52 ` [PATCH 48/68] TTY: simserial, use tty_port_close_start Jiri Slaby
2012-03-05 13:52 ` [PATCH 49/68] TTY: simserial, properly refcount tty_port->tty Jiri Slaby
2012-03-05 13:52 ` [PATCH 50/68] TTY: simserial, use tty_port_open Jiri Slaby
2012-03-05 13:52 ` [PATCH 51/68] TTY: simserial, use tty_port_hangup Jiri Slaby
2012-03-05 13:52 ` [PATCH 52/68] TTY: simserial, remove useless comments Jiri Slaby
2012-03-05 13:52 ` [PATCH 53/68] TTY: simserial, fix includes Jiri Slaby
2012-03-05 13:52 ` [PATCH 54/68] TTY: simserial, reindent some code Jiri Slaby
2012-03-05 13:52 ` [PATCH 55/68] TTY: simserial, final cleanup Jiri Slaby
2012-03-05 13:52 ` [PATCH 56/68] TTY: amiserial, define local tty_port pointer Jiri Slaby
2012-03-05 13:52 ` [PATCH 57/68] TTY: amiserial, stop using serial_state->{irq,type,line} Jiri Slaby
2012-03-05 13:52 ` [PATCH 58/68] TTY: amiserial no longer needs serialP Jiri Slaby
2012-03-05 13:52 ` [PATCH 59/68] TTY: amiserial, provide carrier helpers Jiri Slaby
2012-03-05 13:52 ` [PATCH 60/68] TTY: amiserial, use tty_port_block_til_ready Jiri Slaby
2012-03-05 13:52 ` [PATCH 61/68] TTY: amiserial, use tty_port_close_end Jiri Slaby
2012-03-05 13:52 ` [PATCH 62/68] TTY: amiserial, use tty_port_close_start Jiri Slaby
2012-03-05 13:52 ` [PATCH 63/68] TTY: pdc_cons, fix racy tty test Jiri Slaby
2012-03-05 13:52 ` [PATCH 64/68] TTY: pdc_cons, fix open vs timer race Jiri Slaby
2012-03-05 13:52 ` [PATCH 65/68] TTY: pdc_cons, fix open vs pdc_console_tty_driver race Jiri Slaby
2012-03-05 13:52 ` [PATCH 66/68] TTY: pdc_cons, use tty_port Jiri Slaby
2012-03-05 13:52 ` [PATCH 67/68] TTY: isdn/gigaset, do not set tty->driver_data to NULL Jiri Slaby
2012-03-05 17:05 ` Tilman Schmidt
2012-03-05 17:12 ` Jiri Slaby
2012-03-05 13:52 ` [PATCH 68/68] TTY: isdn/gigaset, use tty_port Jiri Slaby
2012-03-05 17:08 ` Tilman Schmidt
2012-03-08 19:50 ` [PATCH 00/68] TTY buffer in tty_port -- prep no. 1 Greg KH
2012-03-08 20:51 ` Greg KH
2012-03-18 8:56 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).