public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: David Frey <dpfrey@gmail.com>
To: linux-iio@vger.kernel.org
Cc: jic23@vger.kernel.org, himanshujha199640@gmail.com,
	David Frey <dpfrey@gmail.com>
Subject: [PATCH v2 6/7] iio: chemical: bme680: use FIELD_GET macro
Date: Wed, 15 Aug 2018 13:38:34 -0700	[thread overview]
Message-ID: <20180815203835.21079-7-dpfrey@gmail.com> (raw)
In-Reply-To: <20180815203835.21079-1-dpfrey@gmail.com>

Use the FIELD_GET macro instead of explicit mask and shift.

Signed-off-by: David Frey <dpfrey@gmail.com>
---
 drivers/iio/chemical/bme680_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
index d62cb88af481..c96e4a991a61 100644
--- a/drivers/iio/chemical/bme680_core.c
+++ b/drivers/iio/chemical/bme680_core.c
@@ -285,7 +285,7 @@ static int bme680_read_calib(struct bme680_data *data,
 		dev_err(dev, "failed to read resistance heat range\n");
 		return ret;
 	}
-	calib->res_heat_range = (tmp & BME680_RHRANGE_MASK) / 16;
+	calib->res_heat_range = FIELD_GET(BME680_RHRANGE_MASK, tmp);
 
 	ret = regmap_read(data->regmap, BME680_REG_RES_HEAT_VAL, &tmp);
 	if (ret < 0) {
@@ -299,7 +299,7 @@ static int bme680_read_calib(struct bme680_data *data,
 		dev_err(dev, "failed to read range software error\n");
 		return ret;
 	}
-	calib->range_sw_err = (tmp & BME680_RSERROR_MASK) / 16;
+	calib->range_sw_err = FIELD_GET(BME680_RSERROR_MASK, tmp);
 
 	return 0;
 }
-- 
2.11.0

  parent reply	other threads:[~2018-08-15 23:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15 20:38 [PATCH v2 0/7] bme680 cleanup David Frey
2018-08-15 20:38 ` [PATCH v2 1/7] iio: chemical: bme680: use clamp macro David Frey
2018-08-15 20:38 ` [PATCH v2 2/7] iio: chemical: bme680: cleanup bme680_read_calib formatting David Frey
2018-08-15 20:38 ` [PATCH v2 3/7] iio: chemical: bme680: indent #defines consistently David Frey
2018-08-15 20:38 ` [PATCH v2 4/7] iio: chemical: bme680: change MSK->MASK in #defines David Frey
2018-08-15 21:03   ` David Frey
2018-08-16  6:17     ` Himanshu Jha
2018-08-15 20:38 ` [PATCH v2 5/7] iio: chemical: bme680: use GENMASK macro David Frey
2018-08-15 20:38 ` David Frey [this message]
2018-08-15 20:38 ` [PATCH v2 7/7] iio: chemical: bme680: simplify oversampling handling David Frey
2018-08-16  6:24 ` [PATCH v2 0/7] bme680 cleanup Himanshu Jha
2018-08-16 12:55   ` David Frey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180815203835.21079-7-dpfrey@gmail.com \
    --to=dpfrey@gmail.com \
    --cc=himanshujha199640@gmail.com \
    --cc=jic23@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox