* [PATCH] watchdog: imx2_wdt: Fix ioctl() results
@ 2015-06-05 12:41 Markus Rinne
2015-06-05 13:14 ` Guenter Roeck
2015-06-05 14:14 ` Vladimir Zapolskiy
0 siblings, 2 replies; 4+ messages in thread
From: Markus Rinne @ 2015-06-05 12:41 UTC (permalink / raw)
To: wim; +Cc: linux-watchdog, linux-kernel
WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT returned the initial timeout and
not the one that was last set. Fix this by updating struct
watchdog_device member 'timeout'. This is how it's supposed to be done
according to Documentation/watchdog/watchdog-kernel-api.txt.
This is the test case I used:
#include <fcntl.h>
#include <linux/watchdog.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <assert.h>
#include <stdlib.h>
static const int TIMEOUT = 127;
int main(void)
{
int fd = open("/dev/watchdog", O_WRONLY);
if (fd == -1)
return EXIT_FAILURE;
int timeout = TIMEOUT;
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
assert(timeout == TIMEOUT);
close(fd);
return EXIT_SUCCESS;
}
Signed-off-by: Markus Rinne <markus.rinne@vincit.fi>
---
drivers/watchdog/imx2_wdt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
index 5e6d808..b636799 100644
--- a/drivers/watchdog/imx2_wdt.c
+++ b/drivers/watchdog/imx2_wdt.c
@@ -168,6 +168,7 @@ static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
regmap_update_bits(wdev->regmap, IMX2_WDT_WCR, IMX2_WDT_WCR_WT,
WDOG_SEC_TO_COUNT(new_timeout));
+ wdog->timeout = new_timeout;
return 0;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] watchdog: imx2_wdt: Fix ioctl() results
2015-06-05 12:41 [PATCH] watchdog: imx2_wdt: Fix ioctl() results Markus Rinne
@ 2015-06-05 13:14 ` Guenter Roeck
2015-06-05 14:14 ` Vladimir Zapolskiy
1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2015-06-05 13:14 UTC (permalink / raw)
To: Markus Rinne, wim; +Cc: linux-watchdog, linux-kernel
On 06/05/2015 05:41 AM, Markus Rinne wrote:
> WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT returned the initial timeout and
> not the one that was last set. Fix this by updating struct
> watchdog_device member 'timeout'. This is how it's supposed to be done
> according to Documentation/watchdog/watchdog-kernel-api.txt.
>
> This is the test case I used:
>
> #include <fcntl.h>
> #include <linux/watchdog.h>
> #include <sys/stat.h>
> #include <sys/types.h>
>
> #include <assert.h>
> #include <stdlib.h>
>
> static const int TIMEOUT = 127;
>
> int main(void)
> {
> int fd = open("/dev/watchdog", O_WRONLY);
> if (fd == -1)
> return EXIT_FAILURE;
>
> int timeout = TIMEOUT;
> ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
> assert(timeout == TIMEOUT);
>
> close(fd);
>
> return EXIT_SUCCESS;
> }
>
> Signed-off-by: Markus Rinne <markus.rinne@vincit.fi>
> ---
Good catch.
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] watchdog: imx2_wdt: Fix ioctl() results
2015-06-05 12:41 [PATCH] watchdog: imx2_wdt: Fix ioctl() results Markus Rinne
2015-06-05 13:14 ` Guenter Roeck
@ 2015-06-05 14:14 ` Vladimir Zapolskiy
2015-06-05 14:38 ` Guenter Roeck
1 sibling, 1 reply; 4+ messages in thread
From: Vladimir Zapolskiy @ 2015-06-05 14:14 UTC (permalink / raw)
To: Markus Rinne, wim; +Cc: linux-watchdog, linux-kernel, Michael Grzeschik
Hello Markus,
On 05.06.2015 15:41, Markus Rinne wrote:
> WDIOC_SETTIMEOUT and WDIOC_GETTIMEOUT returned the initial timeout and
> not the one that was last set. Fix this by updating struct
> watchdog_device member 'timeout'. This is how it's supposed to be done
> according to Documentation/watchdog/watchdog-kernel-api.txt.
>
> This is the test case I used:
>
> #include <fcntl.h>
> #include <linux/watchdog.h>
> #include <sys/stat.h>
> #include <sys/types.h>
>
> #include <assert.h>
> #include <stdlib.h>
>
> static const int TIMEOUT = 127;
>
> int main(void)
> {
> int fd = open("/dev/watchdog", O_WRONLY);
> if (fd == -1)
> return EXIT_FAILURE;
>
> int timeout = TIMEOUT;
> ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
> assert(timeout == TIMEOUT);
>
> close(fd);
>
> return EXIT_SUCCESS;
> }
>
> Signed-off-by: Markus Rinne <markus.rinne@vincit.fi>
> ---
> drivers/watchdog/imx2_wdt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index 5e6d808..b636799 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -168,6 +168,7 @@ static int imx2_wdt_set_timeout(struct watchdog_device *wdog,
>
> regmap_update_bits(wdev->regmap, IMX2_WDT_WCR, IMX2_WDT_WCR_WT,
> WDOG_SEC_TO_COUNT(new_timeout));
> + wdog->timeout = new_timeout;
> return 0;
> }
>
>
this change repeats the change sent by Michael Grzeschik one month ago
-- http://www.spinics.net/lists/linux-watchdog/msg06296.html
--
With best wishes,
Vladimir
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] watchdog: imx2_wdt: Fix ioctl() results
2015-06-05 14:14 ` Vladimir Zapolskiy
@ 2015-06-05 14:38 ` Guenter Roeck
0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2015-06-05 14:38 UTC (permalink / raw)
To: Vladimir Zapolskiy, Markus Rinne, wim
Cc: linux-watchdog, linux-kernel, Michael Grzeschik
On 06/05/2015 07:14 AM, Vladimir Zapolskiy wrote:
> Hello Markus,
>
[ ... ]
>
> this change repeats the change sent by Michael Grzeschik one month ago
> -- http://www.spinics.net/lists/linux-watchdog/msg06296.html
>
... and I even have it in my list of patches.
Thanks a lot for noticing.
Guenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-06-05 14:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-05 12:41 [PATCH] watchdog: imx2_wdt: Fix ioctl() results Markus Rinne
2015-06-05 13:14 ` Guenter Roeck
2015-06-05 14:14 ` Vladimir Zapolskiy
2015-06-05 14:38 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox