kernel: update 3.10 to 3.10.13
[openwrt.git] / target / linux / brcm63xx / patches-3.10 / 031-MIPS-BCM63XX-export-PSI-size-from-nvram.patch
1 From bda508f975d1372568a4fc9862be501a6176fd46 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sat, 12 May 2012 23:04:17 +0200
4 Subject: [PATCH v2 2/3] MIPS: BCM63XX: export PSI size from nvram
5
6 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
7 ---
8  arch/mips/bcm63xx/nvram.c                          |   13 +++++++++++++
9  arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h |    7 +++++++
10  2 files changed, 20 insertions(+)
11
12 --- a/arch/mips/bcm63xx/nvram.c
13 +++ b/arch/mips/bcm63xx/nvram.c
14 @@ -15,6 +15,7 @@
15  #include <linux/export.h>
16  #include <linux/kernel.h>
17  #include <linux/if_ether.h>
18 +#include <linux/sizes.h>
19  
20  #include <bcm63xx_nvram.h>
21  
22 @@ -35,6 +36,8 @@ struct bcm963xx_nvram {
23         u32     checksum_high;
24  };
25  
26 +#define BCM63XX_DEFAULT_PSI_SIZE       SZ_64K
27 +
28  static struct bcm963xx_nvram nvram;
29  static int mac_addr_used;
30  
31 @@ -104,3 +107,13 @@ int bcm63xx_nvram_get_mac_address(u8 *ma
32         return 0;
33  }
34  EXPORT_SYMBOL(bcm63xx_nvram_get_mac_address);
35 +
36 +unsigned int bcm63xx_nvram_get_psi_size(void)
37 +{
38 +       /* max is 64k, but some vendors use higher values */
39 +       if (nvram.psi_size > 0 && nvram.psi_size <= 512)
40 +               return nvram.psi_size * SZ_1K;
41 +
42 +       return BCM63XX_DEFAULT_PSI_SIZE;
43 +}
44 +EXPORT_SYMBOL(bcm63xx_nvram_get_psi_size);
45 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
46 +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
47 @@ -30,4 +30,11 @@ u8 *bcm63xx_nvram_get_name(void);
48   */
49  int bcm63xx_nvram_get_mac_address(u8 *mac);
50  
51 +/**
52 + * bcm63xx_nvram_get_psi_size() - returns the size of the PSI area
53 + *
54 + * Returns the size of the Persitent Storage Information area in bytes.
55 + */
56 +unsigned int bcm63xx_nvram_get_psi_size(void);
57 +
58  #endif /* BCM63XX_NVRAM_H */