Received: by 10.213.65.68 with SMTP id h4csp1244375imn; Sat, 24 Mar 2018 07:17:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELs//rNV+pMg1WAv8Uz4ArVhrI3XSU+9rTLkSlnXDsmlTkriS+DPC2bw3GoLOOblV7pS5YxZ X-Received: by 10.101.97.13 with SMTP id z13mr23646621pgu.54.1521901038249; Sat, 24 Mar 2018 07:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521901038; cv=none; d=google.com; s=arc-20160816; b=ttvDyhdYCU9NvgUs7L1UA3gqNQp7zLDDunWz0PbSG1WaCMZE2KDHrgaR4CbN/DpK3t Xt/Kg6vhAr8bhpCpG+KaAaCzKH1h9E8lBXaEzpJNRZixkQx99/UL7cn/5nOyxm26EwVe ocaty1+z6gNLwyv5P3hVKPKzMTiS7OWU190jDMAHhq1Z8XuVxT39JsfDq3L3akQ1VFQ2 LRm4q/fD7ErVpCm96xjbMFwqIhFIgogTrdNza5Phn1BahVzpN6MV6l9nqLbLftUtf66W jJoL99cV8Adx7FJWjluQwzHMfX29bylScFPcabFQnQvnZ2mmkVWDLU/yjjHIC635Y+lO ZHbg== 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 :dmarc-filter:arc-authentication-results; bh=AVYZoxJQvBJAFqCQ/WC/1PGG91O8QfDpYbDCQZt4pSs=; b=lMRwhqRXWsT/0o+FrMuU5EU7Qf85KQaDMjYM5GiBHN+nRSDdc/UgHlzKBfMqvOz/Gn lBDkaydW7JSrlj4NalMdpL+fg19puLaL4/gDFQt8Wf1R22dSIuo0fjbnCasHnYpTRAlS UqOC4JgzwZE+HE4cnVpzs0PH0902aYAYozhucnOy6Se2g2aAx82jdu4yx1hEmTL0mFQQ BKwvQbivkDwZ1mQ06HFjBtMZURjp2/YWyJTWXyfUAPhPCMWdzrzCzaI6q6F56iFoH1+y GE+1o+6ebHOdJ81nyShg8PU26SHr02+osf9tt302i36WmcO/+00pNcfoGuDz3lfxQi2U aVkg== 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 b17si7396853pgu.407.2018.03.24.07.17.03; Sat, 24 Mar 2018 07:17:18 -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 S1752279AbeCXOQI (ORCPT + 99 others); Sat, 24 Mar 2018 10:16:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:42148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752213AbeCXOQH (ORCPT ); Sat, 24 Mar 2018 10:16:07 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 80C1721770; Sat, 24 Mar 2018 14:16:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80C1721770 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sat, 24 Mar 2018 14:16:01 +0000 From: Jonathan Cameron To: Himanshu Jha Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de, pmeerw@pmeerw.net, gregkh@linuxfoundation.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, 21cnbao@gmail.com Subject: Re: [PATCH 2/4] Staging: iio: accel: adis16201: Use GENMASK Message-ID: <20180324141601.7faf0c8e@archlinux> In-Reply-To: <1521745965-26972-2-git-send-email-himanshujha199640@gmail.com> References: <1521230786-18155-10-git-send-email-himanshujha199640@gmail.com> <1521745965-26972-1-git-send-email-himanshujha199640@gmail.com> <1521745965-26972-2-git-send-email-himanshujha199640@gmail.com> X-Mailer: Claws Mail 3.16.0 (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, 23 Mar 2018 00:42:43 +0530 Himanshu Jha wrote: > Use GENMASK to improve readability and remove the local variables used to > store intermediate data. > > Signed-off-by: Himanshu Jha Applied to the togreg branch of iio.git. Thanks, Jonathan > --- > drivers/staging/iio/accel/adis16201.c | 34 +++++++++++++++------------------- > 1 file changed, 15 insertions(+), 19 deletions(-) > > diff --git a/drivers/staging/iio/accel/adis16201.c b/drivers/staging/iio/accel/adis16201.c > index b04dbb3..e7593fa 100644 > --- a/drivers/staging/iio/accel/adis16201.c > +++ b/drivers/staging/iio/accel/adis16201.c > @@ -185,28 +185,24 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, > long mask) > { > struct adis *st = iio_priv(indio_dev); > - int bits; > - s16 val16; > - u8 addr; > + int m; > > - switch (mask) { > - case IIO_CHAN_INFO_CALIBBIAS: > - switch (chan->type) { > - case IIO_ACCEL: > - bits = 12; > - break; > - case IIO_INCLI: > - bits = 9; > - break; > - default: > - return -EINVAL; > + if (mask != IIO_CHAN_INFO_CALIBBIAS) > + return -EINVAL; > + > + switch (chan->type) { > + case IIO_ACCEL: > + m = GENMASK(11, 0); > + break; > + case IIO_INCLI: > + m = GENMASK(8, 0); > + break; > + default: > + return -EINVAL; > } > - val16 = val & ((1 << bits) - 1); > - addr = adis16201_addresses[chan->scan_index]; > - return adis_write_reg_16(st, addr, val16); > - } > > - return -EINVAL; > + return adis_write_reg_16(st, adis16201_addresses[chan->scan_index], > + val & m); > } > > static const struct iio_chan_spec adis16201_channels[] = {