X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fchar%2Frocket.c;h=0e29a23ec4c50be1f2d74b492c91785a8feae2b3;hb=bb521c5de070b86a1e049e2dbf62328f717ff1e8;hp=00cfb6c7fd4698b019188cfefb46ec457667a0bd;hpb=978e595f88a1fba5869aa42a4af4fba36f33ecac;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 00cfb6c..0e29a23 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -72,6 +72,8 @@ #include #include #include +#include +#include #include #include #include @@ -81,7 +83,7 @@ #include #include #include -#include +#include #include #include #include @@ -134,6 +136,7 @@ static int rcktpt_type[NUM_BOARDS]; static int is_PCI[NUM_BOARDS]; static rocketModel_t rocketModel[NUM_BOARDS]; static int max_board; +static const struct tty_port_operations rocket_port_ops; /* * The following arrays define the interrupt bits corresponding to each AIOP. @@ -434,15 +437,15 @@ static void rp_do_transmit(struct r_port *info) #endif if (!info) return; - if (!info->tty) { - printk(KERN_WARNING "rp: WARNING %s called with " - "info->tty==NULL\n", __func__); + tty = tty_port_tty_get(&info->port); + + 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]); return; } spin_lock_irqsave(&info->slock, flags); - tty = info->tty; info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); /* Loop sending data to FIFO until done or FIFO full */ @@ -476,6 +479,7 @@ static void rp_do_transmit(struct r_port *info) } spin_unlock_irqrestore(&info->slock, flags); + tty_kref_put(tty); #ifdef ROCKET_DEBUG_INTR printk(KERN_DEBUG "(%d,%d,%d,%d)...\n", info->xmit_cnt, info->xmit_head, @@ -497,18 +501,18 @@ static void rp_handle_port(struct r_port *info) if (!info) return; - if ((info->flags & ROCKET_INITIALIZED) == 0) { + if ((info->port.flags & ASYNC_INITIALIZED) == 0) { printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " "info->flags & NOT_INIT\n"); return; } - if (!info->tty) { + tty = tty_port_tty_get(&info->port); + if (!tty) { printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " - "info->tty==NULL\n"); + "tty==NULL\n"); return; } cp = &info->channel; - tty = info->tty; IntMask = sGetChanIntID(cp) & info->intmask; #ifdef ROCKET_DEBUG_INTR @@ -530,7 +534,7 @@ static void rp_handle_port(struct r_port *info) tty_hangup(tty); } 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 if (IntMask & DELTA_CTS) { /* CTS change */ @@ -540,6 +544,7 @@ static void rp_handle_port(struct r_port *info) printk(KERN_INFO "DSR change...\n"); } #endif + tty_kref_put(tty); } /* @@ -648,9 +653,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) info->board = board; info->aiop = aiop; info->chan = chan; - info->closing_wait = 3000; - info->close_delay = 50; - init_waitqueue_head(&info->open_wait); + tty_port_init(&info->port); + info->port.ops = &rocket_port_ops; init_completion(&info->close_wait); info->flags &= ~ROCKET_MODE_MASK; switch (pc104[board][line]) { @@ -709,7 +713,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 * 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) { unsigned cflag; @@ -717,7 +721,7 @@ static void configure_r_port(struct r_port *info, unsigned rocketMode; int bits, baud, divisor; CHANNEL_t *cp; - struct ktermios *t = info->tty->termios; + struct ktermios *t = tty->termios; cp = &info->channel; cflag = t->c_cflag; @@ -750,7 +754,7 @@ static void configure_r_port(struct r_port *info, } /* baud rate */ - baud = tty_get_baud_rate(info->tty); + baud = tty_get_baud_rate(tty); if (!baud) baud = 9600; divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1; @@ -768,7 +772,7 @@ static void configure_r_port(struct r_port *info, sSetBaud(cp, divisor); /* FIXME: Should really back compute a baud rate from the divisor */ - tty_encode_baud_rate(info->tty, baud, baud); + tty_encode_baud_rate(tty, baud, baud); if (cflag & CRTSCTS) { info->intmask |= DELTA_CTS; @@ -793,15 +797,15 @@ static void configure_r_port(struct r_port *info, * Handle software flow control in the board */ #ifdef ROCKET_SOFT_FLOW - if (I_IXON(info->tty)) { + if (I_IXON(tty)) { sEnTxSoftFlowCtl(cp); - if (I_IXANY(info->tty)) { + if (I_IXANY(tty)) { sEnIXANY(cp); } else { sDisIXANY(cp); } - sSetTxXONChar(cp, START_CHAR(info->tty)); - sSetTxXOFFChar(cp, STOP_CHAR(info->tty)); + sSetTxXONChar(cp, START_CHAR(tty)); + sSetTxXOFFChar(cp, STOP_CHAR(tty)); } else { sDisTxSoftFlowCtl(cp); sDisIXANY(cp); @@ -813,24 +817,24 @@ static void configure_r_port(struct r_port *info, * Set up ignore/read mask words */ info->read_status_mask = STMRCVROVRH | 0xFF; - if (I_INPCK(info->tty)) + if (I_INPCK(tty)) info->read_status_mask |= STMFRAMEH | STMPARITYH; - if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) + if (I_BRKINT(tty) || I_PARMRK(tty)) info->read_status_mask |= STMBREAKH; /* * Characters to ignore */ info->ignore_status_mask = 0; - if (I_IGNPAR(info->tty)) + if (I_IGNPAR(tty)) info->ignore_status_mask |= STMFRAMEH | STMPARITYH; - if (I_IGNBRK(info->tty)) { + if (I_IGNBRK(tty)) { info->ignore_status_mask |= STMBREAKH; /* * If we're ignoring parity and break indicators, * ignore overruns too. (For real raw support). */ - if (I_IGNPAR(info->tty)) + if (I_IGNPAR(tty)) info->ignore_status_mask |= STMRCVROVRH; } @@ -863,106 +867,22 @@ static void configure_r_port(struct r_port *info, } } -/* info->count is considered critical, protected by spinlocks. */ -static int block_til_ready(struct tty_struct *tty, struct file *filp, - struct r_port *info) +static int carrier_raised(struct tty_port *port) { - DECLARE_WAITQUEUE(wait, current); - 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)) - return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); - if (info->flags & ROCKET_CLOSING) { - if (wait_for_completion_interruptible(&info->close_wait)) - return -ERESTARTSYS; - return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); - } - - /* - * 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))) { - info->flags |= ROCKET_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. While we are in - * this loop, info->count is dropped by one, so that rp_close() knows when to free things. - * We restore it upon exit, either normal or abnormal. - */ - retval = 0; - add_wait_queue(&info->open_wait, &wait); -#ifdef ROCKET_DEBUG_OPEN - printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->count); -#endif - spin_lock_irqsave(&info->slock, flags); - -#ifdef ROCKET_DISABLE_SIMUSAGE - info->flags |= ROCKET_NORMAL_ACTIVE; -#else - if (!tty_hung_up_p(filp)) { - extra_count = 1; - info->count--; - } -#endif - info->blocked_open++; - - spin_unlock_irqrestore(&info->slock, flags); + struct r_port *info = container_of(port, struct r_port, port); + return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0; +} - while (1) { - if (tty->termios->c_cflag & CBAUD) { - sSetDTR(&info->channel); - sSetRTS(&info->channel); - } - set_current_state(TASK_INTERRUPTIBLE); - if (tty_hung_up_p(filp) || !(info->flags & ROCKET_INITIALIZED)) { - if (info->flags & ROCKET_HUP_NOTIFY) - retval = -EAGAIN; - else - retval = -ERESTARTSYS; - break; - } - if (!(info->flags & ROCKET_CLOSING) && (do_clocal || (sGetChanStatusLo(&info->channel) & CD_ACT))) - break; - if (signal_pending(current)) { - retval = -ERESTARTSYS; - break; - } -#ifdef ROCKET_DEBUG_OPEN - printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n", - info->line, info->count, info->flags); -#endif - schedule(); /* Don't hold spinlock here, will hang PC */ +static void dtr_rts(struct tty_port *port, int on) +{ + struct r_port *info = container_of(port, struct r_port, port); + if (on) { + sSetDTR(&info->channel); + sSetRTS(&info->channel); + } else { + sClrDTR(&info->channel); + sClrRTS(&info->channel); } - __set_current_state(TASK_RUNNING); - remove_wait_queue(&info->open_wait, &wait); - - spin_lock_irqsave(&info->slock, flags); - - if (extra_count) - info->count++; - info->blocked_open--; - - spin_unlock_irqrestore(&info->slock, flags); - -#ifdef ROCKET_DEBUG_OPEN - printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n", - info->line, info->count); -#endif - if (retval) - return retval; - info->flags |= ROCKET_NORMAL_ACTIVE; - return 0; } /* @@ -972,24 +892,26 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, static int rp_open(struct tty_struct *tty, struct file *filp) { struct r_port *info; + struct tty_port *port; int line = 0, retval; CHANNEL_t *cp; unsigned long page; line = tty->index; - if ((line < 0) || (line >= MAX_RP_PORTS) || ((info = rp_table[line]) == NULL)) + if (line < 0 || line >= MAX_RP_PORTS || ((info = rp_table[line]) == NULL)) return -ENXIO; - + port = &info->port; + page = __get_free_page(GFP_KERNEL); if (!page) return -ENOMEM; - if (info->flags & ROCKET_CLOSING) { + if (port->flags & ASYNC_CLOSING) { retval = wait_for_completion_interruptible(&info->close_wait); free_page(page); if (retval) return retval; - return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); + return ((port->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); } /* @@ -1001,9 +923,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp) info->xmit_buf = (unsigned char *) page; tty->driver_data = info; - info->tty = tty; + tty_port_tty_set(port, tty); - if (info->count++ == 0) { + if (port->count++ == 0) { atomic_inc(&rp_num_ports_open); #ifdef ROCKET_DEBUG_OPEN @@ -1012,13 +934,13 @@ static int rp_open(struct tty_struct *tty, struct file *filp) #endif } #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 /* * Info->count is now 1; so it's safe to sleep now. */ - if ((info->flags & ROCKET_INITIALIZED) == 0) { + if (!test_bit(ASYNCB_INITIALIZED, &port->flags)) { cp = &info->channel; sSetRxTrigger(cp, TRIG_1); if (sGetChanStatus(cp) & CD_ACT) @@ -1042,21 +964,21 @@ static int rp_open(struct tty_struct *tty, struct file *filp) sEnRxFIFO(cp); sEnTransmit(cp); - info->flags |= ROCKET_INITIALIZED; + set_bit(ASYNCB_INITIALIZED, &info->port.flags); /* * Set up the tty->alt_speed kludge */ if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) - info->tty->alt_speed = 57600; + tty->alt_speed = 57600; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) - info->tty->alt_speed = 115200; + tty->alt_speed = 115200; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) - info->tty->alt_speed = 230400; + tty->alt_speed = 230400; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) - info->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) { sSetDTR(cp); sSetRTS(cp); @@ -1065,7 +987,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) /* Starts (or resets) the maint polling loop */ mod_timer(&rocket_timer, jiffies + POLL_PERIOD); - retval = block_til_ready(tty, filp, info); + retval = tty_port_block_til_ready(port, tty, filp); if (retval) { #ifdef ROCKET_DEBUG_OPEN printk(KERN_INFO "rp_open returning after block_til_ready with %d\n", retval); @@ -1076,12 +998,12 @@ 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) { - struct r_port *info = (struct r_port *) tty->driver_data; - unsigned long flags; + struct r_port *info = tty->driver_data; + struct tty_port *port = &info->port; int timeout; CHANNEL_t *cp; @@ -1089,56 +1011,13 @@ static void rp_close(struct tty_struct *tty, struct file *filp) return; #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 - if (tty_hung_up_p(filp)) - return; - spin_lock_irqsave(&info->slock, flags); - - if ((tty->count == 1) && (info->count != 1)) { - /* - * Uh, oh. tty->count is 1, which means that the tty - * structure will be freed. Info->count should always - * be one in these conditions. If it's greater than - * one, we've got real problems, since it means the - * serial port won't be shutdown. - */ - printk(KERN_WARNING "rp_close: bad serial port count; " - "tty->count is 1, info->count is %d\n", info->count); - info->count = 1; - } - if (--info->count < 0) { - printk(KERN_WARNING "rp_close: bad serial port count for " - "ttyR%d: %d\n", info->line, info->count); - info->count = 0; - } - if (info->count) { - spin_unlock_irqrestore(&info->slock, flags); + if (tty_port_close_start(port, tty, filp) == 0) return; - } - info->flags |= ROCKET_CLOSING; - spin_unlock_irqrestore(&info->slock, flags); cp = &info->channel; - - /* - * Notify the line discpline to only process XON/XOFF characters - */ - tty->closing = 1; - - /* - * If transmission was throttled by the application request, - * just flush the xmit buffer. - */ - if (tty->flow_stopped) - rp_flush_buffer(tty); - - /* - * Wait for the transmit buffer to clear - */ - if (info->closing_wait != ROCKET_CLOSING_WAIT_NONE) - tty_wait_until_sent(tty, info->closing_wait); /* * Before we drop DTR, make sure the UART transmitter * has completely drained; this is especially @@ -1167,19 +1046,24 @@ static void rp_close(struct tty_struct *tty, struct file *filp) clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); - if (info->blocked_open) { - if (info->close_delay) { - msleep_interruptible(jiffies_to_msecs(info->close_delay)); + /* We can't yet use tty_port_close_end as the buffer handling in this + driver is a bit different to the usual */ + + if (port->blocked_open) { + if (port->close_delay) { + msleep_interruptible(jiffies_to_msecs(port->close_delay)); } - wake_up_interruptible(&info->open_wait); + wake_up_interruptible(&port->open_wait); } else { if (info->xmit_buf) { free_page((unsigned long) info->xmit_buf); info->xmit_buf = NULL; } } - info->flags &= ~(ROCKET_INITIALIZED | ROCKET_CLOSING | ROCKET_NORMAL_ACTIVE); + info->port.flags &= ~(ASYNC_INITIALIZED | ASYNC_CLOSING | ASYNC_NORMAL_ACTIVE); tty->closing = 0; + tty_port_tty_set(port, NULL); + wake_up_interruptible(&port->close_wait); complete_all(&info->close_wait); atomic_dec(&rp_num_ports_open); @@ -1194,7 +1078,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp) static void rp_set_termios(struct tty_struct *tty, struct ktermios *old_termios) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; unsigned cflag; @@ -1212,7 +1096,7 @@ static void rp_set_termios(struct tty_struct *tty, /* Or CMSPAR */ tty->termios->c_cflag &= ~CMSPAR; - configure_r_port(info, old_termios); + configure_r_port(tty, info, old_termios); cp = &info->channel; @@ -1235,13 +1119,13 @@ static void rp_set_termios(struct tty_struct *tty, } } -static void rp_break(struct tty_struct *tty, int break_state) +static int rp_break(struct tty_struct *tty, int break_state) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; unsigned long flags; if (rocket_paranoia_check(info, "rp_break")) - return; + return -EINVAL; spin_lock_irqsave(&info->slock, flags); if (break_state == -1) @@ -1249,6 +1133,7 @@ static void rp_break(struct tty_struct *tty, int break_state) else sClrBreak(&info->channel); spin_unlock_irqrestore(&info->slock, flags); + return 0; } /* @@ -1282,7 +1167,7 @@ static int sGetChanRI(CHANNEL_T * ChP) */ static int rp_tiocmget(struct tty_struct *tty, struct file *file) { - struct r_port *info = (struct r_port *)tty->driver_data; + struct r_port *info = tty->driver_data; unsigned int control, result, ChanStatus; ChanStatus = sGetChanStatusLo(&info->channel); @@ -1303,7 +1188,7 @@ static int rp_tiocmget(struct tty_struct *tty, struct file *file) static int rp_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) { - struct r_port *info = (struct r_port *)tty->driver_data; + struct r_port *info = tty->driver_data; if (set & TIOCM_RTS) info->channel.TxControl[3] |= SET_RTS; @@ -1327,8 +1212,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo) memset(&tmp, 0, sizeof (tmp)); tmp.line = info->line; tmp.flags = info->flags; - tmp.close_delay = info->close_delay; - tmp.closing_wait = info->closing_wait; + tmp.close_delay = info->port.close_delay; + tmp.closing_wait = info->port.closing_wait; tmp.port = rcktpt_io_addr[(info->line >> 5) & 3]; if (copy_to_user(retinfo, &tmp, sizeof (*retinfo))) @@ -1336,7 +1221,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo) 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; @@ -1348,24 +1234,24 @@ 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)) return -EPERM; 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; } info->flags = ((info->flags & ~ROCKET_FLAGS) | (new_serial.flags & ROCKET_FLAGS)); - info->close_delay = new_serial.close_delay; - info->closing_wait = new_serial.closing_wait; + info->port.close_delay = new_serial.close_delay; + info->port.closing_wait = new_serial.closing_wait; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) - info->tty->alt_speed = 57600; + tty->alt_speed = 57600; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) - info->tty->alt_speed = 115200; + tty->alt_speed = 115200; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) - info->tty->alt_speed = 230400; + tty->alt_speed = 230400; if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) - info->tty->alt_speed = 460800; + tty->alt_speed = 460800; - configure_r_port(info, NULL); + configure_r_port(tty, info, NULL); return 0; } @@ -1432,7 +1318,7 @@ static int get_version(struct r_port *info, struct rocket_version __user *retver static int rp_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; void __user *argp = (void __user *)arg; int ret = 0; @@ -1450,7 +1336,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file, ret = get_config(info, argp); break; case RCKP_SET_CONFIG: - ret = set_config(info, argp); + ret = set_config(tty, info, argp); break; case RCKP_GET_PORTS: ret = get_ports(info, argp); @@ -1470,7 +1356,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file, static void rp_send_xchar(struct tty_struct *tty, char ch) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; if (rocket_paranoia_check(info, "rp_send_xchar")) @@ -1485,7 +1371,7 @@ static void rp_send_xchar(struct tty_struct *tty, char ch) static void rp_throttle(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; #ifdef ROCKET_DEBUG_THROTTLE @@ -1505,7 +1391,7 @@ static void rp_throttle(struct tty_struct *tty) static void rp_unthrottle(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; #ifdef ROCKET_DEBUG_THROTTLE printk(KERN_INFO "unthrottle %s: %d....\n", tty->name, @@ -1532,7 +1418,7 @@ static void rp_unthrottle(struct tty_struct *tty) */ static void rp_stop(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; #ifdef ROCKET_DEBUG_FLOW printk(KERN_INFO "stop %s: %d %d....\n", tty->name, @@ -1548,7 +1434,7 @@ static void rp_stop(struct tty_struct *tty) static void rp_start(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; #ifdef ROCKET_DEBUG_FLOW printk(KERN_INFO "start %s: %d %d....\n", tty->name, @@ -1568,7 +1454,7 @@ static void rp_start(struct tty_struct *tty) */ static void rp_wait_until_sent(struct tty_struct *tty, int timeout) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; unsigned long orig_jiffies; int check_time, exit_time; @@ -1625,7 +1511,7 @@ static void rp_wait_until_sent(struct tty_struct *tty, int timeout) static void rp_hangup(struct tty_struct *tty) { CHANNEL_t *cp; - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; if (rocket_paranoia_check(info, "rp_hangup")) return; @@ -1634,15 +1520,13 @@ static void rp_hangup(struct tty_struct *tty) printk(KERN_INFO "rp_hangup of ttyR%d...\n", info->line); #endif rp_flush_buffer(tty); - if (info->flags & ROCKET_CLOSING) + if (info->port.flags & ASYNC_CLOSING) return; - if (info->count) + if (info->port.count) atomic_dec(&rp_num_ports_open); clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); - info->count = 0; - info->flags &= ~ROCKET_NORMAL_ACTIVE; - info->tty = NULL; + tty_port_hangup(&info->port); cp = &info->channel; sDisRxFIFO(cp); @@ -1651,9 +1535,9 @@ static void rp_hangup(struct tty_struct *tty) sDisCTSFlowCtl(cp); sDisTxSoftFlowCtl(cp); sClrTxXOFF(cp); - info->flags &= ~ROCKET_INITIALIZED; + info->port.flags &= ~ASYNC_INITIALIZED; - wake_up_interruptible(&info->open_wait); + wake_up_interruptible(&info->port.open_wait); } /* @@ -1663,14 +1547,14 @@ static void rp_hangup(struct tty_struct *tty) * writing routines will write directly to transmit FIFO. * Write buffer and counters protected by spinlocks */ -static void rp_put_char(struct tty_struct *tty, unsigned char ch) +static int rp_put_char(struct tty_struct *tty, unsigned char ch) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; unsigned long flags; if (rocket_paranoia_check(info, "rp_put_char")) - return; + return 0; /* * Grab the port write mutex, locking out other processes that try to @@ -1699,6 +1583,7 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch) } spin_unlock_irqrestore(&info->slock, flags); mutex_unlock(&info->write_mtx); + return 1; } /* @@ -1711,7 +1596,7 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch) static int rp_write(struct tty_struct *tty, const unsigned char *buf, int count) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; const unsigned char *b; int c, retval = 0; @@ -1761,7 +1646,8 @@ static int rp_write(struct tty_struct *tty, /* Write remaining data into the port's xmit_buf */ while (1) { - if (!info->tty) /* Seemingly obligatory check... */ + /* Hung up ? */ + if (!test_bit(ASYNCB_NORMAL_ACTIVE, &info->port.flags)) goto end; c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1); c = min(c, XMIT_BUF_SIZE - info->xmit_head); @@ -1803,7 +1689,7 @@ end: */ static int rp_write_room(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; int ret; if (rocket_paranoia_check(info, "rp_write_room")) @@ -1824,7 +1710,7 @@ static int rp_write_room(struct tty_struct *tty) */ static int rp_chars_in_buffer(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; if (rocket_paranoia_check(info, "rp_chars_in_buffer")) @@ -1845,7 +1731,7 @@ static int rp_chars_in_buffer(struct tty_struct *tty) */ static void rp_flush_buffer(struct tty_struct *tty) { - struct r_port *info = (struct r_port *) tty->driver_data; + struct r_port *info = tty->driver_data; CHANNEL_t *cp; unsigned long flags; @@ -2368,6 +2254,11 @@ static const struct tty_operations rocket_ops = { .tiocmset = rp_tiocmset, }; +static const struct tty_port_operations rocket_port_ops = { + .carrier_raised = carrier_raised, + .dtr_rts = dtr_rts, +}; + /* * The module "startup" routine; it's run when the module is loaded. */