Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
[safe/jmp/linux-2.6] / drivers / rtc / rtc-s3c.c
index aacbfea..9a79a24 100644 (file)
@@ -46,7 +46,7 @@ static unsigned int tick_count;
 
 /* IRQ Handlers */
 
-static irqreturn_t s3c_rtc_alarmirq(int irq, void *id, struct pt_regs *r)
+static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
 {
        struct rtc_device *rdev = id;
 
@@ -54,7 +54,7 @@ static irqreturn_t s3c_rtc_alarmirq(int irq, void *id, struct pt_regs *r)
        return IRQ_HANDLED;
 }
 
-static irqreturn_t s3c_rtc_tickirq(int irq, void *id, struct pt_regs *r)
+static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
 {
        struct rtc_device *rdev = id;
 
@@ -153,24 +153,25 @@ static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 static int s3c_rtc_settime(struct device *dev, struct rtc_time *tm)
 {
        void __iomem *base = s3c_rtc_base;
+       int year = tm->tm_year - 100;
 
-       /* the rtc gets round the y2k problem by just not supporting it */
+       pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
+                tm->tm_year, tm->tm_mon, tm->tm_mday,
+                tm->tm_hour, tm->tm_min, tm->tm_sec);
 
-       if (tm->tm_year > 100) {
+       /* we get around y2k by simply not supporting it */
+
+       if (year < 0 || year >= 100) {
                dev_err(dev, "rtc only supports 100 years\n");
                return -EINVAL;
        }
 
-       pr_debug("set time %02d.%02d.%02d %02d/%02d/%02d\n",
-                tm->tm_year, tm->tm_mon, tm->tm_mday,
-                tm->tm_hour, tm->tm_min, tm->tm_sec);
-
        writeb(BIN2BCD(tm->tm_sec),  base + S3C2410_RTCSEC);
        writeb(BIN2BCD(tm->tm_min),  base + S3C2410_RTCMIN);
        writeb(BIN2BCD(tm->tm_hour), base + S3C2410_RTCHOUR);
        writeb(BIN2BCD(tm->tm_mday), base + S3C2410_RTCDATE);
        writeb(BIN2BCD(tm->tm_mon + 1), base + S3C2410_RTCMON);
-       writeb(BIN2BCD(tm->tm_year - 100), base + S3C2410_RTCYEAR);
+       writeb(BIN2BCD(year), base + S3C2410_RTCYEAR);
 
        return 0;
 }
@@ -190,6 +191,8 @@ static int s3c_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
 
        alm_en = readb(base + S3C2410_RTCALM);
 
+       alrm->enabled = (alm_en & S3C2410_RTCALM_ALMEN) ? 1 : 0;
+
        pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
                 alm_en,
                 alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
@@ -330,12 +333,8 @@ static int s3c_rtc_ioctl(struct device *dev,
 
 static int s3c_rtc_proc(struct device *dev, struct seq_file *seq)
 {
-       unsigned int rtcalm = readb(s3c_rtc_base + S3C2410_RTCALM);
        unsigned int ticnt = readb(s3c_rtc_base + S3C2410_TICNT);
 
-       seq_printf(seq, "alarm_IRQ\t: %s\n",
-                  (rtcalm & S3C2410_RTCALM_ALMEN) ? "yes" : "no" );
-
        seq_printf(seq, "periodic_IRQ\t: %s\n",
                     (ticnt & S3C2410_TICNT_ENABLE) ? "yes" : "no" );
 
@@ -351,7 +350,7 @@ static int s3c_rtc_open(struct device *dev)
        int ret;
 
        ret = request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq,
-                         SA_INTERRUPT,  "s3c2410-rtc alarm", rtc_dev);
+                         IRQF_DISABLED,  "s3c2410-rtc alarm", rtc_dev);
 
        if (ret) {
                dev_err(dev, "IRQ%d error %d\n", s3c_rtc_alarmno, ret);
@@ -359,7 +358,7 @@ static int s3c_rtc_open(struct device *dev)
        }
 
        ret = request_irq(s3c_rtc_tickno, s3c_rtc_tickirq,
-                         SA_INTERRUPT,  "s3c2410-rtc tick", rtc_dev);
+                         IRQF_DISABLED,  "s3c2410-rtc tick", rtc_dev);
 
        if (ret) {
                dev_err(dev, "IRQ%d error %d\n", s3c_rtc_tickno, ret);
@@ -385,7 +384,7 @@ static void s3c_rtc_release(struct device *dev)
        free_irq(s3c_rtc_tickno, rtc_dev);
 }
 
-static struct rtc_class_ops s3c_rtcops = {
+static const struct rtc_class_ops s3c_rtcops = {
        .open           = s3c_rtc_open,
        .release        = s3c_rtc_release,
        .ioctl          = s3c_rtc_ioctl,