From patchwork Thu Mar 29 09:21:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreeya Patel X-Patchwork-Id: 10314793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A10A96055B for ; Thu, 29 Mar 2018 09:21:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9960E2A0E9 for ; Thu, 29 Mar 2018 09:21:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DE172A2D5; Thu, 29 Mar 2018 09:21:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32A912A0E9 for ; Thu, 29 Mar 2018 09:21:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750795AbeC2JVZ (ORCPT ); Thu, 29 Mar 2018 05:21:25 -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-Google-Smtp-Source: AIpwx49JQCZQklGAjHGCkZk0s0k8KxMK7uMV2iteWQ2lkmlkOaT3Uhl2k8ejsc7MGG3olbx7JB2eEg== 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-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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,