aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/atari
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2019-01-14 23:18:56 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-22 04:21:43 -0500
commita084dbf6592c22468eb946014b2e731fb42da7a9 (patch)
tree96a9fc304b172c862d317ea73892a2fa55e5d4d1 /arch/m68k/atari
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 'arch/m68k/atari')
-rw-r--r--arch/m68k/atari/nvram.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/arch/m68k/atari/nvram.c b/arch/m68k/atari/nvram.c
index 1d767847ffa6..e75adebe6e7d 100644
--- a/arch/m68k/atari/nvram.c
+++ b/arch/m68k/atari/nvram.c
@@ -74,6 +74,55 @@ static void __nvram_set_checksum(void)
74 __nvram_write_byte(sum, ATARI_CKS_LOC + 1); 74 __nvram_write_byte(sum, ATARI_CKS_LOC + 1);
75} 75}
76 76
77static ssize_t atari_nvram_read(char *buf, size_t count, loff_t *ppos)
78{
79 char *p = buf;
80 loff_t i;
81
82 spin_lock_irq(&rtc_lock);
83 if (!__nvram_check_checksum()) {
84 spin_unlock_irq(&rtc_lock);
85 return -EIO;
86 }
87 for (i = *ppos; count > 0 && i < NVRAM_BYTES; --count, ++i, ++p)
88 *p = __nvram_read_byte(i);
89 spin_unlock_irq(&rtc_lock);
90
91 *ppos = i;
92 return p - buf;
93}
94
95static ssize_t atari_nvram_write(char *buf, size_t count, loff_t *ppos)
96{
97 char *p = buf;
98 loff_t i;
99
100 spin_lock_irq(&rtc_lock);
101 if (!__nvram_check_checksum()) {
102 spin_unlock_irq(&rtc_lock);
103 return -EIO;
104 }
105 for (i = *ppos; count > 0 && i < NVRAM_BYTES; --count, ++i, ++p)
106 __nvram_write_byte(*p, i);
107 __nvram_set_checksum();
108 spin_unlock_irq(&rtc_lock);
109
110 *ppos = i;
111 return p - buf;
112}
113
114static ssize_t atari_nvram_get_size(void)
115{
116 return NVRAM_BYTES;
117}
118
119const struct nvram_ops arch_nvram_ops = {
120 .read = atari_nvram_read,
121 .write = atari_nvram_write,
122 .get_size = atari_nvram_get_size,
123};
124EXPORT_SYMBOL(arch_nvram_ops);
125
77#ifdef CONFIG_PROC_FS 126#ifdef CONFIG_PROC_FS
78static struct { 127static struct {
79 unsigned char val; 128 unsigned char val;