--- zzzz-none-000/linux-3.10.107/sound/pci/ens1370.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/pci/ens1370.c 2021-02-04 17:41:59.000000000 +0000 @@ -26,7 +26,7 @@ * by Kurt J. Bosch */ -#include +#include #include #include #include @@ -446,7 +446,7 @@ static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id); -static DEFINE_PCI_DEVICE_TABLE(snd_audiopci_ids) = { +static const struct pci_device_id snd_audiopci_ids[] = { #ifdef CHIP1370 { PCI_VDEVICE(ENSONIQ, 0x5000), 0, }, /* ES1370 */ #endif @@ -525,7 +525,7 @@ return r; cond_resched(); } - snd_printk(KERN_ERR "wait src ready timeout 0x%lx [0x%x]\n", + dev_err(ensoniq->card->dev, "wait src ready timeout 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_SMPRATE), r); return 0; } @@ -587,7 +587,7 @@ unsigned long end_time = jiffies + HZ / 10; #if 0 - printk(KERN_DEBUG + dev_dbg(ensoniq->card->dev, "CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); #endif @@ -598,7 +598,7 @@ } schedule_timeout_uninterruptible(1); } while (time_after(end_time, jiffies)); - snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n", + dev_err(ensoniq->card->dev, "codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS))); } @@ -649,7 +649,7 @@ } } mutex_unlock(&ensoniq->src_mutex); - snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", + dev_err(ensoniq->card->dev, "codec write timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); } @@ -706,8 +706,8 @@ } mutex_unlock(&ensoniq->src_mutex); if (++fail > 10) { - snd_printk(KERN_ERR "codec read timeout (final) " - "at 0x%lx, reg = 0x%x [0x%x]\n", + dev_err(ensoniq->card->dev, + "codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), reg, inl(ES_REG(ensoniq, 1371_CODEC))); return 0; @@ -716,7 +716,7 @@ } } mutex_unlock(&ensoniq->src_mutex); - snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", + dev_err(ensoniq->card->dev, "codec read timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); return 0; } @@ -1268,14 +1268,11 @@ { } }; -static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device, - struct snd_pcm **rpcm) +static int snd_ensoniq_pcm(struct ensoniq *ensoniq, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ensoniq->card, CHIP_NAME "/1", device, 1, 1, &pcm); if (err < 0) return err; @@ -1302,22 +1299,14 @@ err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_std_chmaps, 2, 0, NULL); #endif - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; + return err; } -static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device, - struct snd_pcm **rpcm) +static int snd_ensoniq_pcm2(struct ensoniq *ensoniq, int device) { struct snd_pcm *pcm; int err; - if (rpcm) - *rpcm = NULL; err = snd_pcm_new(ensoniq->card, CHIP_NAME "/2", device, 1, 0, &pcm); if (err < 0) return err; @@ -1342,12 +1331,7 @@ err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, surround_map, 2, 0, NULL); #endif - if (err < 0) - return err; - - if (rpcm) - *rpcm = pcm; - return 0; + return err; } /* @@ -1796,7 +1780,7 @@ #ifdef SUPPORT_JOYSTICK #ifdef CHIP1371 -static int snd_ensoniq_get_joystick_port(int dev) +static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) { switch (joystick_port[dev]) { case 0: /* disabled */ @@ -1808,12 +1792,13 @@ return joystick_port[dev]; default: - printk(KERN_ERR "ens1371: invalid joystick port %#x", joystick_port[dev]); + dev_err(ensoniq->card->dev, + "invalid joystick port %#x", joystick_port[dev]); return 0; } } #else -static inline int snd_ensoniq_get_joystick_port(int dev) +static int snd_ensoniq_get_joystick_port(struct ensoniq *ensoniq, int dev) { return joystick[dev] ? 0x200 : 0; } @@ -1824,7 +1809,7 @@ struct gameport *gp; int io_port; - io_port = snd_ensoniq_get_joystick_port(dev); + io_port = snd_ensoniq_get_joystick_port(ensoniq, dev); switch (io_port) { case 0: @@ -1835,14 +1820,16 @@ if (request_region(io_port, 8, "ens137x: gameport")) break; if (io_port > 0x218) { - printk(KERN_WARNING "ens137x: no gameport ports available\n"); + dev_warn(ensoniq->card->dev, + "no gameport ports available\n"); return -EBUSY; } break; default: if (!request_region(io_port, 8, "ens137x: gameport")) { - printk(KERN_WARNING "ens137x: gameport io port 0x%#x in use\n", + dev_warn(ensoniq->card->dev, + "gameport io port %#x in use\n", io_port); return -EBUSY; } @@ -1851,7 +1838,8 @@ ensoniq->gameport = gp = gameport_allocate_port(); if (!gp) { - printk(KERN_ERR "ens137x: cannot allocate memory for gameport\n"); + dev_err(ensoniq->card->dev, + "cannot allocate memory for gameport\n"); release_region(io_port, 8); return -ENOMEM; } @@ -1939,7 +1927,7 @@ #endif if (ensoniq->irq >= 0) synchronize_irq(ensoniq->irq); - pci_set_power_state(ensoniq->pci, 3); + pci_set_power_state(ensoniq->pci, PCI_D3hot); __hw_end: #ifdef CHIP1370 if (ensoniq->dma_bug.area) @@ -2045,7 +2033,6 @@ #ifdef CONFIG_PM_SLEEP static int snd_ensoniq_suspend(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct ensoniq *ensoniq = card->private_data; @@ -2066,29 +2053,14 @@ udelay(100); snd_ak4531_suspend(ensoniq->u.es1370.ak4531); #endif - - pci_disable_device(pci); - pci_save_state(pci); - pci_set_power_state(pci, PCI_D3hot); return 0; } static int snd_ensoniq_resume(struct device *dev) { - struct pci_dev *pci = to_pci_dev(dev); struct snd_card *card = dev_get_drvdata(dev); struct ensoniq *ensoniq = card->private_data; - pci_set_power_state(pci, PCI_D0); - pci_restore_state(pci); - if (pci_enable_device(pci) < 0) { - printk(KERN_ERR DRIVER_NAME ": pci_enable_device failed, " - "disabling device\n"); - snd_card_disconnect(card); - return -EIO; - } - pci_set_master(pci); - snd_ensoniq_chip_init(ensoniq); #ifdef CHIP1371 @@ -2137,7 +2109,7 @@ ensoniq->port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_audiopci_interrupt, IRQF_SHARED, KBUILD_MODNAME, ensoniq)) { - snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); snd_ensoniq_free(ensoniq); return -EBUSY; } @@ -2145,7 +2117,7 @@ #ifdef CHIP1370 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 16, &ensoniq->dma_bug) < 0) { - snd_printk(KERN_ERR "unable to allocate space for phantom area - dma_bug\n"); + dev_err(card->dev, "unable to allocate space for phantom area - dma_bug\n"); snd_ensoniq_free(ensoniq); return -EBUSY; } @@ -2180,8 +2152,6 @@ snd_ensoniq_proc_init(ensoniq); - snd_card_set_dev(card, &pci->dev); - *rensoniq = ensoniq; return 0; } @@ -2361,14 +2331,11 @@ .trigger = snd_ensoniq_midi_input_trigger, }; -static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device, - struct snd_rawmidi **rrawmidi) +static int snd_ensoniq_midi(struct ensoniq *ensoniq, int device) { struct snd_rawmidi *rmidi; int err; - if (rrawmidi) - *rrawmidi = NULL; if ((err = snd_rawmidi_new(ensoniq->card, "ES1370/1", device, 1, 1, &rmidi)) < 0) return err; strcpy(rmidi->name, CHIP_NAME); @@ -2378,8 +2345,6 @@ SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = ensoniq; ensoniq->rmidi = rmidi; - if (rrawmidi) - *rrawmidi = rmidi; return 0; } @@ -2437,7 +2402,8 @@ return -ENOENT; } - 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; @@ -2460,15 +2426,15 @@ return err; } #endif - if ((err = snd_ensoniq_pcm(ensoniq, 0, NULL)) < 0) { + if ((err = snd_ensoniq_pcm(ensoniq, 0)) < 0) { snd_card_free(card); return err; } - if ((err = snd_ensoniq_pcm2(ensoniq, 1, NULL)) < 0) { + if ((err = snd_ensoniq_pcm2(ensoniq, 1)) < 0) { snd_card_free(card); return err; } - if ((err = snd_ensoniq_midi(ensoniq, 0, NULL)) < 0) { + if ((err = snd_ensoniq_midi(ensoniq, 0)) < 0) { snd_card_free(card); return err; } @@ -2497,7 +2463,6 @@ static void snd_audiopci_remove(struct pci_dev *pci) { snd_card_free(pci_get_drvdata(pci)); - pci_set_drvdata(pci, NULL); } static struct pci_driver ens137x_driver = {