Changeset 717 for GPL/trunk/alsa-kernel/pci/bt87x.c
- Timestamp:
- Aug 7, 2022, 6:11:12 PM (3 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 710-716
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/bt87x.c
r703 r717 666 666 }; 667 667 668 static int snd_bt87x_free(struct snd_bt87x *chip) 669 { 670 if (chip->mmio) 671 snd_bt87x_stop(chip); 672 if (chip->irq >= 0) 673 free_irq(chip->irq, chip); 674 iounmap(chip->mmio); 675 pci_release_regions(chip->pci); 676 pci_disable_device(chip->pci); 677 kfree(chip); 678 return 0; 679 } 680 681 static int snd_bt87x_dev_free(struct snd_device *device) 682 { 683 struct snd_bt87x *chip = device->device_data; 684 return snd_bt87x_free(chip); 668 static void snd_bt87x_free(struct snd_card *card) 669 { 670 struct snd_bt87x *chip = card->private_data; 671 672 snd_bt87x_stop(chip); 685 673 } 686 674 … … 704 692 705 693 static int snd_bt87x_create(struct snd_card *card, 706 struct pci_dev *pci, 707 struct snd_bt87x **rchip) 708 { 709 struct snd_bt87x *chip; 694 struct pci_dev *pci) 695 { 696 struct snd_bt87x *chip = card->private_data; 710 697 int err; 711 static const struct snd_device_ops ops = { 712 .dev_free = snd_bt87x_dev_free 713 }; 714 715 *rchip = NULL; 716 717 err = pci_enable_device(pci); 698 699 err = pcim_enable_device(pci); 718 700 if (err < 0) 719 701 return err; 720 702 721 chip = kzalloc(sizeof(*chip), GFP_KERNEL);722 if (!chip) {723 pci_disable_device(pci);724 return -ENOMEM;725 }726 703 chip->card = card; 727 704 chip->pci = pci; … … 729 706 spin_lock_init(&chip->reg_lock); 730 707 708 #ifndef TARGET_OS2 709 err = pcim_iomap_regions(pci, 1 << 0, "Bt87x audio"); 710 if (err < 0) 711 return err; 712 chip->mmio = pcim_iomap_table(pci)[0]; 713 #else 731 714 err = pci_request_regions(pci, "Bt87x audio"); 732 715 if (err < 0) { … … 736 719 } 737 720 chip->mmio = pci_ioremap_bar(pci, 0); 738 if (!chip->mmio) { 739 dev_err(card->dev, "cannot remap io memory\n"); 740 err = -ENOMEM; 741 goto fail; 742 } 743 721 #endif 744 722 chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 | 745 723 CTL_PKTP_16 | (15 << CTL_DA_SDR_SHIFT); … … 749 727 snd_bt87x_writel(chip, REG_INT_STAT, MY_INTERRUPTS); 750 728 751 err = request_irq(pci->irq, snd_bt87x_interrupt, IRQF_SHARED,752 KBUILD_MODNAME, chip);729 err = devm_request_irq(&pci->dev, pci->irq, snd_bt87x_interrupt, 730 IRQF_SHARED, KBUILD_MODNAME, chip); 753 731 if (err < 0) { 754 732 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); 755 goto fail;733 return err; 756 734 } 757 735 chip->irq = pci->irq; 758 736 card->sync_irq = chip->irq; 737 card->private_free = snd_bt87x_free; 759 738 pci_set_master(pci); 760 739 761 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 762 if (err < 0) 763 goto fail; 764 765 *rchip = chip; 766 return 0; 767 768 fail: 769 snd_bt87x_free(chip); 770 return err; 740 return 0; 771 741 } 772 742 … … 854 824 } 855 825 856 static int snd_bt87x_probe(struct pci_dev *pci,857 const struct pci_device_id *pci_id)826 static int __snd_bt87x_probe(struct pci_dev *pci, 827 const struct pci_device_id *pci_id) 858 828 { 859 829 static int dev; … … 878 848 } 879 849 880 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,881 0, &card);850 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 851 sizeof(*chip), &card); 882 852 if (err < 0) 883 853 return err; 884 885 err = snd_bt87x_create(card, pci, &chip); 854 chip = card->private_data; 855 856 err = snd_bt87x_create(card, pci); 886 857 if (err < 0) 887 goto _error;858 return err; 888 859 889 860 memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board)); … … 897 868 err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital"); 898 869 if (err < 0) 899 goto _error;870 return err; 900 871 } 901 872 if (!chip->board.no_analog) { 902 873 err = snd_bt87x_pcm(chip, DEVICE_ANALOG, "Bt87x Analog"); 903 874 if (err < 0) 904 goto _error;875 return err; 905 876 err = snd_ctl_add(card, snd_ctl_new1( 906 877 &snd_bt87x_capture_volume, chip)); 907 878 if (err < 0) 908 goto _error;879 return err; 909 880 err = snd_ctl_add(card, snd_ctl_new1( 910 881 &snd_bt87x_capture_boost, chip)); 911 882 if (err < 0) 912 goto _error;883 return err; 913 884 err = snd_ctl_add(card, snd_ctl_new1( 914 885 &snd_bt87x_capture_source, chip)); 915 886 if (err < 0) 916 goto _error;887 return err; 917 888 } 918 889 dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital " … … 930 901 err = snd_card_register(card); 931 902 if (err < 0) 932 goto _error;903 return err; 933 904 934 905 pci_set_drvdata(pci, card); 935 906 ++dev; 936 907 return 0; 937 938 _error: 939 snd_card_free(card); 940 return err; 941 } 942 943 static void snd_bt87x_remove(struct pci_dev *pci) 944 { 945 snd_card_free(pci_get_drvdata(pci)); 908 } 909 910 static int snd_bt87x_probe(struct pci_dev *pci, 911 const struct pci_device_id *pci_id) 912 { 913 return snd_card_free_on_error(&pci->dev, __snd_bt87x_probe(pci, pci_id)); 946 914 } 947 915 … … 958 926 .id_table = snd_bt87x_ids, 959 927 .probe = snd_bt87x_probe, 960 .remove = snd_bt87x_remove,961 928 }; 962 929
Note:
See TracChangeset
for help on using the changeset viewer.