diff options
author | Gavin Shan <gwshan@linux.vnet.ibm.com> | 2014-05-21 01:23:30 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-05-27 19:10:16 -0400 |
commit | d97ffe236894856d08146390ef3fbe6448a8ac2b (patch) | |
tree | 0935d466ca429a5b61a9b82ed44a6c623175964f /drivers/pci | |
parent | a43ae58c848cfbadaba81c8d63202b4487f922a0 (diff) |
PCI: Fix return value from pci_user_{read,write}_config_*()
The PCI user-space config accessors pci_user_{read,write}_config_*() return
negative error numbers, which were introduced by commit 34e3207205ef
("PCI: handle positive error codes"). That patch converted all positive
error numbers from platform-specific PCI config accessors to -EINVAL, which
means the callers don't know anything about the specific cause of the
failure.
The patch fixes the issue by converting the positive PCIBIOS_* error values
to generic negative error numbers with pcibios_err_to_errno().
[bhelgaas: changelog]
Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Greg Thelen <gthelen@google.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/access.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 7f8b78c08879..8c148f39e8d7 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c | |||
@@ -148,7 +148,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev) | |||
148 | int pci_user_read_config_##size \ | 148 | int pci_user_read_config_##size \ |
149 | (struct pci_dev *dev, int pos, type *val) \ | 149 | (struct pci_dev *dev, int pos, type *val) \ |
150 | { \ | 150 | { \ |
151 | int ret = 0; \ | 151 | int ret = PCIBIOS_SUCCESSFUL; \ |
152 | u32 data = -1; \ | 152 | u32 data = -1; \ |
153 | if (PCI_##size##_BAD) \ | 153 | if (PCI_##size##_BAD) \ |
154 | return -EINVAL; \ | 154 | return -EINVAL; \ |
@@ -159,9 +159,7 @@ int pci_user_read_config_##size \ | |||
159 | pos, sizeof(type), &data); \ | 159 | pos, sizeof(type), &data); \ |
160 | raw_spin_unlock_irq(&pci_lock); \ | 160 | raw_spin_unlock_irq(&pci_lock); \ |
161 | *val = (type)data; \ | 161 | *val = (type)data; \ |
162 | if (ret > 0) \ | 162 | return pcibios_err_to_errno(ret); \ |
163 | ret = -EINVAL; \ | ||
164 | return ret; \ | ||
165 | } \ | 163 | } \ |
166 | EXPORT_SYMBOL_GPL(pci_user_read_config_##size); | 164 | EXPORT_SYMBOL_GPL(pci_user_read_config_##size); |
167 | 165 | ||
@@ -170,7 +168,7 @@ EXPORT_SYMBOL_GPL(pci_user_read_config_##size); | |||
170 | int pci_user_write_config_##size \ | 168 | int pci_user_write_config_##size \ |
171 | (struct pci_dev *dev, int pos, type val) \ | 169 | (struct pci_dev *dev, int pos, type val) \ |
172 | { \ | 170 | { \ |
173 | int ret = -EIO; \ | 171 | int ret = PCIBIOS_SUCCESSFUL; \ |
174 | if (PCI_##size##_BAD) \ | 172 | if (PCI_##size##_BAD) \ |
175 | return -EINVAL; \ | 173 | return -EINVAL; \ |
176 | raw_spin_lock_irq(&pci_lock); \ | 174 | raw_spin_lock_irq(&pci_lock); \ |
@@ -179,9 +177,7 @@ int pci_user_write_config_##size \ | |||
179 | ret = dev->bus->ops->write(dev->bus, dev->devfn, \ | 177 | ret = dev->bus->ops->write(dev->bus, dev->devfn, \ |
180 | pos, sizeof(type), val); \ | 178 | pos, sizeof(type), val); \ |
181 | raw_spin_unlock_irq(&pci_lock); \ | 179 | raw_spin_unlock_irq(&pci_lock); \ |
182 | if (ret > 0) \ | 180 | return pcibios_err_to_errno(ret); \ |
183 | ret = -EINVAL; \ | ||
184 | return ret; \ | ||
185 | } \ | 181 | } \ |
186 | EXPORT_SYMBOL_GPL(pci_user_write_config_##size); | 182 | EXPORT_SYMBOL_GPL(pci_user_write_config_##size); |
187 | 183 | ||