linux/drivers/watchdog
Doug Anderson 178624403c watchdog: s3c2410_wdt: Handle rounding a little better for timeout
The existing watchdog timeout worked OK but didn't deal with
rounding in an ideal way when dividing out all of its clocks.

Specifically if you had a timeout of 32 seconds and an input clock of
66666666, you'd end up setting a timeout of 31.9998 seconds and
reporting a timeout of 31 seconds.

Specifically DBG printouts showed:
  s3c2410wdt_set_heartbeat: count=16666656, timeout=32, freq=520833
  s3c2410wdt_set_heartbeat: timeout=32, divisor=255, count=16666656 (0000ff4f)
and the final timeout reported to the user was:
  ((count / divisor) * divisor) / freq
  (0xff4f * 255) / 520833 = 31 (truncated from 31.9998)
the technically "correct" value is:
  (0xff4f * 255) / (66666666.0 / 128) = 31.9998

By using "DIV_ROUND_UP" we can be a little more correct.
  s3c2410wdt_set_heartbeat: count=16666688, timeout=32, freq=520834
  s3c2410wdt_set_heartbeat: timeout=32, divisor=255, count=16666688 (0000ff50)
and the final timeout reported to the user:
  (0xff50 * 255) / 520834 = 32
the technically "correct" value is:
  (0xff50 * 255) / (66666666.0 / 128) = 32.0003

We'll use a DIV_ROUND_UP to solve this, generally erroring on the side
of reporting shorter values to the user and setting the watchdog to
slightly longer than requested:
* Round input frequency up to assume watchdog is counting faster.
* Round divisions by divisor up to give us extra time.

At the same time we can avoid a for loop by just doing the right math.

