From: Alan Cox Date: Fri, 8 Dec 2006 10:38:10 +0000 (-0800) Subject: [PATCH] mxser: PCI refcounts X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1187ece3db310cb1e7cd75083dc7253dbac39675;p=openwrt%2Fstaging%2Fblogic.git [PATCH] mxser: PCI refcounts Switch to pci ref counts for mxser when handling PCI devices. Use pci_get_device and drop the reference when we finish and unload. Signed-off-by: Alan Cox Cc: Greg KH Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 4204746f1590..2dc49be144e6 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -515,6 +515,7 @@ static void __exit mxser_module_exit(void) if (pdev != NULL) { /* PCI */ release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); + pci_dev_put(pdev); } else { release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports); release_region(mxsercfg[i].vector, 1); @@ -839,9 +840,9 @@ static int mxser_init(void) index = 0; b = 0; while (b < n) { - pdev = pci_find_device(mxser_pcibrds[b].vendor, + pdev = pci_get_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev); - if (pdev == NULL) { + if (pdev == NULL) { b++; continue; } @@ -893,6 +894,9 @@ static int mxser_init(void) if (mxser_initbrd(m, &hwconf) < 0) continue; m++; + /* Keep an extra reference if we succeeded. It will + be returned at unload time */ + pci_dev_get(pdev); } } #endif