diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2019-06-12 11:44:09 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-06-12 16:26:50 +0300 |
commit | add147ad556cce588d1a714a6df4c4e556a6cb2f (patch) | |
tree | cf786267aa22efbcd7b7e4df4702f42aa73d3b9a /sound | |
parent | 1dc5921082d48dc53e48e88ae2f9a24b9737307d (diff) | |
download | linux-add147ad556cce588d1a714a6df4c4e556a6cb2f.tar.xz |
ALSA: fireworks: code refactoring for rawmidi.open/close
Two sets of callbacks for rawmidi.open/close but they have the same
codes. This commit unifies each of the callbacks.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/firewire/fireworks/fireworks_midi.c | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c index 7e78cdfe699e..ee5dc7be70b6 100644 --- a/sound/firewire/fireworks/fireworks_midi.c +++ b/sound/firewire/fireworks/fireworks_midi.c @@ -8,7 +8,7 @@ */ #include "fireworks.h" -static int midi_capture_open(struct snd_rawmidi_substream *substream) +static int midi_open(struct snd_rawmidi_substream *substream) { struct snd_efw *efw = substream->rmidi->private_data; int err; @@ -23,44 +23,11 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream) mutex_unlock(&efw->mutex); if (err < 0) snd_efw_stream_lock_release(efw); - end: return err; } -static int midi_playback_open(struct snd_rawmidi_substream *substream) -{ - struct snd_efw *efw = substream->rmidi->private_data; - int err; - - err = snd_efw_stream_lock_try(efw); - if (err < 0) - goto end; - - mutex_lock(&efw->mutex); - ++efw->substreams_counter; - err = snd_efw_stream_start_duplex(efw, 0); - mutex_unlock(&efw->mutex); - if (err < 0) - snd_efw_stream_lock_release(efw); -end: - return err; -} - -static int midi_capture_close(struct snd_rawmidi_substream *substream) -{ - struct snd_efw *efw = substream->rmidi->private_data; - - mutex_lock(&efw->mutex); - --efw->substreams_counter; - snd_efw_stream_stop_duplex(efw); - mutex_unlock(&efw->mutex); - - snd_efw_stream_lock_release(efw); - return 0; -} - -static int midi_playback_close(struct snd_rawmidi_substream *substream) +static int midi_close(struct snd_rawmidi_substream *substream) { struct snd_efw *efw = substream->rmidi->private_data; @@ -121,13 +88,13 @@ static void set_midi_substream_names(struct snd_efw *efw, int snd_efw_create_midi_devices(struct snd_efw *efw) { static const struct snd_rawmidi_ops capture_ops = { - .open = midi_capture_open, - .close = midi_capture_close, + .open = midi_open, + .close = midi_close, .trigger = midi_capture_trigger, }; static const struct snd_rawmidi_ops playback_ops = { - .open = midi_playback_open, - .close = midi_playback_close, + .open = midi_open, + .close = midi_close, .trigger = midi_playback_trigger, }; struct snd_rawmidi *rmidi; |