Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2916785pxb; Tue, 24 Aug 2021 10:32:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSj5XSyf5NgUuzg3zpbTueDWLi8Wx0iMXWDJVzQW0GSiTlLARCjSt+tqB43MdnBpRnM31n X-Received: by 2002:a17:906:a18f:: with SMTP id s15mr33224622ejy.269.1629826328773; Tue, 24 Aug 2021 10:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629826328; cv=none; d=google.com; s=arc-20160816; b=sTQUAiiHqFcdvwNmSkIu0Gux1yj4RYZAjzxBzsKlIeGeRDmqCp0wI5FNezH1piSMwB Z5ufmwej603BwLHL2kBwfVHzXrasvycg6zE2O5VrQq1O8hgDt4N8U991ls7DAOs6gZvl r7AZ4FMAbiD/OBztXy9DsOAUrVFDToHaitxJh5li2ZQUX3nqxWaLdAoIz6J4T3pkwDzO doxRgTj1fvBbOJ2O34BCvzik3qI3iy4iL9z/HXODjir3gKHNqTPY7r+ZkJ/oZMHsMq4p p9PLNS2XWZsPqlwrnBbY3zT/r1hAK0XEzvnPLLrNSsIsRdZwp0Uj/9cQluMYP4MKgyzF wD1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TXl2cC133AUH4peClDY1X15MGE+PZ3VFa+o5AKTYXHM=; b=IrgUNgR056C8ouTWoaP3kvevVzcfUESA+hrzizGTmzt5K9hcGMAssDKC/UACMnWArl 7UpzGpshVyUfcn54mG8t7ugYlU6A5lAXTCKH0sbB1AQ2RYLNyEa5Y8a9sHDUGu0SgQrF udTgFC1LNGZ7KF1gfLfQViSw8TqPXoRRtLP/2B5QLbXQSwUvVpmX1h2QghcX2rsE1GwQ GIpvThURTjMouF3uaJH4FcRtUVuAh6XtstmYJLfxJ733k4+dHYjBGgBMjHtY9ZOhOSyB b8Hfl4XV1Nl5Vohux5b/W1HiaaUrunEHU7A7sm4v552ULoVwHzS4GM27Q7E/Q/AFxwm5 y5pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QPQTwIdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ky22si17150731ejc.543.2021.08.24.10.31.45; Tue, 24 Aug 2021 10:32:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QPQTwIdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240752AbhHXR2q (ORCPT + 99 others); Tue, 24 Aug 2021 13:28:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235597AbhHXR0T (ORCPT ); Tue, 24 Aug 2021 13:26:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78BE3613E6; Tue, 24 Aug 2021 17:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824701; bh=jVALhARwfUqk9BPNTigktFIG3zDSJeIBJc5Z+aI2WQQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPQTwIdUjdhl8wOkG/9usEmS4x1ZVe36KmabzjP496RnRqjX8iKZ9cIkSp7pQIvve A4shI7BHWDOgYdGd0rRneE+CV9MrlWcDiWv2v/BCXP+t8+WllhL1jYYM69fsrYUVnH 9W1liwjpjRpEowXKSJTB6WJ3P2Bbqku/qHblslUm5MUPsxqZEnoO8f/glXb/V08iJK Bsf0ZK3t1zTOmawSEhhzcbBq4rWjaesCK0bGFGdp/EjYO9WTo0DYMra8uX49m/d5H7 snKWqBXj1jgHdQ0qvu6eeJmt1Rv3eR/JSIF9lLES0m4cbnuHLH17Gc43dTW4/VRexs kXAni4k7EQ4CQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Colin Ian King , Jonathan Cameron , Greg Kroah-Hartman Subject: [PATCH 4.14 02/64] iio: adc: Fix incorrect exit of for-loop Date: Tue, 24 Aug 2021 13:03:55 -0400 Message-Id: <20210824170457.710623-3-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170457.710623-1-sashal@kernel.org> References: <20210824170457.710623-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.245-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.245-rc1 X-KernelTest-Deadline: 2021-08-26T17:04+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King commit 5afc1540f13804a31bb704b763308e17688369c5 upstream. Currently the for-loop that scans for the optimial adc_period iterates through all the possible adc_period levels because the exit logic in the loop is inverted. I believe the comparison should be swapped and the continue replaced with a break to exit the loop at the correct point. Addresses-Coverity: ("Continue has no effect") Fixes: e08e19c331fb ("iio:adc: add iio driver for Palmas (twl6035/7) gpadc") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20210730071651.17394-1-colin.king@canonical.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/palmas_gpadc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 7d61b566e148..f5218461ae25 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -660,8 +660,8 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc) adc_period = adc->auto_conversion_period; for (i = 0; i < 16; ++i) { - if (((1000 * (1 << i)) / 32) < adc_period) - continue; + if (((1000 * (1 << i)) / 32) >= adc_period) + break; } if (i > 0) i--; -- 2.30.2