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 / input / serio / sa1111ps2.c
index d8fbab3..ebd9976 100644 (file)
 #include <linux/spinlock.h>
 
 #include <asm/io.h>
-#include <asm/irq.h>
 #include <asm/system.h>
 
 #include <asm/hardware/sa1111.h>
 
 struct ps2if {
-       struct serio            io;
+       struct serio            *io;
        struct sa1111_dev       *dev;
-       unsigned long           base;
+       void __iomem            *base;
        unsigned int            open;
        spinlock_t              lock;
        unsigned int            head;
@@ -45,7 +44,6 @@ static irqreturn_t ps2_rxint(int irq, void *dev_id, struct pt_regs *regs)
 {
        struct ps2if *ps2if = dev_id;
        unsigned int scancode, flag, status;
-       int handled = IRQ_NONE;
 
        status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
        while (status & PS2STAT_RXF) {
@@ -60,14 +58,12 @@ static irqreturn_t ps2_rxint(int irq, void *dev_id, struct pt_regs *regs)
                if (hweight8(scancode) & 1)
                        flag ^= SERIO_PARITY;
 
-               serio_interrupt(&ps2if->io, scancode, flag, regs);
+               serio_interrupt(ps2if->io, scancode, flag, regs);
 
                status = sa1111_readl(ps2if->base + SA1111_PS2STAT);
-
-               handled = IRQ_HANDLED;
         }
 
-        return handled;
+        return IRQ_HANDLED;
 }
 
 /*
@@ -98,7 +94,7 @@ static irqreturn_t ps2_txint(int irq, void *dev_id, struct pt_regs *regs)
  */
 static int ps2_write(struct serio *io, unsigned char val)
 {
-       struct ps2if *ps2if = io->driver;
+       struct ps2if *ps2if = io->port_data;
        unsigned long flags;
        unsigned int head;
 
@@ -125,7 +121,7 @@ static int ps2_write(struct serio *io, unsigned char val)
 
 static int ps2_open(struct serio *io)
 {
-       struct ps2if *ps2if = io->driver;
+       struct ps2if *ps2if = io->port_data;
        int ret;
 
        sa1111_enable_device(ps2if->dev);
@@ -157,7 +153,7 @@ static int ps2_open(struct serio *io)
 
 static void ps2_close(struct serio *io)
 {
-       struct ps2if *ps2if = io->driver;
+       struct ps2if *ps2if = io->port_data;
 
        sa1111_writel(0, ps2if->base + SA1111_PS2CR);
 
@@ -235,22 +231,28 @@ static int __init ps2_test(struct ps2if *ps2if)
 static int ps2_probe(struct sa1111_dev *dev)
 {
        struct ps2if *ps2if;
+       struct serio *serio;
        int ret;
 
        ps2if = kmalloc(sizeof(struct ps2if), GFP_KERNEL);
-       if (!ps2if) {
-               return -ENOMEM;
+       serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
+       if (!ps2if || !serio) {
+               ret = -ENOMEM;
+               goto free;
        }
 
        memset(ps2if, 0, sizeof(struct ps2if));
-
-       ps2if->io.type          = SERIO_8042;
-       ps2if->io.write         = ps2_write;
-       ps2if->io.open          = ps2_open;
-       ps2if->io.close         = ps2_close;
-       ps2if->io.name          = dev->dev.bus_id;
-       ps2if->io.phys          = dev->dev.bus_id;
-       ps2if->io.driver        = ps2if;
+       memset(serio, 0, sizeof(struct serio));
+
+       serio->id.type          = SERIO_8042;
+       serio->write            = ps2_write;
+       serio->open             = ps2_open;
+       serio->close            = ps2_close;
+       strlcpy(serio->name, dev->dev.bus_id, sizeof(serio->name));
+       strlcpy(serio->phys, dev->dev.bus_id, sizeof(serio->phys));
+       serio->port_data        = ps2if;
+       serio->dev.parent       = &dev->dev;
+       ps2if->io               = serio;
        ps2if->dev              = dev;
        sa1111_set_drvdata(dev, ps2if);
 
@@ -269,7 +271,7 @@ static int ps2_probe(struct sa1111_dev *dev)
        /*
         * Our parent device has already mapped the region.
         */
-       ps2if->base = (unsigned long)dev->mapbase;
+       ps2if->base = dev->mapbase;
 
        sa1111_enable_device(ps2if->dev);
 
@@ -295,7 +297,7 @@ static int ps2_probe(struct sa1111_dev *dev)
        ps2_clear_input(ps2if);
 
        sa1111_disable_device(ps2if->dev);
-       serio_register_port(&ps2if->io);
+       serio_register_port(ps2if->io);
        return 0;
 
  out:
@@ -305,6 +307,7 @@ static int ps2_probe(struct sa1111_dev *dev)
  free:
        sa1111_set_drvdata(dev, NULL);
        kfree(ps2if);
+       kfree(serio);
        return ret;
 }
 
@@ -315,7 +318,7 @@ static int ps2_remove(struct sa1111_dev *dev)
 {
        struct ps2if *ps2if = sa1111_get_drvdata(dev);
 
-       serio_unregister_port(&ps2if->io);
+       serio_unregister_port(ps2if->io);
        release_mem_region(dev->res.start,
                           dev->res.end - dev->res.start + 1);
        sa1111_set_drvdata(dev, NULL);