aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/spitzkbd.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:39:56 -0500
committerDmitry Torokhov <dtor@insightbb.com>2006-11-05 22:39:56 -0500
commit2b03b60e6b8635fffdd15d5d24943950f2bbf96e (patch)
tree17f0354b7edb08920a89e663ef724c84518c49fa /drivers/input/keyboard/spitzkbd.c
parent41ad5fbabda0c3930136bb40cfc7a0c23013365f (diff)
Input: keyboards - handle errors when registering input devices
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/spitzkbd.c')
-rw-r--r--drivers/input/keyboard/spitzkbd.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 28b2748e82d0..8a2166c77ff4 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -346,17 +346,12 @@ static int __init spitzkbd_probe(struct platform_device *dev)
346{ 346{
347 struct spitzkbd *spitzkbd; 347 struct spitzkbd *spitzkbd;
348 struct input_dev *input_dev; 348 struct input_dev *input_dev;
349 int i; 349 int i, err = -ENOMEM;
350 350
351 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); 351 spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL);
352 if (!spitzkbd)
353 return -ENOMEM;
354
355 input_dev = input_allocate_device(); 352 input_dev = input_allocate_device();
356 if (!input_dev) { 353 if (!spitzkbd || !input_dev)
357 kfree(spitzkbd); 354 goto fail;
358 return -ENOMEM;
359 }
360 355
361 platform_set_drvdata(dev, spitzkbd); 356 platform_set_drvdata(dev, spitzkbd);
362 strcpy(spitzkbd->phys, "spitzkbd/input0"); 357 strcpy(spitzkbd->phys, "spitzkbd/input0");
@@ -400,7 +395,9 @@ static int __init spitzkbd_probe(struct platform_device *dev)
400 set_bit(SW_TABLET_MODE, input_dev->swbit); 395 set_bit(SW_TABLET_MODE, input_dev->swbit);
401 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit); 396 set_bit(SW_HEADPHONE_INSERT, input_dev->swbit);
402 397
403 input_register_device(input_dev); 398 err = input_register_device(input_dev);
399 if (err)
400 goto fail;
404 401
405 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); 402 mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL));
406 403
@@ -434,13 +431,15 @@ static int __init spitzkbd_probe(struct platform_device *dev)
434 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr, 431 request_irq(SPITZ_IRQ_GPIO_SWB, spitzkbd_hinge_isr,
435 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 432 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
436 "Spitzkbd SWB", spitzkbd); 433 "Spitzkbd SWB", spitzkbd);
437 request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr, 434 request_irq(SPITZ_IRQ_GPIO_AK_INT, spitzkbd_hinge_isr,
438 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 435 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
439 "Spitzkbd HP", spitzkbd); 436 "Spitzkbd HP", spitzkbd);
440 437
441 printk(KERN_INFO "input: Spitz Keyboard Registered\n");
442
443 return 0; 438 return 0;
439
440 fail: input_free_device(input_dev);
441 kfree(spitzkbd);
442 return err;
444} 443}
445 444
446static int spitzkbd_remove(struct platform_device *dev) 445static int spitzkbd_remove(struct platform_device *dev)
@@ -474,6 +473,7 @@ static struct platform_driver spitzkbd_driver = {
474 .resume = spitzkbd_resume, 473 .resume = spitzkbd_resume,
475 .driver = { 474 .driver = {
476 .name = "spitz-keyboard", 475 .name = "spitz-keyboard",
476 .owner = THIS_MODULE,
477 }, 477 },
478}; 478};
479 479