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

ALSA: cmi8330: Allocate resources with device-managed APIs

This patch converts the resource management in ISA cmi8330 driver with
devres as a clean up. Each manual resource management is converted
with the corresponding devres helper. The remove callback became
superfluous and dropped.

This should give no user-visible functional changes.

Link: https://lore.kernel.org/r/20210715075941.23332-61-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+4 -23
+4 -23
sound/isa/cmi8330.c
··· 507 507 struct snd_cmi8330 *acard; 508 508 int err; 509 509 510 - err = snd_card_new(pdev, index[dev], id[dev], THIS_MODULE, 511 - sizeof(struct snd_cmi8330), &card); 510 + err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE, 511 + sizeof(struct snd_cmi8330), &card); 512 512 if (err < 0) { 513 513 snd_printk(KERN_ERR PFX "could not get a new card\n"); 514 514 return err; ··· 629 629 if (err < 0) 630 630 return err; 631 631 err = snd_cmi8330_probe(card, dev); 632 - if (err < 0) { 633 - snd_card_free(card); 632 + if (err < 0) 634 633 return err; 635 - } 636 634 dev_set_drvdata(pdev, card); 637 635 return 0; 638 - } 639 - 640 - static void snd_cmi8330_isa_remove(struct device *devptr, 641 - unsigned int dev) 642 - { 643 - snd_card_free(dev_get_drvdata(devptr)); 644 636 } 645 637 646 638 #ifdef CONFIG_PM ··· 653 661 static struct isa_driver snd_cmi8330_driver = { 654 662 .match = snd_cmi8330_isa_match, 655 663 .probe = snd_cmi8330_isa_probe, 656 - .remove = snd_cmi8330_isa_remove, 657 664 #ifdef CONFIG_PM 658 665 .suspend = snd_cmi8330_isa_suspend, 659 666 .resume = snd_cmi8330_isa_resume, ··· 684 693 res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid); 685 694 if (res < 0) { 686 695 snd_printk(KERN_ERR PFX "PnP detection failed\n"); 687 - snd_card_free(card); 688 696 return res; 689 697 } 690 698 res = snd_cmi8330_probe(card, dev); 691 - if (res < 0) { 692 - snd_card_free(card); 699 + if (res < 0) 693 700 return res; 694 - } 695 701 pnp_set_card_drvdata(pcard, card); 696 702 dev++; 697 703 return 0; 698 - } 699 - 700 - static void snd_cmi8330_pnp_remove(struct pnp_card_link *pcard) 701 - { 702 - snd_card_free(pnp_get_card_drvdata(pcard)); 703 - pnp_set_card_drvdata(pcard, NULL); 704 704 } 705 705 706 706 #ifdef CONFIG_PM ··· 711 729 .name = "cmi8330", 712 730 .id_table = snd_cmi8330_pnpids, 713 731 .probe = snd_cmi8330_pnp_detect, 714 - .remove = snd_cmi8330_pnp_remove, 715 732 #ifdef CONFIG_PM 716 733 .suspend = snd_cmi8330_pnp_suspend, 717 734 .resume = snd_cmi8330_pnp_resume,