path: root/internal.c
diff options
authorCarl-Daniel Hailfinger <>2009-05-16 21:22:56 +0000
committerCarl-Daniel Hailfinger <>2009-05-16 21:22:56 +0000
commit5820f42ef209cfa0d4070fa9be96c9c91123a93f (patch)
treea505b6f813fc4f7601f77e7195e479dfddc73571 /internal.c
parent4059598a068f7694f2238a3811d85cbfa520a8d5 (diff)
Introduce a type "chipaddr" to abstract the offsets within flash regions
Use chipaddr instead of volatile uint8_t * because when we access chips in external flashers, they are not accessed via pointers at all. Benefits: This allows us to differentiate between volatile machine memory accesses and flash chip accesses. It also enforces usage of chip_{read,write}[bwl] to access flash chips, so nobody will unintentionally use pointers to access chips anymore. Some unneeded casts are removed as well. Grepping for chip operations and machine memory operations doesn't yield any false positives anymore. Compile tested on 32 bit and 64 bit Linux. Corresponding to flashrom svn r519. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Uwe Hermann <>
Diffstat (limited to 'internal.c')
1 files changed, 10 insertions, 10 deletions
diff --git a/internal.c b/internal.c
index f10d0d5..653783c 100644
--- a/internal.c
+++ b/internal.c
@@ -138,45 +138,45 @@ int internal_shutdown(void)
return 0;
-void internal_chip_writeb(uint8_t val, volatile void *addr)
+void internal_chip_writeb(uint8_t val, chipaddr addr)
*(volatile uint8_t *) addr = val;
-void internal_chip_writew(uint16_t val, volatile void *addr)
+void internal_chip_writew(uint16_t val, chipaddr addr)
*(volatile uint16_t *) addr = val;
-void internal_chip_writel(uint32_t val, volatile void *addr)
+void internal_chip_writel(uint32_t val, chipaddr addr)
*(volatile uint32_t *) addr = val;
-uint8_t internal_chip_readb(const volatile void *addr)
+uint8_t internal_chip_readb(const chipaddr addr)
return *(volatile uint8_t *) addr;
-uint16_t internal_chip_readw(const volatile void *addr)
+uint16_t internal_chip_readw(const chipaddr addr)
return *(volatile uint16_t *) addr;
-uint32_t internal_chip_readl(const volatile void *addr)
+uint32_t internal_chip_readl(const chipaddr addr)
return *(volatile uint32_t *) addr;
/* Little-endian fallback for drivers not supporting 16 bit accesses */
-void fallback_chip_writew(uint16_t val, volatile void *addr)
+void fallback_chip_writew(uint16_t val, chipaddr addr)
chip_writeb(val & 0xff, addr);
chip_writeb((val >> 8) & 0xff, addr + 1);
/* Little-endian fallback for drivers not supporting 16 bit accesses */
-uint16_t fallback_chip_readw(const volatile void *addr)
+uint16_t fallback_chip_readw(const chipaddr addr)
uint16_t val;
val = chip_readb(addr);
@@ -185,14 +185,14 @@ uint16_t fallback_chip_readw(const volatile void *addr)
/* Little-endian fallback for drivers not supporting 32 bit accesses */
-void fallback_chip_writel(uint32_t val, volatile void *addr)
+void fallback_chip_writel(uint32_t val, chipaddr addr)
chip_writew(val & 0xffff, addr);
chip_writew((val >> 16) & 0xffff, addr + 2);
/* Little-endian fallback for drivers not supporting 32 bit accesses */
-uint32_t fallback_chip_readl(const volatile void *addr)
+uint32_t fallback_chip_readl(const chipaddr addr)
uint32_t val;
val = chip_readw(addr);
OpenPOWER on IntegriCloud