Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146686
b: refs/heads/master
c: 5b644c7
h: refs/heads/master
v: v3
  • Loading branch information
Magnus Damm authored and Paul Mundt committed Apr 28, 2009
1 parent 387aa65 commit 1b24ea2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c2e0090c668fc99f5be65fd9907da781cb6a2ef5
refs/heads/master: 5b644c7a218702668d7b610994e7dcbc3d4705d3
13 changes: 9 additions & 4 deletions trunk/drivers/clocksource/sh_cmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,21 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
int *has_wrapped)
{
unsigned long v1, v2, v3;
int o1, o2;

o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;

/* Make sure the timer value is stable. Stolen from acpi_pm.c */
do {
o2 = o1;
v1 = sh_cmt_read(p, CMCNT);
v2 = sh_cmt_read(p, CMCNT);
v3 = sh_cmt_read(p, CMCNT);
} while (unlikely((v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1)
|| (v3 > v1 && v3 < v2)));
o1 = sh_cmt_read(p, CMCSR) & p->overflow_bit;
} while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3)
|| (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));

*has_wrapped = sh_cmt_read(p, CMCSR) & p->overflow_bit;
*has_wrapped = o1;
return v2;
}

Expand Down Expand Up @@ -394,7 +399,7 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
raw = sh_cmt_get_counter(p, &has_wrapped);

if (unlikely(has_wrapped))
raw = p->match_value;
raw += p->match_value;
spin_unlock_irqrestore(&p->lock, flags);

return value + raw;
Expand Down

0 comments on commit 1b24ea2

Please sign in to comment.