Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Himangi Saraogi and committed by
Dmitry Torokhov
157d45fb ac414da3

+17 -30
+17 -30
drivers/input/touchscreen/intel-mid-touch.c
··· 36 36 #include <linux/irq.h> 37 37 #include <linux/delay.h> 38 38 #include <asm/intel_scu_ipc.h> 39 + #include <linux/device.h> 39 40 40 41 /* PMIC Interrupt registers */ 41 42 #define PMIC_REG_ID1 0x00 /* PMIC ID1 register */ ··· 581 580 return -EINVAL; 582 581 } 583 582 584 - tsdev = kzalloc(sizeof(struct mrstouch_dev), GFP_KERNEL); 585 - input = input_allocate_device(); 586 - if (!tsdev || !input) { 583 + tsdev = devm_kzalloc(&pdev->dev, sizeof(struct mrstouch_dev), 584 + GFP_KERNEL); 585 + if (!tsdev) { 587 586 dev_err(&pdev->dev, "unable to allocate memory\n"); 588 - err = -ENOMEM; 589 - goto err_free_mem; 587 + return -ENOMEM; 588 + } 589 + 590 + input = devm_input_allocate_device(&pdev->dev); 591 + if (!input) { 592 + dev_err(&pdev->dev, "unable to allocate input device\n"); 593 + return -ENOMEM; 590 594 } 591 595 592 596 tsdev->dev = &pdev->dev; ··· 604 598 err = mrstouch_adc_init(tsdev); 605 599 if (err) { 606 600 dev_err(&pdev->dev, "ADC initialization failed\n"); 607 - goto err_free_mem; 601 + return err; 608 602 } 609 603 610 604 input->name = "mrst_touchscreen"; ··· 624 618 input_set_abs_params(tsdev->input, ABS_PRESSURE, 625 619 MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0); 626 620 627 - err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq, 628 - IRQF_ONESHOT, "mrstouch", tsdev); 621 + err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL, 622 + mrstouch_pendet_irq, IRQF_ONESHOT, 623 + "mrstouch", tsdev); 629 624 if (err) { 630 625 dev_err(tsdev->dev, "unable to allocate irq\n"); 631 - goto err_free_mem; 626 + return err; 632 627 } 633 628 634 629 err = input_register_device(tsdev->input); 635 630 if (err) { 636 631 dev_err(tsdev->dev, "unable to register input device\n"); 637 - goto err_free_irq; 632 + return err; 638 633 } 639 - 640 - platform_set_drvdata(pdev, tsdev); 641 - return 0; 642 - 643 - err_free_irq: 644 - free_irq(tsdev->irq, tsdev); 645 - err_free_mem: 646 - input_free_device(input); 647 - kfree(tsdev); 648 - return err; 649 - } 650 - 651 - static int mrstouch_remove(struct platform_device *pdev) 652 - { 653 - struct mrstouch_dev *tsdev = platform_get_drvdata(pdev); 654 - 655 - free_irq(tsdev->irq, tsdev); 656 - input_unregister_device(tsdev->input); 657 - kfree(tsdev); 658 634 659 635 return 0; 660 636 } ··· 647 659 .owner = THIS_MODULE, 648 660 }, 649 661 .probe = mrstouch_probe, 650 - .remove = mrstouch_remove, 651 662 }; 652 663 module_platform_driver(mrstouch_driver); 653 664