diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2007-02-10 04:45:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 13:51:30 -0500 |
commit | a784bf7c195f9eca1188562c54952e4bf9791437 (patch) | |
tree | 606670e6055c7c6415460589c7bc3fc31d1cb668 /drivers/char/moxa.c | |
parent | 9cde5bf027556bd1e58caa14bfe8cdba64192edd (diff) |
[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>
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r-- | drivers/char/moxa.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 9b7067b6ab73..7dbaee8d9402 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -107,7 +107,6 @@ static struct moxa_board_conf { | |||
107 | int numPorts; | 107 | int numPorts; |
108 | unsigned long baseAddr; | 108 | unsigned long baseAddr; |
109 | int busType; | 109 | int busType; |
110 | struct pci_dev *pdev; | ||
111 | 110 | ||
112 | int loadstat; | 111 | int loadstat; |
113 | 112 | ||
@@ -319,8 +318,7 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev, | |||
319 | break; | 318 | break; |
320 | } | 319 | } |
321 | board->busType = MOXA_BUS_TYPE_PCI; | 320 | board->busType = MOXA_BUS_TYPE_PCI; |
322 | /* don't lose the reference in the next pci_get_device iteration */ | 321 | |
323 | board->pdev = pci_dev_get(pdev); | ||
324 | pci_set_drvdata(pdev, board); | 322 | pci_set_drvdata(pdev, board); |
325 | 323 | ||
326 | return (0); | 324 | return (0); |
@@ -334,13 +332,19 @@ static void __devexit moxa_pci_remove(struct pci_dev *pdev) | |||
334 | 332 | ||
335 | pci_iounmap(pdev, brd->basemem); | 333 | pci_iounmap(pdev, brd->basemem); |
336 | brd->basemem = NULL; | 334 | brd->basemem = NULL; |
337 | pci_dev_put(pdev); | ||
338 | } | 335 | } |
336 | |||
337 | static struct pci_driver moxa_pci_driver = { | ||
338 | .name = "moxa", | ||
339 | .id_table = moxa_pcibrds, | ||
340 | .probe = moxa_pci_probe, | ||
341 | .remove = __devexit_p(moxa_pci_remove) | ||
342 | }; | ||
339 | #endif /* CONFIG_PCI */ | 343 | #endif /* CONFIG_PCI */ |
340 | 344 | ||
341 | static int __init moxa_init(void) | 345 | static int __init moxa_init(void) |
342 | { | 346 | { |
343 | int i, numBoards; | 347 | int i, numBoards, retval = 0; |
344 | struct moxa_port *ch; | 348 | struct moxa_port *ch; |
345 | 349 | ||
346 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION); | 350 | printk(KERN_INFO "MOXA Intellio family driver version %s\n", MOXA_VERSION); |
@@ -430,25 +434,22 @@ static int __init moxa_init(void) | |||
430 | } | 434 | } |
431 | } | 435 | } |
432 | #endif | 436 | #endif |
433 | /* Find PCI boards here */ | 437 | |
434 | #ifdef CONFIG_PCI | 438 | #ifdef CONFIG_PCI |
435 | { | 439 | retval = pci_register_driver(&moxa_pci_driver); |
436 | struct pci_dev *p = NULL; | 440 | if (retval) { |
437 | int n = ARRAY_SIZE(moxa_pcibrds) - 1; | 441 | printk(KERN_ERR "Can't register moxa pci driver!\n"); |
438 | i = 0; | 442 | if (numBoards) |
439 | while (i < n) { | 443 | retval = 0; |
440 | while ((p = pci_get_device(moxa_pcibrds[i].vendor, moxa_pcibrds[i].device, p))!=NULL) | ||
441 | moxa_pci_probe(p, &moxa_pcibrds[i]); | ||
442 | i++; | ||
443 | } | ||
444 | } | 444 | } |
445 | #endif | 445 | #endif |
446 | |||
446 | for (i = 0; i < numBoards; i++) { | 447 | for (i = 0; i < numBoards; i++) { |
447 | moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr, | 448 | moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr, |
448 | 0x4000); | 449 | 0x4000); |
449 | } | 450 | } |
450 | 451 | ||
451 | return (0); | 452 | return retval; |
452 | } | 453 | } |
453 | 454 | ||
454 | static void __exit moxa_exit(void) | 455 | static void __exit moxa_exit(void) |
@@ -467,14 +468,13 @@ static void __exit moxa_exit(void) | |||
467 | printk("Couldn't unregister MOXA Intellio family serial driver\n"); | 468 | printk("Couldn't unregister MOXA Intellio family serial driver\n"); |
468 | put_tty_driver(moxaDriver); | 469 | put_tty_driver(moxaDriver); |
469 | 470 | ||
470 | for (i = 0; i < MAX_BOARDS; i++) { | ||
471 | #ifdef CONFIG_PCI | 471 | #ifdef CONFIG_PCI |
472 | if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) | 472 | pci_unregister_driver(&moxa_pci_driver); |
473 | moxa_pci_remove(moxa_boards[i].pdev); | ||
474 | #endif | 473 | #endif |
474 | |||
475 | for (i = 0; i < MAX_BOARDS; i++) | ||
475 | if (moxa_boards[i].basemem) | 476 | if (moxa_boards[i].basemem) |
476 | iounmap(moxa_boards[i].basemem); | 477 | iounmap(moxa_boards[i].basemem); |
477 | } | ||
478 | 478 | ||
479 | if (verbose) | 479 | if (verbose) |
480 | printk("Done\n"); | 480 | printk("Done\n"); |