summaryrefslogtreecommitdiff
path: root/target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch
diff options
context:
space:
mode:
authorjogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-04 10:19:50 +0000
committerjogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-04 10:19:50 +0000
commit404cd71e7c4cb3b69a53db4876c0b2cbf27c3036 (patch)
tree2a0a6f9f6e49e2f6fc676b151fff168991ff6ffe /target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch
parenta8fbf328d42ff0348a4741697ce20bacc50b1116 (diff)
bcm63xx: add support for linux 3.7
Based on 3.7.6. Signed-off-by: Jonas Gorski <jogo@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35481 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch')
-rw-r--r--target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch66
1 files changed, 66 insertions, 0 deletions
diff --git a/target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch b/target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch
new file mode 100644
index 0000000000..cbe0b96bf0
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.7/005-MIPS-BCM63XX-fix-nvram-checksum-calculation.patch
@@ -0,0 +1,66 @@
+From 7180de9a27ce433efc15bc1982b9a9e4ba3c48dc Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jonas.gorski@gmail.com>
+Date: Sat, 10 Nov 2012 02:04:58 +0100
+Subject: [PATCH] MIPS: BCM63XX: fix nvram checksum calculation
+
+The current checksum calculation code does nothing except checking that
+the first byte of nvram is 0 without actually checking the checksum.
+
+Implement the correct checksum calculation by calculating the crc32 with
+the checksum field set to 0.
+
+Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
+---
+
+This patch depends on the previous nvram patch ("move nvram functions
+into their own file").
+
+ arch/mips/bcm63xx/nvram.c | 23 +++++++++++++----------
+ 1 files changed, 13 insertions(+), 10 deletions(-)
+
+--- a/arch/mips/bcm63xx/nvram.c
++++ b/arch/mips/bcm63xx/nvram.c
+@@ -11,6 +11,7 @@
+ #define pr_fmt(fmt) "bcm63xx_nvram: " fmt
+
+ #include <linux/init.h>
++#include <linux/crc32.h>
+ #include <linux/export.h>
+ #include <linux/kernel.h>
+ #include <linux/if_ether.h>
+@@ -40,23 +41,25 @@ static int mac_addr_used;
+ int __init bcm63xx_nvram_init(void *addr)
+ {
+ unsigned int check_len;
+- u8 *p;
+- u32 val;
++ u32 crc, expected_crc;
+
+ /* extract nvram data */
+ memcpy(&nvram, addr, sizeof(nvram));
+
+ /* check checksum before using data */
+- if (nvram.version <= 4)
+- check_len = offsetof(struct bcm963xx_nvram, checksum_old);
+- else
++ if (nvram.version <= 4) {
++ check_len = offsetof(struct bcm963xx_nvram, reserved3);
++ expected_crc = nvram.checksum_old;
++ nvram.checksum_old = 0;
++ } else {
+ check_len = sizeof(nvram);
+- val = 0;
+- p = (u8 *)&nvram;
++ expected_crc = nvram.checksum_high;
++ nvram.checksum_high = 0;
++ }
+
+- while (check_len--)
+- val += *p;
+- if (val)
++ crc = crc32_le(~0, (u8 *)&nvram, check_len);
++
++ if (crc != expected_crc)
+ return -EINVAL;
+
+ return 0;