Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1727318

[PATCH 1/3] ALSA: bebob: Use common error handling code in snd_bebob_stream_start_duplex()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/3] ALSA: bebob: Use common error handling code in snd_bebob_stream_start_duplex()
Date 2017-09-06 12:30 +0200
Message-ID <umFKO-lj-11@gated-at.bofh.it> (permalink)
References <umFKO-lj-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Sep 2017 11:40:53 +0200

Add jump targets 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/firewire/bebob/bebob_stream.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index 4d3034a68bdf..bc9e42b6368e 100644
--- a/sound/firewire/bebob/bebob_stream.c
+++ b/sound/firewire/bebob/bebob_stream.c
@@ -629,8 +629,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)
 		if (err < 0) {
 			dev_err(&bebob->unit->device,
 				"fail to run AMDTP master stream:%d\n", err);
-			break_both_connections(bebob);
-			goto end;
+			goto break_connections;
 		}
 
 		/*
@@ -644,19 +643,15 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)
 				dev_err(&bebob->unit->device,
 					"fail to ensure sampling rate: %d\n",
 					err);
-				amdtp_stream_stop(&bebob->rx_stream);
-				break_both_connections(bebob);
-				goto end;
+				goto stop_rx_stream;
 			}
 		}
 
 		/* wait first callback */
 		if (!amdtp_stream_wait_callback(&bebob->rx_stream,
 						CALLBACK_TIMEOUT)) {
-			amdtp_stream_stop(&bebob->rx_stream);
-			break_both_connections(bebob);
 			err = -ETIMEDOUT;
-			goto end;
+			goto stop_rx_stream;
 		}
 	}
 
@@ -666,9 +661,7 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)
 		if (err < 0) {
 			dev_err(&bebob->unit->device,
 				"fail to run AMDTP slave stream:%d\n", err);
-			amdtp_stream_stop(&bebob->rx_stream);
-			break_both_connections(bebob);
-			goto end;
+			goto stop_rx_stream;
 		}
 
 		/* wait first callback */
@@ -682,6 +675,12 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate)
 	}
 end:
 	return err;
+
+stop_rx_stream:
+	amdtp_stream_stop(&bebob->rx_stream);
+break_connections:
+	break_both_connections(bebob);
+	return err;
 }
 
 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob)
-- 
2.14.1

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 1/3] ALSA: bebob: Use common error handling code in  snd_bebob_stream_start_duplex() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-09-06 12:30 +0200

csiph-web