diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-29 03:11:09 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-29 03:26:33 -0400 |
commit | 157d45fbdde4919c2b0421bb41d52fc8da155e28 (patch) | |
tree | 523dde74adadca13cd1343ff5e81f53a4b3178d0 | |
parent | ac414da37f88ddbc04617d883539113f27c75f56 (diff) |
Input: intel-mid-touch - switch to using managed resources
Let's switch the driver to use managed resources, this will simplify
error handling and driver unbinding logic.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/touchscreen/intel-mid-touch.c | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c index 4f6b156144e9..c38ca4a7e386 100644 --- a/drivers/input/touchscreen/intel-mid-touch.c +++ b/drivers/input/touchscreen/intel-mid-touch.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/irq.h> | 36 | #include <linux/irq.h> |
37 | #include <linux/delay.h> | 37 | #include <linux/delay.h> |
38 | #include <asm/intel_scu_ipc.h> | 38 | #include <asm/intel_scu_ipc.h> |
39 | #include <linux/device.h> | ||
39 | 40 | ||
40 | /* PMIC Interrupt registers */ | 41 | /* PMIC Interrupt registers */ |
41 | #define PMIC_REG_ID1 0x00 /* PMIC ID1 register */ | 42 | #define PMIC_REG_ID1 0x00 /* PMIC ID1 register */ |
@@ -580,12 +581,17 @@ static int mrstouch_probe(struct platform_device *pdev) | |||
580 | return -EINVAL; | 581 | return -EINVAL; |
581 | } | 582 | } |
582 | 583 | ||
583 | tsdev = kzalloc(sizeof(struct mrstouch_dev), GFP_KERNEL); | 584 | tsdev = devm_kzalloc(&pdev->dev, sizeof(struct mrstouch_dev), |
584 | input = input_allocate_device(); | 585 | GFP_KERNEL); |
585 | if (!tsdev || !input) { | 586 | if (!tsdev) { |
586 | dev_err(&pdev->dev, "unable to allocate memory\n"); | 587 | dev_err(&pdev->dev, "unable to allocate memory\n"); |
587 | err = -ENOMEM; | 588 | return -ENOMEM; |
588 | goto err_free_mem; | 589 | } |
590 | |||
591 | input = devm_input_allocate_device(&pdev->dev); | ||
592 | if (!input) { | ||
593 | dev_err(&pdev->dev, "unable to allocate input device\n"); | ||
594 | return -ENOMEM; | ||
589 | } | 595 | } |
590 | 596 | ||
591 | tsdev->dev = &pdev->dev; | 597 | tsdev->dev = &pdev->dev; |
@@ -598,7 +604,7 @@ static int mrstouch_probe(struct platform_device *pdev) | |||
598 | err = mrstouch_adc_init(tsdev); | 604 | err = mrstouch_adc_init(tsdev); |
599 | if (err) { | 605 | if (err) { |
600 | dev_err(&pdev->dev, "ADC initialization failed\n"); | 606 | dev_err(&pdev->dev, "ADC initialization failed\n"); |
601 | goto err_free_mem; | 607 | return err; |
602 | } | 608 | } |
603 | 609 | ||
604 | input->name = "mrst_touchscreen"; | 610 | input->name = "mrst_touchscreen"; |
@@ -618,38 +624,20 @@ static int mrstouch_probe(struct platform_device *pdev) | |||
618 | input_set_abs_params(tsdev->input, ABS_PRESSURE, | 624 | input_set_abs_params(tsdev->input, ABS_PRESSURE, |
619 | MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0); | 625 | MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0); |
620 | 626 | ||
621 | err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq, | 627 | err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL, |
622 | IRQF_ONESHOT, "mrstouch", tsdev); | 628 | mrstouch_pendet_irq, IRQF_ONESHOT, |
629 | "mrstouch", tsdev); | ||
623 | if (err) { | 630 | if (err) { |
624 | dev_err(tsdev->dev, "unable to allocate irq\n"); | 631 | dev_err(tsdev->dev, "unable to allocate irq\n"); |
625 | goto err_free_mem; | 632 | return err; |
626 | } | 633 | } |
627 | 634 | ||
628 | err = input_register_device(tsdev->input); | 635 | err = input_register_device(tsdev->input); |
629 | if (err) { | 636 | if (err) { |
630 | dev_err(tsdev->dev, "unable to register input device\n"); | 637 | dev_err(tsdev->dev, "unable to register input device\n"); |
631 | goto err_free_irq; | 638 | return err; |
632 | } | 639 | } |
633 | 640 | ||
634 | platform_set_drvdata(pdev, tsdev); | ||
635 | return 0; | ||
636 | |||
637 | err_free_irq: | ||
638 | free_irq(tsdev->irq, tsdev); | ||
639 | err_free_mem: | ||
640 | input_free_device(input); | ||
641 | kfree(tsdev); | ||
642 | return err; | ||
643 | } | ||
644 | |||
645 | static int mrstouch_remove(struct platform_device *pdev) | ||
646 | { | ||
647 | struct mrstouch_dev *tsdev = platform_get_drvdata(pdev); | ||
648 | |||
649 | free_irq(tsdev->irq, tsdev); | ||
650 | input_unregister_device(tsdev->input); | ||
651 | kfree(tsdev); | ||
652 | |||
653 | return 0; | 641 | return 0; |
654 | } | 642 | } |
655 | 643 | ||
@@ -659,7 +647,6 @@ static struct platform_driver mrstouch_driver = { | |||
659 | .owner = THIS_MODULE, | 647 | .owner = THIS_MODULE, |
660 | }, | 648 | }, |
661 | .probe = mrstouch_probe, | 649 | .probe = mrstouch_probe, |
662 | .remove = mrstouch_remove, | ||
663 | }; | 650 | }; |
664 | module_platform_driver(mrstouch_driver); | 651 | module_platform_driver(mrstouch_driver); |
665 | 652 | ||