--- zzzz-none-000/linux-3.10.107/sound/pci/nm256/nm256.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/nm256/nm256.c 2021-02-04 17:41:59.000000000 +0000 @@ -24,7 +24,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include #include #include #include @@ -262,7 +262,7 @@ /* * PCI ids */ -static DEFINE_PCI_DEVICE_TABLE(snd_nm256_ids) = { +static const struct pci_device_id snd_nm256_ids[] = { {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO), 0}, {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256ZX_AUDIO), 0}, {PCI_VDEVICE(NEOMAGIC, PCI_DEVICE_ID_NEOMAGIC_NM256XL_PLUS_AUDIO), 0}, @@ -318,7 +318,8 @@ offset -= chip->buffer_start; #ifdef CONFIG_SND_DEBUG if (offset < 0 || offset >= chip->buffer_size) { - snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n", + dev_err(chip->card->dev, + "write_buffer invalid offset = %d size = %d\n", offset, size); return; } @@ -366,7 +367,8 @@ NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); if (snd_nm256_readb(chip, poffset) & 1) { - snd_printd("NM256: Engine was enabled while loading coefficients!\n"); + dev_dbg(chip->card->dev, + "NM256: Engine was enabled while loading coefficients!\n"); return; } @@ -466,7 +468,8 @@ if (chip->irq < 0) { if (request_irq(chip->pci->irq, chip->interrupt, IRQF_SHARED, KBUILD_MODNAME, chip)) { - snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq); + dev_err(chip->card->dev, + "unable to grab IRQ %d\n", chip->pci->irq); mutex_unlock(&chip->irq_mutex); return -EBUSY; } @@ -1039,7 +1042,7 @@ if (status & NM_MISC_INT_1) { status &= ~NM_MISC_INT_1; NM_ACK_INT(chip, NM_MISC_INT_1); - snd_printd("NM256: Got misc interrupt #1\n"); + dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n"); snd_nm256_writew(chip, NM_INT_REG, 0x8000); cbyte = snd_nm256_readb(chip, 0x400); snd_nm256_writeb(chip, 0x400, cbyte | 2); @@ -1048,14 +1051,15 @@ if (status & NM_MISC_INT_2) { status &= ~NM_MISC_INT_2; NM_ACK_INT(chip, NM_MISC_INT_2); - snd_printd("NM256: Got misc interrupt #2\n"); + dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n"); cbyte = snd_nm256_readb(chip, 0x400); snd_nm256_writeb(chip, 0x400, cbyte & ~2); } /* Unknown interrupt. */ if (status) { - snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", + dev_dbg(chip->card->dev, + "NM256: Fire in the hole! Unknown status 0x%x\n", status); /* Pray. */ NM_ACK_INT(chip, status); @@ -1104,7 +1108,7 @@ if (status & NM2_MISC_INT_1) { status &= ~NM2_MISC_INT_1; NM2_ACK_INT(chip, NM2_MISC_INT_1); - snd_printd("NM256: Got misc interrupt #1\n"); + dev_dbg(chip->card->dev, "NM256: Got misc interrupt #1\n"); cbyte = snd_nm256_readb(chip, 0x400); snd_nm256_writeb(chip, 0x400, cbyte | 2); } @@ -1112,14 +1116,15 @@ if (status & NM2_MISC_INT_2) { status &= ~NM2_MISC_INT_2; NM2_ACK_INT(chip, NM2_MISC_INT_2); - snd_printd("NM256: Got misc interrupt #2\n"); + dev_dbg(chip->card->dev, "NM256: Got misc interrupt #2\n"); cbyte = snd_nm256_readb(chip, 0x400); snd_nm256_writeb(chip, 0x400, cbyte & ~2); } /* Unknown interrupt. */ if (status) { - snd_printd("NM256: Fire in the hole! Unknown status 0x%x\n", + dev_dbg(chip->card->dev, + "NM256: Fire in the hole! Unknown status 0x%x\n", status); /* Pray. */ NM2_ACK_INT(chip, status); @@ -1245,7 +1250,7 @@ return; } } - snd_printd("nm256: ac97 codec not ready..\n"); + dev_dbg(chip->card->dev, "nm256: ac97 codec not ready..\n"); } /* static resolution table */ @@ -1347,7 +1352,8 @@ temp = ioremap_nocache(chip->buffer_addr + chip->buffer_end - 0x400, 16); if (temp == NULL) { - snd_printk(KERN_ERR "Unable to scan for card signature in video RAM\n"); + dev_err(chip->card->dev, + "Unable to scan for card signature in video RAM\n"); return -EBUSY; } @@ -1361,12 +1367,14 @@ if (pointer == 0xffffffff || pointer < chip->buffer_size || pointer > chip->buffer_end) { - snd_printk(KERN_ERR "invalid signature found: 0x%x\n", pointer); + dev_err(chip->card->dev, + "invalid signature found: 0x%x\n", pointer); iounmap(temp); return -ENODEV; } else { pointer_found = pointer; - printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", + dev_info(chip->card->dev, + "found card signature in video RAM: 0x%x\n", pointer); } } @@ -1384,7 +1392,6 @@ */ static int nm256_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct nm256 *chip = card->private_data; @@ -1392,15 +1399,11 @@ snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); chip->coeffs_current = 0; - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int nm256_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct nm256 *chip = card->private_data; int i; @@ -1408,16 +1411,6 @@ /* Perform a full reset on the hardware */ chip->in_resume = 1; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - printk(KERN_ERR "nm256: pci_enable_device failed, " - "disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_nm256_init_chip(chip); /* restore ac97 */ @@ -1453,10 +1446,8 @@ if (chip->irq >= 0) free_irq(chip->irq, chip); - if (chip->cport) - iounmap(chip->cport); - if (chip->buffer) - iounmap(chip->buffer); + iounmap(chip->cport); + iounmap(chip->buffer); release_and_free_resource(chip->res_cport); release_and_free_resource(chip->res_buffer); @@ -1520,14 +1511,15 @@ chip->res_cport = request_mem_region(chip->cport_addr, NM_PORT2_SIZE, card->driver); if (chip->res_cport == NULL) { - snd_printk(KERN_ERR "memory region 0x%lx (size 0x%x) busy\n", + dev_err(card->dev, "memory region 0x%lx (size 0x%x) busy\n", chip->cport_addr, NM_PORT2_SIZE); err = -EBUSY; goto __error; } chip->cport = ioremap_nocache(chip->cport_addr, NM_PORT2_SIZE); if (chip->cport == NULL) { - snd_printk(KERN_ERR "unable to map control port %lx\n", chip->cport_addr); + dev_err(card->dev, "unable to map control port %lx\n", + chip->cport_addr); err = -ENOMEM; goto __error; } @@ -1537,12 +1529,14 @@ pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE); if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { if (! force_ac97) { - printk(KERN_ERR "nm256: no ac97 is found!\n"); - printk(KERN_ERR " force the driver to load by " - "passing in the module parameter\n"); - printk(KERN_ERR " force_ac97=1\n"); - printk(KERN_ERR " or try sb16, opl3sa2, or " - "cs423x drivers instead.\n"); + dev_err(card->dev, + "no ac97 is found!\n"); + dev_err(card->dev, + "force the driver to load by passing in the module parameter\n"); + dev_err(card->dev, + " force_ac97=1\n"); + dev_err(card->dev, + "or try sb16, opl3sa2, or cs423x drivers instead.\n"); err = -ENXIO; goto __error; } @@ -1581,14 +1575,14 @@ chip->buffer_start = chip->buffer_end - chip->buffer_size; chip->buffer_addr += chip->buffer_start; - printk(KERN_INFO "nm256: Mapping port 1 from 0x%x - 0x%x\n", + dev_info(card->dev, "Mapping port 1 from 0x%x - 0x%x\n", chip->buffer_start, chip->buffer_end); chip->res_buffer = request_mem_region(chip->buffer_addr, chip->buffer_size, card->driver); if (chip->res_buffer == NULL) { - snd_printk(KERN_ERR "nm256: buffer 0x%lx (size 0x%x) busy\n", + dev_err(card->dev, "buffer 0x%lx (size 0x%x) busy\n", chip->buffer_addr, chip->buffer_size); err = -EBUSY; goto __error; @@ -1596,7 +1590,8 @@ chip->buffer = ioremap_nocache(chip->buffer_addr, chip->buffer_size); if (chip->buffer == NULL) { err = -ENOMEM; - snd_printk(KERN_ERR "unable to map ring buffer at %lx\n", chip->buffer_addr); + dev_err(card->dev, "unable to map ring buffer at %lx\n", + chip->buffer_addr); goto __error; } @@ -1626,8 +1621,6 @@ if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) goto __error; - snd_card_set_dev(card, &pci->dev); - *chip_ret = chip; return 0; @@ -1660,12 +1653,12 @@ q = snd_pci_quirk_lookup(pci, nm256_quirks); if (q) { - snd_printdd(KERN_INFO "nm256: Enabled quirk for %s.\n", + dev_dbg(&pci->dev, "Enabled quirk for %s.\n", snd_pci_quirk_name(q)); switch (q->value) { case NM_BLACKLISTED: - printk(KERN_INFO "nm256: The device is blacklisted. " - "Loading stopped\n"); + dev_info(&pci->dev, + "The device is blacklisted. Loading stopped\n"); return -ENODEV; case NM_RESET_WORKAROUND_2: reset_workaround_2 = 1; @@ -1676,7 +1669,7 @@ } } - err = snd_card_create(index, id, THIS_MODULE, 0, &card); + err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); if (err < 0) return err; @@ -1691,7 +1684,7 @@ strcpy(card->driver, "NM256XL+"); break; default: - snd_printk(KERN_ERR "invalid device id 0x%x\n", pci->device); + dev_err(&pci->dev, "invalid device id 0x%x\n", pci->device); snd_card_free(card); return -EINVAL; } @@ -1714,12 +1707,12 @@ card->private_data = chip; if (reset_workaround) { - snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); + dev_dbg(&pci->dev, "reset_workaround activated\n"); chip->reset_workaround = 1; } if (reset_workaround_2) { - snd_printdd(KERN_INFO "nm256: reset_workaround_2 activated\n"); + dev_dbg(&pci->dev, "reset_workaround_2 activated\n"); chip->reset_workaround_2 = 1; } @@ -1746,7 +1739,6 @@ static void snd_nm256_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); - pci_set_drvdata(pci, NULL); }