Patchwork [2/2] rtc: tps6586x: fix error in tick calculations.

login
register
mail settings
Submitter Varun Wadekar
Date Jan. 25, 2011, 4:53 a.m.
Message ID <4D3E574B.4070700@nvidia.com>
Download mbox | patch
Permalink /patch/80316/
State New
Headers show

Comments

Varun Wadekar - Jan. 25, 2011, 4:53 a.m.
This patch depends on patch 1:

----
    rtc: tps6586x: fix error in tick calculations.

    when converting from seconds to ticks using a shift
    operator, the most significant bits were being lost
    due to seconds being a 32-bit value and ticks being
    a 64-bit value. a hard cast was added to avoid this
    loss.

    Signed-off-by: Lowell Dennis <ldennis@nvidia.com>

     buff[2] = (ticks >> 16) & 0xff;
@@ -148,7 +148,7 @@ static int tps6586x_rtc_set_alarm(struct device
*dev, struct rtc_wkalrm *alrm)
     }

     seconds -= rtc->epoch_start;
-    ticks = (seconds << 10) & 0xffffff;
+    ticks = (unsigned long long)seconds << 10;

     buff[0] = (ticks >> 16) & 0xff;
     buff[1] = (ticks >> 8) & 0xff;

nvpublic

Patch

diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index 9ab93cb..ca6138b 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -95,7 +95,7 @@  static int tps6586x_rtc_set_time(struct device *dev,
struct rtc_time *tm)

     seconds -= rtc->epoch_start;

-    ticks = seconds << 10;
+    ticks = (unsigned long long)seconds << 10;
     buff[0] = (ticks >> 32) & 0xff;
     buff[1] = (ticks >> 24) & 0xff;