linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt
@ 2012-01-26 19:24 Dmitry Artamonow
  2012-01-27 21:08 ` Timur Tabi
  2012-01-27 21:34 ` Timur Tabi
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Artamonow @ 2012-01-26 19:24 UTC (permalink / raw)
  To: linux-watchdog; +Cc: Timur Tabi, Kumar Gala, Wim Van Sebroeck, linux-kernel

Commit dcfb748422 ([WATCHDOG] fix book E watchdog to take
WDIOC_SETTIMEOUT arg in seconds) fixed SETTIMEOUT ioctl
to use seconds as a parameter instead of some hardware-specific
"period", but missed to apply similar changes to GETTIMEOUT,
so it still returns "period" value. Let's fix it!
Also, while at it, make SETTIMEOUT ioctl return real timeout
value as it should do according to the documentation.

Signed-off-by: Dmitry Artamonow <mad_soft@inbox.ru>
---
 drivers/watchdog/booke_wdt.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

NOTE: 
I'm no longer have a hardware, so it haven't been tested actually. 
It would be nice if anyone could test it on some BookE platform.

diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index 337265b..7c0fdfc 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -198,9 +198,13 @@ static long booke_wdt_ioctl(struct file *file,
 		booke_wdt_period = tmp;
 #endif
 		booke_wdt_set();
-		return 0;
+		/* Fall */
 	case WDIOC_GETTIMEOUT:
+#ifdef	CONFIG_FSL_BOOKE
+		return put_user(period_to_sec(booke_wdt_period), p);
+#else
 		return put_user(booke_wdt_period, p);
+#endif
 	default:
 		return -ENOTTY;
 	}
-- 
1.7.5.4


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

* Re: [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt
  2012-01-26 19:24 [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt Dmitry Artamonow
@ 2012-01-27 21:08 ` Timur Tabi
  2012-01-27 21:22   ` Timur Tabi
  2012-01-27 21:34 ` Timur Tabi
  1 sibling, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2012-01-27 21:08 UTC (permalink / raw)
  To: Dmitry Artamonow
  Cc: linux-watchdog, Kumar Gala, Wim Van Sebroeck, linux-kernel

Dmitry Artamonow wrote:
> +#ifdef	CONFIG_FSL_BOOKE
> +		return put_user(period_to_sec(booke_wdt_period), p);
> +#else

period_to_sec() returns an unsigned long long, which means that the driver
will write 8 bytes instead of 4 to user space.  You need to use a
temporary u32, just like WDIOC_SETTIMEOUT:

		if (get_user(tmp, p))
			return -EFAULT;


-- 
Timur Tabi
Linux kernel developer at Freescale


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

* Re: [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt
  2012-01-27 21:08 ` Timur Tabi
@ 2012-01-27 21:22   ` Timur Tabi
  0 siblings, 0 replies; 4+ messages in thread
From: Timur Tabi @ 2012-01-27 21:22 UTC (permalink / raw)
  To: Dmitry Artamonow
  Cc: linux-watchdog, Kumar Gala, Wim Van Sebroeck, linux-kernel

Timur Tabi wrote:
> Dmitry Artamonow wrote:
>> +#ifdef	CONFIG_FSL_BOOKE
>> +		return put_user(period_to_sec(booke_wdt_period), p);
>> +#else
> 
> period_to_sec() returns an unsigned long long, which means that the driver
> will write 8 bytes instead of 4 to user space. 

Ok, I take that back.  put_user() uses the size of the pointer, which
makes more sense anyway.


-- 
Timur Tabi
Linux kernel developer at Freescale


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

* Re: [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt
  2012-01-26 19:24 [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt Dmitry Artamonow
  2012-01-27 21:08 ` Timur Tabi
@ 2012-01-27 21:34 ` Timur Tabi
  1 sibling, 0 replies; 4+ messages in thread
From: Timur Tabi @ 2012-01-27 21:34 UTC (permalink / raw)
  To: Dmitry Artamonow
  Cc: linux-watchdog, Kumar Gala, Wim Van Sebroeck, linux-kernel

Dmitry Artamonow wrote:
> Commit dcfb748422 ([WATCHDOG] fix book E watchdog to take
> WDIOC_SETTIMEOUT arg in seconds) fixed SETTIMEOUT ioctl
> to use seconds as a parameter instead of some hardware-specific
> "period", but missed to apply similar changes to GETTIMEOUT,
> so it still returns "period" value. Let's fix it!
> Also, while at it, make SETTIMEOUT ioctl return real timeout
> value as it should do according to the documentation.
> 
> Signed-off-by: Dmitry Artamonow <mad_soft@inbox.ru>
> ---

Acked-by: Timur Tabi <timur@freescale.com>

I don't have an easy way to test the watchdog ioctls.

-- 
Timur Tabi
Linux kernel developer at Freescale


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

end of thread, other threads:[~2012-01-27 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-26 19:24 [PATCH] watchdog: fix GETTIMEOUT ioctl in booke_wdt Dmitry Artamonow
2012-01-27 21:08 ` Timur Tabi
2012-01-27 21:22   ` Timur Tabi
2012-01-27 21:34 ` Timur Tabi

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