mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 831-v5.13-0001-firmware-bcm47xx_nvram-rename-finding-function-and-i.patch
1 From fb009cbdd0693bd633f11e99526617b3d392cfad Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Mon, 8 Mar 2021 10:03:16 +0100
4 Subject: [PATCH] firmware: bcm47xx_nvram: rename finding function and its
5 variables
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 1. Use "bcm47xx_" function name prefix for consistency
11 2. It takes flash start as argument so s/iobase/flash_start/
12 3. "off" was used for finding flash end so just call it "flash_size"
13
14 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
15 Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
16 ---
17 drivers/firmware/broadcom/bcm47xx_nvram.c | 24 ++++++++++++-----------
18 1 file changed, 13 insertions(+), 11 deletions(-)
19
20 --- a/drivers/firmware/broadcom/bcm47xx_nvram.c
21 +++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
22 @@ -48,11 +48,13 @@ static u32 find_nvram_size(void __iomem
23 return 0;
24 }
25
26 -/* Probe for NVRAM header */
27 -static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
28 +/**
29 + * bcm47xx_nvram_find_and_copy - find NVRAM on flash mapping & copy it
30 + */
31 +static int bcm47xx_nvram_find_and_copy(void __iomem *flash_start, size_t res_size)
32 {
33 struct nvram_header __iomem *header;
34 - u32 off;
35 + size_t flash_size;
36 u32 size;
37
38 if (nvram_len) {
39 @@ -61,25 +63,25 @@ static int nvram_find_and_copy(void __io
40 }
41
42 /* TODO: when nvram is on nand flash check for bad blocks first. */
43 - off = FLASH_MIN;
44 - while (off <= lim) {
45 + flash_size = FLASH_MIN;
46 + while (flash_size <= res_size) {
47 /* Windowed flash access */
48 - size = find_nvram_size(iobase + off);
49 + size = find_nvram_size(flash_start + flash_size);
50 if (size) {
51 - header = (struct nvram_header *)(iobase + off - size);
52 + header = (struct nvram_header *)(flash_start + flash_size - size);
53 goto found;
54 }
55 - off <<= 1;
56 + flash_size <<= 1;
57 }
58
59 /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
60 - header = (struct nvram_header *)(iobase + 4096);
61 + header = (struct nvram_header *)(flash_start + 4096);
62 if (header->magic == NVRAM_MAGIC) {
63 size = NVRAM_SPACE;
64 goto found;
65 }
66
67 - header = (struct nvram_header *)(iobase + 1024);
68 + header = (struct nvram_header *)(flash_start + 1024);
69 if (header->magic == NVRAM_MAGIC) {
70 size = NVRAM_SPACE;
71 goto found;
72 @@ -124,7 +126,7 @@ int bcm47xx_nvram_init_from_mem(u32 base
73 if (!iobase)
74 return -ENOMEM;
75
76 - err = nvram_find_and_copy(iobase, lim);
77 + err = bcm47xx_nvram_find_and_copy(iobase, lim);
78
79 iounmap(iobase);
80