linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: mt6397: fix build on some 32bits platforms
@ 2015-05-14 20:51 Alexandre Belloni
  2015-05-14 21:55 ` [rtc-linux] " Alexandre Belloni
  2015-05-17 10:44 ` Eddie Huang
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandre Belloni @ 2015-05-14 20:51 UTC (permalink / raw)
  To: linux-arm-kernel

On some !ARM 32bits platforms, the following compilation error happens
because of the division on a 64bits value in mtk_rtc_read_time():

drivers/built-in.o: In function `mtk_rtc_read_time':
rtc-mt6397.c:(.text+0x265d13f): undefined reference to `__divdi3'
rtc-mt6397.c:(.text+0x265d150): undefined reference to `__moddi3'

Use div_s64() as done in rtc_time64_to_tm() to solve that.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-mt6397.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 8bed852e4961..c0090b698ff3 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -150,7 +150,7 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
 {
 	time64_t time;
 	struct mt6397_rtc *rtc = dev_get_drvdata(dev);
-	int sec, ret;
+	int days, sec, ret;
 
 	do {
 		ret = __mtk_rtc_read_time(rtc, tm, &sec);
@@ -171,7 +171,8 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
 	/* rtc_tm_to_time64 covert Gregorian date to seconds since
 	 * 01-01-1970 00:00:00, and this date is Thursday.
 	 */
-	tm->tm_wday = (time / 86400 + 4) % 7;
+	days = div_s64(time, 86400);
+	tm->tm_wday = (days + 4) % 7;
 
 exit:
 	return ret;
-- 
2.1.4

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

* [rtc-linux] [PATCH] rtc: mt6397: fix build on some 32bits platforms
  2015-05-14 20:51 [PATCH] rtc: mt6397: fix build on some 32bits platforms Alexandre Belloni
@ 2015-05-14 21:55 ` Alexandre Belloni
  2015-05-17 10:47   ` Eddie Huang
  2015-05-17 10:44 ` Eddie Huang
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2015-05-14 21:55 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 14/05/2015 at 22:51:18 +0200, Alexandre Belloni wrote :
> On some !ARM 32bits platforms, the following compilation error happens
> because of the division on a 64bits value in mtk_rtc_read_time():
> 
> drivers/built-in.o: In function `mtk_rtc_read_time':
> rtc-mt6397.c:(.text+0x265d13f): undefined reference to `__divdi3'
> rtc-mt6397.c:(.text+0x265d150): undefined reference to `__moddi3'
> 
> Use div_s64() as done in rtc_time64_to_tm() to solve that.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

I've already pushed that patch to rtc-next to repair the build for i386
and m68k but feel free to comment if you see anything wrong.

> ---
>  drivers/rtc/rtc-mt6397.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
> index 8bed852e4961..c0090b698ff3 100644
> --- a/drivers/rtc/rtc-mt6397.c
> +++ b/drivers/rtc/rtc-mt6397.c
> @@ -150,7 +150,7 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  {
>  	time64_t time;
>  	struct mt6397_rtc *rtc = dev_get_drvdata(dev);
> -	int sec, ret;
> +	int days, sec, ret;
>  
>  	do {
>  		ret = __mtk_rtc_read_time(rtc, tm, &sec);
> @@ -171,7 +171,8 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  	/* rtc_tm_to_time64 covert Gregorian date to seconds since
>  	 * 01-01-1970 00:00:00, and this date is Thursday.
>  	 */
> -	tm->tm_wday = (time / 86400 + 4) % 7;
> +	days = div_s64(time, 86400);
> +	tm->tm_wday = (days + 4) % 7;
>  
>  exit:
>  	return ret;
> -- 
> 2.1.4
> 
> -- 
> -- 
> You received this message because you are subscribed to "rtc-linux".
> Membership options at http://groups.google.com/group/rtc-linux .
> Please read http://groups.google.com/group/rtc-linux/web/checklist
> before submitting a driver.
> --- 
> You received this message because you are subscribed to the Google Groups "rtc-linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH] rtc: mt6397: fix build on some 32bits platforms
  2015-05-14 20:51 [PATCH] rtc: mt6397: fix build on some 32bits platforms Alexandre Belloni
  2015-05-14 21:55 ` [rtc-linux] " Alexandre Belloni
