aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/spitzkbd.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:45 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:52 -0400
commit3c42f0c3dde8feb59fc87df45cadb847d5511c0a (patch)
treee4f9f644473c3d9c7fe78f5df68bc42c8fa5850e /drivers/input/keyboard/spitzkbd.c
parent2e5b636bb5f8dacbb91d08544e2c41ebcad5dace (diff)
[PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation
Input: convert drivers/input/keyboard to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/keyboard/spitzkbd.c')
-rw-r--r--drivers/input/keyboard/spitzkbd.c79
1 files changed, 45 insertions, 34 deletions
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 344f46005401..732fb310e487 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -85,7 +85,7 @@ static int spitz_senses[] = {
85 85
86struct spitzkbd { 86struct spitzkbd {
87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; 87 unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)];
88 struct input_dev input; 88 struct input_dev *input;
89 char phys[32]; 89 char phys[32];
90 90
91 spinlock_t lock; 91 spinlock_t lock;
@@ -187,8 +187,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
187 187
188 spin_lock_irqsave(&spitzkbd_data->lock, flags); 188 spin_lock_irqsave(&spitzkbd_data->lock, flags);
189 189
190 if (regs) 190 input_regs(spitzkbd_data->input, regs);
191 input_regs(&spitzkbd_data->input, regs);
192 191
193 num_pressed = 0; 192 num_pressed = 0;
194 for (col = 0; col < KB_COLS; col++) { 193 for (col = 0; col < KB_COLS; col++) {
@@ -210,7 +209,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
210 scancode = SCANCODE(row, col); 209 scancode = SCANCODE(row, col);
211 pressed = rowd & KB_ROWMASK(row); 210 pressed = rowd & KB_ROWMASK(row);
212 211
213 input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); 212 input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed);
214 213
215 if (pressed) 214 if (pressed)
216 num_pressed++; 215 num_pressed++;
@@ -220,15 +219,15 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs
220 219
221 spitzkbd_activate_all(); 220 spitzkbd_activate_all();
222 221
223 input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); 222 input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 );
224 input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey); 223 input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey);
225 224
226 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { 225 if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) {
227 input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); 226 input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1);
228 spitzkbd_data->suspend_jiffies = jiffies; 227 spitzkbd_data->suspend_jiffies = jiffies;
229 } 228 }
230 229
231 input_sync(&spitzkbd_data->input); 230 input_sync(spitzkbd_data->input);
232 231
233 /* if any keys are pressed, enable the timer */ 232 /* if any keys are pressed, enable the timer */
234 if (num_pressed) 233 if (num_pressed)
@@ -259,6 +258,7 @@ static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *reg
259static void spitzkbd_timer_callback(unsigned long data) 258static void spitzkbd_timer_callback(unsigned long data)
260{ 259{
261 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; 260 struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data;
261
262 spitzkbd_scankeyboard(spitzkbd_data, NULL); 262 spitzkbd_scankeyboard(spitzkbd_data, NULL);
263} 263}
264 264
@@ -298,9 +298,9 @@ static void spitzkbd_hinge_timer(unsigned long data)
298 if (hinge_count >= HINGE_STABLE_COUNT) { 298 if (hinge_count >= HINGE_STABLE_COUNT) {
299 spin_lock_irqsave(&spitzkbd_data->lock, flags); 299 spin_lock_irqsave(&spitzkbd_data->lock, flags);
300 300
301 input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); 301 input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0));
302 input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); 302 input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0));
303 input_sync(&spitzkbd_data->input); 303 input_sync(spitzkbd_data->input);
304 304
305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags); 305 spin_unlock_irqrestore(&spitzkbd_data->lock, flags);
306 } else { 306 } else {
@@ -346,14 +346,21 @@ static int spitzkbd_resume(struct device *dev, uint32_t level)
346 346
347static int __init spitzkbd_probe(struct device *dev) 347static int __init spitzkbd_probe(struct device *dev)
348{ 348{
349 int i;
350 struct spitzkbd *spitzkbd; 349 struct spitzkbd *spitzkbd;
350 struct input_dev *input_dev;
351 int i;
351 352
352 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); 353 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
353 if (!spitzkbd) 354 if (!spitzkbd)
354 return -ENOMEM; 355 return -ENOMEM;
355 356
356 dev_set_drvdata(dev,spitzkbd); 357 input_dev = input_allocate_device();
358 if (!input_dev) {
359 kfree(spitzkbd);
360 return -ENOMEM;
361 }
362
363 dev_set_drvdata(dev, spitzkbd);
357 strcpy(spitzkbd->phys, "spitzkbd/input0"); 364 strcpy(spitzkbd->phys, "spitzkbd/input0");
358 365
359 spin_lock_init(&spitzkbd->lock); 366 spin_lock_init(&spitzkbd->lock);
@@ -368,30 +375,34 @@ static int __init spitzkbd_probe(struct device *dev)
368 spitzkbd->htimer.function = spitzkbd_hinge_timer; 375 spitzkbd->htimer.function = spitzkbd_hinge_timer;
369 spitzkbd->htimer.data = (unsigned long) spitzkbd; 376 spitzkbd->htimer.data = (unsigned long) spitzkbd;
370 377
371 spitzkbd->suspend_jiffies=jiffies; 378 spitzkbd->suspend_jiffies = jiffies;
372 379
373 init_input_dev(&spitzkbd->input); 380 spitzkbd->input = input_dev;
374 spitzkbd->input.private = spitzkbd; 381
375 spitzkbd->input.name = "Spitz Keyboard"; 382 input_dev->private = spitzkbd;
376 spitzkbd->input.dev = dev; 383 input_dev->name = "Spitz Keyboard";
377 spitzkbd->input.phys = spitzkbd->phys; 384 input_dev->phys = spitzkbd->phys;
378 spitzkbd->input.id.bustype = BUS_HOST; 385 input_dev->cdev.dev = dev;
379 spitzkbd->input.id.vendor = 0x0001; 386
380 spitzkbd->input.id.product = 0x0001; 387 input_dev->id.bustype = BUS_HOST;
381 spitzkbd->input.id.version = 0x0100; 388 input_dev->id.vendor = 0x0001;
382 spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); 389 input_dev->id.product = 0x0001;
383 spitzkbd->input.keycode = spitzkbd->keycode; 390 input_dev->id.version = 0x0100;
384 spitzkbd->input.keycodesize = sizeof(unsigned char); 391
385 spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode); 392 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
393 input_dev->keycode = spitzkbd->keycode;
394 input_dev->keycodesize = sizeof(unsigned char);
395 input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode);
386 396
387 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); 397 memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode));
388 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) 398 for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++)
389 set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit); 399 set_bit(spitzkbd->keycode[i], input_dev->keybit);
390 clear_bit(0, spitzkbd->input.keybit); 400 clear_bit(0, input_dev->keybit);
391 set_bit(SW_0, spitzkbd->input.swbit); 401 set_bit(SW_0, input_dev->swbit);
392 set_bit(SW_1, spitzkbd->input.swbit); 402 set_bit(SW_1, input_dev->swbit);
403
404 input_register_device(input_dev);
393 405
394 input_register_device(&spitzkbd->input);
395 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); 406 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
396 407
397 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ 408 /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */
@@ -444,7 +455,7 @@ static int spitzkbd_remove(struct device *dev)
444 del_timer_sync(&spitzkbd->htimer); 455 del_timer_sync(&spitzkbd->htimer);
445 del_timer_sync(&spitzkbd->timer); 456 del_timer_sync(&spitzkbd->timer);
446 457
447 input_unregister_device(&spitzkbd->input); 458 input_unregister_device(spitzkbd->input);
448 459
449 kfree(spitzkbd); 460 kfree(spitzkbd);
450 461