X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fserial%2F68360serial.c;h=68817a7d8c0d46c7ea33e05e3a1eeac7013a7db8;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=64e296ad3b60830822b697a5bb9a903da825a295;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c index 64e296ad3..68817a7d8 100644 --- a/drivers/serial/68360serial.c +++ b/drivers/serial/68360serial.c @@ -20,7 +20,6 @@ * int rs_360_init(void); */ -#include #include #include #include @@ -394,7 +393,7 @@ static void rs_360_start(struct tty_struct *tty) static _INLINE_ void receive_chars(ser_info_t *info) { struct tty_struct *tty = info->tty; - unsigned char ch, *cp; + unsigned char ch, flag, *cp; /*int ignored = 0;*/ int i; ushort status; @@ -438,24 +437,15 @@ static _INLINE_ void receive_chars(ser_info_t *info) cp = (char *)bdp->buf; status = bdp->status; - /* Check to see if there is room in the tty buffer for - * the characters in our BD buffer. If not, we exit - * now, leaving the BD with the characters. We'll pick - * them up again on the next receive interrupt (which could - * be a timeout). - */ - if ((tty->flip.count + i) >= TTY_FLIPBUF_SIZE) - break; - while (i-- > 0) { ch = *cp++; - *tty->flip.char_buf_ptr = ch; icount->rx++; #ifdef SERIAL_DEBUG_INTR printk("DR%02x:%02x...", ch, status); #endif - *tty->flip.flag_buf_ptr = 0; + flag = TTY_NORMAL; + if (status & (BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV)) { /* @@ -490,30 +480,18 @@ static _INLINE_ void receive_chars(ser_info_t *info) if (info->flags & ASYNC_SAK) do_SAK(tty); } else if (status & BD_SC_PR) - *tty->flip.flag_buf_ptr = TTY_PARITY; + flag = TTY_PARITY; else if (status & BD_SC_FR) - *tty->flip.flag_buf_ptr = TTY_FRAME; - if (status & BD_SC_OV) { - /* - * Overrun is special, since it's - * reported immediately, and doesn't - * affect the current character - */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - tty->flip.count++; - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - *tty->flip.flag_buf_ptr = - TTY_OVERRUN; - } - } + flag = TTY_FRAME; } - if (tty->flip.count >= TTY_FLIPBUF_SIZE) - break; - - tty->flip.flag_buf_ptr++; - tty->flip.char_buf_ptr++; - tty->flip.count++; + tty_insert_flip_char(tty, ch, flag); + if (status & BD_SC_OV) + /* + * Overrun is special, since it's + * reported immediately, and doesn't + * affect the current character + */ + tty_insert_flip_char(tty, 0, TTY_OVERRUN); } /* This BD is ready to be used again. Clear status. @@ -530,7 +508,7 @@ static _INLINE_ void receive_chars(ser_info_t *info) info->rx_cur = (QUICC_BD *)bdp; - schedule_work(&tty->flip.work); + tty_schedule_flip(tty); } static _INLINE_ void receive_break(ser_info_t *info) @@ -541,13 +519,8 @@ static _INLINE_ void receive_break(ser_info_t *info) /* Check to see if there is room in the tty buffer for * the break. If not, we exit now, losing the break. FIXME */ - if ((tty->flip.count + 1) >= TTY_FLIPBUF_SIZE) - return; - *(tty->flip.flag_buf_ptr++) = TTY_BREAK; - *(tty->flip.char_buf_ptr++) = 0; - tty->flip.count++; - - schedule_work(&tty->flip.work); + tty_insert_flip_char(tty, 0, TTY_BREAK); + tty_schedule_flip(tty); } static _INLINE_ void transmit_chars(ser_info_t *info) @@ -639,7 +612,7 @@ static _INLINE_ void check_modem_status(struct async_struct *info) * This is the serial driver's interrupt routine for a single port */ /* static void rs_360_interrupt(void *dev_id) */ /* until and if we start servicing irqs here */ -static void rs_360_interrupt(int vec, void *dev_id, struct pt_regs *fp) +static void rs_360_interrupt(int vec, void *dev_id) { u_char events; int idx; @@ -647,7 +620,7 @@ static void rs_360_interrupt(int vec, void *dev_id, struct pt_regs *fp) volatile struct smc_regs *smcp; volatile struct scc_regs *sccp; - info = (ser_info_t *)dev_id; + info = dev_id; idx = PORT_NUM(info->state->smc_scc_num); if (info->state->smc_scc_num & NUM_IS_SCC) { @@ -700,12 +673,8 @@ static void do_softint(void *private_) if (!tty) return; - if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); - wake_up_interruptible(&tty->write_wait); - } + if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) + tty_wakeup(tty); } @@ -1051,7 +1020,7 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch) } -static int rs_360_write(struct tty_struct * tty, int from_user, +static int rs_360_write(struct tty_struct * tty, const unsigned char *buf, int count) { int c, ret = 0; @@ -1083,16 +1052,8 @@ static int rs_360_write(struct tty_struct * tty, int from_user, break; } - if (from_user) { - if (copy_from_user((void *)bdp->buf, buf, c)) { - if (!ret) - ret = -EFAULT; - break; - } - } else { - /* memcpy(__va(bdp->buf), buf, c); */ - memcpy((void *)bdp->buf, buf, c); - } + /* memcpy(__va(bdp->buf), buf, c); */ + memcpy((void *)bdp->buf, buf, c); bdp->length = c; bdp->status |= BD_SC_READY; @@ -1152,10 +1113,7 @@ static void rs_360_flush_buffer(struct tty_struct *tty) /* There is nothing to "flush", whatever we gave the CPM * is on its way out. */ - wake_up_interruptible(&tty->write_wait); - if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - tty->ldisc.write_wakeup) - (tty->ldisc.write_wakeup)(tty); + tty_wakeup(tty); info->flags &= ~TX_WAKEUP; } @@ -1409,14 +1367,13 @@ static void end_break(ser_info_t *info) /* * This routine sends a break character out the serial port. */ -static void send_break(ser_info_t *info, int duration) +static void send_break(ser_info_t *info, unsigned int duration) { - current->state = TASK_INTERRUPTIBLE; #ifdef SERIAL_DEBUG_SEND_BREAK printk("rs_send_break(%d) jiff=%lu...", duration, jiffies); #endif begin_break(info); - schedule_timeout(duration); + msleep_interruptible(duration); end_break(info); #ifdef SERIAL_DEBUG_SEND_BREAK printk("done jiffies=%lu\n", jiffies); @@ -1451,7 +1408,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file, if (signal_pending(current)) return -EINTR; if (!arg) { - send_break(info, HZ/4); /* 1/4 second */ + send_break(info, 250); /* 1/4 second */ if (signal_pending(current)) return -EINTR; } @@ -1463,7 +1420,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file, tty_wait_until_sent(tty, 0); if (signal_pending(current)) return -EINTR; - send_break(info, arg ? arg*(HZ/10) : HZ/4); + send_break(info, arg ? arg*100 : 250); if (signal_pending(current)) return -EINTR; return 0; @@ -1566,7 +1523,7 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file, /* FIX UP modem control here someday...... */ -static void rs_360_set_termios(struct tty_struct *tty, struct termios *old_termios) +static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios) { ser_info_t *info = (ser_info_t *)tty->driver_data; @@ -1716,15 +1673,13 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp) shutdown(info); if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); - if (tty->ldisc.flush_buffer) - tty->ldisc.flush_buffer(tty); + tty_ldisc_flush(tty); tty->closing = 0; info->event = 0; info->tty = 0; if (info->blocked_open) { if (info->close_delay) { - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(info->close_delay); + msleep_interruptible(jiffies_to_msecs(info->close_delay)); } wake_up_interruptible(&info->open_wait); } @@ -1777,9 +1732,8 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout) #ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT printk("lsr = %d (jiff=%lu)...", lsr, jiffies); #endif - current->state = TASK_INTERRUPTIBLE; /* current->counter = 0; make us low-priority */ - schedule_timeout(char_time); + msleep_interruptible(jiffies_to_msecs(char_time)); if (signal_pending(current)) break; if (timeout && ((orig_jiffies + timeout) < jiffies)) @@ -2470,7 +2424,7 @@ long console_360_init(long kmem_start, long kmem_end) */ static int baud_idx; -static struct tty_operations rs_360_ops = { +static const struct tty_operations rs_360_ops = { .owner = THIS_MODULE, .open = rs_360_open, .close = rs_360_close, @@ -2493,8 +2447,7 @@ static struct tty_operations rs_360_ops = { .tiocmset = rs_360_tiocmset, }; -/* int __init rs_360_init(void) */ -int rs_360_init(void) +static int __init rs_360_init(void) { struct serial_state * state; ser_info_t *info; @@ -2592,7 +2545,7 @@ int rs_360_init(void) state->icount.rx = state->icount.tx = 0; state->icount.frame = state->icount.parity = 0; state->icount.overrun = state->icount.brk = 0; - printk(KERN_INFO "ttyS%02d at irq 0x%02x is an %s\n", + printk(KERN_INFO "ttyS%d at irq 0x%02x is an %s\n", i, (unsigned int)(state->irq), (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC"); @@ -2846,10 +2799,7 @@ int rs_360_init(void) return 0; } - - - - +module_init(rs_360_init); /* This must always be called before the rs_360_init() function, otherwise * it blows away the port control information.