xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/time: cleanup
@ 2014-02-28 16:42 Jan Beulich
  2014-02-28 16:46 ` Keir Fraser
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2014-02-28 16:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

Eliminate effectively unused variables mistakenly left in place by
9539:08aede767c63 ("Rename update_dom_time() to
update_vcpu_system_time()").

Drop the pointless casts.

Use SECONDS() instead of open coding it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -921,15 +921,15 @@ int cpu_frequency_change(u64 freq)
 void do_settime(unsigned long secs, unsigned long nsecs, u64 system_time_base)
 {
     u64 x;
-    u32 y, _wc_sec, _wc_nsec;
+    u32 y;
     struct domain *d;
 
-    x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base;
+    x = SECONDS(secs) + (u64)nsecs - system_time_base;
     y = do_div(x, 1000000000);
 
     spin_lock(&wc_lock);
-    wc_sec  = _wc_sec  = (u32)x;
-    wc_nsec = _wc_nsec = (u32)y;
+    wc_sec  = x;
+    wc_nsec = y;
     spin_unlock(&wc_lock);
 
     rcu_read_lock(&domlist_read_lock);
@@ -1548,8 +1548,8 @@ unsigned long get_localtime(struct domai
 /* Return microsecs after 00:00:00 localtime, 1 January, 1970. */
 uint64_t get_localtime_us(struct domain *d)
 {
-    return ((wc_sec + d->time_offset_seconds) * 1000000000ULL
-        + wc_nsec + NOW()) / 1000UL;
+    return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW())
+           / 1000UL;
 }
 
 unsigned long get_sec(void)
@@ -1651,7 +1651,7 @@ struct tm wallclock_time(void)
     if ( !wc_sec )
         return (struct tm) { 0 };
 
-    seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec;
+    seconds = NOW() + SECONDS(wc_sec) + wc_nsec;
     do_div(seconds, 1000000000);
     return gmtime(seconds);
 }




[-- Attachment #2: x86-time-simplify.patch --]
[-- Type: text/plain, Size: 1655 bytes --]

x86/time: cleanup

Eliminate effectively unused variables mistakenly left in place by
9539:08aede767c63 ("Rename update_dom_time() to
update_vcpu_system_time()").

Drop the pointless casts.

Use SECONDS() instead of open coding it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -921,15 +921,15 @@ int cpu_frequency_change(u64 freq)
 void do_settime(unsigned long secs, unsigned long nsecs, u64 system_time_base)
 {
     u64 x;
-    u32 y, _wc_sec, _wc_nsec;
+    u32 y;
     struct domain *d;
 
-    x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base;
+    x = SECONDS(secs) + (u64)nsecs - system_time_base;
     y = do_div(x, 1000000000);
 
     spin_lock(&wc_lock);
-    wc_sec  = _wc_sec  = (u32)x;
-    wc_nsec = _wc_nsec = (u32)y;
+    wc_sec  = x;
+    wc_nsec = y;
     spin_unlock(&wc_lock);
 
     rcu_read_lock(&domlist_read_lock);
@@ -1548,8 +1548,8 @@ unsigned long get_localtime(struct domai
 /* Return microsecs after 00:00:00 localtime, 1 January, 1970. */
 uint64_t get_localtime_us(struct domain *d)
 {
-    return ((wc_sec + d->time_offset_seconds) * 1000000000ULL
-        + wc_nsec + NOW()) / 1000UL;
+    return (SECONDS(wc_sec + d->time_offset_seconds) + wc_nsec + NOW())
+           / 1000UL;
 }
 
 unsigned long get_sec(void)
@@ -1651,7 +1651,7 @@ struct tm wallclock_time(void)
     if ( !wc_sec )
         return (struct tm) { 0 };
 
-    seconds = NOW() + (wc_sec * 1000000000ull) + wc_nsec;
+    seconds = NOW() + SECONDS(wc_sec) + wc_nsec;
     do_div(seconds, 1000000000);
     return gmtime(seconds);
 }

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-28 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 16:42 [PATCH] x86/time: cleanup Jan Beulich
2014-02-28 16:46 ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).