Commit 4ac4360b authored by Alan Cox's avatar Alan Cox Committed by Linus Torvalds

[PATCH] istallion: cleanups

Turned out to be rather a monster
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent effc8b70
...@@ -42,13 +42,12 @@ ...@@ -42,13 +42,12 @@
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/eisa.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#ifdef CONFIG_PCI
#include <linux/pci.h> #include <linux/pci.h>
#endif
/*****************************************************************************/ /*****************************************************************************/
...@@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = { ...@@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = {
static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); static int stli_nrbrds = ARRAY_SIZE(stli_brdconf);
/* stli_lock must NOT be taken holding brd_lock */
static spinlock_t stli_lock; /* TTY logic lock */
static spinlock_t brd_lock; /* Board logic lock */
/* /*
* There is some experimental EISA board detection code in this driver. * There is some experimental EISA board detection code in this driver.
* By default it is disabled, but for those that want to try it out, * By default it is disabled, but for those that want to try it out,
...@@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE"; ...@@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE";
static struct tty_driver *stli_serial; static struct tty_driver *stli_serial;
/*
* We will need to allocate a temporary write buffer for chars that
* come direct from user space. The problem is that a copy from user
* space might cause a page fault (typically on a system that is
* swapping!). All ports will share one buffer - since if the system
* is already swapping a shared buffer won't make things any worse.
*/
static char *stli_tmpwritebuf;
#define STLI_TXBUFSIZE 4096 #define STLI_TXBUFSIZE 4096
...@@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); ...@@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
#endif #endif
static struct pci_device_id istallion_pci_tbl[] = { static struct pci_device_id istallion_pci_tbl[] = {
{ PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), },
{ 0 } { 0 }
}; };
MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
...@@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp); ...@@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp);
static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
static void stli_poll(unsigned long arg); static void stli_poll(unsigned long arg);
static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
...@@ -693,7 +688,8 @@ static void stli_dohangup(void *arg); ...@@ -693,7 +688,8 @@ static void stli_dohangup(void *arg);
static int stli_setport(stliport_t *portp); static int stli_setport(stliport_t *portp);
static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
static long stli_mktiocm(unsigned long sigvalue); static long stli_mktiocm(unsigned long sigvalue);
...@@ -799,18 +795,8 @@ static struct class *istallion_class; ...@@ -799,18 +795,8 @@ static struct class *istallion_class;
static int __init istallion_module_init(void) static int __init istallion_module_init(void)
{ {
unsigned long flags;
#ifdef DEBUG
printk("init_module()\n");
#endif
save_flags(flags);
cli();
stli_init(); stli_init();
restore_flags(flags); return 0;
return(0);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void) ...@@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void)
{ {
stlibrd_t *brdp; stlibrd_t *brdp;
stliport_t *portp; stliport_t *portp;
unsigned long flags;
int i, j; int i, j;
#ifdef DEBUG
printk("cleanup_module()\n");
#endif
printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
stli_drvversion); stli_drvversion);
save_flags(flags); /*
cli();
/*
* Free up all allocated resources used by the ports. This includes * Free up all allocated resources used by the ports. This includes
* memory and interrupts. * memory and interrupts.
*/ */
if (stli_timeron) { if (stli_timeron) {
stli_timeron = 0; stli_timeron = 0;
del_timer(&stli_timerlist); del_timer_sync(&stli_timerlist);
} }
i = tty_unregister_driver(stli_serial); i = tty_unregister_driver(stli_serial);
if (i) { if (i) {
printk("STALLION: failed to un-register tty driver, " printk("STALLION: failed to un-register tty driver, "
"errno=%d\n", -i); "errno=%d\n", -i);
restore_flags(flags);
return; return;
} }
put_tty_driver(stli_serial); put_tty_driver(stli_serial);
...@@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void) ...@@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void)
printk("STALLION: failed to un-register serial memory device, " printk("STALLION: failed to un-register serial memory device, "
"errno=%d\n", -i); "errno=%d\n", -i);
kfree(stli_tmpwritebuf);
kfree(stli_txcookbuf); kfree(stli_txcookbuf);
for (i = 0; (i < stli_nrbrds); i++) { for (i = 0; (i < stli_nrbrds); i++) {
if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) if ((brdp = stli_brds[i]) == NULL)
continue; continue;
for (j = 0; (j < STL_MAXPORTS); j++) { for (j = 0; (j < STL_MAXPORTS); j++) {
portp = brdp->ports[j]; portp = brdp->ports[j];
if (portp != (stliport_t *) NULL) { if (portp != NULL) {
if (portp->tty != (struct tty_struct *) NULL) if (portp->tty != NULL)
tty_hangup(portp->tty); tty_hangup(portp->tty);
kfree(portp); kfree(portp);
} }
...@@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void) ...@@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void)
if (brdp->iosize > 0) if (brdp->iosize > 0)
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
kfree(brdp); kfree(brdp);
stli_brds[i] = (stlibrd_t *) NULL; stli_brds[i] = NULL;
} }
restore_flags(flags);
} }
module_init(istallion_module_init); module_init(istallion_module_init);
...@@ -899,15 +873,11 @@ static void stli_argbrds(void) ...@@ -899,15 +873,11 @@ static void stli_argbrds(void)
stlibrd_t *brdp; stlibrd_t *brdp;
int i; int i;
#ifdef DEBUG
printk("stli_argbrds()\n");
#endif
for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
memset(&conf, 0, sizeof(conf)); memset(&conf, 0, sizeof(conf));
if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
continue; continue;
if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) if ((brdp = stli_allocbrd()) == NULL)
continue; continue;
stli_nrbrds = i + 1; stli_nrbrds = i + 1;
brdp->brdnr = i; brdp->brdnr = i;
...@@ -965,12 +935,8 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) ...@@ -965,12 +935,8 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
char *sp; char *sp;
int i; int i;
#ifdef DEBUG if (argp[0] == NULL || *argp[0] == 0)
printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp); return 0;
#endif
if ((argp[0] == (char *) NULL) || (*argp[0] == 0))
return(0);
for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
*sp = TOLOWER(*sp); *sp = TOLOWER(*sp);
...@@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) ...@@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
} }
confp->brdtype = stli_brdstr[i].type; confp->brdtype = stli_brdstr[i].type;
if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) if (argp[1] != NULL && *argp[1] != 0)
confp->ioaddr1 = stli_atol(argp[1]); confp->ioaddr1 = stli_atol(argp[1]);
if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) if (argp[2] != NULL && *argp[2] != 0)
confp->memaddr = stli_atol(argp[2]); confp->memaddr = stli_atol(argp[2]);
return(1); return(1);
} }
...@@ -1003,29 +969,24 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1003,29 +969,24 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
unsigned int minordev; unsigned int minordev;
int brdnr, portnr, rc; int brdnr, portnr, rc;
#ifdef DEBUG
printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
(int) filp, tty->name);
#endif
minordev = tty->index; minordev = tty->index;
brdnr = MINOR2BRD(minordev); brdnr = MINOR2BRD(minordev);
if (brdnr >= stli_nrbrds) if (brdnr >= stli_nrbrds)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
if ((brdp->state & BST_STARTED) == 0) if ((brdp->state & BST_STARTED) == 0)
return(-ENODEV); return -ENODEV;
portnr = MINOR2PORT(minordev); portnr = MINOR2PORT(minordev);
if ((portnr < 0) || (portnr > brdp->nrports)) if ((portnr < 0) || (portnr > brdp->nrports))
return(-ENODEV); return -ENODEV;
portp = brdp->ports[portnr]; portp = brdp->ports[portnr];
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(-ENODEV); return -ENODEV;
if (portp->devnr < 1) if (portp->devnr < 1)
return(-ENODEV); return -ENODEV;
/* /*
...@@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
if (portp->flags & ASYNC_CLOSING) { if (portp->flags & ASYNC_CLOSING) {
interruptible_sleep_on(&portp->close_wait); interruptible_sleep_on(&portp->close_wait);
if (portp->flags & ASYNC_HUP_NOTIFY) if (portp->flags & ASYNC_HUP_NOTIFY)
return(-EAGAIN); return -EAGAIN;
return(-ERESTARTSYS); return -ERESTARTSYS;
} }
/* /*
...@@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_INITIALIZING, &portp->state)); !test_bit(ST_INITIALIZING, &portp->state));
if (signal_pending(current)) if (signal_pending(current))
return(-ERESTARTSYS); return -ERESTARTSYS;
if ((portp->flags & ASYNC_INITIALIZED) == 0) { if ((portp->flags & ASYNC_INITIALIZED) == 0) {
set_bit(ST_INITIALIZING, &portp->state); set_bit(ST_INITIALIZING, &portp->state);
...@@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
clear_bit(ST_INITIALIZING, &portp->state); clear_bit(ST_INITIALIZING, &portp->state);
wake_up_interruptible(&portp->raw_wait); wake_up_interruptible(&portp->raw_wait);
if (rc < 0) if (rc < 0)
return(rc); return rc;
} }
/* /*
...@@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
if (portp->flags & ASYNC_CLOSING) { if (portp->flags & ASYNC_CLOSING) {
interruptible_sleep_on(&portp->close_wait); interruptible_sleep_on(&portp->close_wait);
if (portp->flags & ASYNC_HUP_NOTIFY) if (portp->flags & ASYNC_HUP_NOTIFY)
return(-EAGAIN); return -EAGAIN;
return(-ERESTARTSYS); return -ERESTARTSYS;
} }
/* /*
...@@ -1088,10 +1049,10 @@ static int stli_open(struct tty_struct *tty, struct file *filp) ...@@ -1088,10 +1049,10 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
*/ */
if (!(filp->f_flags & O_NONBLOCK)) { if (!(filp->f_flags & O_NONBLOCK)) {
if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
return(rc); return rc;
} }
portp->flags |= ASYNC_NORMAL_ACTIVE; portp->flags |= ASYNC_NORMAL_ACTIVE;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1102,24 +1063,19 @@ static void stli_close(struct tty_struct *tty, struct file *filp) ...@@ -1102,24 +1063,19 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
stliport_t *portp; stliport_t *portp;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
#endif
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
save_flags(flags); spin_lock_irqsave(&stli_lock, flags);
cli();
if (tty_hung_up_p(filp)) { if (tty_hung_up_p(filp)) {
restore_flags(flags); spin_unlock_irqrestore(&stli_lock, flags);
return; return;
} }
if ((tty->count == 1) && (portp->refcount != 1)) if ((tty->count == 1) && (portp->refcount != 1))
portp->refcount = 1; portp->refcount = 1;
if (portp->refcount-- > 1) { if (portp->refcount-- > 1) {
restore_flags(flags); spin_unlock_irqrestore(&stli_lock, flags);
return; return;
} }
...@@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp) ...@@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
if (tty == stli_txcooktty) if (tty == stli_txcooktty)
stli_flushchars(tty); stli_flushchars(tty);
tty->closing = 1; tty->closing = 1;
spin_unlock_irqrestore(&stli_lock, flags);
if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
tty_wait_until_sent(tty, portp->closing_wait); tty_wait_until_sent(tty, portp->closing_wait);
...@@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp) ...@@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
stli_flushbuffer(tty); stli_flushbuffer(tty);
tty->closing = 0; tty->closing = 0;
portp->tty = (struct tty_struct *) NULL; portp->tty = NULL;
if (portp->openwaitcnt) { if (portp->openwaitcnt) {
if (portp->close_delay) if (portp->close_delay)
...@@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp) ...@@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
wake_up_interruptible(&portp->close_wait); wake_up_interruptible(&portp->close_wait);
restore_flags(flags);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1187,40 +1144,36 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) ...@@ -1187,40 +1144,36 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
asyport_t aport; asyport_t aport;
int rc; int rc;
#ifdef DEBUG
printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp);
#endif
if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0)
return(rc); return rc;
memset(&nt, 0, sizeof(asynotify_t)); memset(&nt, 0, sizeof(asynotify_t));
nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK);
nt.signal = SG_DCD; nt.signal = SG_DCD;
if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt,
sizeof(asynotify_t), 0)) < 0) sizeof(asynotify_t), 0)) < 0)
return(rc); return rc;
tty = portp->tty; tty = portp->tty;
if (tty == (struct tty_struct *) NULL) if (tty == NULL)
return(-ENODEV); return -ENODEV;
stli_mkasyport(portp, &aport, tty->termios); stli_mkasyport(portp, &aport, tty->termios);
if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport,
sizeof(asyport_t), 0)) < 0) sizeof(asyport_t), 0)) < 0)
return(rc); return rc;
set_bit(ST_GETSIGS, &portp->state); set_bit(ST_GETSIGS, &portp->state);
if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig,
sizeof(asysigs_t), 1)) < 0) sizeof(asysigs_t), 1)) < 0)
return(rc); return rc;
if (test_and_clear_bit(ST_GETSIGS, &portp->state)) if (test_and_clear_bit(ST_GETSIGS, &portp->state))
portp->sigs = stli_mktiocm(portp->asig.sigvalue); portp->sigs = stli_mktiocm(portp->asig.sigvalue);
stli_mkasysigs(&portp->asig, 1, 1); stli_mkasysigs(&portp->asig, 1, 1);
if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
sizeof(asysigs_t), 0)) < 0) sizeof(asysigs_t), 0)) < 0)
return(rc); return rc;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) ...@@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile cdkctrl_t *cp; cdkctrl_t __iomem *cp;
volatile unsigned char *bits; unsigned char __iomem *bits;
unsigned long flags; unsigned long flags;
int rc; int rc;
#ifdef DEBUG
printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
(int) brdp, (int) portp, (int) arg, wait);
#endif
/* /*
* Send a message to the slave to open this port. * Send a message to the slave to open this port.
*/ */
save_flags(flags);
cli();
/* /*
* Slave is already closing this port. This can happen if a hangup * Slave is already closing this port. This can happen if a hangup
...@@ -1260,7 +1206,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i ...@@ -1260,7 +1206,6 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_CLOSING, &portp->state)); !test_bit(ST_CLOSING, &portp->state));
if (signal_pending(current)) { if (signal_pending(current)) {
restore_flags(flags);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
...@@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i ...@@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
* memory. Once the message is in set the service bits to say that * memory. Once the message is in set the service bits to say that
* this port wants service. * this port wants service.
*/ */
spin_lock_irqsave(&brd_lock, flags);
EBRDENABLE(brdp); EBRDENABLE(brdp);
cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
cp->openarg = arg; writel(arg, &cp->openarg);
cp->open = 1; writeb(1, &cp->open);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
portp->portidx; portp->portidx;
*bits |= portp->portbit; writeb(readb(bits) | portp->portbit, bits);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
if (wait == 0) { if (wait == 0) {
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
return(0); return 0;
} }
/* /*
...@@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i ...@@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
*/ */
rc = 0; rc = 0;
set_bit(ST_OPENING, &portp->state); set_bit(ST_OPENING, &portp->state);
spin_unlock_irqrestore(&brd_lock, flags);
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_OPENING, &portp->state)); !test_bit(ST_OPENING, &portp->state));
if (signal_pending(current)) if (signal_pending(current))
rc = -ERESTARTSYS; rc = -ERESTARTSYS;
restore_flags(flags);
if ((rc == 0) && (portp->rc != 0)) if ((rc == 0) && (portp->rc != 0))
rc = -EIO; rc = -EIO;
return(rc); return rc;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1311,20 +1258,12 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i ...@@ -1311,20 +1258,12 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile cdkctrl_t *cp; cdkctrl_t __iomem *cp;
volatile unsigned char *bits; unsigned char __iomem *bits;
unsigned long flags; unsigned long flags;
int rc; int rc;
#ifdef DEBUG
printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
(int) brdp, (int) portp, (int) arg, wait);
#endif
save_flags(flags);
cli();
/* /*
* Slave is already closing this port. This can happen if a hangup * Slave is already closing this port. This can happen if a hangup
* occurs on this port. * occurs on this port.
...@@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, ...@@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_CLOSING, &portp->state)); !test_bit(ST_CLOSING, &portp->state));
if (signal_pending(current)) { if (signal_pending(current)) {
restore_flags(flags);
return -ERESTARTSYS; return -ERESTARTSYS;
} }
} }
...@@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, ...@@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
/* /*
* Write the close command into shared memory. * Write the close command into shared memory.
*/ */
spin_lock_irqsave(&brd_lock, flags);
EBRDENABLE(brdp); EBRDENABLE(brdp);
cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
cp->closearg = arg; writel(arg, &cp->closearg);
cp->close = 1; writeb(1, &cp->close);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
portp->portidx; portp->portidx;
*bits |= portp->portbit; writeb(readb(bits) |portp->portbit, bits);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
set_bit(ST_CLOSING, &portp->state); set_bit(ST_CLOSING, &portp->state);
if (wait == 0) { spin_unlock_irqrestore(&brd_lock, flags);
restore_flags(flags);
return(0); if (wait == 0)
} return 0;
/* /*
* Slave is in action, so now we must wait for the open acknowledgment * Slave is in action, so now we must wait for the open acknowledgment
...@@ -1366,11 +1305,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, ...@@ -1366,11 +1305,10 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
!test_bit(ST_CLOSING, &portp->state)); !test_bit(ST_CLOSING, &portp->state));
if (signal_pending(current)) if (signal_pending(current))
rc = -ERESTARTSYS; rc = -ERESTARTSYS;
restore_flags(flags);
if ((rc == 0) && (portp->rc != 0)) if ((rc == 0) && (portp->rc != 0))
rc = -EIO; rc = -EIO;
return(rc); return rc;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, ...@@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
{ {
unsigned long flags;
#ifdef DEBUG
printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
"copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
(int) arg, size, copyback);
#endif
save_flags(flags);
cli();
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_CMDING, &portp->state)); !test_bit(ST_CMDING, &portp->state));
if (signal_pending(current)) { if (signal_pending(current))
restore_flags(flags);
return -ERESTARTSYS; return -ERESTARTSYS;
}
stli_sendcmd(brdp, portp, cmd, arg, size, copyback); stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
wait_event_interruptible(portp->raw_wait, wait_event_interruptible(portp->raw_wait,
!test_bit(ST_CMDING, &portp->state)); !test_bit(ST_CMDING, &portp->state));
if (signal_pending(current)) { if (signal_pending(current))
restore_flags(flags);
return -ERESTARTSYS; return -ERESTARTSYS;
}
restore_flags(flags);
if (portp->rc != 0) if (portp->rc != 0)
return(-EIO); return -EIO;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1428,19 +1351,15 @@ static int stli_setport(stliport_t *portp) ...@@ -1428,19 +1351,15 @@ static int stli_setport(stliport_t *portp)
stlibrd_t *brdp; stlibrd_t *brdp;
asyport_t aport; asyport_t aport;
#ifdef DEBUG if (portp == NULL)
printk("stli_setport(portp=%x)\n", (int) portp); return -ENODEV;
#endif if (portp->tty == NULL)
return -ENODEV;
if (portp == (stliport_t *) NULL) if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
return(-ENODEV); return -ENODEV;
if (portp->tty == (struct tty_struct *) NULL)
return(-ENODEV);
if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds))
return(-ENODEV);
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
stli_mkasyport(portp, &aport, portp->tty->termios); stli_mkasyport(portp, &aport, portp->tty->termios);
return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
...@@ -1458,22 +1377,17 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil ...@@ -1458,22 +1377,17 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
unsigned long flags; unsigned long flags;
int rc, doclocal; int rc, doclocal;
#ifdef DEBUG
printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
(int) brdp, (int) portp, (int) filp);
#endif
rc = 0; rc = 0;
doclocal = 0; doclocal = 0;
if (portp->tty->termios->c_cflag & CLOCAL) if (portp->tty->termios->c_cflag & CLOCAL)
doclocal++; doclocal++;
save_flags(flags); spin_lock_irqsave(&stli_lock, flags);
cli();
portp->openwaitcnt++; portp->openwaitcnt++;
if (! tty_hung_up_p(filp)) if (! tty_hung_up_p(filp))
portp->refcount--; portp->refcount--;
spin_unlock_irqrestore(&stli_lock, flags);
for (;;) { for (;;) {
stli_mkasysigs(&portp->asig, 1, 1); stli_mkasysigs(&portp->asig, 1, 1);
...@@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil ...@@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
interruptible_sleep_on(&portp->open_wait); interruptible_sleep_on(&portp->open_wait);
} }
spin_lock_irqsave(&stli_lock, flags);
if (! tty_hung_up_p(filp)) if (! tty_hung_up_p(filp))
portp->refcount++; portp->refcount++;
portp->openwaitcnt--; portp->openwaitcnt--;
restore_flags(flags); spin_unlock_irqrestore(&stli_lock, flags);
return(rc); return rc;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil ...@@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
{ {
volatile cdkasy_t *ap; cdkasy_t __iomem *ap;
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile unsigned char *bits; unsigned char __iomem *bits;
unsigned char *shbuf, *chbuf; unsigned char __iomem *shbuf;
unsigned char *chbuf;
stliport_t *portp; stliport_t *portp;
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned int len, stlen, head, tail, size; unsigned int len, stlen, head, tail, size;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk("stli_write(tty=%x,buf=%x,count=%d)\n",
(int) tty, (int) buf, count);
#endif
if ((tty == (struct tty_struct *) NULL) ||
(stli_tmpwritebuf == (char *) NULL))
return(0);
if (tty == stli_txcooktty) if (tty == stli_txcooktty)
stli_flushchars(tty); stli_flushchars(tty);
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(0); return 0;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
chbuf = (unsigned char *) buf; chbuf = (unsigned char *) buf;
/* /*
* All data is now local, shove as much as possible into shared memory. * All data is now local, shove as much as possible into shared memory.
*/ */
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli();
EBRDENABLE(brdp); EBRDENABLE(brdp);
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
head = (unsigned int) ap->txq.head; head = (unsigned int) readw(&ap->txq.head);
tail = (unsigned int) ap->txq.tail; tail = (unsigned int) readw(&ap->txq.tail);
if (tail != ((unsigned int) ap->txq.tail)) if (tail != ((unsigned int) readw(&ap->txq.tail)))
tail = (unsigned int) ap->txq.tail; tail = (unsigned int) readw(&ap->txq.tail);
size = portp->txsize; size = portp->txsize;
if (head >= tail) { if (head >= tail) {
len = size - (head - tail) - 1; len = size - (head - tail) - 1;
...@@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun ...@@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
len = MIN(len, count); len = MIN(len, count);
count = 0; count = 0;
shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
while (len > 0) { while (len > 0) {
stlen = MIN(len, stlen); stlen = MIN(len, stlen);
memcpy((shbuf + head), chbuf, stlen); memcpy_toio(shbuf + head, chbuf, stlen);
chbuf += stlen; chbuf += stlen;
len -= stlen; len -= stlen;
count += stlen; count += stlen;
...@@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun ...@@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
} }
} }
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
ap->txq.head = head; writew(head, &ap->txq.head);
if (test_bit(ST_TXBUSY, &portp->state)) { if (test_bit(ST_TXBUSY, &portp->state)) {
if (ap->changed.data & DT_TXEMPTY) if (readl(&ap->changed.data) & DT_TXEMPTY)
ap->changed.data &= ~DT_TXEMPTY; writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
} }
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
portp->portidx; portp->portidx;
*bits |= portp->portbit; writeb(readb(bits) | portp->portbit, bits);
set_bit(ST_TXBUSY, &portp->state); set_bit(ST_TXBUSY, &portp->state);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
spin_unlock_irqrestore(&brd_lock, flags);
restore_flags(flags);
return(count); return(count);
} }
...@@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun ...@@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
static void stli_putchar(struct tty_struct *tty, unsigned char ch) static void stli_putchar(struct tty_struct *tty, unsigned char ch)
{ {
#ifdef DEBUG
printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
#endif
if (tty == (struct tty_struct *) NULL)
return;
if (tty != stli_txcooktty) { if (tty != stli_txcooktty) {
if (stli_txcooktty != (struct tty_struct *) NULL) if (stli_txcooktty != NULL)
stli_flushchars(stli_txcooktty); stli_flushchars(stli_txcooktty);
stli_txcooktty = tty; stli_txcooktty = tty;
} }
...@@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch) ...@@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch)
static void stli_flushchars(struct tty_struct *tty) static void stli_flushchars(struct tty_struct *tty)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile unsigned char *bits; unsigned char __iomem *bits;
volatile cdkasy_t *ap; cdkasy_t __iomem *ap;
struct tty_struct *cooktty; struct tty_struct *cooktty;
stliport_t *portp; stliport_t *portp;
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned int len, stlen, head, tail, size, count, cooksize; unsigned int len, stlen, head, tail, size, count, cooksize;
unsigned char *buf, *shbuf; unsigned char *buf;
unsigned char __iomem *shbuf;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk("stli_flushchars(tty=%x)\n", (int) tty);
#endif
cooksize = stli_txcooksize; cooksize = stli_txcooksize;
cooktty = stli_txcooktty; cooktty = stli_txcooktty;
stli_txcooksize = 0; stli_txcooksize = 0;
stli_txcookrealsize = 0; stli_txcookrealsize = 0;
stli_txcooktty = (struct tty_struct *) NULL; stli_txcooktty = NULL;
if (tty == (struct tty_struct *) NULL) if (tty == NULL)
return; return;
if (cooktty == (struct tty_struct *) NULL) if (cooktty == NULL)
return; return;
if (tty != cooktty) if (tty != cooktty)
tty = cooktty; tty = cooktty;
...@@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty) ...@@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty)
return; return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli();
EBRDENABLE(brdp); EBRDENABLE(brdp);
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
head = (unsigned int) ap->txq.head; head = (unsigned int) readw(&ap->txq.head);
tail = (unsigned int) ap->txq.tail; tail = (unsigned int) readw(&ap->txq.tail);
if (tail != ((unsigned int) ap->txq.tail)) if (tail != ((unsigned int) readw(&ap->txq.tail)))
tail = (unsigned int) ap->txq.tail; tail = (unsigned int) readw(&ap->txq.tail);
size = portp->txsize; size = portp->txsize;
if (head >= tail) { if (head >= tail) {
len = size - (head - tail) - 1; len = size - (head - tail) - 1;
...@@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty) ...@@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty)
while (len > 0) { while (len > 0) {
stlen = MIN(len, stlen); stlen = MIN(len, stlen);
memcpy((shbuf + head), buf, stlen); memcpy_toio(shbuf + head, buf, stlen);
buf += stlen; buf += stlen;
len -= stlen; len -= stlen;
count += stlen; count += stlen;
...@@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty) ...@@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty)
} }
} }
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
ap->txq.head = head; writew(head, &ap->txq.head);
if (test_bit(ST_TXBUSY, &portp->state)) { if (test_bit(ST_TXBUSY, &portp->state)) {
if (ap->changed.data & DT_TXEMPTY) if (readl(&ap->changed.data) & DT_TXEMPTY)
ap->changed.data &= ~DT_TXEMPTY; writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
} }
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
portp->portidx; portp->portidx;
*bits |= portp->portbit; writeb(readb(bits) | portp->portbit, bits);
set_bit(ST_TXBUSY, &portp->state); set_bit(ST_TXBUSY, &portp->state);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
} }
/*****************************************************************************/ /*****************************************************************************/
static int stli_writeroom(struct tty_struct *tty) static int stli_writeroom(struct tty_struct *tty)
{ {
volatile cdkasyrq_t *rp; cdkasyrq_t __iomem *rp;
stliport_t *portp; stliport_t *portp;
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned int head, tail, len; unsigned int head, tail, len;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk("stli_writeroom(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return(0);
if (tty == stli_txcooktty) { if (tty == stli_txcooktty) {
if (stli_txcookrealsize != 0) { if (stli_txcookrealsize != 0) {
len = stli_txcookrealsize - stli_txcooksize; len = stli_txcookrealsize - stli_txcooksize;
return(len); return len;
} }
} }
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(0); return 0;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli();
EBRDENABLE(brdp); EBRDENABLE(brdp);
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
head = (unsigned int) rp->head; head = (unsigned int) readw(&rp->head);
tail = (unsigned int) rp->tail; tail = (unsigned int) readw(&rp->tail);
if (tail != ((unsigned int) rp->tail)) if (tail != ((unsigned int) readw(&rp->tail)))
tail = (unsigned int) rp->tail; tail = (unsigned int) readw(&rp->tail);
len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
len--; len--;
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
if (tty == stli_txcooktty) { if (tty == stli_txcooktty) {
stli_txcookrealsize = len; stli_txcookrealsize = len;
len -= stli_txcooksize; len -= stli_txcooksize;
} }
return(len); return len;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty) ...@@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty)
static int stli_charsinbuffer(struct tty_struct *tty) static int stli_charsinbuffer(struct tty_struct *tty)
{ {
volatile cdkasyrq_t *rp; cdkasyrq_t __iomem *rp;
stliport_t *portp; stliport_t *portp;
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned int head, tail, len; unsigned int head, tail, len;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk("stli_charsinbuffer(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return(0);
if (tty == stli_txcooktty) if (tty == stli_txcooktty)
stli_flushchars(tty); stli_flushchars(tty);
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(0); return 0;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli();
EBRDENABLE(brdp); EBRDENABLE(brdp);
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
head = (unsigned int) rp->head; head = (unsigned int) readw(&rp->head);
tail = (unsigned int) rp->tail; tail = (unsigned int) readw(&rp->tail);
if (tail != ((unsigned int) rp->tail)) if (tail != ((unsigned int) readw(&rp->tail)))
tail = (unsigned int) rp->tail; tail = (unsigned int) readw(&rp->tail);
len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head));
if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
len = 1; len = 1;
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
return(len); return len;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1846,10 +1728,6 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) ...@@ -1846,10 +1728,6 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
struct serial_struct sio; struct serial_struct sio;
stlibrd_t *brdp; stlibrd_t *brdp;
#ifdef DEBUG
printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
#endif
memset(&sio, 0, sizeof(struct serial_struct)); memset(&sio, 0, sizeof(struct serial_struct));
sio.type = PORT_UNKNOWN; sio.type = PORT_UNKNOWN;
sio.line = portp->portnr; sio.line = portp->portnr;
...@@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) ...@@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
sio.hub6 = 0; sio.hub6 = 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp != (stlibrd_t *) NULL) if (brdp != NULL)
sio.port = brdp->iobase; sio.port = brdp->iobase;
return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
...@@ -1883,10 +1761,6 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) ...@@ -1883,10 +1761,6 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
struct serial_struct sio; struct serial_struct sio;
int rc; int rc;
#ifdef DEBUG
printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp);
#endif
if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
return -EFAULT; return -EFAULT;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
...@@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) ...@@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
(sio.close_delay != portp->close_delay) || (sio.close_delay != portp->close_delay) ||
((sio.flags & ~ASYNC_USR_MASK) != ((sio.flags & ~ASYNC_USR_MASK) !=
(portp->flags & ~ASYNC_USR_MASK))) (portp->flags & ~ASYNC_USR_MASK)))
return(-EPERM); return -EPERM;
} }
portp->flags = (portp->flags & ~ASYNC_USR_MASK) | portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
...@@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) ...@@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
portp->custom_divisor = sio.custom_divisor; portp->custom_divisor = sio.custom_divisor;
if ((rc = stli_setport(portp)) < 0) if ((rc = stli_setport(portp)) < 0)
return(rc); return rc;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file) ...@@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
stlibrd_t *brdp; stlibrd_t *brdp;
int rc; int rc;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(-ENODEV); return -ENODEV;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
if (tty->flags & (1 << TTY_IO_ERROR)) if (tty->flags & (1 << TTY_IO_ERROR))
return(-EIO); return -EIO;
if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS,
&portp->asig, sizeof(asysigs_t), 1)) < 0) &portp->asig, sizeof(asysigs_t), 1)) < 0)
return(rc); return rc;
return stli_mktiocm(portp->asig.sigvalue); return stli_mktiocm(portp->asig.sigvalue);
} }
...@@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file, ...@@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
stlibrd_t *brdp; stlibrd_t *brdp;
int rts = -1, dtr = -1; int rts = -1, dtr = -1;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(-ENODEV); return -ENODEV;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
if (tty->flags & (1 << TTY_IO_ERROR)) if (tty->flags & (1 << TTY_IO_ERROR))
return(-EIO); return -EIO;
if (set & TIOCM_RTS) if (set & TIOCM_RTS)
rts = 1; rts = 1;
...@@ -1974,26 +1848,19 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -1974,26 +1848,19 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
int rc; int rc;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
#ifdef DEBUG
printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
(int) tty, (int) file, cmd, (int) arg);
#endif
if (tty == (struct tty_struct *) NULL)
return(-ENODEV);
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(-ENODEV); return -ENODEV;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return(0); return 0;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(0); return 0;
if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
(cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
if (tty->flags & (1 << TTY_IO_ERROR)) if (tty->flags & (1 << TTY_IO_ERROR))
return(-EIO); return -EIO;
} }
rc = 0; rc = 0;
...@@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
break; break;
} }
return(rc); return rc;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2057,19 +1924,15 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old) ...@@ -2057,19 +1924,15 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
struct termios *tiosp; struct termios *tiosp;
asyport_t aport; asyport_t aport;
#ifdef DEBUG if (tty == NULL)
printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
#endif
if (tty == (struct tty_struct *) NULL)
return; return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
tiosp = tty->termios; tiosp = tty->termios;
...@@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old) ...@@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
static void stli_throttle(struct tty_struct *tty) static void stli_throttle(struct tty_struct *tty)
{ {
stliport_t *portp; stliport_t *portp = tty->driver_data;
if (portp == NULL)
#ifdef DEBUG
printk("stli_throttle(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data;
if (portp == (stliport_t *) NULL)
return; return;
set_bit(ST_RXSTOP, &portp->state); set_bit(ST_RXSTOP, &portp->state);
} }
...@@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty) ...@@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty)
static void stli_unthrottle(struct tty_struct *tty) static void stli_unthrottle(struct tty_struct *tty)
{ {
stliport_t *portp; stliport_t *portp = tty->driver_data;
if (portp == NULL)
#ifdef DEBUG
printk("stli_unthrottle(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data;
if (portp == (stliport_t *) NULL)
return; return;
clear_bit(ST_RXSTOP, &portp->state); clear_bit(ST_RXSTOP, &portp->state);
} }
/*****************************************************************************/ /*****************************************************************************/
/* /*
* Stop the transmitter. Basically to do this we will just turn TX * Stop the transmitter.
* interrupts off.
*/ */
static void stli_stop(struct tty_struct *tty) static void stli_stop(struct tty_struct *tty)
{ {
stlibrd_t *brdp;
stliport_t *portp;
asyctrl_t actrl;
#ifdef DEBUG
printk("stli_stop(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data;
if (portp == (stliport_t *) NULL)
return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return;
brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL)
return;
memset(&actrl, 0, sizeof(asyctrl_t));
actrl.txctrl = CT_STOPFLOW;
#if 0
stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
#endif
} }
/*****************************************************************************/ /*****************************************************************************/
/* /*
* Start the transmitter again. Just turn TX interrupts back on. * Start the transmitter again.
*/ */
static void stli_start(struct tty_struct *tty) static void stli_start(struct tty_struct *tty)
{ {
stliport_t *portp;
stlibrd_t *brdp;
asyctrl_t actrl;
#ifdef DEBUG
printk("stli_start(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data;
if (portp == (stliport_t *) NULL)
return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
return;
brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL)
return;
memset(&actrl, 0, sizeof(asyctrl_t));
actrl.txctrl = CT_STARTFLOW;
#if 0
stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
#endif
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2224,23 +2020,10 @@ static void stli_start(struct tty_struct *tty) ...@@ -2224,23 +2020,10 @@ static void stli_start(struct tty_struct *tty)
static void stli_dohangup(void *arg) static void stli_dohangup(void *arg)
{ {
stliport_t *portp; stliport_t *portp = (stliport_t *) arg;
if (portp->tty != NULL) {
#ifdef DEBUG
printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg);
#endif
/*
* FIXME: There's a module removal race here: tty_hangup
* calls schedule_work which will call into this
* driver later.
*/
portp = (stliport_t *) arg;
if (portp != (stliport_t *) NULL) {
if (portp->tty != (struct tty_struct *) NULL) {
tty_hangup(portp->tty); tty_hangup(portp->tty);
} }
}
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2258,27 +2041,21 @@ static void stli_hangup(struct tty_struct *tty) ...@@ -2258,27 +2041,21 @@ static void stli_hangup(struct tty_struct *tty)
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
portp->flags &= ~ASYNC_INITIALIZED; portp->flags &= ~ASYNC_INITIALIZED;
save_flags(flags); if (!test_bit(ST_CLOSING, &portp->state))
cli();
if (! test_bit(ST_CLOSING, &portp->state))
stli_rawclose(brdp, portp, 0, 0); stli_rawclose(brdp, portp, 0, 0);
spin_lock_irqsave(&stli_lock, flags);
if (tty->termios->c_cflag & HUPCL) { if (tty->termios->c_cflag & HUPCL) {
stli_mkasysigs(&portp->asig, 0, 0); stli_mkasysigs(&portp->asig, 0, 0);
if (test_bit(ST_CMDING, &portp->state)) { if (test_bit(ST_CMDING, &portp->state)) {
...@@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty) ...@@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty)
&portp->asig, sizeof(asysigs_t), 0); &portp->asig, sizeof(asysigs_t), 0);
} }
} }
restore_flags(flags);
clear_bit(ST_TXBUSY, &portp->state); clear_bit(ST_TXBUSY, &portp->state);
clear_bit(ST_RXSTOP, &portp->state); clear_bit(ST_RXSTOP, &portp->state);
set_bit(TTY_IO_ERROR, &tty->flags); set_bit(TTY_IO_ERROR, &tty->flags);
portp->tty = (struct tty_struct *) NULL; portp->tty = NULL;
portp->flags &= ~ASYNC_NORMAL_ACTIVE; portp->flags &= ~ASYNC_NORMAL_ACTIVE;
portp->refcount = 0; portp->refcount = 0;
spin_unlock_irqrestore(&stli_lock, flags);
wake_up_interruptible(&portp->open_wait); wake_up_interruptible(&portp->open_wait);
} }
...@@ -2316,25 +2094,18 @@ static void stli_flushbuffer(struct tty_struct *tty) ...@@ -2316,25 +2094,18 @@ static void stli_flushbuffer(struct tty_struct *tty)
stlibrd_t *brdp; stlibrd_t *brdp;
unsigned long ftype, flags; unsigned long ftype, flags;
#ifdef DEBUG
printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli();
if (tty == stli_txcooktty) { if (tty == stli_txcooktty) {
stli_txcooktty = (struct tty_struct *) NULL; stli_txcooktty = NULL;
stli_txcooksize = 0; stli_txcooksize = 0;
stli_txcookrealsize = 0; stli_txcookrealsize = 0;
} }
...@@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty) ...@@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty)
ftype |= FLUSHRX; ftype |= FLUSHRX;
clear_bit(ST_DOFLUSHRX, &portp->state); clear_bit(ST_DOFLUSHRX, &portp->state);
} }
stli_sendcmd(brdp, portp, A_FLUSH, &ftype, __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0);
sizeof(unsigned long), 0);
} }
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
tty_wakeup(tty);
wake_up_interruptible(&tty->write_wait);
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup)
(tty->ldisc.write_wakeup)(tty);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2364,38 +2130,18 @@ static void stli_breakctl(struct tty_struct *tty, int state) ...@@ -2364,38 +2130,18 @@ static void stli_breakctl(struct tty_struct *tty, int state)
stlibrd_t *brdp; stlibrd_t *brdp;
stliport_t *portp; stliport_t *portp;
long arg; long arg;
/* long savestate, savetime; */
#ifdef DEBUG
printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
/*
* Due to a bug in the tty send_break() code we need to preserve
* the current process state and timeout...
savetime = current->timeout;
savestate = current->state;
*/
arg = (state == -1) ? BREAKON : BREAKOFF; arg = (state == -1) ? BREAKON : BREAKOFF;
stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
/*
*
current->timeout = savetime;
current->state = savestate;
*/
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2405,14 +2151,10 @@ static void stli_waituntilsent(struct tty_struct *tty, int timeout) ...@@ -2405,14 +2151,10 @@ static void stli_waituntilsent(struct tty_struct *tty, int timeout)
stliport_t *portp; stliport_t *portp;
unsigned long tend; unsigned long tend;
#ifdef DEBUG if (tty == NULL)
printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout);
#endif
if (tty == (struct tty_struct *) NULL)
return; return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if (timeout == 0) if (timeout == 0)
...@@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) ...@@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
stliport_t *portp; stliport_t *portp;
asyctrl_t actrl; asyctrl_t actrl;
#ifdef DEBUG
printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
#endif
if (tty == (struct tty_struct *) NULL)
return;
portp = tty->driver_data; portp = tty->driver_data;
if (portp == (stliport_t *) NULL) if (portp == NULL)
return; return;
if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
return; return;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return; return;
memset(&actrl, 0, sizeof(asyctrl_t)); memset(&actrl, 0, sizeof(asyctrl_t));
...@@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) ...@@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
actrl.txctrl = CT_SENDCHR; actrl.txctrl = CT_SENDCHR;
actrl.tximdch = ch; actrl.tximdch = ch;
} }
stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
} }
...@@ -2486,7 +2221,7 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p ...@@ -2486,7 +2221,7 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
switch (stli_comstats.hwid) { switch (stli_comstats.hwid) {
case 0: uart = "2681"; break; case 0: uart = "2681"; break;
case 1: uart = "SC26198"; break; case 1: uart = "SC26198"; break;
default: uart = "CD1400"; break; default:uart = "CD1400"; break;
} }
} }
...@@ -2543,12 +2278,6 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo ...@@ -2543,12 +2278,6 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
int curoff, maxoff; int curoff, maxoff;
char *pos; char *pos;
#ifdef DEBUG
printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
"data=%x\n", (int) page, (int) start, (int) off, count,
(int) eof, (int) data);
#endif
pos = page; pos = page;
totalport = 0; totalport = 0;
curoff = 0; curoff = 0;
...@@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo ...@@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
*/ */
for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
continue; continue;
if (brdp->state == 0) if (brdp->state == 0)
continue; continue;
...@@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo ...@@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
for (portnr = 0; (portnr < brdp->nrports); portnr++, for (portnr = 0; (portnr < brdp->nrports); portnr++,
totalport++) { totalport++) {
portp = brdp->ports[portnr]; portp = brdp->ports[portnr];
if (portp == (stliport_t *) NULL) if (portp == NULL)
continue; continue;
if (off >= (curoff += MAXLINE)) if (off >= (curoff += MAXLINE))
continue; continue;
...@@ -2610,49 +2339,54 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo ...@@ -2610,49 +2339,54 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
* a poll routine that does not have user context. Therefore you cannot * a poll routine that does not have user context. Therefore you cannot
* copy back directly into user space, or to the kernel stack of a * copy back directly into user space, or to the kernel stack of a
* process. This routine does not sleep, so can be called from anywhere. * process. This routine does not sleep, so can be called from anywhere.
*
* The caller must hold the brd_lock (see also stli_sendcmd the usual
* entry point)
*/ */
static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile cdkctrl_t *cp; cdkctrl_t __iomem *cp;
volatile unsigned char *bits; unsigned char __iomem *bits;
unsigned long flags; unsigned long flags;
#ifdef DEBUG spin_lock_irqsave(&brd_lock, flags);
printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
"copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
(int) arg, size, copyback);
#endif
save_flags(flags);
cli();
if (test_bit(ST_CMDING, &portp->state)) { if (test_bit(ST_CMDING, &portp->state)) {
printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
(int) cmd); (int) cmd);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
return; return;
} }
EBRDENABLE(brdp); EBRDENABLE(brdp);
cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
if (size > 0) { if (size > 0) {
memcpy((void *) &(cp->args[0]), arg, size); memcpy_toio((void __iomem *) &(cp->args[0]), arg, size);
if (copyback) { if (copyback) {
portp->argp = arg; portp->argp = arg;
portp->argsize = size; portp->argsize = size;
} }
} }
cp->status = 0; writel(0, &cp->status);
cp->cmd = cmd; writel(cmd, &cp->cmd);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
portp->portidx; portp->portidx;
*bits |= portp->portbit; writeb(readb(bits) | portp->portbit, bits);
set_bit(ST_CMDING, &portp->state); set_bit(ST_CMDING, &portp->state);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
}
static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
{
unsigned long flags;
spin_lock_irqsave(&brd_lock, flags);
__stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
spin_unlock_irqrestore(&brd_lock, flags);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, ...@@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
static void stli_read(stlibrd_t *brdp, stliport_t *portp) static void stli_read(stlibrd_t *brdp, stliport_t *portp)
{ {
volatile cdkasyrq_t *rp; cdkasyrq_t __iomem *rp;
volatile char *shbuf; char __iomem *shbuf;
struct tty_struct *tty; struct tty_struct *tty;
unsigned int head, tail, size; unsigned int head, tail, size;
unsigned int len, stlen; unsigned int len, stlen;
#ifdef DEBUG
printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n",
(int) brdp, (int) portp);
#endif
if (test_bit(ST_RXSTOP, &portp->state)) if (test_bit(ST_RXSTOP, &portp->state))
return; return;
tty = portp->tty; tty = portp->tty;
if (tty == (struct tty_struct *) NULL) if (tty == NULL)
return; return;
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
head = (unsigned int) rp->head; head = (unsigned int) readw(&rp->head);
if (head != ((unsigned int) rp->head)) if (head != ((unsigned int) readw(&rp->head)))
head = (unsigned int) rp->head; head = (unsigned int) readw(&rp->head);
tail = (unsigned int) rp->tail; tail = (unsigned int) readw(&rp->tail);
size = portp->rxsize; size = portp->rxsize;
if (head >= tail) { if (head >= tail) {
len = head - tail; len = head - tail;
...@@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) ...@@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
} }
len = tty_buffer_request_room(tty, len); len = tty_buffer_request_room(tty, len);
/* FIXME : iomap ? */
shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset);
while (len > 0) { while (len > 0) {
unsigned char *cptr;
stlen = MIN(len, stlen); stlen = MIN(len, stlen);
tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); tty_prepare_flip_string(tty, &cptr, stlen);
memcpy_fromio(cptr, shbuf + tail, stlen);
len -= stlen; len -= stlen;
tail += stlen; tail += stlen;
if (tail >= size) { if (tail >= size) {
...@@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) ...@@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
stlen = head; stlen = head;
} }
} }
rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
rp->tail = tail; writew(tail, &rp->tail);
if (head != tail) if (head != tail)
set_bit(ST_RXING, &portp->state); set_bit(ST_RXING, &portp->state);
...@@ -2729,7 +2461,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) ...@@ -2729,7 +2461,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
* difficult to deal with them here. * difficult to deal with them here.
*/ */
static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
{ {
int cmd; int cmd;
...@@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) ...@@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
clear_bit(ST_DOFLUSHTX, &portp->state); clear_bit(ST_DOFLUSHTX, &portp->state);
clear_bit(ST_DOFLUSHRX, &portp->state); clear_bit(ST_DOFLUSHRX, &portp->state);
clear_bit(ST_DOSIGS, &portp->state); clear_bit(ST_DOSIGS, &portp->state);
memcpy((void *) &(cp->args[0]), (void *) &portp->asig, memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig,
sizeof(asysigs_t)); sizeof(asysigs_t));
cp->status = 0; writel(0, &cp->status);
cp->cmd = cmd; writel(cmd, &cp->cmd);
set_bit(ST_CMDING, &portp->state); set_bit(ST_CMDING, &portp->state);
} else if (test_bit(ST_DOFLUSHTX, &portp->state) || } else if (test_bit(ST_DOFLUSHTX, &portp->state) ||
test_bit(ST_DOFLUSHRX, &portp->state)) { test_bit(ST_DOFLUSHRX, &portp->state)) {
...@@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) ...@@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0);
clear_bit(ST_DOFLUSHTX, &portp->state); clear_bit(ST_DOFLUSHTX, &portp->state);
clear_bit(ST_DOFLUSHRX, &portp->state); clear_bit(ST_DOFLUSHRX, &portp->state);
memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int));
cp->status = 0; writel(0, &cp->status);
cp->cmd = A_FLUSH; writel(A_FLUSH, &cp->cmd);
set_bit(ST_CMDING, &portp->state); set_bit(ST_CMDING, &portp->state);
} }
} }
...@@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) ...@@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
{ {
volatile cdkasy_t *ap; cdkasy_t __iomem *ap;
volatile cdkctrl_t *cp; cdkctrl_t __iomem *cp;
struct tty_struct *tty; struct tty_struct *tty;
asynotify_t nt; asynotify_t nt;
unsigned long oldsigs; unsigned long oldsigs;
int rc, donerx; int rc, donerx;
#ifdef DEBUG ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n",
(int) brdp, channr);
#endif
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
cp = &ap->ctrl; cp = &ap->ctrl;
/* /*
* Check if we are waiting for an open completion message. * Check if we are waiting for an open completion message.
*/ */
if (test_bit(ST_OPENING, &portp->state)) { if (test_bit(ST_OPENING, &portp->state)) {
rc = (int) cp->openarg; rc = readl(&cp->openarg);
if ((cp->open == 0) && (rc != 0)) { if (readb(&cp->open) == 0 && rc != 0) {
if (rc > 0) if (rc > 0)
rc--; rc--;
cp->openarg = 0; writel(0, &cp->openarg);
portp->rc = rc; portp->rc = rc;
clear_bit(ST_OPENING, &portp->state); clear_bit(ST_OPENING, &portp->state);
wake_up_interruptible(&portp->raw_wait); wake_up_interruptible(&portp->raw_wait);
...@@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) ...@@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
* Check if we are waiting for a close completion message. * Check if we are waiting for a close completion message.
*/ */
if (test_bit(ST_CLOSING, &portp->state)) { if (test_bit(ST_CLOSING, &portp->state)) {
rc = (int) cp->closearg; rc = (int) readl(&cp->closearg);
if ((cp->close == 0) && (rc != 0)) { if (readb(&cp->close) == 0 && rc != 0) {
if (rc > 0) if (rc > 0)
rc--; rc--;
cp->closearg = 0; writel(0, &cp->closearg);
portp->rc = rc; portp->rc = rc;
clear_bit(ST_CLOSING, &portp->state); clear_bit(ST_CLOSING, &portp->state);
wake_up_interruptible(&portp->raw_wait); wake_up_interruptible(&portp->raw_wait);
...@@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) ...@@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
* need to copy out the command results associated with this command. * need to copy out the command results associated with this command.
*/ */
if (test_bit(ST_CMDING, &portp->state)) { if (test_bit(ST_CMDING, &portp->state)) {
rc = cp->status; rc = readl(&cp->status);
if ((cp->cmd == 0) && (rc != 0)) { if (readl(&cp->cmd) == 0 && rc != 0) {
if (rc > 0) if (rc > 0)
rc--; rc--;
if (portp->argp != (void *) NULL) { if (portp->argp != NULL) {
memcpy(portp->argp, (void *) &(cp->args[0]), memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]),
portp->argsize); portp->argsize);
portp->argp = (void *) NULL; portp->argp = NULL;
} }
cp->status = 0; writel(0, &cp->status);
portp->rc = rc; portp->rc = rc;
clear_bit(ST_CMDING, &portp->state); clear_bit(ST_CMDING, &portp->state);
stli_dodelaycmd(portp, cp); stli_dodelaycmd(portp, cp);
...@@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) ...@@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
if (nt.data & DT_TXEMPTY) if (nt.data & DT_TXEMPTY)
clear_bit(ST_TXBUSY, &portp->state); clear_bit(ST_TXBUSY, &portp->state);
if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { if (nt.data & (DT_TXEMPTY | DT_TXLOW)) {
if (tty != (struct tty_struct *) NULL) { if (tty != NULL) {
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty_wakeup(tty);
tty->ldisc.write_wakeup) {
(tty->ldisc.write_wakeup)(tty);
EBRDENABLE(brdp); EBRDENABLE(brdp);
}
wake_up_interruptible(&tty->write_wait); wake_up_interruptible(&tty->write_wait);
} }
} }
if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
if (tty != (struct tty_struct *) NULL) { if (tty != NULL) {
tty_insert_flip_char(tty, 0, TTY_BREAK); tty_insert_flip_char(tty, 0, TTY_BREAK);
if (portp->flags & ASYNC_SAK) { if (portp->flags & ASYNC_SAK) {
do_SAK(tty); do_SAK(tty);
...@@ -2932,12 +2656,12 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) ...@@ -2932,12 +2656,12 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
* at the cdk header structure. * at the cdk header structure.
*/ */
static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
{ {
stliport_t *portp; stliport_t *portp;
unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
unsigned char *slavep; unsigned char __iomem *slavep;
int bitpos, bitat, bitsize; int bitpos, bitat, bitsize;
int channr, nrdevs, slavebitchange; int channr, nrdevs, slavebitchange;
...@@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) ...@@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
* 8 service bits at a time in the inner loop, so we can bypass * 8 service bits at a time in the inner loop, so we can bypass
* the lot if none of them want service. * the lot if none of them want service.
*/ */
memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset),
bitsize); bitsize);
memset(&slavebits[0], 0, bitsize); memset(&slavebits[0], 0, bitsize);
...@@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) ...@@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
* service may initiate more slave requests. * service may initiate more slave requests.
*/ */
if (slavebitchange) { if (slavebitchange) {
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset;
for (bitpos = 0; (bitpos < bitsize); bitpos++) { for (bitpos = 0; (bitpos < bitsize); bitpos++) {
if (slavebits[bitpos]) if (readb(slavebits + bitpos))
slavep[bitpos] &= ~slavebits[bitpos]; writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos);
} }
} }
} }
...@@ -3000,7 +2724,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) ...@@ -3000,7 +2724,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
static void stli_poll(unsigned long arg) static void stli_poll(unsigned long arg)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
stlibrd_t *brdp; stlibrd_t *brdp;
int brdnr; int brdnr;
...@@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg) ...@@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg)
*/ */
for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
continue; continue;
if ((brdp->state & BST_STARTED) == 0) if ((brdp->state & BST_STARTED) == 0)
continue; continue;
spin_lock(&brd_lock);
EBRDENABLE(brdp); EBRDENABLE(brdp);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
if (hdrp->hostreq) if (readb(&hdrp->hostreq))
stli_brdpoll(brdp, hdrp); stli_brdpoll(brdp, hdrp);
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
spin_unlock(&brd_lock);
} }
} }
...@@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg) ...@@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg)
static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
(int) portp, (int) pp, (int) tiosp);
#endif
memset(pp, 0, sizeof(asyport_t)); memset(pp, 0, sizeof(asyport_t));
/* /*
...@@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio ...@@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n",
(int) sp, dtr, rts);
#endif
memset(sp, 0, sizeof(asysigs_t)); memset(sp, 0, sizeof(asysigs_t));
if (dtr >= 0) { if (dtr >= 0) {
sp->signal |= SG_DTR; sp->signal |= SG_DTR;
...@@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) ...@@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
static long stli_mktiocm(unsigned long sigvalue) static long stli_mktiocm(unsigned long sigvalue)
{ {
long tiocm; long tiocm = 0;
#ifdef DEBUG
printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue);
#endif
tiocm = 0;
tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0);
tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0);
tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0);
...@@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp) ...@@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp)
stliport_t *portp; stliport_t *portp;
int i, panelnr, panelport; int i, panelnr, panelport;
#ifdef DEBUG
printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp);
#endif
for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
if (!portp) { if (!portp) {
...@@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp) ...@@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp)
brdp->ports[i] = portp; brdp->ports[i] = portp;
} }
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp) ...@@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
{ {
unsigned long memconf; unsigned long memconf;
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp);
#endif
outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
udelay(10); udelay(10);
outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
...@@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp) ...@@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
static void stli_ecpenable(stlibrd_t *brdp) static void stli_ecpenable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp);
#endif
outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
} }
...@@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp) ...@@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp)
static void stli_ecpdisable(stlibrd_t *brdp) static void stli_ecpdisable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp);
#endif
outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
} }
...@@ -3293,11 +2989,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3293,11 +2989,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
void *ptr; void *ptr;
unsigned char val; unsigned char val;
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
(int) offset);
#endif
if (offset > brdp->memsize) { if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of " printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n", "range at line=%d(%d), brd=%d\n",
...@@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
static void stli_ecpreset(stlibrd_t *brdp) static void stli_ecpreset(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp);
#endif
outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
udelay(10); udelay(10);
outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
...@@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp) ...@@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp)
static void stli_ecpintr(stlibrd_t *brdp) static void stli_ecpintr(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp);
#endif
outb(0x1, brdp->iobase); outb(0x1, brdp->iobase);
} }
...@@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp) ...@@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
{ {
unsigned long memconf; unsigned long memconf;
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp);
#endif
outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); outb(0x1, (brdp->iobase + ECP_EIBRDENAB));
outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
udelay(10); udelay(10);
...@@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line ...@@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line
void *ptr; void *ptr;
unsigned char val; unsigned char val;
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
(int) brdp, (int) offset, line);
#endif
if (offset > brdp->memsize) { if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of " printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n", "range at line=%d(%d), brd=%d\n",
...@@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp) ...@@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
static void stli_ecppciinit(stlibrd_t *brdp) static void stli_ecppciinit(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp);
#endif
outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
udelay(10); udelay(10);
outb(0, (brdp->iobase + ECP_PCICONFR)); outb(0, (brdp->iobase + ECP_PCICONFR));
...@@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin ...@@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin
void *ptr; void *ptr;
unsigned char val; unsigned char val;
#ifdef DEBUG
printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
(int) brdp, (int) offset, line);
#endif
if (offset > brdp->memsize) { if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of " printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), board=%d\n", "range at line=%d(%d), board=%d\n",
...@@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp) ...@@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp)
{ {
unsigned long memconf; unsigned long memconf;
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp);
#endif
outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
udelay(10); udelay(10);
outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
...@@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp) ...@@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp)
static void stli_onbenable(stlibrd_t *brdp) static void stli_onbenable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp);
#endif
outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
} }
...@@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp) ...@@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp)
static void stli_onbdisable(stlibrd_t *brdp) static void stli_onbdisable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp);
#endif
outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
} }
...@@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
{ {
void *ptr; void *ptr;
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
(int) offset);
#endif
if (offset > brdp->memsize) { if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of " printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n", "range at line=%d(%d), brd=%d\n",
...@@ -3589,11 +3240,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3589,11 +3240,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
static void stli_onbreset(stlibrd_t *brdp) static void stli_onbreset(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp);
#endif
outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
udelay(10); udelay(10);
outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
...@@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp) ...@@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
{ {
unsigned long memconf; unsigned long memconf;
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp);
#endif
outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); outb(0x1, (brdp->iobase + ONB_EIBRDENAB));
outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
udelay(10); udelay(10);
...@@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp) ...@@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
static void stli_onbeenable(stlibrd_t *brdp) static void stli_onbeenable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp);
#endif
outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
} }
...@@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp) ...@@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp)
static void stli_onbedisable(stlibrd_t *brdp) static void stli_onbedisable(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp);
#endif
outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
} }
...@@ -3655,11 +3291,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3655,11 +3291,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
void *ptr; void *ptr;
unsigned char val; unsigned char val;
#ifdef DEBUG
printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
(int) brdp, (int) offset, line);
#endif
if (offset > brdp->memsize) { if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of " printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n", "range at line=%d(%d), brd=%d\n",
...@@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
static void stli_onbereset(stlibrd_t *brdp) static void stli_onbereset(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp);
#endif
outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
udelay(10); udelay(10);
outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
...@@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp) ...@@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp)
static void stli_bbyinit(stlibrd_t *brdp) static void stli_bbyinit(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp);
#endif
outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
udelay(10); udelay(10);
outb(0, (brdp->iobase + BBY_ATCONFR)); outb(0, (brdp->iobase + BBY_ATCONFR));
...@@ -3720,21 +3341,10 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3720,21 +3341,10 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
void *ptr; void *ptr;
unsigned char val; unsigned char val;
#ifdef DEBUG BUG_ON(offset > brdp->memsize);
printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
(int) offset);
#endif
if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n",
(int) offset, line, __LINE__, brdp->brdnr);
ptr = NULL;
val = 0;
} else {
ptr = brdp->membase + (offset % BBY_PAGESIZE); ptr = brdp->membase + (offset % BBY_PAGESIZE);
val = (unsigned char) (offset / BBY_PAGESIZE); val = (unsigned char) (offset / BBY_PAGESIZE);
}
outb(val, (brdp->iobase + BBY_ATCONFR)); outb(val, (brdp->iobase + BBY_ATCONFR));
return(ptr); return(ptr);
} }
...@@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) ...@@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
static void stli_bbyreset(stlibrd_t *brdp) static void stli_bbyreset(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp);
#endif
outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
udelay(10); udelay(10);
outb(0, (brdp->iobase + BBY_ATCONFR)); outb(0, (brdp->iobase + BBY_ATCONFR));
...@@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp) ...@@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp)
static void stli_stalinit(stlibrd_t *brdp) static void stli_stalinit(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp);
#endif
outb(0x1, brdp->iobase); outb(0x1, brdp->iobase);
mdelay(1000); mdelay(1000);
} }
...@@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp) ...@@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp)
static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
{ {
void *ptr; BUG_ON(offset > brdp->memsize);
return brdp->membase + (offset % STAL_PAGESIZE);
#ifdef DEBUG
printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
(int) offset);
#endif
if (offset > brdp->memsize) {
printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
"range at line=%d(%d), brd=%d\n",
(int) offset, line, __LINE__, brdp->brdnr);
ptr = NULL;
} else {
ptr = brdp->membase + (offset % STAL_PAGESIZE);
}
return(ptr);
} }
/*****************************************************************************/ /*****************************************************************************/
static void stli_stalreset(stlibrd_t *brdp) static void stli_stalreset(stlibrd_t *brdp)
{ {
volatile unsigned long *vecp; u32 __iomem *vecp;
#ifdef DEBUG
printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp);
#endif
vecp = (volatile unsigned long *) (brdp->membase + 0x30); vecp = (u32 __iomem *) (brdp->membase + 0x30);
*vecp = 0xffff0000; writel(0xffff0000, vecp);
outb(0, brdp->iobase); outb(0, brdp->iobase);
mdelay(1000); mdelay(1000);
} }
...@@ -3819,22 +3401,18 @@ static void stli_stalreset(stlibrd_t *brdp) ...@@ -3819,22 +3401,18 @@ static void stli_stalreset(stlibrd_t *brdp)
static int stli_initecp(stlibrd_t *brdp) static int stli_initecp(stlibrd_t *brdp)
{ {
cdkecpsig_t sig; cdkecpsig_t sig;
cdkecpsig_t *sigsp; cdkecpsig_t __iomem *sigsp;
unsigned int status, nxtid; unsigned int status, nxtid;
char *name; char *name;
int panelnr, nrports; int panelnr, nrports;
#ifdef DEBUG
printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
#endif
if (!request_region(brdp->iobase, brdp->iosize, "istallion")) if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
return -EIO; return -EIO;
if ((brdp->iobase == 0) || (brdp->memaddr == 0)) if ((brdp->iobase == 0) || (brdp->memaddr == 0))
{ {
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-ENODEV); return -ENODEV;
} }
brdp->iosize = ECP_IOSIZE; brdp->iosize = ECP_IOSIZE;
...@@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp) ...@@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp)
default: default:
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-EINVAL); return -EINVAL;
} }
/* /*
...@@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp) ...@@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp)
EBRDINIT(brdp); EBRDINIT(brdp);
brdp->membase = ioremap(brdp->memaddr, brdp->memsize); brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
if (brdp->membase == (void *) NULL) if (brdp->membase == NULL)
{ {
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-ENOMEM); return -ENOMEM;
} }
/* /*
...@@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp) ...@@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp)
* this is, and what it is connected to it. * this is, and what it is connected to it.
*/ */
EBRDENABLE(brdp); EBRDENABLE(brdp);
sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); memcpy(&sig, sigsp, sizeof(cdkecpsig_t));
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
#if 0 if (sig.magic != cpu_to_le32(ECP_MAGIC))
printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
__FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0],
(int) sig.panelid[1], (int) sig.panelid[2],
(int) sig.panelid[3], (int) sig.panelid[4],
(int) sig.panelid[5], (int) sig.panelid[6],
(int) sig.panelid[7]);
#endif
if (sig.magic != ECP_MAGIC)
{ {
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-ENODEV); return -ENODEV;
} }
/* /*
...@@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp) ...@@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp)
brdp->state |= BST_FOUND; brdp->state |= BST_FOUND;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -3980,19 +3549,15 @@ static int stli_initecp(stlibrd_t *brdp) ...@@ -3980,19 +3549,15 @@ static int stli_initecp(stlibrd_t *brdp)
static int stli_initonb(stlibrd_t *brdp) static int stli_initonb(stlibrd_t *brdp)
{ {
cdkonbsig_t sig; cdkonbsig_t sig;
cdkonbsig_t *sigsp; cdkonbsig_t __iomem *sigsp;
char *name; char *name;
int i; int i;
#ifdef DEBUG
printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp);
#endif
/* /*
* Do a basic sanity check on the IO and memory addresses. * Do a basic sanity check on the IO and memory addresses.
*/ */
if ((brdp->iobase == 0) || (brdp->memaddr == 0)) if (brdp->iobase == 0 || brdp->memaddr == 0)
return(-ENODEV); return -ENODEV;
brdp->iosize = ONB_IOSIZE; brdp->iosize = ONB_IOSIZE;
...@@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp)
case BRD_ONBOARD2: case BRD_ONBOARD2:
case BRD_ONBOARD2_32: case BRD_ONBOARD2_32:
case BRD_ONBOARDRS: case BRD_ONBOARDRS:
brdp->membase = (void *) brdp->memaddr;
brdp->memsize = ONB_MEMSIZE; brdp->memsize = ONB_MEMSIZE;
brdp->pagesize = ONB_ATPAGESIZE; brdp->pagesize = ONB_ATPAGESIZE;
brdp->init = stli_onbinit; brdp->init = stli_onbinit;
...@@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp)
break; break;
case BRD_ONBOARDE: case BRD_ONBOARDE:
brdp->membase = (void *) brdp->memaddr;
brdp->memsize = ONB_EIMEMSIZE; brdp->memsize = ONB_EIMEMSIZE;
brdp->pagesize = ONB_EIPAGESIZE; brdp->pagesize = ONB_EIPAGESIZE;
brdp->init = stli_onbeinit; brdp->init = stli_onbeinit;
...@@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp)
case BRD_BRUMBY4: case BRD_BRUMBY4:
case BRD_BRUMBY8: case BRD_BRUMBY8:
case BRD_BRUMBY16: case BRD_BRUMBY16:
brdp->membase = (void *) brdp->memaddr;
brdp->memsize = BBY_MEMSIZE; brdp->memsize = BBY_MEMSIZE;
brdp->pagesize = BBY_PAGESIZE; brdp->pagesize = BBY_PAGESIZE;
brdp->init = stli_bbyinit; brdp->init = stli_bbyinit;
...@@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp)
break; break;
case BRD_STALLION: case BRD_STALLION:
brdp->membase = (void *) brdp->memaddr;
brdp->memsize = STAL_MEMSIZE; brdp->memsize = STAL_MEMSIZE;
brdp->pagesize = STAL_PAGESIZE; brdp->pagesize = STAL_PAGESIZE;
brdp->init = stli_stalinit; brdp->init = stli_stalinit;
...@@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp)
default: default:
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-EINVAL); return -EINVAL;
} }
/* /*
...@@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp)
EBRDINIT(brdp); EBRDINIT(brdp);
brdp->membase = ioremap(brdp->memaddr, brdp->memsize); brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
if (brdp->membase == (void *) NULL) if (brdp->membase == NULL)
{ {
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-ENOMEM); return -ENOMEM;
} }
/* /*
...@@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp)
* this is, and how many ports. * this is, and how many ports.
*/ */
EBRDENABLE(brdp); EBRDENABLE(brdp);
sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t));
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
#if 0 if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
__FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); sig.magic3 != cpu_to_le16(ONB_MAGIC3))
#endif
if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) ||
(sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3))
{ {
release_region(brdp->iobase, brdp->iosize); release_region(brdp->iobase, brdp->iosize);
return(-ENODEV); return -ENODEV;
} }
/* /*
...@@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp)
brdp->state |= BST_FOUND; brdp->state |= BST_FOUND;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp) ...@@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp)
static int stli_startbrd(stlibrd_t *brdp) static int stli_startbrd(stlibrd_t *brdp)
{ {
volatile cdkhdr_t *hdrp; cdkhdr_t __iomem *hdrp;
volatile cdkmem_t *memp; cdkmem_t __iomem *memp;
volatile cdkasy_t *ap; cdkasy_t __iomem *ap;
unsigned long flags; unsigned long flags;
stliport_t *portp; stliport_t *portp;
int portnr, nrdevs, i, rc; int portnr, nrdevs, i, rc = 0;
u32 memoff;
#ifdef DEBUG spin_lock_irqsave(&brd_lock, flags);
printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp);
#endif
rc = 0;
save_flags(flags);
cli();
EBRDENABLE(brdp); EBRDENABLE(brdp);
hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
nrdevs = hdrp->nrdevs; nrdevs = hdrp->nrdevs;
#if 0 #if 0
printk("%s(%d): CDK version %d.%d.%d --> " printk("%s(%d): CDK version %d.%d.%d --> "
"nrdevs=%d memp=%x hostp=%x slavep=%x\n", "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
__FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification),
hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp),
(int) hdrp->slavep); readl(&hdrp->slavep));
#endif #endif
if (nrdevs < (brdp->nrports + 1)) { if (nrdevs < (brdp->nrports + 1)) {
...@@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp) ...@@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp)
brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; brdp->hostoffset = hdrp->hostp - CDK_CDKADDR;
brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR;
brdp->bitsize = (nrdevs + 7) / 8; brdp->bitsize = (nrdevs + 7) / 8;
memp = (volatile cdkmem_t *) hdrp->memp; memoff = readl(&hdrp->memp);
if (((unsigned long) memp) > brdp->memsize) { if (memoff > brdp->memsize) {
printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); printk(KERN_ERR "STALLION: corrupted shared memory region?\n");
rc = -EIO; rc = -EIO;
goto stli_donestartup; goto stli_donestartup;
} }
memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff);
if (memp->dtype != TYP_ASYNCTRL) { if (readw(&memp->dtype) != TYP_ASYNCTRL) {
printk(KERN_ERR "STALLION: no slave control device found\n"); printk(KERN_ERR "STALLION: no slave control device found\n");
goto stli_donestartup; goto stli_donestartup;
} }
...@@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp) ...@@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp)
* change pages while reading memory map. * change pages while reading memory map.
*/ */
for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) {
if (memp->dtype != TYP_ASYNC) if (readw(&memp->dtype) != TYP_ASYNC)
break; break;
portp = brdp->ports[portnr]; portp = brdp->ports[portnr];
if (portp == (stliport_t *) NULL) if (portp == NULL)
break; break;
portp->devnr = i; portp->devnr = i;
portp->addr = memp->offset; portp->addr = readl(&memp->offset);
portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs));
portp->portidx = (unsigned char) (i / 8); portp->portidx = (unsigned char) (i / 8);
portp->portbit = (unsigned char) (0x1 << (i % 8)); portp->portbit = (unsigned char) (0x1 << (i % 8));
} }
hdrp->slavereq = 0xff; writeb(0xff, &hdrp->slavereq);
/* /*
* For each port setup a local copy of the RX and TX buffer offsets * For each port setup a local copy of the RX and TX buffer offsets
...@@ -4221,22 +3772,22 @@ static int stli_startbrd(stlibrd_t *brdp) ...@@ -4221,22 +3772,22 @@ static int stli_startbrd(stlibrd_t *brdp)
*/ */
for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) {
portp = brdp->ports[portnr]; portp = brdp->ports[portnr];
if (portp == (stliport_t *) NULL) if (portp == NULL)
break; break;
if (portp->addr == 0) if (portp->addr == 0)
break; break;
ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
if (ap != (volatile cdkasy_t *) NULL) { if (ap != NULL) {
portp->rxsize = ap->rxq.size; portp->rxsize = readw(&ap->rxq.size);
portp->txsize = ap->txq.size; portp->txsize = readw(&ap->txq.size);
portp->rxoffset = ap->rxq.offset; portp->rxoffset = readl(&ap->rxq.offset);
portp->txoffset = ap->txq.offset; portp->txoffset = readl(&ap->txq.offset);
} }
} }
stli_donestartup: stli_donestartup:
EBRDDISABLE(brdp); EBRDDISABLE(brdp);
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
if (rc == 0) if (rc == 0)
brdp->state |= BST_STARTED; brdp->state |= BST_STARTED;
...@@ -4247,7 +3798,7 @@ static int stli_startbrd(stlibrd_t *brdp) ...@@ -4247,7 +3798,7 @@ static int stli_startbrd(stlibrd_t *brdp)
add_timer(&stli_timerlist); add_timer(&stli_timerlist);
} }
return(rc); return rc;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4258,10 +3809,6 @@ static int stli_startbrd(stlibrd_t *brdp) ...@@ -4258,10 +3809,6 @@ static int stli_startbrd(stlibrd_t *brdp)
static int __init stli_brdinit(stlibrd_t *brdp) static int __init stli_brdinit(stlibrd_t *brdp)
{ {
#ifdef DEBUG
printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp);
#endif
stli_brds[brdp->brdnr] = brdp; stli_brds[brdp->brdnr] = brdp;
switch (brdp->brdtype) { switch (brdp->brdtype) {
...@@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp) ...@@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp)
case BRD_ECHPCI: case BRD_ECHPCI:
printk(KERN_ERR "STALLION: %s board type not supported in " printk(KERN_ERR "STALLION: %s board type not supported in "
"this driver\n", stli_brdnames[brdp->brdtype]); "this driver\n", stli_brdnames[brdp->brdtype]);
return(ENODEV); return -ENODEV;
default: default:
printk(KERN_ERR "STALLION: board=%d is unknown board " printk(KERN_ERR "STALLION: board=%d is unknown board "
"type=%d\n", brdp->brdnr, brdp->brdtype); "type=%d\n", brdp->brdnr, brdp->brdtype);
return(ENODEV); return -ENODEV;
} }
if ((brdp->state & BST_FOUND) == 0) { if ((brdp->state & BST_FOUND) == 0) {
...@@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) ...@@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
"io=%x mem=%x\n", "io=%x mem=%x\n",
stli_brdnames[brdp->brdtype], brdp->brdnr, stli_brdnames[brdp->brdtype], brdp->brdnr,
brdp->iobase, (int) brdp->memaddr); brdp->iobase, (int) brdp->memaddr);
return(ENODEV); return -ENODEV;
} }
stli_initports(brdp); stli_initports(brdp);
...@@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) ...@@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
"nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype],
brdp->brdnr, brdp->iobase, (int) brdp->memaddr, brdp->brdnr, brdp->iobase, (int) brdp->memaddr,
brdp->nrpanels, brdp->nrports); brdp->nrpanels, brdp->nrports);
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp) ...@@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp)
static int stli_eisamemprobe(stlibrd_t *brdp) static int stli_eisamemprobe(stlibrd_t *brdp)
{ {
cdkecpsig_t ecpsig, *ecpsigp; cdkecpsig_t ecpsig, __iomem *ecpsigp;
cdkonbsig_t onbsig, *onbsigp; cdkonbsig_t onbsig, __iomem *onbsigp;
int i, foundit; int i, foundit;
#ifdef DEBUG
printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp);
#endif
/* /*
* First up we reset the board, to get it into a known state. There * First up we reset the board, to get it into a known state. There
* is only 2 board types here we need to worry about. Don;t use the * is only 2 board types here we need to worry about. Don;t use the
...@@ -4352,7 +3895,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp) ...@@ -4352,7 +3895,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
mdelay(1); mdelay(1);
stli_onbeenable(brdp); stli_onbeenable(brdp);
} else { } else {
return(-ENODEV); return -ENODEV;
} }
foundit = 0; foundit = 0;
...@@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp) ...@@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
*/ */
for (i = 0; (i < stli_eisamempsize); i++) { for (i = 0; (i < stli_eisamempsize); i++) {
brdp->memaddr = stli_eisamemprobeaddrs[i]; brdp->memaddr = stli_eisamemprobeaddrs[i];
brdp->membase = (void *) brdp->memaddr;
brdp->membase = ioremap(brdp->memaddr, brdp->memsize); brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
if (brdp->membase == (void *) NULL) if (brdp->membase == NULL)
continue; continue;
if (brdp->brdtype == BRD_ECPE) { if (brdp->brdtype == BRD_ECPE) {
ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp,
CDK_SIGADDR, __LINE__); CDK_SIGADDR, __LINE__);
memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t));
if (ecpsig.magic == ECP_MAGIC) if (ecpsig.magic == cpu_to_le32(ECP_MAGIC))
foundit = 1; foundit = 1;
} else { } else {
onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp,
CDK_SIGADDR, __LINE__); CDK_SIGADDR, __LINE__);
memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t));
if ((onbsig.magic0 == ONB_MAGIC0) && if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) &&
(onbsig.magic1 == ONB_MAGIC1) && (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) &&
(onbsig.magic2 == ONB_MAGIC2) && (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) &&
(onbsig.magic3 == ONB_MAGIC3)) (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3)))
foundit = 1; foundit = 1;
} }
...@@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp) ...@@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
printk(KERN_ERR "STALLION: failed to probe shared memory " printk(KERN_ERR "STALLION: failed to probe shared memory "
"region for %s in EISA slot=%d\n", "region for %s in EISA slot=%d\n",
stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); stli_brdnames[brdp->brdtype], (brdp->iobase >> 12));
return(-ENODEV); return -ENODEV;
} }
return(0); return 0;
} }
static int stli_getbrdnr(void) static int stli_getbrdnr(void)
...@@ -4443,18 +3985,12 @@ static int stli_findeisabrds(void) ...@@ -4443,18 +3985,12 @@ static int stli_findeisabrds(void)
unsigned int iobase, eid; unsigned int iobase, eid;
int i; int i;
#ifdef DEBUG
printk(KERN_DEBUG "stli_findeisabrds()\n");
#endif
/* /*
* Firstly check if this is an EISA system. Do this by probing for * Firstly check if this is an EISA system. If this is not an EISA system then
* the system board EISA ID. If this is not an EISA system then
* don't bother going any further! * don't bother going any further!
*/ */
outb(0xff, 0xc80); if (EISA_bus)
if (inb(0xc80) == 0xff) return 0;
return(0);
/* /*
* Looks like an EISA system, so go searching for EISA boards. * Looks like an EISA system, so go searching for EISA boards.
...@@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void) ...@@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void)
*/ */
for (i = 0; (i < STL_MAXBRDS); i++) { for (i = 0; (i < STL_MAXBRDS); i++) {
brdp = stli_brds[i]; brdp = stli_brds[i];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
continue; continue;
if (brdp->iobase == iobase) if (brdp->iobase == iobase)
break; break;
...@@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void) ...@@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void)
* We have found a Stallion board and it is not configured already. * We have found a Stallion board and it is not configured already.
* Allocate a board structure and initialize it. * Allocate a board structure and initialize it.
*/ */
if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) if ((brdp = stli_allocbrd()) == NULL)
return(-ENOMEM); return -ENOMEM;
if ((brdp->brdnr = stli_getbrdnr()) < 0) if ((brdp->brdnr = stli_getbrdnr()) < 0)
return(-ENOMEM); return -ENOMEM;
eid = inb(iobase + 0xc82); eid = inb(iobase + 0xc82);
if (eid == ECP_EISAID) if (eid == ECP_EISAID)
brdp->brdtype = BRD_ECPE; brdp->brdtype = BRD_ECPE;
...@@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void) ...@@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void)
stli_brdinit(brdp); stli_brdinit(brdp);
} }
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4525,30 +4061,16 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp) ...@@ -4525,30 +4061,16 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
{ {
stlibrd_t *brdp; stlibrd_t *brdp;
#ifdef DEBUG
printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n",
brdtype, dev->bus->number, dev->devfn);
#endif
if (pci_enable_device(devp)) if (pci_enable_device(devp))
return(-EIO); return -EIO;
if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) if ((brdp = stli_allocbrd()) == NULL)
return(-ENOMEM); return -ENOMEM;
if ((brdp->brdnr = stli_getbrdnr()) < 0) { if ((brdp->brdnr = stli_getbrdnr()) < 0) {
printk(KERN_INFO "STALLION: too many boards found, " printk(KERN_INFO "STALLION: too many boards found, "
"maximum supported %d\n", STL_MAXBRDS); "maximum supported %d\n", STL_MAXBRDS);
return(0); return 0;
} }
brdp->brdtype = brdtype; brdp->brdtype = brdtype;
#ifdef DEBUG
printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__,
pci_resource_start(devp, 0),
pci_resource_start(devp, 1),
pci_resource_start(devp, 2),
pci_resource_start(devp, 3));
#endif
/* /*
* We have all resources from the board, so lets setup the actual * We have all resources from the board, so lets setup the actual
* board structure now. * board structure now.
...@@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp) ...@@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
brdp->memaddr = pci_resource_start(devp, 2); brdp->memaddr = pci_resource_start(devp, 2);
stli_brdinit(brdp); stli_brdinit(brdp);
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4570,19 +4092,11 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp) ...@@ -4570,19 +4092,11 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
static int stli_findpcibrds(void) static int stli_findpcibrds(void)
{ {
struct pci_dev *dev = NULL; struct pci_dev *dev = NULL;
int rc;
#ifdef DEBUG
printk("stli_findpcibrds()\n");
#endif
while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
PCI_DEVICE_ID_ECRA, dev))) { stli_initpcibrd(BRD_ECPPCI, dev);
if ((rc = stli_initpcibrd(BRD_ECPPCI, dev)))
return(rc);
} }
return 0;
return(0);
} }
#endif #endif
...@@ -4600,12 +4114,11 @@ static stlibrd_t *stli_allocbrd(void) ...@@ -4600,12 +4114,11 @@ static stlibrd_t *stli_allocbrd(void)
brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
if (!brdp) { if (!brdp) {
printk(KERN_ERR "STALLION: failed to allocate memory " printk(KERN_ERR "STALLION: failed to allocate memory "
"(size=%d)\n", sizeof(stlibrd_t)); "(size=%Zd)\n", sizeof(stlibrd_t));
return NULL; return NULL;
} }
brdp->magic = STLI_BOARDMAGIC; brdp->magic = STLI_BOARDMAGIC;
return(brdp); return brdp;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4621,10 +4134,6 @@ static int stli_initbrds(void) ...@@ -4621,10 +4134,6 @@ static int stli_initbrds(void)
stlconf_t *confp; stlconf_t *confp;
int i, j; int i, j;
#ifdef DEBUG
printk(KERN_DEBUG "stli_initbrds()\n");
#endif
if (stli_nrbrds > STL_MAXBRDS) { if (stli_nrbrds > STL_MAXBRDS) {
printk(KERN_INFO "STALLION: too many boards in configuration " printk(KERN_INFO "STALLION: too many boards in configuration "
"table, truncating to %d\n", STL_MAXBRDS); "table, truncating to %d\n", STL_MAXBRDS);
...@@ -4638,11 +4147,9 @@ static int stli_initbrds(void) ...@@ -4638,11 +4147,9 @@ static int stli_initbrds(void)
*/ */
for (i = 0; (i < stli_nrbrds); i++) { for (i = 0; (i < stli_nrbrds); i++) {
confp = &stli_brdconf[i]; confp = &stli_brdconf[i];
#ifdef MODULE
stli_parsebrd(confp, stli_brdsp[i]); stli_parsebrd(confp, stli_brdsp[i]);
#endif if ((brdp = stli_allocbrd()) == NULL)
if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) return -ENOMEM;
return(-ENOMEM);
brdp->brdnr = i; brdp->brdnr = i;
brdp->brdtype = confp->brdtype; brdp->brdtype = confp->brdtype;
brdp->iobase = confp->ioaddr1; brdp->iobase = confp->ioaddr1;
...@@ -4654,9 +4161,7 @@ static int stli_initbrds(void) ...@@ -4654,9 +4161,7 @@ static int stli_initbrds(void)
* Static configuration table done, so now use dynamic methods to * Static configuration table done, so now use dynamic methods to
* see if any more boards should be configured. * see if any more boards should be configured.
*/ */
#ifdef MODULE
stli_argbrds(); stli_argbrds();
#endif
if (STLI_EISAPROBE) if (STLI_EISAPROBE)
stli_findeisabrds(); stli_findeisabrds();
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
...@@ -4672,11 +4177,11 @@ static int stli_initbrds(void) ...@@ -4672,11 +4177,11 @@ static int stli_initbrds(void)
if (stli_nrbrds > 1) { if (stli_nrbrds > 1) {
for (i = 0; (i < stli_nrbrds); i++) { for (i = 0; (i < stli_nrbrds); i++) {
brdp = stli_brds[i]; brdp = stli_brds[i];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
continue; continue;
for (j = i + 1; (j < stli_nrbrds); j++) { for (j = i + 1; (j < stli_nrbrds); j++) {
nxtbrdp = stli_brds[j]; nxtbrdp = stli_brds[j];
if (nxtbrdp == (stlibrd_t *) NULL) if (nxtbrdp == NULL)
continue; continue;
if ((brdp->membase >= nxtbrdp->membase) && if ((brdp->membase >= nxtbrdp->membase) &&
(brdp->membase <= (nxtbrdp->membase + (brdp->membase <= (nxtbrdp->membase +
...@@ -4691,7 +4196,7 @@ static int stli_initbrds(void) ...@@ -4691,7 +4196,7 @@ static int stli_initbrds(void)
if (stli_shared == 0) { if (stli_shared == 0) {
for (i = 0; (i < stli_nrbrds); i++) { for (i = 0; (i < stli_nrbrds); i++) {
brdp = stli_brds[i]; brdp = stli_brds[i];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
continue; continue;
if (brdp->state & BST_FOUND) { if (brdp->state & BST_FOUND) {
EBRDENABLE(brdp); EBRDENABLE(brdp);
...@@ -4701,7 +4206,7 @@ static int stli_initbrds(void) ...@@ -4701,7 +4206,7 @@ static int stli_initbrds(void)
} }
} }
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4718,44 +4223,51 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof ...@@ -4718,44 +4223,51 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof
void *memptr; void *memptr;
stlibrd_t *brdp; stlibrd_t *brdp;
int brdnr, size, n; int brdnr, size, n;
void *p;
#ifdef DEBUG loff_t off = *offp;
printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
(int) fp, (int) buf, count, (int) offp);
#endif
brdnr = iminor(fp->f_dentry->d_inode); brdnr = iminor(fp->f_dentry->d_inode);
if (brdnr >= stli_nrbrds) if (brdnr >= stli_nrbrds)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
if (brdp->state == 0) if (brdp->state == 0)
return(-ENODEV); return -ENODEV;
if (fp->f_pos >= brdp->memsize) if (off >= brdp->memsize || off + count < off)
return(0); return 0;
size = MIN(count, (brdp->memsize - fp->f_pos)); size = MIN(count, (brdp->memsize - off));
/*
* Copy the data a page at a time
*/
p = (void *)__get_free_page(GFP_KERNEL);
if(p == NULL)
return -ENOMEM;
save_flags(flags);
cli();
EBRDENABLE(brdp);
while (size > 0) { while (size > 0) {
memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); spin_lock_irqsave(&brd_lock, flags);
n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); EBRDENABLE(brdp);
if (copy_to_user(buf, memptr, n)) { memptr = (void *) EBRDGETMEMPTR(brdp, off);
n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
n = MIN(n, PAGE_SIZE);
memcpy_fromio(p, memptr, n);
EBRDDISABLE(brdp);
spin_unlock_irqrestore(&brd_lock, flags);
if (copy_to_user(buf, p, n)) {
count = -EFAULT; count = -EFAULT;
goto out; goto out;
} }
fp->f_pos += n; off += n;
buf += n; buf += n;
size -= n; size -= n;
} }
out: out:
EBRDDISABLE(brdp); *offp = off;
restore_flags(flags); free_page((unsigned long)p);
return count;
return(count);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4764,6 +4276,8 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof ...@@ -4764,6 +4276,8 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof
* Code to handle an "staliomem" write operation. This device is the * Code to handle an "staliomem" write operation. This device is the
* contents of the board shared memory. It is used for down loading * contents of the board shared memory. It is used for down loading
* the slave image (and debugging :-) * the slave image (and debugging :-)
*
* FIXME: copy under lock
*/ */
static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp)
...@@ -4773,45 +4287,54 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou ...@@ -4773,45 +4287,54 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou
stlibrd_t *brdp; stlibrd_t *brdp;
char __user *chbuf; char __user *chbuf;
int brdnr, size, n; int brdnr, size, n;
void *p;
#ifdef DEBUG loff_t off = *offp;
printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
(int) fp, (int) buf, count, (int) offp);
#endif
brdnr = iminor(fp->f_dentry->d_inode); brdnr = iminor(fp->f_dentry->d_inode);
if (brdnr >= stli_nrbrds) if (brdnr >= stli_nrbrds)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
if (brdp->state == 0) if (brdp->state == 0)
return(-ENODEV); return -ENODEV;
if (fp->f_pos >= brdp->memsize) if (off >= brdp->memsize || off + count < off)
return(0); return 0;
chbuf = (char __user *) buf; chbuf = (char __user *) buf;
size = MIN(count, (brdp->memsize - fp->f_pos)); size = MIN(count, (brdp->memsize - off));
/*
* Copy the data a page at a time
*/
p = (void *)__get_free_page(GFP_KERNEL);
if(p == NULL)
return -ENOMEM;
save_flags(flags);
cli();
EBRDENABLE(brdp);
while (size > 0) { while (size > 0) {
memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); n = MIN(n, PAGE_SIZE);
if (copy_from_user(memptr, chbuf, n)) { if (copy_from_user(p, chbuf, n)) {
if (count == 0)
count = -EFAULT; count = -EFAULT;
goto out; goto out;
} }
fp->f_pos += n; spin_lock_irqsave(&brd_lock, flags);
EBRDENABLE(brdp);
memptr = (void *) EBRDGETMEMPTR(brdp, off);
memcpy_toio(memptr, p, n);
EBRDDISABLE(brdp);
spin_unlock_irqrestore(&brd_lock, flags);
off += n;
chbuf += n; chbuf += n;
size -= n; size -= n;
} }
out: out:
EBRDDISABLE(brdp); free_page((unsigned long) p);
restore_flags(flags); *offp = off;
return count;
return(count);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4828,10 +4351,10 @@ static int stli_getbrdstats(combrd_t __user *bp) ...@@ -4828,10 +4351,10 @@ static int stli_getbrdstats(combrd_t __user *bp)
if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
return -EFAULT; return -EFAULT;
if (stli_brdstats.brd >= STL_MAXBRDS) if (stli_brdstats.brd >= STL_MAXBRDS)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[stli_brdstats.brd]; brdp = stli_brds[stli_brdstats.brd];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
memset(&stli_brdstats, 0, sizeof(combrd_t)); memset(&stli_brdstats, 0, sizeof(combrd_t));
stli_brdstats.brd = brdp->brdnr; stli_brdstats.brd = brdp->brdnr;
...@@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp) ...@@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t)))
return -EFAULT; return -EFAULT;
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4864,16 +4387,16 @@ static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) ...@@ -4864,16 +4387,16 @@ static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
stlibrd_t *brdp; stlibrd_t *brdp;
int i; int i;
if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) if (brdnr < 0 || brdnr >= STL_MAXBRDS)
return((stliport_t *) NULL); return NULL;
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return((stliport_t *) NULL); return NULL;
for (i = 0; (i < panelnr); i++) for (i = 0; (i < panelnr); i++)
portnr += brdp->panels[i]; portnr += brdp->panels[i];
if ((portnr < 0) || (portnr >= brdp->nrports)) if ((portnr < 0) || (portnr >= brdp->nrports))
return((stliport_t *) NULL); return NULL;
return(brdp->ports[portnr]); return brdp->ports[portnr];
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp) ...@@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp)
memset(&stli_comstats, 0, sizeof(comstats_t)); memset(&stli_comstats, 0, sizeof(comstats_t));
if (portp == (stliport_t *) NULL) if (portp == NULL)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[portp->brdnr]; brdp = stli_brds[portp->brdnr];
if (brdp == (stlibrd_t *) NULL) if (brdp == NULL)
return(-ENODEV); return -ENODEV;
if (brdp->state & BST_STARTED) { if (brdp->state & BST_STARTED) {
if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
&stli_cdkstats, sizeof(asystats_t), 1)) < 0) &stli_cdkstats, sizeof(asystats_t), 1)) < 0)
return(rc); return rc;
} else { } else {
memset(&stli_cdkstats, 0, sizeof(asystats_t)); memset(&stli_cdkstats, 0, sizeof(asystats_t));
} }
...@@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp) ...@@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp)
stli_comstats.state = portp->state; stli_comstats.state = portp->state;
stli_comstats.flags = portp->flags; stli_comstats.flags = portp->flags;
save_flags(flags); spin_lock_irqsave(&brd_lock, flags);
cli(); if (portp->tty != NULL) {
if (portp->tty != (struct tty_struct *) NULL) {
if (portp->tty->driver_data == portp) { if (portp->tty->driver_data == portp) {
stli_comstats.ttystate = portp->tty->flags; stli_comstats.ttystate = portp->tty->flags;
stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; stli_comstats.rxbuffered = -1;
if (portp->tty->termios != (struct termios *) NULL) { if (portp->tty->termios != NULL) {
stli_comstats.cflags = portp->tty->termios->c_cflag; stli_comstats.cflags = portp->tty->termios->c_cflag;
stli_comstats.iflags = portp->tty->termios->c_iflag; stli_comstats.iflags = portp->tty->termios->c_iflag;
stli_comstats.oflags = portp->tty->termios->c_oflag; stli_comstats.oflags = portp->tty->termios->c_oflag;
...@@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp) ...@@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp)
} }
} }
} }
restore_flags(flags); spin_unlock_irqrestore(&brd_lock, flags);
stli_comstats.txtotal = stli_cdkstats.txchars; stli_comstats.txtotal = stli_cdkstats.txchars;
stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;
...@@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp) ...@@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp)
stli_comstats.hwid = stli_cdkstats.hwid; stli_comstats.hwid = stli_cdkstats.hwid;
stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals);
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -5080,11 +4602,6 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un ...@@ -5080,11 +4602,6 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
int brdnr, rc, done; int brdnr, rc, done;
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
#ifdef DEBUG
printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n",
(int) ip, (int) fp, cmd, (int) arg);
#endif
/* /*
* First up handle the board independent ioctls. * First up handle the board independent ioctls.
*/ */
...@@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un ...@@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
} }
if (done) if (done)
return(rc); return rc;
/* /*
* Now handle the board specific ioctls. These all depend on the * Now handle the board specific ioctls. These all depend on the
...@@ -5123,12 +4640,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un ...@@ -5123,12 +4640,12 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
*/ */
brdnr = iminor(ip); brdnr = iminor(ip);
if (brdnr >= STL_MAXBRDS) if (brdnr >= STL_MAXBRDS)
return(-ENODEV); return -ENODEV;
brdp = stli_brds[brdnr]; brdp = stli_brds[brdnr];
if (!brdp) if (!brdp)
return(-ENODEV); return -ENODEV;
if (brdp->state == 0) if (brdp->state == 0)
return(-ENODEV); return -ENODEV;
switch (cmd) { switch (cmd) {
case STL_BINTR: case STL_BINTR:
...@@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un ...@@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
rc = -ENOIOCTLCMD; rc = -ENOIOCTLCMD;
break; break;
} }
return rc;
return(rc);
} }
static struct tty_operations stli_ops = { static struct tty_operations stli_ops = {
...@@ -5187,6 +4703,9 @@ int __init stli_init(void) ...@@ -5187,6 +4703,9 @@ int __init stli_init(void)
int i; int i;
printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
spin_lock_init(&stli_lock);
spin_lock_init(&brd_lock);
stli_initbrds(); stli_initbrds();
stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
...@@ -5196,10 +4715,6 @@ int __init stli_init(void) ...@@ -5196,10 +4715,6 @@ int __init stli_init(void)
/* /*
* Allocate a temporary write buffer. * Allocate a temporary write buffer.
*/ */
stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
if (!stli_tmpwritebuf)
printk(KERN_ERR "STALLION: failed to allocate memory "
"(size=%d)\n", STLI_TXBUFSIZE);
stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
if (!stli_txcookbuf) if (!stli_txcookbuf)
printk(KERN_ERR "STALLION: failed to allocate memory " printk(KERN_ERR "STALLION: failed to allocate memory "
...@@ -5243,7 +4758,7 @@ int __init stli_init(void) ...@@ -5243,7 +4758,7 @@ int __init stli_init(void)
printk(KERN_ERR "STALLION: failed to register serial driver\n"); printk(KERN_ERR "STALLION: failed to register serial driver\n");
return -EBUSY; return -EBUSY;
} }
return(0); return 0;
} }
/*****************************************************************************/ /*****************************************************************************/
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