aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/istallion.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2006-06-28 07:26:52 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-28 17:59:05 -0400
commit4ac4360b95496f4137ee19b54e9f7dfa3946984d (patch)
treeb32ea69a8d92ee93d90b3accf4713466d113a26d /drivers/char/istallion.c
parenteffc8b704b48c3c727715abf49592a57547b6818 (diff)
[PATCH] istallion: cleanups
Turned out to be rather a monster Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/char/istallion.c')
-rw-r--r--drivers/char/istallion.c1819
1 files changed, 667 insertions, 1152 deletions
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ef20c1fc9c4c..216c79256de3 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -42,13 +42,12 @@
42#include <linux/devfs_fs_kernel.h> 42#include <linux/devfs_fs_kernel.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/wait.h> 44#include <linux/wait.h>
45#include <linux/eisa.h>
45 46
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
49#ifdef CONFIG_PCI
50#include <linux/pci.h> 50#include <linux/pci.h>
51#endif
52 51
53/*****************************************************************************/ 52/*****************************************************************************/
54 53
@@ -137,6 +136,10 @@ static stlconf_t stli_brdconf[] = {
137 136
138static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); 137static int stli_nrbrds = ARRAY_SIZE(stli_brdconf);
139 138
139/* stli_lock must NOT be taken holding brd_lock */
140static spinlock_t stli_lock; /* TTY logic lock */
141static spinlock_t brd_lock; /* Board logic lock */
142
140/* 143/*
141 * There is some experimental EISA board detection code in this driver. 144 * There is some experimental EISA board detection code in this driver.
142 * By default it is disabled, but for those that want to try it out, 145 * By default it is disabled, but for those that want to try it out,
@@ -173,14 +176,6 @@ static char *stli_serialname = "ttyE";
173 176
174static struct tty_driver *stli_serial; 177static struct tty_driver *stli_serial;
175 178
176/*
177 * We will need to allocate a temporary write buffer for chars that
178 * come direct from user space. The problem is that a copy from user
179 * space might cause a page fault (typically on a system that is
180 * swapping!). All ports will share one buffer - since if the system
181 * is already swapping a shared buffer won't make things any worse.
182 */
183static char *stli_tmpwritebuf;
184 179
185#define STLI_TXBUFSIZE 4096 180#define STLI_TXBUFSIZE 4096
186 181
@@ -419,7 +414,7 @@ static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs);
419#endif 414#endif
420 415
421static struct pci_device_id istallion_pci_tbl[] = { 416static struct pci_device_id istallion_pci_tbl[] = {
422 { PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 417 { PCI_DEVICE(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA), },
423 { 0 } 418 { 0 }
424}; 419};
425MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); 420MODULE_DEVICE_TABLE(pci, istallion_pci_tbl);
@@ -682,7 +677,7 @@ static int stli_startbrd(stlibrd_t *brdp);
682static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); 677static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp);
683static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); 678static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp);
684static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); 679static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg);
685static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp); 680static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp);
686static void stli_poll(unsigned long arg); 681static void stli_poll(unsigned long arg);
687static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); 682static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp);
688static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); 683static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
@@ -693,7 +688,8 @@ static void stli_dohangup(void *arg);
693static int stli_setport(stliport_t *portp); 688static int stli_setport(stliport_t *portp);
694static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 689static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
695static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 690static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
696static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp); 691static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
692static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp);
697static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); 693static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp);
698static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); 694static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
699static long stli_mktiocm(unsigned long sigvalue); 695static long stli_mktiocm(unsigned long sigvalue);
@@ -799,18 +795,8 @@ static struct class *istallion_class;
799 795
800static int __init istallion_module_init(void) 796static int __init istallion_module_init(void)
801{ 797{
802 unsigned long flags;
803
804#ifdef DEBUG
805 printk("init_module()\n");
806#endif
807
808 save_flags(flags);
809 cli();
810 stli_init(); 798 stli_init();
811 restore_flags(flags); 799 return 0;
812
813 return(0);
814} 800}
815 801
816/*****************************************************************************/ 802/*****************************************************************************/
@@ -819,33 +805,24 @@ static void __exit istallion_module_exit(void)
819{ 805{
820 stlibrd_t *brdp; 806 stlibrd_t *brdp;
821 stliport_t *portp; 807 stliport_t *portp;
822 unsigned long flags;
823 int i, j; 808 int i, j;
824 809
825#ifdef DEBUG
826 printk("cleanup_module()\n");
827#endif
828
829 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, 810 printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle,
830 stli_drvversion); 811 stli_drvversion);
831 812
832 save_flags(flags); 813 /*
833 cli(); 814 * Free up all allocated resources used by the ports. This includes
834 815 * memory and interrupts.
835/* 816 */
836 * Free up all allocated resources used by the ports. This includes
837 * memory and interrupts.
838 */
839 if (stli_timeron) { 817 if (stli_timeron) {
840 stli_timeron = 0; 818 stli_timeron = 0;
841 del_timer(&stli_timerlist); 819 del_timer_sync(&stli_timerlist);
842 } 820 }
843 821
844 i = tty_unregister_driver(stli_serial); 822 i = tty_unregister_driver(stli_serial);
845 if (i) { 823 if (i) {
846 printk("STALLION: failed to un-register tty driver, " 824 printk("STALLION: failed to un-register tty driver, "
847 "errno=%d\n", -i); 825 "errno=%d\n", -i);
848 restore_flags(flags);
849 return; 826 return;
850 } 827 }
851 put_tty_driver(stli_serial); 828 put_tty_driver(stli_serial);
@@ -859,16 +836,15 @@ static void __exit istallion_module_exit(void)
859 printk("STALLION: failed to un-register serial memory device, " 836 printk("STALLION: failed to un-register serial memory device, "
860 "errno=%d\n", -i); 837 "errno=%d\n", -i);
861 838
862 kfree(stli_tmpwritebuf);
863 kfree(stli_txcookbuf); 839 kfree(stli_txcookbuf);
864 840
865 for (i = 0; (i < stli_nrbrds); i++) { 841 for (i = 0; (i < stli_nrbrds); i++) {
866 if ((brdp = stli_brds[i]) == (stlibrd_t *) NULL) 842 if ((brdp = stli_brds[i]) == NULL)
867 continue; 843 continue;
868 for (j = 0; (j < STL_MAXPORTS); j++) { 844 for (j = 0; (j < STL_MAXPORTS); j++) {
869 portp = brdp->ports[j]; 845 portp = brdp->ports[j];
870 if (portp != (stliport_t *) NULL) { 846 if (portp != NULL) {
871 if (portp->tty != (struct tty_struct *) NULL) 847 if (portp->tty != NULL)
872 tty_hangup(portp->tty); 848 tty_hangup(portp->tty);
873 kfree(portp); 849 kfree(portp);
874 } 850 }
@@ -878,10 +854,8 @@ static void __exit istallion_module_exit(void)
878 if (brdp->iosize > 0) 854 if (brdp->iosize > 0)
879 release_region(brdp->iobase, brdp->iosize); 855 release_region(brdp->iobase, brdp->iosize);
880 kfree(brdp); 856 kfree(brdp);
881 stli_brds[i] = (stlibrd_t *) NULL; 857 stli_brds[i] = NULL;
882 } 858 }
883
884 restore_flags(flags);
885} 859}
886 860
887module_init(istallion_module_init); 861module_init(istallion_module_init);
@@ -895,19 +869,15 @@ module_exit(istallion_module_exit);
895 869
896static void stli_argbrds(void) 870static void stli_argbrds(void)
897{ 871{
898 stlconf_t conf; 872 stlconf_t conf;
899 stlibrd_t *brdp; 873 stlibrd_t *brdp;
900 int i; 874 int i;
901
902#ifdef DEBUG
903 printk("stli_argbrds()\n");
904#endif
905 875
906 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { 876 for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) {
907 memset(&conf, 0, sizeof(conf)); 877 memset(&conf, 0, sizeof(conf));
908 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) 878 if (stli_parsebrd(&conf, stli_brdsp[i]) == 0)
909 continue; 879 continue;
910 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 880 if ((brdp = stli_allocbrd()) == NULL)
911 continue; 881 continue;
912 stli_nrbrds = i + 1; 882 stli_nrbrds = i + 1;
913 brdp->brdnr = i; 883 brdp->brdnr = i;
@@ -926,9 +896,9 @@ static void stli_argbrds(void)
926 896
927static unsigned long stli_atol(char *str) 897static unsigned long stli_atol(char *str)
928{ 898{
929 unsigned long val; 899 unsigned long val;
930 int base, c; 900 int base, c;
931 char *sp; 901 char *sp;
932 902
933 val = 0; 903 val = 0;
934 sp = str; 904 sp = str;
@@ -962,15 +932,11 @@ static unsigned long stli_atol(char *str)
962 932
963static int stli_parsebrd(stlconf_t *confp, char **argp) 933static int stli_parsebrd(stlconf_t *confp, char **argp)
964{ 934{
965 char *sp; 935 char *sp;
966 int i; 936 int i;
967
968#ifdef DEBUG
969 printk("stli_parsebrd(confp=%x,argp=%x)\n", (int) confp, (int) argp);
970#endif
971 937
972 if ((argp[0] == (char *) NULL) || (*argp[0] == 0)) 938 if (argp[0] == NULL || *argp[0] == 0)
973 return(0); 939 return 0;
974 940
975 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) 941 for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++)
976 *sp = TOLOWER(*sp); 942 *sp = TOLOWER(*sp);
@@ -985,9 +951,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
985 } 951 }
986 952
987 confp->brdtype = stli_brdstr[i].type; 953 confp->brdtype = stli_brdstr[i].type;
988 if ((argp[1] != (char *) NULL) && (*argp[1] != 0)) 954 if (argp[1] != NULL && *argp[1] != 0)
989 confp->ioaddr1 = stli_atol(argp[1]); 955 confp->ioaddr1 = stli_atol(argp[1]);
990 if ((argp[2] != (char *) NULL) && (*argp[2] != 0)) 956 if (argp[2] != NULL && *argp[2] != 0)
991 confp->memaddr = stli_atol(argp[2]); 957 confp->memaddr = stli_atol(argp[2]);
992 return(1); 958 return(1);
993} 959}
@@ -998,34 +964,29 @@ static int stli_parsebrd(stlconf_t *confp, char **argp)
998 964
999static int stli_open(struct tty_struct *tty, struct file *filp) 965static int stli_open(struct tty_struct *tty, struct file *filp)
1000{ 966{
1001 stlibrd_t *brdp; 967 stlibrd_t *brdp;
1002 stliport_t *portp; 968 stliport_t *portp;
1003 unsigned int minordev; 969 unsigned int minordev;
1004 int brdnr, portnr, rc; 970 int brdnr, portnr, rc;
1005
1006#ifdef DEBUG
1007 printk("stli_open(tty=%x,filp=%x): device=%s\n", (int) tty,
1008 (int) filp, tty->name);
1009#endif
1010 971
1011 minordev = tty->index; 972 minordev = tty->index;
1012 brdnr = MINOR2BRD(minordev); 973 brdnr = MINOR2BRD(minordev);
1013 if (brdnr >= stli_nrbrds) 974 if (brdnr >= stli_nrbrds)
1014 return(-ENODEV); 975 return -ENODEV;
1015 brdp = stli_brds[brdnr]; 976 brdp = stli_brds[brdnr];
1016 if (brdp == (stlibrd_t *) NULL) 977 if (brdp == NULL)
1017 return(-ENODEV); 978 return -ENODEV;
1018 if ((brdp->state & BST_STARTED) == 0) 979 if ((brdp->state & BST_STARTED) == 0)
1019 return(-ENODEV); 980 return -ENODEV;
1020 portnr = MINOR2PORT(minordev); 981 portnr = MINOR2PORT(minordev);
1021 if ((portnr < 0) || (portnr > brdp->nrports)) 982 if ((portnr < 0) || (portnr > brdp->nrports))
1022 return(-ENODEV); 983 return -ENODEV;
1023 984
1024 portp = brdp->ports[portnr]; 985 portp = brdp->ports[portnr];
1025 if (portp == (stliport_t *) NULL) 986 if (portp == NULL)
1026 return(-ENODEV); 987 return -ENODEV;
1027 if (portp->devnr < 1) 988 if (portp->devnr < 1)
1028 return(-ENODEV); 989 return -ENODEV;
1029 990
1030 991
1031/* 992/*
@@ -1037,8 +998,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1037 if (portp->flags & ASYNC_CLOSING) { 998 if (portp->flags & ASYNC_CLOSING) {
1038 interruptible_sleep_on(&portp->close_wait); 999 interruptible_sleep_on(&portp->close_wait);
1039 if (portp->flags & ASYNC_HUP_NOTIFY) 1000 if (portp->flags & ASYNC_HUP_NOTIFY)
1040 return(-EAGAIN); 1001 return -EAGAIN;
1041 return(-ERESTARTSYS); 1002 return -ERESTARTSYS;
1042 } 1003 }
1043 1004
1044/* 1005/*
@@ -1054,7 +1015,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1054 wait_event_interruptible(portp->raw_wait, 1015 wait_event_interruptible(portp->raw_wait,
1055 !test_bit(ST_INITIALIZING, &portp->state)); 1016 !test_bit(ST_INITIALIZING, &portp->state));
1056 if (signal_pending(current)) 1017 if (signal_pending(current))
1057 return(-ERESTARTSYS); 1018 return -ERESTARTSYS;
1058 1019
1059 if ((portp->flags & ASYNC_INITIALIZED) == 0) { 1020 if ((portp->flags & ASYNC_INITIALIZED) == 0) {
1060 set_bit(ST_INITIALIZING, &portp->state); 1021 set_bit(ST_INITIALIZING, &portp->state);
@@ -1065,7 +1026,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1065 clear_bit(ST_INITIALIZING, &portp->state); 1026 clear_bit(ST_INITIALIZING, &portp->state);
1066 wake_up_interruptible(&portp->raw_wait); 1027 wake_up_interruptible(&portp->raw_wait);
1067 if (rc < 0) 1028 if (rc < 0)
1068 return(rc); 1029 return rc;
1069 } 1030 }
1070 1031
1071/* 1032/*
@@ -1077,8 +1038,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1077 if (portp->flags & ASYNC_CLOSING) { 1038 if (portp->flags & ASYNC_CLOSING) {
1078 interruptible_sleep_on(&portp->close_wait); 1039 interruptible_sleep_on(&portp->close_wait);
1079 if (portp->flags & ASYNC_HUP_NOTIFY) 1040 if (portp->flags & ASYNC_HUP_NOTIFY)
1080 return(-EAGAIN); 1041 return -EAGAIN;
1081 return(-ERESTARTSYS); 1042 return -ERESTARTSYS;
1082 } 1043 }
1083 1044
1084/* 1045/*
@@ -1088,38 +1049,33 @@ static int stli_open(struct tty_struct *tty, struct file *filp)
1088 */ 1049 */
1089 if (!(filp->f_flags & O_NONBLOCK)) { 1050 if (!(filp->f_flags & O_NONBLOCK)) {
1090 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0) 1051 if ((rc = stli_waitcarrier(brdp, portp, filp)) != 0)
1091 return(rc); 1052 return rc;
1092 } 1053 }
1093 portp->flags |= ASYNC_NORMAL_ACTIVE; 1054 portp->flags |= ASYNC_NORMAL_ACTIVE;
1094 return(0); 1055 return 0;
1095} 1056}
1096 1057
1097/*****************************************************************************/ 1058/*****************************************************************************/
1098 1059
1099static void stli_close(struct tty_struct *tty, struct file *filp) 1060static void stli_close(struct tty_struct *tty, struct file *filp)
1100{ 1061{
1101 stlibrd_t *brdp; 1062 stlibrd_t *brdp;
1102 stliport_t *portp; 1063 stliport_t *portp;
1103 unsigned long flags; 1064 unsigned long flags;
1104
1105#ifdef DEBUG
1106 printk("stli_close(tty=%x,filp=%x)\n", (int) tty, (int) filp);
1107#endif
1108 1065
1109 portp = tty->driver_data; 1066 portp = tty->driver_data;
1110 if (portp == (stliport_t *) NULL) 1067 if (portp == NULL)
1111 return; 1068 return;
1112 1069
1113 save_flags(flags); 1070 spin_lock_irqsave(&stli_lock, flags);
1114 cli();
1115 if (tty_hung_up_p(filp)) { 1071 if (tty_hung_up_p(filp)) {
1116 restore_flags(flags); 1072 spin_unlock_irqrestore(&stli_lock, flags);
1117 return; 1073 return;
1118 } 1074 }
1119 if ((tty->count == 1) && (portp->refcount != 1)) 1075 if ((tty->count == 1) && (portp->refcount != 1))
1120 portp->refcount = 1; 1076 portp->refcount = 1;
1121 if (portp->refcount-- > 1) { 1077 if (portp->refcount-- > 1) {
1122 restore_flags(flags); 1078 spin_unlock_irqrestore(&stli_lock, flags);
1123 return; 1079 return;
1124 } 1080 }
1125 1081
@@ -1134,6 +1090,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1134 if (tty == stli_txcooktty) 1090 if (tty == stli_txcooktty)
1135 stli_flushchars(tty); 1091 stli_flushchars(tty);
1136 tty->closing = 1; 1092 tty->closing = 1;
1093 spin_unlock_irqrestore(&stli_lock, flags);
1094
1137 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) 1095 if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1138 tty_wait_until_sent(tty, portp->closing_wait); 1096 tty_wait_until_sent(tty, portp->closing_wait);
1139 1097
@@ -1157,7 +1115,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1157 stli_flushbuffer(tty); 1115 stli_flushbuffer(tty);
1158 1116
1159 tty->closing = 0; 1117 tty->closing = 0;
1160 portp->tty = (struct tty_struct *) NULL; 1118 portp->tty = NULL;
1161 1119
1162 if (portp->openwaitcnt) { 1120 if (portp->openwaitcnt) {
1163 if (portp->close_delay) 1121 if (portp->close_delay)
@@ -1167,7 +1125,6 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1167 1125
1168 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1126 portp->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1169 wake_up_interruptible(&portp->close_wait); 1127 wake_up_interruptible(&portp->close_wait);
1170 restore_flags(flags);
1171} 1128}
1172 1129
1173/*****************************************************************************/ 1130/*****************************************************************************/
@@ -1182,45 +1139,41 @@ static void stli_close(struct tty_struct *tty, struct file *filp)
1182 1139
1183static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) 1140static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1184{ 1141{
1185 struct tty_struct *tty; 1142 struct tty_struct *tty;
1186 asynotify_t nt; 1143 asynotify_t nt;
1187 asyport_t aport; 1144 asyport_t aport;
1188 int rc; 1145 int rc;
1189
1190#ifdef DEBUG
1191 printk("stli_initopen(brdp=%x,portp=%x)\n", (int) brdp, (int) portp);
1192#endif
1193 1146
1194 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0) 1147 if ((rc = stli_rawopen(brdp, portp, 0, 1)) < 0)
1195 return(rc); 1148 return rc;
1196 1149
1197 memset(&nt, 0, sizeof(asynotify_t)); 1150 memset(&nt, 0, sizeof(asynotify_t));
1198 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK); 1151 nt.data = (DT_TXLOW | DT_TXEMPTY | DT_RXBUSY | DT_RXBREAK);
1199 nt.signal = SG_DCD; 1152 nt.signal = SG_DCD;
1200 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt, 1153 if ((rc = stli_cmdwait(brdp, portp, A_SETNOTIFY, &nt,
1201 sizeof(asynotify_t), 0)) < 0) 1154 sizeof(asynotify_t), 0)) < 0)
1202 return(rc); 1155 return rc;
1203 1156
1204 tty = portp->tty; 1157 tty = portp->tty;
1205 if (tty == (struct tty_struct *) NULL) 1158 if (tty == NULL)
1206 return(-ENODEV); 1159 return -ENODEV;
1207 stli_mkasyport(portp, &aport, tty->termios); 1160 stli_mkasyport(portp, &aport, tty->termios);
1208 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport, 1161 if ((rc = stli_cmdwait(brdp, portp, A_SETPORT, &aport,
1209 sizeof(asyport_t), 0)) < 0) 1162 sizeof(asyport_t), 0)) < 0)
1210 return(rc); 1163 return rc;
1211 1164
1212 set_bit(ST_GETSIGS, &portp->state); 1165 set_bit(ST_GETSIGS, &portp->state);
1213 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig, 1166 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, &portp->asig,
1214 sizeof(asysigs_t), 1)) < 0) 1167 sizeof(asysigs_t), 1)) < 0)
1215 return(rc); 1168 return rc;
1216 if (test_and_clear_bit(ST_GETSIGS, &portp->state)) 1169 if (test_and_clear_bit(ST_GETSIGS, &portp->state))
1217 portp->sigs = stli_mktiocm(portp->asig.sigvalue); 1170 portp->sigs = stli_mktiocm(portp->asig.sigvalue);
1218 stli_mkasysigs(&portp->asig, 1, 1); 1171 stli_mkasysigs(&portp->asig, 1, 1);
1219 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, 1172 if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig,
1220 sizeof(asysigs_t), 0)) < 0) 1173 sizeof(asysigs_t), 0)) < 0)
1221 return(rc); 1174 return rc;
1222 1175
1223 return(0); 1176 return 0;
1224} 1177}
1225 1178
1226/*****************************************************************************/ 1179/*****************************************************************************/
@@ -1234,22 +1187,15 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp)
1234 1187
1235static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1188static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1236{ 1189{
1237 volatile cdkhdr_t *hdrp; 1190 cdkhdr_t __iomem *hdrp;
1238 volatile cdkctrl_t *cp; 1191 cdkctrl_t __iomem *cp;
1239 volatile unsigned char *bits; 1192 unsigned char __iomem *bits;
1240 unsigned long flags; 1193 unsigned long flags;
1241 int rc; 1194 int rc;
1242
1243#ifdef DEBUG
1244 printk("stli_rawopen(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1245 (int) brdp, (int) portp, (int) arg, wait);
1246#endif
1247 1195
1248/* 1196/*
1249 * Send a message to the slave to open this port. 1197 * Send a message to the slave to open this port.
1250 */ 1198 */
1251 save_flags(flags);
1252 cli();
1253 1199
1254/* 1200/*
1255 * Slave is already closing this port. This can happen if a hangup 1201 * 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 wait_event_interruptible(portp->raw_wait, 1206 wait_event_interruptible(portp->raw_wait,
1261 !test_bit(ST_CLOSING, &portp->state)); 1207 !test_bit(ST_CLOSING, &portp->state));
1262 if (signal_pending(current)) { 1208 if (signal_pending(current)) {
1263 restore_flags(flags);
1264 return -ERESTARTSYS; 1209 return -ERESTARTSYS;
1265 } 1210 }
1266 1211
@@ -1269,19 +1214,20 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1269 * memory. Once the message is in set the service bits to say that 1214 * memory. Once the message is in set the service bits to say that
1270 * this port wants service. 1215 * this port wants service.
1271 */ 1216 */
1217 spin_lock_irqsave(&brd_lock, flags);
1272 EBRDENABLE(brdp); 1218 EBRDENABLE(brdp);
1273 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1219 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1274 cp->openarg = arg; 1220 writel(arg, &cp->openarg);
1275 cp->open = 1; 1221 writeb(1, &cp->open);
1276 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1222 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1277 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1223 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1278 portp->portidx; 1224 portp->portidx;
1279 *bits |= portp->portbit; 1225 writeb(readb(bits) | portp->portbit, bits);
1280 EBRDDISABLE(brdp); 1226 EBRDDISABLE(brdp);
1281 1227
1282 if (wait == 0) { 1228 if (wait == 0) {
1283 restore_flags(flags); 1229 spin_unlock_irqrestore(&brd_lock, flags);
1284 return(0); 1230 return 0;
1285 } 1231 }
1286 1232
1287/* 1233/*
@@ -1290,15 +1236,16 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1290 */ 1236 */
1291 rc = 0; 1237 rc = 0;
1292 set_bit(ST_OPENING, &portp->state); 1238 set_bit(ST_OPENING, &portp->state);
1239 spin_unlock_irqrestore(&brd_lock, flags);
1240
1293 wait_event_interruptible(portp->raw_wait, 1241 wait_event_interruptible(portp->raw_wait,
1294 !test_bit(ST_OPENING, &portp->state)); 1242 !test_bit(ST_OPENING, &portp->state));
1295 if (signal_pending(current)) 1243 if (signal_pending(current))
1296 rc = -ERESTARTSYS; 1244 rc = -ERESTARTSYS;
1297 restore_flags(flags);
1298 1245
1299 if ((rc == 0) && (portp->rc != 0)) 1246 if ((rc == 0) && (portp->rc != 0))
1300 rc = -EIO; 1247 rc = -EIO;
1301 return(rc); 1248 return rc;
1302} 1249}
1303 1250
1304/*****************************************************************************/ 1251/*****************************************************************************/
@@ -1311,19 +1258,11 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i
1311 1258
1312static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) 1259static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait)
1313{ 1260{
1314 volatile cdkhdr_t *hdrp; 1261 cdkhdr_t __iomem *hdrp;
1315 volatile cdkctrl_t *cp; 1262 cdkctrl_t __iomem *cp;
1316 volatile unsigned char *bits; 1263 unsigned char __iomem *bits;
1317 unsigned long flags; 1264 unsigned long flags;
1318 int rc; 1265 int rc;
1319
1320#ifdef DEBUG
1321 printk("stli_rawclose(brdp=%x,portp=%x,arg=%x,wait=%d)\n",
1322 (int) brdp, (int) portp, (int) arg, wait);
1323#endif
1324
1325 save_flags(flags);
1326 cli();
1327 1266
1328/* 1267/*
1329 * Slave is already closing this port. This can happen if a hangup 1268 * Slave is already closing this port. This can happen if a hangup
@@ -1333,7 +1272,6 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1333 wait_event_interruptible(portp->raw_wait, 1272 wait_event_interruptible(portp->raw_wait,
1334 !test_bit(ST_CLOSING, &portp->state)); 1273 !test_bit(ST_CLOSING, &portp->state));
1335 if (signal_pending(current)) { 1274 if (signal_pending(current)) {
1336 restore_flags(flags);
1337 return -ERESTARTSYS; 1275 return -ERESTARTSYS;
1338 } 1276 }
1339 } 1277 }
@@ -1341,21 +1279,22 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1341/* 1279/*
1342 * Write the close command into shared memory. 1280 * Write the close command into shared memory.
1343 */ 1281 */
1282 spin_lock_irqsave(&brd_lock, flags);
1344 EBRDENABLE(brdp); 1283 EBRDENABLE(brdp);
1345 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 1284 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
1346 cp->closearg = arg; 1285 writel(arg, &cp->closearg);
1347 cp->close = 1; 1286 writeb(1, &cp->close);
1348 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1287 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1349 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1288 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1350 portp->portidx; 1289 portp->portidx;
1351 *bits |= portp->portbit; 1290 writeb(readb(bits) |portp->portbit, bits);
1352 EBRDDISABLE(brdp); 1291 EBRDDISABLE(brdp);
1353 1292
1354 set_bit(ST_CLOSING, &portp->state); 1293 set_bit(ST_CLOSING, &portp->state);
1355 if (wait == 0) { 1294 spin_unlock_irqrestore(&brd_lock, flags);
1356 restore_flags(flags); 1295
1357 return(0); 1296 if (wait == 0)
1358 } 1297 return 0;
1359 1298
1360/* 1299/*
1361 * Slave is in action, so now we must wait for the open acknowledgment 1300 * 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 !test_bit(ST_CLOSING, &portp->state)); 1305 !test_bit(ST_CLOSING, &portp->state));
1367 if (signal_pending(current)) 1306 if (signal_pending(current))
1368 rc = -ERESTARTSYS; 1307 rc = -ERESTARTSYS;
1369 restore_flags(flags);
1370 1308
1371 if ((rc == 0) && (portp->rc != 0)) 1309 if ((rc == 0) && (portp->rc != 0))
1372 rc = -EIO; 1310 rc = -EIO;
1373 return(rc); 1311 return rc;
1374} 1312}
1375 1313
1376/*****************************************************************************/ 1314/*****************************************************************************/
@@ -1384,36 +1322,21 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg,
1384 1322
1385static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 1323static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
1386{ 1324{
1387 unsigned long flags;
1388
1389#ifdef DEBUG
1390 printk("stli_cmdwait(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
1391 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
1392 (int) arg, size, copyback);
1393#endif
1394
1395 save_flags(flags);
1396 cli();
1397 wait_event_interruptible(portp->raw_wait, 1325 wait_event_interruptible(portp->raw_wait,
1398 !test_bit(ST_CMDING, &portp->state)); 1326 !test_bit(ST_CMDING, &portp->state));
1399 if (signal_pending(current)) { 1327 if (signal_pending(current))
1400 restore_flags(flags);
1401 return -ERESTARTSYS; 1328 return -ERESTARTSYS;
1402 }
1403 1329
1404 stli_sendcmd(brdp, portp, cmd, arg, size, copyback); 1330 stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
1405 1331
1406 wait_event_interruptible(portp->raw_wait, 1332 wait_event_interruptible(portp->raw_wait,
1407 !test_bit(ST_CMDING, &portp->state)); 1333 !test_bit(ST_CMDING, &portp->state));
1408 if (signal_pending(current)) { 1334 if (signal_pending(current))
1409 restore_flags(flags);
1410 return -ERESTARTSYS; 1335 return -ERESTARTSYS;
1411 }
1412 restore_flags(flags);
1413 1336
1414 if (portp->rc != 0) 1337 if (portp->rc != 0)
1415 return(-EIO); 1338 return -EIO;
1416 return(0); 1339 return 0;
1417} 1340}
1418 1341
1419/*****************************************************************************/ 1342/*****************************************************************************/
@@ -1425,22 +1348,18 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v
1425 1348
1426static int stli_setport(stliport_t *portp) 1349static int stli_setport(stliport_t *portp)
1427{ 1350{
1428 stlibrd_t *brdp; 1351 stlibrd_t *brdp;
1429 asyport_t aport; 1352 asyport_t aport;
1430
1431#ifdef DEBUG
1432 printk("stli_setport(portp=%x)\n", (int) portp);
1433#endif
1434 1353
1435 if (portp == (stliport_t *) NULL) 1354 if (portp == NULL)
1436 return(-ENODEV); 1355 return -ENODEV;
1437 if (portp->tty == (struct tty_struct *) NULL) 1356 if (portp->tty == NULL)
1438 return(-ENODEV); 1357 return -ENODEV;
1439 if ((portp->brdnr < 0) && (portp->brdnr >= stli_nrbrds)) 1358 if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds)
1440 return(-ENODEV); 1359 return -ENODEV;
1441 brdp = stli_brds[portp->brdnr]; 1360 brdp = stli_brds[portp->brdnr];
1442 if (brdp == (stlibrd_t *) NULL) 1361 if (brdp == NULL)
1443 return(-ENODEV); 1362 return -ENODEV;
1444 1363
1445 stli_mkasyport(portp, &aport, portp->tty->termios); 1364 stli_mkasyport(portp, &aport, portp->tty->termios);
1446 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0)); 1365 return(stli_cmdwait(brdp, portp, A_SETPORT, &aport, sizeof(asyport_t), 0));
@@ -1455,13 +1374,8 @@ static int stli_setport(stliport_t *portp)
1455 1374
1456static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) 1375static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp)
1457{ 1376{
1458 unsigned long flags; 1377 unsigned long flags;
1459 int rc, doclocal; 1378 int rc, doclocal;
1460
1461#ifdef DEBUG
1462 printk("stli_waitcarrier(brdp=%x,portp=%x,filp=%x)\n",
1463 (int) brdp, (int) portp, (int) filp);
1464#endif
1465 1379
1466 rc = 0; 1380 rc = 0;
1467 doclocal = 0; 1381 doclocal = 0;
@@ -1469,11 +1383,11 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1469 if (portp->tty->termios->c_cflag & CLOCAL) 1383 if (portp->tty->termios->c_cflag & CLOCAL)
1470 doclocal++; 1384 doclocal++;
1471 1385
1472 save_flags(flags); 1386 spin_lock_irqsave(&stli_lock, flags);
1473 cli();
1474 portp->openwaitcnt++; 1387 portp->openwaitcnt++;
1475 if (! tty_hung_up_p(filp)) 1388 if (! tty_hung_up_p(filp))
1476 portp->refcount--; 1389 portp->refcount--;
1390 spin_unlock_irqrestore(&stli_lock, flags);
1477 1391
1478 for (;;) { 1392 for (;;) {
1479 stli_mkasysigs(&portp->asig, 1, 1); 1393 stli_mkasysigs(&portp->asig, 1, 1);
@@ -1499,12 +1413,13 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1499 interruptible_sleep_on(&portp->open_wait); 1413 interruptible_sleep_on(&portp->open_wait);
1500 } 1414 }
1501 1415
1416 spin_lock_irqsave(&stli_lock, flags);
1502 if (! tty_hung_up_p(filp)) 1417 if (! tty_hung_up_p(filp))
1503 portp->refcount++; 1418 portp->refcount++;
1504 portp->openwaitcnt--; 1419 portp->openwaitcnt--;
1505 restore_flags(flags); 1420 spin_unlock_irqrestore(&stli_lock, flags);
1506 1421
1507 return(rc); 1422 return rc;
1508} 1423}
1509 1424
1510/*****************************************************************************/ 1425/*****************************************************************************/
@@ -1517,46 +1432,38 @@ static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *fil
1517 1432
1518static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count) 1433static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count)
1519{ 1434{
1520 volatile cdkasy_t *ap; 1435 cdkasy_t __iomem *ap;
1521 volatile cdkhdr_t *hdrp; 1436 cdkhdr_t __iomem *hdrp;
1522 volatile unsigned char *bits; 1437 unsigned char __iomem *bits;
1523 unsigned char *shbuf, *chbuf; 1438 unsigned char __iomem *shbuf;
1524 stliport_t *portp; 1439 unsigned char *chbuf;
1525 stlibrd_t *brdp; 1440 stliport_t *portp;
1526 unsigned int len, stlen, head, tail, size; 1441 stlibrd_t *brdp;
1527 unsigned long flags; 1442 unsigned int len, stlen, head, tail, size;
1528 1443 unsigned long flags;
1529#ifdef DEBUG
1530 printk("stli_write(tty=%x,buf=%x,count=%d)\n",
1531 (int) tty, (int) buf, count);
1532#endif
1533 1444
1534 if ((tty == (struct tty_struct *) NULL) ||
1535 (stli_tmpwritebuf == (char *) NULL))
1536 return(0);
1537 if (tty == stli_txcooktty) 1445 if (tty == stli_txcooktty)
1538 stli_flushchars(tty); 1446 stli_flushchars(tty);
1539 portp = tty->driver_data; 1447 portp = tty->driver_data;
1540 if (portp == (stliport_t *) NULL) 1448 if (portp == NULL)
1541 return(0); 1449 return 0;
1542 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1450 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1543 return(0); 1451 return 0;
1544 brdp = stli_brds[portp->brdnr]; 1452 brdp = stli_brds[portp->brdnr];
1545 if (brdp == (stlibrd_t *) NULL) 1453 if (brdp == NULL)
1546 return(0); 1454 return 0;
1547 chbuf = (unsigned char *) buf; 1455 chbuf = (unsigned char *) buf;
1548 1456
1549/* 1457/*
1550 * All data is now local, shove as much as possible into shared memory. 1458 * All data is now local, shove as much as possible into shared memory.
1551 */ 1459 */
1552 save_flags(flags); 1460 spin_lock_irqsave(&brd_lock, flags);
1553 cli();
1554 EBRDENABLE(brdp); 1461 EBRDENABLE(brdp);
1555 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1462 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1556 head = (unsigned int) ap->txq.head; 1463 head = (unsigned int) readw(&ap->txq.head);
1557 tail = (unsigned int) ap->txq.tail; 1464 tail = (unsigned int) readw(&ap->txq.tail);
1558 if (tail != ((unsigned int) ap->txq.tail)) 1465 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1559 tail = (unsigned int) ap->txq.tail; 1466 tail = (unsigned int) readw(&ap->txq.tail);
1560 size = portp->txsize; 1467 size = portp->txsize;
1561 if (head >= tail) { 1468 if (head >= tail) {
1562 len = size - (head - tail) - 1; 1469 len = size - (head - tail) - 1;
@@ -1568,11 +1475,11 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1568 1475
1569 len = MIN(len, count); 1476 len = MIN(len, count);
1570 count = 0; 1477 count = 0;
1571 shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); 1478 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset);
1572 1479
1573 while (len > 0) { 1480 while (len > 0) {
1574 stlen = MIN(len, stlen); 1481 stlen = MIN(len, stlen);
1575 memcpy((shbuf + head), chbuf, stlen); 1482 memcpy_toio(shbuf + head, chbuf, stlen);
1576 chbuf += stlen; 1483 chbuf += stlen;
1577 len -= stlen; 1484 len -= stlen;
1578 count += stlen; 1485 count += stlen;
@@ -1583,20 +1490,19 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1583 } 1490 }
1584 } 1491 }
1585 1492
1586 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1493 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1587 ap->txq.head = head; 1494 writew(head, &ap->txq.head);
1588 if (test_bit(ST_TXBUSY, &portp->state)) { 1495 if (test_bit(ST_TXBUSY, &portp->state)) {
1589 if (ap->changed.data & DT_TXEMPTY) 1496 if (readl(&ap->changed.data) & DT_TXEMPTY)
1590 ap->changed.data &= ~DT_TXEMPTY; 1497 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1591 } 1498 }
1592 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1499 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1593 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1500 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1594 portp->portidx; 1501 portp->portidx;
1595 *bits |= portp->portbit; 1502 writeb(readb(bits) | portp->portbit, bits);
1596 set_bit(ST_TXBUSY, &portp->state); 1503 set_bit(ST_TXBUSY, &portp->state);
1597 EBRDDISABLE(brdp); 1504 EBRDDISABLE(brdp);
1598 1505 spin_unlock_irqrestore(&brd_lock, flags);
1599 restore_flags(flags);
1600 1506
1601 return(count); 1507 return(count);
1602} 1508}
@@ -1613,14 +1519,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun
1613 1519
1614static void stli_putchar(struct tty_struct *tty, unsigned char ch) 1520static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1615{ 1521{
1616#ifdef DEBUG
1617 printk("stli_putchar(tty=%x,ch=%x)\n", (int) tty, (int) ch);
1618#endif
1619
1620 if (tty == (struct tty_struct *) NULL)
1621 return;
1622 if (tty != stli_txcooktty) { 1522 if (tty != stli_txcooktty) {
1623 if (stli_txcooktty != (struct tty_struct *) NULL) 1523 if (stli_txcooktty != NULL)
1624 stli_flushchars(stli_txcooktty); 1524 stli_flushchars(stli_txcooktty);
1625 stli_txcooktty = tty; 1525 stli_txcooktty = tty;
1626 } 1526 }
@@ -1640,29 +1540,26 @@ static void stli_putchar(struct tty_struct *tty, unsigned char ch)
1640 1540
1641static void stli_flushchars(struct tty_struct *tty) 1541static void stli_flushchars(struct tty_struct *tty)
1642{ 1542{
1643 volatile cdkhdr_t *hdrp; 1543 cdkhdr_t __iomem *hdrp;
1644 volatile unsigned char *bits; 1544 unsigned char __iomem *bits;
1645 volatile cdkasy_t *ap; 1545 cdkasy_t __iomem *ap;
1646 struct tty_struct *cooktty; 1546 struct tty_struct *cooktty;
1647 stliport_t *portp; 1547 stliport_t *portp;
1648 stlibrd_t *brdp; 1548 stlibrd_t *brdp;
1649 unsigned int len, stlen, head, tail, size, count, cooksize; 1549 unsigned int len, stlen, head, tail, size, count, cooksize;
1650 unsigned char *buf, *shbuf; 1550 unsigned char *buf;
1651 unsigned long flags; 1551 unsigned char __iomem *shbuf;
1652 1552 unsigned long flags;
1653#ifdef DEBUG
1654 printk("stli_flushchars(tty=%x)\n", (int) tty);
1655#endif
1656 1553
1657 cooksize = stli_txcooksize; 1554 cooksize = stli_txcooksize;
1658 cooktty = stli_txcooktty; 1555 cooktty = stli_txcooktty;
1659 stli_txcooksize = 0; 1556 stli_txcooksize = 0;
1660 stli_txcookrealsize = 0; 1557 stli_txcookrealsize = 0;
1661 stli_txcooktty = (struct tty_struct *) NULL; 1558 stli_txcooktty = NULL;
1662 1559
1663 if (tty == (struct tty_struct *) NULL) 1560 if (tty == NULL)
1664 return; 1561 return;
1665 if (cooktty == (struct tty_struct *) NULL) 1562 if (cooktty == NULL)
1666 return; 1563 return;
1667 if (tty != cooktty) 1564 if (tty != cooktty)
1668 tty = cooktty; 1565 tty = cooktty;
@@ -1670,23 +1567,22 @@ static void stli_flushchars(struct tty_struct *tty)
1670 return; 1567 return;
1671 1568
1672 portp = tty->driver_data; 1569 portp = tty->driver_data;
1673 if (portp == (stliport_t *) NULL) 1570 if (portp == NULL)
1674 return; 1571 return;
1675 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1572 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1676 return; 1573 return;
1677 brdp = stli_brds[portp->brdnr]; 1574 brdp = stli_brds[portp->brdnr];
1678 if (brdp == (stlibrd_t *) NULL) 1575 if (brdp == NULL)
1679 return; 1576 return;
1680 1577
1681 save_flags(flags); 1578 spin_lock_irqsave(&brd_lock, flags);
1682 cli();
1683 EBRDENABLE(brdp); 1579 EBRDENABLE(brdp);
1684 1580
1685 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1581 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1686 head = (unsigned int) ap->txq.head; 1582 head = (unsigned int) readw(&ap->txq.head);
1687 tail = (unsigned int) ap->txq.tail; 1583 tail = (unsigned int) readw(&ap->txq.tail);
1688 if (tail != ((unsigned int) ap->txq.tail)) 1584 if (tail != ((unsigned int) readw(&ap->txq.tail)))
1689 tail = (unsigned int) ap->txq.tail; 1585 tail = (unsigned int) readw(&ap->txq.tail);
1690 size = portp->txsize; 1586 size = portp->txsize;
1691 if (head >= tail) { 1587 if (head >= tail) {
1692 len = size - (head - tail) - 1; 1588 len = size - (head - tail) - 1;
@@ -1703,7 +1599,7 @@ static void stli_flushchars(struct tty_struct *tty)
1703 1599
1704 while (len > 0) { 1600 while (len > 0) {
1705 stlen = MIN(len, stlen); 1601 stlen = MIN(len, stlen);
1706 memcpy((shbuf + head), buf, stlen); 1602 memcpy_toio(shbuf + head, buf, stlen);
1707 buf += stlen; 1603 buf += stlen;
1708 len -= stlen; 1604 len -= stlen;
1709 count += stlen; 1605 count += stlen;
@@ -1714,73 +1610,66 @@ static void stli_flushchars(struct tty_struct *tty)
1714 } 1610 }
1715 } 1611 }
1716 1612
1717 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 1613 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
1718 ap->txq.head = head; 1614 writew(head, &ap->txq.head);
1719 1615
1720 if (test_bit(ST_TXBUSY, &portp->state)) { 1616 if (test_bit(ST_TXBUSY, &portp->state)) {
1721 if (ap->changed.data & DT_TXEMPTY) 1617 if (readl(&ap->changed.data) & DT_TXEMPTY)
1722 ap->changed.data &= ~DT_TXEMPTY; 1618 writel(readl(&ap->changed.data) & ~DT_TXEMPTY, &ap->changed.data);
1723 } 1619 }
1724 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 1620 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
1725 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 1621 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
1726 portp->portidx; 1622 portp->portidx;
1727 *bits |= portp->portbit; 1623 writeb(readb(bits) | portp->portbit, bits);
1728 set_bit(ST_TXBUSY, &portp->state); 1624 set_bit(ST_TXBUSY, &portp->state);
1729 1625
1730 EBRDDISABLE(brdp); 1626 EBRDDISABLE(brdp);
1731 restore_flags(flags); 1627 spin_unlock_irqrestore(&brd_lock, flags);
1732} 1628}
1733 1629
1734/*****************************************************************************/ 1630/*****************************************************************************/
1735 1631
1736static int stli_writeroom(struct tty_struct *tty) 1632static int stli_writeroom(struct tty_struct *tty)
1737{ 1633{
1738 volatile cdkasyrq_t *rp; 1634 cdkasyrq_t __iomem *rp;
1739 stliport_t *portp; 1635 stliport_t *portp;
1740 stlibrd_t *brdp; 1636 stlibrd_t *brdp;
1741 unsigned int head, tail, len; 1637 unsigned int head, tail, len;
1742 unsigned long flags; 1638 unsigned long flags;
1743
1744#ifdef DEBUG
1745 printk("stli_writeroom(tty=%x)\n", (int) tty);
1746#endif
1747 1639
1748 if (tty == (struct tty_struct *) NULL)
1749 return(0);
1750 if (tty == stli_txcooktty) { 1640 if (tty == stli_txcooktty) {
1751 if (stli_txcookrealsize != 0) { 1641 if (stli_txcookrealsize != 0) {
1752 len = stli_txcookrealsize - stli_txcooksize; 1642 len = stli_txcookrealsize - stli_txcooksize;
1753 return(len); 1643 return len;
1754 } 1644 }
1755 } 1645 }
1756 1646
1757 portp = tty->driver_data; 1647 portp = tty->driver_data;
1758 if (portp == (stliport_t *) NULL) 1648 if (portp == NULL)
1759 return(0); 1649 return 0;
1760 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1650 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1761 return(0); 1651 return 0;
1762 brdp = stli_brds[portp->brdnr]; 1652 brdp = stli_brds[portp->brdnr];
1763 if (brdp == (stlibrd_t *) NULL) 1653 if (brdp == NULL)
1764 return(0); 1654 return 0;
1765 1655
1766 save_flags(flags); 1656 spin_lock_irqsave(&brd_lock, flags);
1767 cli();
1768 EBRDENABLE(brdp); 1657 EBRDENABLE(brdp);
1769 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1658 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1770 head = (unsigned int) rp->head; 1659 head = (unsigned int) readw(&rp->head);
1771 tail = (unsigned int) rp->tail; 1660 tail = (unsigned int) readw(&rp->tail);
1772 if (tail != ((unsigned int) rp->tail)) 1661 if (tail != ((unsigned int) readw(&rp->tail)))
1773 tail = (unsigned int) rp->tail; 1662 tail = (unsigned int) readw(&rp->tail);
1774 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head); 1663 len = (head >= tail) ? (portp->txsize - (head - tail)) : (tail - head);
1775 len--; 1664 len--;
1776 EBRDDISABLE(brdp); 1665 EBRDDISABLE(brdp);
1777 restore_flags(flags); 1666 spin_unlock_irqrestore(&brd_lock, flags);
1778 1667
1779 if (tty == stli_txcooktty) { 1668 if (tty == stli_txcooktty) {
1780 stli_txcookrealsize = len; 1669 stli_txcookrealsize = len;
1781 len -= stli_txcooksize; 1670 len -= stli_txcooksize;
1782 } 1671 }
1783 return(len); 1672 return len;
1784} 1673}
1785 1674
1786/*****************************************************************************/ 1675/*****************************************************************************/
@@ -1795,44 +1684,37 @@ static int stli_writeroom(struct tty_struct *tty)
1795 1684
1796static int stli_charsinbuffer(struct tty_struct *tty) 1685static int stli_charsinbuffer(struct tty_struct *tty)
1797{ 1686{
1798 volatile cdkasyrq_t *rp; 1687 cdkasyrq_t __iomem *rp;
1799 stliport_t *portp; 1688 stliport_t *portp;
1800 stlibrd_t *brdp; 1689 stlibrd_t *brdp;
1801 unsigned int head, tail, len; 1690 unsigned int head, tail, len;
1802 unsigned long flags; 1691 unsigned long flags;
1803
1804#ifdef DEBUG
1805 printk("stli_charsinbuffer(tty=%x)\n", (int) tty);
1806#endif
1807 1692
1808 if (tty == (struct tty_struct *) NULL)
1809 return(0);
1810 if (tty == stli_txcooktty) 1693 if (tty == stli_txcooktty)
1811 stli_flushchars(tty); 1694 stli_flushchars(tty);
1812 portp = tty->driver_data; 1695 portp = tty->driver_data;
1813 if (portp == (stliport_t *) NULL) 1696 if (portp == NULL)
1814 return(0); 1697 return 0;
1815 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1698 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
1816 return(0); 1699 return 0;
1817 brdp = stli_brds[portp->brdnr]; 1700 brdp = stli_brds[portp->brdnr];
1818 if (brdp == (stlibrd_t *) NULL) 1701 if (brdp == NULL)
1819 return(0); 1702 return 0;
1820 1703
1821 save_flags(flags); 1704 spin_lock_irqsave(&brd_lock, flags);
1822 cli();
1823 EBRDENABLE(brdp); 1705 EBRDENABLE(brdp);
1824 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->txq; 1706 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->txq;
1825 head = (unsigned int) rp->head; 1707 head = (unsigned int) readw(&rp->head);
1826 tail = (unsigned int) rp->tail; 1708 tail = (unsigned int) readw(&rp->tail);
1827 if (tail != ((unsigned int) rp->tail)) 1709 if (tail != ((unsigned int) readw(&rp->tail)))
1828 tail = (unsigned int) rp->tail; 1710 tail = (unsigned int) readw(&rp->tail);
1829 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head)); 1711 len = (head >= tail) ? (head - tail) : (portp->txsize - (tail - head));
1830 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state)) 1712 if ((len == 0) && test_bit(ST_TXBUSY, &portp->state))
1831 len = 1; 1713 len = 1;
1832 EBRDDISABLE(brdp); 1714 EBRDDISABLE(brdp);
1833 restore_flags(flags); 1715 spin_unlock_irqrestore(&brd_lock, flags);
1834 1716
1835 return(len); 1717 return len;
1836} 1718}
1837 1719
1838/*****************************************************************************/ 1720/*****************************************************************************/
@@ -1843,12 +1725,8 @@ static int stli_charsinbuffer(struct tty_struct *tty)
1843 1725
1844static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) 1726static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1845{ 1727{
1846 struct serial_struct sio; 1728 struct serial_struct sio;
1847 stlibrd_t *brdp; 1729 stlibrd_t *brdp;
1848
1849#ifdef DEBUG
1850 printk("stli_getserial(portp=%x,sp=%x)\n", (int) portp, (int) sp);
1851#endif
1852 1730
1853 memset(&sio, 0, sizeof(struct serial_struct)); 1731 memset(&sio, 0, sizeof(struct serial_struct));
1854 sio.type = PORT_UNKNOWN; 1732 sio.type = PORT_UNKNOWN;
@@ -1863,7 +1741,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1863 sio.hub6 = 0; 1741 sio.hub6 = 0;
1864 1742
1865 brdp = stli_brds[portp->brdnr]; 1743 brdp = stli_brds[portp->brdnr];
1866 if (brdp != (stlibrd_t *) NULL) 1744 if (brdp != NULL)
1867 sio.port = brdp->iobase; 1745 sio.port = brdp->iobase;
1868 1746
1869 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ? 1747 return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
@@ -1880,12 +1758,8 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp)
1880 1758
1881static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) 1759static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1882{ 1760{
1883 struct serial_struct sio; 1761 struct serial_struct sio;
1884 int rc; 1762 int rc;
1885
1886#ifdef DEBUG
1887 printk("stli_setserial(portp=%p,sp=%p)\n", portp, sp);
1888#endif
1889 1763
1890 if (copy_from_user(&sio, sp, sizeof(struct serial_struct))) 1764 if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
1891 return -EFAULT; 1765 return -EFAULT;
@@ -1894,7 +1768,7 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1894 (sio.close_delay != portp->close_delay) || 1768 (sio.close_delay != portp->close_delay) ||
1895 ((sio.flags & ~ASYNC_USR_MASK) != 1769 ((sio.flags & ~ASYNC_USR_MASK) !=
1896 (portp->flags & ~ASYNC_USR_MASK))) 1770 (portp->flags & ~ASYNC_USR_MASK)))
1897 return(-EPERM); 1771 return -EPERM;
1898 } 1772 }
1899 1773
1900 portp->flags = (portp->flags & ~ASYNC_USR_MASK) | 1774 portp->flags = (portp->flags & ~ASYNC_USR_MASK) |
@@ -1905,8 +1779,8 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp)
1905 portp->custom_divisor = sio.custom_divisor; 1779 portp->custom_divisor = sio.custom_divisor;
1906 1780
1907 if ((rc = stli_setport(portp)) < 0) 1781 if ((rc = stli_setport(portp)) < 0)
1908 return(rc); 1782 return rc;
1909 return(0); 1783 return 0;
1910} 1784}
1911 1785
1912/*****************************************************************************/ 1786/*****************************************************************************/
@@ -1917,19 +1791,19 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file)
1917 stlibrd_t *brdp; 1791 stlibrd_t *brdp;
1918 int rc; 1792 int rc;
1919 1793
1920 if (portp == (stliport_t *) NULL) 1794 if (portp == NULL)
1921 return(-ENODEV); 1795 return -ENODEV;
1922 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1796 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1923 return(0); 1797 return 0;
1924 brdp = stli_brds[portp->brdnr]; 1798 brdp = stli_brds[portp->brdnr];
1925 if (brdp == (stlibrd_t *) NULL) 1799 if (brdp == NULL)
1926 return(0); 1800 return 0;
1927 if (tty->flags & (1 << TTY_IO_ERROR)) 1801 if (tty->flags & (1 << TTY_IO_ERROR))
1928 return(-EIO); 1802 return -EIO;
1929 1803
1930 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS, 1804 if ((rc = stli_cmdwait(brdp, portp, A_GETSIGNALS,
1931 &portp->asig, sizeof(asysigs_t), 1)) < 0) 1805 &portp->asig, sizeof(asysigs_t), 1)) < 0)
1932 return(rc); 1806 return rc;
1933 1807
1934 return stli_mktiocm(portp->asig.sigvalue); 1808 return stli_mktiocm(portp->asig.sigvalue);
1935} 1809}
@@ -1941,15 +1815,15 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1941 stlibrd_t *brdp; 1815 stlibrd_t *brdp;
1942 int rts = -1, dtr = -1; 1816 int rts = -1, dtr = -1;
1943 1817
1944 if (portp == (stliport_t *) NULL) 1818 if (portp == NULL)
1945 return(-ENODEV); 1819 return -ENODEV;
1946 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1820 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1947 return(0); 1821 return 0;
1948 brdp = stli_brds[portp->brdnr]; 1822 brdp = stli_brds[portp->brdnr];
1949 if (brdp == (stlibrd_t *) NULL) 1823 if (brdp == NULL)
1950 return(0); 1824 return 0;
1951 if (tty->flags & (1 << TTY_IO_ERROR)) 1825 if (tty->flags & (1 << TTY_IO_ERROR))
1952 return(-EIO); 1826 return -EIO;
1953 1827
1954 if (set & TIOCM_RTS) 1828 if (set & TIOCM_RTS)
1955 rts = 1; 1829 rts = 1;
@@ -1968,32 +1842,25 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file,
1968 1842
1969static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) 1843static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
1970{ 1844{
1971 stliport_t *portp; 1845 stliport_t *portp;
1972 stlibrd_t *brdp; 1846 stlibrd_t *brdp;
1973 unsigned int ival; 1847 unsigned int ival;
1974 int rc; 1848 int rc;
1975 void __user *argp = (void __user *)arg; 1849 void __user *argp = (void __user *)arg;
1976 1850
1977#ifdef DEBUG
1978 printk("stli_ioctl(tty=%x,file=%x,cmd=%x,arg=%x)\n",
1979 (int) tty, (int) file, cmd, (int) arg);
1980#endif
1981
1982 if (tty == (struct tty_struct *) NULL)
1983 return(-ENODEV);
1984 portp = tty->driver_data; 1851 portp = tty->driver_data;
1985 if (portp == (stliport_t *) NULL) 1852 if (portp == NULL)
1986 return(-ENODEV); 1853 return -ENODEV;
1987 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1854 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
1988 return(0); 1855 return 0;
1989 brdp = stli_brds[portp->brdnr]; 1856 brdp = stli_brds[portp->brdnr];
1990 if (brdp == (stlibrd_t *) NULL) 1857 if (brdp == NULL)
1991 return(0); 1858 return 0;
1992 1859
1993 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1860 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1994 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) { 1861 (cmd != COM_GETPORTSTATS) && (cmd != COM_CLRPORTSTATS)) {
1995 if (tty->flags & (1 << TTY_IO_ERROR)) 1862 if (tty->flags & (1 << TTY_IO_ERROR))
1996 return(-EIO); 1863 return -EIO;
1997 } 1864 }
1998 1865
1999 rc = 0; 1866 rc = 0;
@@ -2040,7 +1907,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2040 break; 1907 break;
2041 } 1908 }
2042 1909
2043 return(rc); 1910 return rc;
2044} 1911}
2045 1912
2046/*****************************************************************************/ 1913/*****************************************************************************/
@@ -2052,24 +1919,20 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
2052 1919
2053static void stli_settermios(struct tty_struct *tty, struct termios *old) 1920static void stli_settermios(struct tty_struct *tty, struct termios *old)
2054{ 1921{
2055 stliport_t *portp; 1922 stliport_t *portp;
2056 stlibrd_t *brdp; 1923 stlibrd_t *brdp;
2057 struct termios *tiosp; 1924 struct termios *tiosp;
2058 asyport_t aport; 1925 asyport_t aport;
2059
2060#ifdef DEBUG
2061 printk("stli_settermios(tty=%x,old=%x)\n", (int) tty, (int) old);
2062#endif
2063 1926
2064 if (tty == (struct tty_struct *) NULL) 1927 if (tty == NULL)
2065 return; 1928 return;
2066 portp = tty->driver_data; 1929 portp = tty->driver_data;
2067 if (portp == (stliport_t *) NULL) 1930 if (portp == NULL)
2068 return; 1931 return;
2069 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 1932 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2070 return; 1933 return;
2071 brdp = stli_brds[portp->brdnr]; 1934 brdp = stli_brds[portp->brdnr];
2072 if (brdp == (stlibrd_t *) NULL) 1935 if (brdp == NULL)
2073 return; 1936 return;
2074 1937
2075 tiosp = tty->termios; 1938 tiosp = tty->termios;
@@ -2102,18 +1965,9 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old)
2102 1965
2103static void stli_throttle(struct tty_struct *tty) 1966static void stli_throttle(struct tty_struct *tty)
2104{ 1967{
2105 stliport_t *portp; 1968 stliport_t *portp = tty->driver_data;
2106 1969 if (portp == NULL)
2107#ifdef DEBUG
2108 printk("stli_throttle(tty=%x)\n", (int) tty);
2109#endif
2110
2111 if (tty == (struct tty_struct *) NULL)
2112 return; 1970 return;
2113 portp = tty->driver_data;
2114 if (portp == (stliport_t *) NULL)
2115 return;
2116
2117 set_bit(ST_RXSTOP, &portp->state); 1971 set_bit(ST_RXSTOP, &portp->state);
2118} 1972}
2119 1973
@@ -2127,88 +1981,30 @@ static void stli_throttle(struct tty_struct *tty)
2127 1981
2128static void stli_unthrottle(struct tty_struct *tty) 1982static void stli_unthrottle(struct tty_struct *tty)
2129{ 1983{
2130 stliport_t *portp; 1984 stliport_t *portp = tty->driver_data;
2131 1985 if (portp == NULL)
2132#ifdef DEBUG
2133 printk("stli_unthrottle(tty=%x)\n", (int) tty);
2134#endif
2135
2136 if (tty == (struct tty_struct *) NULL)
2137 return;
2138 portp = tty->driver_data;
2139 if (portp == (stliport_t *) NULL)
2140 return; 1986 return;
2141
2142 clear_bit(ST_RXSTOP, &portp->state); 1987 clear_bit(ST_RXSTOP, &portp->state);
2143} 1988}
2144 1989
2145/*****************************************************************************/ 1990/*****************************************************************************/
2146 1991
2147/* 1992/*
2148 * Stop the transmitter. Basically to do this we will just turn TX 1993 * Stop the transmitter.
2149 * interrupts off.
2150 */ 1994 */
2151 1995
2152static void stli_stop(struct tty_struct *tty) 1996static void stli_stop(struct tty_struct *tty)
2153{ 1997{
2154 stlibrd_t *brdp;
2155 stliport_t *portp;
2156 asyctrl_t actrl;
2157
2158#ifdef DEBUG
2159 printk("stli_stop(tty=%x)\n", (int) tty);
2160#endif
2161
2162 if (tty == (struct tty_struct *) NULL)
2163 return;
2164 portp = tty->driver_data;
2165 if (portp == (stliport_t *) NULL)
2166 return;
2167 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2168 return;
2169 brdp = stli_brds[portp->brdnr];
2170 if (brdp == (stlibrd_t *) NULL)
2171 return;
2172
2173 memset(&actrl, 0, sizeof(asyctrl_t));
2174 actrl.txctrl = CT_STOPFLOW;
2175#if 0
2176 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2177#endif
2178} 1998}
2179 1999
2180/*****************************************************************************/ 2000/*****************************************************************************/
2181 2001
2182/* 2002/*
2183 * Start the transmitter again. Just turn TX interrupts back on. 2003 * Start the transmitter again.
2184 */ 2004 */
2185 2005
2186static void stli_start(struct tty_struct *tty) 2006static void stli_start(struct tty_struct *tty)
2187{ 2007{
2188 stliport_t *portp;
2189 stlibrd_t *brdp;
2190 asyctrl_t actrl;
2191
2192#ifdef DEBUG
2193 printk("stli_start(tty=%x)\n", (int) tty);
2194#endif
2195
2196 if (tty == (struct tty_struct *) NULL)
2197 return;
2198 portp = tty->driver_data;
2199 if (portp == (stliport_t *) NULL)
2200 return;
2201 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds))
2202 return;
2203 brdp = stli_brds[portp->brdnr];
2204 if (brdp == (stlibrd_t *) NULL)
2205 return;
2206
2207 memset(&actrl, 0, sizeof(asyctrl_t));
2208 actrl.txctrl = CT_STARTFLOW;
2209#if 0
2210 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2211#endif
2212} 2008}
2213 2009
2214/*****************************************************************************/ 2010/*****************************************************************************/
@@ -2224,22 +2020,9 @@ static void stli_start(struct tty_struct *tty)
2224 2020
2225static void stli_dohangup(void *arg) 2021static void stli_dohangup(void *arg)
2226{ 2022{
2227 stliport_t *portp; 2023 stliport_t *portp = (stliport_t *) arg;
2228 2024 if (portp->tty != NULL) {
2229#ifdef DEBUG 2025 tty_hangup(portp->tty);
2230 printk(KERN_DEBUG "stli_dohangup(portp=%x)\n", (int) arg);
2231#endif
2232
2233 /*
2234 * FIXME: There's a module removal race here: tty_hangup
2235 * calls schedule_work which will call into this
2236 * driver later.
2237 */
2238 portp = (stliport_t *) arg;
2239 if (portp != (stliport_t *) NULL) {
2240 if (portp->tty != (struct tty_struct *) NULL) {
2241 tty_hangup(portp->tty);
2242 }
2243 } 2026 }
2244} 2027}
2245 2028
@@ -2254,31 +2037,25 @@ static void stli_dohangup(void *arg)
2254 2037
2255static void stli_hangup(struct tty_struct *tty) 2038static void stli_hangup(struct tty_struct *tty)
2256{ 2039{
2257 stliport_t *portp; 2040 stliport_t *portp;
2258 stlibrd_t *brdp; 2041 stlibrd_t *brdp;
2259 unsigned long flags; 2042 unsigned long flags;
2260
2261#ifdef DEBUG
2262 printk(KERN_DEBUG "stli_hangup(tty=%x)\n", (int) tty);
2263#endif
2264 2043
2265 if (tty == (struct tty_struct *) NULL)
2266 return;
2267 portp = tty->driver_data; 2044 portp = tty->driver_data;
2268 if (portp == (stliport_t *) NULL) 2045 if (portp == NULL)
2269 return; 2046 return;
2270 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2047 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2271 return; 2048 return;
2272 brdp = stli_brds[portp->brdnr]; 2049 brdp = stli_brds[portp->brdnr];
2273 if (brdp == (stlibrd_t *) NULL) 2050 if (brdp == NULL)
2274 return; 2051 return;
2275 2052
2276 portp->flags &= ~ASYNC_INITIALIZED; 2053 portp->flags &= ~ASYNC_INITIALIZED;
2277 2054
2278 save_flags(flags); 2055 if (!test_bit(ST_CLOSING, &portp->state))
2279 cli();
2280 if (! test_bit(ST_CLOSING, &portp->state))
2281 stli_rawclose(brdp, portp, 0, 0); 2056 stli_rawclose(brdp, portp, 0, 0);
2057
2058 spin_lock_irqsave(&stli_lock, flags);
2282 if (tty->termios->c_cflag & HUPCL) { 2059 if (tty->termios->c_cflag & HUPCL) {
2283 stli_mkasysigs(&portp->asig, 0, 0); 2060 stli_mkasysigs(&portp->asig, 0, 0);
2284 if (test_bit(ST_CMDING, &portp->state)) { 2061 if (test_bit(ST_CMDING, &portp->state)) {
@@ -2290,14 +2067,15 @@ static void stli_hangup(struct tty_struct *tty)
2290 &portp->asig, sizeof(asysigs_t), 0); 2067 &portp->asig, sizeof(asysigs_t), 0);
2291 } 2068 }
2292 } 2069 }
2293 restore_flags(flags);
2294 2070
2295 clear_bit(ST_TXBUSY, &portp->state); 2071 clear_bit(ST_TXBUSY, &portp->state);
2296 clear_bit(ST_RXSTOP, &portp->state); 2072 clear_bit(ST_RXSTOP, &portp->state);
2297 set_bit(TTY_IO_ERROR, &tty->flags); 2073 set_bit(TTY_IO_ERROR, &tty->flags);
2298 portp->tty = (struct tty_struct *) NULL; 2074 portp->tty = NULL;
2299 portp->flags &= ~ASYNC_NORMAL_ACTIVE; 2075 portp->flags &= ~ASYNC_NORMAL_ACTIVE;
2300 portp->refcount = 0; 2076 portp->refcount = 0;
2077 spin_unlock_irqrestore(&stli_lock, flags);
2078
2301 wake_up_interruptible(&portp->open_wait); 2079 wake_up_interruptible(&portp->open_wait);
2302} 2080}
2303 2081
@@ -2312,29 +2090,22 @@ static void stli_hangup(struct tty_struct *tty)
2312 2090
2313static void stli_flushbuffer(struct tty_struct *tty) 2091static void stli_flushbuffer(struct tty_struct *tty)
2314{ 2092{
2315 stliport_t *portp; 2093 stliport_t *portp;
2316 stlibrd_t *brdp; 2094 stlibrd_t *brdp;
2317 unsigned long ftype, flags; 2095 unsigned long ftype, flags;
2318
2319#ifdef DEBUG
2320 printk(KERN_DEBUG "stli_flushbuffer(tty=%x)\n", (int) tty);
2321#endif
2322 2096
2323 if (tty == (struct tty_struct *) NULL)
2324 return;
2325 portp = tty->driver_data; 2097 portp = tty->driver_data;
2326 if (portp == (stliport_t *) NULL) 2098 if (portp == NULL)
2327 return; 2099 return;
2328 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2100 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2329 return; 2101 return;
2330 brdp = stli_brds[portp->brdnr]; 2102 brdp = stli_brds[portp->brdnr];
2331 if (brdp == (stlibrd_t *) NULL) 2103 if (brdp == NULL)
2332 return; 2104 return;
2333 2105
2334 save_flags(flags); 2106 spin_lock_irqsave(&brd_lock, flags);
2335 cli();
2336 if (tty == stli_txcooktty) { 2107 if (tty == stli_txcooktty) {
2337 stli_txcooktty = (struct tty_struct *) NULL; 2108 stli_txcooktty = NULL;
2338 stli_txcooksize = 0; 2109 stli_txcooksize = 0;
2339 stli_txcookrealsize = 0; 2110 stli_txcookrealsize = 0;
2340 } 2111 }
@@ -2346,15 +2117,10 @@ static void stli_flushbuffer(struct tty_struct *tty)
2346 ftype |= FLUSHRX; 2117 ftype |= FLUSHRX;
2347 clear_bit(ST_DOFLUSHRX, &portp->state); 2118 clear_bit(ST_DOFLUSHRX, &portp->state);
2348 } 2119 }
2349 stli_sendcmd(brdp, portp, A_FLUSH, &ftype, 2120 __stli_sendcmd(brdp, portp, A_FLUSH, &ftype, sizeof(u32), 0);
2350 sizeof(unsigned long), 0);
2351 } 2121 }
2352 restore_flags(flags); 2122 spin_unlock_irqrestore(&brd_lock, flags);
2353 2123 tty_wakeup(tty);
2354 wake_up_interruptible(&tty->write_wait);
2355 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
2356 tty->ldisc.write_wakeup)
2357 (tty->ldisc.write_wakeup)(tty);
2358} 2124}
2359 2125
2360/*****************************************************************************/ 2126/*****************************************************************************/
@@ -2364,55 +2130,31 @@ static void stli_breakctl(struct tty_struct *tty, int state)
2364 stlibrd_t *brdp; 2130 stlibrd_t *brdp;
2365 stliport_t *portp; 2131 stliport_t *portp;
2366 long arg; 2132 long arg;
2367 /* long savestate, savetime; */
2368 2133
2369#ifdef DEBUG
2370 printk(KERN_DEBUG "stli_breakctl(tty=%x,state=%d)\n", (int) tty, state);
2371#endif
2372
2373 if (tty == (struct tty_struct *) NULL)
2374 return;
2375 portp = tty->driver_data; 2134 portp = tty->driver_data;
2376 if (portp == (stliport_t *) NULL) 2135 if (portp == NULL)
2377 return; 2136 return;
2378 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2137 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2379 return; 2138 return;
2380 brdp = stli_brds[portp->brdnr]; 2139 brdp = stli_brds[portp->brdnr];
2381 if (brdp == (stlibrd_t *) NULL) 2140 if (brdp == NULL)
2382 return; 2141 return;
2383 2142
2384/*
2385 * Due to a bug in the tty send_break() code we need to preserve
2386 * the current process state and timeout...
2387 savetime = current->timeout;
2388 savestate = current->state;
2389 */
2390
2391 arg = (state == -1) ? BREAKON : BREAKOFF; 2143 arg = (state == -1) ? BREAKON : BREAKOFF;
2392 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0); 2144 stli_cmdwait(brdp, portp, A_BREAK, &arg, sizeof(long), 0);
2393
2394/*
2395 *
2396 current->timeout = savetime;
2397 current->state = savestate;
2398 */
2399} 2145}
2400 2146
2401/*****************************************************************************/ 2147/*****************************************************************************/
2402 2148
2403static void stli_waituntilsent(struct tty_struct *tty, int timeout) 2149static void stli_waituntilsent(struct tty_struct *tty, int timeout)
2404{ 2150{
2405 stliport_t *portp; 2151 stliport_t *portp;
2406 unsigned long tend; 2152 unsigned long tend;
2407 2153
2408#ifdef DEBUG 2154 if (tty == NULL)
2409 printk(KERN_DEBUG "stli_waituntilsent(tty=%x,timeout=%x)\n", (int) tty, timeout);
2410#endif
2411
2412 if (tty == (struct tty_struct *) NULL)
2413 return; 2155 return;
2414 portp = tty->driver_data; 2156 portp = tty->driver_data;
2415 if (portp == (stliport_t *) NULL) 2157 if (portp == NULL)
2416 return; 2158 return;
2417 2159
2418 if (timeout == 0) 2160 if (timeout == 0)
@@ -2436,19 +2178,13 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2436 stliport_t *portp; 2178 stliport_t *portp;
2437 asyctrl_t actrl; 2179 asyctrl_t actrl;
2438 2180
2439#ifdef DEBUG
2440 printk(KERN_DEBUG "stli_sendxchar(tty=%x,ch=%x)\n", (int) tty, ch);
2441#endif
2442
2443 if (tty == (struct tty_struct *) NULL)
2444 return;
2445 portp = tty->driver_data; 2181 portp = tty->driver_data;
2446 if (portp == (stliport_t *) NULL) 2182 if (portp == NULL)
2447 return; 2183 return;
2448 if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) 2184 if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds)
2449 return; 2185 return;
2450 brdp = stli_brds[portp->brdnr]; 2186 brdp = stli_brds[portp->brdnr];
2451 if (brdp == (stlibrd_t *) NULL) 2187 if (brdp == NULL)
2452 return; 2188 return;
2453 2189
2454 memset(&actrl, 0, sizeof(asyctrl_t)); 2190 memset(&actrl, 0, sizeof(asyctrl_t));
@@ -2460,7 +2196,6 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2460 actrl.txctrl = CT_SENDCHR; 2196 actrl.txctrl = CT_SENDCHR;
2461 actrl.tximdch = ch; 2197 actrl.tximdch = ch;
2462 } 2198 }
2463
2464 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0); 2199 stli_cmdwait(brdp, portp, A_PORTCTRL, &actrl, sizeof(asyctrl_t), 0);
2465} 2200}
2466 2201
@@ -2476,17 +2211,17 @@ static void stli_sendxchar(struct tty_struct *tty, char ch)
2476 2211
2477static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) 2212static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos)
2478{ 2213{
2479 char *sp, *uart; 2214 char *sp, *uart;
2480 int rc, cnt; 2215 int rc, cnt;
2481 2216
2482 rc = stli_portcmdstats(portp); 2217 rc = stli_portcmdstats(portp);
2483 2218
2484 uart = "UNKNOWN"; 2219 uart = "UNKNOWN";
2485 if (brdp->state & BST_STARTED) { 2220 if (brdp->state & BST_STARTED) {
2486 switch (stli_comstats.hwid) { 2221 switch (stli_comstats.hwid) {
2487 case 0: uart = "2681"; break; 2222 case 0: uart = "2681"; break;
2488 case 1: uart = "SC26198"; break; 2223 case 1: uart = "SC26198"; break;
2489 default: uart = "CD1400"; break; 2224 default:uart = "CD1400"; break;
2490 } 2225 }
2491 } 2226 }
2492 2227
@@ -2537,17 +2272,11 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p
2537 2272
2538static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) 2273static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
2539{ 2274{
2540 stlibrd_t *brdp; 2275 stlibrd_t *brdp;
2541 stliport_t *portp; 2276 stliport_t *portp;
2542 int brdnr, portnr, totalport; 2277 int brdnr, portnr, totalport;
2543 int curoff, maxoff; 2278 int curoff, maxoff;
2544 char *pos; 2279 char *pos;
2545
2546#ifdef DEBUG
2547 printk(KERN_DEBUG "stli_readproc(page=%x,start=%x,off=%x,count=%d,eof=%x,"
2548 "data=%x\n", (int) page, (int) start, (int) off, count,
2549 (int) eof, (int) data);
2550#endif
2551 2280
2552 pos = page; 2281 pos = page;
2553 totalport = 0; 2282 totalport = 0;
@@ -2568,7 +2297,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2568 */ 2297 */
2569 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2298 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
2570 brdp = stli_brds[brdnr]; 2299 brdp = stli_brds[brdnr];
2571 if (brdp == (stlibrd_t *) NULL) 2300 if (brdp == NULL)
2572 continue; 2301 continue;
2573 if (brdp->state == 0) 2302 if (brdp->state == 0)
2574 continue; 2303 continue;
@@ -2583,7 +2312,7 @@ static int stli_readproc(char *page, char **start, off_t off, int count, int *eo
2583 for (portnr = 0; (portnr < brdp->nrports); portnr++, 2312 for (portnr = 0; (portnr < brdp->nrports); portnr++,
2584 totalport++) { 2313 totalport++) {
2585 portp = brdp->ports[portnr]; 2314 portp = brdp->ports[portnr];
2586 if (portp == (stliport_t *) NULL) 2315 if (portp == NULL)
2587 continue; 2316 continue;
2588 if (off >= (curoff += MAXLINE)) 2317 if (off >= (curoff += MAXLINE))
2589 continue; 2318 continue;
@@ -2610,49 +2339,54 @@ stli_readdone:
2610 * a poll routine that does not have user context. Therefore you cannot 2339 * a poll routine that does not have user context. Therefore you cannot
2611 * copy back directly into user space, or to the kernel stack of a 2340 * copy back directly into user space, or to the kernel stack of a
2612 * process. This routine does not sleep, so can be called from anywhere. 2341 * process. This routine does not sleep, so can be called from anywhere.
2342 *
2343 * The caller must hold the brd_lock (see also stli_sendcmd the usual
2344 * entry point)
2613 */ 2345 */
2614 2346
2615static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) 2347static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2616{ 2348{
2617 volatile cdkhdr_t *hdrp; 2349 cdkhdr_t __iomem *hdrp;
2618 volatile cdkctrl_t *cp; 2350 cdkctrl_t __iomem *cp;
2619 volatile unsigned char *bits; 2351 unsigned char __iomem *bits;
2620 unsigned long flags; 2352 unsigned long flags;
2621 2353
2622#ifdef DEBUG 2354 spin_lock_irqsave(&brd_lock, flags);
2623 printk(KERN_DEBUG "stli_sendcmd(brdp=%x,portp=%x,cmd=%x,arg=%x,size=%d,"
2624 "copyback=%d)\n", (int) brdp, (int) portp, (int) cmd,
2625 (int) arg, size, copyback);
2626#endif
2627
2628 save_flags(flags);
2629 cli();
2630 2355
2631 if (test_bit(ST_CMDING, &portp->state)) { 2356 if (test_bit(ST_CMDING, &portp->state)) {
2632 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", 2357 printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n",
2633 (int) cmd); 2358 (int) cmd);
2634 restore_flags(flags); 2359 spin_unlock_irqrestore(&brd_lock, flags);
2635 return; 2360 return;
2636 } 2361 }
2637 2362
2638 EBRDENABLE(brdp); 2363 EBRDENABLE(brdp);
2639 cp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl; 2364 cp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->ctrl;
2640 if (size > 0) { 2365 if (size > 0) {
2641 memcpy((void *) &(cp->args[0]), arg, size); 2366 memcpy_toio((void __iomem *) &(cp->args[0]), arg, size);
2642 if (copyback) { 2367 if (copyback) {
2643 portp->argp = arg; 2368 portp->argp = arg;
2644 portp->argsize = size; 2369 portp->argsize = size;
2645 } 2370 }
2646 } 2371 }
2647 cp->status = 0; 2372 writel(0, &cp->status);
2648 cp->cmd = cmd; 2373 writel(cmd, &cp->cmd);
2649 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2374 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2650 bits = ((volatile unsigned char *) hdrp) + brdp->slaveoffset + 2375 bits = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset +
2651 portp->portidx; 2376 portp->portidx;
2652 *bits |= portp->portbit; 2377 writeb(readb(bits) | portp->portbit, bits);
2653 set_bit(ST_CMDING, &portp->state); 2378 set_bit(ST_CMDING, &portp->state);
2654 EBRDDISABLE(brdp); 2379 EBRDDISABLE(brdp);
2655 restore_flags(flags); 2380 spin_unlock_irqrestore(&brd_lock, flags);
2381}
2382
2383static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback)
2384{
2385 unsigned long flags;
2386
2387 spin_lock_irqsave(&brd_lock, flags);
2388 __stli_sendcmd(brdp, portp, cmd, arg, size, copyback);
2389 spin_unlock_irqrestore(&brd_lock, flags);
2656} 2390}
2657 2391
2658/*****************************************************************************/ 2392/*****************************************************************************/
@@ -2667,28 +2401,23 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd,
2667 2401
2668static void stli_read(stlibrd_t *brdp, stliport_t *portp) 2402static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2669{ 2403{
2670 volatile cdkasyrq_t *rp; 2404 cdkasyrq_t __iomem *rp;
2671 volatile char *shbuf; 2405 char __iomem *shbuf;
2672 struct tty_struct *tty; 2406 struct tty_struct *tty;
2673 unsigned int head, tail, size; 2407 unsigned int head, tail, size;
2674 unsigned int len, stlen; 2408 unsigned int len, stlen;
2675
2676#ifdef DEBUG
2677 printk(KERN_DEBUG "stli_read(brdp=%x,portp=%d)\n",
2678 (int) brdp, (int) portp);
2679#endif
2680 2409
2681 if (test_bit(ST_RXSTOP, &portp->state)) 2410 if (test_bit(ST_RXSTOP, &portp->state))
2682 return; 2411 return;
2683 tty = portp->tty; 2412 tty = portp->tty;
2684 if (tty == (struct tty_struct *) NULL) 2413 if (tty == NULL)
2685 return; 2414 return;
2686 2415
2687 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2416 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2688 head = (unsigned int) rp->head; 2417 head = (unsigned int) readw(&rp->head);
2689 if (head != ((unsigned int) rp->head)) 2418 if (head != ((unsigned int) readw(&rp->head)))
2690 head = (unsigned int) rp->head; 2419 head = (unsigned int) readw(&rp->head);
2691 tail = (unsigned int) rp->tail; 2420 tail = (unsigned int) readw(&rp->tail);
2692 size = portp->rxsize; 2421 size = portp->rxsize;
2693 if (head >= tail) { 2422 if (head >= tail) {
2694 len = head - tail; 2423 len = head - tail;
@@ -2699,12 +2428,15 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2699 } 2428 }
2700 2429
2701 len = tty_buffer_request_room(tty, len); 2430 len = tty_buffer_request_room(tty, len);
2702 /* FIXME : iomap ? */ 2431
2703 shbuf = (volatile char *) EBRDGETMEMPTR(brdp, portp->rxoffset); 2432 shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->rxoffset);
2704 2433
2705 while (len > 0) { 2434 while (len > 0) {
2435 unsigned char *cptr;
2436
2706 stlen = MIN(len, stlen); 2437 stlen = MIN(len, stlen);
2707 tty_insert_flip_string(tty, (char *)(shbuf + tail), stlen); 2438 tty_prepare_flip_string(tty, &cptr, stlen);
2439 memcpy_fromio(cptr, shbuf + tail, stlen);
2708 len -= stlen; 2440 len -= stlen;
2709 tail += stlen; 2441 tail += stlen;
2710 if (tail >= size) { 2442 if (tail >= size) {
@@ -2712,8 +2444,8 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2712 stlen = head; 2444 stlen = head;
2713 } 2445 }
2714 } 2446 }
2715 rp = &((volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr))->rxq; 2447 rp = &((cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr))->rxq;
2716 rp->tail = tail; 2448 writew(tail, &rp->tail);
2717 2449
2718 if (head != tail) 2450 if (head != tail)
2719 set_bit(ST_RXING, &portp->state); 2451 set_bit(ST_RXING, &portp->state);
@@ -2729,9 +2461,9 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp)
2729 * difficult to deal with them here. 2461 * difficult to deal with them here.
2730 */ 2462 */
2731 2463
2732static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp) 2464static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp)
2733{ 2465{
2734 int cmd; 2466 int cmd;
2735 2467
2736 if (test_bit(ST_DOSIGS, &portp->state)) { 2468 if (test_bit(ST_DOSIGS, &portp->state)) {
2737 if (test_bit(ST_DOFLUSHTX, &portp->state) && 2469 if (test_bit(ST_DOFLUSHTX, &portp->state) &&
@@ -2746,10 +2478,10 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2746 clear_bit(ST_DOFLUSHTX, &portp->state); 2478 clear_bit(ST_DOFLUSHTX, &portp->state);
2747 clear_bit(ST_DOFLUSHRX, &portp->state); 2479 clear_bit(ST_DOFLUSHRX, &portp->state);
2748 clear_bit(ST_DOSIGS, &portp->state); 2480 clear_bit(ST_DOSIGS, &portp->state);
2749 memcpy((void *) &(cp->args[0]), (void *) &portp->asig, 2481 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &portp->asig,
2750 sizeof(asysigs_t)); 2482 sizeof(asysigs_t));
2751 cp->status = 0; 2483 writel(0, &cp->status);
2752 cp->cmd = cmd; 2484 writel(cmd, &cp->cmd);
2753 set_bit(ST_CMDING, &portp->state); 2485 set_bit(ST_CMDING, &portp->state);
2754 } else if (test_bit(ST_DOFLUSHTX, &portp->state) || 2486 } else if (test_bit(ST_DOFLUSHTX, &portp->state) ||
2755 test_bit(ST_DOFLUSHRX, &portp->state)) { 2487 test_bit(ST_DOFLUSHRX, &portp->state)) {
@@ -2757,9 +2489,9 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2757 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0); 2489 cmd |= ((test_bit(ST_DOFLUSHRX, &portp->state)) ? FLUSHRX : 0);
2758 clear_bit(ST_DOFLUSHTX, &portp->state); 2490 clear_bit(ST_DOFLUSHTX, &portp->state);
2759 clear_bit(ST_DOFLUSHRX, &portp->state); 2491 clear_bit(ST_DOFLUSHRX, &portp->state);
2760 memcpy((void *) &(cp->args[0]), (void *) &cmd, sizeof(int)); 2492 memcpy_toio((void __iomem *) &(cp->args[0]), (void *) &cmd, sizeof(int));
2761 cp->status = 0; 2493 writel(0, &cp->status);
2762 cp->cmd = A_FLUSH; 2494 writel(A_FLUSH, &cp->cmd);
2763 set_bit(ST_CMDING, &portp->state); 2495 set_bit(ST_CMDING, &portp->state);
2764 } 2496 }
2765} 2497}
@@ -2779,30 +2511,25 @@ static void stli_dodelaycmd(stliport_t *portp, volatile cdkctrl_t *cp)
2779 2511
2780static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) 2512static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2781{ 2513{
2782 volatile cdkasy_t *ap; 2514 cdkasy_t __iomem *ap;
2783 volatile cdkctrl_t *cp; 2515 cdkctrl_t __iomem *cp;
2784 struct tty_struct *tty; 2516 struct tty_struct *tty;
2785 asynotify_t nt; 2517 asynotify_t nt;
2786 unsigned long oldsigs; 2518 unsigned long oldsigs;
2787 int rc, donerx; 2519 int rc, donerx;
2788 2520
2789#ifdef DEBUG 2521 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
2790 printk(KERN_DEBUG "stli_hostcmd(brdp=%x,channr=%d)\n",
2791 (int) brdp, channr);
2792#endif
2793
2794 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr);
2795 cp = &ap->ctrl; 2522 cp = &ap->ctrl;
2796 2523
2797/* 2524/*
2798 * Check if we are waiting for an open completion message. 2525 * Check if we are waiting for an open completion message.
2799 */ 2526 */
2800 if (test_bit(ST_OPENING, &portp->state)) { 2527 if (test_bit(ST_OPENING, &portp->state)) {
2801 rc = (int) cp->openarg; 2528 rc = readl(&cp->openarg);
2802 if ((cp->open == 0) && (rc != 0)) { 2529 if (readb(&cp->open) == 0 && rc != 0) {
2803 if (rc > 0) 2530 if (rc > 0)
2804 rc--; 2531 rc--;
2805 cp->openarg = 0; 2532 writel(0, &cp->openarg);
2806 portp->rc = rc; 2533 portp->rc = rc;
2807 clear_bit(ST_OPENING, &portp->state); 2534 clear_bit(ST_OPENING, &portp->state);
2808 wake_up_interruptible(&portp->raw_wait); 2535 wake_up_interruptible(&portp->raw_wait);
@@ -2813,11 +2540,11 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2813 * Check if we are waiting for a close completion message. 2540 * Check if we are waiting for a close completion message.
2814 */ 2541 */
2815 if (test_bit(ST_CLOSING, &portp->state)) { 2542 if (test_bit(ST_CLOSING, &portp->state)) {
2816 rc = (int) cp->closearg; 2543 rc = (int) readl(&cp->closearg);
2817 if ((cp->close == 0) && (rc != 0)) { 2544 if (readb(&cp->close) == 0 && rc != 0) {
2818 if (rc > 0) 2545 if (rc > 0)
2819 rc--; 2546 rc--;
2820 cp->closearg = 0; 2547 writel(0, &cp->closearg);
2821 portp->rc = rc; 2548 portp->rc = rc;
2822 clear_bit(ST_CLOSING, &portp->state); 2549 clear_bit(ST_CLOSING, &portp->state);
2823 wake_up_interruptible(&portp->raw_wait); 2550 wake_up_interruptible(&portp->raw_wait);
@@ -2829,16 +2556,16 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2829 * need to copy out the command results associated with this command. 2556 * need to copy out the command results associated with this command.
2830 */ 2557 */
2831 if (test_bit(ST_CMDING, &portp->state)) { 2558 if (test_bit(ST_CMDING, &portp->state)) {
2832 rc = cp->status; 2559 rc = readl(&cp->status);
2833 if ((cp->cmd == 0) && (rc != 0)) { 2560 if (readl(&cp->cmd) == 0 && rc != 0) {
2834 if (rc > 0) 2561 if (rc > 0)
2835 rc--; 2562 rc--;
2836 if (portp->argp != (void *) NULL) { 2563 if (portp->argp != NULL) {
2837 memcpy(portp->argp, (void *) &(cp->args[0]), 2564 memcpy_fromio(portp->argp, (void __iomem *) &(cp->args[0]),
2838 portp->argsize); 2565 portp->argsize);
2839 portp->argp = (void *) NULL; 2566 portp->argp = NULL;
2840 } 2567 }
2841 cp->status = 0; 2568 writel(0, &cp->status);
2842 portp->rc = rc; 2569 portp->rc = rc;
2843 clear_bit(ST_CMDING, &portp->state); 2570 clear_bit(ST_CMDING, &portp->state);
2844 stli_dodelaycmd(portp, cp); 2571 stli_dodelaycmd(portp, cp);
@@ -2877,18 +2604,15 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2877 if (nt.data & DT_TXEMPTY) 2604 if (nt.data & DT_TXEMPTY)
2878 clear_bit(ST_TXBUSY, &portp->state); 2605 clear_bit(ST_TXBUSY, &portp->state);
2879 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) { 2606 if (nt.data & (DT_TXEMPTY | DT_TXLOW)) {
2880 if (tty != (struct tty_struct *) NULL) { 2607 if (tty != NULL) {
2881 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && 2608 tty_wakeup(tty);
2882 tty->ldisc.write_wakeup) { 2609 EBRDENABLE(brdp);
2883 (tty->ldisc.write_wakeup)(tty);
2884 EBRDENABLE(brdp);
2885 }
2886 wake_up_interruptible(&tty->write_wait); 2610 wake_up_interruptible(&tty->write_wait);
2887 } 2611 }
2888 } 2612 }
2889 2613
2890 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) { 2614 if ((nt.data & DT_RXBREAK) && (portp->rxmarkmsk & BRKINT)) {
2891 if (tty != (struct tty_struct *) NULL) { 2615 if (tty != NULL) {
2892 tty_insert_flip_char(tty, 0, TTY_BREAK); 2616 tty_insert_flip_char(tty, 0, TTY_BREAK);
2893 if (portp->flags & ASYNC_SAK) { 2617 if (portp->flags & ASYNC_SAK) {
2894 do_SAK(tty); 2618 do_SAK(tty);
@@ -2932,14 +2656,14 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp)
2932 * at the cdk header structure. 2656 * at the cdk header structure.
2933 */ 2657 */
2934 2658
2935static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp) 2659static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp)
2936{ 2660{
2937 stliport_t *portp; 2661 stliport_t *portp;
2938 unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; 2662 unsigned char hostbits[(STL_MAXCHANS / 8) + 1];
2939 unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; 2663 unsigned char slavebits[(STL_MAXCHANS / 8) + 1];
2940 unsigned char *slavep; 2664 unsigned char __iomem *slavep;
2941 int bitpos, bitat, bitsize; 2665 int bitpos, bitat, bitsize;
2942 int channr, nrdevs, slavebitchange; 2666 int channr, nrdevs, slavebitchange;
2943 2667
2944 bitsize = brdp->bitsize; 2668 bitsize = brdp->bitsize;
2945 nrdevs = brdp->nrdevs; 2669 nrdevs = brdp->nrdevs;
@@ -2951,7 +2675,7 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2951 * 8 service bits at a time in the inner loop, so we can bypass 2675 * 8 service bits at a time in the inner loop, so we can bypass
2952 * the lot if none of them want service. 2676 * the lot if none of them want service.
2953 */ 2677 */
2954 memcpy(&hostbits[0], (((unsigned char *) hdrp) + brdp->hostoffset), 2678 memcpy_fromio(&hostbits[0], (((unsigned char __iomem *) hdrp) + brdp->hostoffset),
2955 bitsize); 2679 bitsize);
2956 2680
2957 memset(&slavebits[0], 0, bitsize); 2681 memset(&slavebits[0], 0, bitsize);
@@ -2978,11 +2702,11 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
2978 * service may initiate more slave requests. 2702 * service may initiate more slave requests.
2979 */ 2703 */
2980 if (slavebitchange) { 2704 if (slavebitchange) {
2981 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2705 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
2982 slavep = ((unsigned char *) hdrp) + brdp->slaveoffset; 2706 slavep = ((unsigned char __iomem *) hdrp) + brdp->slaveoffset;
2983 for (bitpos = 0; (bitpos < bitsize); bitpos++) { 2707 for (bitpos = 0; (bitpos < bitsize); bitpos++) {
2984 if (slavebits[bitpos]) 2708 if (readb(slavebits + bitpos))
2985 slavep[bitpos] &= ~slavebits[bitpos]; 2709 writeb(readb(slavep + bitpos) & ~slavebits[bitpos], slavebits + bitpos);
2986 } 2710 }
2987 } 2711 }
2988} 2712}
@@ -3000,9 +2724,9 @@ static void stli_brdpoll(stlibrd_t *brdp, volatile cdkhdr_t *hdrp)
3000 2724
3001static void stli_poll(unsigned long arg) 2725static void stli_poll(unsigned long arg)
3002{ 2726{
3003 volatile cdkhdr_t *hdrp; 2727 cdkhdr_t __iomem *hdrp;
3004 stlibrd_t *brdp; 2728 stlibrd_t *brdp;
3005 int brdnr; 2729 int brdnr;
3006 2730
3007 stli_timerlist.expires = STLI_TIMEOUT; 2731 stli_timerlist.expires = STLI_TIMEOUT;
3008 add_timer(&stli_timerlist); 2732 add_timer(&stli_timerlist);
@@ -3012,16 +2736,18 @@ static void stli_poll(unsigned long arg)
3012 */ 2736 */
3013 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) { 2737 for (brdnr = 0; (brdnr < stli_nrbrds); brdnr++) {
3014 brdp = stli_brds[brdnr]; 2738 brdp = stli_brds[brdnr];
3015 if (brdp == (stlibrd_t *) NULL) 2739 if (brdp == NULL)
3016 continue; 2740 continue;
3017 if ((brdp->state & BST_STARTED) == 0) 2741 if ((brdp->state & BST_STARTED) == 0)
3018 continue; 2742 continue;
3019 2743
2744 spin_lock(&brd_lock);
3020 EBRDENABLE(brdp); 2745 EBRDENABLE(brdp);
3021 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 2746 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
3022 if (hdrp->hostreq) 2747 if (readb(&hdrp->hostreq))
3023 stli_brdpoll(brdp, hdrp); 2748 stli_brdpoll(brdp, hdrp);
3024 EBRDDISABLE(brdp); 2749 EBRDDISABLE(brdp);
2750 spin_unlock(&brd_lock);
3025 } 2751 }
3026} 2752}
3027 2753
@@ -3034,11 +2760,6 @@ static void stli_poll(unsigned long arg)
3034 2760
3035static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) 2761static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp)
3036{ 2762{
3037#ifdef DEBUG
3038 printk(KERN_DEBUG "stli_mkasyport(portp=%x,pp=%x,tiosp=%d)\n",
3039 (int) portp, (int) pp, (int) tiosp);
3040#endif
3041
3042 memset(pp, 0, sizeof(asyport_t)); 2763 memset(pp, 0, sizeof(asyport_t));
3043 2764
3044/* 2765/*
@@ -3157,11 +2878,6 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
3157 2878
3158static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts) 2879static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3159{ 2880{
3160#ifdef DEBUG
3161 printk(KERN_DEBUG "stli_mkasysigs(sp=%x,dtr=%d,rts=%d)\n",
3162 (int) sp, dtr, rts);
3163#endif
3164
3165 memset(sp, 0, sizeof(asysigs_t)); 2881 memset(sp, 0, sizeof(asysigs_t));
3166 if (dtr >= 0) { 2882 if (dtr >= 0) {
3167 sp->signal |= SG_DTR; 2883 sp->signal |= SG_DTR;
@@ -3182,13 +2898,7 @@ static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts)
3182 2898
3183static long stli_mktiocm(unsigned long sigvalue) 2899static long stli_mktiocm(unsigned long sigvalue)
3184{ 2900{
3185 long tiocm; 2901 long tiocm = 0;
3186
3187#ifdef DEBUG
3188 printk(KERN_DEBUG "stli_mktiocm(sigvalue=%x)\n", (int) sigvalue);
3189#endif
3190
3191 tiocm = 0;
3192 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0); 2902 tiocm |= ((sigvalue & SG_DCD) ? TIOCM_CD : 0);
3193 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0); 2903 tiocm |= ((sigvalue & SG_CTS) ? TIOCM_CTS : 0);
3194 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0); 2904 tiocm |= ((sigvalue & SG_RI) ? TIOCM_RI : 0);
@@ -3210,10 +2920,6 @@ static int stli_initports(stlibrd_t *brdp)
3210 stliport_t *portp; 2920 stliport_t *portp;
3211 int i, panelnr, panelport; 2921 int i, panelnr, panelport;
3212 2922
3213#ifdef DEBUG
3214 printk(KERN_DEBUG "stli_initports(brdp=%x)\n", (int) brdp);
3215#endif
3216
3217 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { 2923 for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) {
3218 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); 2924 portp = kzalloc(sizeof(stliport_t), GFP_KERNEL);
3219 if (!portp) { 2925 if (!portp) {
@@ -3240,7 +2946,7 @@ static int stli_initports(stlibrd_t *brdp)
3240 brdp->ports[i] = portp; 2946 brdp->ports[i] = portp;
3241 } 2947 }
3242 2948
3243 return(0); 2949 return 0;
3244} 2950}
3245 2951
3246/*****************************************************************************/ 2952/*****************************************************************************/
@@ -3253,10 +2959,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3253{ 2959{
3254 unsigned long memconf; 2960 unsigned long memconf;
3255 2961
3256#ifdef DEBUG
3257 printk(KERN_DEBUG "stli_ecpinit(brdp=%d)\n", (int) brdp);
3258#endif
3259
3260 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 2962 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3261 udelay(10); 2963 udelay(10);
3262 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2964 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3270,9 +2972,6 @@ static void stli_ecpinit(stlibrd_t *brdp)
3270 2972
3271static void stli_ecpenable(stlibrd_t *brdp) 2973static void stli_ecpenable(stlibrd_t *brdp)
3272{ 2974{
3273#ifdef DEBUG
3274 printk(KERN_DEBUG "stli_ecpenable(brdp=%x)\n", (int) brdp);
3275#endif
3276 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); 2975 outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR));
3277} 2976}
3278 2977
@@ -3280,9 +2979,6 @@ static void stli_ecpenable(stlibrd_t *brdp)
3280 2979
3281static void stli_ecpdisable(stlibrd_t *brdp) 2980static void stli_ecpdisable(stlibrd_t *brdp)
3282{ 2981{
3283#ifdef DEBUG
3284 printk(KERN_DEBUG "stli_ecpdisable(brdp=%x)\n", (int) brdp);
3285#endif
3286 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 2982 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
3287} 2983}
3288 2984
@@ -3290,13 +2986,8 @@ static void stli_ecpdisable(stlibrd_t *brdp)
3290 2986
3291static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 2987static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3292{ 2988{
3293 void *ptr; 2989 void *ptr;
3294 unsigned char val; 2990 unsigned char val;
3295
3296#ifdef DEBUG
3297 printk(KERN_DEBUG "stli_ecpgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3298 (int) offset);
3299#endif
3300 2991
3301 if (offset > brdp->memsize) { 2992 if (offset > brdp->memsize) {
3302 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 2993 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3316,10 +3007,6 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3316 3007
3317static void stli_ecpreset(stlibrd_t *brdp) 3008static void stli_ecpreset(stlibrd_t *brdp)
3318{ 3009{
3319#ifdef DEBUG
3320 printk(KERN_DEBUG "stli_ecpreset(brdp=%x)\n", (int) brdp);
3321#endif
3322
3323 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); 3010 outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR));
3324 udelay(10); 3011 udelay(10);
3325 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); 3012 outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR));
@@ -3330,9 +3017,6 @@ static void stli_ecpreset(stlibrd_t *brdp)
3330 3017
3331static void stli_ecpintr(stlibrd_t *brdp) 3018static void stli_ecpintr(stlibrd_t *brdp)
3332{ 3019{
3333#ifdef DEBUG
3334 printk(KERN_DEBUG "stli_ecpintr(brdp=%x)\n", (int) brdp);
3335#endif
3336 outb(0x1, brdp->iobase); 3020 outb(0x1, brdp->iobase);
3337} 3021}
3338 3022
@@ -3346,10 +3030,6 @@ static void stli_ecpeiinit(stlibrd_t *brdp)
3346{ 3030{
3347 unsigned long memconf; 3031 unsigned long memconf;
3348 3032
3349#ifdef DEBUG
3350 printk(KERN_DEBUG "stli_ecpeiinit(brdp=%x)\n", (int) brdp);
3351#endif
3352
3353 outb(0x1, (brdp->iobase + ECP_EIBRDENAB)); 3033 outb(0x1, (brdp->iobase + ECP_EIBRDENAB));
3354 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); 3034 outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR));
3355 udelay(10); 3035 udelay(10);
@@ -3383,11 +3063,6 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line
3383 void *ptr; 3063 void *ptr;
3384 unsigned char val; 3064 unsigned char val;
3385 3065
3386#ifdef DEBUG
3387 printk(KERN_DEBUG "stli_ecpeigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3388 (int) brdp, (int) offset, line);
3389#endif
3390
3391 if (offset > brdp->memsize) { 3066 if (offset > brdp->memsize) {
3392 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3067 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3393 "range at line=%d(%d), brd=%d\n", 3068 "range at line=%d(%d), brd=%d\n",
@@ -3437,8 +3112,8 @@ static void stli_ecpmcdisable(stlibrd_t *brdp)
3437 3112
3438static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3113static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3439{ 3114{
3440 void *ptr; 3115 void *ptr;
3441 unsigned char val; 3116 unsigned char val;
3442 3117
3443 if (offset > brdp->memsize) { 3118 if (offset > brdp->memsize) {
3444 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3119 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3472,10 +3147,6 @@ static void stli_ecpmcreset(stlibrd_t *brdp)
3472 3147
3473static void stli_ecppciinit(stlibrd_t *brdp) 3148static void stli_ecppciinit(stlibrd_t *brdp)
3474{ 3149{
3475#ifdef DEBUG
3476 printk(KERN_DEBUG "stli_ecppciinit(brdp=%x)\n", (int) brdp);
3477#endif
3478
3479 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); 3150 outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR));
3480 udelay(10); 3151 udelay(10);
3481 outb(0, (brdp->iobase + ECP_PCICONFR)); 3152 outb(0, (brdp->iobase + ECP_PCICONFR));
@@ -3489,11 +3160,6 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin
3489 void *ptr; 3160 void *ptr;
3490 unsigned char val; 3161 unsigned char val;
3491 3162
3492#ifdef DEBUG
3493 printk(KERN_DEBUG "stli_ecppcigetmemptr(brdp=%x,offset=%x,line=%d)\n",
3494 (int) brdp, (int) offset, line);
3495#endif
3496
3497 if (offset > brdp->memsize) { 3163 if (offset > brdp->memsize) {
3498 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3164 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3499 "range at line=%d(%d), board=%d\n", 3165 "range at line=%d(%d), board=%d\n",
@@ -3528,10 +3194,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3528{ 3194{
3529 unsigned long memconf; 3195 unsigned long memconf;
3530 3196
3531#ifdef DEBUG
3532 printk(KERN_DEBUG "stli_onbinit(brdp=%d)\n", (int) brdp);
3533#endif
3534
3535 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3197 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3536 udelay(10); 3198 udelay(10);
3537 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3199 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3547,9 +3209,6 @@ static void stli_onbinit(stlibrd_t *brdp)
3547 3209
3548static void stli_onbenable(stlibrd_t *brdp) 3210static void stli_onbenable(stlibrd_t *brdp)
3549{ 3211{
3550#ifdef DEBUG
3551 printk(KERN_DEBUG "stli_onbenable(brdp=%x)\n", (int) brdp);
3552#endif
3553 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); 3212 outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR));
3554} 3213}
3555 3214
@@ -3557,9 +3216,6 @@ static void stli_onbenable(stlibrd_t *brdp)
3557 3216
3558static void stli_onbdisable(stlibrd_t *brdp) 3217static void stli_onbdisable(stlibrd_t *brdp)
3559{ 3218{
3560#ifdef DEBUG
3561 printk(KERN_DEBUG "stli_onbdisable(brdp=%x)\n", (int) brdp);
3562#endif
3563 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); 3219 outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR));
3564} 3220}
3565 3221
@@ -3569,11 +3225,6 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3569{ 3225{
3570 void *ptr; 3226 void *ptr;
3571 3227
3572#ifdef DEBUG
3573 printk(KERN_DEBUG "stli_onbgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3574 (int) offset);
3575#endif
3576
3577 if (offset > brdp->memsize) { 3228 if (offset > brdp->memsize) {
3578 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3229 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3579 "range at line=%d(%d), brd=%d\n", 3230 "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 3240
3590static void stli_onbreset(stlibrd_t *brdp) 3241static void stli_onbreset(stlibrd_t *brdp)
3591{ 3242{
3592
3593#ifdef DEBUG
3594 printk(KERN_DEBUG "stli_onbreset(brdp=%x)\n", (int) brdp);
3595#endif
3596
3597 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); 3243 outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR));
3598 udelay(10); 3244 udelay(10);
3599 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR)); 3245 outb(ONB_ATDISABLE, (brdp->iobase + ONB_ATCONFR));
@@ -3610,10 +3256,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3610{ 3256{
3611 unsigned long memconf; 3257 unsigned long memconf;
3612 3258
3613#ifdef DEBUG
3614 printk(KERN_DEBUG "stli_onbeinit(brdp=%d)\n", (int) brdp);
3615#endif
3616
3617 outb(0x1, (brdp->iobase + ONB_EIBRDENAB)); 3259 outb(0x1, (brdp->iobase + ONB_EIBRDENAB));
3618 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3260 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3619 udelay(10); 3261 udelay(10);
@@ -3632,9 +3274,6 @@ static void stli_onbeinit(stlibrd_t *brdp)
3632 3274
3633static void stli_onbeenable(stlibrd_t *brdp) 3275static void stli_onbeenable(stlibrd_t *brdp)
3634{ 3276{
3635#ifdef DEBUG
3636 printk(KERN_DEBUG "stli_onbeenable(brdp=%x)\n", (int) brdp);
3637#endif
3638 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); 3277 outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR));
3639} 3278}
3640 3279
@@ -3642,9 +3281,6 @@ static void stli_onbeenable(stlibrd_t *brdp)
3642 3281
3643static void stli_onbedisable(stlibrd_t *brdp) 3282static void stli_onbedisable(stlibrd_t *brdp)
3644{ 3283{
3645#ifdef DEBUG
3646 printk(KERN_DEBUG "stli_onbedisable(brdp=%x)\n", (int) brdp);
3647#endif
3648 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3284 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
3649} 3285}
3650 3286
@@ -3652,13 +3288,8 @@ static void stli_onbedisable(stlibrd_t *brdp)
3652 3288
3653static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3289static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3654{ 3290{
3655 void *ptr; 3291 void *ptr;
3656 unsigned char val; 3292 unsigned char val;
3657
3658#ifdef DEBUG
3659 printk(KERN_DEBUG "stli_onbegetmemptr(brdp=%x,offset=%x,line=%d)\n",
3660 (int) brdp, (int) offset, line);
3661#endif
3662 3293
3663 if (offset > brdp->memsize) { 3294 if (offset > brdp->memsize) {
3664 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3295 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
@@ -3681,11 +3312,6 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3681 3312
3682static void stli_onbereset(stlibrd_t *brdp) 3313static void stli_onbereset(stlibrd_t *brdp)
3683{ 3314{
3684
3685#ifdef DEBUG
3686 printk(KERN_ERR "stli_onbereset(brdp=%x)\n", (int) brdp);
3687#endif
3688
3689 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); 3315 outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR));
3690 udelay(10); 3316 udelay(10);
3691 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); 3317 outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR));
@@ -3700,11 +3326,6 @@ static void stli_onbereset(stlibrd_t *brdp)
3700 3326
3701static void stli_bbyinit(stlibrd_t *brdp) 3327static void stli_bbyinit(stlibrd_t *brdp)
3702{ 3328{
3703
3704#ifdef DEBUG
3705 printk(KERN_ERR "stli_bbyinit(brdp=%d)\n", (int) brdp);
3706#endif
3707
3708 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3329 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3709 udelay(10); 3330 udelay(10);
3710 outb(0, (brdp->iobase + BBY_ATCONFR)); 3331 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3717,24 +3338,13 @@ static void stli_bbyinit(stlibrd_t *brdp)
3717 3338
3718static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3339static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3719{ 3340{
3720 void *ptr; 3341 void *ptr;
3721 unsigned char val; 3342 unsigned char val;
3722 3343
3723#ifdef DEBUG 3344 BUG_ON(offset > brdp->memsize);
3724 printk(KERN_ERR "stli_bbygetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3725 (int) offset);
3726#endif
3727 3345
3728 if (offset > brdp->memsize) { 3346 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3729 printk(KERN_ERR "STALLION: shared memory pointer=%x out of " 3347 val = (unsigned char) (offset / BBY_PAGESIZE);
3730 "range at line=%d(%d), brd=%d\n",
3731 (int) offset, line, __LINE__, brdp->brdnr);
3732 ptr = NULL;
3733 val = 0;
3734 } else {
3735 ptr = brdp->membase + (offset % BBY_PAGESIZE);
3736 val = (unsigned char) (offset / BBY_PAGESIZE);
3737 }
3738 outb(val, (brdp->iobase + BBY_ATCONFR)); 3348 outb(val, (brdp->iobase + BBY_ATCONFR));
3739 return(ptr); 3349 return(ptr);
3740} 3350}
@@ -3743,11 +3353,6 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3743 3353
3744static void stli_bbyreset(stlibrd_t *brdp) 3354static void stli_bbyreset(stlibrd_t *brdp)
3745{ 3355{
3746
3747#ifdef DEBUG
3748 printk(KERN_DEBUG "stli_bbyreset(brdp=%x)\n", (int) brdp);
3749#endif
3750
3751 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); 3356 outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR));
3752 udelay(10); 3357 udelay(10);
3753 outb(0, (brdp->iobase + BBY_ATCONFR)); 3358 outb(0, (brdp->iobase + BBY_ATCONFR));
@@ -3762,11 +3367,6 @@ static void stli_bbyreset(stlibrd_t *brdp)
3762 3367
3763static void stli_stalinit(stlibrd_t *brdp) 3368static void stli_stalinit(stlibrd_t *brdp)
3764{ 3369{
3765
3766#ifdef DEBUG
3767 printk(KERN_DEBUG "stli_stalinit(brdp=%d)\n", (int) brdp);
3768#endif
3769
3770 outb(0x1, brdp->iobase); 3370 outb(0x1, brdp->iobase);
3771 mdelay(1000); 3371 mdelay(1000);
3772} 3372}
@@ -3775,36 +3375,18 @@ static void stli_stalinit(stlibrd_t *brdp)
3775 3375
3776static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) 3376static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line)
3777{ 3377{
3778 void *ptr; 3378 BUG_ON(offset > brdp->memsize);
3779 3379 return brdp->membase + (offset % STAL_PAGESIZE);
3780#ifdef DEBUG
3781 printk(KERN_DEBUG "stli_stalgetmemptr(brdp=%x,offset=%x)\n", (int) brdp,
3782 (int) offset);
3783#endif
3784
3785 if (offset > brdp->memsize) {
3786 printk(KERN_ERR "STALLION: shared memory pointer=%x out of "
3787 "range at line=%d(%d), brd=%d\n",
3788 (int) offset, line, __LINE__, brdp->brdnr);
3789 ptr = NULL;
3790 } else {
3791 ptr = brdp->membase + (offset % STAL_PAGESIZE);
3792 }
3793 return(ptr);
3794} 3380}
3795 3381
3796/*****************************************************************************/ 3382/*****************************************************************************/
3797 3383
3798static void stli_stalreset(stlibrd_t *brdp) 3384static void stli_stalreset(stlibrd_t *brdp)
3799{ 3385{
3800 volatile unsigned long *vecp; 3386 u32 __iomem *vecp;
3801
3802#ifdef DEBUG
3803 printk(KERN_DEBUG "stli_stalreset(brdp=%x)\n", (int) brdp);
3804#endif
3805 3387
3806 vecp = (volatile unsigned long *) (brdp->membase + 0x30); 3388 vecp = (u32 __iomem *) (brdp->membase + 0x30);
3807 *vecp = 0xffff0000; 3389 writel(0xffff0000, vecp);
3808 outb(0, brdp->iobase); 3390 outb(0, brdp->iobase);
3809 mdelay(1000); 3391 mdelay(1000);
3810} 3392}
@@ -3818,15 +3400,11 @@ static void stli_stalreset(stlibrd_t *brdp)
3818 3400
3819static int stli_initecp(stlibrd_t *brdp) 3401static int stli_initecp(stlibrd_t *brdp)
3820{ 3402{
3821 cdkecpsig_t sig; 3403 cdkecpsig_t sig;
3822 cdkecpsig_t *sigsp; 3404 cdkecpsig_t __iomem *sigsp;
3823 unsigned int status, nxtid; 3405 unsigned int status, nxtid;
3824 char *name; 3406 char *name;
3825 int panelnr, nrports; 3407 int panelnr, nrports;
3826
3827#ifdef DEBUG
3828 printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
3829#endif
3830 3408
3831 if (!request_region(brdp->iobase, brdp->iosize, "istallion")) 3409 if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
3832 return -EIO; 3410 return -EIO;
@@ -3834,7 +3412,7 @@ static int stli_initecp(stlibrd_t *brdp)
3834 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3412 if ((brdp->iobase == 0) || (brdp->memaddr == 0))
3835 { 3413 {
3836 release_region(brdp->iobase, brdp->iosize); 3414 release_region(brdp->iobase, brdp->iosize);
3837 return(-ENODEV); 3415 return -ENODEV;
3838 } 3416 }
3839 3417
3840 brdp->iosize = ECP_IOSIZE; 3418 brdp->iosize = ECP_IOSIZE;
@@ -3903,7 +3481,7 @@ static int stli_initecp(stlibrd_t *brdp)
3903 3481
3904 default: 3482 default:
3905 release_region(brdp->iobase, brdp->iosize); 3483 release_region(brdp->iobase, brdp->iosize);
3906 return(-EINVAL); 3484 return -EINVAL;
3907 } 3485 }
3908 3486
3909/* 3487/*
@@ -3915,10 +3493,10 @@ static int stli_initecp(stlibrd_t *brdp)
3915 EBRDINIT(brdp); 3493 EBRDINIT(brdp);
3916 3494
3917 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3495 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
3918 if (brdp->membase == (void *) NULL) 3496 if (brdp->membase == NULL)
3919 { 3497 {
3920 release_region(brdp->iobase, brdp->iosize); 3498 release_region(brdp->iobase, brdp->iosize);
3921 return(-ENOMEM); 3499 return -ENOMEM;
3922 } 3500 }
3923 3501
3924/* 3502/*
@@ -3927,23 +3505,14 @@ static int stli_initecp(stlibrd_t *brdp)
3927 * this is, and what it is connected to it. 3505 * this is, and what it is connected to it.
3928 */ 3506 */
3929 EBRDENABLE(brdp); 3507 EBRDENABLE(brdp);
3930 sigsp = (cdkecpsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3508 sigsp = (cdkecpsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
3931 memcpy(&sig, sigsp, sizeof(cdkecpsig_t)); 3509 memcpy(&sig, sigsp, sizeof(cdkecpsig_t));
3932 EBRDDISABLE(brdp); 3510 EBRDDISABLE(brdp);
3933 3511
3934#if 0 3512 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3935 printk("%s(%d): sig-> magic=%x rom=%x panel=%x,%x,%x,%x,%x,%x,%x,%x\n",
3936 __FILE__, __LINE__, (int) sig.magic, sig.romver, sig.panelid[0],
3937 (int) sig.panelid[1], (int) sig.panelid[2],
3938 (int) sig.panelid[3], (int) sig.panelid[4],
3939 (int) sig.panelid[5], (int) sig.panelid[6],
3940 (int) sig.panelid[7]);
3941#endif
3942
3943 if (sig.magic != ECP_MAGIC)
3944 { 3513 {
3945 release_region(brdp->iobase, brdp->iosize); 3514 release_region(brdp->iobase, brdp->iosize);
3946 return(-ENODEV); 3515 return -ENODEV;
3947 } 3516 }
3948 3517
3949/* 3518/*
@@ -3967,7 +3536,7 @@ static int stli_initecp(stlibrd_t *brdp)
3967 3536
3968 3537
3969 brdp->state |= BST_FOUND; 3538 brdp->state |= BST_FOUND;
3970 return(0); 3539 return 0;
3971} 3540}
3972 3541
3973/*****************************************************************************/ 3542/*****************************************************************************/
@@ -3979,20 +3548,16 @@ static int stli_initecp(stlibrd_t *brdp)
3979 3548
3980static int stli_initonb(stlibrd_t *brdp) 3549static int stli_initonb(stlibrd_t *brdp)
3981{ 3550{
3982 cdkonbsig_t sig; 3551 cdkonbsig_t sig;
3983 cdkonbsig_t *sigsp; 3552 cdkonbsig_t __iomem *sigsp;
3984 char *name; 3553 char *name;
3985 int i; 3554 int i;
3986
3987#ifdef DEBUG
3988 printk(KERN_DEBUG "stli_initonb(brdp=%x)\n", (int) brdp);
3989#endif
3990 3555
3991/* 3556/*
3992 * Do a basic sanity check on the IO and memory addresses. 3557 * Do a basic sanity check on the IO and memory addresses.
3993 */ 3558 */
3994 if ((brdp->iobase == 0) || (brdp->memaddr == 0)) 3559 if (brdp->iobase == 0 || brdp->memaddr == 0)
3995 return(-ENODEV); 3560 return -ENODEV;
3996 3561
3997 brdp->iosize = ONB_IOSIZE; 3562 brdp->iosize = ONB_IOSIZE;
3998 3563
@@ -4010,7 +3575,6 @@ static int stli_initonb(stlibrd_t *brdp)
4010 case BRD_ONBOARD2: 3575 case BRD_ONBOARD2:
4011 case BRD_ONBOARD2_32: 3576 case BRD_ONBOARD2_32:
4012 case BRD_ONBOARDRS: 3577 case BRD_ONBOARDRS:
4013 brdp->membase = (void *) brdp->memaddr;
4014 brdp->memsize = ONB_MEMSIZE; 3578 brdp->memsize = ONB_MEMSIZE;
4015 brdp->pagesize = ONB_ATPAGESIZE; 3579 brdp->pagesize = ONB_ATPAGESIZE;
4016 brdp->init = stli_onbinit; 3580 brdp->init = stli_onbinit;
@@ -4028,7 +3592,6 @@ static int stli_initonb(stlibrd_t *brdp)
4028 break; 3592 break;
4029 3593
4030 case BRD_ONBOARDE: 3594 case BRD_ONBOARDE:
4031 brdp->membase = (void *) brdp->memaddr;
4032 brdp->memsize = ONB_EIMEMSIZE; 3595 brdp->memsize = ONB_EIMEMSIZE;
4033 brdp->pagesize = ONB_EIPAGESIZE; 3596 brdp->pagesize = ONB_EIPAGESIZE;
4034 brdp->init = stli_onbeinit; 3597 brdp->init = stli_onbeinit;
@@ -4044,7 +3607,6 @@ static int stli_initonb(stlibrd_t *brdp)
4044 case BRD_BRUMBY4: 3607 case BRD_BRUMBY4:
4045 case BRD_BRUMBY8: 3608 case BRD_BRUMBY8:
4046 case BRD_BRUMBY16: 3609 case BRD_BRUMBY16:
4047 brdp->membase = (void *) brdp->memaddr;
4048 brdp->memsize = BBY_MEMSIZE; 3610 brdp->memsize = BBY_MEMSIZE;
4049 brdp->pagesize = BBY_PAGESIZE; 3611 brdp->pagesize = BBY_PAGESIZE;
4050 brdp->init = stli_bbyinit; 3612 brdp->init = stli_bbyinit;
@@ -4058,7 +3620,6 @@ static int stli_initonb(stlibrd_t *brdp)
4058 break; 3620 break;
4059 3621
4060 case BRD_STALLION: 3622 case BRD_STALLION:
4061 brdp->membase = (void *) brdp->memaddr;
4062 brdp->memsize = STAL_MEMSIZE; 3623 brdp->memsize = STAL_MEMSIZE;
4063 brdp->pagesize = STAL_PAGESIZE; 3624 brdp->pagesize = STAL_PAGESIZE;
4064 brdp->init = stli_stalinit; 3625 brdp->init = stli_stalinit;
@@ -4073,7 +3634,7 @@ static int stli_initonb(stlibrd_t *brdp)
4073 3634
4074 default: 3635 default:
4075 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
4076 return(-EINVAL); 3637 return -EINVAL;
4077 } 3638 }
4078 3639
4079/* 3640/*
@@ -4085,10 +3646,10 @@ static int stli_initonb(stlibrd_t *brdp)
4085 EBRDINIT(brdp); 3646 EBRDINIT(brdp);
4086 3647
4087 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3648 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4088 if (brdp->membase == (void *) NULL) 3649 if (brdp->membase == NULL)
4089 { 3650 {
4090 release_region(brdp->iobase, brdp->iosize); 3651 release_region(brdp->iobase, brdp->iosize);
4091 return(-ENOMEM); 3652 return -ENOMEM;
4092 } 3653 }
4093 3654
4094/* 3655/*
@@ -4097,21 +3658,17 @@ static int stli_initonb(stlibrd_t *brdp)
4097 * this is, and how many ports. 3658 * this is, and how many ports.
4098 */ 3659 */
4099 EBRDENABLE(brdp); 3660 EBRDENABLE(brdp);
4100 sigsp = (cdkonbsig_t *) EBRDGETMEMPTR(brdp, CDK_SIGADDR); 3661 sigsp = (cdkonbsig_t __iomem *) EBRDGETMEMPTR(brdp, CDK_SIGADDR);
4101 memcpy(&sig, sigsp, sizeof(cdkonbsig_t)); 3662 memcpy_fromio(&sig, sigsp, sizeof(cdkonbsig_t));
4102 EBRDDISABLE(brdp); 3663 EBRDDISABLE(brdp);
4103 3664
4104#if 0 3665 if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) ||
4105 printk("%s(%d): sig-> magic=%x:%x:%x:%x romver=%x amask=%x:%x:%x\n", 3666 sig.magic1 != cpu_to_le16(ONB_MAGIC1) ||
4106 __FILE__, __LINE__, sig.magic0, sig.magic1, sig.magic2, 3667 sig.magic2 != cpu_to_le16(ONB_MAGIC2) ||
4107 sig.magic3, sig.romver, sig.amask0, sig.amask1, sig.amask2); 3668 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
4108#endif
4109
4110 if ((sig.magic0 != ONB_MAGIC0) || (sig.magic1 != ONB_MAGIC1) ||
4111 (sig.magic2 != ONB_MAGIC2) || (sig.magic3 != ONB_MAGIC3))
4112 { 3669 {
4113 release_region(brdp->iobase, brdp->iosize); 3670 release_region(brdp->iobase, brdp->iosize);
4114 return(-ENODEV); 3671 return -ENODEV;
4115 } 3672 }
4116 3673
4117/* 3674/*
@@ -4132,7 +3689,7 @@ static int stli_initonb(stlibrd_t *brdp)
4132 3689
4133 3690
4134 brdp->state |= BST_FOUND; 3691 brdp->state |= BST_FOUND;
4135 return(0); 3692 return 0;
4136} 3693}
4137 3694
4138/*****************************************************************************/ 3695/*****************************************************************************/
@@ -4145,31 +3702,25 @@ static int stli_initonb(stlibrd_t *brdp)
4145 3702
4146static int stli_startbrd(stlibrd_t *brdp) 3703static int stli_startbrd(stlibrd_t *brdp)
4147{ 3704{
4148 volatile cdkhdr_t *hdrp; 3705 cdkhdr_t __iomem *hdrp;
4149 volatile cdkmem_t *memp; 3706 cdkmem_t __iomem *memp;
4150 volatile cdkasy_t *ap; 3707 cdkasy_t __iomem *ap;
4151 unsigned long flags; 3708 unsigned long flags;
4152 stliport_t *portp; 3709 stliport_t *portp;
4153 int portnr, nrdevs, i, rc; 3710 int portnr, nrdevs, i, rc = 0;
4154 3711 u32 memoff;
4155#ifdef DEBUG 3712
4156 printk(KERN_DEBUG "stli_startbrd(brdp=%x)\n", (int) brdp); 3713 spin_lock_irqsave(&brd_lock, flags);
4157#endif
4158
4159 rc = 0;
4160
4161 save_flags(flags);
4162 cli();
4163 EBRDENABLE(brdp); 3714 EBRDENABLE(brdp);
4164 hdrp = (volatile cdkhdr_t *) EBRDGETMEMPTR(brdp, CDK_CDKADDR); 3715 hdrp = (cdkhdr_t __iomem *) EBRDGETMEMPTR(brdp, CDK_CDKADDR);
4165 nrdevs = hdrp->nrdevs; 3716 nrdevs = hdrp->nrdevs;
4166 3717
4167#if 0 3718#if 0
4168 printk("%s(%d): CDK version %d.%d.%d --> " 3719 printk("%s(%d): CDK version %d.%d.%d --> "
4169 "nrdevs=%d memp=%x hostp=%x slavep=%x\n", 3720 "nrdevs=%d memp=%x hostp=%x slavep=%x\n",
4170 __FILE__, __LINE__, hdrp->ver_release, hdrp->ver_modification, 3721 __FILE__, __LINE__, readb(&hdrp->ver_release), readb(&hdrp->ver_modification),
4171 hdrp->ver_fix, nrdevs, (int) hdrp->memp, (int) hdrp->hostp, 3722 readb(&hdrp->ver_fix), nrdevs, (int) readl(&hdrp->memp), readl(&hdrp->hostp),
4172 (int) hdrp->slavep); 3723 readl(&hdrp->slavep));
4173#endif 3724#endif
4174 3725
4175 if (nrdevs < (brdp->nrports + 1)) { 3726 if (nrdevs < (brdp->nrports + 1)) {
@@ -4181,14 +3732,14 @@ static int stli_startbrd(stlibrd_t *brdp)
4181 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR; 3732 brdp->hostoffset = hdrp->hostp - CDK_CDKADDR;
4182 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR; 3733 brdp->slaveoffset = hdrp->slavep - CDK_CDKADDR;
4183 brdp->bitsize = (nrdevs + 7) / 8; 3734 brdp->bitsize = (nrdevs + 7) / 8;
4184 memp = (volatile cdkmem_t *) hdrp->memp; 3735 memoff = readl(&hdrp->memp);
4185 if (((unsigned long) memp) > brdp->memsize) { 3736 if (memoff > brdp->memsize) {
4186 printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); 3737 printk(KERN_ERR "STALLION: corrupted shared memory region?\n");
4187 rc = -EIO; 3738 rc = -EIO;
4188 goto stli_donestartup; 3739 goto stli_donestartup;
4189 } 3740 }
4190 memp = (volatile cdkmem_t *) EBRDGETMEMPTR(brdp, (unsigned long) memp); 3741 memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff);
4191 if (memp->dtype != TYP_ASYNCTRL) { 3742 if (readw(&memp->dtype) != TYP_ASYNCTRL) {
4192 printk(KERN_ERR "STALLION: no slave control device found\n"); 3743 printk(KERN_ERR "STALLION: no slave control device found\n");
4193 goto stli_donestartup; 3744 goto stli_donestartup;
4194 } 3745 }
@@ -4200,19 +3751,19 @@ static int stli_startbrd(stlibrd_t *brdp)
4200 * change pages while reading memory map. 3751 * change pages while reading memory map.
4201 */ 3752 */
4202 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) { 3753 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++, memp++) {
4203 if (memp->dtype != TYP_ASYNC) 3754 if (readw(&memp->dtype) != TYP_ASYNC)
4204 break; 3755 break;
4205 portp = brdp->ports[portnr]; 3756 portp = brdp->ports[portnr];
4206 if (portp == (stliport_t *) NULL) 3757 if (portp == NULL)
4207 break; 3758 break;
4208 portp->devnr = i; 3759 portp->devnr = i;
4209 portp->addr = memp->offset; 3760 portp->addr = readl(&memp->offset);
4210 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs)); 3761 portp->reqbit = (unsigned char) (0x1 << (i * 8 / nrdevs));
4211 portp->portidx = (unsigned char) (i / 8); 3762 portp->portidx = (unsigned char) (i / 8);
4212 portp->portbit = (unsigned char) (0x1 << (i % 8)); 3763 portp->portbit = (unsigned char) (0x1 << (i % 8));
4213 } 3764 }
4214 3765
4215 hdrp->slavereq = 0xff; 3766 writeb(0xff, &hdrp->slavereq);
4216 3767
4217/* 3768/*
4218 * For each port setup a local copy of the RX and TX buffer offsets 3769 * 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 */ 3772 */
4222 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) { 3773 for (i = 1, portnr = 0; (i < nrdevs); i++, portnr++) {
4223 portp = brdp->ports[portnr]; 3774 portp = brdp->ports[portnr];
4224 if (portp == (stliport_t *) NULL) 3775 if (portp == NULL)
4225 break; 3776 break;
4226 if (portp->addr == 0) 3777 if (portp->addr == 0)
4227 break; 3778 break;
4228 ap = (volatile cdkasy_t *) EBRDGETMEMPTR(brdp, portp->addr); 3779 ap = (cdkasy_t __iomem *) EBRDGETMEMPTR(brdp, portp->addr);
4229 if (ap != (volatile cdkasy_t *) NULL) { 3780 if (ap != NULL) {
4230 portp->rxsize = ap->rxq.size; 3781 portp->rxsize = readw(&ap->rxq.size);
4231 portp->txsize = ap->txq.size; 3782 portp->txsize = readw(&ap->txq.size);
4232 portp->rxoffset = ap->rxq.offset; 3783 portp->rxoffset = readl(&ap->rxq.offset);
4233 portp->txoffset = ap->txq.offset; 3784 portp->txoffset = readl(&ap->txq.offset);
4234 } 3785 }
4235 } 3786 }
4236 3787
4237stli_donestartup: 3788stli_donestartup:
4238 EBRDDISABLE(brdp); 3789 EBRDDISABLE(brdp);
4239 restore_flags(flags); 3790 spin_unlock_irqrestore(&brd_lock, flags);
4240 3791
4241 if (rc == 0) 3792 if (rc == 0)
4242 brdp->state |= BST_STARTED; 3793 brdp->state |= BST_STARTED;
@@ -4247,7 +3798,7 @@ stli_donestartup:
4247 add_timer(&stli_timerlist); 3798 add_timer(&stli_timerlist);
4248 } 3799 }
4249 3800
4250 return(rc); 3801 return rc;
4251} 3802}
4252 3803
4253/*****************************************************************************/ 3804/*****************************************************************************/
@@ -4258,10 +3809,6 @@ stli_donestartup:
4258 3809
4259static int __init stli_brdinit(stlibrd_t *brdp) 3810static int __init stli_brdinit(stlibrd_t *brdp)
4260{ 3811{
4261#ifdef DEBUG
4262 printk(KERN_DEBUG "stli_brdinit(brdp=%x)\n", (int) brdp);
4263#endif
4264
4265 stli_brds[brdp->brdnr] = brdp; 3812 stli_brds[brdp->brdnr] = brdp;
4266 3813
4267 switch (brdp->brdtype) { 3814 switch (brdp->brdtype) {
@@ -4289,11 +3836,11 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4289 case BRD_ECHPCI: 3836 case BRD_ECHPCI:
4290 printk(KERN_ERR "STALLION: %s board type not supported in " 3837 printk(KERN_ERR "STALLION: %s board type not supported in "
4291 "this driver\n", stli_brdnames[brdp->brdtype]); 3838 "this driver\n", stli_brdnames[brdp->brdtype]);
4292 return(ENODEV); 3839 return -ENODEV;
4293 default: 3840 default:
4294 printk(KERN_ERR "STALLION: board=%d is unknown board " 3841 printk(KERN_ERR "STALLION: board=%d is unknown board "
4295 "type=%d\n", brdp->brdnr, brdp->brdtype); 3842 "type=%d\n", brdp->brdnr, brdp->brdtype);
4296 return(ENODEV); 3843 return -ENODEV;
4297 } 3844 }
4298 3845
4299 if ((brdp->state & BST_FOUND) == 0) { 3846 if ((brdp->state & BST_FOUND) == 0) {
@@ -4301,7 +3848,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4301 "io=%x mem=%x\n", 3848 "io=%x mem=%x\n",
4302 stli_brdnames[brdp->brdtype], brdp->brdnr, 3849 stli_brdnames[brdp->brdtype], brdp->brdnr,
4303 brdp->iobase, (int) brdp->memaddr); 3850 brdp->iobase, (int) brdp->memaddr);
4304 return(ENODEV); 3851 return -ENODEV;
4305 } 3852 }
4306 3853
4307 stli_initports(brdp); 3854 stli_initports(brdp);
@@ -4309,7 +3856,7 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4309 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], 3856 "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype],
4310 brdp->brdnr, brdp->iobase, (int) brdp->memaddr, 3857 brdp->brdnr, brdp->iobase, (int) brdp->memaddr,
4311 brdp->nrpanels, brdp->nrports); 3858 brdp->nrpanels, brdp->nrports);
4312 return(0); 3859 return 0;
4313} 3860}
4314 3861
4315/*****************************************************************************/ 3862/*****************************************************************************/
@@ -4321,14 +3868,10 @@ static int __init stli_brdinit(stlibrd_t *brdp)
4321 3868
4322static int stli_eisamemprobe(stlibrd_t *brdp) 3869static int stli_eisamemprobe(stlibrd_t *brdp)
4323{ 3870{
4324 cdkecpsig_t ecpsig, *ecpsigp; 3871 cdkecpsig_t ecpsig, __iomem *ecpsigp;
4325 cdkonbsig_t onbsig, *onbsigp; 3872 cdkonbsig_t onbsig, __iomem *onbsigp;
4326 int i, foundit; 3873 int i, foundit;
4327 3874
4328#ifdef DEBUG
4329 printk(KERN_DEBUG "stli_eisamemprobe(brdp=%x)\n", (int) brdp);
4330#endif
4331
4332/* 3875/*
4333 * First up we reset the board, to get it into a known state. There 3876 * First up we reset the board, to get it into a known state. There
4334 * is only 2 board types here we need to worry about. Don;t use the 3877 * 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 mdelay(1); 3895 mdelay(1);
4353 stli_onbeenable(brdp); 3896 stli_onbeenable(brdp);
4354 } else { 3897 } else {
4355 return(-ENODEV); 3898 return -ENODEV;
4356 } 3899 }
4357 3900
4358 foundit = 0; 3901 foundit = 0;
@@ -4364,25 +3907,24 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4364 */ 3907 */
4365 for (i = 0; (i < stli_eisamempsize); i++) { 3908 for (i = 0; (i < stli_eisamempsize); i++) {
4366 brdp->memaddr = stli_eisamemprobeaddrs[i]; 3909 brdp->memaddr = stli_eisamemprobeaddrs[i];
4367 brdp->membase = (void *) brdp->memaddr;
4368 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3910 brdp->membase = ioremap(brdp->memaddr, brdp->memsize);
4369 if (brdp->membase == (void *) NULL) 3911 if (brdp->membase == NULL)
4370 continue; 3912 continue;
4371 3913
4372 if (brdp->brdtype == BRD_ECPE) { 3914 if (brdp->brdtype == BRD_ECPE) {
4373 ecpsigp = (cdkecpsig_t *) stli_ecpeigetmemptr(brdp, 3915 ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp,
4374 CDK_SIGADDR, __LINE__); 3916 CDK_SIGADDR, __LINE__);
4375 memcpy(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); 3917 memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t));
4376 if (ecpsig.magic == ECP_MAGIC) 3918 if (ecpsig.magic == cpu_to_le32(ECP_MAGIC))
4377 foundit = 1; 3919 foundit = 1;
4378 } else { 3920 } else {
4379 onbsigp = (cdkonbsig_t *) stli_onbegetmemptr(brdp, 3921 onbsigp = (cdkonbsig_t __iomem *) stli_onbegetmemptr(brdp,
4380 CDK_SIGADDR, __LINE__); 3922 CDK_SIGADDR, __LINE__);
4381 memcpy(&onbsig, onbsigp, sizeof(cdkonbsig_t)); 3923 memcpy_fromio(&onbsig, onbsigp, sizeof(cdkonbsig_t));
4382 if ((onbsig.magic0 == ONB_MAGIC0) && 3924 if ((onbsig.magic0 == cpu_to_le16(ONB_MAGIC0)) &&
4383 (onbsig.magic1 == ONB_MAGIC1) && 3925 (onbsig.magic1 == cpu_to_le16(ONB_MAGIC1)) &&
4384 (onbsig.magic2 == ONB_MAGIC2) && 3926 (onbsig.magic2 == cpu_to_le16(ONB_MAGIC2)) &&
4385 (onbsig.magic3 == ONB_MAGIC3)) 3927 (onbsig.magic3 == cpu_to_le16(ONB_MAGIC3)))
4386 foundit = 1; 3928 foundit = 1;
4387 } 3929 }
4388 3930
@@ -4406,9 +3948,9 @@ static int stli_eisamemprobe(stlibrd_t *brdp)
4406 printk(KERN_ERR "STALLION: failed to probe shared memory " 3948 printk(KERN_ERR "STALLION: failed to probe shared memory "
4407 "region for %s in EISA slot=%d\n", 3949 "region for %s in EISA slot=%d\n",
4408 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); 3950 stli_brdnames[brdp->brdtype], (brdp->iobase >> 12));
4409 return(-ENODEV); 3951 return -ENODEV;
4410 } 3952 }
4411 return(0); 3953 return 0;
4412} 3954}
4413 3955
4414static int stli_getbrdnr(void) 3956static int stli_getbrdnr(void)
@@ -4439,22 +3981,16 @@ static int stli_getbrdnr(void)
4439 3981
4440static int stli_findeisabrds(void) 3982static int stli_findeisabrds(void)
4441{ 3983{
4442 stlibrd_t *brdp; 3984 stlibrd_t *brdp;
4443 unsigned int iobase, eid; 3985 unsigned int iobase, eid;
4444 int i; 3986 int i;
4445
4446#ifdef DEBUG
4447 printk(KERN_DEBUG "stli_findeisabrds()\n");
4448#endif
4449 3987
4450/* 3988/*
4451 * Firstly check if this is an EISA system. Do this by probing for 3989 * Firstly check if this is an EISA system. If this is not an EISA system then
4452 * the system board EISA ID. If this is not an EISA system then
4453 * don't bother going any further! 3990 * don't bother going any further!
4454 */ 3991 */
4455 outb(0xff, 0xc80); 3992 if (EISA_bus)
4456 if (inb(0xc80) == 0xff) 3993 return 0;
4457 return(0);
4458 3994
4459/* 3995/*
4460 * Looks like an EISA system, so go searching for EISA boards. 3996 * Looks like an EISA system, so go searching for EISA boards.
@@ -4472,7 +4008,7 @@ static int stli_findeisabrds(void)
4472 */ 4008 */
4473 for (i = 0; (i < STL_MAXBRDS); i++) { 4009 for (i = 0; (i < STL_MAXBRDS); i++) {
4474 brdp = stli_brds[i]; 4010 brdp = stli_brds[i];
4475 if (brdp == (stlibrd_t *) NULL) 4011 if (brdp == NULL)
4476 continue; 4012 continue;
4477 if (brdp->iobase == iobase) 4013 if (brdp->iobase == iobase)
4478 break; 4014 break;
@@ -4484,10 +4020,10 @@ static int stli_findeisabrds(void)
4484 * We have found a Stallion board and it is not configured already. 4020 * We have found a Stallion board and it is not configured already.
4485 * Allocate a board structure and initialize it. 4021 * Allocate a board structure and initialize it.
4486 */ 4022 */
4487 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4023 if ((brdp = stli_allocbrd()) == NULL)
4488 return(-ENOMEM); 4024 return -ENOMEM;
4489 if ((brdp->brdnr = stli_getbrdnr()) < 0) 4025 if ((brdp->brdnr = stli_getbrdnr()) < 0)
4490 return(-ENOMEM); 4026 return -ENOMEM;
4491 eid = inb(iobase + 0xc82); 4027 eid = inb(iobase + 0xc82);
4492 if (eid == ECP_EISAID) 4028 if (eid == ECP_EISAID)
4493 brdp->brdtype = BRD_ECPE; 4029 brdp->brdtype = BRD_ECPE;
@@ -4502,7 +4038,7 @@ static int stli_findeisabrds(void)
4502 stli_brdinit(brdp); 4038 stli_brdinit(brdp);
4503 } 4039 }
4504 4040
4505 return(0); 4041 return 0;
4506} 4042}
4507 4043
4508/*****************************************************************************/ 4044/*****************************************************************************/
@@ -4523,32 +4059,18 @@ static int stli_findeisabrds(void)
4523 4059
4524static int stli_initpcibrd(int brdtype, struct pci_dev *devp) 4060static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4525{ 4061{
4526 stlibrd_t *brdp; 4062 stlibrd_t *brdp;
4527
4528#ifdef DEBUG
4529 printk(KERN_DEBUG "stli_initpcibrd(brdtype=%d,busnr=%x,devnr=%x)\n",
4530 brdtype, dev->bus->number, dev->devfn);
4531#endif
4532 4063
4533 if (pci_enable_device(devp)) 4064 if (pci_enable_device(devp))
4534 return(-EIO); 4065 return -EIO;
4535 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4066 if ((brdp = stli_allocbrd()) == NULL)
4536 return(-ENOMEM); 4067 return -ENOMEM;
4537 if ((brdp->brdnr = stli_getbrdnr()) < 0) { 4068 if ((brdp->brdnr = stli_getbrdnr()) < 0) {
4538 printk(KERN_INFO "STALLION: too many boards found, " 4069 printk(KERN_INFO "STALLION: too many boards found, "
4539 "maximum supported %d\n", STL_MAXBRDS); 4070 "maximum supported %d\n", STL_MAXBRDS);
4540 return(0); 4071 return 0;
4541 } 4072 }
4542 brdp->brdtype = brdtype; 4073 brdp->brdtype = brdtype;
4543
4544#ifdef DEBUG
4545 printk(KERN_DEBUG "%s(%d): BAR[]=%lx,%lx,%lx,%lx\n", __FILE__, __LINE__,
4546 pci_resource_start(devp, 0),
4547 pci_resource_start(devp, 1),
4548 pci_resource_start(devp, 2),
4549 pci_resource_start(devp, 3));
4550#endif
4551
4552/* 4074/*
4553 * We have all resources from the board, so lets setup the actual 4075 * We have all resources from the board, so lets setup the actual
4554 * board structure now. 4076 * board structure now.
@@ -4557,7 +4079,7 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4557 brdp->memaddr = pci_resource_start(devp, 2); 4079 brdp->memaddr = pci_resource_start(devp, 2);
4558 stli_brdinit(brdp); 4080 stli_brdinit(brdp);
4559 4081
4560 return(0); 4082 return 0;
4561} 4083}
4562 4084
4563/*****************************************************************************/ 4085/*****************************************************************************/
@@ -4569,20 +4091,12 @@ static int stli_initpcibrd(int brdtype, struct pci_dev *devp)
4569 4091
4570static int stli_findpcibrds(void) 4092static int stli_findpcibrds(void)
4571{ 4093{
4572 struct pci_dev *dev = NULL; 4094 struct pci_dev *dev = NULL;
4573 int rc;
4574
4575#ifdef DEBUG
4576 printk("stli_findpcibrds()\n");
4577#endif
4578 4095
4579 while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, 4096 while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) {
4580 PCI_DEVICE_ID_ECRA, dev))) { 4097 stli_initpcibrd(BRD_ECPPCI, dev);
4581 if ((rc = stli_initpcibrd(BRD_ECPPCI, dev)))
4582 return(rc);
4583 } 4098 }
4584 4099 return 0;
4585 return(0);
4586} 4100}
4587 4101
4588#endif 4102#endif
@@ -4595,17 +4109,16 @@ static int stli_findpcibrds(void)
4595 4109
4596static stlibrd_t *stli_allocbrd(void) 4110static stlibrd_t *stli_allocbrd(void)
4597{ 4111{
4598 stlibrd_t *brdp; 4112 stlibrd_t *brdp;
4599 4113
4600 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); 4114 brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL);
4601 if (!brdp) { 4115 if (!brdp) {
4602 printk(KERN_ERR "STALLION: failed to allocate memory " 4116 printk(KERN_ERR "STALLION: failed to allocate memory "
4603 "(size=%d)\n", sizeof(stlibrd_t)); 4117 "(size=%Zd)\n", sizeof(stlibrd_t));
4604 return NULL; 4118 return NULL;
4605 } 4119 }
4606
4607 brdp->magic = STLI_BOARDMAGIC; 4120 brdp->magic = STLI_BOARDMAGIC;
4608 return(brdp); 4121 return brdp;
4609} 4122}
4610 4123
4611/*****************************************************************************/ 4124/*****************************************************************************/
@@ -4617,13 +4130,9 @@ static stlibrd_t *stli_allocbrd(void)
4617 4130
4618static int stli_initbrds(void) 4131static int stli_initbrds(void)
4619{ 4132{
4620 stlibrd_t *brdp, *nxtbrdp; 4133 stlibrd_t *brdp, *nxtbrdp;
4621 stlconf_t *confp; 4134 stlconf_t *confp;
4622 int i, j; 4135 int i, j;
4623
4624#ifdef DEBUG
4625 printk(KERN_DEBUG "stli_initbrds()\n");
4626#endif
4627 4136
4628 if (stli_nrbrds > STL_MAXBRDS) { 4137 if (stli_nrbrds > STL_MAXBRDS) {
4629 printk(KERN_INFO "STALLION: too many boards in configuration " 4138 printk(KERN_INFO "STALLION: too many boards in configuration "
@@ -4638,11 +4147,9 @@ static int stli_initbrds(void)
4638 */ 4147 */
4639 for (i = 0; (i < stli_nrbrds); i++) { 4148 for (i = 0; (i < stli_nrbrds); i++) {
4640 confp = &stli_brdconf[i]; 4149 confp = &stli_brdconf[i];
4641#ifdef MODULE
4642 stli_parsebrd(confp, stli_brdsp[i]); 4150 stli_parsebrd(confp, stli_brdsp[i]);
4643#endif 4151 if ((brdp = stli_allocbrd()) == NULL)
4644 if ((brdp = stli_allocbrd()) == (stlibrd_t *) NULL) 4152 return -ENOMEM;
4645 return(-ENOMEM);
4646 brdp->brdnr = i; 4153 brdp->brdnr = i;
4647 brdp->brdtype = confp->brdtype; 4154 brdp->brdtype = confp->brdtype;
4648 brdp->iobase = confp->ioaddr1; 4155 brdp->iobase = confp->ioaddr1;
@@ -4654,9 +4161,7 @@ static int stli_initbrds(void)
4654 * Static configuration table done, so now use dynamic methods to 4161 * Static configuration table done, so now use dynamic methods to
4655 * see if any more boards should be configured. 4162 * see if any more boards should be configured.
4656 */ 4163 */
4657#ifdef MODULE
4658 stli_argbrds(); 4164 stli_argbrds();
4659#endif
4660 if (STLI_EISAPROBE) 4165 if (STLI_EISAPROBE)
4661 stli_findeisabrds(); 4166 stli_findeisabrds();
4662#ifdef CONFIG_PCI 4167#ifdef CONFIG_PCI
@@ -4672,11 +4177,11 @@ static int stli_initbrds(void)
4672 if (stli_nrbrds > 1) { 4177 if (stli_nrbrds > 1) {
4673 for (i = 0; (i < stli_nrbrds); i++) { 4178 for (i = 0; (i < stli_nrbrds); i++) {
4674 brdp = stli_brds[i]; 4179 brdp = stli_brds[i];
4675 if (brdp == (stlibrd_t *) NULL) 4180 if (brdp == NULL)
4676 continue; 4181 continue;
4677 for (j = i + 1; (j < stli_nrbrds); j++) { 4182 for (j = i + 1; (j < stli_nrbrds); j++) {
4678 nxtbrdp = stli_brds[j]; 4183 nxtbrdp = stli_brds[j];
4679 if (nxtbrdp == (stlibrd_t *) NULL) 4184 if (nxtbrdp == NULL)
4680 continue; 4185 continue;
4681 if ((brdp->membase >= nxtbrdp->membase) && 4186 if ((brdp->membase >= nxtbrdp->membase) &&
4682 (brdp->membase <= (nxtbrdp->membase + 4187 (brdp->membase <= (nxtbrdp->membase +
@@ -4691,7 +4196,7 @@ static int stli_initbrds(void)
4691 if (stli_shared == 0) { 4196 if (stli_shared == 0) {
4692 for (i = 0; (i < stli_nrbrds); i++) { 4197 for (i = 0; (i < stli_nrbrds); i++) {
4693 brdp = stli_brds[i]; 4198 brdp = stli_brds[i];
4694 if (brdp == (stlibrd_t *) NULL) 4199 if (brdp == NULL)
4695 continue; 4200 continue;
4696 if (brdp->state & BST_FOUND) { 4201 if (brdp->state & BST_FOUND) {
4697 EBRDENABLE(brdp); 4202 EBRDENABLE(brdp);
@@ -4701,7 +4206,7 @@ static int stli_initbrds(void)
4701 } 4206 }
4702 } 4207 }
4703 4208
4704 return(0); 4209 return 0;
4705} 4210}
4706 4211
4707/*****************************************************************************/ 4212/*****************************************************************************/
@@ -4714,48 +4219,55 @@ static int stli_initbrds(void)
4714 4219
4715static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) 4220static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp)
4716{ 4221{
4717 unsigned long flags; 4222 unsigned long flags;
4718 void *memptr; 4223 void *memptr;
4719 stlibrd_t *brdp; 4224 stlibrd_t *brdp;
4720 int brdnr, size, n; 4225 int brdnr, size, n;
4721 4226 void *p;
4722#ifdef DEBUG 4227 loff_t off = *offp;
4723 printk(KERN_DEBUG "stli_memread(fp=%x,buf=%x,count=%x,offp=%x)\n",
4724 (int) fp, (int) buf, count, (int) offp);
4725#endif
4726 4228
4727 brdnr = iminor(fp->f_dentry->d_inode); 4229 brdnr = iminor(fp->f_dentry->d_inode);
4728 if (brdnr >= stli_nrbrds) 4230 if (brdnr >= stli_nrbrds)
4729 return(-ENODEV); 4231 return -ENODEV;
4730 brdp = stli_brds[brdnr]; 4232 brdp = stli_brds[brdnr];
4731 if (brdp == (stlibrd_t *) NULL) 4233 if (brdp == NULL)
4732 return(-ENODEV); 4234 return -ENODEV;
4733 if (brdp->state == 0) 4235 if (brdp->state == 0)
4734 return(-ENODEV); 4236 return -ENODEV;
4735 if (fp->f_pos >= brdp->memsize) 4237 if (off >= brdp->memsize || off + count < off)
4736 return(0); 4238 return 0;
4737 4239
4738 size = MIN(count, (brdp->memsize - fp->f_pos)); 4240 size = MIN(count, (brdp->memsize - off));
4241
4242 /*
4243 * Copy the data a page at a time
4244 */
4245
4246 p = (void *)__get_free_page(GFP_KERNEL);
4247 if(p == NULL)
4248 return -ENOMEM;
4739 4249
4740 save_flags(flags);
4741 cli();
4742 EBRDENABLE(brdp);
4743 while (size > 0) { 4250 while (size > 0) {
4744 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4251 spin_lock_irqsave(&brd_lock, flags);
4745 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4252 EBRDENABLE(brdp);
4746 if (copy_to_user(buf, memptr, n)) { 4253 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4254 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4255 n = MIN(n, PAGE_SIZE);
4256 memcpy_fromio(p, memptr, n);
4257 EBRDDISABLE(brdp);
4258 spin_unlock_irqrestore(&brd_lock, flags);
4259 if (copy_to_user(buf, p, n)) {
4747 count = -EFAULT; 4260 count = -EFAULT;
4748 goto out; 4261 goto out;
4749 } 4262 }
4750 fp->f_pos += n; 4263 off += n;
4751 buf += n; 4264 buf += n;
4752 size -= n; 4265 size -= n;
4753 } 4266 }
4754out: 4267out:
4755 EBRDDISABLE(brdp); 4268 *offp = off;
4756 restore_flags(flags); 4269 free_page((unsigned long)p);
4757 4270 return count;
4758 return(count);
4759} 4271}
4760 4272
4761/*****************************************************************************/ 4273/*****************************************************************************/
@@ -4764,54 +4276,65 @@ out:
4764 * Code to handle an "staliomem" write operation. This device is the 4276 * Code to handle an "staliomem" write operation. This device is the
4765 * contents of the board shared memory. It is used for down loading 4277 * contents of the board shared memory. It is used for down loading
4766 * the slave image (and debugging :-) 4278 * the slave image (and debugging :-)
4279 *
4280 * FIXME: copy under lock
4767 */ 4281 */
4768 4282
4769static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) 4283static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp)
4770{ 4284{
4771 unsigned long flags; 4285 unsigned long flags;
4772 void *memptr; 4286 void *memptr;
4773 stlibrd_t *brdp; 4287 stlibrd_t *brdp;
4774 char __user *chbuf; 4288 char __user *chbuf;
4775 int brdnr, size, n; 4289 int brdnr, size, n;
4776 4290 void *p;
4777#ifdef DEBUG 4291 loff_t off = *offp;
4778 printk(KERN_DEBUG "stli_memwrite(fp=%x,buf=%x,count=%x,offp=%x)\n",
4779 (int) fp, (int) buf, count, (int) offp);
4780#endif
4781 4292
4782 brdnr = iminor(fp->f_dentry->d_inode); 4293 brdnr = iminor(fp->f_dentry->d_inode);
4294
4783 if (brdnr >= stli_nrbrds) 4295 if (brdnr >= stli_nrbrds)
4784 return(-ENODEV); 4296 return -ENODEV;
4785 brdp = stli_brds[brdnr]; 4297 brdp = stli_brds[brdnr];
4786 if (brdp == (stlibrd_t *) NULL) 4298 if (brdp == NULL)
4787 return(-ENODEV); 4299 return -ENODEV;
4788 if (brdp->state == 0) 4300 if (brdp->state == 0)
4789 return(-ENODEV); 4301 return -ENODEV;
4790 if (fp->f_pos >= brdp->memsize) 4302 if (off >= brdp->memsize || off + count < off)
4791 return(0); 4303 return 0;
4792 4304
4793 chbuf = (char __user *) buf; 4305 chbuf = (char __user *) buf;
4794 size = MIN(count, (brdp->memsize - fp->f_pos)); 4306 size = MIN(count, (brdp->memsize - off));
4307
4308 /*
4309 * Copy the data a page at a time
4310 */
4311
4312 p = (void *)__get_free_page(GFP_KERNEL);
4313 if(p == NULL)
4314 return -ENOMEM;
4795 4315
4796 save_flags(flags);
4797 cli();
4798 EBRDENABLE(brdp);
4799 while (size > 0) { 4316 while (size > 0) {
4800 memptr = (void *) EBRDGETMEMPTR(brdp, fp->f_pos); 4317 n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize)));
4801 n = MIN(size, (brdp->pagesize - (((unsigned long) fp->f_pos) % brdp->pagesize))); 4318 n = MIN(n, PAGE_SIZE);
4802 if (copy_from_user(memptr, chbuf, n)) { 4319 if (copy_from_user(p, chbuf, n)) {
4803 count = -EFAULT; 4320 if (count == 0)
4321 count = -EFAULT;
4804 goto out; 4322 goto out;
4805 } 4323 }
4806 fp->f_pos += n; 4324 spin_lock_irqsave(&brd_lock, flags);
4325 EBRDENABLE(brdp);
4326 memptr = (void *) EBRDGETMEMPTR(brdp, off);
4327 memcpy_toio(memptr, p, n);
4328 EBRDDISABLE(brdp);
4329 spin_unlock_irqrestore(&brd_lock, flags);
4330 off += n;
4807 chbuf += n; 4331 chbuf += n;
4808 size -= n; 4332 size -= n;
4809 } 4333 }
4810out: 4334out:
4811 EBRDDISABLE(brdp); 4335 free_page((unsigned long) p);
4812 restore_flags(flags); 4336 *offp = off;
4813 4337 return count;
4814 return(count);
4815} 4338}
4816 4339
4817/*****************************************************************************/ 4340/*****************************************************************************/
@@ -4822,16 +4345,16 @@ out:
4822 4345
4823static int stli_getbrdstats(combrd_t __user *bp) 4346static int stli_getbrdstats(combrd_t __user *bp)
4824{ 4347{
4825 stlibrd_t *brdp; 4348 stlibrd_t *brdp;
4826 int i; 4349 int i;
4827 4350
4828 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) 4351 if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t)))
4829 return -EFAULT; 4352 return -EFAULT;
4830 if (stli_brdstats.brd >= STL_MAXBRDS) 4353 if (stli_brdstats.brd >= STL_MAXBRDS)
4831 return(-ENODEV); 4354 return -ENODEV;
4832 brdp = stli_brds[stli_brdstats.brd]; 4355 brdp = stli_brds[stli_brdstats.brd];
4833 if (brdp == (stlibrd_t *) NULL) 4356 if (brdp == NULL)
4834 return(-ENODEV); 4357 return -ENODEV;
4835 4358
4836 memset(&stli_brdstats, 0, sizeof(combrd_t)); 4359 memset(&stli_brdstats, 0, sizeof(combrd_t));
4837 stli_brdstats.brd = brdp->brdnr; 4360 stli_brdstats.brd = brdp->brdnr;
@@ -4850,7 +4373,7 @@ static int stli_getbrdstats(combrd_t __user *bp)
4850 4373
4851 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t))) 4374 if (copy_to_user(bp, &stli_brdstats, sizeof(combrd_t)))
4852 return -EFAULT; 4375 return -EFAULT;
4853 return(0); 4376 return 0;
4854} 4377}
4855 4378
4856/*****************************************************************************/ 4379/*****************************************************************************/
@@ -4861,19 +4384,19 @@ static int stli_getbrdstats(combrd_t __user *bp)
4861 4384
4862static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) 4385static stliport_t *stli_getport(int brdnr, int panelnr, int portnr)
4863{ 4386{
4864 stlibrd_t *brdp; 4387 stlibrd_t *brdp;
4865 int i; 4388 int i;
4866 4389
4867 if ((brdnr < 0) || (brdnr >= STL_MAXBRDS)) 4390 if (brdnr < 0 || brdnr >= STL_MAXBRDS)
4868 return((stliport_t *) NULL); 4391 return NULL;
4869 brdp = stli_brds[brdnr]; 4392 brdp = stli_brds[brdnr];
4870 if (brdp == (stlibrd_t *) NULL) 4393 if (brdp == NULL)
4871 return((stliport_t *) NULL); 4394 return NULL;
4872 for (i = 0; (i < panelnr); i++) 4395 for (i = 0; (i < panelnr); i++)
4873 portnr += brdp->panels[i]; 4396 portnr += brdp->panels[i];
4874 if ((portnr < 0) || (portnr >= brdp->nrports)) 4397 if ((portnr < 0) || (portnr >= brdp->nrports))
4875 return((stliport_t *) NULL); 4398 return NULL;
4876 return(brdp->ports[portnr]); 4399 return brdp->ports[portnr];
4877} 4400}
4878 4401
4879/*****************************************************************************/ 4402/*****************************************************************************/
@@ -4892,16 +4415,16 @@ static int stli_portcmdstats(stliport_t *portp)
4892 4415
4893 memset(&stli_comstats, 0, sizeof(comstats_t)); 4416 memset(&stli_comstats, 0, sizeof(comstats_t));
4894 4417
4895 if (portp == (stliport_t *) NULL) 4418 if (portp == NULL)
4896 return(-ENODEV); 4419 return -ENODEV;
4897 brdp = stli_brds[portp->brdnr]; 4420 brdp = stli_brds[portp->brdnr];
4898 if (brdp == (stlibrd_t *) NULL) 4421 if (brdp == NULL)
4899 return(-ENODEV); 4422 return -ENODEV;
4900 4423
4901 if (brdp->state & BST_STARTED) { 4424 if (brdp->state & BST_STARTED) {
4902 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS, 4425 if ((rc = stli_cmdwait(brdp, portp, A_GETSTATS,
4903 &stli_cdkstats, sizeof(asystats_t), 1)) < 0) 4426 &stli_cdkstats, sizeof(asystats_t), 1)) < 0)
4904 return(rc); 4427 return rc;
4905 } else { 4428 } else {
4906 memset(&stli_cdkstats, 0, sizeof(asystats_t)); 4429 memset(&stli_cdkstats, 0, sizeof(asystats_t));
4907 } 4430 }
@@ -4912,13 +4435,12 @@ static int stli_portcmdstats(stliport_t *portp)
4912 stli_comstats.state = portp->state; 4435 stli_comstats.state = portp->state;
4913 stli_comstats.flags = portp->flags; 4436 stli_comstats.flags = portp->flags;
4914 4437
4915 save_flags(flags); 4438 spin_lock_irqsave(&brd_lock, flags);
4916 cli(); 4439 if (portp->tty != NULL) {
4917 if (portp->tty != (struct tty_struct *) NULL) {
4918 if (portp->tty->driver_data == portp) { 4440 if (portp->tty->driver_data == portp) {
4919 stli_comstats.ttystate = portp->tty->flags; 4441 stli_comstats.ttystate = portp->tty->flags;
4920 stli_comstats.rxbuffered = -1 /*portp->tty->flip.count*/; 4442 stli_comstats.rxbuffered = -1;
4921 if (portp->tty->termios != (struct termios *) NULL) { 4443 if (portp->tty->termios != NULL) {
4922 stli_comstats.cflags = portp->tty->termios->c_cflag; 4444 stli_comstats.cflags = portp->tty->termios->c_cflag;
4923 stli_comstats.iflags = portp->tty->termios->c_iflag; 4445 stli_comstats.iflags = portp->tty->termios->c_iflag;
4924 stli_comstats.oflags = portp->tty->termios->c_oflag; 4446 stli_comstats.oflags = portp->tty->termios->c_oflag;
@@ -4926,7 +4448,7 @@ static int stli_portcmdstats(stliport_t *portp)
4926 } 4448 }
4927 } 4449 }
4928 } 4450 }
4929 restore_flags(flags); 4451 spin_unlock_irqrestore(&brd_lock, flags);
4930 4452
4931 stli_comstats.txtotal = stli_cdkstats.txchars; 4453 stli_comstats.txtotal = stli_cdkstats.txchars;
4932 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover; 4454 stli_comstats.rxtotal = stli_cdkstats.rxchars + stli_cdkstats.ringover;
@@ -4948,7 +4470,7 @@ static int stli_portcmdstats(stliport_t *portp)
4948 stli_comstats.hwid = stli_cdkstats.hwid; 4470 stli_comstats.hwid = stli_cdkstats.hwid;
4949 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals); 4471 stli_comstats.signals = stli_mktiocm(stli_cdkstats.signals);
4950 4472
4951 return(0); 4473 return 0;
4952} 4474}
4953 4475
4954/*****************************************************************************/ 4476/*****************************************************************************/
@@ -4961,8 +4483,8 @@ static int stli_portcmdstats(stliport_t *portp)
4961 4483
4962static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) 4484static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4963{ 4485{
4964 stlibrd_t *brdp; 4486 stlibrd_t *brdp;
4965 int rc; 4487 int rc;
4966 4488
4967 if (!portp) { 4489 if (!portp) {
4968 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4490 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -4992,8 +4514,8 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp)
4992 4514
4993static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) 4515static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
4994{ 4516{
4995 stlibrd_t *brdp; 4517 stlibrd_t *brdp;
4996 int rc; 4518 int rc;
4997 4519
4998 if (!portp) { 4520 if (!portp) {
4999 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t))) 4521 if (copy_from_user(&stli_comstats, cp, sizeof(comstats_t)))
@@ -5031,7 +4553,7 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp)
5031 4553
5032static int stli_getportstruct(stliport_t __user *arg) 4554static int stli_getportstruct(stliport_t __user *arg)
5033{ 4555{
5034 stliport_t *portp; 4556 stliport_t *portp;
5035 4557
5036 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) 4558 if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t)))
5037 return -EFAULT; 4559 return -EFAULT;
@@ -5052,7 +4574,7 @@ static int stli_getportstruct(stliport_t __user *arg)
5052 4574
5053static int stli_getbrdstruct(stlibrd_t __user *arg) 4575static int stli_getbrdstruct(stlibrd_t __user *arg)
5054{ 4576{
5055 stlibrd_t *brdp; 4577 stlibrd_t *brdp;
5056 4578
5057 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) 4579 if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t)))
5058 return -EFAULT; 4580 return -EFAULT;
@@ -5076,15 +4598,10 @@ static int stli_getbrdstruct(stlibrd_t __user *arg)
5076 4598
5077static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) 4599static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg)
5078{ 4600{
5079 stlibrd_t *brdp; 4601 stlibrd_t *brdp;
5080 int brdnr, rc, done; 4602 int brdnr, rc, done;
5081 void __user *argp = (void __user *)arg; 4603 void __user *argp = (void __user *)arg;
5082 4604
5083#ifdef DEBUG
5084 printk(KERN_DEBUG "stli_memioctl(ip=%x,fp=%x,cmd=%x,arg=%x)\n",
5085 (int) ip, (int) fp, cmd, (int) arg);
5086#endif
5087
5088/* 4605/*
5089 * First up handle the board independent ioctls. 4606 * First up handle the board independent ioctls.
5090 */ 4607 */
@@ -5115,7 +4632,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5115 } 4632 }
5116 4633
5117 if (done) 4634 if (done)
5118 return(rc); 4635 return rc;
5119 4636
5120/* 4637/*
5121 * Now handle the board specific ioctls. These all depend on the 4638 * 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 */ 4640 */
5124 brdnr = iminor(ip); 4641 brdnr = iminor(ip);
5125 if (brdnr >= STL_MAXBRDS) 4642 if (brdnr >= STL_MAXBRDS)
5126 return(-ENODEV); 4643 return -ENODEV;
5127 brdp = stli_brds[brdnr]; 4644 brdp = stli_brds[brdnr];
5128 if (!brdp) 4645 if (!brdp)
5129 return(-ENODEV); 4646 return -ENODEV;
5130 if (brdp->state == 0) 4647 if (brdp->state == 0)
5131 return(-ENODEV); 4648 return -ENODEV;
5132 4649
5133 switch (cmd) { 4650 switch (cmd) {
5134 case STL_BINTR: 4651 case STL_BINTR:
@@ -5152,8 +4669,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
5152 rc = -ENOIOCTLCMD; 4669 rc = -ENOIOCTLCMD;
5153 break; 4670 break;
5154 } 4671 }
5155 4672 return rc;
5156 return(rc);
5157} 4673}
5158 4674
5159static struct tty_operations stli_ops = { 4675static struct tty_operations stli_ops = {
@@ -5187,6 +4703,9 @@ int __init stli_init(void)
5187 int i; 4703 int i;
5188 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); 4704 printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion);
5189 4705
4706 spin_lock_init(&stli_lock);
4707 spin_lock_init(&brd_lock);
4708
5190 stli_initbrds(); 4709 stli_initbrds();
5191 4710
5192 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); 4711 stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS);
@@ -5196,10 +4715,6 @@ int __init stli_init(void)
5196/* 4715/*
5197 * Allocate a temporary write buffer. 4716 * Allocate a temporary write buffer.
5198 */ 4717 */
5199 stli_tmpwritebuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5200 if (!stli_tmpwritebuf)
5201 printk(KERN_ERR "STALLION: failed to allocate memory "
5202 "(size=%d)\n", STLI_TXBUFSIZE);
5203 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); 4718 stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL);
5204 if (!stli_txcookbuf) 4719 if (!stli_txcookbuf)
5205 printk(KERN_ERR "STALLION: failed to allocate memory " 4720 printk(KERN_ERR "STALLION: failed to allocate memory "
@@ -5243,7 +4758,7 @@ int __init stli_init(void)
5243 printk(KERN_ERR "STALLION: failed to register serial driver\n"); 4758 printk(KERN_ERR "STALLION: failed to register serial driver\n");
5244 return -EBUSY; 4759 return -EBUSY;
5245 } 4760 }
5246 return(0); 4761 return 0;
5247} 4762}
5248 4763
5249/*****************************************************************************/ 4764/*****************************************************************************/