All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Yousong Zhou <yszhou4tech@gmail.com>
Cc: Markos Chandras <markos.chandras@imgtec.com>,
	linux-mips@linux-mips.org, sibyte-users@bitmover.com,
	Wim Van Sebroeck <wim@iguana.be>
Subject: Re: [PATCH v2 5/7] drivers: watchdog: sb_wdog: Fix 32bit linking problems
Date: Wed, 19 Jun 2013 10:55:09 +0200	[thread overview]
Message-ID: <20130619085509.GA11687@linux-mips.org> (raw)
In-Reply-To: <CAECwjAhzJUO4GFmnu3jX8e-UEj2wiVrB8xA3Hu_0iSaf1L1v5w@mail.gmail.com>

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@linux-mips.org>

 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;

  parent reply	other threads:[~2013-06-19  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18 14:00 [PATCH v2 5/7] drivers: watchdog: sb_wdog: Fix 32bit linking problems Markos Chandras
2013-06-18 14:00 ` Markos Chandras
2013-06-18 14:14 ` Ralf Baechle
2013-06-19  7:45   ` Yousong Zhou
2013-06-19  7:48     ` Yousong Zhou
2013-06-19  8:55     ` Ralf Baechle [this message]
2013-06-27 19:59   ` Wim Van Sebroeck
2013-06-27 20:09   ` Wim Van Sebroeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130619085509.GA11687@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=linux-mips@linux-mips.org \
    --cc=markos.chandras@imgtec.com \
    --cc=sibyte-users@bitmover.com \
    --cc=wim@iguana.be \
    --cc=yszhou4tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.