--- zzzz-none-000/linux-3.10.107/sound/pci/aw2/aw2-alsa.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/aw2/aw2-alsa.c 2021-02-04 17:41:59.000000000 +0000 @@ -160,7 +160,7 @@ module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable Audiowerk2 soundcard."); -static DEFINE_PCI_DEVICE_TABLE(snd_aw2_ids) = { +static const struct pci_device_id snd_aw2_ids[] = { {PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, 0, 0, 0, 0, 0}, {0} @@ -229,9 +229,7 @@ if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); /* release the i/o ports & memory */ - if (chip->iobase_virt) - iounmap(chip->iobase_virt); - + iounmap(chip->iobase_virt); pci_release_regions(chip->pci); /* disable the PCI entry */ pci_disable_device(chip->pci); @@ -260,9 +258,9 @@ pci_set_master(pci); /* check PCI availability (32bit DMA) */ - if ((pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) || - (pci_set_consistent_dma_mask(pci, DMA_BIT_MASK(32)) < 0)) { - printk(KERN_ERR "aw2: Impossible to set 32bit mask DMA\n"); + if ((dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) || + (dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)) < 0)) { + dev_err(card->dev, "Impossible to set 32bit mask DMA\n"); pci_disable_device(pci); return -ENXIO; } @@ -290,7 +288,7 @@ pci_resource_len(pci, 0)); if (chip->iobase_virt == NULL) { - printk(KERN_ERR "aw2: unable to remap memory region"); + dev_err(card->dev, "unable to remap memory region"); pci_release_regions(pci); pci_disable_device(pci); kfree(chip); @@ -302,7 +300,7 @@ if (request_irq(pci->irq, snd_aw2_saa7146_interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { - printk(KERN_ERR "aw2: Cannot grab irq %d\n", pci->irq); + dev_err(card->dev, "Cannot grab irq %d\n", pci->irq); iounmap(chip->iobase_virt); pci_release_regions(chip->pci); @@ -322,12 +320,10 @@ return err; } - snd_card_set_dev(card, &pci->dev); *rchip = chip; - printk(KERN_INFO - "Audiowerk 2 sound card (saa7146 chipset) detected and " - "managed\n"); + dev_info(card->dev, + "Audiowerk 2 sound card (saa7146 chipset) detected and managed\n"); return 0; } @@ -349,7 +345,8 @@ } /* (2) Create card instance */ - err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); + err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, + 0, &card); if (err < 0) return err; @@ -392,7 +389,6 @@ static void snd_aw2_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); - pci_set_drvdata(pci, NULL); } /* open callback */ @@ -400,7 +396,7 @@ { struct snd_pcm_runtime *runtime = substream->runtime; - snd_printdd(KERN_DEBUG "aw2: Playback_open\n"); + dev_dbg(substream->pcm->card->dev, "Playback_open\n"); runtime->hw = snd_aw2_playback_hw; return 0; } @@ -416,7 +412,7 @@ { struct snd_pcm_runtime *runtime = substream->runtime; - snd_printdd(KERN_DEBUG "aw2: Capture_open\n"); + dev_dbg(substream->pcm->card->dev, "Capture_open\n"); runtime->hw = snd_aw2_capture_hw; return 0; } @@ -604,7 +600,7 @@ err = snd_pcm_new(chip->card, "Audiowerk2 analog playback", 0, 1, 0, &pcm_playback_ana); if (err < 0) { - printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); + dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err); return err; } @@ -634,14 +630,15 @@ (chip->pci), 64 * 1024, 64 * 1024); if (err) - printk(KERN_ERR "aw2: snd_pcm_lib_preallocate_pages_for_all " - "error (0x%X)\n", err); + dev_err(chip->card->dev, + "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n", + err); err = snd_pcm_new(chip->card, "Audiowerk2 digital playback", 1, 1, 0, &pcm_playback_num); if (err < 0) { - printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); + dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err); return err; } /* Creation ok */ @@ -670,17 +667,15 @@ (chip->pci), 64 * 1024, 64 * 1024); if (err) - printk(KERN_ERR - "aw2: snd_pcm_lib_preallocate_pages_for_all error " - "(0x%X)\n", err); - - + dev_err(chip->card->dev, + "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n", + err); err = snd_pcm_new(chip->card, "Audiowerk2 capture", 2, 0, 1, &pcm_capture); if (err < 0) { - printk(KERN_ERR "aw2: snd_pcm_new error (0x%X)\n", err); + dev_err(chip->card->dev, "snd_pcm_new error (0x%X)\n", err); return err; } @@ -710,15 +705,15 @@ (chip->pci), 64 * 1024, 64 * 1024); if (err) - printk(KERN_ERR - "aw2: snd_pcm_lib_preallocate_pages_for_all error " - "(0x%X)\n", err); + dev_err(chip->card->dev, + "snd_pcm_lib_preallocate_pages_for_all error (0x%X)\n", + err); /* Create control */ err = snd_ctl_add(chip->card, snd_ctl_new1(&aw2_control, chip)); if (err < 0) { - printk(KERN_ERR "aw2: snd_ctl_add error (0x%X)\n", err); + dev_err(chip->card->dev, "snd_ctl_add error (0x%X)\n", err); return err; } @@ -728,19 +723,10 @@ static int snd_aw2_control_switch_capture_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - static char *texts[2] = { + static const char * const texts[2] = { "Analog", "Digital" }; - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = 2; - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) { - uinfo->value.enumerated.item = - uinfo->value.enumerated.items - 1; - } - strcpy(uinfo->value.enumerated.name, - texts[uinfo->value.enumerated.item]); - return 0; + return snd_ctl_enum_info(uinfo, 1, 2, texts); } static int snd_aw2_control_switch_capture_get(struct snd_kcontrol *kcontrol,