All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [PATCH 02/10] ALSA: firewire-motu: unify midi callback function
Date: Mon, 17 Jun 2019 17:15:02 +0900	[thread overview]
Message-ID: <20190617081510.11025-3-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <20190617081510.11025-1-o-takashi@sakamocchi.jp>

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>
---
 sound/firewire/motu/motu-midi.c | 49 ++++-----------------------------
 1 file changed, 6 insertions(+), 43 deletions(-)

diff --git a/sound/firewire/motu/motu-midi.c b/sound/firewire/motu/motu-midi.c
index b2d339a8ef3f..3b205386ed24 100644
--- a/sound/firewire/motu/motu-midi.c
+++ b/sound/firewire/motu/motu-midi.c
@@ -7,7 +7,7 @@
  */
 #include "motu.h"
 
-static int midi_capture_open(struct snd_rawmidi_substream *substream)
+static int midi_open(struct snd_rawmidi_substream *substream)
 {
 	struct snd_motu *motu = substream->rmidi->private_data;
 	int err;
@@ -29,44 +29,7 @@ static int midi_capture_open(struct snd_rawmidi_substream *substream)
 	return err;
 }
 
-static int midi_playback_open(struct snd_rawmidi_substream *substream)
-{
-	struct snd_motu *motu = substream->rmidi->private_data;
-	int err;
-
-	err = snd_motu_stream_lock_try(motu);
-	if (err < 0)
-		return err;
-
-	mutex_lock(&motu->mutex);
-
-	motu->substreams_counter++;
-	err = snd_motu_stream_start_duplex(motu, 0);
-
-	mutex_unlock(&motu->mutex);
-
-	if (err < 0)
-		snd_motu_stream_lock_release(motu);
-
-	return err;
-}
-
-static int midi_capture_close(struct snd_rawmidi_substream *substream)
-{
-	struct snd_motu *motu = substream->rmidi->private_data;
-
-	mutex_lock(&motu->mutex);
-
-	motu->substreams_counter--;
-	snd_motu_stream_stop_duplex(motu);
-
-	mutex_unlock(&motu->mutex);
-
-	snd_motu_stream_lock_release(motu);
-	return 0;
-}
-
-static int midi_playback_close(struct snd_rawmidi_substream *substream)
+static int midi_close(struct snd_rawmidi_substream *substream)
 {
 	struct snd_motu *motu = substream->rmidi->private_data;
 
@@ -129,13 +92,13 @@ static void set_midi_substream_names(struct snd_motu *motu,
 int snd_motu_create_midi_devices(struct snd_motu *motu)
 {
 	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;
-- 
2.20.1

  parent reply	other threads:[~2019-06-17  8:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17  8:15 [PATCH 00/10] ALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 01/10] ALSA: firewire-motu: unify the count of subscriber for packet streaming Takashi Sakamoto
2019-06-17  8:15 ` Takashi Sakamoto [this message]
2019-06-17  8:15 ` [PATCH 03/10] ALSA: firewire-motu: add helper function to keep isochronous resources Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 04/10] ALSA: firewire-motu: code refactoring for condition to stop streaming Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 05/10] ALSA: firewire-motu: rename helper functions to begin/finish streaming session Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 06/10] ALSA: firewire-motu: minor code refactoring to stop isochronous context Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 07/10] ALSA: firewire-motu: code refactoring to finish streaming session Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 08/10] ALSA: firewire-motu: reserve/release isochronous resources in pcm.hw_params/hw_free callbacks Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 09/10] ALSA: firewire-motu: update isochronous resources when starting packet streaming after bus-reset Takashi Sakamoto
2019-06-17  8:15 ` [PATCH 10/10] ALSA: firewire-motu: code refactoring for pcm.hw_params/hw_free callbacks Takashi Sakamoto
2019-06-18  6:46 ` [PATCH 00/10] ALSA: firewire-motu: reserve/release isochronous resources in " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190617081510.11025-3-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.