Ignore:
Timestamp:
Aug 7, 2022, 6:11:12 PM (3 years ago)
Author:
David Azarewicz
Message:

Merge changes from next branch.

Location:
GPL/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.c

    r703 r717  
    7474        }
    7575
    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);
    7878        if (err < 0)
    7979                return err;
     80        chip = card->private_data;
    8081        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;
    8785        card->private_data = chip;
    8886        chip->accept_valid = mmap_valid[dev];
    8987        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;
    9490#ifdef CONFIG_SND_CS46XX_NEW_DSP
    9591        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;
    10094        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;
    10597#endif
    10698        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;
    111101#ifdef CONFIG_SND_CS46XX_NEW_DSP
    112102        if (chip->nr_ac97_codecs ==2) {
    113103                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;
    118106        }
    119107#endif
    120108        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;
    125111        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;
    131114
    132115        snd_cs46xx_gameport(chip);
     
    141124
    142125        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;
    147128
    148129        pci_set_drvdata(pci, card);
    149130        dev++;
    150131        return 0;
    151 }
    152132
    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;
    156136}
    157137
     
    160140        .id_table = snd_cs46xx_ids,
    161141        .probe = snd_card_cs46xx_probe,
    162         .remove = snd_card_cs46xx_remove,
    163142#ifdef CONFIG_PM_SLEEP
    164143        .driver = {
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx.h

    r679 r717  
    16361636        void __iomem *remap_addr;
    16371637        unsigned long size;
    1638         struct resource *resource;
    16391638};
    16401639
     
    17191718int snd_cs46xx_create(struct snd_card *card,
    17201719                      struct pci_dev *pci,
    1721                       int external_amp, int thinkpad,
    1722                       struct snd_cs46xx **rcodec);
     1720                      int external_amp, int thinkpad);
    17231721extern const struct dev_pm_ops snd_cs46xx_pm;
    17241722
  • GPL/trunk/alsa-kernel/pci/cs46xx/cs46xx_lib.c

    r703 r717  
    11261126                if (runtime->dma_area != cpcm->hw_buf.area)
    11271127                        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);
    11311129
    11321130
     
    11481146
    11491147        } 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);
    11551150                err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    11561151                if (err < 0) {
     
    12011196                snd_pcm_lib_free_pages(substream);
    12021197   
    1203         runtime->dma_area = NULL;
    1204         runtime->dma_addr = 0;
    1205         runtime->dma_bytes = 0;
     1198        snd_pcm_set_runtime_buffer(substream, NULL);
    12061199
    12071200        return 0;
     
    12921285                if (runtime->dma_area != chip->capt.hw_buf.area)
    12931286                        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);
    12971288                substream->ops = &snd_cs46xx_capture_ops;
    12981289        } 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);
    13041292                err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
    13051293                if (err < 0)
     
    13181306        if (runtime->dma_area != chip->capt.hw_buf.area)
    13191307                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);
    13231309
    13241310        return 0;
     
    18701856 *  Mixer routines
    18711857 */
    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 
    18791858static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97)
    18801859{
     
    24922471        if (err < 0)
    24932472                return err;
    2494         chip->ac97_bus->private_free = snd_cs46xx_mixer_free_ac97_bus;
    24952473
    24962474        if (cs46xx_detect_codec(chip, CS46XX_PRIMARY_CODEC_INDEX) < 0)
     
    29182896
    29192897
    2920 static int snd_cs46xx_free(struct snd_cs46xx *chip)
    2921 {
     2898static void snd_cs46xx_free(struct snd_card *card)
     2899{
     2900        struct snd_cs46xx *chip = card->private_data;
     2901#ifdef CONFIG_SND_CS46XX_NEW_DSP
    29222902        int idx;
    2923 
    2924         if (snd_BUG_ON(!chip))
    2925                 return -EINVAL;
     2903#endif
    29262904
    29272905        if (chip->active_ctrl)
     
    29352913        snd_cs46xx_proc_done(chip);
    29362914
    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);
    29422916
    29432917        if (chip->active_ctrl)
    29442918                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         }
    29522919
    29532920#ifdef CONFIG_SND_CS46XX_NEW_DSP
     
    29612928        vfree(chip->ba1);
    29622929#endif
    2963        
    2964 #ifdef CONFIG_PM_SLEEP
    2965         kfree(chip->saved_regs);
    2966 #endif
    2967 
    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);
    29772930}
    29782931
     
    38733826int snd_cs46xx_create(struct snd_card *card,
    38743827                      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;
    38793831        int err, idx;
    38803832        struct snd_cs46xx_region *region;
    38813833        struct cs_card_type *cp;
    38823834        u16 ss_card, ss_vendor;
    3883         static const struct snd_device_ops ops = {
    3884                 .dev_free =     snd_cs46xx_dev_free,
    3885         };
    38863835       
    3887         *rchip = NULL;
    3888 
    38893836        /* enable PCI device */
    3890         err = pci_enable_device(pci);
     3837        err = pcim_enable_device(pci);
    38913838        if (err < 0)
    38923839                return err;
    38933840
    3894         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    3895         if (chip == NULL) {
    3896                 pci_disable_device(pci);
    3897                 return -ENOMEM;
    3898         }
    38993841        spin_lock_init(&chip->reg_lock);
    39003842#ifdef CONFIG_SND_CS46XX_NEW_DSP
     
    39043846        chip->pci = pci;
    39053847        chip->irq = -1;
     3848
     3849        err = pci_request_regions(pci, "CS46xx");
     3850        if (err < 0)
     3851                return err;
    39063852        chip->ba0_addr = pci_resource_start(pci, 0);
    39073853        chip->ba1_addr = pci_resource_start(pci, 1);
     
    39113857                        "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n",
    39123858                           chip->ba0_addr, chip->ba1_addr);
    3913                 snd_cs46xx_free(chip);
    39143859                return -ENOMEM;
    39153860        }
     
    39833928        for (idx = 0; idx < 5; idx++) {
    39843929                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);
    39953932                if (region->remap_addr == NULL) {
    39963933                        dev_err(chip->card->dev,
    39973934                                "%s ioremap problem\n", region->name);
    3998                         snd_cs46xx_free(chip);
    39993935                        return -ENOMEM;
    40003936                }
    40013937        }
    40023938
    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)) {
    40053941                dev_err(chip->card->dev, "unable to grab IRQ %d\n", pci->irq);
    4006                 snd_cs46xx_free(chip);
    40073942                return -EBUSY;
    40083943        }
    40093944        chip->irq = pci->irq;
    40103945        card->sync_irq = chip->irq;
     3946        card->private_free = snd_cs46xx_free;
    40113947
    40123948#ifdef CONFIG_SND_CS46XX_NEW_DSP
    40133949        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)
    40163951                return -ENOMEM;
    4017         }
    40183952#endif
    40193953
    40203954        err = snd_cs46xx_chip_init(chip);
    4021         if (err < 0) {
    4022                 snd_cs46xx_free(chip);
     3955        if (err < 0)
    40233956                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         }
    40313957       
    40323958        snd_cs46xx_proc_init(card, chip);
    40333959
    40343960#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)
    40403966                return -ENOMEM;
    4041         }
    40423967#endif
    40433968
    40443969        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.