Skip to content

Commit 9a8f99f

Browse files
stettbergerozbenh
authored andcommitted
powerpc/rtas-rtc: remove sideeffects of printk_ratelimit
Don't use printk_ratelimit() as an additional condition for returning on an error. Because when the ratelimit is reached, printk_ratelimit will return 0 and e.g. in rtas_get_boot_time won't check for an error condition. Signed-off-by: Christian Dietrich <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 937c190 commit 9a8f99f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

arch/powerpc/kernel/rtas-rtc.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/init.h>
55
#include <linux/rtc.h>
66
#include <linux/delay.h>
7+
#include <linux/ratelimit.h>
78
#include <asm/prom.h>
89
#include <asm/rtas.h>
910
#include <asm/time.h>
@@ -29,9 +30,10 @@ unsigned long __init rtas_get_boot_time(void)
2930
}
3031
} while (wait_time && (get_tb() < max_wait_tb));
3132

32-
if (error != 0 && printk_ratelimit()) {
33-
printk(KERN_WARNING "error: reading the clock failed (%d)\n",
34-
error);
33+
if (error != 0) {
34+
printk_ratelimited(KERN_WARNING
35+
"error: reading the clock failed (%d)\n",
36+
error);
3537
return 0;
3638
}
3739

@@ -55,19 +57,21 @@ void rtas_get_rtc_time(struct rtc_time *rtc_tm)
5557

5658
wait_time = rtas_busy_delay_time(error);
5759
if (wait_time) {
58-
if (in_interrupt() && printk_ratelimit()) {
60+
if (in_interrupt()) {
5961
memset(rtc_tm, 0, sizeof(struct rtc_time));
60-
printk(KERN_WARNING "error: reading clock"
61-
" would delay interrupt\n");
62+
printk_ratelimited(KERN_WARNING
63+
"error: reading clock "
64+
"would delay interrupt\n");
6265
return; /* delay not allowed */
6366
}
6467
msleep(wait_time);
6568
}
6669
} while (wait_time && (get_tb() < max_wait_tb));
6770

68-
if (error != 0 && printk_ratelimit()) {
69-
printk(KERN_WARNING "error: reading the clock failed (%d)\n",
70-
error);
71+
if (error != 0) {
72+
printk_ratelimited(KERN_WARNING
73+
"error: reading the clock failed (%d)\n",
74+
error);
7175
return;
7276
}
7377

@@ -99,9 +103,10 @@ int rtas_set_rtc_time(struct rtc_time *tm)
99103
}
100104
} while (wait_time && (get_tb() < max_wait_tb));
101105

102-
if (error != 0 && printk_ratelimit())
103-
printk(KERN_WARNING "error: setting the clock failed (%d)\n",
104-
error);
106+
if (error != 0)
107+
printk_ratelimited(KERN_WARNING
108+
"error: setting the clock failed (%d)\n",
109+
error);
105110

106111
return 0;
107112
}

0 commit comments

Comments
 (0)