diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2021-09-01 10:29:29 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-09-01 10:29:29 -0700 |
commit | 0d290223a6c77107b1c3988959e49279a8dafaba (patch) | |
tree | 2b250c9e698b84a38d17920c0712558226c93c78 /sound/pci/cmipci.c | |
parent | ea7b4244b3656ca33b19a950f092b5bbc718b40c (diff) | |
parent | a8729efbbb847f6ea9b06e73491ec8ddb560465e (diff) |
Merge tag 'sound-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai:
"There are a few intensive changes in ALSA core side at this time that
helped with significant code reduction. Meanwhile we keep getting new
stuff, so the total size still grows...
Anyway, the below are some highlights in this development cycle.
ALSA core:
- New helpers to manage page allocations and card object with devres
- Refactoring for memory allocation with wc-pages
- A new PCM hardware flag SNDRV_PCM_INFO_EXPLICIT_SYNC for
controlling the explicit sync of the stream control; it'll be used
for ASoC SOF and non-coherent memory in future
ASoC:
- Lots of cleanups and improvements to the Intel drivers, including
some new systems support
- New support for AMD Vangoh, CUI CMM-4030D-261, Mediatek Mt8195,
Renesas RZ/G2L Mediatek Mt8195, RealTek RT101P, Renesas RZ/G2L,
Rockchip RK3568 S/PDIF
USB-audio:
- Re-organized the quirk handling and a new option quirk_flags
- Fix for a regression in 5.14 code change for JACK
- Quirks for Sony WALKMAN, Digidesign mbox
HD-audio:
- Enhanced support for CS8409 codec
- More consistent shutdown behavior with the runtime PM
- The model option can accept the PCI or codec SSID as an alias
- Quirks for ASUS ROG, HP Spectre x360
Others:
- Lots of code reduction in legacy drivers with devres helpers
- FireWire MOTU 896HD support"
* tag 'sound-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (421 commits)
ASoC: Revert PCM trigger changes
ALSA: usb-audio: Add lowlatency module option
ALSA: hda/cs8409: Initialize Codec only in init fixup.
ALSA: hda/cs8409: Ensure Type Detection is only run on startup when necessary
ALSA: usb-audio: Work around for XRUN with low latency playback
ALSA: pcm: fix divide error in snd_pcm_lib_ioctl
ASoC: soc-pcm: test refcount before triggering
ASoC: soc-pcm: protect BE dailink state changes in trigger
ASoC: wcd9335: Disable irq on slave ports in the remove function
ASoC: wcd9335: Fix a memory leak in the error handling path of the probe function
ASoC: wcd9335: Fix a double irq free in the remove function
ALSA: hda: Disable runtime resume at shutdown
ASoC: rockchip: i2s: Add support for frame inversion
ASoC: dt-bindings: rockchip: Add compatible strings for more SoCs
ASoC: rockchip: i2s: Add compatible for more SoCs
ASoC: rockchip: i2s: Make playback/capture optional
ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B
ASoC: dt-bindings: rockchip: Document reset property for i2s
ASoC: rockchip: i2s: Fix regmap_ops hang
ASoC: rockchip: i2s: Improve dma data transfer efficiency
...
Diffstat (limited to 'sound/pci/cmipci.c')
-rw-r--r-- | sound/pci/cmipci.c | 104 |
1 files changed, 28 insertions, 76 deletions
diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index f44f118aacad..ea20236f35db 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2852,13 +2852,15 @@ static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) if (joystick_port[dev] == 1) { /* auto-detect */ for (i = 0; ports[i]; i++) { io_port = ports[i]; - r = request_region(io_port, 1, "CMIPCI gameport"); + r = devm_request_region(&cm->pci->dev, io_port, 1, + "CMIPCI gameport"); if (r) break; } } else { io_port = joystick_port[dev]; - r = request_region(io_port, 1, "CMIPCI gameport"); + r = devm_request_region(&cm->pci->dev, io_port, 1, + "CMIPCI gameport"); } if (!r) { @@ -2869,14 +2871,12 @@ static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) cm->gameport = gp = gameport_allocate_port(); if (!gp) { dev_err(cm->card->dev, "cannot allocate memory for gameport\n"); - release_and_free_resource(r); return -ENOMEM; } gameport_set_name(gp, "C-Media Gameport"); gameport_set_phys(gp, "pci%s/gameport0", pci_name(cm->pci)); gameport_set_dev_parent(gp, &cm->pci->dev); gp->io = io_port; - gameport_set_port_data(gp, r); snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); @@ -2888,13 +2888,10 @@ static int snd_cmipci_create_gameport(struct cmipci *cm, int dev) static void snd_cmipci_free_gameport(struct cmipci *cm) { if (cm->gameport) { - struct resource *r = gameport_get_port_data(cm->gameport); - gameport_unregister_port(cm->gameport); cm->gameport = NULL; snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); - release_and_free_resource(r); } } #else @@ -2902,34 +2899,22 @@ static inline int snd_cmipci_create_gameport(struct cmipci *cm, int dev) { retur static inline void snd_cmipci_free_gameport(struct cmipci *cm) { } #endif -static int snd_cmipci_free(struct cmipci *cm) +static void snd_cmipci_free(struct snd_card *card) { - if (cm->irq >= 0) { - snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); - snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); - snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ - snd_cmipci_ch_reset(cm, CM_CH_PLAY); - snd_cmipci_ch_reset(cm, CM_CH_CAPT); - snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ - snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); + struct cmipci *cm = card->private_data; - /* reset mixer */ - snd_cmipci_mixer_write(cm, 0, 0); + snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); + snd_cmipci_clear_bit(cm, CM_REG_LEGACY_CTRL, CM_ENSPDOUT); + snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); /* disable ints */ + snd_cmipci_ch_reset(cm, CM_CH_PLAY); + snd_cmipci_ch_reset(cm, CM_CH_CAPT); + snd_cmipci_write(cm, CM_REG_FUNCTRL0, 0); /* disable channels */ + snd_cmipci_write(cm, CM_REG_FUNCTRL1, 0); - free_irq(cm->irq, cm); - } + /* reset mixer */ + snd_cmipci_mixer_write(cm, 0, 0); snd_cmipci_free_gameport(cm); - pci_release_regions(cm->pci); - pci_disable_device(cm->pci); - kfree(cm); - return 0; -} - -static int snd_cmipci_dev_free(struct snd_device *device) -{ - struct cmipci *cm = device->device_data; - return snd_cmipci_free(cm); } static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port) @@ -2988,13 +2973,10 @@ static int snd_cmipci_create_fm(struct cmipci *cm, long fm_port) } static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, - int dev, struct cmipci **rcmipci) + int dev) { - struct cmipci *cm; + struct cmipci *cm = card->private_data; int err; - static const struct snd_device_ops ops = { - .dev_free = snd_cmipci_dev_free, - }; unsigned int val; long iomidi = 0; int integrated_midi = 0; @@ -3005,18 +2987,10 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, { }, }; - *rcmipci = NULL; - - err = pci_enable_device(pci); + err = pcim_enable_device(pci); if (err < 0) return err; - cm = kzalloc(sizeof(*cm), GFP_KERNEL); - if (cm == NULL) { - pci_disable_device(pci); - return -ENOMEM; - } - spin_lock_init(&cm->reg_lock); mutex_init(&cm->open_mutex); cm->device = pci->device; @@ -3028,21 +3002,18 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, cm->channel[0].is_dac = cm->channel[1].is_dac = 1; /* dual DAC mode */ err = pci_request_regions(pci, card->driver); - if (err < 0) { - kfree(cm); - pci_disable_device(pci); + if (err < 0) return err; - } cm->iobase = pci_resource_start(pci, 0); - if (request_irq(pci->irq, snd_cmipci_interrupt, - IRQF_SHARED, KBUILD_MODNAME, cm)) { + if (devm_request_irq(&pci->dev, pci->irq, snd_cmipci_interrupt, + IRQF_SHARED, KBUILD_MODNAME, cm)) { dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); - snd_cmipci_free(cm); return -EBUSY; } cm->irq = pci->irq; card->sync_irq = cm->irq; + card->private_free = snd_cmipci_free; pci_set_master(cm->pci); @@ -3142,12 +3113,6 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, sprintf(card->longname, "%s%s at %#lx, irq %i", card->shortname, modelstr, cm->iobase, cm->irq); - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cm, &ops); - if (err < 0) { - snd_cmipci_free(cm); - return err; - } - if (cm->chip_version >= 39) { val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1); if (val != 0x00 && val != 0xff) { @@ -3240,7 +3205,6 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, if (snd_cmipci_create_gameport(cm, dev) < 0) snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); - *rcmipci = cm; return 0; } @@ -3264,10 +3228,11 @@ static int snd_cmipci_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(*cm), &card); if (err < 0) return err; + cm = card->private_data; switch (pci->device) { case PCI_DEVICE_ID_CMEDIA_CM8738: @@ -3283,31 +3248,19 @@ static int snd_cmipci_probe(struct pci_dev *pci, break; } - err = snd_cmipci_create(card, pci, dev, &cm); + err = snd_cmipci_create(card, pci, dev); if (err < 0) - goto free_card; - - card->private_data = cm; + return err; err = snd_card_register(card); if (err < 0) - goto free_card; + return err; pci_set_drvdata(pci, card); dev++; return 0; - -free_card: - snd_card_free(card); - return err; } -static void snd_cmipci_remove(struct pci_dev *pci) -{ - snd_card_free(pci_get_drvdata(pci)); -} - - #ifdef CONFIG_PM_SLEEP /* * power management @@ -3382,7 +3335,6 @@ static struct pci_driver cmipci_driver = { .name = KBUILD_MODNAME, .id_table = snd_cmipci_ids, .probe = snd_cmipci_probe, - .remove = snd_cmipci_remove, .driver = { .pm = SND_CMIPCI_PM_OPS, }, |