diff options
author | Johannes Stezenbach <devnull@localhost> | 2004-12-19 17:51:27 +0000 |
---|---|---|
committer | Johannes Stezenbach <devnull@localhost> | 2004-12-19 17:51:27 +0000 |
commit | 90f03edb0d1508acf2650e213def0054615822cf (patch) | |
tree | 360888265eef858f023363dd45755cadadbc370e /linux | |
parent | 9c567a2b027fe9a8829a97e300f0ee813d25af90 (diff) | |
download | mediapointer-dvb-s2-90f03edb0d1508acf2650e213def0054615822cf.tar.gz mediapointer-dvb-s2-90f03edb0d1508acf2650e213def0054615822cf.tar.bz2 |
PCI api update + leaks
- claim_adapter:
+ s/request_xxx_region/pci_request_region/
+ plug leaks on error path (requested io regions and enabled pci device);
+ propagate the status code;
- driver_halt:
+ missing pci_disable_device();
+ s/release_xxx_region/pci_release_region/
- driver_initialize:
+ s/release_xxx_region/pci_release_region/
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'linux')
-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) |