Skip to contentSkip to conversation

ALSA: FireWire-MOTU: Use common error handling code in snd_motu_stream_start_duplex()

PATCH Applied SF Markus Elfring 2 participants 2 messages Sep 6, 2017 – Sep 12, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: FireWire-MOTU: Use common error handling code in snd_motu_stream_start_duplex()

From: Markus Elfring <[email protected]>
Date: Wed, 6 Sep 2017 13:30:14 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

This issue was detected by using the Coccinelle software.

---
 sound/firewire/motu/motu-stream.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
sound/firewire/motu/motu-stream.c +8 -8
index dc5541c8b359..73e7a5e527fc 100644
@@ -253,24 +253,21 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
 		if (err < 0) {
 			dev_err(&motu->unit->device,
 				"fail to start isochronous comm: %d\n", err);
-			stop_both_streams(motu);
-			return err;
+			goto stop_streams;
 		}
 
 		err = start_isoc_ctx(motu, &motu->rx_stream);
 		if (err < 0) {
 			dev_err(&motu->unit->device,
 				"fail to start IT context: %d\n", err);
-			stop_both_streams(motu);
-			return err;
+			goto stop_streams;
 		}
 
 		err = protocol->switch_fetching_mode(motu, true);
 		if (err < 0) {
 			dev_err(&motu->unit->device,
 				"fail to enable frame fetching: %d\n", err);
-			stop_both_streams(motu);
-			return err;
+			goto stop_streams;
 		}
 	}
 
@@ -281,12 +278,15 @@ int snd_motu_stream_start_duplex(struct snd_motu *motu, unsigned int rate)
 			dev_err(&motu->unit->device,
 				"fail to start IR context: %d", err);
 			amdtp_stream_stop(&motu->rx_stream);
-			stop_both_streams(motu);
-			return err;
+			goto stop_streams;
 		}
 	}
 
 	return 0;
+
+stop_streams:
+	stop_both_streams(motu);
+	return err;
 }
 
 void snd_motu_stream_stop_duplex(struct snd_motu *motu)
Signature · 1 line
2.14.1
Applied
#1 lore raw
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 6 Sep 2017 13:30:14 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function.

This issue was detected by using the Coccinelle software.

Applied, thanks.

Takashi