提交 75a23850 编写于 作者: F Finn Thain 提交者: Geert Uytterhoeven

m68k/mac: Fix compiler warning in via_read_time()

The algorithm described in the comment compares two reads from the RTC but
the code actually reads once and compares the result to an uninitialized
value. This causes the compiler to warn, "last_result maybe used
uninitialized". Make the code match the comment, fix the warning and
perhaps improve reliability. Tested on a Quadra 700.
Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: NGeert Uytterhoeven <geert@linux-m68k.org>
上级 d996e9dc
...@@ -304,35 +304,41 @@ static void via_write_pram(int offset, __u8 data) ...@@ -304,35 +304,41 @@ static void via_write_pram(int offset, __u8 data)
static long via_read_time(void) static long via_read_time(void)
{ {
union { union {
__u8 cdata[4]; __u8 cdata[4];
long idata; long idata;
} result, last_result; } result, last_result;
int ct; int count = 1;
via_pram_command(0x81, &last_result.cdata[3]);
via_pram_command(0x85, &last_result.cdata[2]);
via_pram_command(0x89, &last_result.cdata[1]);
via_pram_command(0x8D, &last_result.cdata[0]);
/* /*
* The NetBSD guys say to loop until you get the same reading * The NetBSD guys say to loop until you get the same reading
* twice in a row. * twice in a row.
*/ */
ct = 0; while (1) {
do {
if (++ct > 10) {
printk("via_read_time: couldn't get valid time, "
"last read = 0x%08lx and 0x%08lx\n",
last_result.idata, result.idata);
break;
}
last_result.idata = result.idata;
result.idata = 0;
via_pram_command(0x81, &result.cdata[3]); via_pram_command(0x81, &result.cdata[3]);
via_pram_command(0x85, &result.cdata[2]); via_pram_command(0x85, &result.cdata[2]);
via_pram_command(0x89, &result.cdata[1]); via_pram_command(0x89, &result.cdata[1]);
via_pram_command(0x8D, &result.cdata[0]); via_pram_command(0x8D, &result.cdata[0]);
} while (result.idata != last_result.idata);
return result.idata - RTC_OFFSET; if (result.idata == last_result.idata)
return result.idata - RTC_OFFSET;
if (++count > 10)
break;
last_result.idata = result.idata;
}
pr_err("via_read_time: failed to read a stable value; "
"got 0x%08lx then 0x%08lx\n",
last_result.idata, result.idata);
return 0;
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册