nvram.c (688d794c4c3f8b08c814381ee2edd3ede5856056) | nvram.c (97367519d7dac94de566796f034d5f72cbc671f7) |
---|---|
1/* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 8 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com> --- 24 unchanged lines hidden (view full) --- 33 u32 checksum_old; 34 u8 reserved3[720]; 35 u32 checksum_high; 36}; 37 38static struct bcm963xx_nvram nvram; 39static int mac_addr_used; 40 | 1/* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 5 * 6 * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr> 7 * Copyright (C) 2008 Florian Fainelli <florian@openwrt.org> 8 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com> --- 24 unchanged lines hidden (view full) --- 33 u32 checksum_old; 34 u8 reserved3[720]; 35 u32 checksum_high; 36}; 37 38static struct bcm963xx_nvram nvram; 39static int mac_addr_used; 40 |
41int __init bcm63xx_nvram_init(void *addr) | 41void __init bcm63xx_nvram_init(void *addr) |
42{ 43 unsigned int check_len; 44 u32 crc, expected_crc; 45 46 /* extract nvram data */ 47 memcpy(&nvram, addr, sizeof(nvram)); 48 49 /* check checksum before using data */ --- 5 unchanged lines hidden (view full) --- 55 check_len = sizeof(nvram); 56 expected_crc = nvram.checksum_high; 57 nvram.checksum_high = 0; 58 } 59 60 crc = crc32_le(~0, (u8 *)&nvram, check_len); 61 62 if (crc != expected_crc) | 42{ 43 unsigned int check_len; 44 u32 crc, expected_crc; 45 46 /* extract nvram data */ 47 memcpy(&nvram, addr, sizeof(nvram)); 48 49 /* check checksum before using data */ --- 5 unchanged lines hidden (view full) --- 55 check_len = sizeof(nvram); 56 expected_crc = nvram.checksum_high; 57 nvram.checksum_high = 0; 58 } 59 60 crc = crc32_le(~0, (u8 *)&nvram, check_len); 61 62 if (crc != expected_crc) |
63 return -EINVAL; 64 65 return 0; | 63 pr_warn("nvram checksum failed, contents may be invalid (expected %08x, got %08x)\n", 64 expected_crc, crc); |
66} 67 68u8 *bcm63xx_nvram_get_name(void) 69{ 70 return nvram.name; 71} 72EXPORT_SYMBOL(bcm63xx_nvram_get_name); 73 --- 34 unchanged lines hidden --- | 65} 66 67u8 *bcm63xx_nvram_get_name(void) 68{ 69 return nvram.name; 70} 71EXPORT_SYMBOL(bcm63xx_nvram_get_name); 72 --- 34 unchanged lines hidden --- |