提交 438c9da5 编写于 作者: D Dmitry Torokhov

Input: locomokbd - convert to dynamic input allocation

Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 7afada45
...@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { ...@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = {
struct locomokbd { struct locomokbd {
unsigned char keycode[LOCOMOKBD_NUMKEYS]; unsigned char keycode[LOCOMOKBD_NUMKEYS];
struct input_dev input; struct input_dev *input;
char phys[32]; char phys[32];
struct locomo_dev *ldev; struct locomo_dev *ldev;
...@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * ...@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
spin_lock_irqsave(&locomokbd->lock, flags); spin_lock_irqsave(&locomokbd->lock, flags);
if (regs) input_regs(locomokbd->input, regs);
input_regs(&locomokbd->input, regs);
locomokbd_charge_all(membase); locomokbd_charge_all(membase);
...@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * ...@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *
scancode = SCANCODE(col, row); scancode = SCANCODE(col, row);
if (rowd & KB_ROWMASK(row)) { if (rowd & KB_ROWMASK(row)) {
num_pressed += 1; num_pressed += 1;
input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 1); input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1);
} else { } else {
input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 0); input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0);
} }
} }
locomokbd_reset_col(membase, col); locomokbd_reset_col(membase, col);
} }
locomokbd_activate_all(membase); locomokbd_activate_all(membase);
input_sync(&locomokbd->input); input_sync(locomokbd->input);
/* if any keys are pressed, enable the timer */ /* if any keys are pressed, enable the timer */
if (num_pressed) if (num_pressed)
...@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data) ...@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data)
static int locomokbd_probe(struct locomo_dev *dev) static int locomokbd_probe(struct locomo_dev *dev)
{ {
struct locomokbd *locomokbd; struct locomokbd *locomokbd;
struct input_dev *input_dev;
int i, ret; int i, ret;
locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL);
if (!locomokbd) input_dev = input_allocate_device();
return -ENOMEM; if (!locomokbd || !input_dev) {
ret = -ENOMEM;
memset(locomokbd, 0, sizeof(struct locomokbd)); goto free;
}
/* try and claim memory region */ /* try and claim memory region */
if (!request_mem_region((unsigned long) dev->mapbase, if (!request_mem_region((unsigned long) dev->mapbase,
...@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev) ...@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev)
locomokbd->timer.function = locomokbd_timer_callback; locomokbd->timer.function = locomokbd_timer_callback;
locomokbd->timer.data = (unsigned long) locomokbd; locomokbd->timer.data = (unsigned long) locomokbd;
locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); locomokbd->input = input_dev;
strcpy(locomokbd->phys, "locomokbd/input0");
input_dev->name = "LoCoMo keyboard";
input_dev->phys = locomokbd->phys;
input_dev->id.bustype = BUS_XTKBD;
input_dev->id.vendor = 0x0001;
input_dev->id.product = 0x0001;
input_dev->id.version = 0x0100;
input_dev->private = locomokbd;
init_input_dev(&locomokbd->input); input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
locomokbd->input.keycode = locomokbd->keycode; input_dev->keycode = locomokbd->keycode;
locomokbd->input.keycodesize = sizeof(unsigned char); input_dev->keycodesize = sizeof(unsigned char);
locomokbd->input.keycodemax = ARRAY_SIZE(locomokbd_keycode); input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode);
locomokbd->input.private = locomokbd;
memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode));
for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) for (i = 0; i < LOCOMOKBD_NUMKEYS; i++)
set_bit(locomokbd->keycode[i], locomokbd->input.keybit); set_bit(locomokbd->keycode[i], input_dev->keybit);
clear_bit(0, locomokbd->input.keybit); clear_bit(0, input_dev->keybit);
strcpy(locomokbd->phys, "locomokbd/input0");
locomokbd->input.name = "LoCoMo keyboard";
locomokbd->input.phys = locomokbd->phys;
locomokbd->input.id.bustype = BUS_XTKBD;
locomokbd->input.id.vendor = 0x0001;
locomokbd->input.id.product = 0x0001;
locomokbd->input.id.version = 0x0100;
/* attempt to get the interrupt */ /* attempt to get the interrupt */
ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd);
...@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev) ...@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
goto out; goto out;
} }
input_register_device(&locomokbd->input); input_register_device(locomokbd->input);
printk(KERN_INFO "input: LoCoMo keyboard on locomokbd\n");
return 0; return 0;
...@@ -263,6 +261,7 @@ static int locomokbd_probe(struct locomo_dev *dev) ...@@ -263,6 +261,7 @@ static int locomokbd_probe(struct locomo_dev *dev)
release_mem_region((unsigned long) dev->mapbase, dev->length); release_mem_region((unsigned long) dev->mapbase, dev->length);
locomo_set_drvdata(dev, NULL); locomo_set_drvdata(dev, NULL);
free: free:
input_free_device(input_dev);
kfree(locomokbd); kfree(locomokbd);
return ret; return ret;
...@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev) ...@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev)
del_timer_sync(&locomokbd->timer); del_timer_sync(&locomokbd->timer);
input_unregister_device(&locomokbd->input); input_unregister_device(locomokbd->input);
locomo_set_drvdata(dev, NULL); locomo_set_drvdata(dev, NULL);
release_mem_region((unsigned long) dev->mapbase, dev->length); release_mem_region((unsigned long) dev->mapbase, dev->length);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册