Changeset 717 for GPL/trunk/alsa-kernel/pci/cs46xx
- Timestamp:
- Aug 7, 2022, 6:11:12 PM (3 years ago)
- Location:
- GPL/trunk
- Files:
-
- 4 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/cs46xx/cs46xx.c
r703 r717 74 74 } 75 75 76 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,77 0, &card);76 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 77 sizeof(*chip), &card); 78 78 if (err < 0) 79 79 return err; 80 chip = card->private_data; 80 81 err = snd_cs46xx_create(card, pci, 81 external_amp[dev], thinkpad[dev], 82 &chip); 83 if (err < 0) { 84 snd_card_free(card); 85 return err; 86 } 82 external_amp[dev], thinkpad[dev]); 83 if (err < 0) 84 goto error; 87 85 card->private_data = chip; 88 86 chip->accept_valid = mmap_valid[dev]; 89 87 err = snd_cs46xx_pcm(chip, 0); 90 if (err < 0) { 91 snd_card_free(card); 92 return err; 93 } 88 if (err < 0) 89 goto error; 94 90 #ifdef CONFIG_SND_CS46XX_NEW_DSP 95 91 err = snd_cs46xx_pcm_rear(chip, 1); 96 if (err < 0) { 97 snd_card_free(card); 98 return err; 99 } 92 if (err < 0) 93 goto error; 100 94 err = snd_cs46xx_pcm_iec958(chip, 2); 101 if (err < 0) { 102 snd_card_free(card); 103 return err; 104 } 95 if (err < 0) 96 goto error; 105 97 #endif 106 98 err = snd_cs46xx_mixer(chip, 2); 107 if (err < 0) { 108 snd_card_free(card); 109 return err; 110 } 99 if (err < 0) 100 goto error; 111 101 #ifdef CONFIG_SND_CS46XX_NEW_DSP 112 102 if (chip->nr_ac97_codecs ==2) { 113 103 err = snd_cs46xx_pcm_center_lfe(chip, 3); 114 if (err < 0) { 115 snd_card_free(card); 116 return err; 117 } 104 if (err < 0) 105 goto error; 118 106 } 119 107 #endif 120 108 err = snd_cs46xx_midi(chip, 0); 121 if (err < 0) { 122 snd_card_free(card); 123 return err; 124 } 109 if (err < 0) 110 goto error; 125 111 err = snd_cs46xx_start_dsp(chip); 126 if (err < 0) { 127 snd_card_free(card); 128 return err; 129 } 130 112 if (err < 0) 113 goto error; 131 114 132 115 snd_cs46xx_gameport(chip); … … 141 124 142 125 err = snd_card_register(card); 143 if (err < 0) { 144 snd_card_free(card); 145 return err; 146 } 126 if (err < 0) 127 goto error; 147 128 148 129 pci_set_drvdata(pci, card); 149 130 dev++; 150 131 return 0; 151 }152 132 153 static void snd_card_cs46xx_remove(struct pci_dev *pci) 154 { 155 snd_card_free(pci_get_drvdata(pci));133 error: 134 snd_card_free(card); 135 return err; 156 136 } 157 137 … … 160 140 .id_table = snd_cs46xx_ids, 161 141 .probe = snd_card_cs46xx_probe, 162 .remove = snd_card_cs46xx_remove,163 142 #ifdef CONFIG_PM_SLEEP 164 143 .driver = { -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.h
r679 r717 1636 1636 void __iomem *remap_addr; 1637 1637 unsigned long size; 1638 struct resource *resource;1639 1638 }; 1640 1639 … … 1719 1718 int snd_cs46xx_create(struct snd_card *card, 1720 1719 struct pci_dev *pci, 1721 int external_amp, int thinkpad, 1722 struct snd_cs46xx **rcodec); 1720 int external_amp, int thinkpad); 1723 1721 extern const struct dev_pm_ops snd_cs46xx_pm; 1724 1722 -
GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c
r703 r717 1126 1126 if (runtime->dma_area != cpcm->hw_buf.area) 1127 1127 snd_pcm_lib_free_pages(substream); 1128 runtime->dma_area = cpcm->hw_buf.area; 1129 runtime->dma_addr = cpcm->hw_buf.addr; 1130 runtime->dma_bytes = cpcm->hw_buf.bytes; 1128 snd_pcm_set_runtime_buffer(substream, &cpcm->hw_buf); 1131 1129 1132 1130 … … 1148 1146 1149 1147 } else { 1150 if (runtime->dma_area == cpcm->hw_buf.area) { 1151 runtime->dma_area = NULL; 1152 runtime->dma_addr = 0; 1153 runtime->dma_bytes = 0; 1154 } 1148 if (runtime->dma_area == cpcm->hw_buf.area) 1149 snd_pcm_set_runtime_buffer(substream, NULL); 1155 1150 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1156 1151 if (err < 0) { … … 1201 1196 snd_pcm_lib_free_pages(substream); 1202 1197 1203 runtime->dma_area = NULL; 1204 runtime->dma_addr = 0; 1205 runtime->dma_bytes = 0; 1198 snd_pcm_set_runtime_buffer(substream, NULL); 1206 1199 1207 1200 return 0; … … 1292 1285 if (runtime->dma_area != chip->capt.hw_buf.area) 1293 1286 snd_pcm_lib_free_pages(substream); 1294 runtime->dma_area = chip->capt.hw_buf.area; 1295 runtime->dma_addr = chip->capt.hw_buf.addr; 1296 runtime->dma_bytes = chip->capt.hw_buf.bytes; 1287 snd_pcm_set_runtime_buffer(substream, &chip->capt.hw_buf); 1297 1288 substream->ops = &snd_cs46xx_capture_ops; 1298 1289 } else { 1299 if (runtime->dma_area == chip->capt.hw_buf.area) { 1300 runtime->dma_area = NULL; 1301 runtime->dma_addr = 0; 1302 runtime->dma_bytes = 0; 1303 } 1290 if (runtime->dma_area == chip->capt.hw_buf.area) 1291 snd_pcm_set_runtime_buffer(substream, NULL); 1304 1292 err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 1305 1293 if (err < 0) … … 1318 1306 if (runtime->dma_area != chip->capt.hw_buf.area) 1319 1307 snd_pcm_lib_free_pages(substream); 1320 runtime->dma_area = NULL; 1321 runtime->dma_addr = 0; 1322 runtime->dma_bytes = 0; 1308 snd_pcm_set_runtime_buffer(substream, NULL); 1323 1309 1324 1310 return 0; … … 1870 1856 * Mixer routines 1871 1857 */ 1872 static void snd_cs46xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus)1873 {1874 struct snd_cs46xx *chip = bus->private_data;1875 1876 chip->ac97_bus = NULL;1877 }1878 1879 1858 static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97) 1880 1859 { … … 2492 2471 if (err < 0) 2493 2472 return err; 2494 chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus;2495 2473 2496 2474 if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0) … … 2918 2896 2919 2897 2920 static int snd_cs46xx_free(struct snd_cs46xx *chip) 2921 { 2898 static void snd_cs46xx_free(struct snd_card *card) 2899 { 2900 struct snd_cs46xx *chip = card->private_data; 2901 #ifdef CONFIG_SND_CS46XX_NEW_DSP 2922 2902 int idx; 2923 2924 if (snd_BUG_ON(!chip)) 2925 return -EINVAL; 2903 #endif 2926 2904 2927 2905 if (chip->active_ctrl) … … 2935 2913 snd_cs46xx_proc_done(chip); 2936 2914 2937 if (chip->region.idx[0].resource) 2938 snd_cs46xx_hw_stop(chip); 2939 2940 if (chip->irq >= 0) 2941 free_irq(chip->irq, chip); 2915 snd_cs46xx_hw_stop(chip); 2942 2916 2943 2917 if (chip->active_ctrl) 2944 2918 chip->active_ctrl(chip, -chip->amplifier); 2945 2946 for (idx = 0; idx < 5; idx++) {2947 struct snd_cs46xx_region *region = &chip->region.idx[idx];2948 2949 iounmap(region->remap_addr);2950 release_and_free_resource(region->resource);2951 }2952 2919 2953 2920 #ifdef CONFIG_SND_CS46XX_NEW_DSP … … 2961 2928 vfree(chip->ba1); 2962 2929 #endif 2963 2964 #ifdef CONFIG_PM_SLEEP2965 kfree(chip->saved_regs);2966 #endif2967 2968 pci_disable_device(chip->pci);2969 kfree(chip);2970 return 0;2971 }2972 2973 static int snd_cs46xx_dev_free(struct snd_device *device)2974 {2975 struct snd_cs46xx *chip = device->device_data;2976 return snd_cs46xx_free(chip);2977 2930 } 2978 2931 … … 3873 3826 int snd_cs46xx_create(struct snd_card *card, 3874 3827 struct pci_dev *pci, 3875 int external_amp, int thinkpad, 3876 struct snd_cs46xx **rchip) 3877 { 3878 struct snd_cs46xx *chip; 3828 int external_amp, int thinkpad) 3829 { 3830 struct snd_cs46xx *chip = card->private_data; 3879 3831 int err, idx; 3880 3832 struct snd_cs46xx_region *region; 3881 3833 struct cs_card_type *cp; 3882 3834 u16 ss_card, ss_vendor; 3883 static const struct snd_device_ops ops = {3884 .dev_free = snd_cs46xx_dev_free,3885 };3886 3835 3887 *rchip = NULL;3888 3889 3836 /* enable PCI device */ 3890 err = pci _enable_device(pci);3837 err = pcim_enable_device(pci); 3891 3838 if (err < 0) 3892 3839 return err; 3893 3840 3894 chip = kzalloc(sizeof(*chip), GFP_KERNEL);3895 if (chip == NULL) {3896 pci_disable_device(pci);3897 return -ENOMEM;3898 }3899 3841 spin_lock_init(&chip->reg_lock); 3900 3842 #ifdef CONFIG_SND_CS46XX_NEW_DSP … … 3904 3846 chip->pci = pci; 3905 3847 chip->irq = -1; 3848 3849 err = pci_request_regions(pci, "CS46xx"); 3850 if (err < 0) 3851 return err; 3906 3852 chip->ba0_addr = pci_resource_start(pci, 0); 3907 3853 chip->ba1_addr = pci_resource_start(pci, 1); … … 3911 3857 "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", 3912 3858 chip->ba0_addr, chip->ba1_addr); 3913 snd_cs46xx_free(chip);3914 3859 return -ENOMEM; 3915 3860 } … … 3983 3928 for (idx = 0; idx < 5; idx++) { 3984 3929 region = &chip->region.idx[idx]; 3985 region->resource = request_mem_region(region->base, region->size, 3986 region->name); 3987 if (!region->resource) { 3988 dev_err(chip->card->dev, 3989 "unable to request memory region 0x%lx-0x%lx\n", 3990 region->base, region->base + region->size - 1); 3991 snd_cs46xx_free(chip); 3992 return -EBUSY; 3993 } 3994 region->remap_addr = ioremap(region->base, region->size); 3930 region->remap_addr = devm_ioremap(&pci->dev, region->base, 3931 region->size); 3995 3932 if (region->remap_addr == NULL) { 3996 3933 dev_err(chip->card->dev, 3997 3934 "%s ioremap problem\n", region->name); 3998 snd_cs46xx_free(chip);3999 3935 return -ENOMEM; 4000 3936 } 4001 3937 } 4002 3938 4003 if ( request_irq(pci->irq, snd_cs46xx_interrupt, IRQF_SHARED,4004 KBUILD_MODNAME, chip)) {3939 if (devm_request_irq(&pci->dev, pci->irq, snd_cs46xx_interrupt, 3940 IRQF_SHARED, KBUILD_MODNAME, chip)) { 4005 3941 dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq); 4006 snd_cs46xx_free(chip);4007 3942 return -EBUSY; 4008 3943 } 4009 3944 chip->irq = pci->irq; 4010 3945 card->sync_irq = chip->irq; 3946 card->private_free = snd_cs46xx_free; 4011 3947 4012 3948 #ifdef CONFIG_SND_CS46XX_NEW_DSP 4013 3949 chip->dsp_spos_instance = cs46xx_dsp_spos_create(chip); 4014 if (chip->dsp_spos_instance == NULL) { 4015 snd_cs46xx_free(chip); 3950 if (!chip->dsp_spos_instance) 4016 3951 return -ENOMEM; 4017 }4018 3952 #endif 4019 3953 4020 3954 err = snd_cs46xx_chip_init(chip); 4021 if (err < 0) { 4022 snd_cs46xx_free(chip); 3955 if (err < 0) 4023 3956 return err; 4024 }4025 4026 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);4027 if (err < 0) {4028 snd_cs46xx_free(chip);4029 return err;4030 }4031 3957 4032 3958 snd_cs46xx_proc_init(card, chip); 4033 3959 4034 3960 #ifdef CONFIG_PM_SLEEP 4035 chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),4036 sizeof(*chip->saved_regs),4037 GFP_KERNEL);4038 if (!chip->saved_regs) {4039 snd_cs46xx_free(chip);3961 chip->saved_regs = devm_kmalloc_array(&pci->dev, 3962 ARRAY_SIZE(saved_regs), 3963 sizeof(*chip->saved_regs), 3964 GFP_KERNEL); 3965 if (!chip->saved_regs) 4040 3966 return -ENOMEM; 4041 }4042 3967 #endif 4043 3968 4044 3969 chip->active_ctrl(chip, -1); /* disable CLKRUN */ 4045 4046 *rchip = chip; 4047 return 0; 4048 } 3970 return 0; 3971 }
Note:
See TracChangeset
for help on using the changeset viewer.