TTY: amiserial/simserial, use tty_port
Add tty_port to serial_state and start using common tty port members from tty_port in amiserial and simserial. The rest will follow one by one. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5e99d54587
commit
87758791c9
|
@ -165,7 +165,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
struct serial_state *info = dev_id;
|
struct serial_state *info = dev_id;
|
||||||
|
|
||||||
if (!info->tty) {
|
if (!info->tport.tty) {
|
||||||
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
|
printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
|
||||||
* pretty simple in our case, because we only get interrupts
|
* pretty simple in our case, because we only get interrupts
|
||||||
* on inbound traffic
|
* on inbound traffic
|
||||||
*/
|
*/
|
||||||
receive_chars(info->tty);
|
receive_chars(info->tport.tty);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,14 +533,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
|
||||||
shutdown(tty, info);
|
shutdown(tty, info);
|
||||||
rs_flush_buffer(tty);
|
rs_flush_buffer(tty);
|
||||||
tty_ldisc_flush(tty);
|
tty_ldisc_flush(tty);
|
||||||
info->tty = NULL;
|
info->tport.tty = NULL;
|
||||||
if (info->blocked_open) {
|
if (info->tport.blocked_open) {
|
||||||
if (info->close_delay)
|
if (info->close_delay)
|
||||||
schedule_timeout_interruptible(info->close_delay);
|
schedule_timeout_interruptible(info->close_delay);
|
||||||
wake_up_interruptible(&info->open_wait);
|
wake_up_interruptible(&info->tport.open_wait);
|
||||||
}
|
}
|
||||||
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
|
info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
|
||||||
wake_up_interruptible(&info->close_wait);
|
wake_up_interruptible(&info->tport.close_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -569,8 +569,8 @@ static void rs_hangup(struct tty_struct *tty)
|
||||||
|
|
||||||
info->count = 0;
|
info->count = 0;
|
||||||
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
||||||
info->tty = NULL;
|
info->tport.tty = NULL;
|
||||||
wake_up_interruptible(&info->open_wait);
|
wake_up_interruptible(&info->tport.open_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -662,8 +662,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
|
||||||
unsigned long page;
|
unsigned long page;
|
||||||
|
|
||||||
info->count++;
|
info->count++;
|
||||||
info->tty = tty;
|
info->tport.tty = tty;
|
||||||
tty->driver_data = info;
|
tty->driver_data = info;
|
||||||
|
tty->port = &info->tport;
|
||||||
|
|
||||||
#ifdef SIMSERIAL_DEBUG
|
#ifdef SIMSERIAL_DEBUG
|
||||||
printk("rs_open %s, count = %d\n", tty->name, info->count);
|
printk("rs_open %s, count = %d\n", tty->name, info->count);
|
||||||
|
@ -685,7 +686,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
|
||||||
*/
|
*/
|
||||||
if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
|
if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) {
|
||||||
if (info->flags & ASYNC_CLOSING)
|
if (info->flags & ASYNC_CLOSING)
|
||||||
interruptible_sleep_on(&info->close_wait);
|
interruptible_sleep_on(&info->tport.close_wait);
|
||||||
#ifdef SERIAL_DO_RESTART
|
#ifdef SERIAL_DO_RESTART
|
||||||
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
|
@ -827,8 +828,7 @@ simrs_init (void)
|
||||||
* Let's have a little bit of fun !
|
* Let's have a little bit of fun !
|
||||||
*/
|
*/
|
||||||
for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
|
for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
|
||||||
init_waitqueue_head(&state->open_wait);
|
tty_port_init(&state->tport);
|
||||||
init_waitqueue_head(&state->close_wait);
|
|
||||||
|
|
||||||
if (state->type == PORT_UNKNOWN) continue;
|
if (state->type == PORT_UNKNOWN) continue;
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ static void receive_chars(struct serial_state *info)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int serdatr;
|
int serdatr;
|
||||||
struct tty_struct *tty = info->tty;
|
struct tty_struct *tty = info->tport.tty;
|
||||||
unsigned char ch, flag;
|
unsigned char ch, flag;
|
||||||
struct async_icount *icount;
|
struct async_icount *icount;
|
||||||
int oe = 0;
|
int oe = 0;
|
||||||
|
@ -331,8 +331,8 @@ static void transmit_chars(struct serial_state *info)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (info->xmit.head == info->xmit.tail
|
if (info->xmit.head == info->xmit.tail
|
||||||
|| info->tty->stopped
|
|| info->tport.tty->stopped
|
||||||
|| info->tty->hw_stopped) {
|
|| info->tport.tty->hw_stopped) {
|
||||||
info->IER &= ~UART_IER_THRI;
|
info->IER &= ~UART_IER_THRI;
|
||||||
custom.intena = IF_TBE;
|
custom.intena = IF_TBE;
|
||||||
mb();
|
mb();
|
||||||
|
@ -347,7 +347,7 @@ static void transmit_chars(struct serial_state *info)
|
||||||
if (CIRC_CNT(info->xmit.head,
|
if (CIRC_CNT(info->xmit.head,
|
||||||
info->xmit.tail,
|
info->xmit.tail,
|
||||||
SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
|
SERIAL_XMIT_SIZE) < WAKEUP_CHARS)
|
||||||
tty_wakeup(info->tty);
|
tty_wakeup(info->tport.tty);
|
||||||
|
|
||||||
#ifdef SERIAL_DEBUG_INTR
|
#ifdef SERIAL_DEBUG_INTR
|
||||||
printk("THRE...");
|
printk("THRE...");
|
||||||
|
@ -384,7 +384,7 @@ static void check_modem_status(struct serial_state *info)
|
||||||
}
|
}
|
||||||
if (dstatus & SER_CTS)
|
if (dstatus & SER_CTS)
|
||||||
icount->cts++;
|
icount->cts++;
|
||||||
wake_up_interruptible(&info->delta_msr_wait);
|
wake_up_interruptible(&info->tport.delta_msr_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
|
if ((info->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
|
||||||
|
@ -393,29 +393,29 @@ static void check_modem_status(struct serial_state *info)
|
||||||
(!(status & SER_DCD)) ? "on" : "off");
|
(!(status & SER_DCD)) ? "on" : "off");
|
||||||
#endif
|
#endif
|
||||||
if (!(status & SER_DCD))
|
if (!(status & SER_DCD))
|
||||||
wake_up_interruptible(&info->open_wait);
|
wake_up_interruptible(&info->tport.open_wait);
|
||||||
else {
|
else {
|
||||||
#ifdef SERIAL_DEBUG_OPEN
|
#ifdef SERIAL_DEBUG_OPEN
|
||||||
printk("doing serial hangup...");
|
printk("doing serial hangup...");
|
||||||
#endif
|
#endif
|
||||||
if (info->tty)
|
if (info->tport.tty)
|
||||||
tty_hangup(info->tty);
|
tty_hangup(info->tport.tty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info->flags & ASYNC_CTS_FLOW) {
|
if (info->flags & ASYNC_CTS_FLOW) {
|
||||||
if (info->tty->hw_stopped) {
|
if (info->tport.tty->hw_stopped) {
|
||||||
if (!(status & SER_CTS)) {
|
if (!(status & SER_CTS)) {
|
||||||
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
|
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
|
||||||
printk("CTS tx start...");
|
printk("CTS tx start...");
|
||||||
#endif
|
#endif
|
||||||
info->tty->hw_stopped = 0;
|
info->tport.tty->hw_stopped = 0;
|
||||||
info->IER |= UART_IER_THRI;
|
info->IER |= UART_IER_THRI;
|
||||||
custom.intena = IF_SETCLR | IF_TBE;
|
custom.intena = IF_SETCLR | IF_TBE;
|
||||||
mb();
|
mb();
|
||||||
/* set a pending Tx Interrupt, transmitter should restart now */
|
/* set a pending Tx Interrupt, transmitter should restart now */
|
||||||
custom.intreq = IF_SETCLR | IF_TBE;
|
custom.intreq = IF_SETCLR | IF_TBE;
|
||||||
mb();
|
mb();
|
||||||
tty_wakeup(info->tty);
|
tty_wakeup(info->tport.tty);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -423,7 +423,7 @@ static void check_modem_status(struct serial_state *info)
|
||||||
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
|
#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
|
||||||
printk("CTS tx stop...");
|
printk("CTS tx stop...");
|
||||||
#endif
|
#endif
|
||||||
info->tty->hw_stopped = 1;
|
info->tport.tty->hw_stopped = 1;
|
||||||
info->IER &= ~UART_IER_THRI;
|
info->IER &= ~UART_IER_THRI;
|
||||||
/* disable Tx interrupt and remove any pending interrupts */
|
/* disable Tx interrupt and remove any pending interrupts */
|
||||||
custom.intena = IF_TBE;
|
custom.intena = IF_TBE;
|
||||||
|
@ -456,7 +456,7 @@ static irqreturn_t ser_rx_int(int irq, void *dev_id)
|
||||||
printk("ser_rx_int...");
|
printk("ser_rx_int...");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!info->tty)
|
if (!info->tport.tty)
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
|
|
||||||
receive_chars(info);
|
receive_chars(info);
|
||||||
|
@ -475,7 +475,7 @@ static irqreturn_t ser_tx_int(int irq, void *dev_id)
|
||||||
printk("ser_tx_int...");
|
printk("ser_tx_int...");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!info->tty)
|
if (!info->tport.tty)
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
|
|
||||||
transmit_chars(info);
|
transmit_chars(info);
|
||||||
|
@ -607,7 +607,7 @@ static void shutdown(struct tty_struct *tty, struct serial_state *info)
|
||||||
* clear delta_msr_wait queue to avoid mem leaks: we may free the irq
|
* clear delta_msr_wait queue to avoid mem leaks: we may free the irq
|
||||||
* here so the queue might never be waken up
|
* here so the queue might never be waken up
|
||||||
*/
|
*/
|
||||||
wake_up_interruptible(&info->delta_msr_wait);
|
wake_up_interruptible(&info->tport.delta_msr_wait);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the IRQ, if necessary
|
* Free the IRQ, if necessary
|
||||||
|
@ -1274,7 +1274,7 @@ static int rs_ioctl(struct tty_struct *tty,
|
||||||
cprev = info->icount;
|
cprev = info->icount;
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
while (1) {
|
while (1) {
|
||||||
interruptible_sleep_on(&info->delta_msr_wait);
|
interruptible_sleep_on(&info->tport.delta_msr_wait);
|
||||||
/* see if a signal did it */
|
/* see if a signal did it */
|
||||||
if (signal_pending(current))
|
if (signal_pending(current))
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
|
@ -1442,15 +1442,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
|
||||||
|
|
||||||
tty_ldisc_flush(tty);
|
tty_ldisc_flush(tty);
|
||||||
tty->closing = 0;
|
tty->closing = 0;
|
||||||
state->tty = NULL;
|
state->tport.tty = NULL;
|
||||||
if (state->blocked_open) {
|
if (state->tport.blocked_open) {
|
||||||
if (state->close_delay) {
|
if (state->close_delay) {
|
||||||
msleep_interruptible(jiffies_to_msecs(state->close_delay));
|
msleep_interruptible(jiffies_to_msecs(state->close_delay));
|
||||||
}
|
}
|
||||||
wake_up_interruptible(&state->open_wait);
|
wake_up_interruptible(&state->tport.open_wait);
|
||||||
}
|
}
|
||||||
state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
|
state->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
|
||||||
wake_up_interruptible(&state->close_wait);
|
wake_up_interruptible(&state->tport.close_wait);
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1531,8 +1531,8 @@ static void rs_hangup(struct tty_struct *tty)
|
||||||
shutdown(tty, info);
|
shutdown(tty, info);
|
||||||
info->count = 0;
|
info->count = 0;
|
||||||
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
info->flags &= ~ASYNC_NORMAL_ACTIVE;
|
||||||
info->tty = NULL;
|
info->tport.tty = NULL;
|
||||||
wake_up_interruptible(&info->open_wait);
|
wake_up_interruptible(&info->tport.open_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1559,7 +1559,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
|
||||||
if (tty_hung_up_p(filp) ||
|
if (tty_hung_up_p(filp) ||
|
||||||
(info->flags & ASYNC_CLOSING)) {
|
(info->flags & ASYNC_CLOSING)) {
|
||||||
if (info->flags & ASYNC_CLOSING)
|
if (info->flags & ASYNC_CLOSING)
|
||||||
interruptible_sleep_on(&info->close_wait);
|
interruptible_sleep_on(&info->tport.close_wait);
|
||||||
#ifdef SERIAL_DO_RESTART
|
#ifdef SERIAL_DO_RESTART
|
||||||
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
|
@ -1589,7 +1589,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
|
||||||
* exit, either normal or abnormal.
|
* exit, either normal or abnormal.
|
||||||
*/
|
*/
|
||||||
retval = 0;
|
retval = 0;
|
||||||
add_wait_queue(&info->open_wait, &wait);
|
add_wait_queue(&info->tport.open_wait, &wait);
|
||||||
#ifdef SERIAL_DEBUG_OPEN
|
#ifdef SERIAL_DEBUG_OPEN
|
||||||
printk("block_til_ready before block: ttys%d, count = %d\n",
|
printk("block_til_ready before block: ttys%d, count = %d\n",
|
||||||
info->line, info->count);
|
info->line, info->count);
|
||||||
|
@ -1600,7 +1600,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
|
||||||
info->count--;
|
info->count--;
|
||||||
}
|
}
|
||||||
local_irq_restore(flags);
|
local_irq_restore(flags);
|
||||||
info->blocked_open++;
|
info->tport.blocked_open++;
|
||||||
while (1) {
|
while (1) {
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
if (tty->termios->c_cflag & CBAUD)
|
if (tty->termios->c_cflag & CBAUD)
|
||||||
|
@ -1635,10 +1635,10 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
|
||||||
tty_lock();
|
tty_lock();
|
||||||
}
|
}
|
||||||
__set_current_state(TASK_RUNNING);
|
__set_current_state(TASK_RUNNING);
|
||||||
remove_wait_queue(&info->open_wait, &wait);
|
remove_wait_queue(&info->tport.open_wait, &wait);
|
||||||
if (extra_count)
|
if (extra_count)
|
||||||
info->count++;
|
info->count++;
|
||||||
info->blocked_open--;
|
info->tport.blocked_open--;
|
||||||
#ifdef SERIAL_DEBUG_OPEN
|
#ifdef SERIAL_DEBUG_OPEN
|
||||||
printk("block_til_ready after blocking: ttys%d, count = %d\n",
|
printk("block_til_ready after blocking: ttys%d, count = %d\n",
|
||||||
info->line, info->count);
|
info->line, info->count);
|
||||||
|
@ -1661,8 +1661,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
info->count++;
|
info->count++;
|
||||||
info->tty = tty;
|
info->tport.tty = tty;
|
||||||
tty->driver_data = info;
|
tty->driver_data = info;
|
||||||
|
tty->port = &info->tport;
|
||||||
if (serial_paranoia_check(info, tty->name, "rs_open"))
|
if (serial_paranoia_check(info, tty->name, "rs_open"))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
@ -1677,7 +1678,7 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
|
||||||
if (tty_hung_up_p(filp) ||
|
if (tty_hung_up_p(filp) ||
|
||||||
(info->flags & ASYNC_CLOSING)) {
|
(info->flags & ASYNC_CLOSING)) {
|
||||||
if (info->flags & ASYNC_CLOSING)
|
if (info->flags & ASYNC_CLOSING)
|
||||||
interruptible_sleep_on(&info->close_wait);
|
interruptible_sleep_on(&info->tport.close_wait);
|
||||||
#ifdef SERIAL_DO_RESTART
|
#ifdef SERIAL_DO_RESTART
|
||||||
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
return ((info->flags & ASYNC_HUP_NOTIFY) ?
|
||||||
-EAGAIN : -ERESTARTSYS);
|
-EAGAIN : -ERESTARTSYS);
|
||||||
|
@ -1869,9 +1870,7 @@ static int __init amiga_serial_probe(struct platform_device *pdev)
|
||||||
state->icount.rx = state->icount.tx = 0;
|
state->icount.rx = state->icount.tx = 0;
|
||||||
state->icount.frame = state->icount.parity = 0;
|
state->icount.frame = state->icount.parity = 0;
|
||||||
state->icount.overrun = state->icount.brk = 0;
|
state->icount.overrun = state->icount.brk = 0;
|
||||||
init_waitqueue_head(&state->open_wait);
|
tty_port_init(&state->tport);
|
||||||
init_waitqueue_head(&state->close_wait);
|
|
||||||
init_waitqueue_head(&state->delta_msr_wait);
|
|
||||||
|
|
||||||
printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
|
printk(KERN_INFO "ttyS%d is the amiga builtin serial port\n",
|
||||||
state->line);
|
state->line);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/circ_buf.h>
|
#include <linux/circ_buf.h>
|
||||||
|
#include <linux/tty.h>
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
|
|
||||||
struct serial_state {
|
struct serial_state {
|
||||||
|
@ -38,6 +39,7 @@ struct serial_state {
|
||||||
unsigned short close_delay;
|
unsigned short close_delay;
|
||||||
unsigned short closing_wait; /* time to wait before closing */
|
unsigned short closing_wait; /* time to wait before closing */
|
||||||
struct async_icount icount;
|
struct async_icount icount;
|
||||||
|
struct tty_port tport;
|
||||||
|
|
||||||
/* amiserial */
|
/* amiserial */
|
||||||
int read_status_mask;
|
int read_status_mask;
|
||||||
|
@ -46,14 +48,9 @@ struct serial_state {
|
||||||
int quot;
|
int quot;
|
||||||
int IER; /* Interrupt Enable Register */
|
int IER; /* Interrupt Enable Register */
|
||||||
int MCR; /* Modem control register */
|
int MCR; /* Modem control register */
|
||||||
wait_queue_head_t delta_msr_wait;
|
|
||||||
/* simserial */
|
/* simserial */
|
||||||
int x_char; /* xon/xoff character */
|
int x_char; /* xon/xoff character */
|
||||||
int blocked_open; /* # of blocked opens */
|
|
||||||
struct circ_buf xmit;
|
struct circ_buf xmit;
|
||||||
wait_queue_head_t open_wait;
|
|
||||||
wait_queue_head_t close_wait;
|
|
||||||
struct tty_struct *tty;
|
|
||||||
/* /simserial */
|
/* /simserial */
|
||||||
/* /amiserial */
|
/* /amiserial */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue