Skip to content

Commit

Permalink
ALSA: ua101: Use managed buffer allocation
Browse files Browse the repository at this point in the history
Clean up the driver with the new managed buffer allocation API.
The hw_free callback became superfluous and got dropped.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Dec 11, 2019
1 parent b9626bd commit 8aa77f9
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions sound/usb/misc/ua101.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,11 +730,7 @@ static int capture_pcm_hw_params(struct snd_pcm_substream *substream,
mutex_lock(&ua->mutex);
err = start_usb_capture(ua);
mutex_unlock(&ua->mutex);
if (err < 0)
return err;

return snd_pcm_lib_malloc_pages(substream,
params_buffer_bytes(hw_params));
return err;
}

static int playback_pcm_hw_params(struct snd_pcm_substream *substream,
Expand All @@ -748,16 +744,7 @@ static int playback_pcm_hw_params(struct snd_pcm_substream *substream,
if (err >= 0)
err = start_usb_playback(ua);
mutex_unlock(&ua->mutex);
if (err < 0)
return err;

return snd_pcm_lib_malloc_pages(substream,
params_buffer_bytes(hw_params));
}

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

static int capture_pcm_prepare(struct snd_pcm_substream *substream)
Expand Down Expand Up @@ -885,7 +872,6 @@ static const struct snd_pcm_ops capture_pcm_ops = {
.close = capture_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = capture_pcm_hw_params,
.hw_free = ua101_pcm_hw_free,
.prepare = capture_pcm_prepare,
.trigger = capture_pcm_trigger,
.pointer = capture_pcm_pointer,
Expand All @@ -896,7 +882,6 @@ static const struct snd_pcm_ops playback_pcm_ops = {
.close = playback_pcm_close,
.ioctl = snd_pcm_lib_ioctl,
.hw_params = playback_pcm_hw_params,
.hw_free = ua101_pcm_hw_free,
.prepare = playback_pcm_prepare,
.trigger = playback_pcm_trigger,
.pointer = playback_pcm_pointer,
Expand Down Expand Up @@ -1294,8 +1279,8 @@ static int ua101_probe(struct usb_interface *interface,
strcpy(ua->pcm->name, name);
snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_pcm_ops);
snd_pcm_set_ops(ua->pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_pcm_ops);
snd_pcm_lib_preallocate_pages_for_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC,
NULL, 0, 0);
snd_pcm_set_managed_buffer_all(ua->pcm, SNDRV_DMA_TYPE_VMALLOC,
NULL, 0, 0);

err = snd_usbmidi_create(card, ua->intf[INTF_MIDI],
&ua->midi_list, &midi_quirk);
Expand Down

0 comments on commit 8aa77f9

Please sign in to comment.