diff options
Diffstat (limited to 'linux/drivers/media/dvb/b2c2/skystar2.c')
-rw-r--r-- | linux/drivers/media/dvb/b2c2/skystar2.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/linux/drivers/media/dvb/b2c2/skystar2.c b/linux/drivers/media/dvb/b2c2/skystar2.c index 4d402971b..418d6e353 100644 --- a/linux/drivers/media/dvb/b2c2/skystar2.c +++ b/linux/drivers/media/dvb/b2c2/skystar2.c @@ -1783,21 +1783,24 @@ static struct pci_driver skystar2_pci_driver; static int claim_adapter(struct adapter *adapter) { struct pci_dev *pdev = adapter->pdev; - u16 var; + int ret; - if (!request_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1), skystar2_pci_driver.name)) - return -EBUSY; + ret = pci_request_region(pdev, 1, skystar2_pci_driver.name); + if (ret < 0) + goto out; - if (!request_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0), skystar2_pci_driver.name)) - return -EBUSY; + ret = pci_request_region(pdev, 0, skystar2_pci_driver.name); + if (ret < 0) + goto err_pci_release_1; pci_read_config_byte(pdev, PCI_CLASS_REVISION, &adapter->card_revision); dprintk("%s: card revision %x \n", __FUNCTION__, adapter->card_revision); - if (pci_enable_device(pdev)) - return -EIO; + ret = pci_enable_device(pdev); + if (ret < 0) + goto err_pci_release_0; pci_read_config_word(pdev, 4, &var); @@ -1810,13 +1813,23 @@ static int claim_adapter(struct adapter *adapter) if (!adapter->io_mem) { dprintk("%s: can not map io memory\n", __FUNCTION__); - - return 2; + ret = -EIO; + goto err_pci_disable; } dprintk("%s: io memory maped at %p\n", __FUNCTION__, adapter->io_mem); - return 1; + ret = 1; +out: + return ret; + +err_pci_disable: + pci_disable_device(pdev); +err_pci_release_0: + pci_release_region(pdev, 0); +err_pci_release_1: + pci_release_region(pdev, 1); + goto out; } /* @@ -1932,8 +1945,8 @@ static int driver_initialize(struct pci_dev *pdev) printk("%s: This driver works only with FlexCopII(rev.130), FlexCopIIB(rev.195) and FlexCopIII(rev.192).\n", __FILE__); free_adapter_object(adapter); pci_set_drvdata(pdev, NULL); - release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); - release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); + pci_release_region(pdev, 1); + pci_release_region(pdev, 0); return -ENODEV; } @@ -1997,9 +2010,9 @@ static void driver_halt(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); - release_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); - - release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); + pci_disable_device(pdev); + pci_release_region(pdev, 1); + pci_release_region(pdev, 0); } static int dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) |