Commit 7564d3b6 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: echoaudio: Avoid non-standard macro usage

Pass the device pointer from the PCI pointer directly, instead of a
non-standard macro.  The macro didn't give any better readability.

Also slightly refactor the code (drop the return value check from the
preallocation) as it never returns an error.

Link: https://lore.kernel.org/r/20191105151856.10785-21-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 3ca5fc06
...@@ -324,7 +324,7 @@ static int pcm_open(struct snd_pcm_substream *substream, ...@@ -324,7 +324,7 @@ static int pcm_open(struct snd_pcm_substream *substream,
/* Finally allocate a page for the scatter-gather list */ /* Finally allocate a page for the scatter-gather list */
if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
snd_dma_pci_data(chip->pci), &chip->pci->dev,
PAGE_SIZE, &pipe->sgpage)) < 0) { PAGE_SIZE, &pipe->sgpage)) < 0) {
dev_err(chip->card->dev, "s-g list allocation failed\n"); dev_err(chip->card->dev, "s-g list allocation failed\n");
return err; return err;
...@@ -865,7 +865,7 @@ static const struct snd_pcm_ops digital_capture_ops = { ...@@ -865,7 +865,7 @@ static const struct snd_pcm_ops digital_capture_ops = {
/* Preallocate memory only for the first substream because it's the most /* Preallocate memory only for the first substream because it's the most
* used one * used one
*/ */
static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) static void snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
{ {
struct snd_pcm_substream *ss; struct snd_pcm_substream *ss;
int stream; int stream;
...@@ -876,8 +876,6 @@ static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev) ...@@ -876,8 +876,6 @@ static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
dev, dev,
ss->number ? 0 : 128<<10, ss->number ? 0 : 128<<10,
256<<10); 256<<10);
return 0;
} }
...@@ -904,8 +902,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -904,8 +902,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
strcpy(pcm->name, chip->card->shortname); strcpy(pcm->name, chip->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0) snd_echo_preallocate_pages(pcm, &chip->pci->dev);
return err;
#ifdef ECHOCARD_HAS_DIGITAL_IO #ifdef ECHOCARD_HAS_DIGITAL_IO
/* PCM#1 Digital inputs, no outputs */ /* PCM#1 Digital inputs, no outputs */
...@@ -916,8 +913,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -916,8 +913,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
chip->digital_pcm = pcm; chip->digital_pcm = pcm;
strcpy(pcm->name, chip->card->shortname); strcpy(pcm->name, chip->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0) snd_echo_preallocate_pages(pcm, &chip->pci->dev);
return err;
#endif /* ECHOCARD_HAS_DIGITAL_IO */ #endif /* ECHOCARD_HAS_DIGITAL_IO */
#else /* ECHOCARD_HAS_VMIXER */ #else /* ECHOCARD_HAS_VMIXER */
...@@ -937,8 +933,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -937,8 +933,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
strcpy(pcm->name, chip->card->shortname); strcpy(pcm->name, chip->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0) snd_echo_preallocate_pages(pcm, &chip->pci->dev);
return err;
#ifdef ECHOCARD_HAS_DIGITAL_IO #ifdef ECHOCARD_HAS_DIGITAL_IO
/* PCM#1 Digital i/o */ /* PCM#1 Digital i/o */
...@@ -951,8 +946,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip) ...@@ -951,8 +946,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
strcpy(pcm->name, chip->card->shortname); strcpy(pcm->name, chip->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0) snd_echo_preallocate_pages(pcm, &chip->pci->dev);
return err;
#endif /* ECHOCARD_HAS_DIGITAL_IO */ #endif /* ECHOCARD_HAS_DIGITAL_IO */
#endif /* ECHOCARD_HAS_VMIXER */ #endif /* ECHOCARD_HAS_VMIXER */
...@@ -1954,7 +1948,7 @@ static int snd_echo_create(struct snd_card *card, ...@@ -1954,7 +1948,7 @@ static int snd_echo_create(struct snd_card *card,
/* Create the DSP comm page - this is the area of memory used for most /* Create the DSP comm page - this is the area of memory used for most
of the communication with the DSP, which accesses it via bus mastering */ of the communication with the DSP, which accesses it via bus mastering */
if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
sizeof(struct comm_page), sizeof(struct comm_page),
&chip->commpage_dma_buf) < 0) { &chip->commpage_dma_buf) < 0) {
dev_err(chip->card->dev, "cannot allocate the comm page\n"); dev_err(chip->card->dev, "cannot allocate the comm page\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment