All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Elvis Pfützenreuter" <epx@signove.com>
To: Santiago Carot-Nemesio <sancane@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Change the for loop to read blutooth clock in MCAP CSP
Date: Fri, 17 Sep 2010 08:56:50 -0300	[thread overview]
Message-ID: <F43E63DF-F78C-403B-B960-F302339BF7C3@signove.com> (raw)
In-Reply-To: <1284709950-5302-1-git-send-email-sancane@gmail.com>

On Sep 17, 2010, at 4:52 AM, Santiago Carot-Nemesio wrote:

> This is only a cosmetic change. Using a do..while loop
> we avoid direct manipulation of counter loop variable
> when error happens reading the BT clock.
> ---
> health/mcap_sync.c |   10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/health/mcap_sync.c b/health/mcap_sync.c
> index bc1ffcd..78cb163 100644
> --- a/health/mcap_sync.c
> +++ b/health/mcap_sync.c
> @@ -406,18 +406,18 @@ static void initialize_caps(struct mcap_mcl *mcl)
> 
> 	/* Do clock read a number of times and measure latency */
> 	avg = 0;
> -	for (i = 0; i < 20; ++i) {
> +	i = 0;
> +	do {
> 		clock_gettime(CLK, &t1);
> -		if (!read_btclock(mcl, &btclock, &btaccuracy)) {
> -			--i;
> +		if (!read_btclock(mcl, &btclock, &btaccuracy))
> 			continue;
> -		}
> 		clock_gettime(CLK, &t2);
> 
> 		latency = time_us(&t2) - time_us(&t1);
> 		latencies[i] = latency;
> 		avg += latency;
> -	}
> +		i++;
> +	} while (i < 20);
> 	avg /= 20;
> 
> 	/* Calculate deviation */
> -- 
> 1.7.2.3

Looking again now, this (the logic, not the patch) may lead to an infinite loop, if for some reason the clock simply can't be read. One more thing to be fixed.

  reply	other threads:[~2010-09-17 11:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-17  7:52 [PATCH] Change the for loop to read blutooth clock in MCAP CSP Santiago Carot-Nemesio
2010-09-17 11:56 ` Elvis Pfützenreuter [this message]
2010-09-17 12:37   ` Santiago Carot-Nemesio

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=F43E63DF-F78C-403B-B960-F302339BF7C3@signove.com \
    --to=epx@signove.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=sancane@gmail.com \
    /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.