Received: by 10.213.65.68 with SMTP id h4csp1316525imn; Thu, 29 Mar 2018 02:22:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx49C3zBmBumHusZ8rL0kcLnOYwCTofGT/JQe/m0y1q8rzmWCru9aobdF201ehlTCBc1dV2rp X-Received: by 2002:a17:902:bc45:: with SMTP id t5-v6mr7463269plz.343.1522315354645; Thu, 29 Mar 2018 02:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522315354; cv=none; d=google.com; s=arc-20160816; b=WzD8B1rMker3vfVxZjnLyyvR2y0DtYxjlNGhspMg738wjkUbHVAP9+BZOC4fyQkB8F oysr95K+6hJwHofldy1D5saEOMNPiXWtFDpqP1TzJdoXVektkc+R68IegSfxmekEy+JL n+zCU4N7NSrG7bNaHAFexar9ruOZb6XlC6wHiuVkx0o5KrpLSnLvV/LXzO94Es34OLt4 NUX22esGe5+kxv6RLlo+ro5iRY+lzkXqADXaPZBssvcS+ZRLd7+UivukJMNYcTJlDn8g xNgWCLaRAXGkXDGVy5iBo0eD+4wnP7VS8c1jx7QyLSQR0Th8fKsyPIHKn+hcC5qzaqzx 9t8A== 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=FypUi30sTzs3YMKs24zAEFibkyYGgvxKsYg9V1SsIag=; b=LWn0vjBtjZTztc7zAkZesw3u2QXORUFTP8JXIYmeCbpu+FOZKuHzRjXDyArdQxfO6m hWALUN94b0liL+rc39M7Z3mojAvZ40nydmGG29PWzRI7B3wr3tOKSYgO234GIN2D+hcG bSS7gthj7B49SmFTl4TAiG0mixFMwAn6VipXkUW8q6WMaAFWxMxYQuuXO8T+HxoECEEZ tOET2ou7Vj/+K+hd+7gKiXLKWXnirOUE1VY53Nj80FT2615qdEgJwrJfab5SXKn1HZKm 3Mz9GQw2aXceHeOsh8e5YnuEUgFckuVs2U2yU5kLDIYLOQ2Z8gObWda+4Xrp66i1EVjc pbiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O+uWRmfV; 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 t11si3799684pgf.93.2018.03.29.02.22.19; Thu, 29 Mar 2018 02:22:34 -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=O+uWRmfV; 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 S1752077AbeC2JV0 (ORCPT + 99 others); Thu, 29 Mar 2018 05:21:26 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35120 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750735AbeC2JVY (ORCPT ); Thu, 29 Mar 2018 05:21:24 -0400 Received: by mail-pg0-f65.google.com with SMTP id j3so2683068pgf.2; Thu, 29 Mar 2018 02:21:24 -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=FypUi30sTzs3YMKs24zAEFibkyYGgvxKsYg9V1SsIag=; b=O+uWRmfVVXRfl0VFMrmiOGXmAMwHfyWpBss4m9yA17ZD0YKZyIP/11SrxBFTjW54M8 ymCGnFOt+T4zTEWjGIy0oE4TurkP8zw8BRSIGyhIx+6O0SIKkfCeX2HbTDPla8VSgHd7 DGZ3y/aiJLkjM9Dt0Kk/z73JuQEjFQyvHVU/DHcVz8X9YU6RPmFDMuenAwtzYxZ3hXVu j3W581Se0IBtYZAT+LO608pA+hKTwY8WT8ibwxHmjeAvnq3iRDPzzFWzTl24brwi/70j NvGqWT87FrMDL7lQa26EOhe0zLxXN34xKQpg++My4Od8SDQ+M41yRbvt3ROdGr571k25 6wGQ== 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=FypUi30sTzs3YMKs24zAEFibkyYGgvxKsYg9V1SsIag=; b=o9CADKnwuHq34Ju/yZk2OcrQEObrQLYxxKvhovvxKbkFou6jT2RKJJuXDounIbAuB7 Y7Kh63O+ogmj6jHW7cWJB/RyusDRaDKM5lYvPWT1DjqPdNugF+Ga6rX9uCKcTzuKCw53 X2YC+cAoeycRa87CLaJuSE+wGTMHaadmIVcEOql3QxbD8o3wAX5wLLrmy9H5XiFe8bgo JfntaMZAaO/az4Bpj0qDSs0/QlWrGL5UpZbK8RrcjUyKQZkXFVgDJdXuyXm0LvOhKYED 36WtUoOpYipfJisTdTwFf/+Cnq1M6mhGUGUlg6OsO8W2kT5vfCUKabAB4/TfkAkD9kEJ 2zVQ== X-Gm-Message-State: AElRT7Fm2O32+asZ+jkW0x/dq3gQhLSYtBz3wliveMI2ny4DpjQe4A4j mU9W0jSnqHn9Uj2tOHuephPNVQ== X-Received: by 2002:a17:902:b60c:: with SMTP id b12-v6mr1391788pls.203.1522315284068; Thu, 29 Mar 2018 02:21:24 -0700 (PDT) Received: from shreeya-VirtualBox ([103.212.140.137]) by smtp.gmail.com with ESMTPSA id h15sm11238393pfi.56.2018.03.29.02.21.22 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Mar 2018 02:21:23 -0700 (PDT) From: Shreeya Patel To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, Michael.Hennerich@analog.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, daniel.baluta@gmail.com Cc: Shreeya Patel Subject: [PATCH v6 5/6] Staging: iio: adis16209: Use GENMASK Date: Thu, 29 Mar 2018 14:51:19 +0530 Message-Id: <5d43c34c95f3b58f5b79254ae67bf7a080f39a92.1522306893.git.shreeya.patel23498@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: 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: Shreeya Patel --- Changes in v6 -Introduce this new patch in the series. drivers/staging/iio/accel/adis16209.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209.c b/drivers/staging/iio/accel/adis16209.c index ed6d7c7..cc50667 100644 --- a/drivers/staging/iio/accel/adis16209.c +++ b/drivers/staging/iio/accel/adis16209.c @@ -112,25 +112,22 @@ static int adis16209_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *st = iio_priv(indio_dev); - int bits; - s16 val16; - u8 addr; + int m; + + if (mask != IIO_CHAN_INFO_CALIBBIAS) + return -EINVAL; - switch (mask) { - case IIO_CHAN_INFO_CALIBBIAS: switch (chan->type) { case IIO_ACCEL: case IIO_INCLI: - bits = 14; + m = GENMASK(13, 0); break; default: return -EINVAL; } - val16 = val & ((1 << bits) - 1); - addr = adis16209_addresses[chan->scan_index][0]; - return adis_write_reg_16(st, addr, val16); - } - return -EINVAL; + + return adis_write_reg_16(st, adis16209_addresses[chan->scan_index][0], + val & m); } static int adis16209_read_raw(struct iio_dev *indio_dev, -- 2.7.4