Commit 3108d42d authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: remove user counters from drivers/input/mouse since input

       core takes care of calling open and close methods only
       when needed.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 0fbf87ca
...@@ -33,7 +33,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); ...@@ -33,7 +33,6 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Amiga mouse driver"); MODULE_DESCRIPTION("Amiga mouse driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static int amimouse_used = 0;
static int amimouse_lastx, amimouse_lasty; static int amimouse_lastx, amimouse_lasty;
static struct input_dev amimouse_dev; static struct input_dev amimouse_dev;
...@@ -81,16 +80,12 @@ static int amimouse_open(struct input_dev *dev) ...@@ -81,16 +80,12 @@ static int amimouse_open(struct input_dev *dev)
{ {
unsigned short joy0dat; unsigned short joy0dat;
if (amimouse_used++)
return 0;
joy0dat = custom.joy0dat; joy0dat = custom.joy0dat;
amimouse_lastx = joy0dat & 0xff; amimouse_lastx = joy0dat & 0xff;
amimouse_lasty = joy0dat >> 8; amimouse_lasty = joy0dat >> 8;
if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) { if (request_irq(IRQ_AMIGA_VERTB, amimouse_interrupt, 0, "amimouse", amimouse_interrupt)) {
amimouse_used--;
printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB); printk(KERN_ERR "amimouse.c: Can't allocate irq %d\n", IRQ_AMIGA_VERTB);
return -EBUSY; return -EBUSY;
} }
...@@ -100,8 +95,7 @@ static int amimouse_open(struct input_dev *dev) ...@@ -100,8 +95,7 @@ static int amimouse_open(struct input_dev *dev)
static void amimouse_close(struct input_dev *dev) static void amimouse_close(struct input_dev *dev)
{ {
if (!--amimouse_used) free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt);
free_irq(IRQ_AMIGA_VERTB, amimouse_interrupt);
} }
static int __init amimouse_init(void) static int __init amimouse_init(void)
......
...@@ -87,29 +87,23 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); ...@@ -87,29 +87,23 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
__obsolete_setup("inport_irq="); __obsolete_setup("inport_irq=");
static int inport_used;
static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t inport_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static int inport_open(struct input_dev *dev) static int inport_open(struct input_dev *dev)
{ {
if (!inport_used++) { if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL))
if (request_irq(inport_irq, inport_interrupt, 0, "inport", NULL)) return -EBUSY;
return -EBUSY; outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
outb(INPORT_MODE_IRQ | INPORT_MODE_BASE, INPORT_DATA_PORT);
}
return 0; return 0;
} }
static void inport_close(struct input_dev *dev) static void inport_close(struct input_dev *dev)
{ {
if (!--inport_used) { outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT); outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
outb(INPORT_MODE_BASE, INPORT_DATA_PORT); free_irq(inport_irq, NULL);
free_irq(inport_irq, NULL);
}
} }
static struct input_dev inport_dev = { static struct input_dev inport_dev = {
......
...@@ -77,16 +77,11 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)"); ...@@ -77,16 +77,11 @@ MODULE_PARM_DESC(irq, "IRQ number (5=default)");
__obsolete_setup("logibm_irq="); __obsolete_setup("logibm_irq=");
static int logibm_used = 0;
static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static int logibm_open(struct input_dev *dev) static int logibm_open(struct input_dev *dev)
{ {
if (logibm_used++)
return 0;
if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) { if (request_irq(logibm_irq, logibm_interrupt, 0, "logibm", NULL)) {
logibm_used--;
printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq); printk(KERN_ERR "logibm.c: Can't allocate irq %d\n", logibm_irq);
return -EBUSY; return -EBUSY;
} }
...@@ -96,8 +91,6 @@ static int logibm_open(struct input_dev *dev) ...@@ -96,8 +91,6 @@ static int logibm_open(struct input_dev *dev)
static void logibm_close(struct input_dev *dev) static void logibm_close(struct input_dev *dev)
{ {
if (--logibm_used)
return;
outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT); outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
free_irq(logibm_irq, NULL); free_irq(logibm_irq, NULL);
} }
......
...@@ -15,80 +15,51 @@ ...@@ -15,80 +15,51 @@
MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>"); MODULE_AUTHOR("YAEGASHI Takeshi <t@keshi.org>");
MODULE_DESCRIPTION("SEGA Dreamcast mouse driver"); MODULE_DESCRIPTION("SEGA Dreamcast mouse driver");
struct dc_mouse {
struct input_dev dev;
int open;
};
static void dc_mouse_callback(struct mapleq *mq) static void dc_mouse_callback(struct mapleq *mq)
{ {
int buttons, relx, rely, relz; int buttons, relx, rely, relz;
struct maple_device *mapledev = mq->dev; struct maple_device *mapledev = mq->dev;
struct dc_mouse *mouse = mapledev->private_data; struct input_dev *dev = mapledev->private_data;
struct input_dev *dev = &mouse->dev;
unsigned char *res = mq->recvbuf; unsigned char *res = mq->recvbuf;
buttons = ~res[8]; buttons = ~res[8];
relx=*(unsigned short *)(res+12)-512; relx = *(unsigned short *)(res + 12) - 512;
rely=*(unsigned short *)(res+14)-512; rely = *(unsigned short *)(res + 14) - 512;
relz=*(unsigned short *)(res+16)-512; relz = *(unsigned short *)(res + 16) - 512;
input_report_key(dev, BTN_LEFT, buttons&4); input_report_key(dev, BTN_LEFT, buttons & 4);
input_report_key(dev, BTN_MIDDLE, buttons&9); input_report_key(dev, BTN_MIDDLE, buttons & 9);
input_report_key(dev, BTN_RIGHT, buttons&2); input_report_key(dev, BTN_RIGHT, buttons & 2);
input_report_rel(dev, REL_X, relx); input_report_rel(dev, REL_X, relx);
input_report_rel(dev, REL_Y, rely); input_report_rel(dev, REL_Y, rely);
input_report_rel(dev, REL_WHEEL, relz); input_report_rel(dev, REL_WHEEL, relz);
input_sync(dev); input_sync(dev);
} }
static int dc_mouse_open(struct input_dev *dev)
{
struct dc_mouse *mouse = dev->private;
mouse->open++;
return 0;
}
static void dc_mouse_close(struct input_dev *dev)
{
struct dc_mouse *mouse = dev->private;
mouse->open--;
}
static int dc_mouse_connect(struct maple_device *dev) static int dc_mouse_connect(struct maple_device *dev)
{ {
unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]);
struct dc_mouse *mouse; struct input_dev *input_dev;
if (!(mouse = kmalloc(sizeof(struct dc_mouse), GFP_KERNEL))) if (!(input_dev = kmalloc(sizeof(struct input_dev), GFP_KERNEL)))
return -1; return -1;
memset(mouse, 0, sizeof(struct dc_mouse));
dev->private_data = mouse;
mouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
mouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
mouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
init_input_dev(&mouse->dev); dev->private_data = input_dev;
mouse->dev.private = mouse; memset(input_dev, 0, sizeof(struct dc_mouse));
mouse->dev.open = dc_mouse_open; init_input_dev(input_dev);
mouse->dev.close = dc_mouse_close; input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
mouse->dev.event = NULL; input_dev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
input_dev->relbit[0] = BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL);
mouse->dev.name = dev->product_name; input_dev->name = dev->product_name;
mouse->dev.id.bustype = BUS_MAPLE; input_dev->id.bustype = BUS_MAPLE;
input_register_device(&mouse->dev); input_register_device(input_dev);
maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE); maple_getcond_callback(dev, dc_mouse_callback, 1, MAPLE_FUNC_MOUSE);
printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, mouse->dev.name); printk(KERN_INFO "input: mouse(0x%lx): %s\n", data, input_dev->name);
return 0; return 0;
} }
...@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev) ...@@ -96,10 +67,10 @@ static int dc_mouse_connect(struct maple_device *dev)
static void dc_mouse_disconnect(struct maple_device *dev) static void dc_mouse_disconnect(struct maple_device *dev)
{ {
struct dc_mouse *mouse = dev->private_data; struct input_dev *input_dev = dev->private_data;
input_unregister_device(&mouse->dev); input_unregister_device(input_dev);
kfree(mouse); kfree(input_dev);
} }
......
...@@ -56,7 +56,6 @@ static int pc110pad_io = 0x15e0; ...@@ -56,7 +56,6 @@ static int pc110pad_io = 0x15e0;
static struct input_dev pc110pad_dev; static struct input_dev pc110pad_dev;
static int pc110pad_data[3]; static int pc110pad_data[3];
static int pc110pad_count; static int pc110pad_count;
static int pc110pad_used;
static char *pc110pad_name = "IBM PC110 TouchPad"; static char *pc110pad_name = "IBM PC110 TouchPad";
static char *pc110pad_phys = "isa15e0/input0"; static char *pc110pad_phys = "isa15e0/input0";
...@@ -90,15 +89,11 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs) ...@@ -90,15 +89,11 @@ static irqreturn_t pc110pad_interrupt(int irq, void *ptr, struct pt_regs *regs)
static void pc110pad_close(struct input_dev *dev) static void pc110pad_close(struct input_dev *dev)
{ {
if (!--pc110pad_used) outb(PC110PAD_OFF, pc110pad_io + 2);
outb(PC110PAD_OFF, pc110pad_io + 2);
} }
static int pc110pad_open(struct input_dev *dev) static int pc110pad_open(struct input_dev *dev)
{ {
if (pc110pad_used++)
return 0;
pc110pad_interrupt(0,NULL,NULL); pc110pad_interrupt(0,NULL,NULL);
pc110pad_interrupt(0,NULL,NULL); pc110pad_interrupt(0,NULL,NULL);
pc110pad_interrupt(0,NULL,NULL); pc110pad_interrupt(0,NULL,NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment