aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/cyclades.c65
1 files changed, 17 insertions, 48 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index d3b42e8d9ba9..249f443115f2 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -5297,46 +5297,9 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5297 5297
5298 return 0; 5298 return 0;
5299} 5299}
5300#endif
5301 5300
5302/* 5301static void __devexit cy_pci_remove(struct pci_dev *pdev)
5303 * ---------------------------------------------------------------------
5304 * cy_detect_pci() - Test PCI bus presence and Cyclom-Ye/PCI.
5305 * sets global variables and return the number of PCI boards found.
5306 * ---------------------------------------------------------------------
5307 */
5308static int __init cy_detect_pci(void)
5309{ 5302{
5310#ifdef CONFIG_PCI
5311 struct pci_dev *pdev = NULL;
5312 unsigned int i, device_id, dev_index = 0;
5313
5314 for (i = 0; i < NR_CARDS; i++) {
5315 /* look for a Cyclades card by vendor and device id */
5316 while ((device_id = cy_pci_dev_id[dev_index].device) != 0) {
5317 if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES,
5318 device_id, pdev)) == NULL) {
5319 dev_index++; /* try next device id */
5320 } else {
5321 break; /* found a board */
5322 }
5323 }
5324
5325 if (device_id == 0)
5326 break;
5327
5328 i -= !!cy_pci_probe(pdev, &cy_pci_dev_id[dev_index]);
5329 }
5330
5331 return i;
5332#else
5333 return 0;
5334#endif /* ifdef CONFIG_PCI */
5335} /* cy_detect_pci */
5336
5337static void __devexit cy_pci_release(struct pci_dev *pdev)
5338{
5339#ifdef CONFIG_PCI
5340 struct cyclades_card *cinfo = pci_get_drvdata(pdev); 5303 struct cyclades_card *cinfo = pci_get_drvdata(pdev);
5341 unsigned int i; 5304 unsigned int i;
5342 5305
@@ -5370,9 +5333,16 @@ static void __devexit cy_pci_release(struct pci_dev *pdev)
5370 for (i = cinfo->first_line; i < cinfo->first_line + 5333 for (i = cinfo->first_line; i < cinfo->first_line +
5371 cinfo->nports; i++) 5334 cinfo->nports; i++)
5372 tty_unregister_device(cy_serial_driver, i); 5335 tty_unregister_device(cy_serial_driver, i);
5373#endif
5374} 5336}
5375 5337
5338static struct pci_driver cy_pci_driver = {
5339 .name = "cyclades",
5340 .id_table = cy_pci_dev_id,
5341 .probe = cy_pci_probe,
5342 .remove = __devexit_p(cy_pci_remove)
5343};
5344#endif
5345
5376/* 5346/*
5377 * This routine prints out the appropriate serial driver version number 5347 * This routine prints out the appropriate serial driver version number
5378 * and identifies which options were configured into this driver. 5348 * and identifies which options were configured into this driver.
@@ -5533,13 +5503,12 @@ static int __init cy_init(void)
5533 /* look for isa boards */ 5503 /* look for isa boards */
5534 nboards = cy_detect_isa(); 5504 nboards = cy_detect_isa();
5535 5505
5506#ifdef CONFIG_PCI
5536 /* look for pci boards */ 5507 /* look for pci boards */
5537 nboards += cy_detect_pci(); 5508 retval = pci_register_driver(&cy_pci_driver);
5538 5509 if (retval && !nboards)
5539 if (nboards == 0) {
5540 retval = -ENODEV;
5541 goto err_unr; 5510 goto err_unr;
5542 } 5511#endif
5543 5512
5544 return 0; 5513 return 0;
5545err_unr: 5514err_unr:
@@ -5564,12 +5533,12 @@ static void __exit cy_cleanup_module(void)
5564 5533
5565 put_tty_driver(cy_serial_driver); 5534 put_tty_driver(cy_serial_driver);
5566 5535
5536#ifdef CONFIG_PCI
5537 pci_unregister_driver(&cy_pci_driver);
5538#endif
5539
5567 for (i = 0; i < NR_CARDS; i++) { 5540 for (i = 0; i < NR_CARDS; i++) {
5568 if (cy_card[i].base_addr) { 5541 if (cy_card[i].base_addr) {
5569 if (cy_card[i].pdev) {
5570 cy_pci_release(cy_card[i].pdev);
5571 continue;
5572 }
5573 /* clear interrupt */ 5542 /* clear interrupt */
5574 cy_writeb(cy_card[i].base_addr + Cy_ClrIntr, 0); 5543 cy_writeb(cy_card[i].base_addr + Cy_ClrIntr, 0);
5575 iounmap(cy_card[i].base_addr); 5544 iounmap(cy_card[i].base_addr);