aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/moxa.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2008-04-30 03:53:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 11:29:41 -0400
commitd353eca4e0480fddcb088c4692e1edba0a82eac9 (patch)
treeed2015db790f7e75546fc63c37db20203b478062 /drivers/char/moxa.c
parent37794952a685538f20ac9792e98f1c9b161dbdfe (diff)
Char: moxa, cleanup module-param passed isa init
Make the code more readable, remap the base address directly. Describe module parameters. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Tested-by: Oyvind Aabling <Oyvind.Aabling@uni-c.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r--drivers/char/moxa.c64
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);
95static struct moxa_board_conf { 95static 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 {
159static int ttymajor = MOXAMAJOR; 158static int ttymajor = MOXAMAJOR;
160/* Variables for insmod */ 159/* Variables for insmod */
161#ifdef MODULE 160#ifdef MODULE
162static int baseaddr[4]; 161static unsigned long baseaddr[MAX_BOARDS];
163static int type[4]; 162static unsigned int type[MAX_BOARDS];
164static int numports[4]; 163static unsigned int numports[MAX_BOARDS];
165#endif 164#endif
166 165
167MODULE_AUTHOR("William Chen"); 166MODULE_AUTHOR("William Chen");
168MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); 167MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
169MODULE_LICENSE("GPL"); 168MODULE_LICENSE("GPL");
170#ifdef MODULE 169#ifdef MODULE
171module_param_array(type, int, NULL, 0); 170module_param_array(type, uint, NULL, 0);
172module_param_array(baseaddr, int, NULL, 0); 171MODULE_PARM_DESC(type, "card type: C218=2, C320=4");
173module_param_array(numports, int, NULL, 0); 172module_param_array(baseaddr, ulong, NULL, 0);
173MODULE_PARM_DESC(baseaddr, "base address");
174module_param_array(numports, uint, NULL, 0);
175MODULE_PARM_DESC(numports, "numports (ignored for C218)");
174#endif 176#endif
175module_param(ttymajor, int, 0); 177module_param(ttymajor, int, 0);
176 178
@@ -335,8 +337,9 @@ static struct pci_driver moxa_pci_driver = {
335 337
336static int __init moxa_init(void) 338static 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