Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[sfrench/cifs-2.6.git] / sound / firewire / tascam / tascam-stream.c
index be9dcc80818843728760a67670c43afbe50ee4b2..e852e46ebe6fa6c9bf77ce579f214c997cb67680 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * tascam-stream.c - a part of driver for TASCAM FireWire series
  *
  * Copyright (c) 2015 Takashi Sakamoto
- *
- * Licensed under the terms of the GNU General Public License, version 2.
  */
 
 #include <linux/delay.h>
@@ -181,6 +180,9 @@ static void finish_session(struct snd_tscm *tscm)
 {
        __be32 reg;
 
+       amdtp_stream_stop(&tscm->rx_stream);
+       amdtp_stream_stop(&tscm->tx_stream);
+
        reg = 0;
        snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST,
                           TSCM_ADDR_BASE + TSCM_OFFSET_START_STREAMING,
@@ -354,9 +356,6 @@ int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate)
                return err;
 
        if (tscm->substreams_counter == 0 || rate != curr_rate) {
-               amdtp_stream_stop(&tscm->rx_stream);
-               amdtp_stream_stop(&tscm->tx_stream);
-
                finish_session(tscm);
 
                fw_iso_resources_free(&tscm->tx_resources);
@@ -380,14 +379,6 @@ int snd_tscm_stream_reserve_duplex(struct snd_tscm *tscm, unsigned int rate)
        return 0;
 }
 
-void snd_tscm_stream_release_duplex(struct snd_tscm *tscm)
-{
-       if (tscm->substreams_counter == 0) {
-               fw_iso_resources_free(&tscm->tx_resources);
-               fw_iso_resources_free(&tscm->rx_resources);
-       }
-}
-
 int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
 {
        unsigned int generation = tscm->rx_resources.generation;
@@ -397,12 +388,8 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
                return 0;
 
        if (amdtp_streaming_error(&tscm->rx_stream) ||
-           amdtp_streaming_error(&tscm->tx_stream)) {
-               amdtp_stream_stop(&tscm->rx_stream);
-               amdtp_stream_stop(&tscm->tx_stream);
-
+           amdtp_streaming_error(&tscm->tx_stream))
                finish_session(tscm);
-       }
 
        if (generation != fw_parent_device(tscm->unit)->card->generation) {
                err = fw_iso_resources_update(&tscm->tx_resources);
@@ -452,9 +439,6 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
 
        return 0;
 error:
-       amdtp_stream_stop(&tscm->rx_stream);
-       amdtp_stream_stop(&tscm->tx_stream);
-
        finish_session(tscm);
 
        return err;
@@ -463,10 +447,10 @@ error:
 void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm)
 {
        if (tscm->substreams_counter == 0) {
-               amdtp_stream_stop(&tscm->tx_stream);
-               amdtp_stream_stop(&tscm->rx_stream);
-
                finish_session(tscm);
+
+               fw_iso_resources_free(&tscm->tx_resources);
+               fw_iso_resources_free(&tscm->rx_resources);
        }
 }