Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp836291ybi; Fri, 12 Jul 2019 05:27:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEurScTOml1oLBL7yppKtrnWnLUkB4JLPGF/+gC2L1gos15AJxOlbeNNDcKBnl4FApl0Mu X-Received: by 2002:a17:90a:1904:: with SMTP id 4mr11799197pjg.116.1562934471303; Fri, 12 Jul 2019 05:27:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562934471; cv=none; d=google.com; s=arc-20160816; b=EePp0D28pSurmQVLISG1GDnLF/vEYkqpCDEXE/4XQpZmGvxsRWvpS76vNzwYks18VR 7ZwlvUPVZOMLf3XwqqxJ19oxGnDjvzWrY814SysVnuvbHih0/RMhp9jGSctXEY+3GvL8 US6GbAGZzlnyDRp6ertxTXVexx9XI0V1DjvEx6bc5qXnPOG35nJn+UGWik90mSkZR64y y87xI4c/PdANMWY54WtNUn8pUHIq90J/DWU9qpgG43w22IAjgTsGr/cUGg+gXUqKGnOD 3RPZae+e0vdJQJMd4FbfTXlPrCl2RPPbF/8s8H+PVtk2o30jZWDcs3Sunzh3xt24XwEY PhtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+acHbh8cZQWHE8HAMPYpJ93Q/UVWih45yQmrGuMEa+4=; b=WWTYq7VpxbmYHAXlk0ZdsrpR+vWGNXIu6qn4bl4OyTBNvzU2GhZjbrFvd974iyLUtW TdL8BfZvF68JlKM6QtmD18QFJ3icPnBKcTe2NJSa6QNTrrrvuNXnpOJGBrClhmC/4CiC rrAc+2JkMB4Yo40LSJ4RT3uswuoJD0tGwqqCN41rt/CRUA3ZRm7ZtVXK8tBO9BsIHvSl AbqWrkEDb61AtI+276KrGI5XRuA3ULnZy9RH/o1HNJ67wOYw5P4JqaCQ/EPgvycUmpPr Qk2J1IqbKnqMaOHHhvUkKLffbL/oZpOm7+VYGKcNLIUS3tkWQIm3rNAuSGqbGPGIcaPB F0JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vhbkdlhW; 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 a2si7795860pgq.298.2019.07.12.05.27.35; Fri, 12 Jul 2019 05:27:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vhbkdlhW; 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 S1728270AbfGLMZ0 (ORCPT + 99 others); Fri, 12 Jul 2019 08:25:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:35372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbfGLMZX (ORCPT ); Fri, 12 Jul 2019 08:25:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BA382084B; Fri, 12 Jul 2019 12:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562934323; bh=cbA3rxIacYN8iqW5ScCQuOlVk3Ps2vZiVALTOwYiYOE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vhbkdlhWJoovnSjIdgWEWw4X+afTyZ0FVH+Feh1//M5aqpoX713HFig30nL5H7Y6q T/GlTm3hpFvAhrZireFnBL3EVoi1jAIg7ACbKQON96KswmIOJUrysMOohXB9+/5aR4 OgLTh6hhX3xsftJxAtCfjaCVTP0I+Usa5ax2Zs54= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Melissa Wen , Jonathan Cameron , Sasha Levin Subject: [PATCH 5.1 018/138] staging:iio:ad7150: fix threshold mode config bit Date: Fri, 12 Jul 2019 14:18:02 +0200 Message-Id: <20190712121629.417081578@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190712121628.731888964@linuxfoundation.org> References: <20190712121628.731888964@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit df4d737ee4d7205aaa6275158aeebff87fd14488 ] 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: Sasha Levin --- drivers/staging/iio/cdc/ad7150.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 24f74ce60f80..14596aa7eaf1 100644 --- 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 @@ -131,7 +132,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, { 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); @@ -139,21 +140,23 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, 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; } -- 2.20.1