linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Simplify logic to calculate the BT/system clock latency
@ 2010-09-22  7:03 Santiago Carot-Nemesio
  2010-09-22  7:03 ` [PATCH 2/2] Remove magic numbers in MCAP CSP Santiago Carot-Nemesio
  2010-09-22  7:59 ` [PATCH 1/2] Simplify logic to calculate the BT/system clock latency Johan Hedberg
  0 siblings, 2 replies; 4+ messages in thread
From: Santiago Carot-Nemesio @ 2010-09-22  7:03 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Santiago Carot-Nemesio

This is only a cosmetic change. Using a while loop
we avoid direct manipulation of counter loop variable
when error happens reading the BT clock.
---
 health/mcap_sync.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/health/mcap_sync.c b/health/mcap_sync.c
index 670260b..3d54936 100644
--- a/health/mcap_sync.c
+++ b/health/mcap_sync.c
@@ -384,12 +384,12 @@ static gboolean initialize_caps(struct mcap_mcl *mcl)
 
 	/* Do clock read a number of times and measure latency */
 	avg = 0;
+	i = 0;
 	retries = 10;
-	for (i = 0; i < 20 && retries > 0; ++i) {
+	while ((i < 20) && (retries > 0)) {
 		clock_gettime(CLK, &t1);
 		if (!read_btclock(mcl, &btclock, &btaccuracy)) {
-			--i;
-			--retries;
+			retries--;
 			continue;
 		}
 		clock_gettime(CLK, &t2);
@@ -397,6 +397,7 @@ static gboolean initialize_caps(struct mcap_mcl *mcl)
 		latency = time_us(&t2) - time_us(&t1);
 		latencies[i] = latency;
 		avg += latency;
+		i++;
 	}
 
 	if (retries <= 0)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-22  7:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-22  7:03 [PATCH 1/2] Simplify logic to calculate the BT/system clock latency Santiago Carot-Nemesio
2010-09-22  7:03 ` [PATCH 2/2] Remove magic numbers in MCAP CSP Santiago Carot-Nemesio
2010-09-22  7:59   ` Johan Hedberg
2010-09-22  7:59 ` [PATCH 1/2] Simplify logic to calculate the BT/system clock latency Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).