Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1197011ybn; Wed, 2 Oct 2019 12:17:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6I13s8sURDf9V+b1JTdynOBAfLyYVv/l3ROcauvOAKBpyicF8Fb60sl02LqmHm8dx5Pwl X-Received: by 2002:aa7:cf86:: with SMTP id z6mr5442247edx.230.1570043823258; Wed, 02 Oct 2019 12:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043823; cv=none; d=google.com; s=arc-20160816; b=opOk73WzCBN1F/a8Li/f4YW7r1LVQ7nkKHCIFIcHxxsyKr4nZVIcxOxPy1v9/fWrWe gMV54G0qcwcCbyZh3pDp26wvHjF6QLUPst+NJegCPNWnxgqio3gG+dr7JwPSwCGA+/uL x4CWpgdZmo7mKIyahzomAFjhlqF+6N5IkmSu/89NQgPTlXR3EWqY4/lH567zaykJ57ZZ T1h1ceJJ3fOQr2K7cAg27uCA6ykNmFFcPc9y60XS4QFOFr016+4xJF1/NuEI6Lvsch3n tg3YDxn/eFjOJtGFHbvWtxZ2u0RjeuqRe/43oCGESh5eL7p8WHH1vkgd8uoQykdOwidP ZUBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=3BNPpiQqyTLOYUtxv6Da1nyjZXOMP/NNGmfaPxVJGs8=; b=EYTqsXaIXwu5C6x64M3SWVVAWx65JRqU1v9Ki7nAV2YbGdAfrkiM5DmLsdIQ522LxA W0+fx+C1NLRiJCEVsErmu1gGY+2R4Wuuar4GhKUnfxapSP29mT3umTnIle/kBlEuOSug bnNcloyPpIB5zCGnGwUcuHV3Nrn5Oa9km20Yll0fQRqHd8ZQaiVvbyesN+saMgulWDhT RVMu8q/qh1tkbue77Oa3a3YHsS08+hHlYKxs1s8fYMPHJ15opDLvxNAEcb3SGk/zCrVn IbsGIpZHdnceDEMp1FG4+Xug1K/quplcoWpC3BFQ6icASVFSbg0CXqGGHNxPXWGAiXSK nTTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f31si35820ede.253.2019.10.02.12.16.39; Wed, 02 Oct 2019 12:17:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730217AbfJBTNh (ORCPT + 99 others); Wed, 2 Oct 2019 15:13:37 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35320 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729083AbfJBTIJ (ORCPT ); Wed, 2 Oct 2019 15:08:09 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyo-000363-Hy; Wed, 02 Oct 2019 20:08:06 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyn-0003cG-SO; Wed, 02 Oct 2019 20:08:05 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Melissa Wen" , "Jonathan Cameron" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 30/87] staging:iio:ad7150: fix threshold mode config bit In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Melissa Wen commit df4d737ee4d7205aaa6275158aeebff87fd14488 upstream. According to the AD7150 configuration register description, bit 7 assumes value 1 when the threshold mode is fixed and 0 when it is adaptive, however, the operation that identifies this mode was considering the opposite values. This patch renames the boolean variable to describe it correctly and properly replaces it in the places where it is used. Fixes: 531efd6aa0991 ("staging:iio:adc:ad7150: chan_spec conv + i2c_smbus commands + drop unused poweroff timeout control.") Signed-off-by: Melissa Wen Signed-off-by: Jonathan Cameron Signed-off-by: Ben Hutchings --- drivers/staging/iio/cdc/ad7150.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -6,6 +6,7 @@ * Licensed under the GPL-2 or later. */ +#include #include #include #include @@ -129,7 +130,7 @@ static int ad7150_read_event_config(stru { int ret; u8 threshtype; - bool adaptive; + bool thrfixed; struct ad7150_chip_info *chip = iio_priv(indio_dev); ret = i2c_smbus_read_byte_data(chip->client, AD7150_CFG); @@ -137,21 +138,23 @@ static int ad7150_read_event_config(stru return ret; threshtype = (ret >> 5) & 0x03; - adaptive = !!(ret & 0x80); + + /*check if threshold mode is fixed or adaptive*/ + thrfixed = FIELD_GET(AD7150_CFG_FIX, ret); switch (type) { case IIO_EV_TYPE_MAG_ADAPTIVE: if (dir == IIO_EV_DIR_RISING) - return adaptive && (threshtype == 0x1); - return adaptive && (threshtype == 0x0); + return !thrfixed && (threshtype == 0x1); + return !thrfixed && (threshtype == 0x0); case IIO_EV_TYPE_THRESH_ADAPTIVE: if (dir == IIO_EV_DIR_RISING) - return adaptive && (threshtype == 0x3); - return adaptive && (threshtype == 0x2); + return !thrfixed && (threshtype == 0x3); + return !thrfixed && (threshtype == 0x2); case IIO_EV_TYPE_THRESH: if (dir == IIO_EV_DIR_RISING) - return !adaptive && (threshtype == 0x1); - return !adaptive && (threshtype == 0x0); + return thrfixed && (threshtype == 0x1); + return thrfixed && (threshtype == 0x0); default: break; }