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/bt87x.c

    r703 r717  
    666666};
    667667
    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);
     668static void snd_bt87x_free(struct snd_card *card)
     669{
     670        struct snd_bt87x *chip = card->private_data;
     671
     672        snd_bt87x_stop(chip);
    685673}
    686674
     
    704692
    705693static 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;
    710697        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);
    718700        if (err < 0)
    719701                return err;
    720702
    721         chip = kzalloc(sizeof(*chip), GFP_KERNEL);
    722         if (!chip) {
    723                 pci_disable_device(pci);
    724                 return -ENOMEM;
    725         }
    726703        chip->card = card;
    727704        chip->pci = pci;
     
    729706        spin_lock_init(&chip->reg_lock);
    730707
     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
    731714        err = pci_request_regions(pci, "Bt87x audio");
    732715        if (err < 0) {
     
    736719        }
    737720        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
    744722        chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 |
    745723                            CTL_PKTP_16 | (15 << CTL_DA_SDR_SHIFT);
     
    749727        snd_bt87x_writel(chip, REG_INT_STAT, MY_INTERRUPTS);
    750728
    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);
    753731        if (err < 0) {
    754732                dev_err(card->dev, "cannot grab irq %d\n", pci->irq);
    755                 goto fail;
     733                return err;
    756734        }
    757735        chip->irq = pci->irq;
    758736        card->sync_irq = chip->irq;
     737        card->private_free = snd_bt87x_free;
    759738        pci_set_master(pci);
    760739
    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;
    771741}
    772742
     
    854824}
    855825
    856 static int snd_bt87x_probe(struct pci_dev *pci,
    857                            const struct pci_device_id *pci_id)
     826static int __snd_bt87x_probe(struct pci_dev *pci,
     827                             const struct pci_device_id *pci_id)
    858828{
    859829        static int dev;
     
    878848        }
    879849
    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);
    882852        if (err < 0)
    883853                return err;
    884 
    885         err = snd_bt87x_create(card, pci, &chip);
     854        chip = card->private_data;
     855
     856        err = snd_bt87x_create(card, pci);
    886857        if (err < 0)
    887                 goto _error;
     858                return err;
    888859
    889860        memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board));
     
    897868                err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital");
    898869                if (err < 0)
    899                         goto _error;
     870                        return err;
    900871        }
    901872        if (!chip->board.no_analog) {
    902873                err = snd_bt87x_pcm(chip, DEVICE_ANALOG, "Bt87x Analog");
    903874                if (err < 0)
    904                         goto _error;
     875                        return err;
    905876                err = snd_ctl_add(card, snd_ctl_new1(
    906877                                  &snd_bt87x_capture_volume, chip));
    907878                if (err < 0)
    908                         goto _error;
     879                        return err;
    909880                err = snd_ctl_add(card, snd_ctl_new1(
    910881                                  &snd_bt87x_capture_boost, chip));
    911882                if (err < 0)
    912                         goto _error;
     883                        return err;
    913884                err = snd_ctl_add(card, snd_ctl_new1(
    914885                                  &snd_bt87x_capture_source, chip));
    915886                if (err < 0)
    916                         goto _error;
     887                        return err;
    917888        }
    918889        dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital "
     
    930901        err = snd_card_register(card);
    931902        if (err < 0)
    932                 goto _error;
     903                return err;
    933904
    934905        pci_set_drvdata(pci, card);
    935906        ++dev;
    936907        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
     910static 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));
    946914}
    947915
     
    958926        .id_table = snd_bt87x_ids,
    959927        .probe = snd_bt87x_probe,
    960         .remove = snd_bt87x_remove,
    961928};
    962929
Note: See TracChangeset for help on using the changeset viewer.