提交 f5273fa3 编写于 作者: A Alexander Clouter 提交者: Nicolas Pitre

[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: NAlexander Clouter <alex@digriz.org.uk>
Signed-off-by: NNicolas Pitre <nico@cam.org>
上级 f1f54657
...@@ -117,6 +117,7 @@ static struct platform_device ts78xx_ts_rtc_device = { ...@@ -117,6 +117,7 @@ static struct platform_device ts78xx_ts_rtc_device = {
*/ */
static int ts78xx_ts_rtc_load(void) static int ts78xx_ts_rtc_load(void)
{ {
int rc;
unsigned char tmp_rtc0, tmp_rtc1; unsigned char tmp_rtc0, tmp_rtc1;
tmp_rtc0 = ts78xx_ts_rtc_readbyte(126); tmp_rtc0 = ts78xx_ts_rtc_readbyte(126);
...@@ -130,16 +131,18 @@ static int ts78xx_ts_rtc_load(void) ...@@ -130,16 +131,18 @@ static int ts78xx_ts_rtc_load(void)
&& ts78xx_ts_rtc_readbyte(126) == 0x00) { && ts78xx_ts_rtc_readbyte(126) == 0x00) {
ts78xx_ts_rtc_writebyte(tmp_rtc0, 126); ts78xx_ts_rtc_writebyte(tmp_rtc0, 126);
ts78xx_ts_rtc_writebyte(tmp_rtc1, 127); ts78xx_ts_rtc_writebyte(tmp_rtc1, 127);
if (ts78xx_fpga.supports.ts_rtc.init == 0) { if (ts78xx_fpga.supports.ts_rtc.init == 0) {
ts78xx_fpga.supports.ts_rtc.init = 1; rc = platform_device_register(&ts78xx_ts_rtc_device);
platform_device_register(&ts78xx_ts_rtc_device); if (!rc)
ts78xx_fpga.supports.ts_rtc.init = 1;
} else } else
platform_device_add(&ts78xx_ts_rtc_device); rc = platform_device_add(&ts78xx_ts_rtc_device);
return 0;
return rc;
} }
} }
ts78xx_fpga.supports.ts_rtc.present = 0;
return -ENODEV; return -ENODEV;
}; };
...@@ -150,7 +153,7 @@ static void ts78xx_ts_rtc_unload(void) ...@@ -150,7 +153,7 @@ static void ts78xx_ts_rtc_unload(void)
#else #else
static int ts78xx_ts_rtc_load(void) static int ts78xx_ts_rtc_load(void)
{ {
return 0; return -ENODEV;
} }
static void ts78xx_ts_rtc_unload(void) static void ts78xx_ts_rtc_unload(void)
...@@ -184,8 +187,11 @@ static int ts78xx_fpga_load_devices(void) ...@@ -184,8 +187,11 @@ static int ts78xx_fpga_load_devices(void)
if (ts78xx_fpga.supports.ts_rtc.present == 1) { if (ts78xx_fpga.supports.ts_rtc.present == 1) {
tmp = ts78xx_ts_rtc_load(); tmp = ts78xx_ts_rtc_load();
if (tmp) if (tmp) {
printk(KERN_INFO "TS-78xx RTC not detected or enabled\n"); printk(KERN_INFO "TS-78xx RTC"
" not detected or enabled\n");
ts78xx_fpga.supports.ts_rtc.present = 0;
}
ret |= tmp; ret |= tmp;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册