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