fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / char / genrtc.c
index d110713..23b25ad 100644 (file)
@@ -43,7 +43,6 @@
 #define RTC_VERSION    "1.07"
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/miscdevice.h>
 #include <linux/fcntl.h>
@@ -83,7 +82,7 @@ static unsigned char days_in_mo[] =
 static int irq_active;
 
 #ifdef CONFIG_GEN_RTC_X
-struct work_struct genrtc_task;
+static struct work_struct genrtc_task;
 static struct timer_list timer_task;
 
 static unsigned int oldsecs;
@@ -95,7 +94,7 @@ static void gen_rtc_timer(unsigned long data);
 static volatile int stask_active;              /* schedule_work */
 static volatile int ttask_active;              /* timer_task */
 static int stop_rtc_timers;                    /* don't requeue tasks */
-static spinlock_t gen_rtc_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(gen_rtc_lock);
 
 static void gen_rtc_interrupt(unsigned long arg);
 
@@ -103,7 +102,7 @@ static void gen_rtc_interrupt(unsigned long arg);
  * Routine to poll RTC seconds field for change as often as possible,
  * after first RTC_UIE use timer to reduce polling
  */
-static void genrtc_troutine(void *data)
+static void genrtc_troutine(struct work_struct *work)
 {
        unsigned int tmp = get_rtc_ss();
        
@@ -171,7 +170,7 @@ static void gen_rtc_interrupt(unsigned long arg)
 /*
  *     Now all the various file operations that we export.
  */
-static ssize_t gen_rtc_read(struct file *file, char *buf,
+static ssize_t gen_rtc_read(struct file *file, char __user *buf,
                        size_t count, loff_t *ppos)
 {
        DECLARE_WAITQUEUE(wait, current);
@@ -200,13 +199,13 @@ static ssize_t gen_rtc_read(struct file *file, char *buf,
        /* first test allows optimizer to nuke this case for 32-bit machines */
        if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) {
                unsigned int uidata = data;
-               retval = put_user(uidata, (unsigned long *)buf);
+               retval = put_user(uidata, (unsigned int __user *)buf) ?:
+                       sizeof(unsigned int);
        }
        else {
-               retval = put_user(data, (unsigned long *)buf);
+               retval = put_user(data, (unsigned long __user *)buf) ?:
+                       sizeof(unsigned long);
        }
-       if (!retval)
-               retval = sizeof(unsigned long);
  out:
        current->state = TASK_RUNNING;
        remove_wait_queue(&gen_rtc_wait, &wait);
@@ -256,7 +255,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
                irq_active = 1;
                stop_rtc_timers = 0;
                lostint = 0;
-               INIT_WORK(&genrtc_task, genrtc_troutine, NULL);
+               INIT_WORK(&genrtc_task, genrtc_troutine);
                oldsecs = get_rtc_ss();
                init_timer(&timer_task);
 
@@ -278,6 +277,7 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
 {
        struct rtc_time wtime;
        struct rtc_pll_info pll;
+       void __user *argp = (void __user *)arg;
 
        switch (cmd) {
 
@@ -285,13 +285,12 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
            if (get_rtc_pll(&pll))
                    return -EINVAL;
            else
-                   return copy_to_user((void *)arg, &pll, sizeof pll) ? -EFAULT : 0;
+                   return copy_to_user(argp, &pll, sizeof pll) ? -EFAULT : 0;
 
        case RTC_PLL_SET:
                if (!capable(CAP_SYS_TIME))
                        return -EACCES;
-               if (copy_from_user(&pll, (struct rtc_pll_info*)arg,
-                                  sizeof(pll)))
+               if (copy_from_user(&pll, argp, sizeof(pll)))
                        return -EFAULT;
            return set_rtc_pll(&pll);
 
@@ -307,7 +306,7 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
                memset(&wtime, 0, sizeof(wtime));
                get_rtc_time(&wtime);
 
-               return copy_to_user((void *)arg, &wtime, sizeof(wtime)) ? -EFAULT : 0;
+               return copy_to_user(argp, &wtime, sizeof(wtime)) ? -EFAULT : 0;
 
        case RTC_SET_TIME:      /* Set the RTC */
            {
@@ -317,8 +316,7 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file,
                if (!capable(CAP_SYS_TIME))
                        return -EACCES;
 
-               if (copy_from_user(&wtime, (struct rtc_time *)arg,
-                                  sizeof(wtime)))
+               if (copy_from_user(&wtime, argp, sizeof(wtime)))
                        return -EFAULT;
 
                year = wtime.tm_year + 1900;
@@ -470,7 +468,7 @@ static int __init gen_rtc_proc_init(void)
 {
        struct proc_dir_entry *r;
 
-       r = create_proc_read_entry("driver/rtc", 0, 0, gen_rtc_read_proc, NULL);
+       r = create_proc_read_entry("driver/rtc", 0, NULL, gen_rtc_read_proc, NULL);
        if (!r)
                return -ENOMEM;
        return 0;
@@ -484,7 +482,7 @@ static inline int gen_rtc_proc_init(void) { return 0; }
  *     The various file operations we support.
  */
 
-static struct file_operations gen_rtc_fops = {
+static const struct file_operations gen_rtc_fops = {
        .owner          = THIS_MODULE,
 #ifdef CONFIG_GEN_RTC_X
        .read           = gen_rtc_read,