diff options
author | Tejun Heo <htejun@gmail.com> | 2007-02-25 07:36:01 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-03-09 18:36:30 -0500 |
commit | 7f375f325feacd8a628e00e0d53390a4f6d8abc2 (patch) | |
tree | 434d3d5b5bf75e85515b514b12e2f08205dec079 /drivers/pci/pci.c | |
parent | a967e127d0233f2472af64597de3f3920872310c (diff) |
PCI: allow multiple calls to pcim_pin_device()
Sanity check in pcim_pin_device() was too restrictive in that it didn't
allow multiple calls to the function, which is against the devres
philosohpy of fire-and-forget. Track pinned status separately and allow
pinning multiple times.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index df495300ce3d..a32db0628157 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -757,7 +757,8 @@ int pci_enable_device(struct pci_dev *dev) | |||
757 | * when a device is enabled using managed PCI device enable interface. | 757 | * when a device is enabled using managed PCI device enable interface. |
758 | */ | 758 | */ |
759 | struct pci_devres { | 759 | struct pci_devres { |
760 | unsigned int disable:1; | 760 | unsigned int enabled:1; |
761 | unsigned int pinned:1; | ||
761 | unsigned int orig_intx:1; | 762 | unsigned int orig_intx:1; |
762 | unsigned int restore_intx:1; | 763 | unsigned int restore_intx:1; |
763 | u32 region_mask; | 764 | u32 region_mask; |
@@ -781,7 +782,7 @@ static void pcim_release(struct device *gendev, void *res) | |||
781 | if (this->restore_intx) | 782 | if (this->restore_intx) |
782 | pci_intx(dev, this->orig_intx); | 783 | pci_intx(dev, this->orig_intx); |
783 | 784 | ||
784 | if (this->disable) | 785 | if (this->enabled && !this->pinned) |
785 | pci_disable_device(dev); | 786 | pci_disable_device(dev); |
786 | } | 787 | } |
787 | 788 | ||
@@ -820,12 +821,12 @@ int pcim_enable_device(struct pci_dev *pdev) | |||
820 | dr = get_pci_dr(pdev); | 821 | dr = get_pci_dr(pdev); |
821 | if (unlikely(!dr)) | 822 | if (unlikely(!dr)) |
822 | return -ENOMEM; | 823 | return -ENOMEM; |
823 | WARN_ON(!!dr->disable); | 824 | WARN_ON(!!dr->enabled); |
824 | 825 | ||
825 | rc = pci_enable_device(pdev); | 826 | rc = pci_enable_device(pdev); |
826 | if (!rc) { | 827 | if (!rc) { |
827 | pdev->is_managed = 1; | 828 | pdev->is_managed = 1; |
828 | dr->disable = 1; | 829 | dr->enabled = 1; |
829 | } | 830 | } |
830 | return rc; | 831 | return rc; |
831 | } | 832 | } |
@@ -843,9 +844,9 @@ void pcim_pin_device(struct pci_dev *pdev) | |||
843 | struct pci_devres *dr; | 844 | struct pci_devres *dr; |
844 | 845 | ||
845 | dr = find_pci_dr(pdev); | 846 | dr = find_pci_dr(pdev); |
846 | WARN_ON(!dr || !dr->disable); | 847 | WARN_ON(!dr || !dr->enabled); |
847 | if (dr) | 848 | if (dr) |
848 | dr->disable = 0; | 849 | dr->pinned = 1; |
849 | } | 850 | } |
850 | 851 | ||
851 | /** | 852 | /** |
@@ -876,7 +877,7 @@ pci_disable_device(struct pci_dev *dev) | |||
876 | 877 | ||
877 | dr = find_pci_dr(dev); | 878 | dr = find_pci_dr(dev); |
878 | if (dr) | 879 | if (dr) |
879 | dr->disable = 0; | 880 | dr->enabled = 0; |
880 | 881 | ||
881 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) | 882 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) |
882 | return; | 883 | return; |