@ 2015-05-17 10:44 ` Eddie Huang
  1 sibling, 0 replies; 4+ messages in thread
From: Eddie Huang @ 2015-05-17 10:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2015-05-14 at 22:51 +0200, Alexandre Belloni wrote:
> On some !ARM 32bits platforms, the following compilation error happens
> because of the division on a 64bits value in mtk_rtc_read_time():
> 
> drivers/built-in.o: In function `mtk_rtc_read_time':
> rtc-mt6397.c:(.text+0x265d13f): undefined reference to `__divdi3'
> rtc-mt6397.c:(.text+0x265d150): undefined reference to `__moddi3'
> 
> Use div_s64() as done in rtc_time64_to_tm() to solve that.
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>  drivers/rtc/rtc-mt6397.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
> index 8bed852e4961..c0090b698ff3 100644
> --- a/drivers/rtc/rtc-mt6397.c
> +++ b/drivers/rtc/rtc-mt6397.c
> @@ -150,7 +150,7 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  {
>  	time64_t time;
>  	struct mt6397_rtc *rtc = dev_get_drvdata(dev);
> -	int sec, ret;
> +	int days, sec, ret;
>  
>  	do {
>  		ret = __mtk_rtc_read_time(rtc, tm, &sec);
> @@ -171,7 +171,8 @@ static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm)
>  	/* rtc_tm_to_time64 covert Gregorian date to seconds since
>  	 * 01-01-1970 00:00:00, and this date is Thursday.
>  	 */
> -	tm->tm_wday = (time / 86400 + 4) % 7;
> +	days = div_s64(time, 86400);
> +	tm->tm_wday = (days + 4) % 7;
>  
>  exit:
>  	return ret;

Acked-by: Eddie Huang <eddie.huang@mediatek.com>

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

* [rtc-linux] [PATCH] rtc: mt6397: fix build on some 32bits platforms
  2015-05-14 21:55 ` [rtc-linux] " Alexandre Belloni
@ 2015-05-17 10:47   ` Eddie Huang
  0 siblings, 0 replies; 4+ messages in thread
From: Eddie Huang @ 2015-05-17 10:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2015-05-14 at 23:55 +0200, Alexandre Belloni wrote:
> Hi,
> 
> On 14/05/2015 at 22:51:18 +0200, Alexandre Belloni wrote :
> > On some !ARM 32bits platforms, the following compilation error happens
> > because of the division on a 64bits value in mtk_rtc_read_time():
> > 
> > drivers/built-in.o: In function `mtk_rtc_read_time':
> > rtc-mt6397.c:(.text+0x265d13f): undefined reference to `__divdi3'
> > rtc-mt6397.c:(.text+0x265d150): undefined reference to `__moddi3'
> > 
> > Use div_s64() as done in rtc_time64_to_tm() to solve that.
> > 
> > Reported-by: kbuild test robot <fengguang.wu@intel.com>
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> 
> I've already pushed that patch to rtc-next to repair the build for i386
> and m68k but feel free to comment if you see anything wrong.

Sorry for late. I am in vacation and can't receive mail last week.
Thanks your effort to correct this.

Eddie

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

end of thread, other threads:[~2015-05-17 10:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-14 20:51 [PATCH] rtc: mt6397: fix build on some 32bits platforms Alexandre Belloni
2015-05-14 21:55 ` [rtc-linux] " Alexandre Belloni
2015-05-17 10:47   ` Eddie Huang
2015-05-17 10:44 ` Eddie Huang

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).