Commit 5116b94a authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: pci: Drop superfluous PCM preallocation error checks



snd_pcm_lib_preallocate_pages() and co always succeed, so the error
check is simply redundant.  Drop it.

Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f32e5616
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -644,16 +644,11 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device)
	chip->psubs = NULL;
	chip->csubs = NULL;

	err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
						snd_dma_pci_data(chip->pci),
						BUFFER_BYTES_MAX / 2,
						BUFFER_BYTES_MAX);

	if (err < 0) {
		dev_err(chip->card->dev, "buffer allocation error: %d\n", err);
		return err;
	}
	
	return 0;
}

+12 −28
Original line number Diff line number Diff line
@@ -624,15 +624,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
	snd_pcm_lib_preallocate_pages_for_all(pcm_playback_ana,
					      SNDRV_DMA_TYPE_DEV,
						    snd_dma_pci_data
						    (chip->pci),
					      snd_dma_pci_data(chip->pci),
					      64 * 1024, 64 * 1024);
	if (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);
@@ -661,15 +656,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	err = snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
	snd_pcm_lib_preallocate_pages_for_all(pcm_playback_num,
					      SNDRV_DMA_TYPE_DEV,
						    snd_dma_pci_data
						    (chip->pci),
					      snd_dma_pci_data(chip->pci),
					      64 * 1024, 64 * 1024);
	if (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);
@@ -699,16 +689,10 @@ static int snd_aw2_new_pcm(struct aw2 *chip)

	/* pre-allocation of buffers */
	/* Preallocate continuous pages. */
	err = snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
	snd_pcm_lib_preallocate_pages_for_all(pcm_capture,
					      SNDRV_DMA_TYPE_DEV,
						    snd_dma_pci_data
						    (chip->pci),
					      snd_dma_pci_data(chip->pci),
					      64 * 1024, 64 * 1024);
	if (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));
+5 −5
Original line number Diff line number Diff line
@@ -714,11 +714,11 @@ static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name)
	pcm->private_data = chip;
	strcpy(pcm->name, name);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_bt87x_pcm_ops);
	return snd_pcm_lib_preallocate_pages_for_all(pcm,
						     SNDRV_DMA_TYPE_DEV_SG,
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG,
					      snd_dma_pci_data(chip->pci),
					      128 * 1024,
					      ALIGN(255 * 4092, 1024));
	return 0;
}

static int snd_bt87x_create(struct snd_card *card,
+6 −10
Original line number Diff line number Diff line
@@ -1402,21 +1402,17 @@ static int snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
	for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 
	    substream; 
	    substream = substream->next) {
		if ((err = snd_pcm_lib_preallocate_pages(substream, 
							 SNDRV_DMA_TYPE_DEV, 
		snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
					      snd_dma_pci_data(emu->pci),
							 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */
			return err;
					      64*1024, 64*1024);
	}

	for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; 
	      substream; 
	      substream = substream->next) {
 		if ((err = snd_pcm_lib_preallocate_pages(substream, 
	                                           SNDRV_DMA_TYPE_DEV, 
		snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV,
					      snd_dma_pci_data(emu->pci),
	                                           64*1024, 64*1024)) < 0)
			return err;
					      64*1024, 64*1024);
	}
  
	err = snd_pcm_add_chmap_ctls(pcm, SNDRV_PCM_STREAM_PLAYBACK, map, 2,
+7 −9
Original line number Diff line number Diff line
@@ -884,17 +884,15 @@ static const struct snd_pcm_ops digital_capture_ops = {
static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
{
	struct snd_pcm_substream *ss;
	int stream, err;
	int stream;

	for (stream = 0; stream < 2; stream++)
		for (ss = pcm->streams[stream].substream; ss; ss = ss->next) {
			err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
		for (ss = pcm->streams[stream].substream; ss; ss = ss->next)
			snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
						      dev,
						      ss->number ? 0 : 128<<10,
						      256<<10);
			if (err < 0)
				return err;
		}

	return 0;
}

Loading