Commit a3f4f2d5 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: firewire: Convert to the common vmalloc memalloc

The recent change (*) in the ALSA memalloc core allows us to drop the
special vmalloc-specific allocation and page handling.  This patch
coverts to the common code.
(*) 1fe7f397: ALSA: memalloc: Add vmalloc buffer allocation
                  support
    7e8edae3: ALSA: pcm: Handle special page mapping in the
                  default mmap handler

Link: https://lore.kernel.org/r/20191105151856.10785-11-tiwai@suse.de


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b29e5ef1
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -214,8 +214,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_bebob *bebob = substream->private_data;
	int err;

	err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;

@@ -248,7 +247,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)

	mutex_unlock(&bebob->mutex);

	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_pages(substream);
}

static int
@@ -354,7 +353,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
		.trigger	= pcm_capture_trigger,
		.pointer	= pcm_capture_pointer,
		.ack		= pcm_capture_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	static const struct snd_pcm_ops playback_ops = {
		.open		= pcm_open,
@@ -366,7 +364,6 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
		.trigger	= pcm_playback_trigger,
		.pointer	= pcm_playback_pointer,
		.ack		= pcm_playback_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	struct snd_pcm *pcm;
	int err;
@@ -380,6 +377,8 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
		 "%s PCM", bebob->card->shortname);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
					      NULL, 0, 0);
end:
	return err;
}
+6 −5
Original line number Diff line number Diff line
@@ -266,8 +266,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_dice *dice = substream->private_data;
	int err;

	err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;

@@ -305,7 +304,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)

	mutex_unlock(&dice->mutex);

	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_pages(substream);
}

static int capture_prepare(struct snd_pcm_substream *substream)
@@ -417,7 +416,6 @@ int snd_dice_create_pcm(struct snd_dice *dice)
		.trigger   = capture_trigger,
		.pointer   = capture_pointer,
		.ack       = capture_ack,
		.page      = snd_pcm_lib_get_vmalloc_page,
	};
	static const struct snd_pcm_ops playback_ops = {
		.open      = pcm_open,
@@ -429,7 +427,6 @@ int snd_dice_create_pcm(struct snd_dice *dice)
		.trigger   = playback_trigger,
		.pointer   = playback_pointer,
		.ack       = playback_ack,
		.page      = snd_pcm_lib_get_vmalloc_page,
	};
	struct snd_pcm *pcm;
	unsigned int capture, playback;
@@ -459,6 +456,10 @@ int snd_dice_create_pcm(struct snd_dice *dice)
		if (playback > 0)
			snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
					&playback_ops);

		snd_pcm_lib_preallocate_pages_for_all(pcm,
						      SNDRV_DMA_TYPE_VMALLOC,
						      NULL, 0, 0);
	}

	return 0;
+4 −5
Original line number Diff line number Diff line
@@ -190,8 +190,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_dg00x *dg00x = substream->private_data;
	int err;

	err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;

@@ -224,7 +223,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)

	mutex_unlock(&dg00x->mutex);

	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_pages(substream);
}

static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -337,7 +336,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
		.trigger	= pcm_capture_trigger,
		.pointer	= pcm_capture_pointer,
		.ack		= pcm_capture_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	static const struct snd_pcm_ops playback_ops = {
		.open		= pcm_open,
@@ -349,7 +347,6 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
		.trigger	= pcm_playback_trigger,
		.pointer	= pcm_playback_pointer,
		.ack		= pcm_playback_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	struct snd_pcm *pcm;
	int err;
@@ -363,6 +360,8 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
		 "%s PCM", dg00x->card->shortname);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
					      NULL, 0, 0);

	return 0;
}
+4 −5
Original line number Diff line number Diff line
@@ -230,8 +230,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_ff *ff = substream->private_data;
	int err;

	err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;

@@ -264,7 +263,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)

	mutex_unlock(&ff->mutex);

	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_pages(substream);
}

static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -377,7 +376,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
		.trigger	= pcm_capture_trigger,
		.pointer	= pcm_capture_pointer,
		.ack		= pcm_capture_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	static const struct snd_pcm_ops pcm_playback_ops = {
		.open		= pcm_open,
@@ -389,7 +387,6 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
		.trigger	= pcm_playback_trigger,
		.pointer	= pcm_playback_pointer,
		.ack		= pcm_playback_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	struct snd_pcm *pcm;
	int err;
@@ -403,6 +400,8 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
		 "%s PCM", ff->card->shortname);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
					      NULL, 0, 0);

	return 0;
}
+4 −5
Original line number Diff line number Diff line
@@ -250,8 +250,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
	struct snd_efw *efw = substream->private_data;
	int err;

	err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
					       params_buffer_bytes(hw_params));
	err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
	if (err < 0)
		return err;

@@ -284,7 +283,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)

	mutex_unlock(&efw->mutex);

	return snd_pcm_lib_free_vmalloc_buffer(substream);
	return snd_pcm_lib_free_pages(substream);
}

static int pcm_capture_prepare(struct snd_pcm_substream *substream)
@@ -384,7 +383,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
		.trigger	= pcm_capture_trigger,
		.pointer	= pcm_capture_pointer,
		.ack		= pcm_capture_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	static const struct snd_pcm_ops playback_ops = {
		.open		= pcm_open,
@@ -396,7 +394,6 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
		.trigger	= pcm_playback_trigger,
		.pointer	= pcm_playback_pointer,
		.ack		= pcm_playback_ack,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};
	struct snd_pcm *pcm;
	int err;
@@ -409,6 +406,8 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
	snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
	snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
					      NULL, 0, 0);
end:
	return err;
}
Loading