Commit 909c7d2c authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: als300: Use managed buffer allocation

Clean up the driver with the new managed buffer allocation API.
The hw_params and hw_free callbacks became superfluous and got
dropped.

Link: https://lore.kernel.org/r/20191209094943.14984-22-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e6957454
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -378,7 +378,6 @@ static int snd_als300_playback_close(struct snd_pcm_substream *substream)
	data = substream->runtime->private_data;
	kfree(data);
	chip->playback_substream = NULL;
	snd_pcm_lib_free_pages(substream);
	return 0;
}

@@ -407,22 +406,9 @@ static int snd_als300_capture_close(struct snd_pcm_substream *substream)
	data = substream->runtime->private_data;
	kfree(data);
	chip->capture_substream = NULL;
	snd_pcm_lib_free_pages(substream);
	return 0;
}

static int snd_als300_pcm_hw_params(struct snd_pcm_substream *substream,
				    struct snd_pcm_hw_params *hw_params)
{
	return snd_pcm_lib_malloc_pages(substream,
					params_buffer_bytes(hw_params));
}

static int snd_als300_pcm_hw_free(struct snd_pcm_substream *substream)
{
	return snd_pcm_lib_free_pages(substream);
}

static int snd_als300_playback_prepare(struct snd_pcm_substream *substream)
{
	u32 tmp;
@@ -554,8 +540,6 @@ static const struct snd_pcm_ops snd_als300_playback_ops = {
	.open =		snd_als300_playback_open,
	.close =	snd_als300_playback_close,
	.ioctl =	snd_pcm_lib_ioctl,
	.hw_params =	snd_als300_pcm_hw_params,
	.hw_free =	snd_als300_pcm_hw_free,
	.prepare =	snd_als300_playback_prepare,
	.trigger =	snd_als300_trigger,
	.pointer =	snd_als300_pointer,
@@ -565,8 +549,6 @@ static const struct snd_pcm_ops snd_als300_capture_ops = {
	.open =		snd_als300_capture_open,
	.close =	snd_als300_capture_close,
	.ioctl =	snd_pcm_lib_ioctl,
	.hw_params =	snd_als300_pcm_hw_params,
	.hw_free =	snd_als300_pcm_hw_free,
	.prepare =	snd_als300_capture_prepare,
	.trigger =	snd_als300_trigger,
	.pointer =	snd_als300_pointer,
@@ -591,8 +573,7 @@ static int snd_als300_new_pcm(struct snd_als300 *chip)
				&snd_als300_capture_ops);

	/* pre-allocation of buffers */
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
					      &chip->pci->dev,
	snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_DEV, &chip->pci->dev,
				       64*1024, 64*1024);
	return 0;
}