#include <linux/smp_lock.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/device.h>
+#include <linux/delay.h>
#include <asm/io.h>
#include <asm/uaccess.h>
/*{ BRD_EASYIO, 0x2a0, 0, 0, 10, 0 },*/
};
-static int stl_nrbrds = sizeof(stl_brdconf) / sizeof(stlconf_t);
+static int stl_nrbrds = ARRAY_SIZE(stl_brdconf);
/*****************************************************************************/
*/
static char stl_unwanted[SC26198_RXFIFOSIZE];
-/*
- * Keep track of what interrupts we have requested for us.
- * We don't need to request an interrupt twice if it is being
- * shared with another Stallion board.
- */
-static int stl_gotintrs[STL_MAXBRDS];
-static int stl_numintrs;
-
/*****************************************************************************/
static stlbrd_t *stl_brds[STL_MAXBRDS];
/*****************************************************************************/
-#ifdef MODULE
/*
* Define some string labels for arguments passed from the module
* load line. These allow for easy board definitions, and easy
* modification of the io, memory and irq resoucres.
*/
-
+static int stl_nargs = 0;
static char *board0[4];
static char *board1[4];
static char *board2[4];
MODULE_DESCRIPTION("Stallion Multiport Serial Driver");
MODULE_LICENSE("GPL");
-MODULE_PARM(board0, "1-4s");
+module_param_array(board0, charp, &stl_nargs, 0);
MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,ioaddr2][,irq]]");
-MODULE_PARM(board1, "1-4s");
+module_param_array(board1, charp, &stl_nargs, 0);
MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,ioaddr2][,irq]]");
-MODULE_PARM(board2, "1-4s");
+module_param_array(board2, charp, &stl_nargs, 0);
MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,ioaddr2][,irq]]");
-MODULE_PARM(board3, "1-4s");
+module_param_array(board3, charp, &stl_nargs, 0);
MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,ioaddr2][,irq]]");
-#endif
-
/*****************************************************************************/
/*
{ PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, BRD_ECHPCI },
};
-static int stl_nrpcibrds = sizeof(stl_pcibrds) / sizeof(stlpcibrd_t);
+static int stl_nrpcibrds = ARRAY_SIZE(stl_pcibrds);
#endif
* Declare all those functions in this driver!
*/
-#ifdef MODULE
static void stl_argbrds(void);
static int stl_parsebrd(stlconf_t *confp, char **argp);
static unsigned long stl_atol(char *str);
-#endif
-int stl_init(void);
+static int stl_init(void);
static int stl_open(struct tty_struct *tty, struct file *filp);
static void stl_close(struct tty_struct *tty, struct file *filp);
-static int stl_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count);
static void stl_putchar(struct tty_struct *tty, unsigned char ch);
static void stl_flushchars(struct tty_struct *tty);
static int stl_writeroom(struct tty_struct *tty);
static int stl_brdinit(stlbrd_t *brdp);
static int stl_initports(stlbrd_t *brdp, stlpanel_t *panelp);
-static int stl_mapirq(int irq, char *name);
static int stl_getserial(stlport_t *portp, struct serial_struct __user *sp);
static int stl_setserial(stlport_t *portp, struct serial_struct __user *sp);
static int stl_getbrdstats(combrd_t __user *bp);
static int stl_getportstruct(stlport_t __user *arg);
static int stl_getbrdstruct(stlbrd_t __user *arg);
static int stl_waitcarrier(stlport_t *portp, struct file *filp);
-static void stl_delay(int len);
-static void stl_eiointr(stlbrd_t *brdp);
-static void stl_echatintr(stlbrd_t *brdp);
-static void stl_echmcaintr(stlbrd_t *brdp);
-static void stl_echpciintr(stlbrd_t *brdp);
-static void stl_echpci64intr(stlbrd_t *brdp);
+static int stl_eiointr(stlbrd_t *brdp);
+static int stl_echatintr(stlbrd_t *brdp);
+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);
230400, 460800, 921600
};
-#define SC26198_NRBAUDS (sizeof(sc26198_baudtable) / sizeof(unsigned int))
+#define SC26198_NRBAUDS ARRAY_SIZE(sc26198_baudtable)
/*****************************************************************************/
/*****************************************************************************/
-static struct class_simple *stallion_class;
-
-#ifdef MODULE
+static struct class *stallion_class;
/*
* Loadable module initialization stuff.
stl_init();
restore_flags(flags);
- return(0);
+ return 0;
}
/*****************************************************************************/
}
for (i = 0; i < 4; i++) {
devfs_remove("staliomem/%d", i);
- class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i));
+ class_device_destroy(stallion_class, MKDEV(STL_SIOMEMMAJOR, i));
}
devfs_remove("staliomem");
if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
printk("STALLION: failed to un-register serial memory device, "
"errno=%d\n", -i);
- class_simple_destroy(stallion_class);
+ class_destroy(stallion_class);
- if (stl_tmpwritebuf != (char *) NULL)
- kfree(stl_tmpwritebuf);
+ kfree(stl_tmpwritebuf);
for (i = 0; (i < stl_nrbrds); i++) {
if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
continue;
+
+ free_irq(brdp->irq, brdp);
+
for (j = 0; (j < STL_MAXPANELS); j++) {
panelp = brdp->panels[j];
if (panelp == (stlpanel_t *) NULL)
continue;
if (portp->tty != (struct tty_struct *) NULL)
stl_hangup(portp->tty);
- if (portp->tx.buf != (char *) NULL)
- kfree(portp->tx.buf);
+ kfree(portp->tx.buf);
kfree(portp);
}
kfree(panelp);
stl_brds[i] = (stlbrd_t *) NULL;
}
- for (i = 0; (i < stl_numintrs); i++)
- free_irq(stl_gotintrs[i], NULL);
-
restore_flags(flags);
}
{
stlconf_t conf;
stlbrd_t *brdp;
- int nrargs, i;
+ int i;
#ifdef DEBUG
printk("stl_argbrds()\n");
#endif
- nrargs = sizeof(stl_brdsp) / sizeof(char **);
-
- for (i = stl_nrbrds; (i < nrargs); i++) {
+ for (i = stl_nrbrds; (i < stl_nargs); i++) {
memset(&conf, 0, sizeof(conf));
if (stl_parsebrd(&conf, stl_brdsp[i]) == 0)
continue;
}
val = (val * base) + c;
}
- return(val);
+ return val;
}
/*****************************************************************************/
static int stl_parsebrd(stlconf_t *confp, char **argp)
{
char *sp;
- int nrbrdnames, i;
+ int i;
#ifdef DEBUG
printk("stl_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) 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);
- nrbrdnames = sizeof(stl_brdstr) / sizeof(stlbrdtype_t);
- for (i = 0; (i < nrbrdnames); i++) {
+ for (i = 0; i < ARRAY_SIZE(stl_brdstr); i++) {
if (strcmp(stl_brdstr[i].name, argp[0]) == 0)
break;
}
- if (i >= nrbrdnames) {
+ if (i == ARRAY_SIZE(stl_brdstr)) {
printk("STALLION: unknown board name, %s?\n", argp[0]);
- return(0);
+ return 0;
}
confp->brdtype = stl_brdstr[i].type;
}
if ((argp[i] != (char *) NULL) && (*argp[i] != 0))
confp->irq = stl_atol(argp[i]);
- return(1);
+ return 1;
}
-#endif
-
/*****************************************************************************/
/*
static void *stl_memalloc(int len)
{
- return((void *) kmalloc(len, GFP_KERNEL));
+ return (void *) kmalloc(len, GFP_KERNEL);
}
/*****************************************************************************/
if (brdp == (stlbrd_t *) NULL) {
printk("STALLION: failed to allocate memory (size=%d)\n",
sizeof(stlbrd_t));
- return((stlbrd_t *) NULL);
+ return (stlbrd_t *) NULL;
}
memset(brdp, 0, sizeof(stlbrd_t));
brdp->magic = STL_BOARDMAGIC;
- return(brdp);
+ return brdp;
}
/*****************************************************************************/
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)
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
if (portp->tx.buf == (char *) NULL) {
portp->tx.buf = (char *) stl_memalloc(STL_TXBUFSIZE);
if (portp->tx.buf == (char *) NULL)
- return(-ENOMEM);
+ return -ENOMEM;
portp->tx.head = portp->tx.buf;
portp->tx.tail = portp->tx.buf;
}
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;
}
/*
*/
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;
}
/*****************************************************************************/
portp->openwaitcnt--;
restore_flags(flags);
- return(rc);
+ return rc;
}
/*****************************************************************************/
portp->tx.tail = (char *) NULL;
}
set_bit(TTY_IO_ERROR, &tty->flags);
- if (tty->ldisc.flush_buffer)
- (tty->ldisc.flush_buffer)(tty);
+ tty_ldisc_flush(tty);
tty->closing = 0;
portp->tty = (struct tty_struct *) NULL;
if (portp->openwaitcnt) {
if (portp->close_delay)
- stl_delay(portp->close_delay);
+ msleep_interruptible(jiffies_to_msecs(portp->close_delay));
wake_up_interruptible(&portp->open_wait);
}
/*****************************************************************************/
-/*
- * Wait for a specified delay period, this is not a busy-loop. It will
- * give up the processor while waiting. Unfortunately this has some
- * rather intimate knowledge of the process management stuff.
- */
-
-static void stl_delay(int len)
-{
-#ifdef DEBUG
- printk("stl_delay(len=%d)\n", len);
-#endif
- if (len > 0) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(len);
- }
-}
-
-/*****************************************************************************/
-
/*
* Write routine. Take data and stuff it in to the TX ring queue.
* If transmit interrupts are not running then start them.
*/
-static int stl_write(struct tty_struct *tty, int from_user, const unsigned char *buf, int count)
+static int stl_write(struct tty_struct *tty, const unsigned char *buf, int count)
{
stlport_t *portp;
unsigned int len, stlen;
char *head, *tail;
#ifdef DEBUG
- printk("stl_write(tty=%x,from_user=%d,buf=%x,count=%d)\n",
- (int) tty, from_user, (int) buf, count);
+ printk("stl_write(tty=%x,buf=%x,count=%d)\n",
+ (int) tty, (int) buf, count);
#endif
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,
* copy it into the TX buffer.
*/
chbuf = (unsigned char *) buf;
- if (from_user) {
- head = portp->tx.head;
- tail = portp->tx.tail;
- len = (head >= tail) ? (STL_TXBUFSIZE - (head - tail) - 1) :
- (tail - head - 1);
- count = MIN(len, count);
-
- down(&stl_tmpwritesem);
- if (copy_from_user(stl_tmpwritebuf, chbuf, count))
- return -EFAULT;
- chbuf = &stl_tmpwritebuf[0];
- }
head = portp->tx.head;
tail = portp->tx.tail;
clear_bit(ASYI_TXLOW, &portp->istate);
stl_startrxtx(portp, -1, 1);
- if (from_user)
- up(&stl_tmpwritesem);
-
- return(count);
+ return count;
}
/*****************************************************************************/
#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));
}
/*****************************************************************************/
#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;
}
/*****************************************************************************/
(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) |
portp->closing_wait = sio.closing_wait;
portp->custom_divisor = sio.custom_divisor;
stl_setport(portp, portp->tty->termios);
- return(0);
+ return 0;
}
/*****************************************************************************/
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);
}
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;
#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;
break;
}
- return(rc);
+ return rc;
}
/*****************************************************************************/
return;
stl_flush(portp);
- 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);
}
/*****************************************************************************/
while (stl_datastate(portp)) {
if (signal_pending(current))
break;
- stl_delay(2);
+ msleep_interruptible(20);
if (time_after_eq(jiffies, tend))
break;
}
pos[(MAXLINE - 2)] = '+';
pos[(MAXLINE - 1)] = '\n';
- return(MAXLINE);
+ return MAXLINE;
}
/*****************************************************************************/
stl_readdone:
*start = page;
- return(pos - page);
+ return (pos - page);
}
/*****************************************************************************/
static irqreturn_t stl_intr(int irq, void *dev_id, struct pt_regs *regs)
{
- stlbrd_t *brdp;
- int i;
- int handled = 0;
+ stlbrd_t *brdp = (stlbrd_t *) dev_id;
#ifdef DEBUG
- printk("stl_intr(irq=%d,regs=%x)\n", irq, (int) regs);
+ printk("stl_intr(brdp=%x,irq=%d,regs=%x)\n", (int) brdp, irq,
+ (int) regs);
#endif
- for (i = 0; (i < stl_nrbrds); i++) {
- if ((brdp = stl_brds[i]) == (stlbrd_t *) NULL)
- continue;
- if (brdp->state == 0)
- continue;
- handled = 1;
- (* brdp->isr)(brdp);
- }
- return IRQ_RETVAL(handled);
+ return IRQ_RETVAL((* brdp->isr)(brdp));
}
/*****************************************************************************/
* Interrupt service routine for EasyIO board types.
*/
-static void stl_eiointr(stlbrd_t *brdp)
+static int stl_eiointr(stlbrd_t *brdp)
{
stlpanel_t *panelp;
unsigned int iobase;
+ int handled = 0;
panelp = brdp->panels[0];
iobase = panelp->iobase;
- while (inb(brdp->iostatus) & EIO_INTRPEND)
+ while (inb(brdp->iostatus) & EIO_INTRPEND) {
+ handled = 1;
(* panelp->isr)(panelp, iobase);
+ }
+ return handled;
}
/*****************************************************************************/
* Interrupt service routine for ECH-AT board types.
*/
-static void stl_echatintr(stlbrd_t *brdp)
+static int stl_echatintr(stlbrd_t *brdp)
{
stlpanel_t *panelp;
unsigned int ioaddr;
int bnknr;
+ int handled = 0;
outb((brdp->ioctrlval | ECH_BRDENABLE), brdp->ioctrl);
while (inb(brdp->iostatus) & ECH_INTRPEND) {
+ handled = 1;
for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
ioaddr = brdp->bnkstataddr[bnknr];
if (inb(ioaddr) & ECH_PNLINTRPEND) {
}
outb((brdp->ioctrlval | ECH_BRDDISABLE), brdp->ioctrl);
+
+ return handled;
}
/*****************************************************************************/
* Interrupt service routine for ECH-MCA board types.
*/
-static void stl_echmcaintr(stlbrd_t *brdp)
+static int stl_echmcaintr(stlbrd_t *brdp)
{
stlpanel_t *panelp;
unsigned int ioaddr;
int bnknr;
+ int handled = 0;
while (inb(brdp->iostatus) & ECH_INTRPEND) {
+ handled = 1;
for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
ioaddr = brdp->bnkstataddr[bnknr];
if (inb(ioaddr) & ECH_PNLINTRPEND) {
}
}
}
+ return handled;
}
/*****************************************************************************/
* Interrupt service routine for ECH-PCI board types.
*/
-static void stl_echpciintr(stlbrd_t *brdp)
+static int stl_echpciintr(stlbrd_t *brdp)
{
stlpanel_t *panelp;
unsigned int ioaddr;
int bnknr, recheck;
+ int handled = 0;
while (1) {
recheck = 0;
panelp = brdp->bnk2panel[bnknr];
(* panelp->isr)(panelp, (ioaddr & 0xfffc));
recheck++;
+ handled = 1;
}
}
if (! recheck)
break;
}
+ return handled;
}
/*****************************************************************************/
* Interrupt service routine for ECH-8/64-PCI board types.
*/
-static void stl_echpci64intr(stlbrd_t *brdp)
+static int stl_echpci64intr(stlbrd_t *brdp)
{
stlpanel_t *panelp;
unsigned int ioaddr;
int bnknr;
+ int handled = 0;
while (inb(brdp->ioctrl) & 0x1) {
+ handled = 1;
for (bnknr = 0; (bnknr < brdp->nrbnks); bnknr++) {
ioaddr = brdp->bnkstataddr[bnknr];
if (inb(ioaddr) & ECH_PNLINTRPEND) {
}
}
}
+
+ return handled;
}
/*****************************************************************************/
lock_kernel();
if (test_bit(ASYI_TXLOW, &portp->istate)) {
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
- wake_up_interruptible(&tty->write_wait);
+ tty_wakeup(tty);
}
if (test_bit(ASYI_DCDCHANGE, &portp->istate)) {
clear_bit(ASYI_DCDCHANGE, &portp->istate);
/*****************************************************************************/
-/*
- * Map in interrupt vector to this driver. Check that we don't
- * already have this vector mapped, we might be sharing this
- * interrupt across multiple boards.
- */
-
-static int __init stl_mapirq(int irq, char *name)
-{
- int rc, i;
-
-#ifdef DEBUG
- printk("stl_mapirq(irq=%d,name=%s)\n", irq, name);
-#endif
-
- rc = 0;
- for (i = 0; (i < stl_numintrs); i++) {
- if (stl_gotintrs[i] == irq)
- break;
- }
- if (i >= stl_numintrs) {
- if (request_irq(irq, stl_intr, SA_SHIRQ, name, NULL) != 0) {
- printk("STALLION: failed to register interrupt "
- "routine for %s irq=%d\n", name, irq);
- rc = -ENODEV;
- } else {
- stl_gotintrs[stl_numintrs++] = irq;
- }
- }
- return(rc);
-}
-
-/*****************************************************************************/
-
/*
* Initialize all the ports on a panel.
*/
brdp->nrpanels = 1;
brdp->state |= BRD_FOUND;
brdp->hwid = status;
- rc = stl_mapirq(brdp->irq, name);
- return(rc);
+ if (request_irq(brdp->irq, stl_intr, SA_SHIRQ, name, brdp) != 0) {
+ printk("STALLION: failed to register interrupt "
+ "routine for %s irq=%d\n", name, brdp->irq);
+ rc = -ENODEV;
+ } else {
+ rc = 0;
+ }
+ return rc;
}
/*****************************************************************************/
outb((brdp->ioctrlval | ECH_BRDDISABLE), brdp->ioctrl);
brdp->state |= BRD_FOUND;
- i = stl_mapirq(brdp->irq, name);
+ if (request_irq(brdp->irq, stl_intr, SA_SHIRQ, name, brdp) != 0) {
+ printk("STALLION: failed to register interrupt "
+ "routine for %s irq=%d\n", name, brdp->irq);
+ i = -ENODEV;
+ } else {
+ i = 0;
+ }
+
return(i);
}
*/
for (i = 0; (i < stl_nrbrds); i++) {
confp = &stl_brdconf[i];
-#ifdef MODULE
stl_parsebrd(confp, stl_brdsp[i]);
-#endif
if ((brdp = stl_allocbrd()) == (stlbrd_t *) NULL)
return(-ENOMEM);
brdp->brdnr = i;
* Find any dynamically supported boards. That is via module load
* line options or auto-detected on the PCI bus.
*/
-#ifdef MODULE
stl_argbrds();
-#endif
#ifdef CONFIG_PCI
stl_findpcibrds();
#endif
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;
/*****************************************************************************/
-int __init stl_init(void)
+static int __init stl_init(void)
{
int i;
printk(KERN_INFO "%s: version %s\n", stl_drvtitle, stl_drvversion);
printk("STALLION: failed to register serial board device\n");
devfs_mk_dir("staliomem");
- stallion_class = class_simple_create(THIS_MODULE, "staliomem");
+ stallion_class = class_create(THIS_MODULE, "staliomem");
for (i = 0; i < 4; i++) {
devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
S_IFCHR|S_IRUSR|S_IWUSR,
"staliomem/%d", i);
- class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
+ class_device_create(stallion_class, NULL,
+ MKDEV(STL_SIOMEMMAJOR, i), NULL,
+ "staliomem%d", i);
}
stl_serial->owner = THIS_MODULE;
return -1;
}
- return(0);
+ return 0;
}
/*****************************************************************************/
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)
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;
}
/*****************************************************************************/
}
BRDDISABLE(panelp->brdnr);
- return(chipmask);
+ return chipmask;
}
/*****************************************************************************/
#else
sigs |= TIOCM_DSR;
#endif
- return(sigs);
+ return sigs;
}
/*****************************************************************************/
#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;
}
/*****************************************************************************/
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;
}
/*****************************************************************************/
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);
} 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;
}
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;
} 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);
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)
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;
}
/*****************************************************************************/
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
}
BRDDISABLE(panelp->brdnr);
- return(chipmask);
+ return chipmask;
}
/*****************************************************************************/
sigs |= (ipr & IPR_DTR) ? 0: TIOCM_DTR;
sigs |= (ipr & IPR_RTS) ? 0: TIOCM_RTS;
sigs |= TIOCM_DSR;
- return(sigs);
+ return sigs;
}
/*****************************************************************************/
#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();
BRDDISABLE(portp->brdnr);
restore_flags(flags);
- return((sr & SR_TXEMPTY) ? 0 : 1);
+ return (sr & SR_TXEMPTY) ? 0 : 1;
}
/*****************************************************************************/
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);
} 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;
}
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++;