summaryrefslogtreecommitdiff
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:43 +0100
commita084dbf6592c22468eb946014b2e731fb42da7a9 (patch)
tree96a9fc304b172c862d317ea73892a2fa55e5d4d1 /include/linux/nvram.h
parent1278cf66cf4b1c3d30e311200b50c45457c92baa (diff)
m68k/atari: Implement arch_nvram_ops struct
By implementing an arch_nvram_ops struct, a platform can re-use the drivers/char/nvram.c module without needing any arch-specific code in that module. Atari does so here. Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> 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.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/nvram.h b/include/linux/nvram.h
index eb5b52a9a747..a1e01dc89759 100644
--- a/include/linux/nvram.h
+++ b/include/linux/nvram.h
@@ -5,8 +5,18 @@
#include <linux/errno.h>
#include <uapi/linux/nvram.h>
+struct nvram_ops {
+ ssize_t (*get_size)(void);
+ ssize_t (*read)(char *, size_t, loff_t *);
+ ssize_t (*write)(char *, size_t, loff_t *);
+};
+
+extern const struct nvram_ops arch_nvram_ops;
+
static inline ssize_t nvram_get_size(void)
{
+ if (arch_nvram_ops.get_size)
+ return arch_nvram_ops.get_size();
return -ENODEV;
}
@@ -21,11 +31,15 @@ static inline void nvram_write_byte(unsigned char val, int addr)
static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
{
+ if (arch_nvram_ops.read)
+ return arch_nvram_ops.read(buf, count, ppos);
return -ENODEV;
}
static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
{
+ if (arch_nvram_ops.write)
+ return arch_nvram_ops.write(buf, count, ppos);
return -ENODEV;
}