Skip to contentSkip to conversation

watchdog inconsistency.

PATCH Gleb Natapov 1 participant 1 message Nov 16, 2003 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hello,

There is inconsistency in fops->write() implementation in different watchdog drivers.
Some of them return number of bytes written while others return 1.

I think the correct implementation should always return number of bytes written (we examine all the buffer after all) otherwise "echo V > /dev/watchdog" doesn't work as expected (it doesn't stop watchdog).

The included patch fix watchdog drivers in linux-2.6.0-test9 (patch is trivial but isn't tested).

drivers/char/watchdog/i810-tco.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/i810-tco.c linux-2.6.0-test9.fix/drivers/char/watchdog/i810-tco.c
@@ -232,9 +232,8 @@
 
 		/* someone wrote to us, we should reload the timer */
 		tco_timer_reload ();
-		return 1;
 	}
-	return 0;
+	return len;
 }
 
 static int i810tco_ioctl (struct inode *inode, struct file *file,
drivers/char/watchdog/ib700wdt.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/ib700wdt.c linux-2.6.0-test9.fix/drivers/char/watchdog/ib700wdt.c
@@ -161,9 +161,8 @@
 			}
 		}
 		ibwdt_ping();
-		return 1;
 	}
-	return 0;
+	return count;
 }
 
 static int
drivers/char/watchdog/indydog.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/indydog.c linux-2.6.0-test9.fix/drivers/char/watchdog/indydog.c
@@ -113,9 +113,8 @@
 			}
 		}
 		indydog_ping();
-		return 1;
 	}
-	return 0;
+	return len;
 }
 
 static int indydog_ioctl(struct inode *inode, struct file *file,
drivers/char/watchdog/machzwd.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/machzwd.c linux-2.6.0-test9.fix/drivers/char/watchdog/machzwd.c
@@ -343,10 +343,9 @@
 		next_heartbeat = jiffies + ZF_USER_TIMEO;
 		dprintk("user ping at %ld\n", jiffies);
 		
-		return 1;
 	}
 
-	return 0;
+	return count;
 }
 
 static int zf_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
drivers/char/watchdog/mixcomwd.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/mixcomwd.c linux-2.6.0-test9.fix/drivers/char/watchdog/mixcomwd.c
@@ -156,9 +156,8 @@
 			}
 		}
 		mixcomwd_ping();
-		return 1;
 	}
-	return 0;
+	return len;
 }
 
 static int mixcomwd_ioctl(struct inode *inode, struct file *file,
drivers/char/watchdog/pcwd.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/pcwd.c linux-2.6.0-test9.fix/drivers/char/watchdog/pcwd.c
@@ -419,9 +419,8 @@
 			}
 		}
 		pcwd_send_heartbeat();
-		return 1;
 	}
-	return 0;
+	return len;
 }
 
 static int pcwd_open(struct inode *ino, struct file *filep)
drivers/char/watchdog/sa1100_wdt.c +1 -1
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/sa1100_wdt.c linux-2.6.0-test9.fix/drivers/char/watchdog/sa1100_wdt.c
@@ -106,7 +106,7 @@
 		OSMR3 = OSCR + pre_margin;
 	}
 
-	return len ? 1 : 0;
+	return len;
 }
 
 static struct watchdog_info ident = {
drivers/char/watchdog/softdog.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/softdog.c linux-2.6.0-test9.fix/drivers/char/watchdog/softdog.c
@@ -155,9 +155,8 @@
 			}
 		}
 		mod_timer(&watchdog_ticktock, jiffies+(soft_margin*HZ));
-		return 1;
 	}
-	return 0;
+	return len;
 }
 
 static int softdog_ioctl(struct inode *inode, struct file *file,
drivers/char/watchdog/wdt.c +1 -2
diff -urX /home/gleb/work/dontdiff linux-2.6.0-test9/drivers/char/watchdog/wdt.c linux-2.6.0-test9.fix/drivers/char/watchdog/wdt.c
@@ -265,9 +265,8 @@
 			}
 		}
 		wdt_ping();
-		return 1;
 	}
-	return 0;
+	return count;
 }
 
 /**

--
Gleb.