[PATCH] devfs: Remove the devfs_fs_kernel.h file from the tree
[powerpc.git] / drivers / input / mouse / inport.c
index 1f62c01..afc66f5 100644 (file)
@@ -87,40 +87,7 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
 
 __obsolete_setup("inport_irq=");
 
-static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
-
-static int inport_open(struct input_dev *dev)
-{
-       if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
-               return -EBUSY;
-       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
-       outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
-
-       return 0;
-}
-
-static void inport_close(struct input_dev *dev)
-{
-       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
-       outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
-       free_irq(inport_irq, NULL);
-}
-
-static struct input_dev inport_dev = {
-       .evbit  = { BIT(EV_KEY) | BIT(EV_REL) },
-       .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT) },
-       .relbit = { BIT(REL_X) | BIT(REL_Y) },
-       .open   = inport_open,
-       .close  = inport_close,
-       .name   = INPORT_NAME,
-       .phys   = "isa023c/input0",
-       .id = {
-               .bustype = BUS_ISA,
-               .vendor  = INPORT_VENDOR,
-               .product = 0x0001,
-               .version = 0x0100,
-       },
-};
+static struct input_dev *inport_dev;
 
 static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
@@ -129,31 +96,48 @@ static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
        outb(INPORT_MODE_HOLD | INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
 
-       input_regs(&inport_dev, regs);
+       input_regs(inport_dev, regs);
 
        outb(INPORT_REG_X, INPORT_CONTROL_PORT);
-       input_report_rel(&inport_dev, REL_X, inb(INPORT_DATA_PORT));
+       input_report_rel(inport_dev, REL_X, inb(INPORT_DATA_PORT));
 
        outb(INPORT_REG_Y, INPORT_CONTROL_PORT);
-       input_report_rel(&inport_dev, REL_Y, inb(INPORT_DATA_PORT));
+       input_report_rel(inport_dev, REL_Y, inb(INPORT_DATA_PORT));
 
        outb(INPORT_REG_BTNS, INPORT_CONTROL_PORT);
        buttons = inb(INPORT_DATA_PORT);
 
-       input_report_key(&inport_dev, BTN_MIDDLE, buttons & 1);
-       input_report_key(&inport_dev, BTN_LEFT,   buttons & 2);
-       input_report_key(&inport_dev, BTN_RIGHT,  buttons & 4);
+       input_report_key(inport_dev, BTN_MIDDLE, buttons & 1);
+       input_report_key(inport_dev, BTN_LEFT,   buttons & 2);
+       input_report_key(inport_dev, BTN_RIGHT,  buttons & 4);
 
        outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
        outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
 
-       input_sync(&inport_dev);
+       input_sync(inport_dev);
        return IRQ_HANDLED;
 }
 
+static int inport_open(struct input_dev *dev)
+{
+       if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
+               return -EBUSY;
+       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+       outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
+
+       return 0;
+}
+
+static void inport_close(struct input_dev *dev)
+{
+       outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
+       outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
+       free_irq(inport_irq, NULL);
+}
+
 static int __init inport_init(void)
 {
-       unsigned char a,b,c;
+       unsigned char a, b, c;
 
        if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
                printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
@@ -163,26 +147,44 @@ static int __init inport_init(void)
        a = inb(INPORT_SIGNATURE_PORT);
        b = inb(INPORT_SIGNATURE_PORT);
        c = inb(INPORT_SIGNATURE_PORT);
-       if (( a == b ) || ( a != c )) {
+       if (a == b || a != c) {
                release_region(INPORT_BASE, INPORT_EXTENT);
                printk(KERN_ERR "inport.c: Didn't find InPort mouse at %#x\n", INPORT_BASE);
                return -ENODEV;
        }
 
+       if (!(inport_dev = input_allocate_device())) {
+               printk(KERN_ERR "inport.c: Not enough memory for input device\n");
+               release_region(INPORT_BASE, INPORT_EXTENT);
+               return -ENOMEM;
+       }
+
+       inport_dev->name = INPORT_NAME;
+       inport_dev->phys = "isa023c/input0";
+       inport_dev->id.bustype = BUS_ISA;
+       inport_dev->id.vendor  = INPORT_VENDOR;
+       inport_dev->id.product = 0x0001;
+       inport_dev->id.version = 0x0100;
+
+       inport_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
+       inport_dev->keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
+       inport_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
+
+       inport_dev->open  = inport_open;
+       inport_dev->close = inport_close;
+
        outb(INPORT_RESET, INPORT_CONTROL_PORT);
        outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
        outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
 
-       input_register_device(&inport_dev);
-
-       printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq);
+       input_register_device(inport_dev);
 
        return 0;
 }
 
 static void __exit inport_exit(void)
 {
-       input_unregister_device(&inport_dev);
+       input_unregister_device(inport_dev);
        release_region(INPORT_BASE, INPORT_EXTENT);
 }