Commit 368b9617 authored by Vojtech Pavlik's avatar Vojtech Pavlik

Initialize struct input_dev in input drivers before it's passed to input_event().

input_register_device() usually does that, but some drivers will call
input_event() before registering to pre-load the absolute values in
struct input_dev in an easy way.
parent 027de1fc
......@@ -300,6 +300,8 @@ static void a3d_connect(struct gameport *gameport, struct gameport_dev *dev)
a3d->length = 33;
init_input_dev(&a3d->dev);
a3d->dev.evbit[0] |= BIT(EV_ABS) | BIT(EV_KEY) | BIT(EV_REL);
a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
a3d->dev.absbit[0] |= BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_THROTTLE) | BIT(ABS_RUDDER)
......@@ -328,6 +330,8 @@ static void a3d_connect(struct gameport *gameport, struct gameport_dev *dev)
} else {
a3d->length = 29;
init_input_dev(&a3d->dev);
a3d->dev.evbit[0] |= BIT(EV_KEY) | BIT(EV_REL);
a3d->dev.relbit[0] |= BIT(REL_X) | BIT(REL_Y);
a3d->dev.keybit[LONG(BTN_MOUSE)] |= BIT(BTN_RIGHT) | BIT(BTN_LEFT) | BIT(BTN_MIDDLE);
......
......@@ -404,6 +404,8 @@ static void adi_init_input(struct adi *adi, struct adi_port *port, int half)
if (!adi->length) return;
init_input_dev(&adi->dev);
t = adi->id < ADI_ID_MAX ? adi->id : ADI_ID_MAX;
sprintf(buf, adi_names[t], adi->id);
......
......@@ -431,9 +431,10 @@ static void analog_init_device(struct analog_port *port, struct analog *analog,
analog_name(analog);
sprintf(analog->phys, "%s/input%d", port->gameport->phys, index);
analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn;
init_input_dev(&analog->dev);
analog->dev.name = analog->name;
analog->dev.phys = analog->phys;
analog->dev.id.bustype = BUS_GAMEPORT;
......
......@@ -290,6 +290,8 @@ static void gf2k_connect(struct gameport *gameport, struct gameport_dev *dev)
gf2k->length = gf2k_lens[gf2k->id];
init_input_dev(&gf2k->dev);
gf2k->dev.private = gf2k;
gf2k->dev.open = gf2k_open;
gf2k->dev.close = gf2k_close;
......
......@@ -169,6 +169,7 @@ static void magellan_connect(struct serio *serio, struct serio_dev *dev)
sprintf(magellan->phys, "%s/input0", serio->phys);
init_input_dev(&magellan->dev);
magellan->dev.private = magellan;
magellan->dev.name = magellan_name;
magellan->dev.phys = magellan->phys;
......@@ -187,6 +188,7 @@ static void magellan_connect(struct serio *serio, struct serio_dev *dev)
input_register_device(&magellan->dev);
printk(KERN_INFO "input: %s on %s\n", magellan_name, serio->phys);
}
/*
......
......@@ -240,6 +240,7 @@ static void spaceball_connect(struct serio *serio, struct serio_dev *dev)
sprintf(spaceball->phys, "%s/input0", serio->phys);
init_input_dev(&spaceball->dev);
spaceball->dev.name = spaceball_names[id];
spaceball->dev.phys = spaceball->phys;
spaceball->dev.id.bustype = BUS_RS232;
......
......@@ -187,6 +187,7 @@ static void spaceorb_connect(struct serio *serio, struct serio_dev *dev)
sprintf(spaceorb->phys, "%s/input0", serio->phys);
init_input_dev(&spaceorb->dev);
spaceorb->dev.name = spaceorb_name;
spaceorb->dev.phys = spaceorb->phys;
spaceorb->dev.id.bustype = BUS_RS232;
......
......@@ -152,6 +152,7 @@ static void stinger_connect(struct serio *serio, struct serio_dev *dev)
sprintf(stinger->phys, "%s/serio0", serio->phys);
init_input_dev(&stinger->dev);
stinger->dev.name = stinger_name;
stinger->dev.phys = stinger->phys;
stinger->dev.id.bustype = BUS_RS232;
......@@ -166,7 +167,6 @@ static void stinger_connect(struct serio *serio, struct serio_dev *dev)
}
stinger->dev.private = stinger;
serio->private = stinger;
if (serio_open(serio, dev)) {
......@@ -177,6 +177,7 @@ static void stinger_connect(struct serio *serio, struct serio_dev *dev)
input_register_device(&stinger->dev);
printk(KERN_INFO "input: %s on %s\n", stinger_name, serio->phys);
}
/*
......
......@@ -198,6 +198,7 @@ static void twidjoy_connect(struct serio *serio, struct serio_dev *dev)
sprintf(twidjoy->phys, "%s/input0", serio->phys);
init_input_dev(&twidjoy->dev);
twidjoy->dev.name = twidjoy_name;
twidjoy->dev.phys = twidjoy->phys;
twidjoy->dev.id.bustype = BUS_RS232;
......@@ -224,7 +225,6 @@ static void twidjoy_connect(struct serio *serio, struct serio_dev *dev)
}
twidjoy->dev.private = twidjoy;
serio->private = twidjoy;
if (serio_open(serio, dev)) {
......
......@@ -155,6 +155,7 @@ static void warrior_connect(struct serio *serio, struct serio_dev *dev)
sprintf(warrior->phys, "%s/input0", serio->phys);
init_input_dev(&warrior->dev);
warrior->dev.name = warrior_name;
warrior->dev.phys = warrior->phys;
warrior->dev.id.bustype = BUS_RS232;
......@@ -180,7 +181,7 @@ static void warrior_connect(struct serio *serio, struct serio_dev *dev)
serio->private = warrior;
if (serio_open(serio, dev)) {
if (serio_open(serio, dev)) {
kfree(warrior);
return;
}
......
......@@ -112,6 +112,8 @@ static int __init amikbd_init(void)
if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb"))
return -EBUSY;
init_input_dev(&amibkd_dev);
amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
amikbd_dev.keycode = amikbd_keycode;
amikbd_dev.keycodesize = sizeof(unsigned char);
......
......@@ -474,6 +474,8 @@ static void atkbd_connect(struct serio *serio, struct serio_dev *dev)
atkbd->serio = serio;
init_input_dev(&atkbd->dev);
atkbd->dev.keycode = atkbd->keycode;
atkbd->dev.keycodesize = sizeof(unsigned char);
atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode);
......
......@@ -93,11 +93,11 @@ void nkbd_connect(struct serio *serio, struct serio_dev *dev)
nkbd->serio = serio;
init_input_dev(&nkbd->dev);
nkbd->dev.keycode = nkbd->keycode;
nkbd->dev.keycodesize = sizeof(unsigned char);
nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode);
nkbd->dev.private = nkbd;
serio->private = nkbd;
if (serio_open(serio, dev)) {
......
......@@ -234,6 +234,8 @@ static void sunkbd_connect(struct serio *serio, struct serio_dev *dev)
memset(sunkbd, 0, sizeof(struct sunkbd));
init_input_dev(&sunkbd->dev);
sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP);
sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML);
sunkbd->dev.sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL);
......
......@@ -100,6 +100,7 @@ void xtkbd_connect(struct serio *serio, struct serio_dev *dev)
xtkbd->serio = serio;
init_input_dev(&xtkbd->dev);
xtkbd->dev.keycode = xtkbd->keycode;
xtkbd->dev.keycodesize = sizeof(unsigned char);
xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode);
......
......@@ -115,6 +115,12 @@ static struct input_dev inport_dev = {
.close = inport_close,
.name = INPORT_NAME,
.phys = "isa023c/input0",
.id = {
.bustype = BUS_ISA,
.vendor = INPORT_VENDOR,
.product = 0x0001,
.version = 0x0100,
},
};
static void inport_interrupt(int irq, void *dev_id, struct pt_regs *regs)
......@@ -158,30 +164,27 @@ static int __init inport_init(void)
{
unsigned char a,b,c;
if (check_region(INPORT_BASE, INPORT_EXTENT))
if (!request_region(INPORT_BASE, INPORT_EXTENT, "inport")) {
printk(KERN_ERR "inport.c: Can't allocate ports at %#x\n", INPORT_BASE);
return -EBUSY;
}
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;
}
outb(INPORT_RESET, INPORT_CONTROL_PORT);
outb(INPORT_REG_MODE, INPORT_CONTROL_PORT);
outb(INPORT_MODE_BASE, INPORT_DATA_PORT);
request_region(INPORT_BASE, INPORT_EXTENT, "inport");
input_register_device(&inport_dev);
inport_dev.id.bustype =BUS_ISA;
inport_dev.id.vendor =INPORT_VENDOR;
inport_dev.id.product =0x0001;
inport_dev.id.version =0x0100;
printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n",
INPORT_BASE, inport_irq);
printk(KERN_INFO "input: " INPORT_NAME " at %#x irq %d\n", INPORT_BASE, inport_irq);
return 0;
}
......
......@@ -105,6 +105,12 @@ static struct input_dev logibm_dev = {
.close = logibm_close,
.name = "Logitech bus mouse",
.phys = "isa023c/input0",
.id = {
.bustype = BUS_ISA,
.vendor = 0x0003,
.product = 0x0001,
.version = 0x0100,
},
};
static void logibm_interrupt(int irq, void *dev_id, struct pt_regs *regs)
......@@ -165,11 +171,7 @@ static int __init logibm_init(void)
outb(LOGIBM_DISABLE_IRQ, LOGIBM_CONTROL_PORT);
input_register_device(&logibm_dev);
logibm_dev.id.bustype = BUS_ISA;
logibm_dev.id.vendor = 0x0003;
logibm_dev.id.product = 0x0001;
logibm_dev.id.version = 0x0100;
printk(KERN_INFO "input: Logitech bus mouse at %#x irq %d\n", LOGIBM_BASE, logibm_irq);
return 0;
......
......@@ -583,6 +583,7 @@ static void psmouse_connect(struct serio *serio, struct serio_dev *dev)
memset(psmouse, 0, sizeof(struct psmouse));
init_input_dev(&psmouse->dev);
psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
......
......@@ -41,6 +41,12 @@ static struct input_dev rpcmouse_dev = {
.relbit = { BIT(REL_X) | BIT(REL_Y) },
.name = "Acorn RiscPC Mouse",
.phys = "rpcmouse/input0",
.id = {
.bustype = BUS_HOST,
.vendor = 0x0005,
.product = 0x0001,
.version = 0x0100,
},
};
static void rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
......@@ -69,6 +75,8 @@ static void rpcmouse_irq(int irq, void *dev_id, struct pt_regs *regs)
static int __init rpcmouse_init(void)
{
init_input_dev(&rpcmouse_dev);
rpcmouse_lastx = (short) iomd_readl(IOMD_MOUSEX);
rpcmouse_lasty = (short) iomd_readl(IOMD_MOUSEY);
......@@ -78,10 +86,6 @@ static int __init rpcmouse_init(void)
}
input_register_device(&rpcmouse_dev);
rpcmouse.id.bustype =BUS_HOST,
rpcmouse.id.vendor =0x0005,
rpcmouse.id.product =0x0001,
rpcmouse.id.version =0x0100,
printk(KERN_INFO "input: Acorn RiscPC mouse irq %d", IRQ_VSYNCPULSE);
......
......@@ -247,6 +247,7 @@ static void sermouse_connect(struct serio *serio, struct serio_dev *dev)
memset(sermouse, 0, sizeof(struct sermouse));
init_input_dev(&sermouse->dev);
sermouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
sermouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
sermouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
......
......@@ -120,6 +120,7 @@ static void gunze_connect(struct serio *serio, struct serio_dev *dev)
memset(gunze, 0, sizeof(struct gunze));
init_input_dev(&gunze->dev);
gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
gunze->dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
......
......@@ -371,6 +371,8 @@ static void h3600ts_connect(struct serio *serio, struct serio_dev *dev)
memset(ts, 0, sizeof(struct h3600_dev));
init_input_dev(&ts->dev);
/* Device specific stuff */
set_GPIO_IRQ_edge( GPIO_BITSY_ACTION_BUTTON, GPIO_BOTH_EDGES );
set_GPIO_IRQ_edge( GPIO_BITSY_NPOWER_BUTTON, GPIO_RISING_EDGE );
......
......@@ -479,6 +479,8 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
memset(adbhid[id], 0, sizeof(struct adbhid));
sprintf(adbhid[id]->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id);
init_input_dev(&adbhid[id]);
adbhid[id]->id = default_id;
adbhid[id]->original_handler_id = original_handler_id;
adbhid[id]->current_handler_id = current_handler_id;
......
......@@ -91,6 +91,8 @@ static void emumousebtn_input_register(void)
{
emumousebtn.name = "Macintosh mouse button emulation";
init_input_dev(&emumousebtn);
emumousebtn.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
emumousebtn.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
emumousebtn.relbit[0] = BIT(REL_X) | BIT(REL_Y);
......
......@@ -317,6 +317,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
}
init_MUTEX(&pm->lock);
init_input_dev(&pm->input);
/* get a handle to the interrupt data pipe */
pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
......
......@@ -744,6 +744,8 @@ struct ff_effect {
#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \
((dev->keycodesize == 1) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))
#define init_input_dev(dev) do { INIT_LIST_HEAD(&((dev)->h_list)); INIT_LIST_HEAD(&((dev)->node)); } while (0)
struct input_dev {
void *private;
......
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