Received: by 10.213.65.68 with SMTP id h4csp964075imn; Thu, 22 Mar 2018 12:16:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELs6Q8qeNcfTKiMlyONGUDl2ol4U1hMcwkN8dP+Jn/4t3j54AQCcbCWxQe0AgWEl9t7jwGCd X-Received: by 2002:a17:902:d207:: with SMTP id t7-v6mr9392684ply.216.1521746191238; Thu, 22 Mar 2018 12:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521746191; cv=none; d=google.com; s=arc-20160816; b=0Z16jj7pT6lfDoNA5sHqNDiSM25Qv5zchky4nClIY3qpLdkuzVCq8cGfn5KeFS+oB/ P0ve4w0N8TvSE+QijDOKaa+y4Tuv7mzgSr2X5uyMfG53zUaiJnv2uallqBZYHwnKZmRO sfPj/LmfMzB8azlPCUHFSs3LYjqNXXbhrWW4+QcZfkGvqwFoiftTbvr1hqSUY4LC3yvf 1+7fD0HsUtsg668LzCYEBIfzNyTjN2+r7ZKDlGBjvf40Y2L4kGaSYlq4+RdNLyB5CQOR Z1DaU3r0HbjQYU7q7Coo1u/kjmqoH/AQLphcX7jwiXkT2AiT6M7pCjYN9iPVTspVktej iS8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=4PpvmNGRuHtFZUjwvJ3trU7QaYWdtfqKyOw8Zc+BfKk=; b=PB2XWemM69TY7bdue8g92mxjdKwm9sFUzqN70c0SU04r6W6Om50fNVXRNO5g+Bys5Z CG4KPEqpbHWp7prm5P8qbmZA7y5W0FNjzAsm6zPB5SFZgxcVzu1pVolJYdMPAfSU53Dc gSVrC+ORIxU54q4LM0K97cA4fXzemZTj2CRSjAlJpuZcL16Lm6FdOd6p9nqqVoC0YSUm CvF747DSmg6Ff9pwsQSk3YvPNKVkjsuV6SRfAVLNX/9GOx3yejYKHtBln/+d+pZzQGLI PvXIDliWn8z64tuZWZqUMZWw0r6Oa6g7kY9pGezN5x4VoZORj7xfjg1BgtnL0Jxh1HMA 7nRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TJdkwzDZ; 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 i68si3078665pfc.129.2018.03.22.12.15.46; Thu, 22 Mar 2018 12:16:31 -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=TJdkwzDZ; 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 S1751901AbeCVTNN (ORCPT + 99 others); Thu, 22 Mar 2018 15:13:13 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:32920 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751831AbeCVTNK (ORCPT ); Thu, 22 Mar 2018 15:13:10 -0400 Received: by mail-pl0-f68.google.com with SMTP id c11-v6so5928120plo.0; Thu, 22 Mar 2018 12:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4PpvmNGRuHtFZUjwvJ3trU7QaYWdtfqKyOw8Zc+BfKk=; b=TJdkwzDZTyyxeK46gSyCR9FOQwBfnGJE4He6uTV++rrhVfD+PGzIFvI0BOOztyFkhS VxQyMfTjPje8bZXvS5sxdcUBPV+xEntHVnnOfYZLy+Ay5eWottmTWycq07bDdSRTIRQG sJ2JFQ2QWTUgPlm/tO+uvBbszczq0piMVR68iLS8Yn3FvbkzZPIfMqJO1FNl5oTOPN3O PzLHC/7Jr1dcQG9Equ98N9n+zM/IWrCWmI7A0E0JjuHTxb9DorEZOfHx7s/BnmHtEtJA h3R7luV43eKSZMBLWcAENe1O86kW5txI007AaZkLLL3N7H2nCmpUEZcqEFzjiWoS2q/F +0WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4PpvmNGRuHtFZUjwvJ3trU7QaYWdtfqKyOw8Zc+BfKk=; b=hbZYF67g9S/frSU8a9ZO+ipKCHfMI4ezoEybi1rXMOuBFQ2ROcsx9vp3a39Qv7Z6iS ZcdjLFAdygeYIgyVZ1KIcbDoG6TW5HGjbacu9nPGgmwzut8sBQLoFBayYWZfKp7ZM6LQ npvrn95N7fd0N5xtCSkzcpER1f5d2SV1dl2iqJD7CyPkfesBhYpoGLJJ8PQlOeKKPU8/ 3iNbjseuL+9qyPn2JlPkZ/wFuypA0SIZASRDvsb2F0MNRqgxpg7UHZ1tefBSULxst09j L9OJ2u/pkQriPIbvYh7ApKuGAK2b5PZYT7/AmYOTxKurm5LxaH2RalmoJQqEfaYccuy0 Gk4Q== X-Gm-Message-State: AElRT7FeUYp6853nB4xPDffTSvaNuEKnn6Ya8Hibt5lH9dHAgSRHyVpl F1xjSEBjGr4na+O9RhtMIavCVA== X-Received: by 2002:a17:902:8206:: with SMTP id x6-v6mr19660253pln.256.1521745990085; Thu, 22 Mar 2018 12:13:10 -0700 (PDT) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id w83sm15089628pfi.33.2018.03.22.12.13.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Mar 2018 12:13:09 -0700 (PDT) From: Himanshu Jha To: jic23@kernel.org 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, Himanshu Jha Subject: [PATCH 2/4] Staging: iio: accel: adis16201: Use GENMASK Date: Fri, 23 Mar 2018 00:42:43 +0530 Message-Id: <1521745965-26972-2-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521745965-26972-1-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use GENMASK to improve readability and remove the local variables used to store intermediate data. Signed-off-by: Himanshu Jha --- 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[] = { -- 2.7.4