Skip to content

Commit

Permalink
[WATCHDOG] w83697ug: add error checking
Browse files Browse the repository at this point in the history
I noticed the W83697UG driver tries to register a watchdog even though
it already noticed the chip isn't there.

WDT driver for the Winbond(TM) W83697UG/UF Super I/O chip initialising.
w83697ug/uf WDT: No W83697UG/UF could be found
w83697ug/uf WDT: Watchdog already running. Resetting timeout to 60 sec
w83697ug/uf WDT: cannot register miscdev on minor=130 (err=-16)

Patch propagates the error back to wdt_init().

Signed-off-by: Eric Lammerts <eric@lammerts.org>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
  • Loading branch information
Eric Lammerts authored and Wim Van Sebroeck committed Mar 25, 2009
1 parent 9626dd7 commit 63bad14
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions drivers/watchdog/w83697ug_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ MODULE_PARM_DESC(nowayout,
(same as EFER) */
#define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */

static void w83697ug_select_wd_register(void)
static int w83697ug_select_wd_register(void)
{
unsigned char c;
unsigned char version;
Expand All @@ -102,26 +102,31 @@ static void w83697ug_select_wd_register(void)

} else {
printk(KERN_ERR PFX "No W83697UG/UF could be found\n");
return;
return -ENODEV;
}

outb_p(0x07, WDT_EFER); /* point to logical device number reg */
outb_p(0x08, WDT_EFDR); /* select logical device 8 (GPIO2) */
outb_p(0x30, WDT_EFER); /* select CR30 */
c = inb_p(WDT_EFDR);
outb_p(c || 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */

return 0;
}

static void w83697ug_unselect_wd_register(void)
{
outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
}

static void w83697ug_init(void)
static int w83697ug_init(void)
{
int ret;
unsigned char t;

w83697ug_select_wd_register();
ret = w83697ug_select_wd_register();
if (ret != 0)
return ret;

outb_p(0xF6, WDT_EFER); /* Select CRF6 */
t = inb_p(WDT_EFDR); /* read CRF6 */
Expand All @@ -137,13 +142,15 @@ static void w83697ug_init(void)
outb_p(t, WDT_EFDR); /* Write back to CRF5 */

w83697ug_unselect_wd_register();
return 0;
}

static void wdt_ctrl(int timeout)
{
spin_lock(&io_lock);

w83697ug_select_wd_register();
if (w83697ug_select_wd_register() < 0)
return;

outb_p(0xF4, WDT_EFER); /* Select CRF4 */
outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */
Expand Down Expand Up @@ -347,7 +354,9 @@ static int __init wdt_init(void)
goto out;
}

w83697ug_init();
ret = w83697ug_init();
if (ret != 0)
goto unreg_regions;

ret = register_reboot_notifier(&wdt_notifier);
if (ret != 0) {
Expand Down

0 comments on commit 63bad14

Please sign in to comment.