Commit 7641d549 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: firewire: Use managed buffer allocation

Clean up the drivers with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.
Acked-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20191209192422.23902-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8f326303
...@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_bebob *bebob = substream->private_data; struct snd_bebob *bebob = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&bebob->mutex); mutex_unlock(&bebob->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int static int
...@@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob) ...@@ -377,8 +373,7 @@ int snd_bebob_create_pcm_devices(struct snd_bebob *bebob)
"%s PCM", bebob->card->shortname); "%s PCM", bebob->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
end: end:
return err; return err;
} }
...@@ -264,11 +264,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -264,11 +264,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_dice *dice = substream->private_data; struct snd_dice *dice = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -304,7 +300,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dice->mutex); mutex_unlock(&dice->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int capture_prepare(struct snd_pcm_substream *substream) static int capture_prepare(struct snd_pcm_substream *substream)
...@@ -457,8 +453,7 @@ int snd_dice_create_pcm(struct snd_dice *dice) ...@@ -457,8 +453,7 @@ int snd_dice_create_pcm(struct snd_dice *dice)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
&playback_ops); &playback_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC,
SNDRV_DMA_TYPE_VMALLOC,
NULL, 0, 0); NULL, 0, 0);
} }
......
...@@ -188,11 +188,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -188,11 +188,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_dg00x *dg00x = substream->private_data; struct snd_dg00x *dg00x = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -223,7 +219,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&dg00x->mutex); mutex_unlock(&dg00x->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream)
...@@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x) ...@@ -360,8 +356,7 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
"%s PCM", dg00x->card->shortname); "%s PCM", dg00x->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
...@@ -228,11 +228,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -228,11 +228,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_ff *ff = substream->private_data; struct snd_ff *ff = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -263,7 +259,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&ff->mutex); mutex_unlock(&ff->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream)
...@@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff) ...@@ -400,8 +396,7 @@ int snd_ff_create_pcm_devices(struct snd_ff *ff)
"%s PCM", ff->card->shortname); "%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_PLAYBACK, &pcm_playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_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, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
...@@ -248,11 +248,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -248,11 +248,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_efw *efw = substream->private_data; struct snd_efw *efw = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -283,7 +279,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&efw->mutex); mutex_unlock(&efw->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream)
...@@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) ...@@ -406,8 +402,7 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw)
snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); 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_PLAYBACK, &playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
end: end:
return err; return err;
} }
......
...@@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream, ...@@ -286,11 +286,6 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct isight *isight = substream->private_data; struct isight *isight = substream->private_data;
int err;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
WRITE_ONCE(isight->pcm_active, true); WRITE_ONCE(isight->pcm_active, true);
...@@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream) ...@@ -336,7 +331,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
isight_stop_streaming(isight); isight_stop_streaming(isight);
mutex_unlock(&isight->mutex); mutex_unlock(&isight->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int isight_start_streaming(struct isight *isight) static int isight_start_streaming(struct isight *isight)
...@@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight) ...@@ -463,8 +458,7 @@ static int isight_create_pcm(struct isight *isight)
strcpy(pcm->name, "iSight"); strcpy(pcm->name, "iSight");
isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; isight->pcm = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream;
isight->pcm->ops = &ops; isight->pcm->ops = &ops;
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
......
...@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -212,11 +212,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_motu *motu = substream->private_data; struct snd_motu *motu = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -247,7 +243,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&motu->mutex); mutex_unlock(&motu->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int capture_prepare(struct snd_pcm_substream *substream) static int capture_prepare(struct snd_pcm_substream *substream)
...@@ -374,8 +370,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu) ...@@ -374,8 +370,7 @@ int snd_motu_create_pcm_devices(struct snd_motu *motu)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
...@@ -237,11 +237,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream, ...@@ -237,11 +237,7 @@ static int pcm_capture_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_oxfw *oxfw = substream->private_data; struct snd_oxfw *oxfw = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -264,11 +260,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream, ...@@ -264,11 +260,7 @@ static int pcm_playback_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_oxfw *oxfw = substream->private_data; struct snd_oxfw *oxfw = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream) ...@@ -301,7 +293,7 @@ static int pcm_capture_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex); mutex_unlock(&oxfw->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_playback_hw_free(struct snd_pcm_substream *substream) static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
{ {
...@@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream) ...@@ -316,7 +308,7 @@ static int pcm_playback_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&oxfw->mutex); mutex_unlock(&oxfw->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream)
...@@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw) ...@@ -454,8 +446,7 @@ int snd_oxfw_create_pcm(struct snd_oxfw *oxfw)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
if (cap > 0) if (cap > 0)
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
...@@ -117,11 +117,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream, ...@@ -117,11 +117,7 @@ static int pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *hw_params) struct snd_pcm_hw_params *hw_params)
{ {
struct snd_tscm *tscm = substream->private_data; struct snd_tscm *tscm = substream->private_data;
int err; int err = 0;
err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
if (err < 0)
return err;
if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) { if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN) {
unsigned int rate = params_rate(hw_params); unsigned int rate = params_rate(hw_params);
...@@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream) ...@@ -152,7 +148,7 @@ static int pcm_hw_free(struct snd_pcm_substream *substream)
mutex_unlock(&tscm->mutex); mutex_unlock(&tscm->mutex);
return snd_pcm_lib_free_pages(substream); return 0;
} }
static int pcm_capture_prepare(struct snd_pcm_substream *substream) static int pcm_capture_prepare(struct snd_pcm_substream *substream)
...@@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) ...@@ -289,8 +285,7 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm)
"%s PCM", tscm->card->shortname); "%s PCM", tscm->card->shortname);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_VMALLOC, snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_VMALLOC, NULL, 0, 0);
NULL, 0, 0);
return 0; return 0;
} }
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