X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Finput%2Fkeyboard%2Flocomokbd.c;fp=drivers%2Finput%2Fkeyboard%2Flocomokbd.c;h=2c510881874ab70e5827bee15619286872542ed4;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=d3e9dd6a13cdc8236010765c56e12b648c16fe31;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index d3e9dd6a1..2c5108818 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -42,7 +42,7 @@ MODULE_AUTHOR("John Lenz "); MODULE_DESCRIPTION("LoCoMo keyboard driver"); MODULE_LICENSE("GPL"); -#define LOCOMOKBD_NUMKEYS 128 +#define LOCOMOKBD_NUMKEYS 128 #define KEY_ACTIVITY KEY_F16 #define KEY_CONTACT KEY_F18 @@ -61,7 +61,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { KEY_G, KEY_F, KEY_X, KEY_S, 0, 0, 0, 0, 0, 0, /* 90 - 99 */ 0, 0, KEY_DOT, 0, KEY_COMMA, KEY_N, KEY_B, KEY_C, KEY_Z, KEY_A, /* 100 - 109 */ KEY_LEFTSHIFT, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, 0, 0, /* 110 - 119 */ - KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ + KEY_M, KEY_SPACE, KEY_V, KEY_APOSTROPHE, KEY_SLASH, 0, 0, 0 /* 120 - 128 */ }; #define KB_ROWS 16 @@ -76,13 +76,13 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { struct locomokbd { unsigned char keycode[LOCOMOKBD_NUMKEYS]; - struct input_dev input; + struct input_dev *input; char phys[32]; struct locomo_dev *ldev; unsigned long base; spinlock_t lock; - + struct timer_list timer; }; @@ -95,7 +95,7 @@ static inline void locomokbd_charge_all(unsigned long membase) static inline void locomokbd_activate_all(unsigned long membase) { unsigned long r; - + locomo_writel(0, membase + LOCOMO_KSC); r = locomo_readl(membase + LOCOMO_KIC); r &= 0xFEFF; @@ -127,7 +127,7 @@ static inline void locomokbd_reset_col(unsigned long membase, int col) */ /* Scan the hardware keyboard and push any changes up through the input layer */ -static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) +static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs *regs) { unsigned int row, col, rowd, scancode; unsigned long flags; @@ -136,9 +136,8 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * spin_lock_irqsave(&locomokbd->lock, flags); - if (regs) - input_regs(&locomokbd->input, regs); - + input_regs(locomokbd->input, regs); + locomokbd_charge_all(membase); num_pressed = 0; @@ -146,22 +145,22 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * locomokbd_activate_col(membase, col); udelay(KB_DELAY); - + rowd = ~locomo_readl(membase + LOCOMO_KIB); - for (row = 0; row < KB_ROWS; row++ ) { + for (row = 0; row < KB_ROWS; row++) { scancode = SCANCODE(col, row); if (rowd & KB_ROWMASK(row)) { num_pressed += 1; - input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 1); + input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1); } 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_activate_all(membase); - input_sync(&locomokbd->input); + input_sync(locomokbd->input); /* if any keys are pressed, enable the timer */ if (num_pressed) @@ -170,7 +169,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * spin_unlock_irqrestore(&locomokbd->lock, flags); } -/* +/* * LoCoMo keyboard interrupt handler. */ static irqreturn_t locomokbd_interrupt(int irq, void *dev_id, struct pt_regs *regs) @@ -196,17 +195,19 @@ static void locomokbd_timer_callback(unsigned long data) static int locomokbd_probe(struct locomo_dev *dev) { struct locomokbd *locomokbd; + struct input_dev *input_dev; int i, ret; - locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); - if (!locomokbd) - return -ENOMEM; - - memset(locomokbd, 0, sizeof(struct locomokbd)); + locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); + input_dev = input_allocate_device(); + if (!locomokbd || !input_dev) { + ret = -ENOMEM; + goto free; + } /* try and claim memory region */ - if (!request_mem_region((unsigned long) dev->mapbase, - dev->length, + if (!request_mem_region((unsigned long) dev->mapbase, + dev->length, LOCOMO_DRIVER_NAME(dev))) { ret = -EBUSY; printk(KERN_ERR "locomokbd: Can't acquire access to io memory for keyboard\n"); @@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev) locomokbd->timer.function = locomokbd_timer_callback; locomokbd->timer.data = (unsigned long) locomokbd; - locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); - - init_input_dev(&locomokbd->input); - locomokbd->input.keycode = locomokbd->keycode; - locomokbd->input.keycodesize = sizeof(unsigned char); - locomokbd->input.keycodemax = ARRAY_SIZE(locomokbd_keycode); - locomokbd->input.private = locomokbd; + locomokbd->input = input_dev; + strcpy(locomokbd->phys, "locomokbd/input0"); - memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); - for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) - set_bit(locomokbd->keycode[i], locomokbd->input.keybit); - clear_bit(0, locomokbd->input.keybit); + input_dev->name = "LoCoMo keyboard"; + input_dev->phys = locomokbd->phys; + input_dev->id.bustype = BUS_HOST; + input_dev->id.vendor = 0x0001; + input_dev->id.product = 0x0001; + input_dev->id.version = 0x0100; + input_dev->private = locomokbd; - strcpy(locomokbd->phys, "locomokbd/input0"); + input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); + input_dev->keycode = locomokbd->keycode; + input_dev->keycodesize = sizeof(unsigned char); + input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); - 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; + memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); + for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) + set_bit(locomokbd->keycode[i], input_dev->keybit); + clear_bit(0, input_dev->keybit); /* attempt to get the interrupt */ ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); @@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev) goto out; } - input_register_device(&locomokbd->input); - - printk(KERN_INFO "input: LoCoMo keyboard on locomokbd\n"); + input_register_device(locomokbd->input); return 0; @@ -263,6 +261,7 @@ out: release_mem_region((unsigned long) dev->mapbase, dev->length); locomo_set_drvdata(dev, NULL); free: + input_free_device(input_dev); kfree(locomokbd); return ret; @@ -271,12 +270,12 @@ free: static int locomokbd_remove(struct locomo_dev *dev) { struct locomokbd *locomokbd = locomo_get_drvdata(dev); - + free_irq(dev->irq[0], locomokbd); del_timer_sync(&locomokbd->timer); - - input_unregister_device(&locomokbd->input); + + input_unregister_device(locomokbd->input); locomo_set_drvdata(dev, NULL); release_mem_region((unsigned long) dev->mapbase, dev->length);