aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-orion5x/ts78xx-setup.c
diff options
context:
space:
mode:
authorAlexander Clouter <alex@digriz.org.uk>2009-02-23 17:37:36 -0500
committerNicolas Pitre <nico@cam.org>2009-02-24 23:59:33 -0500
commitf5273fa3102fa4c25819f3034b8834c37d3e62a3 (patch)
tree8b58f9413702bbd91e85c90398e35f113435a286 /arch/arm/mach-orion5x/ts78xx-setup.c
parentf1f5465782a96201798ef1e8167ed3ffaefdb30d (diff)
[ARM] orion5x: ts78xx make more bulletproof the RTC load/unload code
Added checks to the platform_device_(register|add) calls so that if a device failed to load it would then not later be unloaded; also added the hooks so that it would not try to unload when the RTC driver support is compiled out. Signed-off-by: Alexander Clouter <alex@digriz.org.uk> Signed-off-by: Nicolas Pitre <nico@cam.org>
Diffstat (limited to 'arch/arm/mach-orion5x/ts78xx-setup.c')
-rw-r--r--arch/arm/mach-orion5x/ts78xx-setup.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c
index baa25d0fd5c9..778b11860ee6 100644
--- a/arch/arm/mach-orion5x/ts78xx-setup.c
+++ b/arch/arm/mach-orion5x/ts78xx-setup.c
@@ -117,6 +117,7 @@ static struct platform_device ts78xx_ts_rtc_device = {
117 */ 117 */
118static int ts78xx_ts_rtc_load(void) 118static int ts78xx_ts_rtc_load(void)
119{ 119{
120 int rc;
120 unsigned char tmp_rtc0, tmp_rtc1; 121 unsigned char tmp_rtc0, tmp_rtc1;
121 122
122 tmp_rtc0 = ts78xx_ts_rtc_readbyte(126); 123 tmp_rtc0 = ts78xx_ts_rtc_readbyte(126);
@@ -130,16 +131,18 @@ static int ts78xx_ts_rtc_load(void)
130 && ts78xx_ts_rtc_readbyte(126) == 0x00) { 131 && ts78xx_ts_rtc_readbyte(126) == 0x00) {
131 ts78xx_ts_rtc_writebyte(tmp_rtc0, 126); 132 ts78xx_ts_rtc_writebyte(tmp_rtc0, 126);
132 ts78xx_ts_rtc_writebyte(tmp_rtc1, 127); 133 ts78xx_ts_rtc_writebyte(tmp_rtc1, 127);
134
133 if (ts78xx_fpga.supports.ts_rtc.init == 0) { 135 if (ts78xx_fpga.supports.ts_rtc.init == 0) {
134 ts78xx_fpga.supports.ts_rtc.init = 1; 136 rc = platform_device_register(&ts78xx_ts_rtc_device);
135 platform_device_register(&ts78xx_ts_rtc_device); 137 if (!rc)
138 ts78xx_fpga.supports.ts_rtc.init = 1;
136 } else 139 } else
137 platform_device_add(&ts78xx_ts_rtc_device); 140 rc = platform_device_add(&ts78xx_ts_rtc_device);
138 return 0; 141
142 return rc;
139 } 143 }
140 } 144 }
141 145
142 ts78xx_fpga.supports.ts_rtc.present = 0;
143 return -ENODEV; 146 return -ENODEV;
144}; 147};
145 148
@@ -150,7 +153,7 @@ static void ts78xx_ts_rtc_unload(void)
150#else 153#else
151static int ts78xx_ts_rtc_load(void) 154static int ts78xx_ts_rtc_load(void)
152{ 155{
153 return 0; 156 return -ENODEV;
154} 157}
155 158
156static void ts78xx_ts_rtc_unload(void) 159static void ts78xx_ts_rtc_unload(void)
@@ -184,8 +187,11 @@ static int ts78xx_fpga_load_devices(void)
184 187
185 if (ts78xx_fpga.supports.ts_rtc.present == 1) { 188 if (ts78xx_fpga.supports.ts_rtc.present == 1) {
186 tmp = ts78xx_ts_rtc_load(); 189 tmp = ts78xx_ts_rtc_load();
187 if (tmp) 190 if (tmp) {
188 printk(KERN_INFO "TS-78xx RTC not detected or enabled\n"); 191 printk(KERN_INFO "TS-78xx RTC"
192 " not detected or enabled\n");
193 ts78xx_fpga.supports.ts_rtc.present = 0;
194 }
189 ret |= tmp; 195 ret |= tmp;
190 } 196 }
191 197