diff options
| -rw-r--r-- | drivers/xen/xen-pciback/pci_stub.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 258b7c325649..79a9e4d66819 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c | |||
| @@ -149,13 +149,10 @@ static inline void pcistub_device_put(struct pcistub_device *psdev) | |||
| 149 | kref_put(&psdev->kref, pcistub_device_release); | 149 | kref_put(&psdev->kref, pcistub_device_release); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | static struct pcistub_device *pcistub_device_find(int domain, int bus, | 152 | static struct pcistub_device *pcistub_device_find_locked(int domain, int bus, |
| 153 | int slot, int func) | 153 | int slot, int func) |
| 154 | { | 154 | { |
| 155 | struct pcistub_device *psdev = NULL; | 155 | struct pcistub_device *psdev; |
| 156 | unsigned long flags; | ||
| 157 | |||
| 158 | spin_lock_irqsave(&pcistub_devices_lock, flags); | ||
| 159 | 156 | ||
| 160 | list_for_each_entry(psdev, &pcistub_devices, dev_list) { | 157 | list_for_each_entry(psdev, &pcistub_devices, dev_list) { |
| 161 | if (psdev->dev != NULL | 158 | if (psdev->dev != NULL |
| @@ -163,15 +160,25 @@ static struct pcistub_device *pcistub_device_find(int domain, int bus, | |||
| 163 | && bus == psdev->dev->bus->number | 160 | && bus == psdev->dev->bus->number |
| 164 | && slot == PCI_SLOT(psdev->dev->devfn) | 161 | && slot == PCI_SLOT(psdev->dev->devfn) |
| 165 | && func == PCI_FUNC(psdev->dev->devfn)) { | 162 | && func == PCI_FUNC(psdev->dev->devfn)) { |
| 166 | pcistub_device_get(psdev); | 163 | return psdev; |
| 167 | goto out; | ||
| 168 | } | 164 | } |
| 169 | } | 165 | } |
| 170 | 166 | ||
| 171 | /* didn't find it */ | 167 | return NULL; |
| 172 | psdev = NULL; | 168 | } |
| 169 | |||
| 170 | static struct pcistub_device *pcistub_device_find(int domain, int bus, | ||
| 171 | int slot, int func) | ||
| 172 | { | ||
| 173 | struct pcistub_device *psdev; | ||
| 174 | unsigned long flags; | ||
| 175 | |||
| 176 | spin_lock_irqsave(&pcistub_devices_lock, flags); | ||
| 177 | |||
| 178 | psdev = pcistub_device_find_locked(domain, bus, slot, func); | ||
| 179 | if (psdev) | ||
| 180 | pcistub_device_get(psdev); | ||
| 173 | 181 | ||
| 174 | out: | ||
| 175 | spin_unlock_irqrestore(&pcistub_devices_lock, flags); | 182 | spin_unlock_irqrestore(&pcistub_devices_lock, flags); |
| 176 | return psdev; | 183 | return psdev; |
| 177 | } | 184 | } |
| @@ -207,16 +214,9 @@ struct pci_dev *pcistub_get_pci_dev_by_slot(struct xen_pcibk_device *pdev, | |||
| 207 | 214 | ||
| 208 | spin_lock_irqsave(&pcistub_devices_lock, flags); | 215 | spin_lock_irqsave(&pcistub_devices_lock, flags); |
| 209 | 216 | ||
| 210 | list_for_each_entry(psdev, &pcistub_devices, dev_list) { | 217 | psdev = pcistub_device_find_locked(domain, bus, slot, func); |
| 211 | if (psdev->dev != NULL | 218 | if (psdev) |
| 212 | && domain == pci_domain_nr(psdev->dev->bus) | 219 | found_dev = pcistub_device_get_pci_dev(pdev, psdev); |
| 213 | && bus == psdev->dev->bus->number | ||
| 214 | && slot == PCI_SLOT(psdev->dev->devfn) | ||
| 215 | && func == PCI_FUNC(psdev->dev->devfn)) { | ||
| 216 | found_dev = pcistub_device_get_pci_dev(pdev, psdev); | ||
| 217 | break; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | 220 | ||
| 221 | spin_unlock_irqrestore(&pcistub_devices_lock, flags); | 221 | spin_unlock_irqrestore(&pcistub_devices_lock, flags); |
| 222 | return found_dev; | 222 | return found_dev; |
