From patchwork Fri Feb 13 13:14:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 23109 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A6AA6DDDA0 for ; Sat, 14 Feb 2009 00:14:26 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760179AbZBMNOY (ORCPT ); Fri, 13 Feb 2009 08:14:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760162AbZBMNOX (ORCPT ); Fri, 13 Feb 2009 08:14:23 -0500 Received: from ey-out-2122.google.com ([74.125.78.24]:25046 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760131AbZBMNOW (ORCPT ); Fri, 13 Feb 2009 08:14:22 -0500 Received: by ey-out-2122.google.com with SMTP id 25so142474eya.37 for ; Fri, 13 Feb 2009 05:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=b222XwvqM5Cdfm11HZwHElg89M5qeyBS/AnYVW5RFtE=; b=qjj5qwYLVau/v47toN3/L/+8aiYY5NUIv9x6i08DL/8iVFGxb2BU5L0s8v92+Ti4/k hlVU8SmDiTAsa+N7CHOYStOBkx5l8gIqI35IMDsPyvLaZSiZ0rPLilEReoNS5rnptDkR uMha78smIAJ6nkVhZB+mImcBNRnRnS7U+XzQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=hfwfGmUrDhBGq/X7X8dFi9f86IVZItNiyuPvEesWE+cXNShYm64VH8wLtz6MqgLo/M G9/dN+p/Sindqh2Y3y84zjRznXmTNrWGmRfScG5QpjUWu+feF9Ozm2NJqOk2X5F4zOxD ounXk6Lnhf4cpliVJTaA+p9Pa3OlQHj4hOEvw= Received: by 10.210.120.17 with SMTP id s17mr1624410ebc.54.1234530858099; Fri, 13 Feb 2009 05:14:18 -0800 (PST) Received: from ?192.168.1.115? (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 28sm2049519eyg.35.2009.02.13.05.14.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Feb 2009 05:14:17 -0800 (PST) Message-ID: <49957229.9060401@gmail.com> Date: Fri, 13 Feb 2009 14:14:17 +0100 From: Roel Kluin User-Agent: Thunderbird 2.0.0.18 (X11/20081105) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Juha_Lepp=E4nen?= CC: davem@davemloft.net, netdev@vger.kernel.org, Jarek Poplawski , Andrew Morton Subject: Re: IRDA: mcs7780.c References: <1234514947203.juha_motorsportcom.12982.AOyeEm8k4zVzAxDijub1SA@luukku.com> In-Reply-To: <1234514947203.juha_motorsportcom.12982.AOyeEm8k4zVzAxDijub1SA@luukku.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Juha Leppänen wrote: > Hi, > > In recent patch to file > > drivers/net/irda/mcs7780.c That's this one: http://www.spinics.net/lists/netdev/msg88746.html [PATCH] IRDA: cnt is off by 1 > I noticed when checking the code around the patch ... > In worst case do {...} while loop is executed > 101 times --> mcs_get_reg() is executed 101 times... > But rval is checked only 100 times. Right, thanks. > If you change the order of the && expressions inside while () to > > - } while(cnt++ < 100 && (rval & MCS_IRINTX)); > + } while((rval & MCS_IRINTX) && cnt++ < 100); > If you also want exactly 100 maximum mcs_get_reg() > tries ( now it is 101 ) ... I don't think it really matters, does it? > Happy hacking, > > Mr. Juha Leppänen > Kuopio, Finland You too. ------------------------------>8----------------8<------------------------------ If no prior break occurs, cnt reaches 101 after the loop, so we are still able to change speed when cnt has become 100. Signed-off-by: Roel Kluin --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c index 7eafdca..8fdfb5a 100644 --- a/drivers/net/irda/mcs7780.c +++ b/drivers/net/irda/mcs7780.c @@ -583,9 +583,9 @@ static int mcs_speed_change(struct mcs_cb *mcs) do { mcs_get_reg(mcs, MCS_RESV_REG, &rval); - } while(cnt++ < 100 && (rval & MCS_IRINTX)); + } while((rval & MCS_IRINTX) && cnt++ < 100); - if(cnt >= 100) { + if (cnt > 100) { IRDA_ERROR("unable to change speed\n"); ret = -EIO; goto error;