diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/locomokbd.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 8935290256b3..a6ddd9472602 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c | |||
@@ -76,7 +76,7 @@ static unsigned char locomokbd_keycode[LOCOMOKBD_NUMKEYS] = { | |||
76 | 76 | ||
77 | struct locomokbd { | 77 | struct locomokbd { |
78 | unsigned char keycode[LOCOMOKBD_NUMKEYS]; | 78 | unsigned char keycode[LOCOMOKBD_NUMKEYS]; |
79 | struct input_dev input; | 79 | struct input_dev *input; |
80 | char phys[32]; | 80 | char phys[32]; |
81 | 81 | ||
82 | struct locomo_dev *ldev; | 82 | struct locomo_dev *ldev; |
@@ -136,8 +136,7 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * | |||
136 | 136 | ||
137 | spin_lock_irqsave(&locomokbd->lock, flags); | 137 | spin_lock_irqsave(&locomokbd->lock, flags); |
138 | 138 | ||
139 | if (regs) | 139 | input_regs(locomokbd->input, regs); |
140 | input_regs(&locomokbd->input, regs); | ||
141 | 140 | ||
142 | locomokbd_charge_all(membase); | 141 | locomokbd_charge_all(membase); |
143 | 142 | ||
@@ -152,16 +151,16 @@ static void locomokbd_scankeyboard(struct locomokbd *locomokbd, struct pt_regs * | |||
152 | scancode = SCANCODE(col, row); | 151 | scancode = SCANCODE(col, row); |
153 | if (rowd & KB_ROWMASK(row)) { | 152 | if (rowd & KB_ROWMASK(row)) { |
154 | num_pressed += 1; | 153 | num_pressed += 1; |
155 | input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 1); | 154 | input_report_key(locomokbd->input, locomokbd->keycode[scancode], 1); |
156 | } else { | 155 | } else { |
157 | input_report_key(&locomokbd->input, locomokbd->keycode[scancode], 0); | 156 | input_report_key(locomokbd->input, locomokbd->keycode[scancode], 0); |
158 | } | 157 | } |
159 | } | 158 | } |
160 | locomokbd_reset_col(membase, col); | 159 | locomokbd_reset_col(membase, col); |
161 | } | 160 | } |
162 | locomokbd_activate_all(membase); | 161 | locomokbd_activate_all(membase); |
163 | 162 | ||
164 | input_sync(&locomokbd->input); | 163 | input_sync(locomokbd->input); |
165 | 164 | ||
166 | /* if any keys are pressed, enable the timer */ | 165 | /* if any keys are pressed, enable the timer */ |
167 | if (num_pressed) | 166 | if (num_pressed) |
@@ -196,13 +195,15 @@ static void locomokbd_timer_callback(unsigned long data) | |||
196 | static int locomokbd_probe(struct locomo_dev *dev) | 195 | static int locomokbd_probe(struct locomo_dev *dev) |
197 | { | 196 | { |
198 | struct locomokbd *locomokbd; | 197 | struct locomokbd *locomokbd; |
198 | struct input_dev *input_dev; | ||
199 | int i, ret; | 199 | int i, ret; |
200 | 200 | ||
201 | locomokbd = kmalloc(sizeof(struct locomokbd), GFP_KERNEL); | 201 | locomokbd = kzalloc(sizeof(struct locomokbd), GFP_KERNEL); |
202 | if (!locomokbd) | 202 | input_dev = input_allocate_device(); |
203 | return -ENOMEM; | 203 | if (!locomokbd || !input_dev) { |
204 | 204 | ret = -ENOMEM; | |
205 | memset(locomokbd, 0, sizeof(struct locomokbd)); | 205 | goto free; |
206 | } | ||
206 | 207 | ||
207 | /* try and claim memory region */ | 208 | /* try and claim memory region */ |
208 | if (!request_mem_region((unsigned long) dev->mapbase, | 209 | if (!request_mem_region((unsigned long) dev->mapbase, |
@@ -224,27 +225,26 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
224 | locomokbd->timer.function = locomokbd_timer_callback; | 225 | locomokbd->timer.function = locomokbd_timer_callback; |
225 | locomokbd->timer.data = (unsigned long) locomokbd; | 226 | locomokbd->timer.data = (unsigned long) locomokbd; |
226 | 227 | ||
227 | locomokbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 228 | locomokbd->input = input_dev; |
229 | strcpy(locomokbd->phys, "locomokbd/input0"); | ||
230 | |||
231 | input_dev->name = "LoCoMo keyboard"; | ||
232 | input_dev->phys = locomokbd->phys; | ||
233 | input_dev->id.bustype = BUS_XTKBD; | ||
234 | input_dev->id.vendor = 0x0001; | ||
235 | input_dev->id.product = 0x0001; | ||
236 | input_dev->id.version = 0x0100; | ||
237 | input_dev->private = locomokbd; | ||
228 | 238 | ||
229 | init_input_dev(&locomokbd->input); | 239 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
230 | locomokbd->input.keycode = locomokbd->keycode; | 240 | input_dev->keycode = locomokbd->keycode; |
231 | locomokbd->input.keycodesize = sizeof(unsigned char); | 241 | input_dev->keycodesize = sizeof(unsigned char); |
232 | locomokbd->input.keycodemax = ARRAY_SIZE(locomokbd_keycode); | 242 | input_dev->keycodemax = ARRAY_SIZE(locomokbd_keycode); |
233 | locomokbd->input.private = locomokbd; | ||
234 | 243 | ||
235 | memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); | 244 | memcpy(locomokbd->keycode, locomokbd_keycode, sizeof(locomokbd->keycode)); |
236 | for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) | 245 | for (i = 0; i < LOCOMOKBD_NUMKEYS; i++) |
237 | set_bit(locomokbd->keycode[i], locomokbd->input.keybit); | 246 | set_bit(locomokbd->keycode[i], input_dev->keybit); |
238 | clear_bit(0, locomokbd->input.keybit); | 247 | clear_bit(0, input_dev->keybit); |
239 | |||
240 | strcpy(locomokbd->phys, "locomokbd/input0"); | ||
241 | |||
242 | locomokbd->input.name = "LoCoMo keyboard"; | ||
243 | locomokbd->input.phys = locomokbd->phys; | ||
244 | locomokbd->input.id.bustype = BUS_XTKBD; | ||
245 | locomokbd->input.id.vendor = 0x0001; | ||
246 | locomokbd->input.id.product = 0x0001; | ||
247 | locomokbd->input.id.version = 0x0100; | ||
248 | 248 | ||
249 | /* attempt to get the interrupt */ | 249 | /* attempt to get the interrupt */ |
250 | ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); | 250 | ret = request_irq(dev->irq[0], locomokbd_interrupt, 0, "locomokbd", locomokbd); |
@@ -253,9 +253,7 @@ static int locomokbd_probe(struct locomo_dev *dev) | |||
253 | goto out; | 253 | goto out; |
254 | } | 254 | } |
255 | 255 | ||
256 | input_register_device(&locomokbd->input); | 256 | input_register_device(locomokbd->input); |
257 | |||
258 | printk(KERN_INFO "input: LoCoMo keyboard on locomokbd\n"); | ||
259 | 257 | ||
260 | return 0; | 258 | return 0; |
261 | 259 | ||
@@ -263,6 +261,7 @@ out: | |||
263 | release_mem_region((unsigned long) dev->mapbase, dev->length); | 261 | release_mem_region((unsigned long) dev->mapbase, dev->length); |
264 | locomo_set_drvdata(dev, NULL); | 262 | locomo_set_drvdata(dev, NULL); |
265 | free: | 263 | free: |
264 | input_free_device(input_dev); | ||
266 | kfree(locomokbd); | 265 | kfree(locomokbd); |
267 | 266 | ||
268 | return ret; | 267 | return ret; |
@@ -276,7 +275,7 @@ static int locomokbd_remove(struct locomo_dev *dev) | |||
276 | 275 | ||
277 | del_timer_sync(&locomokbd->timer); | 276 | del_timer_sync(&locomokbd->timer); |
278 | 277 | ||
279 | input_unregister_device(&locomokbd->input); | 278 | input_unregister_device(locomokbd->input); |
280 | locomo_set_drvdata(dev, NULL); | 279 | locomo_set_drvdata(dev, NULL); |
281 | 280 | ||
282 | release_mem_region((unsigned long) dev->mapbase, dev->length); | 281 | release_mem_region((unsigned long) dev->mapbase, dev->length); |