From patchwork Wed Jul 13 06:57:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 970742 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6D6vkO6013055 for ; Wed, 13 Jul 2011 06:57:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750980Ab1GMG5p (ORCPT ); Wed, 13 Jul 2011 02:57:45 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:37945 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750849Ab1GMG5p (ORCPT ); Wed, 13 Jul 2011 02:57:45 -0400 Received: by iwn6 with SMTP id 6so5309930iwn.19 for ; Tue, 12 Jul 2011 23:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=k4nDy2UuwTOedNZ99aVs9AjIZxgk0iRZ77maqVallJo=; b=HTxPnLpSyOoQ+VOdMsNwiSe1zlqA4wG0IIaCyPKrca1N6f0Ox1WJBDca1xy826JCH4 Gew6c2HseQhF6Ak+6Epj7PyzVGmbtJdGoGbEWI0nqEiVCJmxN0eu9V4lgCTTRFuJsI98 rmepIJaEW2RupEk3IheaRvQTGuBax36Xn1680= Received: by 10.231.166.142 with SMTP id m14mr687863iby.116.1310540264541; Tue, 12 Jul 2011 23:57:44 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-98-234-113-65.hsd1.ca.comcast.net [98.234.113.65]) by mx.google.com with ESMTPS id v3sm1759444ibh.50.2011.07.12.23.57.41 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Jul 2011 23:57:42 -0700 (PDT) Date: Tue, 12 Jul 2011 23:57:37 -0700 From: Dmitry Torokhov To: Axel Lin Cc: linux-kernel@vger.kernel.org, "Sreedhara Murthy. D.S" , linux-input@vger.kernel.org, Alan Cox Subject: Re: [PATCH] Input: intel-mid-touch - remove pointless checking for variable 'found' Message-ID: <20110713065737.GA4201@core.coreip.homeip.net> References: <1310454831.16511.1.camel@phoenix> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1310454831.16511.1.camel@phoenix> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 13 Jul 2011 06:57:47 +0000 (UTC) On Tue, Jul 12, 2011 at 03:13:51PM +0800, Axel Lin wrote: > The implementation does break from the for loop after we assign i to variable > 'found'. > Hmm, if we are cleaning this up what about the following? Thanks. diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c index 66c96bf..3276952 100644 --- a/drivers/input/touchscreen/intel-mid-touch.c +++ b/drivers/input/touchscreen/intel-mid-touch.c @@ -448,15 +448,11 @@ static int __devinit mrstouch_read_pmic_id(uint *vendor, uint *rev) */ static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev) { - int err, i, found; + int found = 0; + int err, i; u8 r8; - found = -1; - for (i = 0; i < MRSTOUCH_MAX_CHANNELS; i++) { - if (found >= 0) - break; - err = intel_scu_ipc_ioread8(PMICADDR0 + i, &r8); if (err) return err; @@ -466,16 +462,15 @@ static int __devinit mrstouch_chan_parse(struct mrstouch_dev *tsdev) break; } } - if (found < 0) - return 0; if (tsdev->vendor == PMIC_VENDOR_FS) { - if (found && found > (MRSTOUCH_MAX_CHANNELS - 18)) + if (found > MRSTOUCH_MAX_CHANNELS - 18) return -ENOSPC; } else { - if (found && found > (MRSTOUCH_MAX_CHANNELS - 4)) + if (found > MRSTOUCH_MAX_CHANNELS - 4) return -ENOSPC; } + return found; }