Signed-off-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
2014-01-28 21:23:20 +01:00
..
acquirewdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
advantechwdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
alim1535_wdt.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
alim7101_wdt.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
ar7_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
at32ap700x_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
at91rm9200_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
at91sam9_wdt.c watchdog: add timeout-sec property binding 2013-03-01 12:53:45 +01:00
at91sam9_wdt.h ARM: at91: make watchdog drivers soc independent 2011-11-28 22:50:39 +08:00
ath79_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
bcm47xx_wdt.c watchdog: bcm47xx_wdt.c: add hard timer 2013-03-01 12:47:31 +01:00
bcm63xx_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
bcm2835_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
bcm_kona_wdt.c watchdog: bcm281xx: Debugfs support 2014-01-28 21:17:53 +01:00
bfin_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
booke_wdt.c powerpc/watchdog: Don't enable interrupt on PPC64 BookE 2013-06-25 18:14:45 -05:00
coh901327_wdt.c watchdog: coh901327: devicetree support 2013-05-31 11:25:52 +02:00
cpu5wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
cpwd.c watchdog: cpwd: use platform_{get,set}_drvdata() 2013-07-11 21:07:24 +02:00
da9052_wdt.c watchdog: da9052: use platform_{get,set}_drvdata() 2013-07-11 21:08:01 +02:00
da9055_wdt.c watchdog: da9055: use platform_{get,set}_drvdata() 2013-07-11 21:08:27 +02:00
davinci_wdt.c watchdog: davinci: reuse driver for keystone arch 2014-01-28 21:20:05 +01:00
dw_wdt.c watchdog: dw: Enable OF support for DW watchdog timer 2013-11-17 19:38:26 +01:00
ep93xx_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
eurotechwdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
f71808e_wdt.c watchdog: f71808e_wdt: Add support for Jetway JNF99 motherboard 2012-07-23 12:46:38 +02:00
gef_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
geodewdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
gpio_wdt.c watchdog: GPIO-controlled watchdog 2014-01-28 21:21:02 +01:00
hpwdt.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
i6300esb.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
ib700wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
ibmasr.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
ie6xx_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
imx2_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
indydog.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
intel_scu_watchdog.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
intel_scu_watchdog.h watchdog: Use pr_<fmt> and pr_<level> 2012-03-27 19:59:26 +02:00
iop_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
it87_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
it8712f_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
iTCO_vendor_support.c watchdog: Convert iTCO_wdt driver to mfd model 2012-05-09 17:20:09 +02:00
iTCO_vendor.h watchdog: Convert iTCO_wdt driver to mfd model 2012-05-09 17:20:09 +02:00
iTCO_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
ixp4xx_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
jz4740_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
Kconfig watchdog: GPIO-controlled watchdog 2014-01-28 21:21:02 +01:00
kempld_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
ks8695_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
lantiq_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
m54xx_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
machzwd.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
Makefile watchdog: GPIO-controlled watchdog 2014-01-28 21:21:02 +01:00
max63xx_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
mena21_wdt.c watchdog: New watchdog driver for MEN A21 watchdogs 2013-07-11 22:19:05 +02:00
mixcomwd.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
moxart_wdt.c watchdog: Add MOXA ART watchdog driver 2013-11-17 19:34:49 +01:00
mpc8xxx_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
mtx-1_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
mv64x60_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
nuc900_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
nv_tco.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
nv_tco.h watchdog: Add TCO support for nVidia chipsets 2011-01-12 13:51:23 +00:00
octeon-wdt-main.c watchdog: nowayout is bool 2012-03-27 20:06:02 +02:00
octeon-wdt-nmi.S WATCHDOG: Add watchdog driver for OCTEON SOCs 2010-08-05 13:26:22 +01:00
of_xilinx_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
omap_wdt.c watchdog: omap_wdt: raw read and write endian fix 2013-11-17 19:42:38 +01:00
omap_wdt.h watchdog: cleanup spaces before tabs 2011-03-15 16:02:27 +00:00
orion_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
pc87413_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
pcwd_pci.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
pcwd_usb.c Watchdog: pcwd_usb: remove CONFIG_USB_DEBUG usage 2014-01-07 16:15:39 -08:00
pcwd.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
pika_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
pnx833x_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
pnx4008_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
rc32434_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
rdc321x_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
retu_wdt.c watchdog: introduce retu_wdt driver 2013-03-01 12:31:14 +01:00
riowd.c watchdog: riowd: use platform_{get,set}_drvdata() 2013-07-11 20:57:25 +02:00
rt2880_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
s3c2410_wdt.c watchdog: s3c2410_wdt: Handle rounding a little better for timeout 2014-01-28 21:23:20 +01:00
sa1100_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sb_wdog.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sbc60xxwdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sbc7240_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sbc8360.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sbc_epx_c3.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sbc_fitpc2_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sc520_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
sc1200wdt.c sc1200_wdt: Fix oops 2013-12-10 08:48:15 +01:00
sch311x_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
scx200_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
shwdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
sirfsoc_wdt.c watchdog: sirf: don't depend on dummy value of CLOCK_TICK_RATE 2013-11-17 19:42:31 +01:00
smsc37b787_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
softdog.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
sp805_wdt.c watchdog: sp805_wdt: Remove unnecessary amba_set_drvdata() 2013-11-17 19:37:31 +01:00
sp5100_tco.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
sp5100_tco.h watchdog: sp5100_tco: Set the AcpiMmioSel bitmask value to 1 instead of 2 2013-03-22 23:21:55 +01:00
stmp3xxx_rtc_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
sunxi_wdt.c watchdog: Remove redundant of_match_ptr 2013-11-17 19:37:11 +01:00
ts72xx_wdt.c watchdog: ts72xx_wdt: Propagate return value from timeout_to_regval 2013-11-17 19:38:02 +01:00
twl4030_wdt.c watchdog: twl4030: Remove redundant platform_set_drvdata() 2013-07-11 21:10:13 +02:00
txx9wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
ux500_wdt.c watchdog: Drop unnecessary include of miscdevice.h 2013-12-10 08:48:09 +01:00
via_wdt.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
w83627hf_wdt.c watchdog: w83627hf: Use helper functions to access superio registers 2013-11-18 21:34:19 +01:00
w83697hf_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
w83697ug_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
w83877f_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
w83977f_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
wafer5823wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
watchdog_core.c watchdog: core: Make dt "timeout-sec" property work on drivers w/out min/max 2014-01-28 19:07:56 +01:00
watchdog_core.h watchdog: Add multiple device support 2012-05-30 07:54:25 +02:00
watchdog_dev.c watchdog: core: don't try to stop device if not running 2013-07-11 21:14:39 +02:00
wd501p.h
wdrtas.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
wdt285.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
wdt977.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
wdt_pci.c watchdog: remove DEFINE_PCI_DEVICE_TABLE macro 2014-01-28 19:07:07 +01:00
wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00
wm831x_wdt.c watchdog: use dev_get_platdata() 2013-11-17 19:34:20 +01:00
wm8350_wdt.c watchdog: remove use of __devexit 2012-11-28 12:00:24 -08:00
xen_wdt.c watchdog: Get rid of MODULE_ALIAS_MISCDEV statements 2013-11-17 19:38:13 +01:00