[PATCH] rtc: tps6586x: Fix error in RTC tick calculations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Lowell Dennis <ldennis@xxxxxxxxxx>

In the TPS6586x PMU/PMIC RTC support code, 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.

Reviewed-by: Lowell Dennis <ldennis@xxxxxxxxxx>
Tested-by: Lowell Dennis <ldennis@xxxxxxxxxx>
Reviewed-by: Jonathan Mayo <jmayo@xxxxxxxxxx>
Reviewed-by: Peter Zu <pzu@xxxxxxxxxx>
Reviewed-by: Bharat Nihalani <bnihalani@xxxxxxxxxx>
Signed-off-by: Robert Morell <rmorell@xxxxxxxxxx>
---

Although this driver isn't Tegra-specific, it only seems to exist in the
linux-tegra branches, so I'm sending this to the linux-tegra mailing list to
be applied.

Thanks.

 drivers/rtc/rtc-tps6586x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

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;
 	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;
-- 
1.7.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux