aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorEric Lammerts <eric@lammerts.org>2009-02-03 17:45:56 -0500
committerWim Van Sebroeck <wim@iguana.be>2009-03-25 04:57:15 -0400
commit63bad1452e9087e6f130316c005eb38a8758a267 (patch)
tree7a6583ed8f9b09535f4efbbc28c2b7b4afe285f9 /drivers/watchdog
parent9626dd75c57360666f4cdcb660c1672ee9f952e8 (diff)
[WATCHDOG] w83697ug: add error checking
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>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/w83697ug_wdt.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/watchdog/w83697ug_wdt.c b/drivers/watchdog/w83697ug_wdt.c
index ada8ad82d993..6972c0a1e4d6 100644
--- a/drivers/watchdog/w83697ug_wdt.c
+++ b/drivers/watchdog/w83697ug_wdt.c
@@ -79,7 +79,7 @@ MODULE_PARM_DESC(nowayout,
79 (same as EFER) */ 79 (same as EFER) */
80#define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */ 80#define WDT_EFDR (WDT_EFIR+1) /* Extended Function Data Register */
81 81
82static void w83697ug_select_wd_register(void) 82static int w83697ug_select_wd_register(void)
83{ 83{
84 unsigned char c; 84 unsigned char c;
85 unsigned char version; 85 unsigned char version;
@@ -102,7 +102,7 @@ static void w83697ug_select_wd_register(void)
102 102
103 } else { 103 } else {
104 printk(KERN_ERR PFX "No W83697UG/UF could be found\n"); 104 printk(KERN_ERR PFX "No W83697UG/UF could be found\n");
105 return; 105 return -ENODEV;
106 } 106 }
107 107
108 outb_p(0x07, WDT_EFER); /* point to logical device number reg */ 108 outb_p(0x07, WDT_EFER); /* point to logical device number reg */
@@ -110,6 +110,8 @@ static void w83697ug_select_wd_register(void)
110 outb_p(0x30, WDT_EFER); /* select CR30 */ 110 outb_p(0x30, WDT_EFER); /* select CR30 */
111 c = inb_p(WDT_EFDR); 111 c = inb_p(WDT_EFDR);
112 outb_p(c || 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */ 112 outb_p(c || 0x01, WDT_EFDR); /* set bit 0 to activate GPIO2 */
113
114 return 0;
113} 115}
114 116
115static void w83697ug_unselect_wd_register(void) 117static void w83697ug_unselect_wd_register(void)
@@ -117,11 +119,14 @@ static void w83697ug_unselect_wd_register(void)
117 outb_p(0xAA, WDT_EFER); /* Leave extended function mode */ 119 outb_p(0xAA, WDT_EFER); /* Leave extended function mode */
118} 120}
119 121
120static void w83697ug_init(void) 122static int w83697ug_init(void)
121{ 123{
124 int ret;
122 unsigned char t; 125 unsigned char t;
123 126
124 w83697ug_select_wd_register(); 127 ret = w83697ug_select_wd_register();
128 if (ret != 0)
129 return ret;
125 130
126 outb_p(0xF6, WDT_EFER); /* Select CRF6 */ 131 outb_p(0xF6, WDT_EFER); /* Select CRF6 */
127 t = inb_p(WDT_EFDR); /* read CRF6 */ 132 t = inb_p(WDT_EFDR); /* read CRF6 */
@@ -137,13 +142,15 @@ static void w83697ug_init(void)
137 outb_p(t, WDT_EFDR); /* Write back to CRF5 */ 142 outb_p(t, WDT_EFDR); /* Write back to CRF5 */
138 143
139 w83697ug_unselect_wd_register(); 144 w83697ug_unselect_wd_register();
145 return 0;
140} 146}
141 147
142static void wdt_ctrl(int timeout) 148static void wdt_ctrl(int timeout)
143{ 149{
144 spin_lock(&io_lock); 150 spin_lock(&io_lock);
145 151
146 w83697ug_select_wd_register(); 152 if (w83697ug_select_wd_register() < 0)
153 return;
147 154
148 outb_p(0xF4, WDT_EFER); /* Select CRF4 */ 155 outb_p(0xF4, WDT_EFER); /* Select CRF4 */
149 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */ 156 outb_p(timeout, WDT_EFDR); /* Write Timeout counter to CRF4 */
@@ -347,7 +354,9 @@ static int __init wdt_init(void)
347 goto out; 354 goto out;
348 } 355 }
349 356
350 w83697ug_init(); 357 ret = w83697ug_init();
358 if (ret != 0)
359 goto unreg_regions;
351 360
352 ret = register_reboot_notifier(&wdt_notifier); 361 ret = register_reboot_notifier(&wdt_notifier);
353 if (ret != 0) { 362 if (ret != 0) {