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>
This commit is contained in:
Jiri Slaby 2008-04-30 00:53:37 -07:00 committed by Linus Torvalds
parent 37794952a6
commit d353eca4e0

View file

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