#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/timer.h>
+#include <linux/completion.h>
+#include <linux/jiffies.h>
#include <asm/io.h>
#include <asm/uaccess.h>
/* some device data */
static struct {
- struct semaphore stop;
+ struct completion stop;
volatile int running;
struct timer_list timer;
volatile int queue;
}
else {
/* ticks doesn't matter anyway */
- up(&cpu5wdt_device.stop);
+ complete(&cpu5wdt_device.stop);
}
}
if ( test_and_set_bit(0, &cpu5wdt_device.inuse) )
return -EBUSY;
- return 0;
+ return nonseekable_open(inode, file);
}
static int cpu5wdt_release(struct inode *inode, struct file *file)
static int cpu5wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
+ void __user *argp = (void __user *)arg;
unsigned int value;
static struct watchdog_info ident =
{
case WDIOC_GETSTATUS:
value = inb(port + CPU5WDT_STATUS_REG);
value = (value >> 2) & 1;
- if ( copy_to_user((int *)arg, (int *)&value, sizeof(int)) )
+ if ( copy_to_user(argp, &value, sizeof(int)) )
return -EFAULT;
break;
case WDIOC_GETSUPPORT:
- if ( copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)) )
+ if ( copy_to_user(argp, &ident, sizeof(ident)) )
return -EFAULT;
break;
case WDIOC_SETOPTIONS:
- if ( copy_from_user(&value, (int *)arg, sizeof(int)) )
+ if ( copy_from_user(&value, argp, sizeof(int)) )
return -EFAULT;
switch(value) {
case WDIOS_ENABLECARD:
return 0;
}
-static ssize_t cpu5wdt_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+static ssize_t cpu5wdt_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
{
if ( !count )
return -EIO;
static struct file_operations cpu5wdt_fops = {
.owner = THIS_MODULE,
+ .llseek = no_llseek,
.ioctl = cpu5wdt_ioctl,
.open = cpu5wdt_open,
.write = cpu5wdt_write,
if ( !val )
printk(KERN_INFO PFX "sorry, was my fault\n");
- init_MUTEX_LOCKED(&cpu5wdt_device.stop);
+ init_completion(&cpu5wdt_device.stop);
cpu5wdt_device.queue = 0;
clear_bit(0, &cpu5wdt_device.inuse);
{
if ( cpu5wdt_device.queue ) {
cpu5wdt_device.queue = 0;
- down(&cpu5wdt_device.stop);
+ wait_for_completion(&cpu5wdt_device.stop);
}
misc_deregister(&cpu5wdt_misc);