Re: [PATCH v2 5/7] drivers: watchdog: sb_wdog: Fix 32bit linking problems

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

 



On Wed, Jun 19, 2013 at 03:45:07PM +0800, Yousong Zhou wrote:

> I am not quite sure on this. I just digged this[1] out and thought that Linus
>  may not be happy about the operation `tmp_user_dog/1000000`.
> 
> Correct me if I am wrong, please.
> 
> [1] http://lwn.net/Articles/456241/

Well, Linus' posting is about a division by a power of two.  Doing that
by do_div() is not terribly smart.  Now, reading some manuals it turned
out that the register (like most registers on Sibyte SOCs) is 64 bit
but only the lower 23 bits are being used; bits 23..64 always read as
zero.

So the best fix is to truncate the value down to 32 bit then use the plain
old `/' division.

  Ralf

Signed-off-by: Ralf Baechle <ralf@xxxxxxxxxxxxxx>

 drivers/watchdog/sb_wdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/sb_wdog.c b/drivers/watchdog/sb_wdog.c
index 25c7a3f..ea5d84a 100644
--- a/drivers/watchdog/sb_wdog.c
+++ b/drivers/watchdog/sb_wdog.c
@@ -208,7 +208,7 @@ static long sbwdog_ioctl(struct file *file, unsigned int cmd,
 		 * get the remaining count from the ... count register
 		 * which is 1*8 before the config register
 		 */
-		ret = put_user(__raw_readq(user_dog - 8) / 1000000, p);
+		ret = put_user((u32)__raw_readq(user_dog - 8) / 1000000, p);
 		break;
 	}
 	return ret;


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux