diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-28 13:09:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-28 13:09:47 -0700 |
commit | 84860bf0644d7c45afe7ddbd30731c3e3c371fae (patch) | |
tree | d6c4b98a9c3fd9981e7fcc5d7729c9e01e327767 /drivers/input/mouse/inport.c | |
parent | 8caf89157d64f1eedba37113afb4b303b2b3e301 (diff) | |
parent | 6fbfddcb52d8d9fa2cd209f5ac2a1c87497d55b5 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
Diffstat (limited to 'drivers/input/mouse/inport.c')
-rw-r--r-- | drivers/input/mouse/inport.c | 96 |
1 files changed, 49 insertions, 47 deletions
diff --git a/drivers/input/mouse/inport.c b/drivers/input/mouse/inport.c index 1f62c0134010..afc66f56df43 100644 --- a/drivers/input/mouse/inport.c +++ b/drivers/input/mouse/inport.c @@ -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); } |