aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/nvram.h
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2019-01-15 15:18:56 +1100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-22 10:21:45 +0100
commitf9c3a570f5fc584f2ca2dd222d1b8c8537fc55f6 (patch)
tree0bacf78e4973fea728c05a0c8b69e8afff1209e0 /include/linux/nvram.h
parentpowerpc, fbdev: Use NV_CMODE and NV_VMODE only when CONFIG_PPC32 && CONFIG_PPC_PMAC && CONFIG_NVRAM (diff)
downloadwireguard-linux-f9c3a570f5fc584f2ca2dd222d1b8c8537fc55f6.tar.xz
wireguard-linux-f9c3a570f5fc584f2ca2dd222d1b8c8537fc55f6.zip
powerpc: Enable HAVE_ARCH_NVRAM_OPS and disable GENERIC_NVRAM
Switch PPC32 kernels from the generic_nvram module to the nvram module. Also fix a theoretical bug where CHRP omits the chrp_nvram_init() call when CONFIG_NVRAM_MODULE=m. Tested-by: Stan Johnson <userm57@yahoo.com> Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/nvram.h')
-rw-r--r--include/linux/nvram.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/nvram.h b/include/linux/nvram.h
index 9e3a957c8f1f..d29d9c93a927 100644
--- a/include/linux/nvram.h
+++ b/include/linux/nvram.h
@@ -5,6 +5,10 @@
#include <linux/errno.h>
#include <uapi/linux/nvram.h>
+#ifdef CONFIG_PPC
+#include <asm/machdep.h>
+#endif
+
/**
* struct nvram_ops - NVRAM functionality made available to drivers
* @read: validate checksum (if any) then load a range of bytes from NVRAM
@@ -42,6 +46,8 @@ extern const struct nvram_ops arch_nvram_ops;
static inline ssize_t nvram_get_size(void)
{
#ifdef CONFIG_PPC
+ if (ppc_md.nvram_size)
+ return ppc_md.nvram_size();
#else
if (arch_nvram_ops.get_size)
return arch_nvram_ops.get_size();
@@ -52,6 +58,8 @@ static inline ssize_t nvram_get_size(void)
static inline unsigned char nvram_read_byte(int addr)
{
#ifdef CONFIG_PPC
+ if (ppc_md.nvram_read_val)
+ return ppc_md.nvram_read_val(addr);
#else
if (arch_nvram_ops.read_byte)
return arch_nvram_ops.read_byte(addr);
@@ -62,6 +70,8 @@ static inline unsigned char nvram_read_byte(int addr)
static inline void nvram_write_byte(unsigned char val, int addr)
{
#ifdef CONFIG_PPC
+ if (ppc_md.nvram_write_val)
+ ppc_md.nvram_write_val(addr, val);
#else
if (arch_nvram_ops.write_byte)
arch_nvram_ops.write_byte(val, addr);
@@ -98,15 +108,25 @@ static inline ssize_t nvram_write_bytes(char *buf, size_t count, loff_t *ppos)
static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
{
+#ifdef CONFIG_PPC
+ if (ppc_md.nvram_read)
+ return ppc_md.nvram_read(buf, count, ppos);
+#else
if (arch_nvram_ops.read)
return arch_nvram_ops.read(buf, count, ppos);
+#endif
return nvram_read_bytes(buf, count, ppos);
}
static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
{
+#ifdef CONFIG_PPC
+ if (ppc_md.nvram_write)
+ return ppc_md.nvram_write(buf, count, ppos);
+#else
if (arch_nvram_ops.write)
return arch_nvram_ops.write(buf, count, ppos);
+#endif
return nvram_write_bytes(buf, count, ppos);
}