[U-Boot-Users] [PATCH] PCI_READ_VIA_DWORD_OP: initialize val parameter on fail

Shinya Kuribayashi shinya.kuribayashi at necel.com
Tue Jun 5 09:35:07 CEST 2007


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)
 




More information about the U-Boot mailing list