static int riowd_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { static struct watchdog_info info = { WDIOF_SETTIMEOUT, 0, "Natl. Semiconductor PC97317" }; void __user *argp = (void __user *)arg; unsigned int options; int new_margin; switch (cmd) { case WDIOC_GETSUPPORT: if (copy_to_user(argp, &info, sizeof(info))) return -EFAULT; break; case WDIOC_GETSTATUS: case WDIOC_GETBOOTSTATUS: if (put_user(0, (int __user *)argp)) return -EFAULT; break; case WDIOC_KEEPALIVE: riowd_pingtimer(); break; case WDIOC_SETOPTIONS: if (copy_from_user(&options, argp, sizeof(options))) return -EFAULT; if (options & WDIOS_DISABLECARD) riowd_stoptimer(); else if (options & WDIOS_ENABLECARD) riowd_starttimer(); else return -EINVAL; break; case WDIOC_SETTIMEOUT: if (get_user(new_margin, (int __user *)argp)) return -EFAULT; if ((new_margin < 60) || (new_margin > (255 * 60))) return -EINVAL; riowd_timeout = (new_margin + 59) / 60; riowd_pingtimer(); /* Fall */ case WDIOC_GETTIMEOUT: return put_user(riowd_timeout * 60, (int __user *)argp); default: return -EINVAL; }; return 0; }
static ssize_t riowd_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { if (count) { riowd_pingtimer(); return 1; } return 0; }
static ssize_t riowd_write(struct file *file, const char *buf, size_t count, loff_t *ppos) { if (ppos != &file->f_pos) return -ESPIPE; if (count) { riowd_pingtimer(); return 1; } return 0; }