[U-Boot] [PATCH] e1000: fix bugs from recent commits
Wolfgang Denk
wd at denx.de
Fri Oct 28 07:49:13 CEST 2011
Commit 114d7fc0 "e1000: Rewrite EEPROM checksum error to give more
information" failed to initialize the checksum variable which should
result in random results. Fix that.
[I wonder if that code has _ever_ been tested!!]
Commit 2326a94d caused a ton of "unused variable 'x'" warnings.
Fix these. While we are at it, remove some bogus parens.
Signed-off-by: Wolfgang Denk <wd at denx.de>
Cc: Kyle Moffett <Kyle.D.Moffett at boeing.com>
---
Kyle,
I wonder if you have ever actually build and run this code???
With the "checksum" variable being random (due to not being
initialized) you should have seen serious checksum problems.
How did this escape your testing?
And all these build warnings - have you ever actully compiled that
code? What's going on here??? - wd
Marek: Could you please be so kind and have a look at the debug code?
I think this needs a major cleanup, too. Thanks in advance. - wd
drivers/net/e1000.c | 1 +
drivers/net/e1000.h | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index c86bf0a..6eab7b2 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -884,6 +884,7 @@ static int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
}
/* Compute the checksum */
+ checksum = 0;
for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
checksum += buf[i];
checksum = ((uint16_t)EEPROM_SUM) - checksum;
diff --git a/drivers/net/e1000.h b/drivers/net/e1000.h
index 05f2bce..db72604 100644
--- a/drivers/net/e1000.h
+++ b/drivers/net/e1000.h
@@ -62,15 +62,15 @@
/* I/O wrapper functions */
#define E1000_WRITE_REG(a, reg, value) \
- (writel((value), ((a)->hw_addr + E1000_##reg)))
+ writel((value), ((a)->hw_addr + E1000_##reg))
#define E1000_READ_REG(a, reg) \
- (readl((a)->hw_addr + E1000_##reg))
+ readl((a)->hw_addr + E1000_##reg)
#define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
- (writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2))))
+ writel((value), ((a)->hw_addr + E1000_##reg + ((offset) << 2)))
#define E1000_READ_REG_ARRAY(a, reg, offset) \
- (readl((a)->hw_addr + E1000_##reg + ((offset) << 2)))
+ readl((a)->hw_addr + E1000_##reg + ((offset) << 2))
#define E1000_WRITE_FLUSH(a) \
- do { uint32_t x = E1000_READ_REG(a, STATUS); } while (0)
+ E1000_READ_REG(a, STATUS)
/* Forward declarations of structures used by the shared code */
struct e1000_hw;
--
1.7.6.4
More information about the U-Boot
mailing list