X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=drivers%2Fchar%2Fstallion.c;h=a9c5a7230f8958b5d8ee1338fa88c40cddf79a58;hb=dea74869f3c62b0b7addd67017b22b394e942aac;hp=acef2abf3f0de39aa4f40c2993f644de5887ead9;hpb=fe971071a89c5c5184fc9f3482c7a8e997cf0520;p=cascardo%2Flinux.git diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index acef2abf3f0d..a9c5a7230f89 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -148,7 +148,6 @@ static struct tty_driver *stl_serial; * is already swapping a shared buffer won't make things any worse. */ static char *stl_tmpwritebuf; -static DECLARE_MUTEX(stl_tmpwritesem); /* * Define a local default termios struct. All ports will be created @@ -505,7 +504,6 @@ static int stl_echmcaintr(stlbrd_t *brdp); static int stl_echpciintr(stlbrd_t *brdp); static int stl_echpci64intr(stlbrd_t *brdp); static void stl_offintr(void *private); -static void *stl_memalloc(int len); static stlbrd_t *stl_allocbrd(void); static stlport_t *stl_getport(int brdnr, int panelnr, int portnr); @@ -738,7 +736,7 @@ static int __init stallion_module_init(void) stl_init(); restore_flags(flags); - return(0); + return 0; } /*****************************************************************************/ @@ -889,7 +887,7 @@ static unsigned long stl_atol(char *str) } val = (val * base) + c; } - return(val); + return val; } /*****************************************************************************/ @@ -908,7 +906,7 @@ static int stl_parsebrd(stlconf_t *confp, char **argp) #endif if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) - return(0); + return 0; for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) *sp = TOLOWER(*sp); @@ -935,18 +933,7 @@ static int stl_parsebrd(stlconf_t *confp, char **argp) } if ((argp[i] != (char *) NULL) && (*argp[i] != 0)) confp->irq = stl_atol(argp[i]); - return(1); -} - -/*****************************************************************************/ - -/* - * Local driver kernel memory allocation routine. - */ - -static void *stl_memalloc(int len) -{ - return((void *) kmalloc(len, GFP_KERNEL)); + return 1; } /*****************************************************************************/ @@ -959,16 +946,15 @@ static stlbrd_t *stl_allocbrd(void) { stlbrd_t *brdp; - brdp = (stlbrd_t *) stl_memalloc(sizeof(stlbrd_t)); - if (brdp == (stlbrd_t *) NULL) { + brdp = kzalloc(sizeof(stlbrd_t), GFP_KERNEL); + if (!brdp) { printk("STALLION: failed to allocate memory (size=%d)\n", sizeof(stlbrd_t)); - return((stlbrd_t *) NULL); + return NULL; } - memset(brdp, 0, sizeof(stlbrd_t)); brdp->magic = STL_BOARDMAGIC; - return(brdp); + return brdp; } /*****************************************************************************/ @@ -988,10 +974,10 @@ static int stl_open(struct tty_struct *tty, struct file *filp) minordev = tty->index; brdnr = MINOR2BRD(minordev); if (brdnr >= stl_nrbrds) - return(-ENODEV); + return -ENODEV; brdp = stl_brds[brdnr]; if (brdp == (stlbrd_t *) NULL) - return(-ENODEV); + return -ENODEV; minordev = MINOR2PORT(minordev); for (portnr = -1, panelnr = 0; (panelnr < STL_MAXPANELS); panelnr++) { if (brdp->panels[panelnr] == (stlpanel_t *) NULL) @@ -1003,11 +989,11 @@ static int stl_open(struct tty_struct *tty, struct file *filp) minordev -= brdp->panels[panelnr]->nrports; } if (portnr < 0) - return(-ENODEV); + return -ENODEV; portp = brdp->panels[panelnr]->ports[portnr]; if (portp == (stlport_t *) NULL) - return(-ENODEV); + return -ENODEV; /* * On the first open of the device setup the port hardware, and @@ -1018,10 +1004,10 @@ static int stl_open(struct tty_struct *tty, struct file *filp) portp->refcount++; if ((portp->flags & ASYNC_INITIALIZED) == 0) { - if (portp->tx.buf == (char *) NULL) { - portp->tx.buf = (char *) stl_memalloc(STL_TXBUFSIZE); - if (portp->tx.buf == (char *) NULL) - return(-ENOMEM); + if (!portp->tx.buf) { + portp->tx.buf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); + if (!portp->tx.buf) + return -ENOMEM; portp->tx.head = portp->tx.buf; portp->tx.tail = portp->tx.buf; } @@ -1043,8 +1029,8 @@ static int stl_open(struct tty_struct *tty, struct file *filp) if (portp->flags & ASYNC_CLOSING) { interruptible_sleep_on(&portp->close_wait); if (portp->flags & ASYNC_HUP_NOTIFY) - return(-EAGAIN); - return(-ERESTARTSYS); + return -EAGAIN; + return -ERESTARTSYS; } /* @@ -1054,11 +1040,11 @@ static int stl_open(struct tty_struct *tty, struct file *filp) */ if (!(filp->f_flags & O_NONBLOCK)) { if ((rc = stl_waitcarrier(portp, filp)) != 0) - return(rc); + return rc; } portp->flags |= ASYNC_NORMAL_ACTIVE; - return(0); + return 0; } /*****************************************************************************/ @@ -1115,7 +1101,7 @@ static int stl_waitcarrier(stlport_t *portp, struct file *filp) portp->openwaitcnt--; restore_flags(flags); - return(rc); + return rc; } /*****************************************************************************/ @@ -1211,12 +1197,12 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count if ((tty == (struct tty_struct *) NULL) || (stl_tmpwritebuf == (char *) NULL)) - return(0); + return 0; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(0); + return 0; if (portp->tx.buf == (char *) NULL) - return(0); + return 0; /* * If copying direct from user space we must cater for page faults, @@ -1255,7 +1241,7 @@ static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count clear_bit(ASYI_TXLOW, &portp->istate); stl_startrxtx(portp, -1, 1); - return(count); + return count; } /*****************************************************************************/ @@ -1336,16 +1322,16 @@ static int stl_writeroom(struct tty_struct *tty) #endif if (tty == (struct tty_struct *) NULL) - return(0); + return 0; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(0); + return 0; if (portp->tx.buf == (char *) NULL) - return(0); + return 0; head = portp->tx.head; tail = portp->tx.tail; - return((head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) : (tail - head - 1)); + return ((head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) : (tail - head - 1)); } /*****************************************************************************/ @@ -1370,19 +1356,19 @@ static int stl_charsinbuffer(struct tty_struct *tty) #endif if (tty == (struct tty_struct *) NULL) - return(0); + return 0; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(0); + return 0; if (portp->tx.buf == (char *) NULL) - return(0); + return 0; head = portp->tx.head; tail = portp->tx.tail; size = (head >= tail) ? (head - tail) : (STL_TXBUFSIZE - (tail - head)); if ((size == 0) && test_bit(ASYI_TXBUSY, &portp->istate)) size = 1; - return(size); + return size; } /*****************************************************************************/ @@ -1447,7 +1433,7 @@ static int stl_setserial(stlport_t *portp, struct serial_struct __user *sp) (sio.close_delay != portp->close_delay) || ((sio.flags & ~ASYNC_USR_MASK) != (portp->flags & ~ASYNC_USR_MASK))) - return(-EPERM); + return -EPERM; } portp->flags = (portp->flags & ~ASYNC_USR_MASK) | @@ -1457,7 +1443,7 @@ static int stl_setserial(stlport_t *portp, struct serial_struct __user *sp) portp->closing_wait = sio.closing_wait; portp->custom_divisor = sio.custom_divisor; stl_setport(portp, portp->tty->termios); - return(0); + return 0; } /*****************************************************************************/ @@ -1467,12 +1453,12 @@ static int stl_tiocmget(struct tty_struct *tty, struct file *file) stlport_t *portp; if (tty == (struct tty_struct *) NULL) - return(-ENODEV); + return -ENODEV; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(-ENODEV); + return -ENODEV; if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; return stl_getsignals(portp); } @@ -1484,12 +1470,12 @@ static int stl_tiocmset(struct tty_struct *tty, struct file *file, int rts = -1, dtr = -1; if (tty == (struct tty_struct *) NULL) - return(-ENODEV); + return -ENODEV; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(-ENODEV); + return -ENODEV; if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; if (set & TIOCM_RTS) rts = 1; @@ -1517,15 +1503,15 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd #endif if (tty == (struct tty_struct *) NULL) - return(-ENODEV); + return -ENODEV; portp = tty->driver_data; if (portp == (stlport_t *) NULL) - return(-ENODEV); + return -ENODEV; if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { if (tty->flags & (1 << TTY_IO_ERROR)) - return(-EIO); + return -EIO; } rc = 0; @@ -1566,7 +1552,7 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd break; } - return(rc); + return rc; } /*****************************************************************************/ @@ -1872,7 +1858,7 @@ static int stl_portinfo(stlport_t *portp, int portnr, char *pos) pos[(MAXLINE - 2)] = '+'; pos[(MAXLINE - 1)] = '\n'; - return(MAXLINE); + return MAXLINE; } /*****************************************************************************/ @@ -1957,7 +1943,7 @@ static int stl_readproc(char *page, char **start, off_t off, int count, int *eof stl_readdone: *start = page; - return(pos - page); + return (pos - page); } /*****************************************************************************/ @@ -2179,13 +2165,12 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp) * each ports data structures. */ for (i = 0; (i < panelp->nrports); i++) { - portp = (stlport_t *) stl_memalloc(sizeof(stlport_t)); - if (portp == (stlport_t *) NULL) { + portp = kzalloc(sizeof(stlport_t), GFP_KERNEL); + if (!portp) { printk("STALLION: failed to allocate memory " "(size=%d)\n", sizeof(stlport_t)); break; } - memset(portp, 0, sizeof(stlport_t)); portp->magic = STL_PORTMAGIC; portp->portnr = i; @@ -2316,13 +2301,12 @@ static inline int stl_initeio(stlbrd_t *brdp) * can complete the setup. */ - panelp = (stlpanel_t *) stl_memalloc(sizeof(stlpanel_t)); - if (panelp == (stlpanel_t *) NULL) { + panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); + if (!panelp) { printk(KERN_WARNING "STALLION: failed to allocate memory " "(size=%d)\n", sizeof(stlpanel_t)); - return(-ENOMEM); + return -ENOMEM; } - memset(panelp, 0, sizeof(stlpanel_t)); panelp->magic = STL_PANELMAGIC; panelp->brdnr = brdp->brdnr; @@ -2349,7 +2333,7 @@ static inline int stl_initeio(stlbrd_t *brdp) } else { rc = 0; } - return(rc); + return rc; } /*****************************************************************************/ @@ -2491,13 +2475,12 @@ static inline int stl_initech(stlbrd_t *brdp) status = inb(ioaddr + ECH_PNLSTATUS); if ((status & ECH_PNLIDMASK) != nxtid) break; - panelp = (stlpanel_t *) stl_memalloc(sizeof(stlpanel_t)); - if (panelp == (stlpanel_t *) NULL) { + panelp = kzalloc(sizeof(stlpanel_t), GFP_KERNEL); + if (!panelp) { printk("STALLION: failed to allocate memory " "(size=%d)\n", sizeof(stlpanel_t)); break; } - memset(panelp, 0, sizeof(stlpanel_t)); panelp->magic = STL_PANELMAGIC; panelp->brdnr = brdp->brdnr; panelp->panelnr = panelnr; @@ -2901,7 +2884,8 @@ static int stl_getportstats(stlport_t *portp, comstats_t __user *cp) if (portp->tty != (struct tty_struct *) NULL) { if (portp->tty->driver_data == portp) { portp->stats.ttystate = portp->tty->flags; - portp->stats.rxbuffered = portp->tty->flip.count; + /* No longer available as a statistic */ + portp->stats.rxbuffered = 1; /*portp->tty->flip.count; */ if (portp->tty->termios != (struct termios *) NULL) { portp->stats.cflags = portp->tty->termios->c_cflag; portp->stats.iflags = portp->tty->termios->c_iflag; @@ -3074,8 +3058,8 @@ static int __init stl_init(void) /* * Allocate a temporary write buffer. */ - stl_tmpwritebuf = (char *) stl_memalloc(STL_TXBUFSIZE); - if (stl_tmpwritebuf == (char *) NULL) + stl_tmpwritebuf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); + if (!stl_tmpwritebuf) printk("STALLION: failed to allocate memory (size=%d)\n", STL_TXBUFSIZE); @@ -3115,7 +3099,7 @@ static int __init stl_init(void) return -1; } - return(0); + return 0; } /*****************************************************************************/ @@ -3131,7 +3115,7 @@ static int __init stl_init(void) static int stl_cd1400getreg(stlport_t *portp, int regnr) { outb((regnr + portp->uartaddr), portp->ioaddr); - return(inb(portp->ioaddr + EREG_DATA)); + return inb(portp->ioaddr + EREG_DATA); } static void stl_cd1400setreg(stlport_t *portp, int regnr, int value) @@ -3145,9 +3129,9 @@ static int stl_cd1400updatereg(stlport_t *portp, int regnr, int value) outb((regnr + portp->uartaddr), portp->ioaddr); if (inb(portp->ioaddr + EREG_DATA) != value) { outb(value, portp->ioaddr + EREG_DATA); - return(1); + return 1; } - return(0); + return 0; } /*****************************************************************************/ @@ -3205,7 +3189,7 @@ static int stl_cd1400panelinit(stlbrd_t *brdp, stlpanel_t *panelp) } BRDDISABLE(panelp->brdnr); - return(chipmask); + return chipmask; } /*****************************************************************************/ @@ -3556,7 +3540,7 @@ static int stl_cd1400getsignals(stlport_t *portp) #else sigs |= TIOCM_DSR; #endif - return(sigs); + return sigs; } /*****************************************************************************/ @@ -3829,9 +3813,9 @@ static int stl_cd1400datastate(stlport_t *portp) #endif if (portp == (stlport_t *) NULL) - return(0); + return 0; - return(test_bit(ASYI_TXBUSY, &portp->istate) ? 1 : 0); + return test_bit(ASYI_TXBUSY, &portp->istate) ? 1 : 0; } /*****************************************************************************/ @@ -3911,20 +3895,20 @@ static inline int stl_cd1400breakisr(stlport_t *portp, int ioaddr) outb((SRER + portp->uartaddr), ioaddr); outb((inb(ioaddr + EREG_DATA) & ~(SRER_TXDATA | SRER_TXEMPTY)), (ioaddr + EREG_DATA)); - return(1); + return 1; } else if (portp->brklen > 1) { outb((TDR + portp->uartaddr), ioaddr); outb(ETC_CMD, (ioaddr + EREG_DATA)); outb(ETC_STOPBREAK, (ioaddr + EREG_DATA)); portp->brklen = -1; - return(1); + return 1; } else { outb((COR2 + portp->uartaddr), ioaddr); outb((inb(ioaddr + EREG_DATA) & ~COR2_ETC), (ioaddr + EREG_DATA)); portp->brklen = 0; } - return(0); + return 0; } /*****************************************************************************/ @@ -4045,9 +4029,7 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) if ((ioack & ACK_TYPMASK) == ACK_TYPRXGOOD) { outb((RDCR + portp->uartaddr), ioaddr); len = inb(ioaddr + EREG_DATA); - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb((RDSR + portp->uartaddr), ioaddr); insb((ioaddr + EREG_DATA), &stl_unwanted[0], len); @@ -4056,12 +4038,10 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb((RDSR + portp->uartaddr), ioaddr); - insb((ioaddr + EREG_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + EREG_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -4085,8 +4065,7 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) portp->stats.txxoff++; goto stl_rxalldone; } - if ((tty != (struct tty_struct *) NULL) && - ((portp->rxignoremsk & status) == 0)) { + if (tty != NULL && (portp->rxignoremsk & status) == 0) { if (portp->rxmarkmsk & status) { if (status & ST_BREAK) { status = TTY_BREAK; @@ -4106,14 +4085,8 @@ static void stl_cd1400rxisr(stlpanel_t *panelp, int ioaddr) } else { status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); } } else { printk("STALLION: bad RX interrupt ack value=%x\n", ioack); @@ -4176,7 +4149,7 @@ static void stl_cd1400mdmisr(stlpanel_t *panelp, int ioaddr) static int stl_sc26198getreg(stlport_t *portp, int regnr) { outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR)); - return(inb(portp->ioaddr + XP_DATA)); + return inb(portp->ioaddr + XP_DATA); } static void stl_sc26198setreg(stlport_t *portp, int regnr, int value) @@ -4190,9 +4163,9 @@ static int stl_sc26198updatereg(stlport_t *portp, int regnr, int value) outb((regnr | portp->uartaddr), (portp->ioaddr + XP_ADDR)); if (inb(portp->ioaddr + XP_DATA) != value) { outb(value, (portp->ioaddr + XP_DATA)); - return(1); + return 1; } - return(0); + return 0; } /*****************************************************************************/ @@ -4204,7 +4177,7 @@ static int stl_sc26198updatereg(stlport_t *portp, int regnr, int value) static int stl_sc26198getglobreg(stlport_t *portp, int regnr) { outb(regnr, (portp->ioaddr + XP_ADDR)); - return(inb(portp->ioaddr + XP_DATA)); + return inb(portp->ioaddr + XP_DATA); } #if 0 @@ -4262,7 +4235,7 @@ static int stl_sc26198panelinit(stlbrd_t *brdp, stlpanel_t *panelp) } BRDDISABLE(panelp->brdnr); - return(chipmask); + return chipmask; } /*****************************************************************************/ @@ -4556,7 +4529,7 @@ static int stl_sc26198getsignals(stlport_t *portp) sigs |= (ipr & IPR_DTR) ? 0: TIOCM_DTR; sigs |= (ipr & IPR_RTS) ? 0: TIOCM_RTS; sigs |= TIOCM_DSR; - return(sigs); + return sigs; } /*****************************************************************************/ @@ -4838,9 +4811,9 @@ static int stl_sc26198datastate(stlport_t *portp) #endif if (portp == (stlport_t *) NULL) - return(0); + return 0; if (test_bit(ASYI_TXBUSY, &portp->istate)) - return(1); + return 1; save_flags(flags); cli(); @@ -4849,7 +4822,7 @@ static int stl_sc26198datastate(stlport_t *portp) BRDDISABLE(portp->brdnr); restore_flags(flags); - return((sr & SR_TXEMPTY) ? 0 : 1); + return (sr & SR_TXEMPTY) ? 0 : 1; } /*****************************************************************************/ @@ -5012,9 +4985,7 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack) len = inb(ioaddr + XP_DATA) + 1; if ((iack & IVR_TYPEMASK) == IVR_RXDATA) { - if ((tty == (struct tty_struct *) NULL) || - (tty->flip.char_buf_ptr == (char *) NULL) || - ((buflen = TTY_FLIPBUF_SIZE - tty->flip.count) == 0)) { + if (tty == NULL || (buflen = tty_buffer_request_room(tty, len)) == 0) { len = MIN(len, sizeof(stl_unwanted)); outb(GRXFIFO, (ioaddr + XP_ADDR)); insb((ioaddr + XP_DATA), &stl_unwanted[0], len); @@ -5023,12 +4994,10 @@ static void stl_sc26198rxisr(stlport_t *portp, unsigned int iack) } else { len = MIN(len, buflen); if (len > 0) { + unsigned char *ptr; outb(GRXFIFO, (ioaddr + XP_ADDR)); - insb((ioaddr + XP_DATA), tty->flip.char_buf_ptr, len); - memset(tty->flip.flag_buf_ptr, 0, len); - tty->flip.flag_buf_ptr += len; - tty->flip.char_buf_ptr += len; - tty->flip.count += len; + tty_prepare_flip_string(tty, &ptr, len); + insb((ioaddr + XP_DATA), ptr, len); tty_schedule_flip(tty); portp->stats.rxtotal += len; } @@ -5096,14 +5065,8 @@ static inline void stl_sc26198rxbadch(stlport_t *portp, unsigned char status, ch status = 0; } - if (tty->flip.char_buf_ptr != (char *) NULL) { - if (tty->flip.count < TTY_FLIPBUF_SIZE) { - *tty->flip.flag_buf_ptr++ = status; - *tty->flip.char_buf_ptr++ = ch; - tty->flip.count++; - } - tty_schedule_flip(tty); - } + tty_insert_flip_char(tty, ch, status); + tty_schedule_flip(tty); if (status == 0) portp->stats.rxtotal++;