diff options
author | Takashi Iwai <tiwai@suse.de> | 2018-05-27 07:59:03 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-05-28 05:53:04 -0400 |
commit | 6fddc797878181c9bb16dff1034ad9de2b25902d (patch) | |
tree | ecdf3e2ecdf8afc0712148baf9b24239c7baa733 /sound/usb | |
parent | 9f88058e7830d5943091e044e7b2d58773e31bca (diff) |
ALSA: usb-audio: Simplify PCM open/close callbacks
The stream direction in open and close callbacks can be retrieved from
substream->direction, hence we don't have to stick with the unique PCM
ops hard-coded for each direction. Rewrite the common open/close
callback functions.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/pcm.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 20bed1c7a312..d5b9c30d3bb1 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
@@ -1227,8 +1227,9 @@ rep_err: | |||
1227 | return err; | 1227 | return err; |
1228 | } | 1228 | } |
1229 | 1229 | ||
1230 | static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) | 1230 | static int snd_usb_pcm_open(struct snd_pcm_substream *substream) |
1231 | { | 1231 | { |
1232 | int direction = substream->stream; | ||
1232 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); | 1233 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); |
1233 | struct snd_pcm_runtime *runtime = substream->runtime; | 1234 | struct snd_pcm_runtime *runtime = substream->runtime; |
1234 | struct snd_usb_substream *subs = &as->substream[direction]; | 1235 | struct snd_usb_substream *subs = &as->substream[direction]; |
@@ -1248,8 +1249,9 @@ static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction) | |||
1248 | return setup_hw_info(runtime, subs); | 1249 | return setup_hw_info(runtime, subs); |
1249 | } | 1250 | } |
1250 | 1251 | ||
1251 | static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) | 1252 | static int snd_usb_pcm_close(struct snd_pcm_substream *substream) |
1252 | { | 1253 | { |
1254 | int direction = substream->stream; | ||
1253 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); | 1255 | struct snd_usb_stream *as = snd_pcm_substream_chip(substream); |
1254 | struct snd_usb_substream *subs = &as->substream[direction]; | 1256 | struct snd_usb_substream *subs = &as->substream[direction]; |
1255 | 1257 | ||
@@ -1611,26 +1613,6 @@ static void retire_playback_urb(struct snd_usb_substream *subs, | |||
1611 | spin_unlock_irqrestore(&subs->lock, flags); | 1613 | spin_unlock_irqrestore(&subs->lock, flags); |
1612 | } | 1614 | } |
1613 | 1615 | ||
1614 | static int snd_usb_playback_open(struct snd_pcm_substream *substream) | ||
1615 | { | ||
1616 | return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK); | ||
1617 | } | ||
1618 | |||
1619 | static int snd_usb_playback_close(struct snd_pcm_substream *substream) | ||
1620 | { | ||
1621 | return snd_usb_pcm_close(substream, SNDRV_PCM_STREAM_PLAYBACK); | ||
1622 | } | ||
1623 | |||
1624 | static int snd_usb_capture_open(struct snd_pcm_substream *substream) | ||
1625 | { | ||
1626 | return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE); | ||
1627 | } | ||
1628 | |||
1629 | static int snd_usb_capture_close(struct snd_pcm_substream *substream) | ||
1630 | { | ||
1631 | return snd_usb_pcm_close(substream, SNDRV_PCM_STREAM_CAPTURE); | ||
1632 | } | ||
1633 | |||
1634 | static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substream, | 1616 | static int snd_usb_substream_playback_trigger(struct snd_pcm_substream *substream, |
1635 | int cmd) | 1617 | int cmd) |
1636 | { | 1618 | { |
@@ -1692,8 +1674,8 @@ static int snd_usb_substream_capture_trigger(struct snd_pcm_substream *substream | |||
1692 | } | 1674 | } |
1693 | 1675 | ||
1694 | static const struct snd_pcm_ops snd_usb_playback_ops = { | 1676 | static const struct snd_pcm_ops snd_usb_playback_ops = { |
1695 | .open = snd_usb_playback_open, | 1677 | .open = snd_usb_pcm_open, |
1696 | .close = snd_usb_playback_close, | 1678 | .close = snd_usb_pcm_close, |
1697 | .ioctl = snd_pcm_lib_ioctl, | 1679 | .ioctl = snd_pcm_lib_ioctl, |
1698 | .hw_params = snd_usb_hw_params, | 1680 | .hw_params = snd_usb_hw_params, |
1699 | .hw_free = snd_usb_hw_free, | 1681 | .hw_free = snd_usb_hw_free, |
@@ -1705,8 +1687,8 @@ static const struct snd_pcm_ops snd_usb_playback_ops = { | |||
1705 | }; | 1687 | }; |
1706 | 1688 | ||
1707 | static const struct snd_pcm_ops snd_usb_capture_ops = { | 1689 | static const struct snd_pcm_ops snd_usb_capture_ops = { |
1708 | .open = snd_usb_capture_open, | 1690 | .open = snd_usb_pcm_open, |
1709 | .close = snd_usb_capture_close, | 1691 | .close = snd_usb_pcm_close, |
1710 | .ioctl = snd_pcm_lib_ioctl, | 1692 | .ioctl = snd_pcm_lib_ioctl, |
1711 | .hw_params = snd_usb_hw_params, | 1693 | .hw_params = snd_usb_hw_params, |
1712 | .hw_free = snd_usb_hw_free, | 1694 | .hw_free = snd_usb_hw_free, |