diff options
Diffstat (limited to 'drivers/char/istallion.c')
-rw-r--r-- | drivers/char/istallion.c | 1214 |
1 files changed, 579 insertions, 635 deletions
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 8c09997cc3d6..68645d351873 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -14,14 +14,6 @@ | |||
14 | * the Free Software Foundation; either version 2 of the License, or | 14 | * the Free Software Foundation; either version 2 of the License, or |
15 | * (at your option) any later version. | 15 | * (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
25 | */ | 17 | */ |
26 | 18 | ||
27 | /*****************************************************************************/ | 19 | /*****************************************************************************/ |
@@ -41,6 +33,7 @@ | |||
41 | #include <linux/device.h> | 33 | #include <linux/device.h> |
42 | #include <linux/wait.h> | 34 | #include <linux/wait.h> |
43 | #include <linux/eisa.h> | 35 | #include <linux/eisa.h> |
36 | #include <linux/ctype.h> | ||
44 | 37 | ||
45 | #include <asm/io.h> | 38 | #include <asm/io.h> |
46 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
@@ -61,21 +54,10 @@ | |||
61 | #define BRD_BRUMBY4 2 | 54 | #define BRD_BRUMBY4 2 |
62 | #define BRD_ONBOARD2 3 | 55 | #define BRD_ONBOARD2 3 |
63 | #define BRD_ONBOARD 4 | 56 | #define BRD_ONBOARD 4 |
64 | #define BRD_BRUMBY8 5 | ||
65 | #define BRD_BRUMBY16 6 | ||
66 | #define BRD_ONBOARDE 7 | 57 | #define BRD_ONBOARDE 7 |
67 | #define BRD_ONBOARD32 9 | ||
68 | #define BRD_ONBOARD2_32 10 | ||
69 | #define BRD_ONBOARDRS 11 | ||
70 | #define BRD_EASYIO 20 | ||
71 | #define BRD_ECH 21 | ||
72 | #define BRD_ECHMC 22 | ||
73 | #define BRD_ECP 23 | 58 | #define BRD_ECP 23 |
74 | #define BRD_ECPE 24 | 59 | #define BRD_ECPE 24 |
75 | #define BRD_ECPMC 25 | 60 | #define BRD_ECPMC 25 |
76 | #define BRD_ECHPCI 26 | ||
77 | #define BRD_ECH64PCI 27 | ||
78 | #define BRD_EASYIOPCI 28 | ||
79 | #define BRD_ECPPCI 29 | 61 | #define BRD_ECPPCI 29 |
80 | 62 | ||
81 | #define BRD_BRUMBY BRD_BRUMBY4 | 63 | #define BRD_BRUMBY BRD_BRUMBY4 |
@@ -119,20 +101,16 @@ | |||
119 | * interrupt is required. | 101 | * interrupt is required. |
120 | */ | 102 | */ |
121 | 103 | ||
122 | typedef struct { | 104 | struct stlconf { |
123 | int brdtype; | 105 | int brdtype; |
124 | int ioaddr1; | 106 | int ioaddr1; |
125 | int ioaddr2; | 107 | int ioaddr2; |
126 | unsigned long memaddr; | 108 | unsigned long memaddr; |
127 | int irq; | 109 | int irq; |
128 | int irqtype; | 110 | int irqtype; |
129 | } stlconf_t; | ||
130 | |||
131 | static stlconf_t stli_brdconf[] = { | ||
132 | /*{ BRD_ECP, 0x2a0, 0, 0xcc000, 0, 0 },*/ | ||
133 | }; | 111 | }; |
134 | 112 | ||
135 | static int stli_nrbrds = ARRAY_SIZE(stli_brdconf); | 113 | static unsigned int stli_nrbrds; |
136 | 114 | ||
137 | /* stli_lock must NOT be taken holding brd_lock */ | 115 | /* stli_lock must NOT be taken holding brd_lock */ |
138 | static spinlock_t stli_lock; /* TTY logic lock */ | 116 | static spinlock_t stli_lock; /* TTY logic lock */ |
@@ -194,9 +172,11 @@ static struct tty_struct *stli_txcooktty; | |||
194 | * with this termios initially. Basically all it defines is a raw port | 172 | * with this termios initially. Basically all it defines is a raw port |
195 | * at 9600 baud, 8 data bits, no parity, 1 stop bit. | 173 | * at 9600 baud, 8 data bits, no parity, 1 stop bit. |
196 | */ | 174 | */ |
197 | static struct termios stli_deftermios = { | 175 | static struct ktermios stli_deftermios = { |
198 | .c_cflag = (B9600 | CS8 | CREAD | HUPCL | CLOCAL), | 176 | .c_cflag = (B9600 | CS8 | CREAD | HUPCL | CLOCAL), |
199 | .c_cc = INIT_C_CC, | 177 | .c_cc = INIT_C_CC, |
178 | .c_ispeed = 9600, | ||
179 | .c_ospeed = 9600, | ||
200 | }; | 180 | }; |
201 | 181 | ||
202 | /* | 182 | /* |
@@ -205,13 +185,12 @@ static struct termios stli_deftermios = { | |||
205 | */ | 185 | */ |
206 | static comstats_t stli_comstats; | 186 | static comstats_t stli_comstats; |
207 | static combrd_t stli_brdstats; | 187 | static combrd_t stli_brdstats; |
208 | static asystats_t stli_cdkstats; | 188 | static struct asystats stli_cdkstats; |
209 | static stlibrd_t stli_dummybrd; | ||
210 | static stliport_t stli_dummyport; | ||
211 | 189 | ||
212 | /*****************************************************************************/ | 190 | /*****************************************************************************/ |
213 | 191 | ||
214 | static stlibrd_t *stli_brds[STL_MAXBRDS]; | 192 | static DEFINE_MUTEX(stli_brdslock); |
193 | static struct stlibrd *stli_brds[STL_MAXBRDS]; | ||
215 | 194 | ||
216 | static int stli_shared; | 195 | static int stli_shared; |
217 | 196 | ||
@@ -223,6 +202,7 @@ static int stli_shared; | |||
223 | */ | 202 | */ |
224 | #define BST_FOUND 0x1 | 203 | #define BST_FOUND 0x1 |
225 | #define BST_STARTED 0x2 | 204 | #define BST_STARTED 0x2 |
205 | #define BST_PROBED 0x4 | ||
226 | 206 | ||
227 | /* | 207 | /* |
228 | * Define the set of port state flags. These are marked for internal | 208 | * Define the set of port state flags. These are marked for internal |
@@ -255,18 +235,18 @@ static char *stli_brdnames[] = { | |||
255 | "Brumby", | 235 | "Brumby", |
256 | "Brumby", | 236 | "Brumby", |
257 | "ONboard-EI", | 237 | "ONboard-EI", |
258 | (char *) NULL, | 238 | NULL, |
259 | "ONboard", | 239 | "ONboard", |
260 | "ONboard-MC", | 240 | "ONboard-MC", |
261 | "ONboard-MC", | 241 | "ONboard-MC", |
262 | (char *) NULL, | 242 | NULL, |
263 | (char *) NULL, | 243 | NULL, |
264 | (char *) NULL, | 244 | NULL, |
265 | (char *) NULL, | 245 | NULL, |
266 | (char *) NULL, | 246 | NULL, |
267 | (char *) NULL, | 247 | NULL, |
268 | (char *) NULL, | 248 | NULL, |
269 | (char *) NULL, | 249 | NULL, |
270 | "EasyIO", | 250 | "EasyIO", |
271 | "EC8/32-AT", | 251 | "EC8/32-AT", |
272 | "EC8/32-MC", | 252 | "EC8/32-MC", |
@@ -304,12 +284,10 @@ static char **stli_brdsp[] = { | |||
304 | * parse any module arguments. | 284 | * parse any module arguments. |
305 | */ | 285 | */ |
306 | 286 | ||
307 | typedef struct stlibrdtype { | 287 | static struct stlibrdtype { |
308 | char *name; | 288 | char *name; |
309 | int type; | 289 | int type; |
310 | } stlibrdtype_t; | 290 | } stli_brdstr[] = { |
311 | |||
312 | static stlibrdtype_t stli_brdstr[] = { | ||
313 | { "stallion", BRD_STALLION }, | 291 | { "stallion", BRD_STALLION }, |
314 | { "1", BRD_STALLION }, | 292 | { "1", BRD_STALLION }, |
315 | { "brumby", BRD_BRUMBY }, | 293 | { "brumby", BRD_BRUMBY }, |
@@ -379,6 +357,7 @@ MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]"); | |||
379 | module_param_array(board3, charp, NULL, 0); | 357 | module_param_array(board3, charp, NULL, 0); |
380 | MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]"); | 358 | MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]"); |
381 | 359 | ||
360 | #if STLI_EISAPROBE != 0 | ||
382 | /* | 361 | /* |
383 | * Set up a default memory address table for EISA board probing. | 362 | * Set up a default memory address table for EISA board probing. |
384 | * The default addresses are all bellow 1Mbyte, which has to be the | 363 | * The default addresses are all bellow 1Mbyte, which has to be the |
@@ -396,14 +375,11 @@ static unsigned long stli_eisamemprobeaddrs[] = { | |||
396 | }; | 375 | }; |
397 | 376 | ||
398 | static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); | 377 | static int stli_eisamempsize = ARRAY_SIZE(stli_eisamemprobeaddrs); |
378 | #endif | ||
399 | 379 | ||
400 | /* | 380 | /* |
401 | * Define the Stallion PCI vendor and device IDs. | 381 | * Define the Stallion PCI vendor and device IDs. |
402 | */ | 382 | */ |
403 | #ifdef CONFIG_PCI | ||
404 | #ifndef PCI_VENDOR_ID_STALLION | ||
405 | #define PCI_VENDOR_ID_STALLION 0x124d | ||
406 | #endif | ||
407 | #ifndef PCI_DEVICE_ID_ECRA | 383 | #ifndef PCI_DEVICE_ID_ECRA |
408 | #define PCI_DEVICE_ID_ECRA 0x0004 | 384 | #define PCI_DEVICE_ID_ECRA 0x0004 |
409 | #endif | 385 | #endif |
@@ -414,7 +390,7 @@ static struct pci_device_id istallion_pci_tbl[] = { | |||
414 | }; | 390 | }; |
415 | MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); | 391 | MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); |
416 | 392 | ||
417 | #endif /* CONFIG_PCI */ | 393 | static struct pci_driver stli_pcidriver; |
418 | 394 | ||
419 | /*****************************************************************************/ | 395 | /*****************************************************************************/ |
420 | 396 | ||
@@ -612,35 +588,13 @@ MODULE_DEVICE_TABLE(pci, istallion_pci_tbl); | |||
612 | #define MINOR2BRD(min) (((min) & 0xc0) >> 6) | 588 | #define MINOR2BRD(min) (((min) & 0xc0) >> 6) |
613 | #define MINOR2PORT(min) ((min) & 0x3f) | 589 | #define MINOR2PORT(min) ((min) & 0x3f) |
614 | 590 | ||
615 | /* | ||
616 | * Define a baud rate table that converts termios baud rate selector | ||
617 | * into the actual baud rate value. All baud rate calculations are based | ||
618 | * on the actual baud rate required. | ||
619 | */ | ||
620 | static unsigned int stli_baudrates[] = { | ||
621 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, | ||
622 | 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 | ||
623 | }; | ||
624 | |||
625 | /*****************************************************************************/ | ||
626 | |||
627 | /* | ||
628 | * Define some handy local macros... | ||
629 | */ | ||
630 | #undef MIN | ||
631 | #define MIN(a,b) (((a) <= (b)) ? (a) : (b)) | ||
632 | |||
633 | #undef TOLOWER | ||
634 | #define TOLOWER(x) ((((x) >= 'A') && ((x) <= 'Z')) ? ((x) + 0x20) : (x)) | ||
635 | |||
636 | /*****************************************************************************/ | 591 | /*****************************************************************************/ |
637 | 592 | ||
638 | /* | 593 | /* |
639 | * Prototype all functions in this driver! | 594 | * Prototype all functions in this driver! |
640 | */ | 595 | */ |
641 | 596 | ||
642 | static int stli_parsebrd(stlconf_t *confp, char **argp); | 597 | static int stli_parsebrd(struct stlconf *confp, char **argp); |
643 | static int stli_init(void); | ||
644 | static int stli_open(struct tty_struct *tty, struct file *filp); | 598 | static int stli_open(struct tty_struct *tty, struct file *filp); |
645 | static void stli_close(struct tty_struct *tty, struct file *filp); | 599 | static void stli_close(struct tty_struct *tty, struct file *filp); |
646 | static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count); | 600 | static int stli_write(struct tty_struct *tty, const unsigned char *buf, int count); |
@@ -649,7 +603,7 @@ static void stli_flushchars(struct tty_struct *tty); | |||
649 | static int stli_writeroom(struct tty_struct *tty); | 603 | static int stli_writeroom(struct tty_struct *tty); |
650 | static int stli_charsinbuffer(struct tty_struct *tty); | 604 | static int stli_charsinbuffer(struct tty_struct *tty); |
651 | static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); | 605 | static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); |
652 | static void stli_settermios(struct tty_struct *tty, struct termios *old); | 606 | static void stli_settermios(struct tty_struct *tty, struct ktermios *old); |
653 | static void stli_throttle(struct tty_struct *tty); | 607 | static void stli_throttle(struct tty_struct *tty); |
654 | static void stli_unthrottle(struct tty_struct *tty); | 608 | static void stli_unthrottle(struct tty_struct *tty); |
655 | static void stli_stop(struct tty_struct *tty); | 609 | static void stli_stop(struct tty_struct *tty); |
@@ -659,86 +613,84 @@ static void stli_breakctl(struct tty_struct *tty, int state); | |||
659 | static void stli_waituntilsent(struct tty_struct *tty, int timeout); | 613 | static void stli_waituntilsent(struct tty_struct *tty, int timeout); |
660 | static void stli_sendxchar(struct tty_struct *tty, char ch); | 614 | static void stli_sendxchar(struct tty_struct *tty, char ch); |
661 | static void stli_hangup(struct tty_struct *tty); | 615 | static void stli_hangup(struct tty_struct *tty); |
662 | static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos); | 616 | static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos); |
663 | 617 | ||
664 | static int stli_brdinit(stlibrd_t *brdp); | 618 | static int stli_brdinit(struct stlibrd *brdp); |
665 | static int stli_startbrd(stlibrd_t *brdp); | 619 | static int stli_startbrd(struct stlibrd *brdp); |
666 | static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); | 620 | static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp); |
667 | static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); | 621 | static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp); |
668 | static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); | 622 | static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg); |
669 | static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp); | 623 | static void stli_brdpoll(struct stlibrd *brdp, cdkhdr_t __iomem *hdrp); |
670 | static void stli_poll(unsigned long arg); | 624 | static void stli_poll(unsigned long arg); |
671 | static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp); | 625 | static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp); |
672 | static int stli_initopen(stlibrd_t *brdp, stliport_t *portp); | 626 | static int stli_initopen(struct stlibrd *brdp, struct stliport *portp); |
673 | static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); | 627 | static int stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); |
674 | static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); | 628 | static int stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); |
675 | static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp); | 629 | static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct file *filp); |
676 | static void stli_dohangup(void *arg); | 630 | static void stli_dohangup(struct work_struct *); |
677 | static int stli_setport(stliport_t *portp); | 631 | static int stli_setport(struct stliport *portp); |
678 | static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); | 632 | static int stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); |
679 | static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); | 633 | static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); |
680 | static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); | 634 | static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); |
681 | static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp); | 635 | static void stli_dodelaycmd(struct stliport *portp, cdkctrl_t __iomem *cp); |
682 | static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp); | 636 | static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermios *tiosp); |
683 | static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); | 637 | static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); |
684 | static long stli_mktiocm(unsigned long sigvalue); | 638 | static long stli_mktiocm(unsigned long sigvalue); |
685 | static void stli_read(stlibrd_t *brdp, stliport_t *portp); | 639 | static void stli_read(struct stlibrd *brdp, struct stliport *portp); |
686 | static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp); | 640 | static int stli_getserial(struct stliport *portp, struct serial_struct __user *sp); |
687 | static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp); | 641 | static int stli_setserial(struct stliport *portp, struct serial_struct __user *sp); |
688 | static int stli_getbrdstats(combrd_t __user *bp); | 642 | static int stli_getbrdstats(combrd_t __user *bp); |
689 | static int stli_getportstats(stliport_t *portp, comstats_t __user *cp); | 643 | static int stli_getportstats(struct stliport *portp, comstats_t __user *cp); |
690 | static int stli_portcmdstats(stliport_t *portp); | 644 | static int stli_portcmdstats(struct stliport *portp); |
691 | static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp); | 645 | static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp); |
692 | static int stli_getportstruct(stliport_t __user *arg); | 646 | static int stli_getportstruct(struct stliport __user *arg); |
693 | static int stli_getbrdstruct(stlibrd_t __user *arg); | 647 | static int stli_getbrdstruct(struct stlibrd __user *arg); |
694 | static stlibrd_t *stli_allocbrd(void); | 648 | static struct stlibrd *stli_allocbrd(void); |
695 | 649 | ||
696 | static void stli_ecpinit(stlibrd_t *brdp); | 650 | static void stli_ecpinit(struct stlibrd *brdp); |
697 | static void stli_ecpenable(stlibrd_t *brdp); | 651 | static void stli_ecpenable(struct stlibrd *brdp); |
698 | static void stli_ecpdisable(stlibrd_t *brdp); | 652 | static void stli_ecpdisable(struct stlibrd *brdp); |
699 | static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 653 | static void __iomem *stli_ecpgetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
700 | static void stli_ecpreset(stlibrd_t *brdp); | 654 | static void stli_ecpreset(struct stlibrd *brdp); |
701 | static void stli_ecpintr(stlibrd_t *brdp); | 655 | static void stli_ecpintr(struct stlibrd *brdp); |
702 | static void stli_ecpeiinit(stlibrd_t *brdp); | 656 | static void stli_ecpeiinit(struct stlibrd *brdp); |
703 | static void stli_ecpeienable(stlibrd_t *brdp); | 657 | static void stli_ecpeienable(struct stlibrd *brdp); |
704 | static void stli_ecpeidisable(stlibrd_t *brdp); | 658 | static void stli_ecpeidisable(struct stlibrd *brdp); |
705 | static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 659 | static void __iomem *stli_ecpeigetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
706 | static void stli_ecpeireset(stlibrd_t *brdp); | 660 | static void stli_ecpeireset(struct stlibrd *brdp); |
707 | static void stli_ecpmcenable(stlibrd_t *brdp); | 661 | static void stli_ecpmcenable(struct stlibrd *brdp); |
708 | static void stli_ecpmcdisable(stlibrd_t *brdp); | 662 | static void stli_ecpmcdisable(struct stlibrd *brdp); |
709 | static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 663 | static void __iomem *stli_ecpmcgetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
710 | static void stli_ecpmcreset(stlibrd_t *brdp); | 664 | static void stli_ecpmcreset(struct stlibrd *brdp); |
711 | static void stli_ecppciinit(stlibrd_t *brdp); | 665 | static void stli_ecppciinit(struct stlibrd *brdp); |
712 | static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 666 | static void __iomem *stli_ecppcigetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
713 | static void stli_ecppcireset(stlibrd_t *brdp); | 667 | static void stli_ecppcireset(struct stlibrd *brdp); |
714 | 668 | ||
715 | static void stli_onbinit(stlibrd_t *brdp); | 669 | static void stli_onbinit(struct stlibrd *brdp); |
716 | static void stli_onbenable(stlibrd_t *brdp); | 670 | static void stli_onbenable(struct stlibrd *brdp); |
717 | static void stli_onbdisable(stlibrd_t *brdp); | 671 | static void stli_onbdisable(struct stlibrd *brdp); |
718 | static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 672 | static void __iomem *stli_onbgetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
719 | static void stli_onbreset(stlibrd_t *brdp); | 673 | static void stli_onbreset(struct stlibrd *brdp); |
720 | static void stli_onbeinit(stlibrd_t *brdp); | 674 | static void stli_onbeinit(struct stlibrd *brdp); |
721 | static void stli_onbeenable(stlibrd_t *brdp); | 675 | static void stli_onbeenable(struct stlibrd *brdp); |
722 | static void stli_onbedisable(stlibrd_t *brdp); | 676 | static void stli_onbedisable(struct stlibrd *brdp); |
723 | static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 677 | static void __iomem *stli_onbegetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
724 | static void stli_onbereset(stlibrd_t *brdp); | 678 | static void stli_onbereset(struct stlibrd *brdp); |
725 | static void stli_bbyinit(stlibrd_t *brdp); | 679 | static void stli_bbyinit(struct stlibrd *brdp); |
726 | static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 680 | static void __iomem *stli_bbygetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
727 | static void stli_bbyreset(stlibrd_t *brdp); | 681 | static void stli_bbyreset(struct stlibrd *brdp); |
728 | static void stli_stalinit(stlibrd_t *brdp); | 682 | static void stli_stalinit(struct stlibrd *brdp); |
729 | static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line); | 683 | static void __iomem *stli_stalgetmemptr(struct stlibrd *brdp, unsigned long offset, int line); |
730 | static void stli_stalreset(stlibrd_t *brdp); | 684 | static void stli_stalreset(struct stlibrd *brdp); |
731 | 685 | ||
732 | static stliport_t *stli_getport(int brdnr, int panelnr, int portnr); | 686 | static struct stliport *stli_getport(unsigned int brdnr, unsigned int panelnr, unsigned int portnr); |
733 | 687 | ||
734 | static int stli_initecp(stlibrd_t *brdp); | 688 | static int stli_initecp(struct stlibrd *brdp); |
735 | static int stli_initonb(stlibrd_t *brdp); | 689 | static int stli_initonb(struct stlibrd *brdp); |
736 | static int stli_eisamemprobe(stlibrd_t *brdp); | 690 | #if STLI_EISAPROBE != 0 |
737 | static int stli_initports(stlibrd_t *brdp); | 691 | static int stli_eisamemprobe(struct stlibrd *brdp); |
738 | |||
739 | #ifdef CONFIG_PCI | ||
740 | static int stli_initpcibrd(int brdtype, struct pci_dev *devp); | ||
741 | #endif | 692 | #endif |
693 | static int stli_initports(struct stlibrd *brdp); | ||
742 | 694 | ||
743 | /*****************************************************************************/ | 695 | /*****************************************************************************/ |
744 | 696 | ||
@@ -776,154 +728,37 @@ static int stli_timeron; | |||
776 | 728 | ||
777 | static struct class *istallion_class; | 729 | static struct class *istallion_class; |
778 | 730 | ||
779 | /* | 731 | static void stli_cleanup_ports(struct stlibrd *brdp) |
780 | * Loadable module initialization stuff. | ||
781 | */ | ||
782 | |||
783 | static int __init istallion_module_init(void) | ||
784 | { | 732 | { |
785 | stli_init(); | 733 | struct stliport *portp; |
786 | return 0; | 734 | unsigned int j; |
787 | } | 735 | |
788 | 736 | for (j = 0; j < STL_MAXPORTS; j++) { | |
789 | /*****************************************************************************/ | 737 | portp = brdp->ports[j]; |
790 | 738 | if (portp != NULL) { | |
791 | static void __exit istallion_module_exit(void) | 739 | if (portp->tty != NULL) |
792 | { | 740 | tty_hangup(portp->tty); |
793 | stlibrd_t *brdp; | 741 | kfree(portp); |
794 | stliport_t *portp; | ||
795 | int i, j; | ||
796 | |||
797 | printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, | ||
798 | stli_drvversion); | ||
799 | |||
800 | /* | ||
801 | * Free up all allocated resources used by the ports. This includes | ||
802 | * memory and interrupts. | ||
803 | */ | ||
804 | if (stli_timeron) { | ||
805 | stli_timeron = 0; | ||
806 | del_timer_sync(&stli_timerlist); | ||
807 | } | ||
808 | |||
809 | i = tty_unregister_driver(stli_serial); | ||
810 | if (i) { | ||
811 | printk("STALLION: failed to un-register tty driver, " | ||
812 | "errno=%d\n", -i); | ||
813 | return; | ||
814 | } | ||
815 | put_tty_driver(stli_serial); | ||
816 | for (i = 0; i < 4; i++) | ||
817 | class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, i)); | ||
818 | class_destroy(istallion_class); | ||
819 | if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"))) | ||
820 | printk("STALLION: failed to un-register serial memory device, " | ||
821 | "errno=%d\n", -i); | ||
822 | |||
823 | kfree(stli_txcookbuf); | ||
824 | |||
825 | for (i = 0; (i < stli_nrbrds); i++) { | ||
826 | if ((brdp = stli_brds[i]) == NULL) | ||
827 | continue; | ||
828 | for (j = 0; (j < STL_MAXPORTS); j++) { | ||
829 | portp = brdp->ports[j]; | ||
830 | if (portp != NULL) { | ||
831 | if (portp->tty != NULL) | ||
832 | tty_hangup(portp->tty); | ||
833 | kfree(portp); | ||
834 | } | ||
835 | } | 742 | } |
836 | |||
837 | iounmap(brdp->membase); | ||
838 | if (brdp->iosize > 0) | ||
839 | release_region(brdp->iobase, brdp->iosize); | ||
840 | kfree(brdp); | ||
841 | stli_brds[i] = NULL; | ||
842 | } | 743 | } |
843 | } | 744 | } |
844 | 745 | ||
845 | module_init(istallion_module_init); | ||
846 | module_exit(istallion_module_exit); | ||
847 | |||
848 | /*****************************************************************************/ | ||
849 | |||
850 | /* | ||
851 | * Check for any arguments passed in on the module load command line. | ||
852 | */ | ||
853 | |||
854 | static void stli_argbrds(void) | ||
855 | { | ||
856 | stlconf_t conf; | ||
857 | stlibrd_t *brdp; | ||
858 | int i; | ||
859 | |||
860 | for (i = stli_nrbrds; i < ARRAY_SIZE(stli_brdsp); i++) { | ||
861 | memset(&conf, 0, sizeof(conf)); | ||
862 | if (stli_parsebrd(&conf, stli_brdsp[i]) == 0) | ||
863 | continue; | ||
864 | if ((brdp = stli_allocbrd()) == NULL) | ||
865 | continue; | ||
866 | stli_nrbrds = i + 1; | ||
867 | brdp->brdnr = i; | ||
868 | brdp->brdtype = conf.brdtype; | ||
869 | brdp->iobase = conf.ioaddr1; | ||
870 | brdp->memaddr = conf.memaddr; | ||
871 | stli_brdinit(brdp); | ||
872 | } | ||
873 | } | ||
874 | |||
875 | /*****************************************************************************/ | ||
876 | |||
877 | /* | ||
878 | * Convert an ascii string number into an unsigned long. | ||
879 | */ | ||
880 | |||
881 | static unsigned long stli_atol(char *str) | ||
882 | { | ||
883 | unsigned long val; | ||
884 | int base, c; | ||
885 | char *sp; | ||
886 | |||
887 | val = 0; | ||
888 | sp = str; | ||
889 | if ((*sp == '0') && (*(sp+1) == 'x')) { | ||
890 | base = 16; | ||
891 | sp += 2; | ||
892 | } else if (*sp == '0') { | ||
893 | base = 8; | ||
894 | sp++; | ||
895 | } else { | ||
896 | base = 10; | ||
897 | } | ||
898 | |||
899 | for (; (*sp != 0); sp++) { | ||
900 | c = (*sp > '9') ? (TOLOWER(*sp) - 'a' + 10) : (*sp - '0'); | ||
901 | if ((c < 0) || (c >= base)) { | ||
902 | printk("STALLION: invalid argument %s\n", str); | ||
903 | val = 0; | ||
904 | break; | ||
905 | } | ||
906 | val = (val * base) + c; | ||
907 | } | ||
908 | return(val); | ||
909 | } | ||
910 | |||
911 | /*****************************************************************************/ | 746 | /*****************************************************************************/ |
912 | 747 | ||
913 | /* | 748 | /* |
914 | * Parse the supplied argument string, into the board conf struct. | 749 | * Parse the supplied argument string, into the board conf struct. |
915 | */ | 750 | */ |
916 | 751 | ||
917 | static int stli_parsebrd(stlconf_t *confp, char **argp) | 752 | static int stli_parsebrd(struct stlconf *confp, char **argp) |
918 | { | 753 | { |
754 | unsigned int i; | ||
919 | char *sp; | 755 | char *sp; |
920 | int i; | ||
921 | 756 | ||
922 | if (argp[0] == NULL || *argp[0] == 0) | 757 | if (argp[0] == NULL || *argp[0] == 0) |
923 | return 0; | 758 | return 0; |
924 | 759 | ||
925 | for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) | 760 | for (sp = argp[0], i = 0; ((*sp != 0) && (i < 25)); sp++, i++) |
926 | *sp = TOLOWER(*sp); | 761 | *sp = tolower(*sp); |
927 | 762 | ||
928 | for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) { | 763 | for (i = 0; i < ARRAY_SIZE(stli_brdstr); i++) { |
929 | if (strcmp(stli_brdstr[i].name, argp[0]) == 0) | 764 | if (strcmp(stli_brdstr[i].name, argp[0]) == 0) |
@@ -936,9 +771,9 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) | |||
936 | 771 | ||
937 | confp->brdtype = stli_brdstr[i].type; | 772 | confp->brdtype = stli_brdstr[i].type; |
938 | if (argp[1] != NULL && *argp[1] != 0) | 773 | if (argp[1] != NULL && *argp[1] != 0) |
939 | confp->ioaddr1 = stli_atol(argp[1]); | 774 | confp->ioaddr1 = simple_strtoul(argp[1], NULL, 0); |
940 | if (argp[2] != NULL && *argp[2] != 0) | 775 | if (argp[2] != NULL && *argp[2] != 0) |
941 | confp->memaddr = stli_atol(argp[2]); | 776 | confp->memaddr = simple_strtoul(argp[2], NULL, 0); |
942 | return(1); | 777 | return(1); |
943 | } | 778 | } |
944 | 779 | ||
@@ -946,10 +781,10 @@ static int stli_parsebrd(stlconf_t *confp, char **argp) | |||
946 | 781 | ||
947 | static int stli_open(struct tty_struct *tty, struct file *filp) | 782 | static int stli_open(struct tty_struct *tty, struct file *filp) |
948 | { | 783 | { |
949 | stlibrd_t *brdp; | 784 | struct stlibrd *brdp; |
950 | stliport_t *portp; | 785 | struct stliport *portp; |
951 | unsigned int minordev; | 786 | unsigned int minordev, brdnr, portnr; |
952 | int brdnr, portnr, rc; | 787 | int rc; |
953 | 788 | ||
954 | minordev = tty->index; | 789 | minordev = tty->index; |
955 | brdnr = MINOR2BRD(minordev); | 790 | brdnr = MINOR2BRD(minordev); |
@@ -961,7 +796,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
961 | if ((brdp->state & BST_STARTED) == 0) | 796 | if ((brdp->state & BST_STARTED) == 0) |
962 | return -ENODEV; | 797 | return -ENODEV; |
963 | portnr = MINOR2PORT(minordev); | 798 | portnr = MINOR2PORT(minordev); |
964 | if ((portnr < 0) || (portnr > brdp->nrports)) | 799 | if (portnr > brdp->nrports) |
965 | return -ENODEV; | 800 | return -ENODEV; |
966 | 801 | ||
967 | portp = brdp->ports[portnr]; | 802 | portp = brdp->ports[portnr]; |
@@ -1041,8 +876,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
1041 | 876 | ||
1042 | static void stli_close(struct tty_struct *tty, struct file *filp) | 877 | static void stli_close(struct tty_struct *tty, struct file *filp) |
1043 | { | 878 | { |
1044 | stlibrd_t *brdp; | 879 | struct stlibrd *brdp; |
1045 | stliport_t *portp; | 880 | struct stliport *portp; |
1046 | unsigned long flags; | 881 | unsigned long flags; |
1047 | 882 | ||
1048 | portp = tty->driver_data; | 883 | portp = tty->driver_data; |
@@ -1119,7 +954,7 @@ static void stli_close(struct tty_struct *tty, struct file *filp) | |||
1119 | * this still all happens pretty quickly. | 954 | * this still all happens pretty quickly. |
1120 | */ | 955 | */ |
1121 | 956 | ||
1122 | static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) | 957 | static int stli_initopen(struct stlibrd *brdp, struct stliport *portp) |
1123 | { | 958 | { |
1124 | struct tty_struct *tty; | 959 | struct tty_struct *tty; |
1125 | asynotify_t nt; | 960 | asynotify_t nt; |
@@ -1167,7 +1002,7 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp) | |||
1167 | * to overlap. | 1002 | * to overlap. |
1168 | */ | 1003 | */ |
1169 | 1004 | ||
1170 | static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) | 1005 | static int stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait) |
1171 | { | 1006 | { |
1172 | cdkhdr_t __iomem *hdrp; | 1007 | cdkhdr_t __iomem *hdrp; |
1173 | cdkctrl_t __iomem *cp; | 1008 | cdkctrl_t __iomem *cp; |
@@ -1238,7 +1073,7 @@ static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, i | |||
1238 | * wait is true then must have user context (to sleep). | 1073 | * wait is true then must have user context (to sleep). |
1239 | */ | 1074 | */ |
1240 | 1075 | ||
1241 | static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait) | 1076 | static int stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait) |
1242 | { | 1077 | { |
1243 | cdkhdr_t __iomem *hdrp; | 1078 | cdkhdr_t __iomem *hdrp; |
1244 | cdkctrl_t __iomem *cp; | 1079 | cdkctrl_t __iomem *cp; |
@@ -1302,7 +1137,7 @@ static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, | |||
1302 | * to complete (as opposed to initiating the command then returning). | 1137 | * to complete (as opposed to initiating the command then returning). |
1303 | */ | 1138 | */ |
1304 | 1139 | ||
1305 | static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) | 1140 | static int stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback) |
1306 | { | 1141 | { |
1307 | wait_event_interruptible(portp->raw_wait, | 1142 | wait_event_interruptible(portp->raw_wait, |
1308 | !test_bit(ST_CMDING, &portp->state)); | 1143 | !test_bit(ST_CMDING, &portp->state)); |
@@ -1328,16 +1163,16 @@ static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, v | |||
1328 | * waiting for the command to complete - so must have user context. | 1163 | * waiting for the command to complete - so must have user context. |
1329 | */ | 1164 | */ |
1330 | 1165 | ||
1331 | static int stli_setport(stliport_t *portp) | 1166 | static int stli_setport(struct stliport *portp) |
1332 | { | 1167 | { |
1333 | stlibrd_t *brdp; | 1168 | struct stlibrd *brdp; |
1334 | asyport_t aport; | 1169 | asyport_t aport; |
1335 | 1170 | ||
1336 | if (portp == NULL) | 1171 | if (portp == NULL) |
1337 | return -ENODEV; | 1172 | return -ENODEV; |
1338 | if (portp->tty == NULL) | 1173 | if (portp->tty == NULL) |
1339 | return -ENODEV; | 1174 | return -ENODEV; |
1340 | if (portp->brdnr < 0 && portp->brdnr >= stli_nrbrds) | 1175 | if (portp->brdnr >= stli_nrbrds) |
1341 | return -ENODEV; | 1176 | return -ENODEV; |
1342 | brdp = stli_brds[portp->brdnr]; | 1177 | brdp = stli_brds[portp->brdnr]; |
1343 | if (brdp == NULL) | 1178 | if (brdp == NULL) |
@@ -1354,7 +1189,7 @@ static int stli_setport(stliport_t *portp) | |||
1354 | * maybe because if we are clocal then we don't need to wait... | 1189 | * maybe because if we are clocal then we don't need to wait... |
1355 | */ | 1190 | */ |
1356 | 1191 | ||
1357 | static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp) | 1192 | static int stli_waitcarrier(struct stlibrd *brdp, struct stliport *portp, struct file *filp) |
1358 | { | 1193 | { |
1359 | unsigned long flags; | 1194 | unsigned long flags; |
1360 | int rc, doclocal; | 1195 | int rc, doclocal; |
@@ -1419,8 +1254,8 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun | |||
1419 | unsigned char __iomem *bits; | 1254 | unsigned char __iomem *bits; |
1420 | unsigned char __iomem *shbuf; | 1255 | unsigned char __iomem *shbuf; |
1421 | unsigned char *chbuf; | 1256 | unsigned char *chbuf; |
1422 | stliport_t *portp; | 1257 | struct stliport *portp; |
1423 | stlibrd_t *brdp; | 1258 | struct stlibrd *brdp; |
1424 | unsigned int len, stlen, head, tail, size; | 1259 | unsigned int len, stlen, head, tail, size; |
1425 | unsigned long flags; | 1260 | unsigned long flags; |
1426 | 1261 | ||
@@ -1429,7 +1264,7 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun | |||
1429 | portp = tty->driver_data; | 1264 | portp = tty->driver_data; |
1430 | if (portp == NULL) | 1265 | if (portp == NULL) |
1431 | return 0; | 1266 | return 0; |
1432 | if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) | 1267 | if (portp->brdnr >= stli_nrbrds) |
1433 | return 0; | 1268 | return 0; |
1434 | brdp = stli_brds[portp->brdnr]; | 1269 | brdp = stli_brds[portp->brdnr]; |
1435 | if (brdp == NULL) | 1270 | if (brdp == NULL) |
@@ -1455,12 +1290,12 @@ static int stli_write(struct tty_struct *tty, const unsigned char *buf, int coun | |||
1455 | stlen = len; | 1290 | stlen = len; |
1456 | } | 1291 | } |
1457 | 1292 | ||
1458 | len = MIN(len, count); | 1293 | len = min(len, (unsigned int)count); |
1459 | count = 0; | 1294 | count = 0; |
1460 | shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset); | 1295 | shbuf = (char __iomem *) EBRDGETMEMPTR(brdp, portp->txoffset); |
1461 | 1296 | ||
1462 | while (len > 0) { | 1297 | while (len > 0) { |
1463 | stlen = MIN(len, stlen); | 1298 | stlen = min(len, stlen); |
1464 | memcpy_toio(shbuf + head, chbuf, stlen); | 1299 | memcpy_toio(shbuf + head, chbuf, stlen); |
1465 | chbuf += stlen; | 1300 | chbuf += stlen; |
1466 | len -= stlen; | 1301 | len -= stlen; |
@@ -1526,8 +1361,8 @@ static void stli_flushchars(struct tty_struct *tty) | |||
1526 | unsigned char __iomem *bits; | 1361 | unsigned char __iomem *bits; |
1527 | cdkasy_t __iomem *ap; | 1362 | cdkasy_t __iomem *ap; |
1528 | struct tty_struct *cooktty; | 1363 | struct tty_struct *cooktty; |
1529 | stliport_t *portp; | 1364 | struct stliport *portp; |
1530 | stlibrd_t *brdp; | 1365 | struct stlibrd *brdp; |
1531 | unsigned int len, stlen, head, tail, size, count, cooksize; | 1366 | unsigned int len, stlen, head, tail, size, count, cooksize; |
1532 | unsigned char *buf; | 1367 | unsigned char *buf; |
1533 | unsigned char __iomem *shbuf; | 1368 | unsigned char __iomem *shbuf; |
@@ -1551,7 +1386,7 @@ static void stli_flushchars(struct tty_struct *tty) | |||
1551 | portp = tty->driver_data; | 1386 | portp = tty->driver_data; |
1552 | if (portp == NULL) | 1387 | if (portp == NULL) |
1553 | return; | 1388 | return; |
1554 | if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) | 1389 | if (portp->brdnr >= stli_nrbrds) |
1555 | return; | 1390 | return; |
1556 | brdp = stli_brds[portp->brdnr]; | 1391 | brdp = stli_brds[portp->brdnr]; |
1557 | if (brdp == NULL) | 1392 | if (brdp == NULL) |
@@ -1574,13 +1409,13 @@ static void stli_flushchars(struct tty_struct *tty) | |||
1574 | stlen = len; | 1409 | stlen = len; |
1575 | } | 1410 | } |
1576 | 1411 | ||
1577 | len = MIN(len, cooksize); | 1412 | len = min(len, cooksize); |
1578 | count = 0; | 1413 | count = 0; |
1579 | shbuf = (char *) EBRDGETMEMPTR(brdp, portp->txoffset); | 1414 | shbuf = EBRDGETMEMPTR(brdp, portp->txoffset); |
1580 | buf = stli_txcookbuf; | 1415 | buf = stli_txcookbuf; |
1581 | 1416 | ||
1582 | while (len > 0) { | 1417 | while (len > 0) { |
1583 | stlen = MIN(len, stlen); | 1418 | stlen = min(len, stlen); |
1584 | memcpy_toio(shbuf + head, buf, stlen); | 1419 | memcpy_toio(shbuf + head, buf, stlen); |
1585 | buf += stlen; | 1420 | buf += stlen; |
1586 | len -= stlen; | 1421 | len -= stlen; |
@@ -1614,8 +1449,8 @@ static void stli_flushchars(struct tty_struct *tty) | |||
1614 | static int stli_writeroom(struct tty_struct *tty) | 1449 | static int stli_writeroom(struct tty_struct *tty) |
1615 | { | 1450 | { |
1616 | cdkasyrq_t __iomem *rp; | 1451 | cdkasyrq_t __iomem *rp; |
1617 | stliport_t *portp; | 1452 | struct stliport *portp; |
1618 | stlibrd_t *brdp; | 1453 | struct stlibrd *brdp; |
1619 | unsigned int head, tail, len; | 1454 | unsigned int head, tail, len; |
1620 | unsigned long flags; | 1455 | unsigned long flags; |
1621 | 1456 | ||
@@ -1629,7 +1464,7 @@ static int stli_writeroom(struct tty_struct *tty) | |||
1629 | portp = tty->driver_data; | 1464 | portp = tty->driver_data; |
1630 | if (portp == NULL) | 1465 | if (portp == NULL) |
1631 | return 0; | 1466 | return 0; |
1632 | if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) | 1467 | if (portp->brdnr >= stli_nrbrds) |
1633 | return 0; | 1468 | return 0; |
1634 | brdp = stli_brds[portp->brdnr]; | 1469 | brdp = stli_brds[portp->brdnr]; |
1635 | if (brdp == NULL) | 1470 | if (brdp == NULL) |
@@ -1667,8 +1502,8 @@ static int stli_writeroom(struct tty_struct *tty) | |||
1667 | static int stli_charsinbuffer(struct tty_struct *tty) | 1502 | static int stli_charsinbuffer(struct tty_struct *tty) |
1668 | { | 1503 | { |
1669 | cdkasyrq_t __iomem *rp; | 1504 | cdkasyrq_t __iomem *rp; |
1670 | stliport_t *portp; | 1505 | struct stliport *portp; |
1671 | stlibrd_t *brdp; | 1506 | struct stlibrd *brdp; |
1672 | unsigned int head, tail, len; | 1507 | unsigned int head, tail, len; |
1673 | unsigned long flags; | 1508 | unsigned long flags; |
1674 | 1509 | ||
@@ -1677,7 +1512,7 @@ static int stli_charsinbuffer(struct tty_struct *tty) | |||
1677 | portp = tty->driver_data; | 1512 | portp = tty->driver_data; |
1678 | if (portp == NULL) | 1513 | if (portp == NULL) |
1679 | return 0; | 1514 | return 0; |
1680 | if ((portp->brdnr < 0) || (portp->brdnr >= stli_nrbrds)) | 1515 | if (portp->brdnr >= stli_nrbrds) |
1681 | return 0; | 1516 | return 0; |
1682 | brdp = stli_brds[portp->brdnr]; | 1517 | brdp = stli_brds[portp->brdnr]; |
1683 | if (brdp == NULL) | 1518 | if (brdp == NULL) |
@@ -1705,10 +1540,10 @@ static int stli_charsinbuffer(struct tty_struct *tty) | |||
1705 | * Generate the serial struct info. | 1540 | * Generate the serial struct info. |
1706 | */ | 1541 | */ |
1707 | 1542 | ||
1708 | static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) | 1543 | static int stli_getserial(struct stliport *portp, struct serial_struct __user *sp) |
1709 | { | 1544 | { |
1710 | struct serial_struct sio; | 1545 | struct serial_struct sio; |
1711 | stlibrd_t *brdp; | 1546 | struct stlibrd *brdp; |
1712 | 1547 | ||
1713 | memset(&sio, 0, sizeof(struct serial_struct)); | 1548 | memset(&sio, 0, sizeof(struct serial_struct)); |
1714 | sio.type = PORT_UNKNOWN; | 1549 | sio.type = PORT_UNKNOWN; |
@@ -1738,7 +1573,7 @@ static int stli_getserial(stliport_t *portp, struct serial_struct __user *sp) | |||
1738 | * just quietly ignore any requests to change irq, etc. | 1573 | * just quietly ignore any requests to change irq, etc. |
1739 | */ | 1574 | */ |
1740 | 1575 | ||
1741 | static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) | 1576 | static int stli_setserial(struct stliport *portp, struct serial_struct __user *sp) |
1742 | { | 1577 | { |
1743 | struct serial_struct sio; | 1578 | struct serial_struct sio; |
1744 | int rc; | 1579 | int rc; |
@@ -1769,13 +1604,13 @@ static int stli_setserial(stliport_t *portp, struct serial_struct __user *sp) | |||
1769 | 1604 | ||
1770 | static int stli_tiocmget(struct tty_struct *tty, struct file *file) | 1605 | static int stli_tiocmget(struct tty_struct *tty, struct file *file) |
1771 | { | 1606 | { |
1772 | stliport_t *portp = tty->driver_data; | 1607 | struct stliport *portp = tty->driver_data; |
1773 | stlibrd_t *brdp; | 1608 | struct stlibrd *brdp; |
1774 | int rc; | 1609 | int rc; |
1775 | 1610 | ||
1776 | if (portp == NULL) | 1611 | if (portp == NULL) |
1777 | return -ENODEV; | 1612 | return -ENODEV; |
1778 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1613 | if (portp->brdnr >= stli_nrbrds) |
1779 | return 0; | 1614 | return 0; |
1780 | brdp = stli_brds[portp->brdnr]; | 1615 | brdp = stli_brds[portp->brdnr]; |
1781 | if (brdp == NULL) | 1616 | if (brdp == NULL) |
@@ -1793,13 +1628,13 @@ static int stli_tiocmget(struct tty_struct *tty, struct file *file) | |||
1793 | static int stli_tiocmset(struct tty_struct *tty, struct file *file, | 1628 | static int stli_tiocmset(struct tty_struct *tty, struct file *file, |
1794 | unsigned int set, unsigned int clear) | 1629 | unsigned int set, unsigned int clear) |
1795 | { | 1630 | { |
1796 | stliport_t *portp = tty->driver_data; | 1631 | struct stliport *portp = tty->driver_data; |
1797 | stlibrd_t *brdp; | 1632 | struct stlibrd *brdp; |
1798 | int rts = -1, dtr = -1; | 1633 | int rts = -1, dtr = -1; |
1799 | 1634 | ||
1800 | if (portp == NULL) | 1635 | if (portp == NULL) |
1801 | return -ENODEV; | 1636 | return -ENODEV; |
1802 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1637 | if (portp->brdnr >= stli_nrbrds) |
1803 | return 0; | 1638 | return 0; |
1804 | brdp = stli_brds[portp->brdnr]; | 1639 | brdp = stli_brds[portp->brdnr]; |
1805 | if (brdp == NULL) | 1640 | if (brdp == NULL) |
@@ -1824,8 +1659,8 @@ static int stli_tiocmset(struct tty_struct *tty, struct file *file, | |||
1824 | 1659 | ||
1825 | static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) | 1660 | static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) |
1826 | { | 1661 | { |
1827 | stliport_t *portp; | 1662 | struct stliport *portp; |
1828 | stlibrd_t *brdp; | 1663 | struct stlibrd *brdp; |
1829 | unsigned int ival; | 1664 | unsigned int ival; |
1830 | int rc; | 1665 | int rc; |
1831 | void __user *argp = (void __user *)arg; | 1666 | void __user *argp = (void __user *)arg; |
@@ -1833,7 +1668,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm | |||
1833 | portp = tty->driver_data; | 1668 | portp = tty->driver_data; |
1834 | if (portp == NULL) | 1669 | if (portp == NULL) |
1835 | return -ENODEV; | 1670 | return -ENODEV; |
1836 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1671 | if (portp->brdnr >= stli_nrbrds) |
1837 | return 0; | 1672 | return 0; |
1838 | brdp = stli_brds[portp->brdnr]; | 1673 | brdp = stli_brds[portp->brdnr]; |
1839 | if (brdp == NULL) | 1674 | if (brdp == NULL) |
@@ -1899,11 +1734,11 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm | |||
1899 | * Looks like it is true for the current ttys implementation..!! | 1734 | * Looks like it is true for the current ttys implementation..!! |
1900 | */ | 1735 | */ |
1901 | 1736 | ||
1902 | static void stli_settermios(struct tty_struct *tty, struct termios *old) | 1737 | static void stli_settermios(struct tty_struct *tty, struct ktermios *old) |
1903 | { | 1738 | { |
1904 | stliport_t *portp; | 1739 | struct stliport *portp; |
1905 | stlibrd_t *brdp; | 1740 | struct stlibrd *brdp; |
1906 | struct termios *tiosp; | 1741 | struct ktermios *tiosp; |
1907 | asyport_t aport; | 1742 | asyport_t aport; |
1908 | 1743 | ||
1909 | if (tty == NULL) | 1744 | if (tty == NULL) |
@@ -1911,7 +1746,7 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old) | |||
1911 | portp = tty->driver_data; | 1746 | portp = tty->driver_data; |
1912 | if (portp == NULL) | 1747 | if (portp == NULL) |
1913 | return; | 1748 | return; |
1914 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1749 | if (portp->brdnr >= stli_nrbrds) |
1915 | return; | 1750 | return; |
1916 | brdp = stli_brds[portp->brdnr]; | 1751 | brdp = stli_brds[portp->brdnr]; |
1917 | if (brdp == NULL) | 1752 | if (brdp == NULL) |
@@ -1947,7 +1782,7 @@ static void stli_settermios(struct tty_struct *tty, struct termios *old) | |||
1947 | 1782 | ||
1948 | static void stli_throttle(struct tty_struct *tty) | 1783 | static void stli_throttle(struct tty_struct *tty) |
1949 | { | 1784 | { |
1950 | stliport_t *portp = tty->driver_data; | 1785 | struct stliport *portp = tty->driver_data; |
1951 | if (portp == NULL) | 1786 | if (portp == NULL) |
1952 | return; | 1787 | return; |
1953 | set_bit(ST_RXSTOP, &portp->state); | 1788 | set_bit(ST_RXSTOP, &portp->state); |
@@ -1963,7 +1798,7 @@ static void stli_throttle(struct tty_struct *tty) | |||
1963 | 1798 | ||
1964 | static void stli_unthrottle(struct tty_struct *tty) | 1799 | static void stli_unthrottle(struct tty_struct *tty) |
1965 | { | 1800 | { |
1966 | stliport_t *portp = tty->driver_data; | 1801 | struct stliport *portp = tty->driver_data; |
1967 | if (portp == NULL) | 1802 | if (portp == NULL) |
1968 | return; | 1803 | return; |
1969 | clear_bit(ST_RXSTOP, &portp->state); | 1804 | clear_bit(ST_RXSTOP, &portp->state); |
@@ -2000,9 +1835,9 @@ static void stli_start(struct tty_struct *tty) | |||
2000 | * aren't that time critical). | 1835 | * aren't that time critical). |
2001 | */ | 1836 | */ |
2002 | 1837 | ||
2003 | static void stli_dohangup(void *arg) | 1838 | static void stli_dohangup(struct work_struct *ugly_api) |
2004 | { | 1839 | { |
2005 | stliport_t *portp = (stliport_t *) arg; | 1840 | struct stliport *portp = container_of(ugly_api, struct stliport, tqhangup); |
2006 | if (portp->tty != NULL) { | 1841 | if (portp->tty != NULL) { |
2007 | tty_hangup(portp->tty); | 1842 | tty_hangup(portp->tty); |
2008 | } | 1843 | } |
@@ -2019,14 +1854,14 @@ static void stli_dohangup(void *arg) | |||
2019 | 1854 | ||
2020 | static void stli_hangup(struct tty_struct *tty) | 1855 | static void stli_hangup(struct tty_struct *tty) |
2021 | { | 1856 | { |
2022 | stliport_t *portp; | 1857 | struct stliport *portp; |
2023 | stlibrd_t *brdp; | 1858 | struct stlibrd *brdp; |
2024 | unsigned long flags; | 1859 | unsigned long flags; |
2025 | 1860 | ||
2026 | portp = tty->driver_data; | 1861 | portp = tty->driver_data; |
2027 | if (portp == NULL) | 1862 | if (portp == NULL) |
2028 | return; | 1863 | return; |
2029 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1864 | if (portp->brdnr >= stli_nrbrds) |
2030 | return; | 1865 | return; |
2031 | brdp = stli_brds[portp->brdnr]; | 1866 | brdp = stli_brds[portp->brdnr]; |
2032 | if (brdp == NULL) | 1867 | if (brdp == NULL) |
@@ -2072,14 +1907,14 @@ static void stli_hangup(struct tty_struct *tty) | |||
2072 | 1907 | ||
2073 | static void stli_flushbuffer(struct tty_struct *tty) | 1908 | static void stli_flushbuffer(struct tty_struct *tty) |
2074 | { | 1909 | { |
2075 | stliport_t *portp; | 1910 | struct stliport *portp; |
2076 | stlibrd_t *brdp; | 1911 | struct stlibrd *brdp; |
2077 | unsigned long ftype, flags; | 1912 | unsigned long ftype, flags; |
2078 | 1913 | ||
2079 | portp = tty->driver_data; | 1914 | portp = tty->driver_data; |
2080 | if (portp == NULL) | 1915 | if (portp == NULL) |
2081 | return; | 1916 | return; |
2082 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1917 | if (portp->brdnr >= stli_nrbrds) |
2083 | return; | 1918 | return; |
2084 | brdp = stli_brds[portp->brdnr]; | 1919 | brdp = stli_brds[portp->brdnr]; |
2085 | if (brdp == NULL) | 1920 | if (brdp == NULL) |
@@ -2109,14 +1944,14 @@ static void stli_flushbuffer(struct tty_struct *tty) | |||
2109 | 1944 | ||
2110 | static void stli_breakctl(struct tty_struct *tty, int state) | 1945 | static void stli_breakctl(struct tty_struct *tty, int state) |
2111 | { | 1946 | { |
2112 | stlibrd_t *brdp; | 1947 | struct stlibrd *brdp; |
2113 | stliport_t *portp; | 1948 | struct stliport *portp; |
2114 | long arg; | 1949 | long arg; |
2115 | 1950 | ||
2116 | portp = tty->driver_data; | 1951 | portp = tty->driver_data; |
2117 | if (portp == NULL) | 1952 | if (portp == NULL) |
2118 | return; | 1953 | return; |
2119 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 1954 | if (portp->brdnr >= stli_nrbrds) |
2120 | return; | 1955 | return; |
2121 | brdp = stli_brds[portp->brdnr]; | 1956 | brdp = stli_brds[portp->brdnr]; |
2122 | if (brdp == NULL) | 1957 | if (brdp == NULL) |
@@ -2130,7 +1965,7 @@ static void stli_breakctl(struct tty_struct *tty, int state) | |||
2130 | 1965 | ||
2131 | static void stli_waituntilsent(struct tty_struct *tty, int timeout) | 1966 | static void stli_waituntilsent(struct tty_struct *tty, int timeout) |
2132 | { | 1967 | { |
2133 | stliport_t *portp; | 1968 | struct stliport *portp; |
2134 | unsigned long tend; | 1969 | unsigned long tend; |
2135 | 1970 | ||
2136 | if (tty == NULL) | 1971 | if (tty == NULL) |
@@ -2156,14 +1991,14 @@ static void stli_waituntilsent(struct tty_struct *tty, int timeout) | |||
2156 | 1991 | ||
2157 | static void stli_sendxchar(struct tty_struct *tty, char ch) | 1992 | static void stli_sendxchar(struct tty_struct *tty, char ch) |
2158 | { | 1993 | { |
2159 | stlibrd_t *brdp; | 1994 | struct stlibrd *brdp; |
2160 | stliport_t *portp; | 1995 | struct stliport *portp; |
2161 | asyctrl_t actrl; | 1996 | asyctrl_t actrl; |
2162 | 1997 | ||
2163 | portp = tty->driver_data; | 1998 | portp = tty->driver_data; |
2164 | if (portp == NULL) | 1999 | if (portp == NULL) |
2165 | return; | 2000 | return; |
2166 | if (portp->brdnr < 0 || portp->brdnr >= stli_nrbrds) | 2001 | if (portp->brdnr >= stli_nrbrds) |
2167 | return; | 2002 | return; |
2168 | brdp = stli_brds[portp->brdnr]; | 2003 | brdp = stli_brds[portp->brdnr]; |
2169 | if (brdp == NULL) | 2004 | if (brdp == NULL) |
@@ -2191,7 +2026,7 @@ static void stli_sendxchar(struct tty_struct *tty, char ch) | |||
2191 | * short then padded with spaces). | 2026 | * short then padded with spaces). |
2192 | */ | 2027 | */ |
2193 | 2028 | ||
2194 | static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *pos) | 2029 | static int stli_portinfo(struct stlibrd *brdp, struct stliport *portp, int portnr, char *pos) |
2195 | { | 2030 | { |
2196 | char *sp, *uart; | 2031 | char *sp, *uart; |
2197 | int rc, cnt; | 2032 | int rc, cnt; |
@@ -2254,9 +2089,9 @@ static int stli_portinfo(stlibrd_t *brdp, stliport_t *portp, int portnr, char *p | |||
2254 | 2089 | ||
2255 | static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) | 2090 | static int stli_readproc(char *page, char **start, off_t off, int count, int *eof, void *data) |
2256 | { | 2091 | { |
2257 | stlibrd_t *brdp; | 2092 | struct stlibrd *brdp; |
2258 | stliport_t *portp; | 2093 | struct stliport *portp; |
2259 | int brdnr, portnr, totalport; | 2094 | unsigned int brdnr, portnr, totalport; |
2260 | int curoff, maxoff; | 2095 | int curoff, maxoff; |
2261 | char *pos; | 2096 | char *pos; |
2262 | 2097 | ||
@@ -2326,7 +2161,7 @@ stli_readdone: | |||
2326 | * entry point) | 2161 | * entry point) |
2327 | */ | 2162 | */ |
2328 | 2163 | ||
2329 | static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) | 2164 | static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback) |
2330 | { | 2165 | { |
2331 | cdkhdr_t __iomem *hdrp; | 2166 | cdkhdr_t __iomem *hdrp; |
2332 | cdkctrl_t __iomem *cp; | 2167 | cdkctrl_t __iomem *cp; |
@@ -2362,7 +2197,7 @@ static void __stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd | |||
2362 | spin_unlock_irqrestore(&brd_lock, flags); | 2197 | spin_unlock_irqrestore(&brd_lock, flags); |
2363 | } | 2198 | } |
2364 | 2199 | ||
2365 | static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback) | 2200 | static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback) |
2366 | { | 2201 | { |
2367 | unsigned long flags; | 2202 | unsigned long flags; |
2368 | 2203 | ||
@@ -2381,7 +2216,7 @@ static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, | |||
2381 | * more chars to unload. | 2216 | * more chars to unload. |
2382 | */ | 2217 | */ |
2383 | 2218 | ||
2384 | static void stli_read(stlibrd_t *brdp, stliport_t *portp) | 2219 | static void stli_read(struct stlibrd *brdp, struct stliport *portp) |
2385 | { | 2220 | { |
2386 | cdkasyrq_t __iomem *rp; | 2221 | cdkasyrq_t __iomem *rp; |
2387 | char __iomem *shbuf; | 2222 | char __iomem *shbuf; |
@@ -2416,7 +2251,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) | |||
2416 | while (len > 0) { | 2251 | while (len > 0) { |
2417 | unsigned char *cptr; | 2252 | unsigned char *cptr; |
2418 | 2253 | ||
2419 | stlen = MIN(len, stlen); | 2254 | stlen = min(len, stlen); |
2420 | tty_prepare_flip_string(tty, &cptr, stlen); | 2255 | tty_prepare_flip_string(tty, &cptr, stlen); |
2421 | memcpy_fromio(cptr, shbuf + tail, stlen); | 2256 | memcpy_fromio(cptr, shbuf + tail, stlen); |
2422 | len -= stlen; | 2257 | len -= stlen; |
@@ -2443,7 +2278,7 @@ static void stli_read(stlibrd_t *brdp, stliport_t *portp) | |||
2443 | * difficult to deal with them here. | 2278 | * difficult to deal with them here. |
2444 | */ | 2279 | */ |
2445 | 2280 | ||
2446 | static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp) | 2281 | static void stli_dodelaycmd(struct stliport *portp, cdkctrl_t __iomem *cp) |
2447 | { | 2282 | { |
2448 | int cmd; | 2283 | int cmd; |
2449 | 2284 | ||
@@ -2491,7 +2326,7 @@ static void stli_dodelaycmd(stliport_t *portp, cdkctrl_t __iomem *cp) | |||
2491 | * then port is still busy, otherwise no longer busy. | 2326 | * then port is still busy, otherwise no longer busy. |
2492 | */ | 2327 | */ |
2493 | 2328 | ||
2494 | static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) | 2329 | static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp) |
2495 | { | 2330 | { |
2496 | cdkasy_t __iomem *ap; | 2331 | cdkasy_t __iomem *ap; |
2497 | cdkctrl_t __iomem *cp; | 2332 | cdkctrl_t __iomem *cp; |
@@ -2638,9 +2473,9 @@ static int stli_hostcmd(stlibrd_t *brdp, stliport_t *portp) | |||
2638 | * at the cdk header structure. | 2473 | * at the cdk header structure. |
2639 | */ | 2474 | */ |
2640 | 2475 | ||
2641 | static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp) | 2476 | static void stli_brdpoll(struct stlibrd *brdp, cdkhdr_t __iomem *hdrp) |
2642 | { | 2477 | { |
2643 | stliport_t *portp; | 2478 | struct stliport *portp; |
2644 | unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; | 2479 | unsigned char hostbits[(STL_MAXCHANS / 8) + 1]; |
2645 | unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; | 2480 | unsigned char slavebits[(STL_MAXCHANS / 8) + 1]; |
2646 | unsigned char __iomem *slavep; | 2481 | unsigned char __iomem *slavep; |
@@ -2707,11 +2542,10 @@ static void stli_brdpoll(stlibrd_t *brdp, cdkhdr_t __iomem *hdrp) | |||
2707 | static void stli_poll(unsigned long arg) | 2542 | static void stli_poll(unsigned long arg) |
2708 | { | 2543 | { |
2709 | cdkhdr_t __iomem *hdrp; | 2544 | cdkhdr_t __iomem *hdrp; |
2710 | stlibrd_t *brdp; | 2545 | struct stlibrd *brdp; |
2711 | int brdnr; | 2546 | unsigned int brdnr; |
2712 | 2547 | ||
2713 | stli_timerlist.expires = STLI_TIMEOUT; | 2548 | mod_timer(&stli_timerlist, STLI_TIMEOUT); |
2714 | add_timer(&stli_timerlist); | ||
2715 | 2549 | ||
2716 | /* | 2550 | /* |
2717 | * Check each board and do any servicing required. | 2551 | * Check each board and do any servicing required. |
@@ -2740,22 +2574,14 @@ static void stli_poll(unsigned long arg) | |||
2740 | * the slave. | 2574 | * the slave. |
2741 | */ | 2575 | */ |
2742 | 2576 | ||
2743 | static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tiosp) | 2577 | static void stli_mkasyport(struct stliport *portp, asyport_t *pp, struct ktermios *tiosp) |
2744 | { | 2578 | { |
2745 | memset(pp, 0, sizeof(asyport_t)); | 2579 | memset(pp, 0, sizeof(asyport_t)); |
2746 | 2580 | ||
2747 | /* | 2581 | /* |
2748 | * Start of by setting the baud, char size, parity and stop bit info. | 2582 | * Start of by setting the baud, char size, parity and stop bit info. |
2749 | */ | 2583 | */ |
2750 | pp->baudout = tiosp->c_cflag & CBAUD; | 2584 | pp->baudout = tty_get_baud_rate(portp->tty); |
2751 | if (pp->baudout & CBAUDEX) { | ||
2752 | pp->baudout &= ~CBAUDEX; | ||
2753 | if ((pp->baudout < 1) || (pp->baudout > 4)) | ||
2754 | tiosp->c_cflag &= ~CBAUDEX; | ||
2755 | else | ||
2756 | pp->baudout += 15; | ||
2757 | } | ||
2758 | pp->baudout = stli_baudrates[pp->baudout]; | ||
2759 | if ((tiosp->c_cflag & CBAUD) == B38400) { | 2585 | if ((tiosp->c_cflag & CBAUD) == B38400) { |
2760 | if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 2586 | if ((portp->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
2761 | pp->baudout = 57600; | 2587 | pp->baudout = 57600; |
@@ -2897,13 +2723,13 @@ static long stli_mktiocm(unsigned long sigvalue) | |||
2897 | * we need to do here is set up the appropriate per port data structures. | 2723 | * we need to do here is set up the appropriate per port data structures. |
2898 | */ | 2724 | */ |
2899 | 2725 | ||
2900 | static int stli_initports(stlibrd_t *brdp) | 2726 | static int stli_initports(struct stlibrd *brdp) |
2901 | { | 2727 | { |
2902 | stliport_t *portp; | 2728 | struct stliport *portp; |
2903 | int i, panelnr, panelport; | 2729 | unsigned int i, panelnr, panelport; |
2904 | 2730 | ||
2905 | for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { | 2731 | for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { |
2906 | portp = kzalloc(sizeof(stliport_t), GFP_KERNEL); | 2732 | portp = kzalloc(sizeof(struct stliport), GFP_KERNEL); |
2907 | if (!portp) { | 2733 | if (!portp) { |
2908 | printk("STALLION: failed to allocate port structure\n"); | 2734 | printk("STALLION: failed to allocate port structure\n"); |
2909 | continue; | 2735 | continue; |
@@ -2916,7 +2742,7 @@ static int stli_initports(stlibrd_t *brdp) | |||
2916 | portp->baud_base = STL_BAUDBASE; | 2742 | portp->baud_base = STL_BAUDBASE; |
2917 | portp->close_delay = STL_CLOSEDELAY; | 2743 | portp->close_delay = STL_CLOSEDELAY; |
2918 | portp->closing_wait = 30 * HZ; | 2744 | portp->closing_wait = 30 * HZ; |
2919 | INIT_WORK(&portp->tqhangup, stli_dohangup, portp); | 2745 | INIT_WORK(&portp->tqhangup, stli_dohangup); |
2920 | init_waitqueue_head(&portp->open_wait); | 2746 | init_waitqueue_head(&portp->open_wait); |
2921 | init_waitqueue_head(&portp->close_wait); | 2747 | init_waitqueue_head(&portp->close_wait); |
2922 | init_waitqueue_head(&portp->raw_wait); | 2748 | init_waitqueue_head(&portp->raw_wait); |
@@ -2937,7 +2763,7 @@ static int stli_initports(stlibrd_t *brdp) | |||
2937 | * All the following routines are board specific hardware operations. | 2763 | * All the following routines are board specific hardware operations. |
2938 | */ | 2764 | */ |
2939 | 2765 | ||
2940 | static void stli_ecpinit(stlibrd_t *brdp) | 2766 | static void stli_ecpinit(struct stlibrd *brdp) |
2941 | { | 2767 | { |
2942 | unsigned long memconf; | 2768 | unsigned long memconf; |
2943 | 2769 | ||
@@ -2952,23 +2778,23 @@ static void stli_ecpinit(stlibrd_t *brdp) | |||
2952 | 2778 | ||
2953 | /*****************************************************************************/ | 2779 | /*****************************************************************************/ |
2954 | 2780 | ||
2955 | static void stli_ecpenable(stlibrd_t *brdp) | 2781 | static void stli_ecpenable(struct stlibrd *brdp) |
2956 | { | 2782 | { |
2957 | outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); | 2783 | outb(ECP_ATENABLE, (brdp->iobase + ECP_ATCONFR)); |
2958 | } | 2784 | } |
2959 | 2785 | ||
2960 | /*****************************************************************************/ | 2786 | /*****************************************************************************/ |
2961 | 2787 | ||
2962 | static void stli_ecpdisable(stlibrd_t *brdp) | 2788 | static void stli_ecpdisable(struct stlibrd *brdp) |
2963 | { | 2789 | { |
2964 | outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); | 2790 | outb(ECP_ATDISABLE, (brdp->iobase + ECP_ATCONFR)); |
2965 | } | 2791 | } |
2966 | 2792 | ||
2967 | /*****************************************************************************/ | 2793 | /*****************************************************************************/ |
2968 | 2794 | ||
2969 | static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 2795 | static void __iomem *stli_ecpgetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
2970 | { | 2796 | { |
2971 | void *ptr; | 2797 | void __iomem *ptr; |
2972 | unsigned char val; | 2798 | unsigned char val; |
2973 | 2799 | ||
2974 | if (offset > brdp->memsize) { | 2800 | if (offset > brdp->memsize) { |
@@ -2987,7 +2813,7 @@ static char *stli_ecpgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | |||
2987 | 2813 | ||
2988 | /*****************************************************************************/ | 2814 | /*****************************************************************************/ |
2989 | 2815 | ||
2990 | static void stli_ecpreset(stlibrd_t *brdp) | 2816 | static void stli_ecpreset(struct stlibrd *brdp) |
2991 | { | 2817 | { |
2992 | outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); | 2818 | outb(ECP_ATSTOP, (brdp->iobase + ECP_ATCONFR)); |
2993 | udelay(10); | 2819 | udelay(10); |
@@ -2997,7 +2823,7 @@ static void stli_ecpreset(stlibrd_t *brdp) | |||
2997 | 2823 | ||
2998 | /*****************************************************************************/ | 2824 | /*****************************************************************************/ |
2999 | 2825 | ||
3000 | static void stli_ecpintr(stlibrd_t *brdp) | 2826 | static void stli_ecpintr(struct stlibrd *brdp) |
3001 | { | 2827 | { |
3002 | outb(0x1, brdp->iobase); | 2828 | outb(0x1, brdp->iobase); |
3003 | } | 2829 | } |
@@ -3008,7 +2834,7 @@ static void stli_ecpintr(stlibrd_t *brdp) | |||
3008 | * The following set of functions act on ECP EISA boards. | 2834 | * The following set of functions act on ECP EISA boards. |
3009 | */ | 2835 | */ |
3010 | 2836 | ||
3011 | static void stli_ecpeiinit(stlibrd_t *brdp) | 2837 | static void stli_ecpeiinit(struct stlibrd *brdp) |
3012 | { | 2838 | { |
3013 | unsigned long memconf; | 2839 | unsigned long memconf; |
3014 | 2840 | ||
@@ -3026,23 +2852,23 @@ static void stli_ecpeiinit(stlibrd_t *brdp) | |||
3026 | 2852 | ||
3027 | /*****************************************************************************/ | 2853 | /*****************************************************************************/ |
3028 | 2854 | ||
3029 | static void stli_ecpeienable(stlibrd_t *brdp) | 2855 | static void stli_ecpeienable(struct stlibrd *brdp) |
3030 | { | 2856 | { |
3031 | outb(ECP_EIENABLE, (brdp->iobase + ECP_EICONFR)); | 2857 | outb(ECP_EIENABLE, (brdp->iobase + ECP_EICONFR)); |
3032 | } | 2858 | } |
3033 | 2859 | ||
3034 | /*****************************************************************************/ | 2860 | /*****************************************************************************/ |
3035 | 2861 | ||
3036 | static void stli_ecpeidisable(stlibrd_t *brdp) | 2862 | static void stli_ecpeidisable(struct stlibrd *brdp) |
3037 | { | 2863 | { |
3038 | outb(ECP_EIDISABLE, (brdp->iobase + ECP_EICONFR)); | 2864 | outb(ECP_EIDISABLE, (brdp->iobase + ECP_EICONFR)); |
3039 | } | 2865 | } |
3040 | 2866 | ||
3041 | /*****************************************************************************/ | 2867 | /*****************************************************************************/ |
3042 | 2868 | ||
3043 | static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 2869 | static void __iomem *stli_ecpeigetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3044 | { | 2870 | { |
3045 | void *ptr; | 2871 | void __iomem *ptr; |
3046 | unsigned char val; | 2872 | unsigned char val; |
3047 | 2873 | ||
3048 | if (offset > brdp->memsize) { | 2874 | if (offset > brdp->memsize) { |
@@ -3064,7 +2890,7 @@ static char *stli_ecpeigetmemptr(stlibrd_t *brdp, unsigned long offset, int line | |||
3064 | 2890 | ||
3065 | /*****************************************************************************/ | 2891 | /*****************************************************************************/ |
3066 | 2892 | ||
3067 | static void stli_ecpeireset(stlibrd_t *brdp) | 2893 | static void stli_ecpeireset(struct stlibrd *brdp) |
3068 | { | 2894 | { |
3069 | outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); | 2895 | outb(ECP_EISTOP, (brdp->iobase + ECP_EICONFR)); |
3070 | udelay(10); | 2896 | udelay(10); |
@@ -3078,23 +2904,23 @@ static void stli_ecpeireset(stlibrd_t *brdp) | |||
3078 | * The following set of functions act on ECP MCA boards. | 2904 | * The following set of functions act on ECP MCA boards. |
3079 | */ | 2905 | */ |
3080 | 2906 | ||
3081 | static void stli_ecpmcenable(stlibrd_t *brdp) | 2907 | static void stli_ecpmcenable(struct stlibrd *brdp) |
3082 | { | 2908 | { |
3083 | outb(ECP_MCENABLE, (brdp->iobase + ECP_MCCONFR)); | 2909 | outb(ECP_MCENABLE, (brdp->iobase + ECP_MCCONFR)); |
3084 | } | 2910 | } |
3085 | 2911 | ||
3086 | /*****************************************************************************/ | 2912 | /*****************************************************************************/ |
3087 | 2913 | ||
3088 | static void stli_ecpmcdisable(stlibrd_t *brdp) | 2914 | static void stli_ecpmcdisable(struct stlibrd *brdp) |
3089 | { | 2915 | { |
3090 | outb(ECP_MCDISABLE, (brdp->iobase + ECP_MCCONFR)); | 2916 | outb(ECP_MCDISABLE, (brdp->iobase + ECP_MCCONFR)); |
3091 | } | 2917 | } |
3092 | 2918 | ||
3093 | /*****************************************************************************/ | 2919 | /*****************************************************************************/ |
3094 | 2920 | ||
3095 | static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 2921 | static void __iomem *stli_ecpmcgetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3096 | { | 2922 | { |
3097 | void *ptr; | 2923 | void __iomem *ptr; |
3098 | unsigned char val; | 2924 | unsigned char val; |
3099 | 2925 | ||
3100 | if (offset > brdp->memsize) { | 2926 | if (offset > brdp->memsize) { |
@@ -3113,7 +2939,7 @@ static char *stli_ecpmcgetmemptr(stlibrd_t *brdp, unsigned long offset, int line | |||
3113 | 2939 | ||
3114 | /*****************************************************************************/ | 2940 | /*****************************************************************************/ |
3115 | 2941 | ||
3116 | static void stli_ecpmcreset(stlibrd_t *brdp) | 2942 | static void stli_ecpmcreset(struct stlibrd *brdp) |
3117 | { | 2943 | { |
3118 | outb(ECP_MCSTOP, (brdp->iobase + ECP_MCCONFR)); | 2944 | outb(ECP_MCSTOP, (brdp->iobase + ECP_MCCONFR)); |
3119 | udelay(10); | 2945 | udelay(10); |
@@ -3127,7 +2953,7 @@ static void stli_ecpmcreset(stlibrd_t *brdp) | |||
3127 | * The following set of functions act on ECP PCI boards. | 2953 | * The following set of functions act on ECP PCI boards. |
3128 | */ | 2954 | */ |
3129 | 2955 | ||
3130 | static void stli_ecppciinit(stlibrd_t *brdp) | 2956 | static void stli_ecppciinit(struct stlibrd *brdp) |
3131 | { | 2957 | { |
3132 | outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); | 2958 | outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); |
3133 | udelay(10); | 2959 | udelay(10); |
@@ -3137,9 +2963,9 @@ static void stli_ecppciinit(stlibrd_t *brdp) | |||
3137 | 2963 | ||
3138 | /*****************************************************************************/ | 2964 | /*****************************************************************************/ |
3139 | 2965 | ||
3140 | static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 2966 | static void __iomem *stli_ecppcigetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3141 | { | 2967 | { |
3142 | void *ptr; | 2968 | void __iomem *ptr; |
3143 | unsigned char val; | 2969 | unsigned char val; |
3144 | 2970 | ||
3145 | if (offset > brdp->memsize) { | 2971 | if (offset > brdp->memsize) { |
@@ -3158,7 +2984,7 @@ static char *stli_ecppcigetmemptr(stlibrd_t *brdp, unsigned long offset, int lin | |||
3158 | 2984 | ||
3159 | /*****************************************************************************/ | 2985 | /*****************************************************************************/ |
3160 | 2986 | ||
3161 | static void stli_ecppcireset(stlibrd_t *brdp) | 2987 | static void stli_ecppcireset(struct stlibrd *brdp) |
3162 | { | 2988 | { |
3163 | outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); | 2989 | outb(ECP_PCISTOP, (brdp->iobase + ECP_PCICONFR)); |
3164 | udelay(10); | 2990 | udelay(10); |
@@ -3172,7 +2998,7 @@ static void stli_ecppcireset(stlibrd_t *brdp) | |||
3172 | * The following routines act on ONboards. | 2998 | * The following routines act on ONboards. |
3173 | */ | 2999 | */ |
3174 | 3000 | ||
3175 | static void stli_onbinit(stlibrd_t *brdp) | 3001 | static void stli_onbinit(struct stlibrd *brdp) |
3176 | { | 3002 | { |
3177 | unsigned long memconf; | 3003 | unsigned long memconf; |
3178 | 3004 | ||
@@ -3189,23 +3015,23 @@ static void stli_onbinit(stlibrd_t *brdp) | |||
3189 | 3015 | ||
3190 | /*****************************************************************************/ | 3016 | /*****************************************************************************/ |
3191 | 3017 | ||
3192 | static void stli_onbenable(stlibrd_t *brdp) | 3018 | static void stli_onbenable(struct stlibrd *brdp) |
3193 | { | 3019 | { |
3194 | outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); | 3020 | outb((brdp->enabval | ONB_ATENABLE), (brdp->iobase + ONB_ATCONFR)); |
3195 | } | 3021 | } |
3196 | 3022 | ||
3197 | /*****************************************************************************/ | 3023 | /*****************************************************************************/ |
3198 | 3024 | ||
3199 | static void stli_onbdisable(stlibrd_t *brdp) | 3025 | static void stli_onbdisable(struct stlibrd *brdp) |
3200 | { | 3026 | { |
3201 | outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); | 3027 | outb((brdp->enabval | ONB_ATDISABLE), (brdp->iobase + ONB_ATCONFR)); |
3202 | } | 3028 | } |
3203 | 3029 | ||
3204 | /*****************************************************************************/ | 3030 | /*****************************************************************************/ |
3205 | 3031 | ||
3206 | static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 3032 | static void __iomem *stli_onbgetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3207 | { | 3033 | { |
3208 | void *ptr; | 3034 | void __iomem *ptr; |
3209 | 3035 | ||
3210 | if (offset > brdp->memsize) { | 3036 | if (offset > brdp->memsize) { |
3211 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 3037 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " |
@@ -3220,7 +3046,7 @@ static char *stli_onbgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | |||
3220 | 3046 | ||
3221 | /*****************************************************************************/ | 3047 | /*****************************************************************************/ |
3222 | 3048 | ||
3223 | static void stli_onbreset(stlibrd_t *brdp) | 3049 | static void stli_onbreset(struct stlibrd *brdp) |
3224 | { | 3050 | { |
3225 | outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); | 3051 | outb(ONB_ATSTOP, (brdp->iobase + ONB_ATCONFR)); |
3226 | udelay(10); | 3052 | udelay(10); |
@@ -3234,7 +3060,7 @@ static void stli_onbreset(stlibrd_t *brdp) | |||
3234 | * The following routines act on ONboard EISA. | 3060 | * The following routines act on ONboard EISA. |
3235 | */ | 3061 | */ |
3236 | 3062 | ||
3237 | static void stli_onbeinit(stlibrd_t *brdp) | 3063 | static void stli_onbeinit(struct stlibrd *brdp) |
3238 | { | 3064 | { |
3239 | unsigned long memconf; | 3065 | unsigned long memconf; |
3240 | 3066 | ||
@@ -3254,23 +3080,23 @@ static void stli_onbeinit(stlibrd_t *brdp) | |||
3254 | 3080 | ||
3255 | /*****************************************************************************/ | 3081 | /*****************************************************************************/ |
3256 | 3082 | ||
3257 | static void stli_onbeenable(stlibrd_t *brdp) | 3083 | static void stli_onbeenable(struct stlibrd *brdp) |
3258 | { | 3084 | { |
3259 | outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); | 3085 | outb(ONB_EIENABLE, (brdp->iobase + ONB_EICONFR)); |
3260 | } | 3086 | } |
3261 | 3087 | ||
3262 | /*****************************************************************************/ | 3088 | /*****************************************************************************/ |
3263 | 3089 | ||
3264 | static void stli_onbedisable(stlibrd_t *brdp) | 3090 | static void stli_onbedisable(struct stlibrd *brdp) |
3265 | { | 3091 | { |
3266 | outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); | 3092 | outb(ONB_EIDISABLE, (brdp->iobase + ONB_EICONFR)); |
3267 | } | 3093 | } |
3268 | 3094 | ||
3269 | /*****************************************************************************/ | 3095 | /*****************************************************************************/ |
3270 | 3096 | ||
3271 | static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 3097 | static void __iomem *stli_onbegetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3272 | { | 3098 | { |
3273 | void *ptr; | 3099 | void __iomem *ptr; |
3274 | unsigned char val; | 3100 | unsigned char val; |
3275 | 3101 | ||
3276 | if (offset > brdp->memsize) { | 3102 | if (offset > brdp->memsize) { |
@@ -3292,7 +3118,7 @@ static char *stli_onbegetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | |||
3292 | 3118 | ||
3293 | /*****************************************************************************/ | 3119 | /*****************************************************************************/ |
3294 | 3120 | ||
3295 | static void stli_onbereset(stlibrd_t *brdp) | 3121 | static void stli_onbereset(struct stlibrd *brdp) |
3296 | { | 3122 | { |
3297 | outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); | 3123 | outb(ONB_EISTOP, (brdp->iobase + ONB_EICONFR)); |
3298 | udelay(10); | 3124 | udelay(10); |
@@ -3306,7 +3132,7 @@ static void stli_onbereset(stlibrd_t *brdp) | |||
3306 | * The following routines act on Brumby boards. | 3132 | * The following routines act on Brumby boards. |
3307 | */ | 3133 | */ |
3308 | 3134 | ||
3309 | static void stli_bbyinit(stlibrd_t *brdp) | 3135 | static void stli_bbyinit(struct stlibrd *brdp) |
3310 | { | 3136 | { |
3311 | outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); | 3137 | outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); |
3312 | udelay(10); | 3138 | udelay(10); |
@@ -3318,9 +3144,9 @@ static void stli_bbyinit(stlibrd_t *brdp) | |||
3318 | 3144 | ||
3319 | /*****************************************************************************/ | 3145 | /*****************************************************************************/ |
3320 | 3146 | ||
3321 | static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 3147 | static void __iomem *stli_bbygetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3322 | { | 3148 | { |
3323 | void *ptr; | 3149 | void __iomem *ptr; |
3324 | unsigned char val; | 3150 | unsigned char val; |
3325 | 3151 | ||
3326 | BUG_ON(offset > brdp->memsize); | 3152 | BUG_ON(offset > brdp->memsize); |
@@ -3333,7 +3159,7 @@ static char *stli_bbygetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | |||
3333 | 3159 | ||
3334 | /*****************************************************************************/ | 3160 | /*****************************************************************************/ |
3335 | 3161 | ||
3336 | static void stli_bbyreset(stlibrd_t *brdp) | 3162 | static void stli_bbyreset(struct stlibrd *brdp) |
3337 | { | 3163 | { |
3338 | outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); | 3164 | outb(BBY_ATSTOP, (brdp->iobase + BBY_ATCONFR)); |
3339 | udelay(10); | 3165 | udelay(10); |
@@ -3347,7 +3173,7 @@ static void stli_bbyreset(stlibrd_t *brdp) | |||
3347 | * The following routines act on original old Stallion boards. | 3173 | * The following routines act on original old Stallion boards. |
3348 | */ | 3174 | */ |
3349 | 3175 | ||
3350 | static void stli_stalinit(stlibrd_t *brdp) | 3176 | static void stli_stalinit(struct stlibrd *brdp) |
3351 | { | 3177 | { |
3352 | outb(0x1, brdp->iobase); | 3178 | outb(0x1, brdp->iobase); |
3353 | mdelay(1000); | 3179 | mdelay(1000); |
@@ -3355,7 +3181,7 @@ static void stli_stalinit(stlibrd_t *brdp) | |||
3355 | 3181 | ||
3356 | /*****************************************************************************/ | 3182 | /*****************************************************************************/ |
3357 | 3183 | ||
3358 | static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | 3184 | static void __iomem *stli_stalgetmemptr(struct stlibrd *brdp, unsigned long offset, int line) |
3359 | { | 3185 | { |
3360 | BUG_ON(offset > brdp->memsize); | 3186 | BUG_ON(offset > brdp->memsize); |
3361 | return brdp->membase + (offset % STAL_PAGESIZE); | 3187 | return brdp->membase + (offset % STAL_PAGESIZE); |
@@ -3363,7 +3189,7 @@ static char *stli_stalgetmemptr(stlibrd_t *brdp, unsigned long offset, int line) | |||
3363 | 3189 | ||
3364 | /*****************************************************************************/ | 3190 | /*****************************************************************************/ |
3365 | 3191 | ||
3366 | static void stli_stalreset(stlibrd_t *brdp) | 3192 | static void stli_stalreset(struct stlibrd *brdp) |
3367 | { | 3193 | { |
3368 | u32 __iomem *vecp; | 3194 | u32 __iomem *vecp; |
3369 | 3195 | ||
@@ -3380,21 +3206,22 @@ static void stli_stalreset(stlibrd_t *brdp) | |||
3380 | * board types. | 3206 | * board types. |
3381 | */ | 3207 | */ |
3382 | 3208 | ||
3383 | static int stli_initecp(stlibrd_t *brdp) | 3209 | static int stli_initecp(struct stlibrd *brdp) |
3384 | { | 3210 | { |
3385 | cdkecpsig_t sig; | 3211 | cdkecpsig_t sig; |
3386 | cdkecpsig_t __iomem *sigsp; | 3212 | cdkecpsig_t __iomem *sigsp; |
3387 | unsigned int status, nxtid; | 3213 | unsigned int status, nxtid; |
3388 | char *name; | 3214 | char *name; |
3389 | int panelnr, nrports; | 3215 | int retval, panelnr, nrports; |
3390 | 3216 | ||
3391 | if (!request_region(brdp->iobase, brdp->iosize, "istallion")) | 3217 | if ((brdp->iobase == 0) || (brdp->memaddr == 0)) { |
3392 | return -EIO; | 3218 | retval = -ENODEV; |
3393 | 3219 | goto err; | |
3394 | if ((brdp->iobase == 0) || (brdp->memaddr == 0)) | 3220 | } |
3395 | { | 3221 | |
3396 | release_region(brdp->iobase, brdp->iosize); | 3222 | if (!request_region(brdp->iobase, brdp->iosize, "istallion")) { |
3397 | return -ENODEV; | 3223 | retval = -EIO; |
3224 | goto err; | ||
3398 | } | 3225 | } |
3399 | 3226 | ||
3400 | brdp->iosize = ECP_IOSIZE; | 3227 | brdp->iosize = ECP_IOSIZE; |
@@ -3406,7 +3233,6 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3406 | */ | 3233 | */ |
3407 | switch (brdp->brdtype) { | 3234 | switch (brdp->brdtype) { |
3408 | case BRD_ECP: | 3235 | case BRD_ECP: |
3409 | brdp->membase = (void *) brdp->memaddr; | ||
3410 | brdp->memsize = ECP_MEMSIZE; | 3236 | brdp->memsize = ECP_MEMSIZE; |
3411 | brdp->pagesize = ECP_ATPAGESIZE; | 3237 | brdp->pagesize = ECP_ATPAGESIZE; |
3412 | brdp->init = stli_ecpinit; | 3238 | brdp->init = stli_ecpinit; |
@@ -3420,7 +3246,6 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3420 | break; | 3246 | break; |
3421 | 3247 | ||
3422 | case BRD_ECPE: | 3248 | case BRD_ECPE: |
3423 | brdp->membase = (void *) brdp->memaddr; | ||
3424 | brdp->memsize = ECP_MEMSIZE; | 3249 | brdp->memsize = ECP_MEMSIZE; |
3425 | brdp->pagesize = ECP_EIPAGESIZE; | 3250 | brdp->pagesize = ECP_EIPAGESIZE; |
3426 | brdp->init = stli_ecpeiinit; | 3251 | brdp->init = stli_ecpeiinit; |
@@ -3434,7 +3259,6 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3434 | break; | 3259 | break; |
3435 | 3260 | ||
3436 | case BRD_ECPMC: | 3261 | case BRD_ECPMC: |
3437 | brdp->membase = (void *) brdp->memaddr; | ||
3438 | brdp->memsize = ECP_MEMSIZE; | 3262 | brdp->memsize = ECP_MEMSIZE; |
3439 | brdp->pagesize = ECP_MCPAGESIZE; | 3263 | brdp->pagesize = ECP_MCPAGESIZE; |
3440 | brdp->init = NULL; | 3264 | brdp->init = NULL; |
@@ -3448,7 +3272,6 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3448 | break; | 3272 | break; |
3449 | 3273 | ||
3450 | case BRD_ECPPCI: | 3274 | case BRD_ECPPCI: |
3451 | brdp->membase = (void *) brdp->memaddr; | ||
3452 | brdp->memsize = ECP_PCIMEMSIZE; | 3275 | brdp->memsize = ECP_PCIMEMSIZE; |
3453 | brdp->pagesize = ECP_PCIPAGESIZE; | 3276 | brdp->pagesize = ECP_PCIPAGESIZE; |
3454 | brdp->init = stli_ecppciinit; | 3277 | brdp->init = stli_ecppciinit; |
@@ -3462,8 +3285,8 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3462 | break; | 3285 | break; |
3463 | 3286 | ||
3464 | default: | 3287 | default: |
3465 | release_region(brdp->iobase, brdp->iosize); | 3288 | retval = -EINVAL; |
3466 | return -EINVAL; | 3289 | goto err_reg; |
3467 | } | 3290 | } |
3468 | 3291 | ||
3469 | /* | 3292 | /* |
@@ -3475,10 +3298,9 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3475 | EBRDINIT(brdp); | 3298 | EBRDINIT(brdp); |
3476 | 3299 | ||
3477 | brdp->membase = ioremap(brdp->memaddr, brdp->memsize); | 3300 | brdp->membase = ioremap(brdp->memaddr, brdp->memsize); |
3478 | if (brdp->membase == NULL) | 3301 | if (brdp->membase == NULL) { |
3479 | { | 3302 | retval = -ENOMEM; |
3480 | release_region(brdp->iobase, brdp->iosize); | 3303 | goto err_reg; |
3481 | return -ENOMEM; | ||
3482 | } | 3304 | } |
3483 | 3305 | ||
3484 | /* | 3306 | /* |
@@ -3491,10 +3313,9 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3491 | memcpy_fromio(&sig, sigsp, sizeof(cdkecpsig_t)); | 3313 | memcpy_fromio(&sig, sigsp, sizeof(cdkecpsig_t)); |
3492 | EBRDDISABLE(brdp); | 3314 | EBRDDISABLE(brdp); |
3493 | 3315 | ||
3494 | if (sig.magic != cpu_to_le32(ECP_MAGIC)) | 3316 | if (sig.magic != cpu_to_le32(ECP_MAGIC)) { |
3495 | { | 3317 | retval = -ENODEV; |
3496 | release_region(brdp->iobase, brdp->iosize); | 3318 | goto err_unmap; |
3497 | return -ENODEV; | ||
3498 | } | 3319 | } |
3499 | 3320 | ||
3500 | /* | 3321 | /* |
@@ -3519,6 +3340,13 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3519 | 3340 | ||
3520 | brdp->state |= BST_FOUND; | 3341 | brdp->state |= BST_FOUND; |
3521 | return 0; | 3342 | return 0; |
3343 | err_unmap: | ||
3344 | iounmap(brdp->membase); | ||
3345 | brdp->membase = NULL; | ||
3346 | err_reg: | ||
3347 | release_region(brdp->iobase, brdp->iosize); | ||
3348 | err: | ||
3349 | return retval; | ||
3522 | } | 3350 | } |
3523 | 3351 | ||
3524 | /*****************************************************************************/ | 3352 | /*****************************************************************************/ |
@@ -3528,23 +3356,27 @@ static int stli_initecp(stlibrd_t *brdp) | |||
3528 | * This handles only these board types. | 3356 | * This handles only these board types. |
3529 | */ | 3357 | */ |
3530 | 3358 | ||
3531 | static int stli_initonb(stlibrd_t *brdp) | 3359 | static int stli_initonb(struct stlibrd *brdp) |
3532 | { | 3360 | { |
3533 | cdkonbsig_t sig; | 3361 | cdkonbsig_t sig; |
3534 | cdkonbsig_t __iomem *sigsp; | 3362 | cdkonbsig_t __iomem *sigsp; |
3535 | char *name; | 3363 | char *name; |
3536 | int i; | 3364 | int i, retval; |
3537 | 3365 | ||
3538 | /* | 3366 | /* |
3539 | * Do a basic sanity check on the IO and memory addresses. | 3367 | * Do a basic sanity check on the IO and memory addresses. |
3540 | */ | 3368 | */ |
3541 | if (brdp->iobase == 0 || brdp->memaddr == 0) | 3369 | if (brdp->iobase == 0 || brdp->memaddr == 0) { |
3542 | return -ENODEV; | 3370 | retval = -ENODEV; |
3371 | goto err; | ||
3372 | } | ||
3543 | 3373 | ||
3544 | brdp->iosize = ONB_IOSIZE; | 3374 | brdp->iosize = ONB_IOSIZE; |
3545 | 3375 | ||
3546 | if (!request_region(brdp->iobase, brdp->iosize, "istallion")) | 3376 | if (!request_region(brdp->iobase, brdp->iosize, "istallion")) { |
3547 | return -EIO; | 3377 | retval = -EIO; |
3378 | goto err; | ||
3379 | } | ||
3548 | 3380 | ||
3549 | /* | 3381 | /* |
3550 | * Based on the specific board type setup the common vars to access | 3382 | * Based on the specific board type setup the common vars to access |
@@ -3553,10 +3385,7 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3553 | */ | 3385 | */ |
3554 | switch (brdp->brdtype) { | 3386 | switch (brdp->brdtype) { |
3555 | case BRD_ONBOARD: | 3387 | case BRD_ONBOARD: |
3556 | case BRD_ONBOARD32: | ||
3557 | case BRD_ONBOARD2: | 3388 | case BRD_ONBOARD2: |
3558 | case BRD_ONBOARD2_32: | ||
3559 | case BRD_ONBOARDRS: | ||
3560 | brdp->memsize = ONB_MEMSIZE; | 3389 | brdp->memsize = ONB_MEMSIZE; |
3561 | brdp->pagesize = ONB_ATPAGESIZE; | 3390 | brdp->pagesize = ONB_ATPAGESIZE; |
3562 | brdp->init = stli_onbinit; | 3391 | brdp->init = stli_onbinit; |
@@ -3587,8 +3416,6 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3587 | break; | 3416 | break; |
3588 | 3417 | ||
3589 | case BRD_BRUMBY4: | 3418 | case BRD_BRUMBY4: |
3590 | case BRD_BRUMBY8: | ||
3591 | case BRD_BRUMBY16: | ||
3592 | brdp->memsize = BBY_MEMSIZE; | 3419 | brdp->memsize = BBY_MEMSIZE; |
3593 | brdp->pagesize = BBY_PAGESIZE; | 3420 | brdp->pagesize = BBY_PAGESIZE; |
3594 | brdp->init = stli_bbyinit; | 3421 | brdp->init = stli_bbyinit; |
@@ -3615,8 +3442,8 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3615 | break; | 3442 | break; |
3616 | 3443 | ||
3617 | default: | 3444 | default: |
3618 | release_region(brdp->iobase, brdp->iosize); | 3445 | retval = -EINVAL; |
3619 | return -EINVAL; | 3446 | goto err_reg; |
3620 | } | 3447 | } |
3621 | 3448 | ||
3622 | /* | 3449 | /* |
@@ -3628,10 +3455,9 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3628 | EBRDINIT(brdp); | 3455 | EBRDINIT(brdp); |
3629 | 3456 | ||
3630 | brdp->membase = ioremap(brdp->memaddr, brdp->memsize); | 3457 | brdp->membase = ioremap(brdp->memaddr, brdp->memsize); |
3631 | if (brdp->membase == NULL) | 3458 | if (brdp->membase == NULL) { |
3632 | { | 3459 | retval = -ENOMEM; |
3633 | release_region(brdp->iobase, brdp->iosize); | 3460 | goto err_reg; |
3634 | return -ENOMEM; | ||
3635 | } | 3461 | } |
3636 | 3462 | ||
3637 | /* | 3463 | /* |
@@ -3647,10 +3473,9 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3647 | if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) || | 3473 | if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) || |
3648 | sig.magic1 != cpu_to_le16(ONB_MAGIC1) || | 3474 | sig.magic1 != cpu_to_le16(ONB_MAGIC1) || |
3649 | sig.magic2 != cpu_to_le16(ONB_MAGIC2) || | 3475 | sig.magic2 != cpu_to_le16(ONB_MAGIC2) || |
3650 | sig.magic3 != cpu_to_le16(ONB_MAGIC3)) | 3476 | sig.magic3 != cpu_to_le16(ONB_MAGIC3)) { |
3651 | { | 3477 | retval = -ENODEV; |
3652 | release_region(brdp->iobase, brdp->iosize); | 3478 | goto err_unmap; |
3653 | return -ENODEV; | ||
3654 | } | 3479 | } |
3655 | 3480 | ||
3656 | /* | 3481 | /* |
@@ -3672,6 +3497,13 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3672 | 3497 | ||
3673 | brdp->state |= BST_FOUND; | 3498 | brdp->state |= BST_FOUND; |
3674 | return 0; | 3499 | return 0; |
3500 | err_unmap: | ||
3501 | iounmap(brdp->membase); | ||
3502 | brdp->membase = NULL; | ||
3503 | err_reg: | ||
3504 | release_region(brdp->iobase, brdp->iosize); | ||
3505 | err: | ||
3506 | return retval; | ||
3675 | } | 3507 | } |
3676 | 3508 | ||
3677 | /*****************************************************************************/ | 3509 | /*****************************************************************************/ |
@@ -3682,14 +3514,15 @@ static int stli_initonb(stlibrd_t *brdp) | |||
3682 | * read in the memory map, and get the show on the road... | 3514 | * read in the memory map, and get the show on the road... |
3683 | */ | 3515 | */ |
3684 | 3516 | ||
3685 | static int stli_startbrd(stlibrd_t *brdp) | 3517 | static int stli_startbrd(struct stlibrd *brdp) |
3686 | { | 3518 | { |
3687 | cdkhdr_t __iomem *hdrp; | 3519 | cdkhdr_t __iomem *hdrp; |
3688 | cdkmem_t __iomem *memp; | 3520 | cdkmem_t __iomem *memp; |
3689 | cdkasy_t __iomem *ap; | 3521 | cdkasy_t __iomem *ap; |
3690 | unsigned long flags; | 3522 | unsigned long flags; |
3691 | stliport_t *portp; | 3523 | unsigned int portnr, nrdevs, i; |
3692 | int portnr, nrdevs, i, rc = 0; | 3524 | struct stliport *portp; |
3525 | int rc = 0; | ||
3693 | u32 memoff; | 3526 | u32 memoff; |
3694 | 3527 | ||
3695 | spin_lock_irqsave(&brd_lock, flags); | 3528 | spin_lock_irqsave(&brd_lock, flags); |
@@ -3776,8 +3609,7 @@ stli_donestartup: | |||
3776 | 3609 | ||
3777 | if (! stli_timeron) { | 3610 | if (! stli_timeron) { |
3778 | stli_timeron++; | 3611 | stli_timeron++; |
3779 | stli_timerlist.expires = STLI_TIMEOUT; | 3612 | mod_timer(&stli_timerlist, STLI_TIMEOUT); |
3780 | add_timer(&stli_timerlist); | ||
3781 | } | 3613 | } |
3782 | 3614 | ||
3783 | return rc; | 3615 | return rc; |
@@ -3789,49 +3621,32 @@ stli_donestartup: | |||
3789 | * Probe and initialize the specified board. | 3621 | * Probe and initialize the specified board. |
3790 | */ | 3622 | */ |
3791 | 3623 | ||
3792 | static int __init stli_brdinit(stlibrd_t *brdp) | 3624 | static int __devinit stli_brdinit(struct stlibrd *brdp) |
3793 | { | 3625 | { |
3794 | stli_brds[brdp->brdnr] = brdp; | 3626 | int retval; |
3795 | 3627 | ||
3796 | switch (brdp->brdtype) { | 3628 | switch (brdp->brdtype) { |
3797 | case BRD_ECP: | 3629 | case BRD_ECP: |
3798 | case BRD_ECPE: | 3630 | case BRD_ECPE: |
3799 | case BRD_ECPMC: | 3631 | case BRD_ECPMC: |
3800 | case BRD_ECPPCI: | 3632 | case BRD_ECPPCI: |
3801 | stli_initecp(brdp); | 3633 | retval = stli_initecp(brdp); |
3802 | break; | 3634 | break; |
3803 | case BRD_ONBOARD: | 3635 | case BRD_ONBOARD: |
3804 | case BRD_ONBOARDE: | 3636 | case BRD_ONBOARDE: |
3805 | case BRD_ONBOARD2: | 3637 | case BRD_ONBOARD2: |
3806 | case BRD_ONBOARD32: | ||
3807 | case BRD_ONBOARD2_32: | ||
3808 | case BRD_ONBOARDRS: | ||
3809 | case BRD_BRUMBY4: | 3638 | case BRD_BRUMBY4: |
3810 | case BRD_BRUMBY8: | ||
3811 | case BRD_BRUMBY16: | ||
3812 | case BRD_STALLION: | 3639 | case BRD_STALLION: |
3813 | stli_initonb(brdp); | 3640 | retval = stli_initonb(brdp); |
3814 | break; | 3641 | break; |
3815 | case BRD_EASYIO: | ||
3816 | case BRD_ECH: | ||
3817 | case BRD_ECHMC: | ||
3818 | case BRD_ECHPCI: | ||
3819 | printk(KERN_ERR "STALLION: %s board type not supported in " | ||
3820 | "this driver\n", stli_brdnames[brdp->brdtype]); | ||
3821 | return -ENODEV; | ||
3822 | default: | 3642 | default: |
3823 | printk(KERN_ERR "STALLION: board=%d is unknown board " | 3643 | printk(KERN_ERR "STALLION: board=%d is unknown board " |
3824 | "type=%d\n", brdp->brdnr, brdp->brdtype); | 3644 | "type=%d\n", brdp->brdnr, brdp->brdtype); |
3825 | return -ENODEV; | 3645 | retval = -ENODEV; |
3826 | } | 3646 | } |
3827 | 3647 | ||
3828 | if ((brdp->state & BST_FOUND) == 0) { | 3648 | if (retval) |
3829 | printk(KERN_ERR "STALLION: %s board not found, board=%d " | 3649 | return retval; |
3830 | "io=%x mem=%x\n", | ||
3831 | stli_brdnames[brdp->brdtype], brdp->brdnr, | ||
3832 | brdp->iobase, (int) brdp->memaddr); | ||
3833 | return -ENODEV; | ||
3834 | } | ||
3835 | 3650 | ||
3836 | stli_initports(brdp); | 3651 | stli_initports(brdp); |
3837 | printk(KERN_INFO "STALLION: %s found, board=%d io=%x mem=%x " | 3652 | printk(KERN_INFO "STALLION: %s found, board=%d io=%x mem=%x " |
@@ -3841,6 +3656,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) | |||
3841 | return 0; | 3656 | return 0; |
3842 | } | 3657 | } |
3843 | 3658 | ||
3659 | #if STLI_EISAPROBE != 0 | ||
3844 | /*****************************************************************************/ | 3660 | /*****************************************************************************/ |
3845 | 3661 | ||
3846 | /* | 3662 | /* |
@@ -3848,7 +3664,7 @@ static int __init stli_brdinit(stlibrd_t *brdp) | |||
3848 | * might be. This is a bit if hack, but it is the best we can do. | 3664 | * might be. This is a bit if hack, but it is the best we can do. |
3849 | */ | 3665 | */ |
3850 | 3666 | ||
3851 | static int stli_eisamemprobe(stlibrd_t *brdp) | 3667 | static int stli_eisamemprobe(struct stlibrd *brdp) |
3852 | { | 3668 | { |
3853 | cdkecpsig_t ecpsig, __iomem *ecpsigp; | 3669 | cdkecpsig_t ecpsig, __iomem *ecpsigp; |
3854 | cdkonbsig_t onbsig, __iomem *onbsigp; | 3670 | cdkonbsig_t onbsig, __iomem *onbsigp; |
@@ -3894,7 +3710,7 @@ static int stli_eisamemprobe(stlibrd_t *brdp) | |||
3894 | continue; | 3710 | continue; |
3895 | 3711 | ||
3896 | if (brdp->brdtype == BRD_ECPE) { | 3712 | if (brdp->brdtype == BRD_ECPE) { |
3897 | ecpsigp = (cdkecpsig_t __iomem *) stli_ecpeigetmemptr(brdp, | 3713 | ecpsigp = stli_ecpeigetmemptr(brdp, |
3898 | CDK_SIGADDR, __LINE__); | 3714 | CDK_SIGADDR, __LINE__); |
3899 | memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); | 3715 | memcpy_fromio(&ecpsig, ecpsigp, sizeof(cdkecpsig_t)); |
3900 | if (ecpsig.magic == cpu_to_le32(ECP_MAGIC)) | 3716 | if (ecpsig.magic == cpu_to_le32(ECP_MAGIC)) |
@@ -3934,10 +3750,11 @@ static int stli_eisamemprobe(stlibrd_t *brdp) | |||
3934 | } | 3750 | } |
3935 | return 0; | 3751 | return 0; |
3936 | } | 3752 | } |
3753 | #endif | ||
3937 | 3754 | ||
3938 | static int stli_getbrdnr(void) | 3755 | static int stli_getbrdnr(void) |
3939 | { | 3756 | { |
3940 | int i; | 3757 | unsigned int i; |
3941 | 3758 | ||
3942 | for (i = 0; i < STL_MAXBRDS; i++) { | 3759 | for (i = 0; i < STL_MAXBRDS; i++) { |
3943 | if (!stli_brds[i]) { | 3760 | if (!stli_brds[i]) { |
@@ -3949,6 +3766,7 @@ static int stli_getbrdnr(void) | |||
3949 | return -1; | 3766 | return -1; |
3950 | } | 3767 | } |
3951 | 3768 | ||
3769 | #if STLI_EISAPROBE != 0 | ||
3952 | /*****************************************************************************/ | 3770 | /*****************************************************************************/ |
3953 | 3771 | ||
3954 | /* | 3772 | /* |
@@ -3963,9 +3781,9 @@ static int stli_getbrdnr(void) | |||
3963 | 3781 | ||
3964 | static int stli_findeisabrds(void) | 3782 | static int stli_findeisabrds(void) |
3965 | { | 3783 | { |
3966 | stlibrd_t *brdp; | 3784 | struct stlibrd *brdp; |
3967 | unsigned int iobase, eid; | 3785 | unsigned int iobase, eid, i; |
3968 | int i; | 3786 | int brdnr, found = 0; |
3969 | 3787 | ||
3970 | /* | 3788 | /* |
3971 | * Firstly check if this is an EISA system. If this is not an EISA system then | 3789 | * Firstly check if this is an EISA system. If this is not an EISA system then |
@@ -4003,9 +3821,11 @@ static int stli_findeisabrds(void) | |||
4003 | * Allocate a board structure and initialize it. | 3821 | * Allocate a board structure and initialize it. |
4004 | */ | 3822 | */ |
4005 | if ((brdp = stli_allocbrd()) == NULL) | 3823 | if ((brdp = stli_allocbrd()) == NULL) |
4006 | return -ENOMEM; | 3824 | return found ? : -ENOMEM; |
4007 | if ((brdp->brdnr = stli_getbrdnr()) < 0) | 3825 | brdnr = stli_getbrdnr(); |
4008 | return -ENOMEM; | 3826 | if (brdnr < 0) |
3827 | return found ? : -ENOMEM; | ||
3828 | brdp->brdnr = (unsigned int)brdnr; | ||
4009 | eid = inb(iobase + 0xc82); | 3829 | eid = inb(iobase + 0xc82); |
4010 | if (eid == ECP_EISAID) | 3830 | if (eid == ECP_EISAID) |
4011 | brdp->brdtype = BRD_ECPE; | 3831 | brdp->brdtype = BRD_ECPE; |
@@ -4017,11 +3837,24 @@ static int stli_findeisabrds(void) | |||
4017 | outb(0x1, (iobase + 0xc84)); | 3837 | outb(0x1, (iobase + 0xc84)); |
4018 | if (stli_eisamemprobe(brdp)) | 3838 | if (stli_eisamemprobe(brdp)) |
4019 | outb(0, (iobase + 0xc84)); | 3839 | outb(0, (iobase + 0xc84)); |
4020 | stli_brdinit(brdp); | 3840 | if (stli_brdinit(brdp) < 0) { |
3841 | kfree(brdp); | ||
3842 | continue; | ||
3843 | } | ||
3844 | |||
3845 | stli_brds[brdp->brdnr] = brdp; | ||
3846 | found++; | ||
3847 | |||
3848 | for (i = 0; i < brdp->nrports; i++) | ||
3849 | tty_register_device(stli_serial, | ||
3850 | brdp->brdnr * STL_MAXPORTS + i, NULL); | ||
4021 | } | 3851 | } |
4022 | 3852 | ||
4023 | return 0; | 3853 | return found; |
4024 | } | 3854 | } |
3855 | #else | ||
3856 | static inline int stli_findeisabrds(void) { return 0; } | ||
3857 | #endif | ||
4025 | 3858 | ||
4026 | /*****************************************************************************/ | 3859 | /*****************************************************************************/ |
4027 | 3860 | ||
@@ -4031,72 +3864,104 @@ static int stli_findeisabrds(void) | |||
4031 | 3864 | ||
4032 | /*****************************************************************************/ | 3865 | /*****************************************************************************/ |
4033 | 3866 | ||
4034 | #ifdef CONFIG_PCI | ||
4035 | |||
4036 | /* | 3867 | /* |
4037 | * We have a Stallion board. Allocate a board structure and | 3868 | * We have a Stallion board. Allocate a board structure and |
4038 | * initialize it. Read its IO and MEMORY resources from PCI | 3869 | * initialize it. Read its IO and MEMORY resources from PCI |
4039 | * configuration space. | 3870 | * configuration space. |
4040 | */ | 3871 | */ |
4041 | 3872 | ||
4042 | static int stli_initpcibrd(int brdtype, struct pci_dev *devp) | 3873 | static int __devinit stli_pciprobe(struct pci_dev *pdev, |
3874 | const struct pci_device_id *ent) | ||
4043 | { | 3875 | { |
4044 | stlibrd_t *brdp; | 3876 | struct stlibrd *brdp; |
4045 | 3877 | unsigned int i; | |
4046 | if (pci_enable_device(devp)) | 3878 | int brdnr, retval = -EIO; |
4047 | return -EIO; | 3879 | |
4048 | if ((brdp = stli_allocbrd()) == NULL) | 3880 | retval = pci_enable_device(pdev); |
4049 | return -ENOMEM; | 3881 | if (retval) |
4050 | if ((brdp->brdnr = stli_getbrdnr()) < 0) { | 3882 | goto err; |
3883 | brdp = stli_allocbrd(); | ||
3884 | if (brdp == NULL) { | ||
3885 | retval = -ENOMEM; | ||
3886 | goto err; | ||
3887 | } | ||
3888 | mutex_lock(&stli_brdslock); | ||
3889 | brdnr = stli_getbrdnr(); | ||
3890 | if (brdnr < 0) { | ||
4051 | printk(KERN_INFO "STALLION: too many boards found, " | 3891 | printk(KERN_INFO "STALLION: too many boards found, " |
4052 | "maximum supported %d\n", STL_MAXBRDS); | 3892 | "maximum supported %d\n", STL_MAXBRDS); |
4053 | return 0; | 3893 | mutex_unlock(&stli_brdslock); |
3894 | retval = -EIO; | ||
3895 | goto err_fr; | ||
4054 | } | 3896 | } |
4055 | brdp->brdtype = brdtype; | 3897 | brdp->brdnr = (unsigned int)brdnr; |
3898 | stli_brds[brdp->brdnr] = brdp; | ||
3899 | mutex_unlock(&stli_brdslock); | ||
3900 | brdp->brdtype = BRD_ECPPCI; | ||
4056 | /* | 3901 | /* |
4057 | * We have all resources from the board, so lets setup the actual | 3902 | * We have all resources from the board, so lets setup the actual |
4058 | * board structure now. | 3903 | * board structure now. |
4059 | */ | 3904 | */ |
4060 | brdp->iobase = pci_resource_start(devp, 3); | 3905 | brdp->iobase = pci_resource_start(pdev, 3); |
4061 | brdp->memaddr = pci_resource_start(devp, 2); | 3906 | brdp->memaddr = pci_resource_start(pdev, 2); |
4062 | stli_brdinit(brdp); | 3907 | retval = stli_brdinit(brdp); |
3908 | if (retval) | ||
3909 | goto err_null; | ||
3910 | |||
3911 | brdp->state |= BST_PROBED; | ||
3912 | pci_set_drvdata(pdev, brdp); | ||
3913 | |||
3914 | EBRDENABLE(brdp); | ||
3915 | brdp->enable = NULL; | ||
3916 | brdp->disable = NULL; | ||
3917 | |||
3918 | for (i = 0; i < brdp->nrports; i++) | ||
3919 | tty_register_device(stli_serial, brdp->brdnr * STL_MAXPORTS + i, | ||
3920 | &pdev->dev); | ||
4063 | 3921 | ||
4064 | return 0; | 3922 | return 0; |
3923 | err_null: | ||
3924 | stli_brds[brdp->brdnr] = NULL; | ||
3925 | err_fr: | ||
3926 | kfree(brdp); | ||
3927 | err: | ||
3928 | return retval; | ||
4065 | } | 3929 | } |
4066 | 3930 | ||
4067 | /*****************************************************************************/ | 3931 | static void stli_pciremove(struct pci_dev *pdev) |
3932 | { | ||
3933 | struct stlibrd *brdp = pci_get_drvdata(pdev); | ||
4068 | 3934 | ||
4069 | /* | 3935 | stli_cleanup_ports(brdp); |
4070 | * Find all Stallion PCI boards that might be installed. Initialize each | ||
4071 | * one as it is found. | ||
4072 | */ | ||
4073 | 3936 | ||
4074 | static int stli_findpcibrds(void) | 3937 | iounmap(brdp->membase); |
4075 | { | 3938 | if (brdp->iosize > 0) |
4076 | struct pci_dev *dev = NULL; | 3939 | release_region(brdp->iobase, brdp->iosize); |
4077 | 3940 | ||
4078 | while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, PCI_DEVICE_ID_ECRA, dev))) { | 3941 | stli_brds[brdp->brdnr] = NULL; |
4079 | stli_initpcibrd(BRD_ECPPCI, dev); | 3942 | kfree(brdp); |
4080 | } | ||
4081 | return 0; | ||
4082 | } | 3943 | } |
4083 | 3944 | ||
4084 | #endif | 3945 | static struct pci_driver stli_pcidriver = { |
4085 | 3946 | .name = "istallion", | |
3947 | .id_table = istallion_pci_tbl, | ||
3948 | .probe = stli_pciprobe, | ||
3949 | .remove = __devexit_p(stli_pciremove) | ||
3950 | }; | ||
4086 | /*****************************************************************************/ | 3951 | /*****************************************************************************/ |
4087 | 3952 | ||
4088 | /* | 3953 | /* |
4089 | * Allocate a new board structure. Fill out the basic info in it. | 3954 | * Allocate a new board structure. Fill out the basic info in it. |
4090 | */ | 3955 | */ |
4091 | 3956 | ||
4092 | static stlibrd_t *stli_allocbrd(void) | 3957 | static struct stlibrd *stli_allocbrd(void) |
4093 | { | 3958 | { |
4094 | stlibrd_t *brdp; | 3959 | struct stlibrd *brdp; |
4095 | 3960 | ||
4096 | brdp = kzalloc(sizeof(stlibrd_t), GFP_KERNEL); | 3961 | brdp = kzalloc(sizeof(struct stlibrd), GFP_KERNEL); |
4097 | if (!brdp) { | 3962 | if (!brdp) { |
4098 | printk(KERN_ERR "STALLION: failed to allocate memory " | 3963 | printk(KERN_ERR "STALLION: failed to allocate memory " |
4099 | "(size=%Zd)\n", sizeof(stlibrd_t)); | 3964 | "(size=%Zd)\n", sizeof(struct stlibrd)); |
4100 | return NULL; | 3965 | return NULL; |
4101 | } | 3966 | } |
4102 | brdp->magic = STLI_BOARDMAGIC; | 3967 | brdp->magic = STLI_BOARDMAGIC; |
@@ -4112,43 +3977,37 @@ static stlibrd_t *stli_allocbrd(void) | |||
4112 | 3977 | ||
4113 | static int stli_initbrds(void) | 3978 | static int stli_initbrds(void) |
4114 | { | 3979 | { |
4115 | stlibrd_t *brdp, *nxtbrdp; | 3980 | struct stlibrd *brdp, *nxtbrdp; |
4116 | stlconf_t *confp; | 3981 | struct stlconf conf; |
4117 | int i, j; | 3982 | unsigned int i, j, found = 0; |
4118 | 3983 | int retval; | |
4119 | if (stli_nrbrds > STL_MAXBRDS) { | ||
4120 | printk(KERN_INFO "STALLION: too many boards in configuration " | ||
4121 | "table, truncating to %d\n", STL_MAXBRDS); | ||
4122 | stli_nrbrds = STL_MAXBRDS; | ||
4123 | } | ||
4124 | 3984 | ||
4125 | /* | 3985 | for (stli_nrbrds = 0; stli_nrbrds < ARRAY_SIZE(stli_brdsp); |
4126 | * Firstly scan the list of static boards configured. Allocate | 3986 | stli_nrbrds++) { |
4127 | * resources and initialize the boards as found. If this is a | 3987 | memset(&conf, 0, sizeof(conf)); |
4128 | * module then let the module args override static configuration. | 3988 | if (stli_parsebrd(&conf, stli_brdsp[stli_nrbrds]) == 0) |
4129 | */ | 3989 | continue; |
4130 | for (i = 0; (i < stli_nrbrds); i++) { | ||
4131 | confp = &stli_brdconf[i]; | ||
4132 | stli_parsebrd(confp, stli_brdsp[i]); | ||
4133 | if ((brdp = stli_allocbrd()) == NULL) | 3990 | if ((brdp = stli_allocbrd()) == NULL) |
4134 | return -ENOMEM; | 3991 | continue; |
4135 | brdp->brdnr = i; | 3992 | brdp->brdnr = stli_nrbrds; |
4136 | brdp->brdtype = confp->brdtype; | 3993 | brdp->brdtype = conf.brdtype; |
4137 | brdp->iobase = confp->ioaddr1; | 3994 | brdp->iobase = conf.ioaddr1; |
4138 | brdp->memaddr = confp->memaddr; | 3995 | brdp->memaddr = conf.memaddr; |
4139 | stli_brdinit(brdp); | 3996 | if (stli_brdinit(brdp) < 0) { |
3997 | kfree(brdp); | ||
3998 | continue; | ||
3999 | } | ||
4000 | stli_brds[brdp->brdnr] = brdp; | ||
4001 | found++; | ||
4002 | |||
4003 | for (i = 0; i < brdp->nrports; i++) | ||
4004 | tty_register_device(stli_serial, | ||
4005 | brdp->brdnr * STL_MAXPORTS + i, NULL); | ||
4140 | } | 4006 | } |
4141 | 4007 | ||
4142 | /* | 4008 | retval = stli_findeisabrds(); |
4143 | * Static configuration table done, so now use dynamic methods to | 4009 | if (retval > 0) |
4144 | * see if any more boards should be configured. | 4010 | found += retval; |
4145 | */ | ||
4146 | stli_argbrds(); | ||
4147 | if (STLI_EISAPROBE) | ||
4148 | stli_findeisabrds(); | ||
4149 | #ifdef CONFIG_PCI | ||
4150 | stli_findpcibrds(); | ||
4151 | #endif | ||
4152 | 4011 | ||
4153 | /* | 4012 | /* |
4154 | * All found boards are initialized. Now for a little optimization, if | 4013 | * All found boards are initialized. Now for a little optimization, if |
@@ -4188,7 +4047,16 @@ static int stli_initbrds(void) | |||
4188 | } | 4047 | } |
4189 | } | 4048 | } |
4190 | 4049 | ||
4050 | retval = pci_register_driver(&stli_pcidriver); | ||
4051 | if (retval && found == 0) { | ||
4052 | printk(KERN_ERR "Neither isa nor eisa cards found nor pci " | ||
4053 | "driver can be registered!\n"); | ||
4054 | goto err; | ||
4055 | } | ||
4056 | |||
4191 | return 0; | 4057 | return 0; |
4058 | err: | ||
4059 | return retval; | ||
4192 | } | 4060 | } |
4193 | 4061 | ||
4194 | /*****************************************************************************/ | 4062 | /*****************************************************************************/ |
@@ -4202,13 +4070,14 @@ static int stli_initbrds(void) | |||
4202 | static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) | 4070 | static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, loff_t *offp) |
4203 | { | 4071 | { |
4204 | unsigned long flags; | 4072 | unsigned long flags; |
4205 | void *memptr; | 4073 | void __iomem *memptr; |
4206 | stlibrd_t *brdp; | 4074 | struct stlibrd *brdp; |
4207 | int brdnr, size, n; | 4075 | unsigned int brdnr; |
4076 | int size, n; | ||
4208 | void *p; | 4077 | void *p; |
4209 | loff_t off = *offp; | 4078 | loff_t off = *offp; |
4210 | 4079 | ||
4211 | brdnr = iminor(fp->f_dentry->d_inode); | 4080 | brdnr = iminor(fp->f_path.dentry->d_inode); |
4212 | if (brdnr >= stli_nrbrds) | 4081 | if (brdnr >= stli_nrbrds) |
4213 | return -ENODEV; | 4082 | return -ENODEV; |
4214 | brdp = stli_brds[brdnr]; | 4083 | brdp = stli_brds[brdnr]; |
@@ -4219,7 +4088,7 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof | |||
4219 | if (off >= brdp->memsize || off + count < off) | 4088 | if (off >= brdp->memsize || off + count < off) |
4220 | return 0; | 4089 | return 0; |
4221 | 4090 | ||
4222 | size = MIN(count, (brdp->memsize - off)); | 4091 | size = min(count, (size_t)(brdp->memsize - off)); |
4223 | 4092 | ||
4224 | /* | 4093 | /* |
4225 | * Copy the data a page at a time | 4094 | * Copy the data a page at a time |
@@ -4232,9 +4101,9 @@ static ssize_t stli_memread(struct file *fp, char __user *buf, size_t count, lof | |||
4232 | while (size > 0) { | 4101 | while (size > 0) { |
4233 | spin_lock_irqsave(&brd_lock, flags); | 4102 | spin_lock_irqsave(&brd_lock, flags); |
4234 | EBRDENABLE(brdp); | 4103 | EBRDENABLE(brdp); |
4235 | memptr = (void *) EBRDGETMEMPTR(brdp, off); | 4104 | memptr = EBRDGETMEMPTR(brdp, off); |
4236 | n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); | 4105 | n = min(size, (int)(brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); |
4237 | n = MIN(n, PAGE_SIZE); | 4106 | n = min(n, (int)PAGE_SIZE); |
4238 | memcpy_fromio(p, memptr, n); | 4107 | memcpy_fromio(p, memptr, n); |
4239 | EBRDDISABLE(brdp); | 4108 | EBRDDISABLE(brdp); |
4240 | spin_unlock_irqrestore(&brd_lock, flags); | 4109 | spin_unlock_irqrestore(&brd_lock, flags); |
@@ -4265,14 +4134,15 @@ out: | |||
4265 | static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) | 4134 | static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t count, loff_t *offp) |
4266 | { | 4135 | { |
4267 | unsigned long flags; | 4136 | unsigned long flags; |
4268 | void *memptr; | 4137 | void __iomem *memptr; |
4269 | stlibrd_t *brdp; | 4138 | struct stlibrd *brdp; |
4270 | char __user *chbuf; | 4139 | char __user *chbuf; |
4271 | int brdnr, size, n; | 4140 | unsigned int brdnr; |
4141 | int size, n; | ||
4272 | void *p; | 4142 | void *p; |
4273 | loff_t off = *offp; | 4143 | loff_t off = *offp; |
4274 | 4144 | ||
4275 | brdnr = iminor(fp->f_dentry->d_inode); | 4145 | brdnr = iminor(fp->f_path.dentry->d_inode); |
4276 | 4146 | ||
4277 | if (brdnr >= stli_nrbrds) | 4147 | if (brdnr >= stli_nrbrds) |
4278 | return -ENODEV; | 4148 | return -ENODEV; |
@@ -4285,7 +4155,7 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou | |||
4285 | return 0; | 4155 | return 0; |
4286 | 4156 | ||
4287 | chbuf = (char __user *) buf; | 4157 | chbuf = (char __user *) buf; |
4288 | size = MIN(count, (brdp->memsize - off)); | 4158 | size = min(count, (size_t)(brdp->memsize - off)); |
4289 | 4159 | ||
4290 | /* | 4160 | /* |
4291 | * Copy the data a page at a time | 4161 | * Copy the data a page at a time |
@@ -4296,8 +4166,8 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou | |||
4296 | return -ENOMEM; | 4166 | return -ENOMEM; |
4297 | 4167 | ||
4298 | while (size > 0) { | 4168 | while (size > 0) { |
4299 | n = MIN(size, (brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); | 4169 | n = min(size, (int)(brdp->pagesize - (((unsigned long) off) % brdp->pagesize))); |
4300 | n = MIN(n, PAGE_SIZE); | 4170 | n = min(n, (int)PAGE_SIZE); |
4301 | if (copy_from_user(p, chbuf, n)) { | 4171 | if (copy_from_user(p, chbuf, n)) { |
4302 | if (count == 0) | 4172 | if (count == 0) |
4303 | count = -EFAULT; | 4173 | count = -EFAULT; |
@@ -4305,7 +4175,7 @@ static ssize_t stli_memwrite(struct file *fp, const char __user *buf, size_t cou | |||
4305 | } | 4175 | } |
4306 | spin_lock_irqsave(&brd_lock, flags); | 4176 | spin_lock_irqsave(&brd_lock, flags); |
4307 | EBRDENABLE(brdp); | 4177 | EBRDENABLE(brdp); |
4308 | memptr = (void *) EBRDGETMEMPTR(brdp, off); | 4178 | memptr = EBRDGETMEMPTR(brdp, off); |
4309 | memcpy_toio(memptr, p, n); | 4179 | memcpy_toio(memptr, p, n); |
4310 | EBRDDISABLE(brdp); | 4180 | EBRDDISABLE(brdp); |
4311 | spin_unlock_irqrestore(&brd_lock, flags); | 4181 | spin_unlock_irqrestore(&brd_lock, flags); |
@@ -4327,8 +4197,8 @@ out: | |||
4327 | 4197 | ||
4328 | static int stli_getbrdstats(combrd_t __user *bp) | 4198 | static int stli_getbrdstats(combrd_t __user *bp) |
4329 | { | 4199 | { |
4330 | stlibrd_t *brdp; | 4200 | struct stlibrd *brdp; |
4331 | int i; | 4201 | unsigned int i; |
4332 | 4202 | ||
4333 | if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) | 4203 | if (copy_from_user(&stli_brdstats, bp, sizeof(combrd_t))) |
4334 | return -EFAULT; | 4204 | return -EFAULT; |
@@ -4364,19 +4234,20 @@ static int stli_getbrdstats(combrd_t __user *bp) | |||
4364 | * Resolve the referenced port number into a port struct pointer. | 4234 | * Resolve the referenced port number into a port struct pointer. |
4365 | */ | 4235 | */ |
4366 | 4236 | ||
4367 | static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) | 4237 | static struct stliport *stli_getport(unsigned int brdnr, unsigned int panelnr, |
4238 | unsigned int portnr) | ||
4368 | { | 4239 | { |
4369 | stlibrd_t *brdp; | 4240 | struct stlibrd *brdp; |
4370 | int i; | 4241 | unsigned int i; |
4371 | 4242 | ||
4372 | if (brdnr < 0 || brdnr >= STL_MAXBRDS) | 4243 | if (brdnr >= STL_MAXBRDS) |
4373 | return NULL; | 4244 | return NULL; |
4374 | brdp = stli_brds[brdnr]; | 4245 | brdp = stli_brds[brdnr]; |
4375 | if (brdp == NULL) | 4246 | if (brdp == NULL) |
4376 | return NULL; | 4247 | return NULL; |
4377 | for (i = 0; (i < panelnr); i++) | 4248 | for (i = 0; (i < panelnr); i++) |
4378 | portnr += brdp->panels[i]; | 4249 | portnr += brdp->panels[i]; |
4379 | if ((portnr < 0) || (portnr >= brdp->nrports)) | 4250 | if (portnr >= brdp->nrports) |
4380 | return NULL; | 4251 | return NULL; |
4381 | return brdp->ports[portnr]; | 4252 | return brdp->ports[portnr]; |
4382 | } | 4253 | } |
@@ -4389,10 +4260,10 @@ static stliport_t *stli_getport(int brdnr, int panelnr, int portnr) | |||
4389 | * what port to get stats for (used through board control device). | 4260 | * what port to get stats for (used through board control device). |
4390 | */ | 4261 | */ |
4391 | 4262 | ||
4392 | static int stli_portcmdstats(stliport_t *portp) | 4263 | static int stli_portcmdstats(struct stliport *portp) |
4393 | { | 4264 | { |
4394 | unsigned long flags; | 4265 | unsigned long flags; |
4395 | stlibrd_t *brdp; | 4266 | struct stlibrd *brdp; |
4396 | int rc; | 4267 | int rc; |
4397 | 4268 | ||
4398 | memset(&stli_comstats, 0, sizeof(comstats_t)); | 4269 | memset(&stli_comstats, 0, sizeof(comstats_t)); |
@@ -4463,9 +4334,9 @@ static int stli_portcmdstats(stliport_t *portp) | |||
4463 | * what port to get stats for (used through board control device). | 4334 | * what port to get stats for (used through board control device). |
4464 | */ | 4335 | */ |
4465 | 4336 | ||
4466 | static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) | 4337 | static int stli_getportstats(struct stliport *portp, comstats_t __user *cp) |
4467 | { | 4338 | { |
4468 | stlibrd_t *brdp; | 4339 | struct stlibrd *brdp; |
4469 | int rc; | 4340 | int rc; |
4470 | 4341 | ||
4471 | if (!portp) { | 4342 | if (!portp) { |
@@ -4494,9 +4365,9 @@ static int stli_getportstats(stliport_t *portp, comstats_t __user *cp) | |||
4494 | * Clear the port stats structure. We also return it zeroed out... | 4365 | * Clear the port stats structure. We also return it zeroed out... |
4495 | */ | 4366 | */ |
4496 | 4367 | ||
4497 | static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) | 4368 | static int stli_clrportstats(struct stliport *portp, comstats_t __user *cp) |
4498 | { | 4369 | { |
4499 | stlibrd_t *brdp; | 4370 | struct stlibrd *brdp; |
4500 | int rc; | 4371 | int rc; |
4501 | 4372 | ||
4502 | if (!portp) { | 4373 | if (!portp) { |
@@ -4533,17 +4404,18 @@ static int stli_clrportstats(stliport_t *portp, comstats_t __user *cp) | |||
4533 | * Return the entire driver ports structure to a user app. | 4404 | * Return the entire driver ports structure to a user app. |
4534 | */ | 4405 | */ |
4535 | 4406 | ||
4536 | static int stli_getportstruct(stliport_t __user *arg) | 4407 | static int stli_getportstruct(struct stliport __user *arg) |
4537 | { | 4408 | { |
4538 | stliport_t *portp; | 4409 | struct stliport stli_dummyport; |
4410 | struct stliport *portp; | ||
4539 | 4411 | ||
4540 | if (copy_from_user(&stli_dummyport, arg, sizeof(stliport_t))) | 4412 | if (copy_from_user(&stli_dummyport, arg, sizeof(struct stliport))) |
4541 | return -EFAULT; | 4413 | return -EFAULT; |
4542 | portp = stli_getport(stli_dummyport.brdnr, stli_dummyport.panelnr, | 4414 | portp = stli_getport(stli_dummyport.brdnr, stli_dummyport.panelnr, |
4543 | stli_dummyport.portnr); | 4415 | stli_dummyport.portnr); |
4544 | if (!portp) | 4416 | if (!portp) |
4545 | return -ENODEV; | 4417 | return -ENODEV; |
4546 | if (copy_to_user(arg, portp, sizeof(stliport_t))) | 4418 | if (copy_to_user(arg, portp, sizeof(struct stliport))) |
4547 | return -EFAULT; | 4419 | return -EFAULT; |
4548 | return 0; | 4420 | return 0; |
4549 | } | 4421 | } |
@@ -4554,18 +4426,19 @@ static int stli_getportstruct(stliport_t __user *arg) | |||
4554 | * Return the entire driver board structure to a user app. | 4426 | * Return the entire driver board structure to a user app. |
4555 | */ | 4427 | */ |
4556 | 4428 | ||
4557 | static int stli_getbrdstruct(stlibrd_t __user *arg) | 4429 | static int stli_getbrdstruct(struct stlibrd __user *arg) |
4558 | { | 4430 | { |
4559 | stlibrd_t *brdp; | 4431 | struct stlibrd stli_dummybrd; |
4432 | struct stlibrd *brdp; | ||
4560 | 4433 | ||
4561 | if (copy_from_user(&stli_dummybrd, arg, sizeof(stlibrd_t))) | 4434 | if (copy_from_user(&stli_dummybrd, arg, sizeof(struct stlibrd))) |
4562 | return -EFAULT; | 4435 | return -EFAULT; |
4563 | if ((stli_dummybrd.brdnr < 0) || (stli_dummybrd.brdnr >= STL_MAXBRDS)) | 4436 | if (stli_dummybrd.brdnr >= STL_MAXBRDS) |
4564 | return -ENODEV; | 4437 | return -ENODEV; |
4565 | brdp = stli_brds[stli_dummybrd.brdnr]; | 4438 | brdp = stli_brds[stli_dummybrd.brdnr]; |
4566 | if (!brdp) | 4439 | if (!brdp) |
4567 | return -ENODEV; | 4440 | return -ENODEV; |
4568 | if (copy_to_user(arg, brdp, sizeof(stlibrd_t))) | 4441 | if (copy_to_user(arg, brdp, sizeof(struct stlibrd))) |
4569 | return -EFAULT; | 4442 | return -EFAULT; |
4570 | return 0; | 4443 | return 0; |
4571 | } | 4444 | } |
@@ -4580,7 +4453,7 @@ static int stli_getbrdstruct(stlibrd_t __user *arg) | |||
4580 | 4453 | ||
4581 | static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) | 4454 | static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) |
4582 | { | 4455 | { |
4583 | stlibrd_t *brdp; | 4456 | struct stlibrd *brdp; |
4584 | int brdnr, rc, done; | 4457 | int brdnr, rc, done; |
4585 | void __user *argp = (void __user *)arg; | 4458 | void __user *argp = (void __user *)arg; |
4586 | 4459 | ||
@@ -4654,7 +4527,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un | |||
4654 | return rc; | 4527 | return rc; |
4655 | } | 4528 | } |
4656 | 4529 | ||
4657 | static struct tty_operations stli_ops = { | 4530 | static const struct tty_operations stli_ops = { |
4658 | .open = stli_open, | 4531 | .open = stli_open, |
4659 | .close = stli_close, | 4532 | .close = stli_close, |
4660 | .write = stli_write, | 4533 | .write = stli_write, |
@@ -4679,46 +4552,53 @@ static struct tty_operations stli_ops = { | |||
4679 | }; | 4552 | }; |
4680 | 4553 | ||
4681 | /*****************************************************************************/ | 4554 | /*****************************************************************************/ |
4555 | /* | ||
4556 | * Loadable module initialization stuff. | ||
4557 | */ | ||
4558 | |||
4559 | static void istallion_cleanup_isa(void) | ||
4560 | { | ||
4561 | struct stlibrd *brdp; | ||
4562 | unsigned int j; | ||
4682 | 4563 | ||
4683 | static int __init stli_init(void) | 4564 | for (j = 0; (j < stli_nrbrds); j++) { |
4565 | if ((brdp = stli_brds[j]) == NULL || (brdp->state & BST_PROBED)) | ||
4566 | continue; | ||
4567 | |||
4568 | stli_cleanup_ports(brdp); | ||
4569 | |||
4570 | iounmap(brdp->membase); | ||
4571 | if (brdp->iosize > 0) | ||
4572 | release_region(brdp->iobase, brdp->iosize); | ||
4573 | kfree(brdp); | ||
4574 | stli_brds[j] = NULL; | ||
4575 | } | ||
4576 | } | ||
4577 | |||
4578 | static int __init istallion_module_init(void) | ||
4684 | { | 4579 | { |
4685 | int i; | 4580 | unsigned int i; |
4581 | int retval; | ||
4582 | |||
4686 | printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); | 4583 | printk(KERN_INFO "%s: version %s\n", stli_drvtitle, stli_drvversion); |
4687 | 4584 | ||
4688 | spin_lock_init(&stli_lock); | 4585 | spin_lock_init(&stli_lock); |
4689 | spin_lock_init(&brd_lock); | 4586 | spin_lock_init(&brd_lock); |
4690 | 4587 | ||
4691 | stli_initbrds(); | ||
4692 | |||
4693 | stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); | ||
4694 | if (!stli_serial) | ||
4695 | return -ENOMEM; | ||
4696 | |||
4697 | /* | ||
4698 | * Allocate a temporary write buffer. | ||
4699 | */ | ||
4700 | stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); | 4588 | stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); |
4701 | if (!stli_txcookbuf) | 4589 | if (!stli_txcookbuf) { |
4702 | printk(KERN_ERR "STALLION: failed to allocate memory " | 4590 | printk(KERN_ERR "STALLION: failed to allocate memory " |
4703 | "(size=%d)\n", STLI_TXBUFSIZE); | 4591 | "(size=%d)\n", STLI_TXBUFSIZE); |
4592 | retval = -ENOMEM; | ||
4593 | goto err; | ||
4594 | } | ||
4704 | 4595 | ||
4705 | /* | 4596 | stli_serial = alloc_tty_driver(STL_MAXBRDS * STL_MAXPORTS); |
4706 | * Set up a character driver for the shared memory region. We need this | 4597 | if (!stli_serial) { |
4707 | * to down load the slave code image. Also it is a useful debugging tool. | 4598 | retval = -ENOMEM; |
4708 | */ | 4599 | goto err_free; |
4709 | if (register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem)) | 4600 | } |
4710 | printk(KERN_ERR "STALLION: failed to register serial memory " | ||
4711 | "device\n"); | ||
4712 | |||
4713 | istallion_class = class_create(THIS_MODULE, "staliomem"); | ||
4714 | for (i = 0; i < 4; i++) | ||
4715 | class_device_create(istallion_class, NULL, | ||
4716 | MKDEV(STL_SIOMEMMAJOR, i), | ||
4717 | NULL, "staliomem%d", i); | ||
4718 | 4601 | ||
4719 | /* | ||
4720 | * Set up the tty driver structure and register us as a driver. | ||
4721 | */ | ||
4722 | stli_serial->owner = THIS_MODULE; | 4602 | stli_serial->owner = THIS_MODULE; |
4723 | stli_serial->driver_name = stli_drvname; | 4603 | stli_serial->driver_name = stli_drvname; |
4724 | stli_serial->name = stli_serialname; | 4604 | stli_serial->name = stli_serialname; |
@@ -4727,15 +4607,79 @@ static int __init stli_init(void) | |||
4727 | stli_serial->type = TTY_DRIVER_TYPE_SERIAL; | 4607 | stli_serial->type = TTY_DRIVER_TYPE_SERIAL; |
4728 | stli_serial->subtype = SERIAL_TYPE_NORMAL; | 4608 | stli_serial->subtype = SERIAL_TYPE_NORMAL; |
4729 | stli_serial->init_termios = stli_deftermios; | 4609 | stli_serial->init_termios = stli_deftermios; |
4730 | stli_serial->flags = TTY_DRIVER_REAL_RAW; | 4610 | stli_serial->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; |
4731 | tty_set_operations(stli_serial, &stli_ops); | 4611 | tty_set_operations(stli_serial, &stli_ops); |
4732 | 4612 | ||
4733 | if (tty_register_driver(stli_serial)) { | 4613 | retval = tty_register_driver(stli_serial); |
4734 | put_tty_driver(stli_serial); | 4614 | if (retval) { |
4735 | printk(KERN_ERR "STALLION: failed to register serial driver\n"); | 4615 | printk(KERN_ERR "STALLION: failed to register serial driver\n"); |
4736 | return -EBUSY; | 4616 | goto err_ttyput; |
4737 | } | 4617 | } |
4618 | |||
4619 | retval = stli_initbrds(); | ||
4620 | if (retval) | ||
4621 | goto err_ttyunr; | ||
4622 | |||
4623 | /* | ||
4624 | * Set up a character driver for the shared memory region. We need this | ||
4625 | * to down load the slave code image. Also it is a useful debugging tool. | ||
4626 | */ | ||
4627 | retval = register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem); | ||
4628 | if (retval) { | ||
4629 | printk(KERN_ERR "STALLION: failed to register serial memory " | ||
4630 | "device\n"); | ||
4631 | goto err_deinit; | ||
4632 | } | ||
4633 | |||
4634 | istallion_class = class_create(THIS_MODULE, "staliomem"); | ||
4635 | for (i = 0; i < 4; i++) | ||
4636 | class_device_create(istallion_class, NULL, | ||
4637 | MKDEV(STL_SIOMEMMAJOR, i), | ||
4638 | NULL, "staliomem%d", i); | ||
4639 | |||
4738 | return 0; | 4640 | return 0; |
4641 | err_deinit: | ||
4642 | pci_unregister_driver(&stli_pcidriver); | ||
4643 | istallion_cleanup_isa(); | ||
4644 | err_ttyunr: | ||
4645 | tty_unregister_driver(stli_serial); | ||
4646 | err_ttyput: | ||
4647 | put_tty_driver(stli_serial); | ||
4648 | err_free: | ||
4649 | kfree(stli_txcookbuf); | ||
4650 | err: | ||
4651 | return retval; | ||
4739 | } | 4652 | } |
4740 | 4653 | ||
4741 | /*****************************************************************************/ | 4654 | /*****************************************************************************/ |
4655 | |||
4656 | static void __exit istallion_module_exit(void) | ||
4657 | { | ||
4658 | unsigned int j; | ||
4659 | |||
4660 | printk(KERN_INFO "Unloading %s: version %s\n", stli_drvtitle, | ||
4661 | stli_drvversion); | ||
4662 | |||
4663 | if (stli_timeron) { | ||
4664 | stli_timeron = 0; | ||
4665 | del_timer_sync(&stli_timerlist); | ||
4666 | } | ||
4667 | |||
4668 | unregister_chrdev(STL_SIOMEMMAJOR, "staliomem"); | ||
4669 | |||
4670 | for (j = 0; j < 4; j++) | ||
4671 | class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, | ||
4672 | j)); | ||
4673 | class_destroy(istallion_class); | ||
4674 | |||
4675 | pci_unregister_driver(&stli_pcidriver); | ||
4676 | istallion_cleanup_isa(); | ||
4677 | |||
4678 | tty_unregister_driver(stli_serial); | ||
4679 | put_tty_driver(stli_serial); | ||
4680 | |||
4681 | kfree(stli_txcookbuf); | ||
4682 | } | ||
4683 | |||
4684 | module_init(istallion_module_init); | ||
4685 | module_exit(istallion_module_exit); | ||