Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1360975ybi; Sun, 16 Jun 2019 03:18:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7BO+sRLouPxxm0pabnzXnQBQ+mwoB9tmwyDyKhqby86qOoN7mqUvQXGXYz734vv1OAZ+N X-Received: by 2002:a65:508b:: with SMTP id r11mr13278778pgp.387.1560680307730; Sun, 16 Jun 2019 03:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560680307; cv=none; d=google.com; s=arc-20160816; b=sph16Ms/ov5qewJRaTp9Uwu/gMHHVpJLyBJsqmT69szdpimqje8lOn7wR4A+iwGi37 ypO/CK6Ybw9cC90fmtB51gjKXucrOVqt+BDCRNv2buV8x+xPc6CQwWYGX0GukWp3f0E0 R1/nj8YCr2IquAv+4g/9z7IoPI5981lrq4eScIeP80yeyUU2Hq7Do3sRpM0+uRgcDUDE kmcvcOrxjRAH4fsA/D8J00alBEs/1QoUZ3KEWYt8zmVDDgq+17dytLYjMUT4kjDKuV6W Q22ZvZzNAwhA2pcDfz81rSolL8xbafrgc/diquM3/FvOqJXtWXki0umxbGHlHf69+BNO UiGQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=TCJsVtH1ZRP8lE3k69aQv/jdlzfSMJZ3mkm6+VJWr8o=; b=jfY0gYpcTlQR3TShvzheKtLM7E8YUWairYIGyIOQY/F8mKppEp3Ij6oZWa778cT8y0 6U4gJ5KyCZwoNg6xTb4FntmmPkfxBY/6Il91b3YG9HUMj7hTss6t3qGTUUD8/uJUFp4u VRvlaVRnVeK+8aLJT+2aY1KAxEljsEqr1PBFOwkfd1Lxyeyt8yyf4e458dTi/fVef7u3 lS3p4yhSlhLeaRBl6sVcv3a4xh/mDUI3wwnn3Ilz8ZODN1l4AzNU2wNGuQK4uQTwZCmT BtbQZgc+OFdihsRSdbK8pJM481aEXj5ZVkvengSlrad0oHlt4swpdcPgfpmXVxikqxS/ mc2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="t3Y/hPQk"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si8237717pgg.386.2019.06.16.03.18.12; Sun, 16 Jun 2019 03:18:27 -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="t3Y/hPQk"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726266AbfFPKSI (ORCPT + 99 others); Sun, 16 Jun 2019 06:18:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:33050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbfFPKSI (ORCPT ); Sun, 16 Jun 2019 06:18:08 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 778A32084A; Sun, 16 Jun 2019 10:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560680287; bh=22Nyl8r5NyujEokw6IbfB3M3uwmZEcDVVxHqLyjGrAo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=t3Y/hPQk6Y8RrOPdI2Afc/IrTEmx6ELkPRXG2g3JQvnVpf0/lB8YuwpJDRo5pnqVG Qp/2WjOqyaRYXdrz2s5yzJn1wvEFF7IVaXzJ8py/MQL/yw3Ysj2wl4IwC2/kGmI/1e vcrL17OhNPhmcA+2889gkgcyOon4gipSdMgXs6v4= Date: Sun, 16 Jun 2019 11:18:02 +0100 From: Jonathan Cameron To: Melissa Wen Cc: 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, linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com Subject: Re: [PATCH v2 1/3] staging: iio: ad7150: use FIELD_GET and GENMASK Message-ID: <20190616111802.51498c02@archlinux> In-Reply-To: <4f88fd66e478289006353645d84b7af1b5aa345c.1560529045.git.melissa.srw@gmail.com> References: <4f88fd66e478289006353645d84b7af1b5aa345c.1560529045.git.melissa.srw@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Jun 2019 13:32:21 -0300 Melissa Wen wrote: > Use the bitfield macro FIELD_GET, and GENMASK to do the shift and mask in > one go. This makes the code more readable than explicit masking followed > by a shift. > > Signed-off-by: Melissa Wen Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to paly with it. Thanks, Jonathan > --- > drivers/staging/iio/cdc/ad7150.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c > index 8234da4b8c65..091aa33589d7 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 > @@ -45,6 +46,9 @@ > #define AD7150_SN0 22 > #define AD7150_ID 23 > > +/* AD7150 masks */ > +#define AD7150_THRESHTYPE_MSK GENMASK(6, 5) > + > /** > * struct ad7150_chip_info - instance specific chip data > * @client: i2c client for this device > @@ -137,7 +141,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, > if (ret < 0) > return ret; > > - threshtype = (ret >> 5) & 0x03; > + threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret); > adaptive = !!(ret & 0x80); > > switch (type) {