Commit 47b01b3a authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

tty: kref the rocket driver

We will need this kref fitted to make full use of the port operations.
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 21bed701
...@@ -436,15 +436,15 @@ static void rp_do_transmit(struct r_port *info) ...@@ -436,15 +436,15 @@ static void rp_do_transmit(struct r_port *info)
#endif #endif
if (!info) if (!info)
return; return;
if (!info->port.tty) { tty = tty_port_tty_get(&info->port);
printk(KERN_WARNING "rp: WARNING %s called with "
"info->port.tty==NULL\n", __func__); if (tty == NULL) {
printk(KERN_WARNING "rp: WARNING %s called with 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->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 */
...@@ -478,6 +478,7 @@ static void rp_do_transmit(struct r_port *info) ...@@ -478,6 +478,7 @@ static void rp_do_transmit(struct r_port *info)
} }
spin_unlock_irqrestore(&info->slock, flags); spin_unlock_irqrestore(&info->slock, flags);
tty_kref_put(tty);
#ifdef ROCKET_DEBUG_INTR #ifdef ROCKET_DEBUG_INTR
printk(KERN_DEBUG "(%d,%d,%d,%d)...\n", info->xmit_cnt, info->xmit_head, printk(KERN_DEBUG "(%d,%d,%d,%d)...\n", info->xmit_cnt, info->xmit_head,
...@@ -504,13 +505,13 @@ static void rp_handle_port(struct r_port *info) ...@@ -504,13 +505,13 @@ static void rp_handle_port(struct r_port *info)
"info->flags & NOT_INIT\n"); "info->flags & NOT_INIT\n");
return; return;
} }
if (!info->port.tty) { tty = tty_port_tty_get(&info->port);
if (!tty) {
printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " printk(KERN_WARNING "rp: WARNING: rp_handle_port called with "
"info->port.tty==NULL\n"); "tty==NULL\n");
return; return;
} }
cp = &info->channel; cp = &info->channel;
tty = info->port.tty;
IntMask = sGetChanIntID(cp) & info->intmask; IntMask = sGetChanIntID(cp) & info->intmask;
#ifdef ROCKET_DEBUG_INTR #ifdef ROCKET_DEBUG_INTR
...@@ -542,6 +543,7 @@ static void rp_handle_port(struct r_port *info) ...@@ -542,6 +543,7 @@ static void rp_handle_port(struct r_port *info)
printk(KERN_INFO "DSR change...\n"); printk(KERN_INFO "DSR change...\n");
} }
#endif #endif
tty_kref_put(tty);
} }
/* /*
...@@ -710,7 +712,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) ...@@ -710,7 +712,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
* Configures a rocketport port according to its termio settings. Called from * Configures a rocketport port according to its termio settings. Called from
* user mode into the driver (exception handler). *info CD manipulation is spinlock protected. * user mode into the driver (exception handler). *info CD manipulation is spinlock protected.
*/ */
static void configure_r_port(struct r_port *info, static void configure_r_port(struct tty_struct *tty, struct r_port *info,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
unsigned cflag; unsigned cflag;
...@@ -718,7 +720,7 @@ static void configure_r_port(struct r_port *info, ...@@ -718,7 +720,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->port.tty->termios; struct ktermios *t = tty->termios;
cp = &info->channel; cp = &info->channel;
cflag = t->c_cflag; cflag = t->c_cflag;
...@@ -751,7 +753,7 @@ static void configure_r_port(struct r_port *info, ...@@ -751,7 +753,7 @@ static void configure_r_port(struct r_port *info,
} }
/* baud rate */ /* baud rate */
baud = tty_get_baud_rate(info->port.tty); baud = tty_get_baud_rate(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;
...@@ -769,7 +771,7 @@ static void configure_r_port(struct r_port *info, ...@@ -769,7 +771,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->port.tty, baud, baud); tty_encode_baud_rate(tty, baud, baud);
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
info->intmask |= DELTA_CTS; info->intmask |= DELTA_CTS;
...@@ -794,15 +796,15 @@ static void configure_r_port(struct r_port *info, ...@@ -794,15 +796,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->port.tty)) { if (I_IXON(tty)) {
sEnTxSoftFlowCtl(cp); sEnTxSoftFlowCtl(cp);
if (I_IXANY(info->port.tty)) { if (I_IXANY(tty)) {
sEnIXANY(cp); sEnIXANY(cp);
} else { } else {
sDisIXANY(cp); sDisIXANY(cp);
} }
sSetTxXONChar(cp, START_CHAR(info->port.tty)); sSetTxXONChar(cp, START_CHAR(tty));
sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty)); sSetTxXOFFChar(cp, STOP_CHAR(tty));
} else { } else {
sDisTxSoftFlowCtl(cp); sDisTxSoftFlowCtl(cp);
sDisIXANY(cp); sDisIXANY(cp);
...@@ -814,24 +816,24 @@ static void configure_r_port(struct r_port *info, ...@@ -814,24 +816,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->port.tty)) if (I_INPCK(tty))
info->read_status_mask |= STMFRAMEH | STMPARITYH; info->read_status_mask |= STMFRAMEH | STMPARITYH;
if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) if (I_BRKINT(tty) || I_PARMRK(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->port.tty)) if (I_IGNPAR(tty))
info->ignore_status_mask |= STMFRAMEH | STMPARITYH; info->ignore_status_mask |= STMFRAMEH | STMPARITYH;
if (I_IGNBRK(info->port.tty)) { if (I_IGNBRK(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->port.tty)) if (I_IGNPAR(tty))
info->ignore_status_mask |= STMRCVROVRH; info->ignore_status_mask |= STMRCVROVRH;
} }
...@@ -1015,7 +1017,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) ...@@ -1015,7 +1017,7 @@ 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->port.tty = tty; tty_port_tty_set(&info->port, tty);
if (info->port.count++ == 0) { if (info->port.count++ == 0) {
atomic_inc(&rp_num_ports_open); atomic_inc(&rp_num_ports_open);
...@@ -1062,15 +1064,15 @@ static int rp_open(struct tty_struct *tty, struct file *filp) ...@@ -1062,15 +1064,15 @@ 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->port.tty->alt_speed = 57600; tty->alt_speed = 57600;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
info->port.tty->alt_speed = 115200; tty->alt_speed = 115200;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
info->port.tty->alt_speed = 230400; tty->alt_speed = 230400;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
info->port.tty->alt_speed = 460800; tty->alt_speed = 460800;
configure_r_port(info, NULL); configure_r_port(tty, info, NULL);
if (tty->termios->c_cflag & CBAUD) { if (tty->termios->c_cflag & CBAUD) {
sSetDTR(cp); sSetDTR(cp);
sSetRTS(cp); sSetRTS(cp);
...@@ -1227,7 +1229,7 @@ static void rp_set_termios(struct tty_struct *tty, ...@@ -1227,7 +1229,7 @@ static void rp_set_termios(struct tty_struct *tty,
/* Or CMSPAR */ /* Or CMSPAR */
tty->termios->c_cflag &= ~CMSPAR; tty->termios->c_cflag &= ~CMSPAR;
configure_r_port(info, old_termios); configure_r_port(tty, info, old_termios);
cp = &info->channel; cp = &info->channel;
...@@ -1352,7 +1354,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo) ...@@ -1352,7 +1354,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo)
return 0; return 0;
} }
static int set_config(struct r_port *info, struct rocket_config __user *new_info) static int set_config(struct tty_struct *tty, struct r_port *info,
struct rocket_config __user *new_info)
{ {
struct rocket_config new_serial; struct rocket_config new_serial;
...@@ -1364,7 +1367,7 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info ...@@ -1364,7 +1367,7 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
if ((new_serial.flags & ~ROCKET_USR_MASK) != (info->flags & ~ROCKET_USR_MASK)) if ((new_serial.flags & ~ROCKET_USR_MASK) != (info->flags & ~ROCKET_USR_MASK))
return -EPERM; return -EPERM;
info->flags = ((info->flags & ~ROCKET_USR_MASK) | (new_serial.flags & ROCKET_USR_MASK)); info->flags = ((info->flags & ~ROCKET_USR_MASK) | (new_serial.flags & ROCKET_USR_MASK));
configure_r_port(info, NULL); configure_r_port(tty, info, NULL);
return 0; return 0;
} }
...@@ -1373,15 +1376,15 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info ...@@ -1373,15 +1376,15 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info
info->port.closing_wait = new_serial.closing_wait; info->port.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->port.tty->alt_speed = 57600; tty->alt_speed = 57600;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI)
info->port.tty->alt_speed = 115200; tty->alt_speed = 115200;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI)
info->port.tty->alt_speed = 230400; tty->alt_speed = 230400;
if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP)
info->port.tty->alt_speed = 460800; tty->alt_speed = 460800;
configure_r_port(info, NULL); configure_r_port(tty, info, NULL);
return 0; return 0;
} }
...@@ -1466,7 +1469,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file, ...@@ -1466,7 +1469,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file,
ret = get_config(info, argp); ret = get_config(info, argp);
break; break;
case RCKP_SET_CONFIG: case RCKP_SET_CONFIG:
ret = set_config(info, argp); ret = set_config(tty, info, argp);
break; break;
case RCKP_GET_PORTS: case RCKP_GET_PORTS:
ret = get_ports(info, argp); ret = get_ports(info, argp);
...@@ -1658,7 +1661,7 @@ static void rp_hangup(struct tty_struct *tty) ...@@ -1658,7 +1661,7 @@ static void rp_hangup(struct tty_struct *tty)
info->port.count = 0; info->port.count = 0;
info->port.flags &= ~ASYNC_NORMAL_ACTIVE; info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
info->port.tty = NULL; tty_port_tty_set(&info->port, NULL);
cp = &info->channel; cp = &info->channel;
sDisRxFIFO(cp); sDisRxFIFO(cp);
...@@ -1778,7 +1781,8 @@ static int rp_write(struct tty_struct *tty, ...@@ -1778,7 +1781,8 @@ 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->port.tty) /* Seemingly obligatory check... */ /* Hung up ? */
if (!test_bit(ASYNC_NORMAL_ACTIVE, &info->port.flags))
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);
......
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