hpwdt: Introduce SECS_TO_TICKS() macro
PATCH 1/3 hpwdt: Introduce SECS_TO_TICKS() macro
Define a macro to convert from seconds to timer ticks.
Signed-off-by dann frazier <[email protected]>
--- drivers/watchdog/hpwdt.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/watchdog/hpwdt.c +4 -2
@@ -49,6 +49,8 @@#define ROM_SIZE 0x10000#define HPWDT_VERSION "1.1.1" +#define SECS_TO_TICKS (secs) ((secs) * 1000 / 128) +struct bios32_service_dir {u32 signature;u32 entry_point;
@@ -420,7 +422,7 @@ static int __devinit detect_cru_service(void)*/ static void hpwdt_start (void ) { - reload = (soft_margin *1000 ) /128 ; + reload =SECS_TO_TICKS (soft_margin);iowrite16 (reload, hpwdt_timer_reg);iowrite16 (0x85 , hpwdt_timer_con); }
@@ -453,7 +455,7 @@ static int hpwdt_change_timer(int new_margin)printk (KERN_DEBUG "hpwdt: New timer passed in is %d seconds.\n" , new_margin); - reload = (soft_margin *1000 ) /128 ; + reload =SECS_TO_TICKS (soft_margin);return 0 ; }
Signature · 1 line
1.7.1
PATCH 2/3 hpwdt: allow full range of timer values supported by hardware
The hpwdt timer is a 16 bit value with 128ms resolution. Let applications use this entire range.
Signed-off-by dann frazier <[email protected]>
--- drivers/watchdog/hpwdt.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/watchdog/hpwdt.c +3 -2
@@ -50,6 +50,8 @@#define HPWDT_VERSION "1.1.1"#define SECS_TO_TICKS (secs) ((secs) * 1000 / 128) +#define TICKS_TO_SECS (ticks) ((ticks) * 128 / 1000) +#define HPWDT_MAX_TIMER TICKS_TO_SECS(65535)struct bios32_service_dir {u32 signature;
@@ -443,8 +445,7 @@ static void hpwdt_ping(void)static int hpwdt_change_timer (int new_margin) { -/* Arbitrary, can't find the card's limits */ -if (new_margin <5 || new_margin >600 ) { +if (new_margin <1 || new_margin >HPWDT_MAX_TIMER ) {printk (KERN_WARNING "hpwdt: New value passed in is invalid: %d seconds.\n" , new_margin);
Signature · 1 line
1.7.1
PATCH 3/3 hpwdt: implement WDIOC_GETTIMELEFT
In reply to dann frazierLet applications check the amount of time left before the watchdog will fire.
Signed-off-by dann frazier <[email protected]>
--- drivers/watchdog/hpwdt.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/watchdog/hpwdt.c +9 -0
@@ -443,6 +443,11 @@ static void hpwdt_ping(void)iowrite16 (reload, hpwdt_timer_reg); } +static int hpwdt_time_left (void ) +{ +return TICKS_TO_SECS (ioread16 (hpwdt_timer_reg)); +} +static int hpwdt_change_timer (int new_margin) {if (new_margin <1 || new_margin >HPWDT_MAX_TIMER ) {
@@ -583,6 +588,10 @@ static long hpwdt_ioctl(struct file *file, unsigned int cmd, ret =put_user (0 , p);break ; +case WDIOC_GETTIMELEFT : + ret =put_user (hpwdt_time_left (), p); +break ; +case WDIOC_KEEPALIVE :hpwdt_ping (); ret =0 ;
Signature · 1 line
1.7.1