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