Pull sony into release branch
[pandora-kernel.git] / arch / m68k / bvme6000 / rtc.c
index eb63ca6..a812d03 100644 (file)
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
 #include <linux/ioport.h>
+#include <linux/capability.h>
 #include <linux/fcntl.h>
 #include <linux/init.h>
 #include <linux/poll.h>
 #include <linux/module.h>
 #include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
 #include <linux/smp_lock.h>
+#include <linux/bcd.h>
 #include <asm/bvme6000hw.h>
 
 #include <asm/io.h>
@@ -31,9 +33,6 @@
  *     ioctls.
  */
 
-#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
-#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
-
 static unsigned char days_in_mo[] =
 {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
@@ -46,6 +45,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        unsigned char msr;
        unsigned long flags;
        struct rtc_time wtime;
+       void __user *argp = (void __user *)arg;
 
        switch (cmd) {
        case RTC_RD_TIME:       /* Read the time/date from RTC  */
@@ -68,7 +68,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                } while (wtime.tm_sec != BCD2BIN(rtc->bcd_sec));
                rtc->msr = msr;
                local_irq_restore(flags);
-               return copy_to_user((void *)arg, &wtime, sizeof wtime) ?
+               return copy_to_user(argp, &wtime, sizeof wtime) ?
                                                                -EFAULT : 0;
        }
        case RTC_SET_TIME:      /* Set the RTC */
@@ -80,8 +80,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                if (!capable(CAP_SYS_ADMIN))
                        return -EACCES;
 
-               if (copy_from_user(&rtc_tm, (struct rtc_time*)arg,
-                                  sizeof(struct rtc_time)))
+               if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time)))
                        return -EFAULT;
 
                yrs = rtc_tm.tm_year;
@@ -160,7 +159,7 @@ static int rtc_release(struct inode *inode, struct file *file)
  *     The various file operations we support.
  */
 
-static struct file_operations rtc_fops = {
+static const struct file_operations rtc_fops = {
        .ioctl =        rtc_ioctl,
        .open =         rtc_open,
        .release =      rtc_release,