diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-23 18:39:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-23 18:39:34 -0400 |
commit | 5e152b4c9e0fce6149c74406346a7ae7e7a17727 (patch) | |
tree | 12503a50142797c1babfd87099c193b3e4d54f93 /drivers/pci/access.c | |
parent | a77febbef105554c5a37241cf903f48ab7bc03c7 (diff) | |
parent | 9251bac97d47fdaea406ea0595c2d0aa50022f12 (diff) |
Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6
* 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6: (27 commits)
PCI: Don't use dmi_name_in_vendors in quirk
PCI: remove unused AER functions
PCI/sysfs: move bus cpuaffinity to class dev_attrs
PCI: add rescan to /sys/.../pci_bus/.../
PCI: update bridge resources to get more big ranges when allocating space (again)
KVM: Use pci_store/load_saved_state() around VM device usage
PCI: Add interfaces to store and load the device saved state
PCI: Track the size of each saved capability data area
PCI/e1000e: Add and use pci_disable_link_state_locked()
x86/PCI: derive pcibios_last_bus from ACPI MCFG
PCI: add latency tolerance reporting enable/disable support
PCI: add OBFF enable/disable support
PCI: add ID-based ordering enable/disable support
PCI hotplug: acpiphp: assume device is in state D0 after powering on a slot.
PCI: Set PCIE maxpayload for card during hotplug insertion
PCI/ACPI: Report _OSC control mask returned on failure to get control
x86/PCI: irq and pci_ids patch for Intel Panther Point DeviceIDs
PCI: handle positive error codes
PCI: check pci_vpd_pci22_wait() return
PCI: Use ICH6_GPIO_EN in ich6_lpc_acpi_gpio
...
Fix up trivial conflicts in include/linux/pci_ids.h: commit a6e5e2be4461
moved the intel SMBUS ID definitons to the i2c-i801.c driver.
Diffstat (limited to 'drivers/pci/access.c')
-rw-r--r-- | drivers/pci/access.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 531bc697d800..fdaa42aac7c6 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -143,33 +143,41 @@ static noinline void pci_wait_ucfg(struct pci_dev *dev) | |||
143 | __remove_wait_queue(&pci_ucfg_wait, &wait); | 143 | __remove_wait_queue(&pci_ucfg_wait, &wait); |
144 | } | 144 | } |
145 | 145 | ||
146 | /* Returns 0 on success, negative values indicate error. */ | ||
146 | #define PCI_USER_READ_CONFIG(size,type) \ | 147 | #define PCI_USER_READ_CONFIG(size,type) \ |
147 | int pci_user_read_config_##size \ | 148 | int pci_user_read_config_##size \ |
148 | (struct pci_dev *dev, int pos, type *val) \ | 149 | (struct pci_dev *dev, int pos, type *val) \ |
149 | { \ | 150 | { \ |
150 | int ret = 0; \ | 151 | int ret = 0; \ |
151 | u32 data = -1; \ | 152 | u32 data = -1; \ |
152 | if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ | 153 | if (PCI_##size##_BAD) \ |
154 | return -EINVAL; \ | ||
153 | raw_spin_lock_irq(&pci_lock); \ | 155 | raw_spin_lock_irq(&pci_lock); \ |
154 | if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \ | 156 | if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \ |
155 | ret = dev->bus->ops->read(dev->bus, dev->devfn, \ | 157 | ret = dev->bus->ops->read(dev->bus, dev->devfn, \ |
156 | pos, sizeof(type), &data); \ | 158 | pos, sizeof(type), &data); \ |
157 | raw_spin_unlock_irq(&pci_lock); \ | 159 | raw_spin_unlock_irq(&pci_lock); \ |
158 | *val = (type)data; \ | 160 | *val = (type)data; \ |
161 | if (ret > 0) \ | ||
162 | ret = -EINVAL; \ | ||
159 | return ret; \ | 163 | return ret; \ |
160 | } | 164 | } |
161 | 165 | ||
166 | /* Returns 0 on success, negative values indicate error. */ | ||
162 | #define PCI_USER_WRITE_CONFIG(size,type) \ | 167 | #define PCI_USER_WRITE_CONFIG(size,type) \ |
163 | int pci_user_write_config_##size \ | 168 | int pci_user_write_config_##size \ |
164 | (struct pci_dev *dev, int pos, type val) \ | 169 | (struct pci_dev *dev, int pos, type val) \ |
165 | { \ | 170 | { \ |
166 | int ret = -EIO; \ | 171 | int ret = -EIO; \ |
167 | if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \ | 172 | if (PCI_##size##_BAD) \ |
173 | return -EINVAL; \ | ||
168 | raw_spin_lock_irq(&pci_lock); \ | 174 | raw_spin_lock_irq(&pci_lock); \ |
169 | if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \ | 175 | if (unlikely(dev->block_ucfg_access)) pci_wait_ucfg(dev); \ |
170 | ret = dev->bus->ops->write(dev->bus, dev->devfn, \ | 176 | ret = dev->bus->ops->write(dev->bus, dev->devfn, \ |
171 | pos, sizeof(type), val); \ | 177 | pos, sizeof(type), val); \ |
172 | raw_spin_unlock_irq(&pci_lock); \ | 178 | raw_spin_unlock_irq(&pci_lock); \ |
179 | if (ret > 0) \ | ||
180 | ret = -EINVAL; \ | ||
173 | return ret; \ | 181 | return ret; \ |
174 | } | 182 | } |
175 | 183 | ||
@@ -197,6 +205,8 @@ struct pci_vpd_pci22 { | |||
197 | * This code has to spin since there is no other notification from the PCI | 205 | * This code has to spin since there is no other notification from the PCI |
198 | * hardware. Since the VPD is often implemented by serial attachment to an | 206 | * hardware. Since the VPD is often implemented by serial attachment to an |
199 | * EEPROM, it may take many milliseconds to complete. | 207 | * EEPROM, it may take many milliseconds to complete. |
208 | * | ||
209 | * Returns 0 on success, negative values indicate error. | ||
200 | */ | 210 | */ |
201 | static int pci_vpd_pci22_wait(struct pci_dev *dev) | 211 | static int pci_vpd_pci22_wait(struct pci_dev *dev) |
202 | { | 212 | { |
@@ -212,7 +222,7 @@ static int pci_vpd_pci22_wait(struct pci_dev *dev) | |||
212 | for (;;) { | 222 | for (;;) { |
213 | ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR, | 223 | ret = pci_user_read_config_word(dev, vpd->cap + PCI_VPD_ADDR, |
214 | &status); | 224 | &status); |
215 | if (ret) | 225 | if (ret < 0) |
216 | return ret; | 226 | return ret; |
217 | 227 | ||
218 | if ((status & PCI_VPD_ADDR_F) == vpd->flag) { | 228 | if ((status & PCI_VPD_ADDR_F) == vpd->flag) { |
@@ -324,6 +334,8 @@ static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count | |||
324 | vpd->busy = true; | 334 | vpd->busy = true; |
325 | vpd->flag = 0; | 335 | vpd->flag = 0; |
326 | ret = pci_vpd_pci22_wait(dev); | 336 | ret = pci_vpd_pci22_wait(dev); |
337 | if (ret < 0) | ||
338 | break; | ||
327 | 339 | ||
328 | pos += sizeof(u32); | 340 | pos += sizeof(u32); |
329 | } | 341 | } |