Commit e60a1084 authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

rocket: use tty_port

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