[PATCH] Char: moxa, pci probing
Alter the driver to use the pci probing. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
9cde5bf027
commit
a784bf7c19
1 changed files with 20 additions and 20 deletions
|
@ -107,7 +107,6 @@ static struct moxa_board_conf {
|
||||||
int numPorts;
|
int numPorts;
|
||||||
unsigned long baseAddr;
|
unsigned long baseAddr;
|
||||||
int busType;
|
int busType;
|
||||||
struct pci_dev *pdev;
|
|
||||||
|
|
||||||
int loadstat;
|
int loadstat;
|
||||||
|
|
||||||
|
@ -319,8 +318,7 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
board->busType = MOXA_BUS_TYPE_PCI;
|
board->busType = MOXA_BUS_TYPE_PCI;
|
||||||
/* don't lose the reference in the next pci_get_device iteration */
|
|
||||||
board->pdev = pci_dev_get(pdev);
|
|
||||||
pci_set_drvdata(pdev, board);
|
pci_set_drvdata(pdev, board);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -334,13 +332,19 @@ static void __devexit moxa_pci_remove(struct pci_dev *pdev)
|
||||||
|
|
||||||
pci_iounmap(pdev, brd->basemem);
|
pci_iounmap(pdev, brd->basemem);
|
||||||
brd->basemem = NULL;
|
brd->basemem = NULL;
|
||||||
pci_dev_put(pdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct pci_driver moxa_pci_driver = {
|
||||||
|
.name = "moxa",
|
||||||
|
.id_table = moxa_pcibrds,
|
||||||
|
.probe = moxa_pci_probe,
|
||||||
|
.remove = __devexit_p(moxa_pci_remove)
|
||||||
|
};
|
||||||
#endif /* CONFIG_PCI */
|
#endif /* CONFIG_PCI */
|
||||||
|
|
||||||
static int __init moxa_init(void)
|
static int __init moxa_init(void)
|
||||||
{
|
{
|
||||||
int i, numBoards;
|
int i, numBoards, retval = 0;
|
||||||
struct moxa_port *ch;
|
struct moxa_port *ch;
|
||||||
|
|
||||||
printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION);
|
printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION);
|
||||||
|
@ -430,25 +434,22 @@ static int __init moxa_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Find PCI boards here */
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
{
|
retval = pci_register_driver(&moxa_pci_driver);
|
||||||
struct pci_dev *p = NULL;
|
if (retval) {
|
||||||
int n = ARRAY_SIZE(moxa_pcibrds) - 1;
|
printk(KERN_ERR "Can't register moxa pci driver!\n");
|
||||||
i = 0;
|
if (numBoards)
|
||||||
while (i < n) {
|
retval = 0;
|
||||||
while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL)
|
|
||||||
moxa_pci_probe(p, &moxa_pcibrds[i]);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < numBoards; i++) {
|
for (i = 0; i < numBoards; i++) {
|
||||||
moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
|
moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
|
||||||
0x4000);
|
0x4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit moxa_exit(void)
|
static void __exit moxa_exit(void)
|
||||||
|
@ -467,14 +468,13 @@ static void __exit moxa_exit(void)
|
||||||
printk("Couldn't unregister MOXA Intellio family serial driver\n");
|
printk("Couldn't unregister MOXA Intellio family serial driver\n");
|
||||||
put_tty_driver(moxaDriver);
|
put_tty_driver(moxaDriver);
|
||||||
|
|
||||||
for (i = 0; i < MAX_BOARDS; i++) {
|
|
||||||
#ifdef CONFIG_PCI
|
#ifdef CONFIG_PCI
|
||||||
if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
|
pci_unregister_driver(&moxa_pci_driver);
|
||||||
moxa_pci_remove(moxa_boards[i].pdev);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_BOARDS; i++)
|
||||||
if (moxa_boards[i].basemem)
|
if (moxa_boards[i].basemem)
|
||||||
iounmap(moxa_boards[i].basemem);
|
iounmap(moxa_boards[i].basemem);
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
printk("Done\n");
|
printk("Done\n");
|
||||||
|
|
Loading…
Reference in a new issue