@@ -36,30 +36,38 @@ DEFINE_RAW_SPINLOCK(pci_lock);
3636int noinline pci_bus_read_config_##size \
3737 (struct pci_bus *bus, unsigned int devfn, int pos, type *value) \
3838{ \
39- int res; \
4039 unsigned long flags; \
4140 u32 data = 0; \
42- if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
41+ int res; \
42+ \
43+ if (PCI_##size##_BAD) \
44+ return PCIBIOS_BAD_REGISTER_NUMBER; \
45+ \
4346 pci_lock_config(flags); \
4447 res = bus->ops->read(bus, devfn, pos, len, &data); \
4548 if (res) \
4649 PCI_SET_ERROR_RESPONSE(value); \
4750 else \
4851 *value = (type)data; \
4952 pci_unlock_config(flags); \
53+ \
5054 return res; \
5155}
5256
5357#define PCI_OP_WRITE (size , type , len ) \
5458int noinline pci_bus_write_config_##size \
5559 (struct pci_bus *bus, unsigned int devfn, int pos, type value) \
5660{ \
57- int res; \
5861 unsigned long flags; \
59- if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER; \
62+ int res; \
63+ \
64+ if (PCI_##size##_BAD) \
65+ return PCIBIOS_BAD_REGISTER_NUMBER; \
66+ \
6067 pci_lock_config(flags); \
6168 res = bus->ops->write(bus, devfn, pos, len, value); \
6269 pci_unlock_config(flags); \
70+ \
6371 return res; \
6472}
6573
@@ -216,24 +224,27 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
216224}
217225
218226/* Returns 0 on success, negative values indicate error. */
219- #define PCI_USER_READ_CONFIG (size , type ) \
227+ #define PCI_USER_READ_CONFIG (size , type ) \
220228int pci_user_read_config_##size \
221229 (struct pci_dev *dev, int pos, type *val) \
222230{ \
223- int ret = PCIBIOS_SUCCESSFUL; \
224231 u32 data = -1; \
232+ int ret; \
233+ \
225234 if (PCI_##size##_BAD) \
226235 return -EINVAL; \
227- raw_spin_lock_irq(&pci_lock); \
236+ \
237+ raw_spin_lock_irq(&pci_lock); \
228238 if (unlikely(dev->block_cfg_access)) \
229239 pci_wait_cfg(dev); \
230240 ret = dev->bus->ops->read(dev->bus, dev->devfn, \
231- pos, sizeof(type), &data); \
232- raw_spin_unlock_irq(&pci_lock); \
241+ pos, sizeof(type), &data); \
242+ raw_spin_unlock_irq(&pci_lock); \
233243 if (ret) \
234244 PCI_SET_ERROR_RESPONSE(val); \
235245 else \
236246 *val = (type)data; \
247+ \
237248 return pcibios_err_to_errno(ret); \
238249} \
239250EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
@@ -243,15 +254,18 @@ EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
243254int pci_user_write_config_##size \
244255 (struct pci_dev *dev, int pos, type val) \
245256{ \
246- int ret = PCIBIOS_SUCCESSFUL; \
257+ int ret; \
258+ \
247259 if (PCI_##size##_BAD) \
248260 return -EINVAL; \
249- raw_spin_lock_irq(&pci_lock); \
261+ \
262+ raw_spin_lock_irq(&pci_lock); \
250263 if (unlikely(dev->block_cfg_access)) \
251264 pci_wait_cfg(dev); \
252265 ret = dev->bus->ops->write(dev->bus, dev->devfn, \
253- pos, sizeof(type), val); \
254- raw_spin_unlock_irq(&pci_lock); \
266+ pos, sizeof(type), val); \
267+ raw_spin_unlock_irq(&pci_lock); \
268+ \
255269 return pcibios_err_to_errno(ret); \
256270} \
257271EXPORT_SYMBOL_GPL(pci_user_write_config_##size);
0 commit comments