* [PATCH 32/68] TTY: amiserial, remove IRQ_ports
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
They used to work as a storage for 'info' pointer used in ISRs. They
are not really needed. Just pass the pointer through request_irq to
the handlers.
It was set to NULL and tested in the ISRs, but we do not need the
tests as we disable all the interrupts at the same places where NULL
sets were.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/tty/amiserial.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 5540216..7607c6e 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -100,8 +100,6 @@ static struct tty_driver *serial_driver;
/* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256
-static struct async_struct *IRQ_ports;
-
static unsigned char current_ctl_bits;
static void change_speed(struct async_struct *info, struct ktermios *old);
@@ -439,7 +437,7 @@ static void check_modem_status(struct async_struct *info)
static irqreturn_t ser_vbl_int( int irq, void *data)
{
/* vbl is just a periodic interrupt we tie into to update modem status */
- struct async_struct * info = IRQ_ports;
+ struct async_struct *info = data;
/*
* TBD - is it better to unregister from this interrupt or to
* ignore it if MSI is clear ?
@@ -451,13 +449,13 @@ static irqreturn_t ser_vbl_int( int irq, void *data)
static irqreturn_t ser_rx_int(int irq, void *dev_id)
{
- struct async_struct * info;
+ struct serial_state *state = dev_id;
+ struct async_struct *info = state->info;
#ifdef SERIAL_DEBUG_INTR
printk("ser_rx_int...");
#endif
- info = IRQ_ports;
if (!info || !info->tty)
return IRQ_NONE;
@@ -470,14 +468,14 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
static irqreturn_t ser_tx_int(int irq, void *dev_id)
{
- struct async_struct * info;
+ struct serial_state *state = dev_id;
+ struct async_struct *info = state->info;
if (custom.serdatr & SDR_TBE) {
#ifdef SERIAL_DEBUG_INTR
printk("ser_tx_int...");
#endif
- info = IRQ_ports;
if (!info || !info->tty)
return IRQ_NONE;
@@ -554,8 +552,6 @@ static int startup(struct async_struct * info)
/* remember current state of the DCD and CTS bits */
current_ctl_bits = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
- IRQ_ports = info;
-
info->MCR = 0;
if (info->tty->termios->c_cflag & CBAUD)
info->MCR = SER_DTR | SER_RTS;
@@ -619,8 +615,6 @@ static void shutdown(struct async_struct * info)
*/
wake_up_interruptible(&info->delta_msr_wait);
- IRQ_ports = NULL;
-
/*
* Free the IRQ, if necessary
*/
@@ -1913,8 +1907,6 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
if (!serial_driver)
return -ENOMEM;
- IRQ_ports = NULL;
-
show_serial_version();
/* Initialize the tty_driver structure */
--
1.7.9.2
^ permalink raw reply related
* [PATCH 34/68] TTY: amiserial, simplify set_serial_info
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 35/68] TTY: amiserial, pass tty down to functions
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 38/68] TTY: amiserial/simserial, use close delays from tty_port
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 39/68] TTY: amiserial/simserial, use count from tty_port
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 40/68] TTY: amiserial/simserial, use flags from tty_port
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh
Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven,
Tony Luck, Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
This 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
* [PATCH 41/68] TTY: simserial, remove static initialization
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
We do not 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
* [PATCH 42/68] TTY: simserial, remove tmp_buf
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 43/68] TTY: simserial, stop using serial_state->{line,icount}
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
* 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
* [PATCH 45/68] TTY: simserial, define local tty_port pointer
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 48/68] TTY: simserial, use tty_port_close_start
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 50/68] TTY: simserial, use tty_port_open
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 51/68] TTY: simserial, use tty_port_hangup
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 52/68] TTY: simserial, remove useless comments
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 53/68] TTY: simserial, fix includes
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 54/68] TTY: simserial, reindent some code
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 55/68] TTY: simserial, final cleanup
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Tony Luck,
Fenghua Yu
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
* 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
* [PATCH 56/68] TTY: amiserial, define local tty_port pointer
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 57/68] TTY: amiserial, stop using serial_state->{irq,type,line}
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
* 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
* [PATCH 58/68] TTY: amiserial no longer needs serialP
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 59/68] TTY: amiserial, provide carrier helpers
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 60/68] TTY: amiserial, use tty_port_block_til_ready
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 61/68] TTY: amiserial, use tty_port_close_end
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 62/68] TTY: amiserial, use tty_port_close_start
From: Jiri Slaby @ 2012-03-05 13:52 UTC (permalink / raw)
To: gregkh; +Cc: alan, linux-serial, linux-kernel, jirislaby, Geert Uytterhoeven
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
* [PATCH 63/68] TTY: pdc_cons, fix racy tty test
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
In-Reply-To: <1330955575-26641-1-git-send-email-jslaby@suse.cz>
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
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox