hwaccess: Constify `addr` argument of MMIO read functions
Change-Id: I1419241a8332b74103b3921df2c615bdf91346a7
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/18881
Tested-by: build bot (Jenkins)
Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com>
Reviewed-by: Youness Alaoui <snifikino@gmail.com>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
diff --git a/hwaccess.c b/hwaccess.c
index 1901ee6..aede7e3 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -147,22 +147,22 @@
sync_primitive();
}
-uint8_t mmio_readb(void *addr)
+uint8_t mmio_readb(const void *addr)
{
- return *(volatile uint8_t *) addr;
+ return *(volatile const uint8_t *) addr;
}
-uint16_t mmio_readw(void *addr)
+uint16_t mmio_readw(const void *addr)
{
- return *(volatile uint16_t *) addr;
+ return *(volatile const uint16_t *) addr;
}
-uint32_t mmio_readl(void *addr)
+uint32_t mmio_readl(const void *addr)
{
- return *(volatile uint32_t *) addr;
+ return *(volatile const uint32_t *) addr;
}
-void mmio_readn(void *addr, uint8_t *buf, size_t len)
+void mmio_readn(const void *addr, uint8_t *buf, size_t len)
{
memcpy(buf, addr, len);
return;
@@ -183,17 +183,17 @@
mmio_writel(cpu_to_le32(val), addr);
}
-uint8_t mmio_le_readb(void *addr)
+uint8_t mmio_le_readb(const void *addr)
{
return le_to_cpu8(mmio_readb(addr));
}
-uint16_t mmio_le_readw(void *addr)
+uint16_t mmio_le_readw(const void *addr)
{
return le_to_cpu16(mmio_readw(addr));
}
-uint32_t mmio_le_readl(void *addr)
+uint32_t mmio_le_readl(const void *addr)
{
return le_to_cpu32(mmio_readl(addr));
}
diff --git a/programmer.h b/programmer.h
index 3853413..1a6216a 100644
--- a/programmer.h
+++ b/programmer.h
@@ -351,16 +351,16 @@
void mmio_writeb(uint8_t val, void *addr);
void mmio_writew(uint16_t val, void *addr);
void mmio_writel(uint32_t val, void *addr);
-uint8_t mmio_readb(void *addr);
-uint16_t mmio_readw(void *addr);
-uint32_t mmio_readl(void *addr);
-void mmio_readn(void *addr, uint8_t *buf, size_t len);
+uint8_t mmio_readb(const void *addr);
+uint16_t mmio_readw(const void *addr);
+uint32_t mmio_readl(const void *addr);
+void mmio_readn(const void *addr, uint8_t *buf, size_t len);
void mmio_le_writeb(uint8_t val, void *addr);
void mmio_le_writew(uint16_t val, void *addr);
void mmio_le_writel(uint32_t val, void *addr);
-uint8_t mmio_le_readb(void *addr);
-uint16_t mmio_le_readw(void *addr);
-uint32_t mmio_le_readl(void *addr);
+uint8_t mmio_le_readb(const void *addr);
+uint16_t mmio_le_readw(const void *addr);
+uint32_t mmio_le_readl(const void *addr);
#define pci_mmio_writeb mmio_le_writeb
#define pci_mmio_writew mmio_le_writew
#define pci_mmio_writel mmio_le_writel