Skip to contentSkip to conversation

MIPS: BCM47XX: Include io.h directly and fix brace indent

PATCH In review Rafał Miłecki 2 participants 7 messages Apr 1, 2015

Subsystems (2)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/3 MIPS: BCM47XX: Include io.h directly and fix brace indent

We use IO functions like readl & ioremap_nocache, so include linux/io.h

---
 arch/mips/bcm47xx/nvram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/bcm47xx/nvram.c +2 -1
index 6a97732..2357ea3 100644
@@ -11,6 +11,7 @@
  * option) any later version.
  */
 
+#include <linux/io.h>
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -203,7 +204,7 @@ int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
 		if (eq - var == strlen(name) &&
 		    strncmp(var, name, eq - var) == 0)
 			return snprintf(val, val_len, "%s", value);
-		}
+	}
 	return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_getenv);
Signature · 1 line
1.8.4.5
author maintainer
#1 lore raw

PATCH 2/3 MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB

For years Broadcom devices use 64 KiB NVRAM partition size and some of them indeed have it filled in more than 50%. This change allows reading whole NVRAM e.g. on Netgear WNDR4500 and Netgear R8000.

---
 arch/mips/bcm47xx/nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/bcm47xx/nvram.c +1 -1
index 2357ea3..2ac7482 100644
@@ -20,7 +20,7 @@
 #include <linux/bcm47xx_nvram.h>
 
 #define NVRAM_MAGIC			0x48534C46	/* 'FLSH' */
-#define NVRAM_SPACE			0x8000
+#define NVRAM_SPACE			0x10000
 #define NVRAM_MAX_GPIO_ENTRIES		32
 #define NVRAM_MAX_GPIO_VALUE_LEN	30
 
Signature · 1 line
1.8.4.5
author maintainer
#2 lore raw

PATCH 3/3 MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition

In reply to Rafał Miłecki

When dealing with whole flash content (bcm47xx_nvram_init_from_mem) we need to find NVRAM start trying various partition sizes (nvram_sizes). This is not needed when using MTD as we have direct partition access.

---
 arch/mips/bcm47xx/nvram.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)
arch/mips/bcm47xx/nvram.c +14 -22
index 2ac7482..ba632ff 100644
@@ -139,36 +139,28 @@ static int nvram_init(void)
 	struct mtd_info *mtd;
 	struct nvram_header header;
 	size_t bytes_read;
-	int err, i;
+	int err;
 
 	mtd = get_mtd_device_nm("nvram");
 	if (IS_ERR(mtd))
 		return -ENODEV;
 
-	for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
-		loff_t from = mtd->size - nvram_sizes[i];
-
-		if (from < 0)
-			continue;
-
-		err = mtd_read(mtd, from, sizeof(header), &bytes_read,
-			       (uint8_t *)&header);
-		if (!err && header.magic == NVRAM_MAGIC) {
-			u8 *dst = (uint8_t *)nvram_buf;
-			size_t len = header.len;
+	err = mtd_read(mtd, 0, sizeof(header), &bytes_read, (uint8_t *)&header);
+	if (!err && header.magic == NVRAM_MAGIC) {
+		u8 *dst = (uint8_t *)nvram_buf;
+		size_t len = header.len;
 
-			if (header.len > NVRAM_SPACE) {
-				pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
-				       header.len, NVRAM_SPACE);
-				len = NVRAM_SPACE;
-			}
+		if (header.len > NVRAM_SPACE) {
+			pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+				header.len, NVRAM_SPACE);
+			len = NVRAM_SPACE;
+		}
 
-			err = mtd_read(mtd, from, len, &bytes_read, dst);
-			if (err)
-				return err;
+		err = mtd_read(mtd, 0, len, &bytes_read, dst);
+		if (err)
+			return err;
 
-			return 0;
-		}
+		return 0;
 	}
 #endif
 
Signature · 1 line
1.8.4.5
#3 lore raw
In reply to Rafał Miłecki

Hello.

Quoted 11 lines · Rafał Miłecki

We use IO functions like readl & ioremap_nocache, so include linux/io.h

---
  arch/mips/bcm47xx/nvram.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 6a97732..2357ea3 100644

[...]

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len) · line 207

Quoted 6 lines
arch/mips/bcm47xx/nvram.c +1 -1
@@ -203,7 +204,7 @@ int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
  		if (eq - var == strlen(name) &&
  		    strncmp(var, name, eq - var) == 0)
  			return snprintf(val, val_len, "%s", value);
-		}
+	}

Unrelated (and undescribed) change.

[...]

WBR, Sergei

author maintainer
#4 lore raw
Quoted 20 lines · Sergei Shtylyov

Hello.

Quoted 13 lines · Rafał Miłecki

We use IO functions like readl & ioremap_nocache, so include linux/io.h

---
  arch/mips/bcm47xx/nvram.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 6a97732..2357ea3 100644

[...]

Quoted 1 line
Quoted 10 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_getenv(const char *name, char *val, · line 208

Quoted 7 lines
arch/mips/bcm47xx/nvram.c +1 -1
@@ -203,7 +204,7 @@ int bcm47xx_nvram_getenv(const char *name, char *val,
 size_t val_len)
                if (eq - var == strlen(name) &&
                    strncmp(var, name, eq - var) == 0)
                        return snprintf(val, val_len, "%s", value);
-               }
+       }

Unrelated (and undescribed) change.

Described in the commit message, skipped in the description.

I was feeling a bit unsure about sending two so trivial patches: one for single-line include, second for single-line indent. So I merged them.

Signature · 1 line
Rafał
#5 lore raw

Hello.

Quoted 22 lines · Rafał Miłecki
Quoted 12 lines
Quoted 11 lines

We use IO functions like readl & ioremap_nocache, so include linux/io.h

---
   arch/mips/bcm47xx/nvram.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/bcm47xx/nvram.c +0 -0
index 6a97732..2357ea3 100644

[...]

Quoted 9 lines

arch/mips/bcm47xx/nvram.c int bcm47xx_nvram_getenv(const char *name, char *val, · line 208

Quoted 7 lines
arch/mips/bcm47xx/nvram.c +1 -1
@@ -203,7 +204,7 @@ int bcm47xx_nvram_getenv(const char *name, char *val,
 size_t val_len)
                 if (eq - var == strlen(name) &&
                     strncmp(var, name, eq - var) == 0)
                         return snprintf(val, val_len, "%s", value);
-               }
+       }

Unrelated (and undescribed) change.

Quoted 1 line

Described in the commit message, skipped in the description.

Ah, sorry, missed you summary...

Quoted 3 lines

I was feeling a bit unsure about sending two so trivial patches: one for single-line include, second for single-line indent. So I merged them.

No need to be unsure about this. Doing one thing per patch is perfectly
legal and certainly better than doing 2 unrelated things. :-)

WBR, Sergei

author maintainer
#6 lore raw
Quoted 8 lines · Sergei Shtylyov
Quoted 4 lines · Rafał Miłecki

I was feeling a bit unsure about sending two so trivial patches: one

for single-line include, second for single-line indent. So I merged them.

No need to be unsure about this. Doing one thing per patch is perfectly
legal and certainly better than doing 2 unrelated things. :-)

OK, I promise to note that for the future, thanks!

Signature · 1 line
Rafał