From d75138be002d079a28901686b9dacb6bdb9eba7d Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Mon, 4 Jul 2011 10:46:51 +0200 Subject: [PATCH] E1000 - fixed reading/writing device registers - the pointers must be flagged as volatile because otherwise they might be "optimized" by a compiler. It is a common good practice to access the registers this way, the keyword is in C for a reason. - for instance, in eeprom_eerd() when polling a register the compiler, under certain conditions, may decide upon the first read and if it does not break the loop it assumes that the value is not going to change and thus stays in an infinite loop. --- drivers/e1000/e1000.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/e1000/e1000.c b/drivers/e1000/e1000.c index b4c297738..a11129d51 100644 --- a/drivers/e1000/e1000.c +++ b/drivers/e1000/e1000.c @@ -878,7 +878,7 @@ uint32_t reg; assert(reg < 0x1ffff); /* Read from memory mapped register. */ - value = *(u32_t *)(e->regs + reg); + value = *(volatile u32_t *)(e->regs + reg); /* Return the result. */ return value; @@ -896,7 +896,7 @@ uint32_t value; assert(reg < 0x1ffff); /* Write to memory mapped register. */ - *(u32_t *)(e->regs + reg) = value; + *(volatile u32_t *)(e->regs + reg) = value; } /*===========================================================================* -- 2.44.0