summaryrefslogtreecommitdiffstats
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
commit1278cf66cf4b1c3d30e311200b50c45457c92baa (patch)
tree78e061ec221158e7792f821c90ce3b9572a4bd71
parentcb8d8006d43f22924e000c730d18862587a824ff (diff)
nvram: Replace nvram_* function exports with static functions
Replace nvram_* functions with static functions in nvram.h. These will become wrappers for struct nvram_ops method calls. This patch effectively disables existing NVRAM functionality so as to allow the rest of the series to be bisected without build failures. That functionality is gradually re-implemented in subsequent patches. Replace the sole validate-checksum-and-read-byte sequence with a call to nvram_read() which will gain the same semantics in subsequent patches. Remove unused exports. 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>
-rw-r--r--arch/m68k/atari/nvram.c39
-rw-r--r--drivers/char/nvram.c27
-rw-r--r--drivers/scsi/atari_scsi.c8
-rw-r--r--include/linux/nvram.h32
4 files changed, 38 insertions, 68 deletions
diff --git a/arch/m68k/atari/nvram.c b/arch/m68k/atari/nvram.c
index a8c457e40b0b..1d767847ffa6 100644
--- a/arch/m68k/atari/nvram.c
+++ b/arch/m68k/atari/nvram.c
@@ -34,38 +34,17 @@
34 * periodic 11 min sync from kernel/time/ntp.c vs. this driver.) 34 * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
35 */ 35 */
36 36
37unsigned char __nvram_read_byte(int i) 37static unsigned char __nvram_read_byte(int i)
38{ 38{
39 return CMOS_READ(NVRAM_FIRST_BYTE + i); 39 return CMOS_READ(NVRAM_FIRST_BYTE + i);
40} 40}
41 41
42unsigned char nvram_read_byte(int i)
43{
44 unsigned long flags;
45 unsigned char c;
46
47 spin_lock_irqsave(&rtc_lock, flags);
48 c = __nvram_read_byte(i);
49 spin_unlock_irqrestore(&rtc_lock, flags);
50 return c;
51}
52EXPORT_SYMBOL(nvram_read_byte);
53
54/* This races nicely with trying to read with checksum checking */ 42/* This races nicely with trying to read with checksum checking */
55void __nvram_write_byte(unsigned char c, int i) 43static void __nvram_write_byte(unsigned char c, int i)
56{ 44{
57 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); 45 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
58} 46}
59 47
60void nvram_write_byte(unsigned char c, int i)
61{
62 unsigned long flags;
63
64 spin_lock_irqsave(&rtc_lock, flags);
65 __nvram_write_byte(c, i);
66 spin_unlock_irqrestore(&rtc_lock, flags);
67}
68
69/* On Ataris, the checksum is over all bytes except the checksum bytes 48/* On Ataris, the checksum is over all bytes except the checksum bytes
70 * themselves; these are at the very end. 49 * themselves; these are at the very end.
71 */ 50 */
@@ -73,7 +52,7 @@ void nvram_write_byte(unsigned char c, int i)
73#define ATARI_CKS_RANGE_END 47 52#define ATARI_CKS_RANGE_END 47
74#define ATARI_CKS_LOC 48 53#define ATARI_CKS_LOC 48
75 54
76int __nvram_check_checksum(void) 55static int __nvram_check_checksum(void)
77{ 56{
78 int i; 57 int i;
79 unsigned char sum = 0; 58 unsigned char sum = 0;
@@ -84,18 +63,6 @@ int __nvram_check_checksum(void)
84 (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); 63 (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff));
85} 64}
86 65
87int nvram_check_checksum(void)
88{
89 unsigned long flags;
90 int rv;
91
92 spin_lock_irqsave(&rtc_lock, flags);
93 rv = __nvram_check_checksum();
94 spin_unlock_irqrestore(&rtc_lock, flags);
95 return rv;
96}
97EXPORT_SYMBOL(nvram_check_checksum);
98
99static void __nvram_set_checksum(void) 66static void __nvram_set_checksum(void)
100{ 67{
101 int i; 68 int i;
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
index c660cff9faf4..c98775bfd896 100644
--- a/drivers/char/nvram.c
+++ b/drivers/char/nvram.c
@@ -74,13 +74,12 @@ static int nvram_open_mode; /* special open modes */
74 * periodic 11 min sync from kernel/time/ntp.c vs. this driver.) 74 * periodic 11 min sync from kernel/time/ntp.c vs. this driver.)
75 */ 75 */
76 76
77unsigned char __nvram_read_byte(int i) 77static unsigned char __nvram_read_byte(int i)
78{ 78{
79 return CMOS_READ(NVRAM_FIRST_BYTE + i); 79 return CMOS_READ(NVRAM_FIRST_BYTE + i);
80} 80}
81EXPORT_SYMBOL(__nvram_read_byte);
82 81
83unsigned char nvram_read_byte(int i) 82static unsigned char pc_nvram_read_byte(int i)
84{ 83{
85 unsigned long flags; 84 unsigned long flags;
86 unsigned char c; 85 unsigned char c;
@@ -90,16 +89,14 @@ unsigned char nvram_read_byte(int i)
90 spin_unlock_irqrestore(&rtc_lock, flags); 89 spin_unlock_irqrestore(&rtc_lock, flags);
91 return c; 90 return c;
92} 91}
93EXPORT_SYMBOL(nvram_read_byte);
94 92
95/* This races nicely with trying to read with checksum checking (nvram_read) */ 93/* This races nicely with trying to read with checksum checking (nvram_read) */
96void __nvram_write_byte(unsigned char c, int i) 94static void __nvram_write_byte(unsigned char c, int i)
97{ 95{
98 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); 96 CMOS_WRITE(c, NVRAM_FIRST_BYTE + i);
99} 97}
100EXPORT_SYMBOL(__nvram_write_byte);
101 98
102void nvram_write_byte(unsigned char c, int i) 99static void pc_nvram_write_byte(unsigned char c, int i)
103{ 100{
104 unsigned long flags; 101 unsigned long flags;
105 102
@@ -107,14 +104,13 @@ void nvram_write_byte(unsigned char c, int i)
107 __nvram_write_byte(c, i); 104 __nvram_write_byte(c, i);
108 spin_unlock_irqrestore(&rtc_lock, flags); 105 spin_unlock_irqrestore(&rtc_lock, flags);
109} 106}
110EXPORT_SYMBOL(nvram_write_byte);
111 107
112/* On PCs, the checksum is built only over bytes 2..31 */ 108/* On PCs, the checksum is built only over bytes 2..31 */
113#define PC_CKS_RANGE_START 2 109#define PC_CKS_RANGE_START 2
114#define PC_CKS_RANGE_END 31 110#define PC_CKS_RANGE_END 31
115#define PC_CKS_LOC 32 111#define PC_CKS_LOC 32
116 112
117int __nvram_check_checksum(void) 113static int __nvram_check_checksum(void)
118{ 114{
119 int i; 115 int i;
120 unsigned short sum = 0; 116 unsigned short sum = 0;
@@ -126,19 +122,6 @@ int __nvram_check_checksum(void)
126 __nvram_read_byte(PC_CKS_LOC+1); 122 __nvram_read_byte(PC_CKS_LOC+1);
127 return (sum & 0xffff) == expect; 123 return (sum & 0xffff) == expect;
128} 124}
129EXPORT_SYMBOL(__nvram_check_checksum);
130
131int nvram_check_checksum(void)
132{
133 unsigned long flags;
134 int rv;
135
136 spin_lock_irqsave(&rtc_lock, flags);
137 rv = __nvram_check_checksum();
138 spin_unlock_irqrestore(&rtc_lock, flags);
139 return rv;
140}
141EXPORT_SYMBOL(nvram_check_checksum);
142 125
143static void __nvram_set_checksum(void) 126static void __nvram_set_checksum(void)
144{ 127{
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index 78b43200c99e..e809493d0d06 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -759,13 +759,15 @@ static int __init atari_scsi_probe(struct platform_device *pdev)
759 atari_scsi_template.this_id = setup_hostid & 7; 759 atari_scsi_template.this_id = setup_hostid & 7;
760 } else if (IS_REACHABLE(CONFIG_NVRAM)) { 760 } else if (IS_REACHABLE(CONFIG_NVRAM)) {
761 /* Test if a host id is set in the NVRam */ 761 /* Test if a host id is set in the NVRam */
762 if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) { 762 if (ATARIHW_PRESENT(TT_CLK)) {
763 unsigned char b = nvram_read_byte(16); 763 unsigned char b;
764 loff_t offset = 16;
765 ssize_t count = nvram_read(&b, 1, &offset);
764 766
765 /* Arbitration enabled? (for TOS) 767 /* Arbitration enabled? (for TOS)
766 * If yes, use configured host ID 768 * If yes, use configured host ID
767 */ 769 */
768 if (b & 0x80) 770 if ((count == 1) && (b & 0x80))
769 atari_scsi_template.this_id = b & 7; 771 atari_scsi_template.this_id = b & 7;
770 } 772 }
771 } 773 }
diff --git a/include/linux/nvram.h b/include/linux/nvram.h
index 28bfb9ab94ca..eb5b52a9a747 100644
--- a/include/linux/nvram.h
+++ b/include/linux/nvram.h
@@ -2,13 +2,31 @@
2#ifndef _LINUX_NVRAM_H 2#ifndef _LINUX_NVRAM_H
3#define _LINUX_NVRAM_H 3#define _LINUX_NVRAM_H
4 4
5#include <linux/errno.h>
5#include <uapi/linux/nvram.h> 6#include <uapi/linux/nvram.h>
6 7
7/* __foo is foo without grabbing the rtc_lock - get it yourself */ 8static inline ssize_t nvram_get_size(void)
8extern unsigned char __nvram_read_byte(int i); 9{
9extern unsigned char nvram_read_byte(int i); 10 return -ENODEV;
10extern void __nvram_write_byte(unsigned char c, int i); 11}
11extern void nvram_write_byte(unsigned char c, int i); 12
12extern int __nvram_check_checksum(void); 13static inline unsigned char nvram_read_byte(int addr)
13extern int nvram_check_checksum(void); 14{
15 return 0xFF;
16}
17
18static inline void nvram_write_byte(unsigned char val, int addr)
19{
20}
21
22static inline ssize_t nvram_read(char *buf, size_t count, loff_t *ppos)
23{
24 return -ENODEV;
25}
26
27static inline ssize_t nvram_write(char *buf, size_t count, loff_t *ppos)
28{
29 return -ENODEV;
30}
31
14#endif /* _LINUX_NVRAM_H */ 32#endif /* _LINUX_NVRAM_H */