]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Char: moxa, cleanup module-param passed isa init
authorJiri Slaby <jirislaby@gmail.com>
Wed, 30 Apr 2008 07:53:37 +0000 (00:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 30 Apr 2008 15:29:41 +0000 (08:29 -0700)
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>
drivers/char/moxa.c

index 7f4d1ec4b03d522db289ff4701096acb2e8b067d..2701f7c9f9389643a762c92d3ceb505bf1e98021 100644 (file)
@@ -95,7 +95,6 @@ MODULE_DEVICE_TABLE(pci, moxa_pcibrds);
 static struct moxa_board_conf {
        int boardType;
        int numPorts;
-       unsigned long baseAddr;
        int busType;
 
        int loadstat;
@@ -159,18 +158,21 @@ struct moxa_port {
 static int ttymajor = MOXAMAJOR;
 /* Variables for insmod */
 #ifdef MODULE
-static int baseaddr[4];
-static int type[4];
-static int numports[4];
+static unsigned long baseaddr[MAX_BOARDS];
+static unsigned int type[MAX_BOARDS];
+static unsigned int numports[MAX_BOARDS];
 #endif
 
 MODULE_AUTHOR("William Chen");
 MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
 MODULE_LICENSE("GPL");
 #ifdef MODULE
-module_param_array(type, int, NULL, 0);
-module_param_array(baseaddr, int, NULL, 0);
-module_param_array(numports, int, NULL, 0);
+module_param_array(type, uint, NULL, 0);
+MODULE_PARM_DESC(type, "card type: C218=2, C320=4");
+module_param_array(baseaddr, ulong, NULL, 0);
+MODULE_PARM_DESC(baseaddr, "base address");
+module_param_array(numports, uint, NULL, 0);
+MODULE_PARM_DESC(numports, "numports (ignored for C218)");
 #endif
 module_param(ttymajor, int, 0);
 
@@ -335,8 +337,9 @@ static struct pci_driver moxa_pci_driver = {
 
 static int __init moxa_init(void)
 {
-       int i, numBoards = 0, retval = 0;
        struct moxa_port *ch;
+       unsigned int i, isabrds = 0;
+       int retval = 0;
 
        printk(KERN_INFO "MOXA Intellio family driver version %s\n",
                        MOXA_VERSION);
@@ -380,46 +383,45 @@ static int __init moxa_init(void)
 
        mod_timer(&moxaTimer, jiffies + HZ / 50);
 
-       /* Find the boards defined form module args. */
+       /* Find the boards defined from module args. */
 #ifdef MODULE
+       {
+       struct moxa_board_conf *brd = moxa_boards;
        for (i = 0; i < MAX_BOARDS; i++) {
-               if ((type[i] == MOXA_BOARD_C218_ISA) ||
-                   (type[i] == MOXA_BOARD_C320_ISA)) {
+               if (!baseaddr[i])
+                       break;
+               if (type[i] == MOXA_BOARD_C218_ISA ||
+                               type[i] == MOXA_BOARD_C320_ISA) {
                        pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n",
-                              numBoards + 1, moxa_brdname[type[i] - 1],
-                              (unsigned long)baseaddr[i]);
-                       if (numBoards >= MAX_BOARDS) {
-                               printk(KERN_WARNING "More than %d MOXA "
-                                       "Intellio family boards found. Board "
-                                       "is ignored.\n", MAX_BOARDS);
+                                       isabrds + 1, moxa_brdname[type[i] - 1],
+                                       baseaddr[i]);
+                       brd->boardType = type[i];
+                       brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 :
+                                       numports[i];
+                       brd->busType = MOXA_BUS_TYPE_ISA;
+                       brd->basemem = ioremap(baseaddr[i], 0x4000);
+                       if (!brd->basemem) {
+                               printk(KERN_ERR "moxa: can't remap %lx\n",
+                                               baseaddr[i]);
                                continue;
                        }
-                       moxa_boards[numBoards].boardType = type[i];
-                       if (type[i] == MOXA_BOARD_C218_ISA)
-                               moxa_boards[numBoards].numPorts = 8;
-                       else
-                               moxa_boards[numBoards].numPorts = numports[i];
-                       moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA;
-                       moxa_boards[numBoards].baseAddr = baseaddr[i];
-                       numBoards++;
+
+                       brd++;
+                       isabrds++;
                }
        }
+       }
 #endif
 
 #ifdef CONFIG_PCI
        retval = pci_register_driver(&moxa_pci_driver);
        if (retval) {
                printk(KERN_ERR "Can't register moxa pci driver!\n");
-               if (numBoards)
+               if (isabrds)
                        retval = 0;
        }
 #endif
 
-       for (i = 0; i < numBoards; i++) {
-               moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
-                               0x4000);
-       }
-
        return retval;
 }