From: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] PCI_READ_VIA_DWORD_OP: initialize val parameter on fail
Date: Wed, 06 Jun 2007 12:33:42 +0900 [thread overview]
Message-ID: <46662B16.3060906@necel.com> (raw)
In-Reply-To: <46660525.3000708@necel.com>
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) \
prev parent reply other threads:[~2007-06-06 3:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-05 7:35 [U-Boot-Users] [PATCH] PCI_READ_VIA_DWORD_OP: initialize val parameter on fail Shinya Kuribayashi
2007-06-05 16:04 ` Wolfgang Denk
2007-06-06 0:51 ` Shinya Kuribayashi
2007-06-06 2:18 ` Shinya Kuribayashi
2007-06-06 3:33 ` Shinya Kuribayashi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46662B16.3060906@necel.com \
--to=shinya.kuribayashi@necel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.