
Wolfgang,
I have to admit that I don't get wht you need all this "error_code" trickery instead of simpley writing
*val = -1;
Can you please change your patch like that, and while you are at it please fix the other uses of this ugly construct as well?
I simply tried to remove error_code trickery for the remaining part, but failed to compile. *val = -1; is not allowed for config write. If we want to remove error_code completely, pci_##rw##_config_##size() should be revised first.
I have a feeling the current macro may be compact tough, let's see the patch. Of course compiled and tested.
Thanks.
---
This patch contains the following cleanups for PCI_OP macro: - Split PCI_OP into PCI_READ_OP and PCI_WRITE_OP, respectivly - Fix bad brace style - Initialize *val with -1 on error. This obsoletes error_code trick
Signed-off-by: Shinya Kuribayashi shinya.kuribayashi@necel.com
---
drivers/pci.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
Index: b/drivers/pci.c =================================================================== --- a/drivers/pci.c +++ b/drivers/pci.c @@ -53,26 +53,36 @@ PCI_HOSE_OP(write, word, u16) PCI_HOSE_OP(write, dword, u32)
#ifndef CONFIG_IXP425 -#define PCI_OP(rw, size, type, error_code) \ -int pci_##rw##_config_##size(pci_dev_t dev, int offset, type value) \ +#define PCI_READ_OP(size, type) \ +int pci_read_config_##size(pci_dev_t dev, int offset, type value) \ { \ struct pci_controller *hose = pci_bus_to_hose(PCI_BUS(dev)); \ \ - if (!hose) \ - { \ - error_code; \ + if (!hose) { \ + *value = -1; \ return -1; \ } \ \ - return pci_hose_##rw##_config_##size(hose, dev, offset, value); \ + return pci_hose_read_config_##size(hose, dev, offset, value); \ +} + +#define PCI_WRITE_OP(size, type) \ +int pci_write_config_##size(pci_dev_t dev, int offset, type value) \ +{ \ + struct pci_controller *hose = pci_bus_to_hose(PCI_BUS(dev)); \ + \ + if (!hose) \ + return -1; \ + \ + return pci_hose_write_config_##size(hose, dev, offset, value); \ }
-PCI_OP(read, byte, u8 *, *value = 0xff) -PCI_OP(read, word, u16 *, *value = 0xffff) -PCI_OP(read, dword, u32 *, *value = 0xffffffff) -PCI_OP(write, byte, u8, ) -PCI_OP(write, word, u16, ) -PCI_OP(write, dword, u32, ) +PCI_READ_OP(byte, u8 *) +PCI_READ_OP(word, u16 *) +PCI_READ_OP(dword, u32 *) +PCI_WRITE_OP(byte, u8) +PCI_WRITE_OP(word, u16) +PCI_WRITE_OP(dword, u32) #endif /* CONFIG_IXP425 */
#define PCI_READ_VIA_DWORD_OP(size, type, off_mask) \