nfsd4: implement reclaim_complete
[safe/jmp/linux-2.6] / drivers / rtc / rtc-bq4802.c
index 541580c..128270c 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/platform_device.h>
 #include <linux/rtc.h>
 #include <linux/bcd.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("David S. Miller <davem@davemloft.net>");
 MODULE_DESCRIPTION("TI BQ4802 RTC driver");
@@ -17,6 +18,7 @@ MODULE_LICENSE("GPL");
 
 struct bq4802 {
        void __iomem            *regs;
+       unsigned long           ioport;
        struct rtc_device       *rtc;
        spinlock_t              lock;
        struct resource         *r;
@@ -26,12 +28,12 @@ struct bq4802 {
 
 static u8 bq4802_read_io(struct bq4802 *p, int off)
 {
-       return inb(p->regs + off);
+       return inb(p->ioport + off);
 }
 
 static void bq4802_write_io(struct bq4802 *p, int off, u8 val)
 {
-       return outb(val, p->regs + off);
+       outb(val, p->ioport + off);
 }
 
 static u8 bq4802_read_mem(struct bq4802 *p, int off)
@@ -41,7 +43,7 @@ static u8 bq4802_read_mem(struct bq4802 *p, int off)
 
 static void bq4802_write_mem(struct bq4802 *p, int off, u8 val)
 {
-       return writeb(val, p->regs + off);
+       writeb(val, p->regs + off);
 }
 
 static int bq4802_read_time(struct device *dev, struct rtc_time *tm)
@@ -70,14 +72,14 @@ static int bq4802_read_time(struct device *dev, struct rtc_time *tm)
 
        spin_unlock_irqrestore(&p->lock, flags);
 
-       BCD_TO_BIN(tm->tm_sec);
-       BCD_TO_BIN(tm->tm_min);
-       BCD_TO_BIN(tm->tm_hour);
-       BCD_TO_BIN(tm->tm_mday);
-       BCD_TO_BIN(tm->tm_mon);
-       BCD_TO_BIN(tm->tm_year);
-       BCD_TO_BIN(tm->tm_wday);
-       BCD_TO_BIN(century);
+       tm->tm_sec = bcd2bin(tm->tm_sec);
+       tm->tm_min = bcd2bin(tm->tm_min);
+       tm->tm_hour = bcd2bin(tm->tm_hour);
+       tm->tm_mday = bcd2bin(tm->tm_mday);
+       tm->tm_mon = bcd2bin(tm->tm_mon);
+       tm->tm_year = bcd2bin(tm->tm_year);
+       tm->tm_wday = bcd2bin(tm->tm_wday);
+       century = bcd2bin(century);
 
        tm->tm_year += (century * 100);
        tm->tm_year -= 1900;
@@ -105,13 +107,13 @@ static int bq4802_set_time(struct device *dev, struct rtc_time *tm)
        min = tm->tm_min;
        sec = tm->tm_sec;
 
-       BIN_TO_BCD(sec);
-       BIN_TO_BCD(min);
-       BIN_TO_BCD(hrs);
-       BIN_TO_BCD(day);
-       BIN_TO_BCD(mon);
-       BIN_TO_BCD(yrs);
-       BIN_TO_BCD(century);
+       sec = bin2bcd(sec);
+       min = bin2bcd(min);
+       hrs = bin2bcd(hrs);
+       day = bin2bcd(day);
+       mon = bin2bcd(mon);
+       yrs = bin2bcd(yrs);
+       century = bin2bcd(century);
 
        spin_lock_irqsave(&p->lock, flags);
 
@@ -156,7 +158,7 @@ static int __devinit bq4802_probe(struct platform_device *pdev)
                        goto out_free;
        }
        if (p->r->flags & IORESOURCE_IO) {
-               p->regs = (void __iomem *) p->r->start;
+               p->ioport = p->r->start;
                p->read = bq4802_read_io;
                p->write = bq4802_write_io;
        } else if (p->r->flags & IORESOURCE_MEM) {
@@ -168,6 +170,8 @@ static int __devinit bq4802_probe(struct platform_device *pdev)
                goto out_free;
        }
 
+       platform_set_drvdata(pdev, p);
+
        p->rtc = rtc_device_register("bq4802", &pdev->dev,
                                     &bq4802_ops, THIS_MODULE);
        if (IS_ERR(p->rtc)) {
@@ -175,7 +179,6 @@ static int __devinit bq4802_probe(struct platform_device *pdev)
                goto out_iounmap;
        }
 
-       platform_set_drvdata(pdev, p);
        err = 0;
 out:
        return err;