All of lore.kernel.org
 help / color / mirror / Atom feed
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: Tue, 05 Jun 2007 16:35:07 +0900	[thread overview]
Message-ID: <4665122B.6010707@necel.com> (raw)

Hi,

pci_hose_read_config_{byte,word}_via_dword uses a temporary read
buffer `val32', so if read_config_dword returns -1 then val32 also
should be initialized.

Without this fix we'll go on scanning bus with vendor or header_
type uninitialized. This brings many unnecessary config trials.

compiled and tested with our MIPS board.

Thanks,
Shinya

Index: b/drivers/pci.c
===================================================================
--- a/drivers/pci.c
+++ b/drivers/pci.c
@@ -75,7 +75,7 @@ PCI_OP(write, word, u16, )
 PCI_OP(write, dword, u32, )
 #endif	/* CONFIG_IXP425 */
 
-#define PCI_READ_VIA_DWORD_OP(size, type, off_mask)			\
+#define PCI_READ_VIA_DWORD_OP(size, type, off_mask, error_code)		\
 int pci_hose_read_config_##size##_via_dword(struct pci_controller *hose,\
 					pci_dev_t dev, 			\
 					int offset, type val)		\
@@ -83,7 +83,10 @@ int pci_hose_read_config_##size##_via_dw
 	u32 val32;							\
 									\
 	if (pci_hose_read_config_dword(hose, dev, offset & 0xfc, &val32) < 0)\
+	{								\
+		error_code;						\
 		return -1;						\
+	}								\
 									\
 	*val = (val32 >> ((offset & (int)off_mask) * 8));		\
 									\
@@ -111,8 +114,8 @@ int pci_hose_write_config_##size##_via_d
 	return 0;							\
 }
 
-PCI_READ_VIA_DWORD_OP(byte, u8 *, 0x03)
-PCI_READ_VIA_DWORD_OP(word, u16 *, 0x02)
+PCI_READ_VIA_DWORD_OP(byte, u8 *, 0x03, *val = 0xff)
+PCI_READ_VIA_DWORD_OP(word, u16 *, 0x02, *val = 0xffff)
 PCI_WRITE_VIA_DWORD_OP(byte, u8, 0x03, 0x000000ff)
 PCI_WRITE_VIA_DWORD_OP(word, u16, 0x02, 0x0000ffff)
 

             reply	other threads:[~2007-06-05  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-05  7:35 Shinya Kuribayashi [this message]
2007-06-05 16:04 ` [U-Boot-Users] [PATCH] PCI_READ_VIA_DWORD_OP: initialize val parameter on fail Wolfgang Denk
2007-06-06  0:51   ` Shinya Kuribayashi
2007-06-06  2:18     ` Shinya Kuribayashi
2007-06-06  3:33     ` Shinya Kuribayashi

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=4665122B.6010707@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.