Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
u-boot-2015.04
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vesta
u-boot-2015.04
Commits
61973afc
Commit
61973afc
authored
14 years ago
by
Nobuhiro Iwamatsu
Browse files
Options
Downloads
Patches
Plain Diff
sh: Fix overflow problem in get_ticks
Signed-off-by:
Nobuhiro Iwamatsu
<
iwamatsu@nigauri.org
>
parent
8d1f6355
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arch/sh/lib/time.c
+18
-2
18 additions, 2 deletions
arch/sh/lib/time.c
with
18 additions
and
2 deletions
arch/sh/lib/time.c
+
18
−
2
View file @
61973afc
...
...
@@ -2,7 +2,7 @@
* (C) Copyright 2009
* Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
*
* (C) Copyright 2007-200
8
* (C) Copyright 2007-20
1
0
* Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
*
* (C) Copyright 2003
...
...
@@ -36,6 +36,8 @@
#define TMU_MAX_COUNTER (~0UL)
static
ulong
timer_freq
;
static
unsigned
long
last_tcnt
;
static
unsigned
long
long
overflow_ticks
;
static
inline
unsigned
long
long
tick_to_time
(
unsigned
long
long
tick
)
{
...
...
@@ -97,12 +99,26 @@ int timer_init (void)
tmu_timer_stop
(
0
);
tmu_timer_start
(
0
);
last_tcnt
=
0
;
overflow_ticks
=
0
;
return
0
;
}
unsigned
long
long
get_ticks
(
void
)
{
return
0
-
readl
(
TCNT0
);
unsigned
long
tcnt
=
0
-
readl
(
TCNT0
);
unsigned
long
ticks
;
if
(
last_tcnt
>
tcnt
)
{
/* overflow */
overflow_ticks
++
;
ticks
=
(
0xffffffff
-
last_tcnt
)
+
tcnt
;
}
else
{
ticks
=
tcnt
;
}
last_tcnt
=
tcnt
;
return
(
overflow_ticks
<<
32
)
|
tcnt
;
}
void
__udelay
(
unsigned
long
usec
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment