diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/moxa.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 7f4d1ec4b03d..2701f7c9f938 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -95,7 +95,6 @@ MODULE_DEVICE_TABLE(pci, moxa_pcibrds); | |||
95 | static struct moxa_board_conf { | 95 | static struct moxa_board_conf { |
96 | int boardType; | 96 | int boardType; |
97 | int numPorts; | 97 | int numPorts; |
98 | unsigned long baseAddr; | ||
99 | int busType; | 98 | int busType; |
100 | 99 | ||
101 | int loadstat; | 100 | int loadstat; |
@@ -159,18 +158,21 @@ struct moxa_port { | |||
159 | static int ttymajor = MOXAMAJOR; | 158 | static int ttymajor = MOXAMAJOR; |
160 | /* Variables for insmod */ | 159 | /* Variables for insmod */ |
161 | #ifdef MODULE | 160 | #ifdef MODULE |
162 | static int baseaddr[4]; | 161 | static unsigned long baseaddr[MAX_BOARDS]; |
163 | static int type[4]; | 162 | static unsigned int type[MAX_BOARDS]; |
164 | static int numports[4]; | 163 | static unsigned int numports[MAX_BOARDS]; |
165 | #endif | 164 | #endif |
166 | 165 | ||
167 | MODULE_AUTHOR("William Chen"); | 166 | MODULE_AUTHOR("William Chen"); |
168 | MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); | 167 | MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); |
169 | MODULE_LICENSE("GPL"); | 168 | MODULE_LICENSE("GPL"); |
170 | #ifdef MODULE | 169 | #ifdef MODULE |
171 | module_param_array(type, int, NULL, 0); | 170 | module_param_array(type, uint, NULL, 0); |
172 | module_param_array(baseaddr, int, NULL, 0); | 171 | MODULE_PARM_DESC(type, "card type: C218=2, C320=4"); |
173 | module_param_array(numports, int, NULL, 0); | 172 | module_param_array(baseaddr, ulong, NULL, 0); |
173 | MODULE_PARM_DESC(baseaddr, "base address"); | ||
174 | module_param_array(numports, uint, NULL, 0); | ||
175 | MODULE_PARM_DESC(numports, "numports (ignored for C218)"); | ||
174 | #endif | 176 | #endif |
175 | module_param(ttymajor, int, 0); | 177 | module_param(ttymajor, int, 0); |
176 | 178 | ||
@@ -335,8 +337,9 @@ static struct pci_driver moxa_pci_driver = { | |||
335 | 337 | ||
336 | static int __init moxa_init(void) | 338 | static int __init moxa_init(void) |
337 | { | 339 | { |
338 | int i, numBoards = 0, retval = 0; | ||
339 | struct moxa_port *ch; | 340 | struct moxa_port *ch; |
341 | unsigned int i, isabrds = 0; | ||
342 | int retval = 0; | ||
340 | 343 | ||
341 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", | 344 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", |
342 | MOXA_VERSION); | 345 | MOXA_VERSION); |
@@ -380,46 +383,45 @@ static int __init moxa_init(void) | |||
380 | 383 | ||
381 | mod_timer(&moxaTimer, jiffies + HZ / 50); | 384 | mod_timer(&moxaTimer, jiffies + HZ / 50); |
382 | 385 | ||
383 | /* Find the boards defined form module args. */ | 386 | /* Find the boards defined from module args. */ |
384 | #ifdef MODULE | 387 | #ifdef MODULE |
388 | { | ||
389 | struct moxa_board_conf *brd = moxa_boards; | ||
385 | for (i = 0; i < MAX_BOARDS; i++) { | 390 | for (i = 0; i < MAX_BOARDS; i++) { |
386 | if ((type[i] == MOXA_BOARD_C218_ISA) || | 391 | if (!baseaddr[i]) |
387 | (type[i] == MOXA_BOARD_C320_ISA)) { | 392 | break; |
393 | if (type[i] == MOXA_BOARD_C218_ISA || | ||
394 | type[i] == MOXA_BOARD_C320_ISA) { | ||
388 | pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", | 395 | pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", |
389 | numBoards + 1, moxa_brdname[type[i] - 1], | 396 | isabrds + 1, moxa_brdname[type[i] - 1], |
390 | (unsigned long)baseaddr[i]); | 397 | baseaddr[i]); |
391 | if (numBoards >= MAX_BOARDS) { | 398 | brd->boardType = type[i]; |
392 | printk(KERN_WARNING "More than %d MOXA " | 399 | brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : |
393 | "Intellio family boards found. Board " | 400 | numports[i]; |
394 | "is ignored.\n", MAX_BOARDS); | 401 | brd->busType = MOXA_BUS_TYPE_ISA; |
402 | brd->basemem = ioremap(baseaddr[i], 0x4000); | ||
403 | if (!brd->basemem) { | ||
404 | printk(KERN_ERR "moxa: can't remap %lx\n", | ||
405 | baseaddr[i]); | ||
395 | continue; | 406 | continue; |
396 | } | 407 | } |
397 | moxa_boards[numBoards].boardType = type[i]; | 408 | |
398 | if (type[i] == MOXA_BOARD_C218_ISA) | 409 | brd++; |
399 | moxa_boards[numBoards].numPorts = 8; | 410 | isabrds++; |
400 | else | ||
401 | moxa_boards[numBoards].numPorts = numports[i]; | ||
402 | moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA; | ||
403 | moxa_boards[numBoards].baseAddr = baseaddr[i]; | ||
404 | numBoards++; | ||
405 | } | 411 | } |
406 | } | 412 | } |
413 | } | ||
407 | #endif | 414 | #endif |
408 | 415 | ||
409 | #ifdef CONFIG_PCI | 416 | #ifdef CONFIG_PCI |
410 | retval = pci_register_driver(&moxa_pci_driver); | 417 | retval = pci_register_driver(&moxa_pci_driver); |
411 | if (retval) { | 418 | if (retval) { |
412 | printk(KERN_ERR "Can't register moxa pci driver!\n"); | 419 | printk(KERN_ERR "Can't register moxa pci driver!\n"); |
413 | if (numBoards) | 420 | if (isabrds) |
414 | retval = 0; | 421 | retval = 0; |
415 | } | 422 | } |
416 | #endif | 423 | #endif |
417 | 424 | ||
418 | for (i = 0; i < numBoards; i++) { | ||
419 | moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr, | ||
420 | 0x4000); | ||
421 | } | ||
422 | |||
423 | return retval; | 425 | return retval; |
424 | } | 426 | } |
425 | 427 | ||