Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent
@ 2015-04-01  6:23 Rafał Miłecki
  2015-04-01  6:23 ` [PATCH 2/3] MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB Rafał Miłecki
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-04-01  6:23 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Hauke Mehrtens, Rafał Miłecki

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

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 arch/mips/bcm47xx/nvram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 6a97732..2357ea3 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -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);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB
  2015-04-01  6:23 [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Rafał Miłecki
@ 2015-04-01  6:23 ` Rafał Miłecki
  2015-04-01  6:23 ` [PATCH 3/3] MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition Rafał Miłecki
  2015-04-01 11:15 ` [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Sergei Shtylyov
  2 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-04-01  6:23 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Hauke Mehrtens, Rafał Miłecki

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.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 arch/mips/bcm47xx/nvram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 2357ea3..2ac7482 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -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
 
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition
  2015-04-01  6:23 [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Rafał Miłecki
  2015-04-01  6:23 ` [PATCH 2/3] MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB Rafał Miłecki
@ 2015-04-01  6:23 ` Rafał Miłecki
  2015-04-01 11:15 ` [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Sergei Shtylyov
  2 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-04-01  6:23 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Hauke Mehrtens, 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.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 arch/mips/bcm47xx/nvram.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 2ac7482..ba632ff 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -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
 
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent
  2015-04-01  6:23 [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Rafał Miłecki
  2015-04-01  6:23 ` [PATCH 2/3] MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB Rafał Miłecki
  2015-04-01  6:23 ` [PATCH 3/3] MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition Rafał Miłecki
@ 2015-04-01 11:15 ` Sergei Shtylyov
  2015-04-01 11:20   ` Rafał Miłecki
  2 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2015-04-01 11:15 UTC (permalink / raw)
  To: Rafał Miłecki, linux-mips, Ralf Baechle; +Cc: Hauke Mehrtens

Hello.

On 4/1/2015 9:23 AM, Rafał Miłecki wrote:

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

> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
>   arch/mips/bcm47xx/nvram.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

> diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
> index 6a97732..2357ea3 100644
> --- a/arch/mips/bcm47xx/nvram.c
> +++ b/arch/mips/bcm47xx/nvram.c
[...]
> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent
  2015-04-01 11:15 ` [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Sergei Shtylyov
@ 2015-04-01 11:20   ` Rafał Miłecki
  2015-04-01 11:23     ` Sergei Shtylyov
  0 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2015-04-01 11:20 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-mips@linux-mips.org, Ralf Baechle, Hauke Mehrtens

On 1 April 2015 at 13:15, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Hello.
>
> On 4/1/2015 9:23 AM, Rafał Miłecki wrote:
>
>> We use IO functions like readl & ioremap_nocache, so include linux/io.h
>
>
>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>> ---
>>   arch/mips/bcm47xx/nvram.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>
>
>> diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
>> index 6a97732..2357ea3 100644
>> --- a/arch/mips/bcm47xx/nvram.c
>> +++ b/arch/mips/bcm47xx/nvram.c
>
> [...]
>>
>> @@ -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.

-- 
Rafał

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent
  2015-04-01 11:20   ` Rafał Miłecki
@ 2015-04-01 11:23     ` Sergei Shtylyov
  2015-04-01 11:28       ` Rafał Miłecki
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2015-04-01 11:23 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: linux-mips@linux-mips.org, Ralf Baechle, Hauke Mehrtens

Hello.

On 4/1/2015 2:20 PM, Rafał Miłecki wrote:

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

>>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>>> ---
>>>    arch/mips/bcm47xx/nvram.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)

>>> diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
>>> index 6a97732..2357ea3 100644
>>> --- a/arch/mips/bcm47xx/nvram.c
>>> +++ b/arch/mips/bcm47xx/nvram.c
>> [...]
>>> @@ -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.

    Ah, sorry, missed you summary...

> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent
  2015-04-01 11:23     ` Sergei Shtylyov
@ 2015-04-01 11:28       ` Rafał Miłecki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-04-01 11:28 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-mips@linux-mips.org, Ralf Baechle, Hauke Mehrtens

On 1 April 2015 at 13:23, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> On 4/1/2015 2:20 PM, Rafał Miłecki wrote:
>> 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!

-- 
Rafał

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-01 11:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-01  6:23 [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Rafał Miłecki
2015-04-01  6:23 ` [PATCH 2/3] MIPS: BCM47XX: Increase NVRAM buffer size to 64 KiB Rafał Miłecki
2015-04-01  6:23 ` [PATCH 3/3] MIPS: BCM47XX: Don't try guessing NVRAM size on MTD partition Rafał Miłecki
2015-04-01 11:15 ` [PATCH 1/3] MIPS: BCM47XX: Include io.h directly and fix brace indent Sergei Shtylyov
2015-04-01 11:20   ` Rafał Miłecki
2015-04-01 11:23     ` Sergei Shtylyov
2015-04-01 11:28       ` Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox