Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp156208yba; Mon, 20 May 2019 06:36:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmzLm8tV3OygyNFcQO+++00dAoCcillZcNaYXBstg9TdOkm0ecnLOIA30LRj1lBTz7m5rR X-Received: by 2002:a17:902:3103:: with SMTP id w3mr863001plb.329.1558359364752; Mon, 20 May 2019 06:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558359364; cv=none; d=google.com; s=arc-20160816; b=mOuwA55CPiXl/BKdkIKHboxylAHJkDXBf5n8hXsonzbIv6pDVo7o5Zn9We9w+3VMtx jbuk1tOGAg0526Im7pUgJz9YG4re/jXoMkuKI86asxFFBD5MAcy+3+OZi8S1+Cu9a3st NDuLlZ2DIKrr0kN2WXqKTNLR0B/aPPhsX9WG9u4ZHzkF1Mw/4q3giuBD0a+xBN734m8v JRUs1AVWbrq8klO3l+3upUX6J5ytC4myM62CwPc1eWNzh6/uPm7K4fNju0AB9XtpkAzp 0PlWNWeiBICAeBFIilUVQ92/4AtoYv6lc04KZKAIYxLizWtEo9EoW7b7mxRje1qilQv1 0bPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sX15Iw5l1LNzMWpN9XQ1qH/8ma8DeddYURAa0CQDGzo=; b=v6pEzmWe0X4f+5rurR29cxRkuPS8oxmw8TYX8aA6lwABaaQhZmdw90yf5jdVs1St6E pSkxo3g8BRwndopgUGabzOgs3gb3s+Amd22u9rLg2XN/6jeSZGv63SF6ycH6k7sePmdo dkmhX2aUZRUzvL3bsnfHmd+PUAKnLyzx392xezl8weDFg/RUARCV2wspLQOu4oAMZvqf 8d4aqus5Z+C5DhfvIW5kKRR23lmIbQkdQQeK8kvtyBR6apfKjx5nvZwdVplkpOFh3Zq/ iVbcb3GrMO0eKXVLzIH+jzlImHgz6m5w5qCzkHDtkS3iWzyHS81KhXq5n0T3wSk2ZrMd 9q7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OKcoO4cv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si7475149plp.321.2019.05.20.06.35.49; Mon, 20 May 2019 06:36:04 -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=@gmail.com header.s=20161025 header.b=OKcoO4cv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731248AbfETKAB (ORCPT + 99 others); Mon, 20 May 2019 06:00:01 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:42344 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730039AbfETKAA (ORCPT ); Mon, 20 May 2019 06:00:00 -0400 Received: by mail-ot1-f65.google.com with SMTP id i2so7052960otr.9; Mon, 20 May 2019 03:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sX15Iw5l1LNzMWpN9XQ1qH/8ma8DeddYURAa0CQDGzo=; b=OKcoO4cvjF2ftHSC7dsg/Ul+Hi416KyLId41DZpB1ZUVdu5OBRqxiajlaBo1enDJtj UtC4m57jqcJbDkWQEZcnRmPSDgl5y4v1mw0XFq0VC30m+cupIlwapNUq2LtPJsWo7Hev Yrh7oW2EVmq658mqXpyarKSJIsFjzg0jhEYGFkGLCKV9G2eeUcEI7IjGf4B+fjMHf7W6 VXxbO1nC+qwNV1zlUkmRjqUGgSJTHusK8ZczWJZea8uBLWT6EDmn00TJGJqSzUwtpmJG hUkZNgm5KiY1AND0loMxy9ZK3nvRINSNK6kL4CFa6POjmL4vRU6y+wexjgmN5ak9QtDR NFbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sX15Iw5l1LNzMWpN9XQ1qH/8ma8DeddYURAa0CQDGzo=; b=nT9ZRzOxuoLzy6EIXJkRcSEq7tzbG3ozqkzuUD3MDEam3GNMzkPGj6+8cRpOKdQpAq eYfnLbWUZiBnwTcUSBSZfy/byaSVZsiVQvHpWo0X0wYToqrS1Roylk9PgPjbt6/JJ4Sd t7WXPkJIirEuQDNjNXynx4LykcM8g/XOjeloLWeiw3ty6t+y3M/zhEDa66rFNNuPALk8 AYuLDrqNdTeOl5P3A6nCVQ5leXINbpK33C/pZ4DC8Kbl1MSgxZZswwMaTVAubzR2Tbwj 5K/nDhTr3RE5AujuS/rh72eJ1bXmtxnv9dLnIPAIBriadeYhmCexoNOkhtAMpr4nntgg Is1g== X-Gm-Message-State: APjAAAU4fF3lqUgiZ1M9Ur7NoG5RKS2D415j+AAB6MiGIc2FInaK6LCo KtXGd9R8yujdCoC4MR+gIgUOTuSWP/g23N9qL4o= X-Received: by 2002:a9d:68c5:: with SMTP id i5mr24555676oto.224.1558346399739; Mon, 20 May 2019 02:59:59 -0700 (PDT) MIME-Version: 1.0 References: <20190519010456.lwq7n2e6nkqa6niz@smtp.gmail.com> <20190519112952.58142fb0@archlinux> In-Reply-To: <20190519112952.58142fb0@archlinux> From: Alexandru Ardelean Date: Mon, 20 May 2019 12:59:47 +0300 Message-ID: Subject: Re: [PATCH] staging:iio:ad7150: fix threshold mode config bit To: Jonathan Cameron Cc: Melissa Wen , Lars-Peter Clausen , Michael Hennerich , Stefan Popa , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Barry Song <21cnbao@gmail.com>, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, LKML , kernel-usp@googlegroups.com, Alexandru Ardelean Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 19, 2019 at 8:38 PM Jonathan Cameron wrote: > > On Sat, 18 May 2019 22:04:56 -0300 > Melissa Wen wrote: > > > 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 > > Looks good to me. Applied to the fixes-togreg branch of iio.git pushed out as > as testing-fixes for the autobuilders to see if they can find anything > we have missed. > > Thanks, > > Jonathan > > > --- > > 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 dd7fcab8e19e..e075244c602b 100644 > > --- a/drivers/staging/iio/cdc/ad7150.c > > +++ b/drivers/staging/iio/cdc/ad7150.c > > @@ -5,6 +5,7 @@ > > * Copyright 2010-2011 Analog Devices Inc. > > */ > > > > +#include > > #include > > #include > > #include > > @@ -130,7 +131,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); > > @@ -138,21 +139,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); nitpick: i would have kept the original variable name as "adaptive", mostly for consistency. "adaptive" is used in other places as well; as i recall, the fix is just oneliner in this case: - adaptive = !!(ret & 0x80); + adaptive = !(ret & 0x80); > > > > 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; > > } >