Skip to contentSkip to conversation

Char: ds1286, eliminate busy waiting

PATCH In review Jiri Slaby 2 participants 3 messages Jul 25, 2008 – Jul 29, 2008

Subsystems (2)
lore
Share & tools
lore

Jiri Slaby

author
#0 lore raw

PATCH 1/1 Char: ds1286, eliminate busy waiting

ds1286_get_time(); is not called from atomic context, sleep for 20 ms is better choice than a (home-made) busy waiting for such a situation.

---
 drivers/char/ds1286.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/char/ds1286.c +1 -3
index fb58493..5329d48 100644
@@ -443,7 +443,6 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
 {
 	unsigned char save_control;
 	unsigned long flags;
-	unsigned long uip_watchdog = jiffies;
 
 	/*
 	 * read RTC once any update in progress is done. The update
@@ -456,8 +455,7 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
 	 */
 
 	if (ds1286_is_updating() != 0)
-		while (time_before(jiffies, uip_watchdog + 2*HZ/100))
-			barrier();
+		msleep(20);
 
 	/*
 	 * Only the values that we read from the RTC are set. We leave
Signature · 1 line
1.5.6.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jiri Slaby

ds1286_get_time(); is not called from atomic context, sleep for 20 ms is better choice than a (home-made) busy waiting for such a situation.

Looks ok to me I guess. Though I don't really think it matters ...

The same condition also appears in drivers/char/rtc.c and maybe a few others. Rtc.c has been copies and modified several times.

Ralf

author
#2 lore raw

Ralf Baechle napsal(a):

Quoted 6 lines · Jiri Slaby
Quoted 3 lines

ds1286_get_time(); is not called from atomic context, sleep for 20 ms is better choice than a (home-made) busy waiting for such a situation.

Looks ok to me I guess. Though I don't really think it matters ...

I think RT people has different opinion ;).

Quoted 2 lines

The same condition also appears in drivers/char/rtc.c and maybe a few others. Rtc.c has been copies and modified several times.

In rtc.c there is something completely different:

        while (rtc_is_updating() != 0 &&
               time_before(jiffies, uip_watchdog + 2*HZ/100))
                cpu_relax();

It's a conditional busy-waiting. It reads the rtc status after each busy cycle while in the ds1286 there was

        if (ds1286_is_updating() != 0)
                while (time_before(jiffies, uip_watchdog + 2*HZ/100))
                        barrier();