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:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

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

    r703 r717  
    242242}
    243243
    244 static int snd_cs5535audio_free(struct cs5535audio *cs5535au)
    245 {
    246         pci_set_power_state(cs5535au->pci, PCI_D3hot);
    247 
    248         if (cs5535au->irq >= 0)
    249                 free_irq(cs5535au->irq, cs5535au);
    250 
    251         pci_release_regions(cs5535au->pci);
    252         pci_disable_device(cs5535au->pci);
    253         kfree(cs5535au);
    254         return 0;
    255 }
    256 
    257 static int snd_cs5535audio_dev_free(struct snd_device *device)
    258 {
    259         struct cs5535audio *cs5535au = device->device_data;
    260         return snd_cs5535audio_free(cs5535au);
     244static void snd_cs5535audio_free(struct snd_card *card)
     245{
     246        olpc_quirks_cleanup();
    261247}
    262248
    263249static int snd_cs5535audio_create(struct snd_card *card,
    264                                   struct pci_dev *pci,
    265                                   struct cs5535audio **rcs5535au)
    266 {
    267         struct cs5535audio *cs5535au;
    268 
     250                                  struct pci_dev *pci)
     251{
     252        struct cs5535audio *cs5535au = card->private_data;
    269253        int err;
    270         static const struct snd_device_ops ops = {
    271                 .dev_free =     snd_cs5535audio_dev_free,
    272         };
    273 
    274         *rcs5535au = NULL;
    275         err = pci_enable_device(pci);
     254
     255        err = pcim_enable_device(pci);
    276256        if (err < 0)
    277257                return err;
     
    279259        if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) {
    280260                dev_warn(card->dev, "unable to get 32bit dma\n");
    281                 err = -ENXIO;
    282                 goto pcifail;
    283         }
    284 
    285         cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL);
    286         if (cs5535au == NULL) {
    287                 err = -ENOMEM;
    288                 goto pcifail;
     261                return -ENXIO;
    289262        }
    290263
     
    295268
    296269        err = pci_request_regions(pci, "CS5535 Audio");
    297         if (err < 0) {
    298                 kfree(cs5535au);
    299                 goto pcifail;
    300         }
     270        if (err < 0)
     271                return err;
    301272
    302273        cs5535au->port = pci_resource_start(pci, 0);
    303274
    304         if (request_irq(pci->irq, snd_cs5535audio_interrupt,
    305                         IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
     275        if (devm_request_irq(&pci->dev, pci->irq, snd_cs5535audio_interrupt,
     276                             IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {
    306277                dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
    307                 err = -EBUSY;
    308                 goto sndfail;
     278                return -EBUSY;
    309279        }
    310280
     
    313283        pci_set_master(pci);
    314284
    315         err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cs5535au, &ops);
    316         if (err < 0)
    317                 goto sndfail;
    318 
    319         *rcs5535au = cs5535au;
    320285        return 0;
    321 
    322 sndfail: /* leave the device alive, just kill the snd */
    323         snd_cs5535audio_free(cs5535au);
    324         return err;
    325 
    326 pcifail:
    327         pci_disable_device(pci);
    328         return err;
    329 }
    330 
    331 static int snd_cs5535audio_probe(struct pci_dev *pci,
    332                                  const struct pci_device_id *pci_id)
     286}
     287
     288static int __snd_cs5535audio_probe(struct pci_dev *pci,
     289                                   const struct pci_device_id *pci_id)
    333290{
    334291        static int dev;
     
    344301        }
    345302
    346         err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
    347                            0, &card);
    348         if (err < 0)
    349                 return err;
    350 
    351         err = snd_cs5535audio_create(card, pci, &cs5535au);
    352         if (err < 0)
    353                 goto probefail_out;
    354 
    355         card->private_data = cs5535au;
     303        err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
     304                                sizeof(*cs5535au), &card);
     305        if (err < 0)
     306                return err;
     307        cs5535au = card->private_data;
     308        card->private_free = snd_cs5535audio_free;
     309
     310        err = snd_cs5535audio_create(card, pci);
     311        if (err < 0)
     312                return err;
    356313
    357314        err = snd_cs5535audio_mixer(cs5535au);
    358315        if (err < 0)
    359                 goto probefail_out;
     316                return err;
    360317
    361318        err = snd_cs5535audio_pcm(cs5535au);
    362319        if (err < 0)
    363                 goto probefail_out;
     320                return err;
    364321
    365322        strcpy(card->driver, DRIVER_NAME);
     
    372329        err = snd_card_register(card);
    373330        if (err < 0)
    374                 goto probefail_out;
     331                return err;
    375332
    376333        pci_set_drvdata(pci, card);
    377334        dev++;
    378335        return 0;
    379 
    380 probefail_out:
    381         snd_card_free(card);
    382         return err;
    383 }
    384 
    385 static void snd_cs5535audio_remove(struct pci_dev *pci)
    386 {
    387         olpc_quirks_cleanup();
    388         snd_card_free(pci_get_drvdata(pci));
     336}
     337
     338static int snd_cs5535audio_probe(struct pci_dev *pci,
     339                                 const struct pci_device_id *pci_id)
     340{
     341        return snd_card_free_on_error(&pci->dev, __snd_cs5535audio_probe(pci, pci_id));
    389342}
    390343
     
    393346        .id_table = snd_cs5535audio_ids,
    394347        .probe = snd_cs5535audio_probe,
    395         .remove = snd_cs5535audio_remove,
    396348#ifdef CONFIG_PM_SLEEP
    397349        .driver = {
Note: See TracChangeset for help on using the changeset viewer.