summaryrefslogtreecommitdiff
path: root/sound/pci/cs46xx/cs46xx.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-07-15 10:58:52 +0300
committerTakashi Iwai <tiwai@suse.de>2021-07-19 17:16:54 +0300
commit5bff69b3645db7b3018ecbc26218d8866aeaf214 (patch)
treed9fcad31aee504c53c65168e60522fdec6c9c022 /sound/pci/cs46xx/cs46xx.c
parent1656fa6ea2583d9779c10051b3b37d664c8899e3 (diff)
downloadlinux-5bff69b3645db7b3018ecbc26218d8866aeaf214.tar.xz
ALSA: cs46xx: Allocate resources with device-managed APIs
This patch converts the resource management in PCI cs46xx driver with devres as a clean up. Each manual resource management is converted with the corresponding devres helper, and the card object release is managed now via card->private_free instead of a lowlevel snd_device. This should give no user-visible functional changes. Link: https://lore.kernel.org/r/20210715075941.23332-31-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/cs46xx/cs46xx.c')
-rw-r--r--sound/pci/cs46xx/cs46xx.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c
index 358ca84cbdea..bd60308769ff 100644
--- a/sound/pci/cs46xx/cs46xx.c
+++ b/sound/pci/cs46xx/cs46xx.c
@@ -66,61 +66,44 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
return -ENOENT;
}
- err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
- 0, &card);
+ err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
+ sizeof(*chip), &card);
if (err < 0)
return err;
+ chip = card->private_data;
err = snd_cs46xx_create(card, pci,
- external_amp[dev], thinkpad[dev],
- &chip);
- if (err < 0) {
- snd_card_free(card);
+ external_amp[dev], thinkpad[dev]);
+ if (err < 0)
return err;
- }
card->private_data = chip;
chip->accept_valid = mmap_valid[dev];
err = snd_cs46xx_pcm(chip, 0);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
#ifdef CONFIG_SND_CS46XX_NEW_DSP
err = snd_cs46xx_pcm_rear(chip, 1);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
err = snd_cs46xx_pcm_iec958(chip, 2);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
#endif
err = snd_cs46xx_mixer(chip, 2);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
#ifdef CONFIG_SND_CS46XX_NEW_DSP
if (chip->nr_ac97_codecs ==2) {
err = snd_cs46xx_pcm_center_lfe(chip, 3);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
}
#endif
err = snd_cs46xx_midi(chip, 0);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
err = snd_cs46xx_start_dsp(chip);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
-
snd_cs46xx_gameport(chip);
@@ -133,26 +116,18 @@ static int snd_card_cs46xx_probe(struct pci_dev *pci,
chip->irq);
err = snd_card_register(card);
- if (err < 0) {
- snd_card_free(card);
+ if (err < 0)
return err;
- }
pci_set_drvdata(pci, card);
dev++;
return 0;
}
-static void snd_card_cs46xx_remove(struct pci_dev *pci)
-{
- snd_card_free(pci_get_drvdata(pci));
-}
-
static struct pci_driver cs46xx_driver = {
.name = KBUILD_MODNAME,
.id_table = snd_cs46xx_ids,
.probe = snd_card_cs46xx_probe,
- .remove = snd_card_cs46xx_remove,
#ifdef CONFIG_PM_SLEEP
.driver = {
.pm = &snd_cs46xx_pm,