summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2021-03-08 10:03:16 +0100
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2021-03-12 15:53:07 +0100
commitfb009cbdd0693bd633f11e99526617b3d392cfad (patch)
tree45be01ef84d5fdb963bfa41313370147e065d1de
parentdd647b125505646d5143ce6e3117cf5ee9ec228a (diff)
firmware: bcm47xx_nvram: rename finding function and its variables
1. Use "bcm47xx_" function name prefix for consistency 2. It takes flash start as argument so s/iobase/flash_start/ 3. "off" was used for finding flash end so just call it "flash_size" Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
-rw-r--r--drivers/firmware/broadcom/bcm47xx_nvram.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/firmware/broadcom/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
index 835ece9c00f1..b04007adc79f 100644
--- a/drivers/firmware/broadcom/bcm47xx_nvram.c
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
@@ -48,11 +48,13 @@ static u32 find_nvram_size(void __iomem *end)
return 0;
}
-/* Probe for NVRAM header */
-static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
+/**
+ * bcm47xx_nvram_find_and_copy - find NVRAM on flash mapping & copy it
+ */
+static int bcm47xx_nvram_find_and_copy(void __iomem *flash_start, size_t res_size)
{
struct nvram_header __iomem *header;
- u32 off;
+ size_t flash_size;
u32 size;
if (nvram_len) {
@@ -61,25 +63,25 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
}
/* TODO: when nvram is on nand flash check for bad blocks first. */
- off = FLASH_MIN;
- while (off <= lim) {
+ flash_size = FLASH_MIN;
+ while (flash_size <= res_size) {
/* Windowed flash access */
- size = find_nvram_size(iobase + off);
+ size = find_nvram_size(flash_start + flash_size);
if (size) {
- header = (struct nvram_header *)(iobase + off - size);
+ header = (struct nvram_header *)(flash_start + flash_size - size);
goto found;
}
- off <<= 1;
+ flash_size <<= 1;
}
/* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
- header = (struct nvram_header *)(iobase + 4096);
+ header = (struct nvram_header *)(flash_start + 4096);
if (header->magic == NVRAM_MAGIC) {
size = NVRAM_SPACE;
goto found;
}
- header = (struct nvram_header *)(iobase + 1024);
+ header = (struct nvram_header *)(flash_start + 1024);
if (header->magic == NVRAM_MAGIC) {
size = NVRAM_SPACE;
goto found;
@@ -124,7 +126,7 @@ int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
if (!iobase)
return -ENOMEM;
- err = nvram_find_and_copy(iobase, lim);
+ err = bcm47xx_nvram_find_and_copy(iobase, lim);
iounmap(iobase);