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

Input: tsc2005 - convert driver to use devm_*

Simplify the driver by using managed resources for memory allocation of
internal structure, input device allocation and irq request.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Sebastian Reichel and committed by
Dmitry Torokhov
99e8325f 6e51c857

+14 -23
+14 -23
drivers/input/touchscreen/tsc2005.c
··· 604 604 if (error) 605 605 return error; 606 606 607 - ts = kzalloc(sizeof(*ts), GFP_KERNEL); 608 - input_dev = input_allocate_device(); 609 - if (!ts || !input_dev) { 610 - error = -ENOMEM; 611 - goto err_free_mem; 612 - } 607 + ts = devm_kzalloc(&spi->dev, sizeof(*ts), GFP_KERNEL); 608 + if (!ts) 609 + return -ENOMEM; 610 + 611 + input_dev = devm_input_allocate_device(&spi->dev); 612 + if (!input_dev) 613 + return -ENOMEM; 613 614 614 615 ts->spi = spi; 615 616 ts->idev = input_dev; ··· 650 649 /* Ensure the touchscreen is off */ 651 650 tsc2005_stop_scan(ts); 652 651 653 - error = request_threaded_irq(spi->irq, NULL, tsc2005_irq_thread, 654 - IRQF_TRIGGER_RISING | IRQF_ONESHOT, 655 - "tsc2005", ts); 652 + error = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, 653 + tsc2005_irq_thread, 654 + IRQF_TRIGGER_RISING | IRQF_ONESHOT, 655 + "tsc2005", ts); 656 656 if (error) { 657 657 dev_err(&spi->dev, "Failed to request irq, err: %d\n", error); 658 - goto err_free_mem; 658 + return error; 659 659 } 660 660 661 661 spi_set_drvdata(spi, ts); ··· 664 662 if (error) { 665 663 dev_err(&spi->dev, 666 664 "Failed to create sysfs attributes, err: %d\n", error); 667 - goto err_clear_drvdata; 665 + return error; 668 666 } 669 667 670 668 error = input_register_device(ts->idev); ··· 679 677 680 678 err_remove_sysfs: 681 679 sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group); 682 - err_clear_drvdata: 683 - free_irq(spi->irq, ts); 684 - err_free_mem: 685 - input_free_device(input_dev); 686 - kfree(ts); 687 680 return error; 688 681 } 689 682 690 683 static int tsc2005_remove(struct spi_device *spi) 691 684 { 692 - struct tsc2005 *ts = spi_get_drvdata(spi); 693 - 694 - sysfs_remove_group(&ts->spi->dev.kobj, &tsc2005_attr_group); 695 - 696 - free_irq(ts->spi->irq, ts); 697 - input_unregister_device(ts->idev); 698 - kfree(ts); 685 + sysfs_remove_group(&spi->dev.kobj, &tsc2005_attr_group); 699 686 700 687 return 0; 701 688 }