Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / macintosh / macio-adb.c
index f8bc90f..314fc08 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <linux/init.h>
+#include <linux/ioport.h>
 
 struct preg {
        unsigned char r;
@@ -57,9 +58,9 @@ struct adb_regs {
 /* Bits in autopoll register */
 #define APE    1               /* autopoll enable */
 
-static volatile struct adb_regs *adb;
+static volatile struct adb_regs __iomem *adb;
 static struct adb_request *current_req, *last_req;
-static spinlock_t macio_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(macio_lock);
 
 static int macio_probe(void);
 static int macio_init(void);
@@ -88,25 +89,26 @@ int macio_probe(void)
 int macio_init(void)
 {
        struct device_node *adbs;
+       struct resource r;
 
        adbs = find_compatible_devices("adb", "chrp,adb0");
        if (adbs == 0)
                return -ENXIO;
 
 #if 0
-       { int i;
+       { int i = 0;
 
        printk("macio_adb_init: node = %p, addrs =", adbs->node);
-       for (i = 0; i < adbs->n_addrs; ++i)
-               printk(" %x(%x)", adbs->addrs[i].address, adbs->addrs[i].size);
+       while(!of_address_to_resource(adbs, i, &r))
+               printk(" %x(%x)", r.start, r.end - r.start);
        printk(", intrs =");
        for (i = 0; i < adbs->n_intrs; ++i)
                printk(" %x", adbs->intrs[i].line);
        printk("\n"); }
 #endif
-       
-       adb = (volatile struct adb_regs *)
-               ioremap(adbs->addrs->address, sizeof(struct adb_regs));
+       if (of_address_to_resource(adbs, 0, &r))
+               return -ENXIO;
+       adb = ioremap(r.start, sizeof(struct adb_regs));
 
        out_8(&adb->ctrl.r, 0);
        out_8(&adb->intr.r, 0);
@@ -175,7 +177,7 @@ static int macio_send_request(struct adb_request *req, int sync)
                req->data[i] = req->data[i+1];
        --req->nbytes;
        
-       req->next = 0;
+       req->next = NULL;
        req->sent = 0;
        req->complete = 0;
        req->reply_len = 0;
@@ -202,7 +204,7 @@ static irqreturn_t macio_adb_interrupt(int irq, void *arg,
                                       struct pt_regs *regs)
 {
        int i, n, err;
-       struct adb_request *req;
+       struct adb_request *req = NULL;
        unsigned char ibuf[16];
        int ibuf_len = 0;
        int complete = 0;
@@ -280,6 +282,6 @@ static void macio_adb_poll(void)
 
        local_irq_save(flags);
        if (in_8(&adb->intr.r) != 0)
-               macio_adb_interrupt(0, 0, 0);
+               macio_adb_interrupt(0, NULL, NULL);
        local_irq_restore(flags);
 }