Skip to contentSkip to conversation

watchdog: Add support for the WM8350 watchdog

PATCH In review Mark Brown 3 participants 4 messages Oct 20, 2008 – Oct 24, 2008

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 watchdog: Add support for the WM8350 watchdog

This driver implements support for the watchdog functionality provided by the Wolfson Microelectronics WM8350, a multi-function audio and power management subsystem intended for use in embedded systems. It is based on a driver originally written by Graeme Gregory, though it has been extensively modified since then.

Use of a GPIO to kick the watchdog is not yet supported.

---

This driver is unchanged since the last submission but since the WM8350 core support has now been merged into mainline with registration of the watchdog device already present this patch should now be directly mergable.

 drivers/watchdog/Kconfig      |    7 +
 drivers/watchdog/Makefile     |    1 +
 drivers/watchdog/wm8350_wdt.c |  316 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 324 insertions(+), 0 deletions(-)
 create mode 100644 drivers/watchdog/wm8350_wdt.c
drivers/watchdog/Kconfig +7 -0
index 1a22fe7..b93e334 100644
@@ -55,6 +55,13 @@ config SOFT_WATCHDOG
 	  To compile this driver as a module, choose M here: the
 	  module will be called softdog.
 
+config WM8350_WATCHDOG
+	tristate "WM8350 watchdog"
+	depends on MFD_WM8350
+	help
+	  Support for the watchdog in the WM8350 AudioPlus PMIC.  When
+	  the watchdog triggers the system will be reset.
+
 # ALPHA Architecture
 
 # ARM Architecture
drivers/watchdog/Makefile +1 -0
index e352bbb..c3b8db3 100644
@@ -134,3 +134,4 @@ obj-$(CONFIG_WATCHDOG_CP1XXX)		+= cpwd.o
 
 # Architecture Independant
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
+obj-$(CONFIG_WM8350_WATCHDOG) += wm8350_wdt.o
drivers/watchdog/wm8350_wdt.c new file +316 -0

316 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#1 lore raw

Hi Mark,

Quoted 9 lines

This driver implements support for the watchdog functionality provided by the Wolfson Microelectronics WM8350, a multi-function audio and power management subsystem intended for use in embedded systems. It is based on a driver originally written by Graeme Gregory, though it has been extensively modified since then.

Use of a GPIO to kick the watchdog is not yet supported.

Reviewing this one. Will get back on this driver tomorrow.

Kind regards,
Wim.

#2 lore raw
In reply to Mark Brown

drivers/watchdog/wm8350_wdt.c line 113

Quoted 2 lines · Mark Brown
drivers/watchdog/wm8350_wdt.c new file +2 -0
+	if (!wm8350) {
+		printk(KERN_CRIT "FNORD\n");

Gah, obviously this printk() shouldn't be there - I'll submit an updated version once you've had time to review this. Sorry about that.

#3 lore raw
In reply to Mark Brown

Hi Marc,

Finally a stable ADSL line again. I just finished reviewing your driver:

drivers/watchdog/wm8350_wdt.c line 113

Quoted 7 lines
drivers/watchdog/wm8350_wdt.c new file +7 -0
+static int wm8350_wdt_open(struct inode *inode, struct file *file)
+{
+	struct wm8350 *wm8350 = get_wm8350();
+	int ret;
+
+	if (!wm8350) {
+		printk(KERN_CRIT "FNORD\n");

:-) as you pointed out this should be removed.

drivers/watchdog/wm8350_wdt.c line 133

Quoted 8 lines
drivers/watchdog/wm8350_wdt.c new file +8 -0
+static int wm8350_wdt_release(struct inode *inode, struct file *file)
+{
+	struct wm8350 *wm8350 = get_wm8350();
+
+	if (wm8350_wdt_expect_close)
+		wm8350_wdt_stop(wm8350);
+	else
+		dev_warn(wm8350->dev, "Watchdog device closed uncleanly\n");

you should ping the watchdog if you don't stop it.

drivers/watchdog/wm8350_wdt.c line 174

Quoted 2 lines
drivers/watchdog/wm8350_wdt.c new file +2 -0
+static int wm8350_wdt_ioctl(struct inode *inode, struct file *file,
+			    unsigned int cmd, unsigned long arg)

we use the unlocked_ioctl call in watchdog drivers now. So this should be:
static long wm8350_wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)

drivers/watchdog/wm8350_wdt.c line 187

Quoted 13 lines
drivers/watchdog/wm8350_wdt.c new file +13 -0
+{
+	struct wm8350 *wm8350 = get_wm8350();
+	int ret = -ENOTTY, time, i;
+	void __user *argp = (void __user *)arg;
+	int __user *p = argp;
+	u16 reg;
+
+	switch (cmd) {
+	case WDIOC_GETSUPPORT:
+		ret = copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
+		break;
+
+	case WDIOC_GETSTATUS:

Bootstatus is a mandatory ioctl according to the API. So just add:
case WDIOC_GETBOOTSTATUS:

drivers/watchdog/wm8350_wdt.c line 258

Quoted 5 lines
drivers/watchdog/wm8350_wdt.c new file +5 -0
+static const struct file_operations wm8350_wdt_fops = {
+	.owner = THIS_MODULE,
+	.llseek = no_llseek,
+	.write = wm8350_wdt_write,
+	.ioctl = wm8350_wdt_ioctl,

and for the unlocked_ioctl call this needs to be:

	.unlocked_ioctl = wm8350_wdt_ioctl,

For the rest: seems OK to me.

Kind regards,
Wim.