diff options
| -rw-r--r-- | arch/mips/bcm63xx/nvram.c | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/arch/mips/bcm63xx/nvram.c b/arch/mips/bcm63xx/nvram.c index 4b50d40f7451..05757aed016c 100644 --- a/arch/mips/bcm63xx/nvram.c +++ b/arch/mips/bcm63xx/nvram.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #define pr_fmt(fmt) "bcm63xx_nvram: " fmt | 11 | #define pr_fmt(fmt) "bcm63xx_nvram: " fmt |
| 12 | 12 | ||
| 13 | #include <linux/bcm963xx_nvram.h> | ||
| 13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 14 | #include <linux/crc32.h> | 15 | #include <linux/crc32.h> |
| 15 | #include <linux/export.h> | 16 | #include <linux/export.h> |
| @@ -18,23 +19,6 @@ | |||
| 18 | 19 | ||
| 19 | #include <bcm63xx_nvram.h> | 20 | #include <bcm63xx_nvram.h> |
| 20 | 21 | ||
| 21 | /* | ||
| 22 | * nvram structure | ||
| 23 | */ | ||
| 24 | struct bcm963xx_nvram { | ||
| 25 | u32 version; | ||
| 26 | u8 reserved1[256]; | ||
| 27 | u8 name[16]; | ||
| 28 | u32 main_tp_number; | ||
| 29 | u32 psi_size; | ||
| 30 | u32 mac_addr_count; | ||
| 31 | u8 mac_addr_base[ETH_ALEN]; | ||
| 32 | u8 reserved2[2]; | ||
| 33 | u32 checksum_old; | ||
| 34 | u8 reserved3[720]; | ||
| 35 | u32 checksum_high; | ||
| 36 | }; | ||
| 37 | |||
| 38 | #define BCM63XX_DEFAULT_PSI_SIZE 64 | 22 | #define BCM63XX_DEFAULT_PSI_SIZE 64 |
| 39 | 23 | ||
| 40 | static struct bcm963xx_nvram nvram; | 24 | static struct bcm963xx_nvram nvram; |
| @@ -42,27 +26,14 @@ static int mac_addr_used; | |||
| 42 | 26 | ||
| 43 | void __init bcm63xx_nvram_init(void *addr) | 27 | void __init bcm63xx_nvram_init(void *addr) |
| 44 | { | 28 | { |
| 45 | unsigned int check_len; | ||
| 46 | u32 crc, expected_crc; | 29 | u32 crc, expected_crc; |
| 47 | u8 hcs_mac_addr[ETH_ALEN] = { 0x00, 0x10, 0x18, 0xff, 0xff, 0xff }; | 30 | u8 hcs_mac_addr[ETH_ALEN] = { 0x00, 0x10, 0x18, 0xff, 0xff, 0xff }; |
| 48 | 31 | ||
| 49 | /* extract nvram data */ | 32 | /* extract nvram data */ |
| 50 | memcpy(&nvram, addr, sizeof(nvram)); | 33 | memcpy(&nvram, addr, BCM963XX_NVRAM_V5_SIZE); |
| 51 | 34 | ||
| 52 | /* check checksum before using data */ | 35 | /* check checksum before using data */ |
| 53 | if (nvram.version <= 4) { | 36 | if (bcm963xx_nvram_checksum(&nvram, &expected_crc, &crc)) |
| 54 | check_len = offsetof(struct bcm963xx_nvram, reserved3); | ||
| 55 | expected_crc = nvram.checksum_old; | ||
| 56 | nvram.checksum_old = 0; | ||
| 57 | } else { | ||
| 58 | check_len = sizeof(nvram); | ||
| 59 | expected_crc = nvram.checksum_high; | ||
| 60 | nvram.checksum_high = 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | crc = crc32_le(~0, (u8 *)&nvram, check_len); | ||
| 64 | |||
| 65 | if (crc != expected_crc) | ||
| 66 | pr_warn("nvram checksum failed, contents may be invalid (expected %08x, got %08x)\n", | 37 | pr_warn("nvram checksum failed, contents may be invalid (expected %08x, got %08x)\n", |
| 67 | expected_crc, crc); | 38 | expected_crc, crc); |
| 68 | 39 | ||
