linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Meerwald <pmeerw@pmeerw.net>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org, Peter Meerwald <pmeerw@pmeerw.net>
Subject: [PATCH 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros
Date: Sat,  7 Jun 2014 17:42:45 +0200	[thread overview]
Message-ID: <1402155772-1373-6-git-send-email-pmeerw@pmeerw.net> (raw)
In-Reply-To: <1402155772-1373-1-git-send-email-pmeerw@pmeerw.net>

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/adc/ad7298.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c
index 2a3b65c..4a8c0a2 100644
--- a/drivers/iio/adc/ad7298.c
+++ b/drivers/iio/adc/ad7298.c
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -25,23 +26,19 @@
 
 #include <linux/platform_data/ad7298.h>
 
-#define AD7298_WRITE	(1 << 15) /* write to the control register */
-#define AD7298_REPEAT	(1 << 14) /* repeated conversion enable */
-#define AD7298_CH(x)	(1 << (13 - (x))) /* channel select */
-#define AD7298_TSENSE	(1 << 5) /* temperature conversion enable */
-#define AD7298_EXTREF	(1 << 2) /* external reference enable */
-#define AD7298_TAVG	(1 << 1) /* temperature sensor averaging enable */
-#define AD7298_PDD	(1 << 0) /* partial power down enable */
+#define AD7298_WRITE	BIT(15) /* write to the control register */
+#define AD7298_REPEAT	BIT(14) /* repeated conversion enable */
+#define AD7298_CH(x)	BIT(13 - (x)) /* channel select */
+#define AD7298_TSENSE	BIT(5) /* temperature conversion enable */
+#define AD7298_EXTREF	BIT(2) /* external reference enable */
+#define AD7298_TAVG	BIT(1) /* temperature sensor averaging enable */
+#define AD7298_PDD	BIT(0) /* partial power down enable */
 
 #define AD7298_MAX_CHAN		8
-#define AD7298_BITS		12
-#define AD7298_STORAGE_BITS	16
 #define AD7298_INTREF_mV	2500
 
 #define AD7298_CH_TEMP		9
 
-#define RES_MASK(bits)	((1 << (bits)) - 1)
-
 struct ad7298_state {
 	struct spi_device		*spi;
 	struct regulator		*reg;
@@ -257,7 +254,7 @@ static int ad7298_read_raw(struct iio_dev *indio_dev,
 			return ret;
 
 		if (chan->address != AD7298_CH_TEMP)
-			*val = ret & RES_MASK(AD7298_BITS);
+			*val = ret & GENMASK(chan->scan_type.realbits - 1, 0);
 
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-- 
1.9.1


  parent reply	other threads:[~2014-06-07 15:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-07 15:42 [PATCH 00/12] misc IIO cleanup Peter Meerwald
2014-06-07 15:42 ` [PATCH 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros Peter Meerwald
2014-06-09 11:58   ` Lars-Peter Clausen
2014-06-07 15:42 ` [PATCH 02/12] iio:adc:ad5504: " Peter Meerwald
2014-06-07 15:42 ` [PATCH 03/12] iio:adc:ad7887: " Peter Meerwald
2014-06-09 11:59   ` Lars-Peter Clausen
2014-06-07 15:42 ` [PATCH 04/12] iio:adc:ad7476: Use GENMASK() macro Peter Meerwald
2014-06-09 12:00   ` Lars-Peter Clausen
2014-06-07 15:42 ` Peter Meerwald [this message]
2014-06-09 12:00   ` [PATCH 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros Lars-Peter Clausen
2014-06-07 15:42 ` [PATCH 06/12] iio: Move documentation of iio-trig-sysfs to ABI Peter Meerwald
2014-06-09 19:58   ` Jonathan Cameron
2014-06-07 15:42 ` [PATCH 07/12] staging:iio: Update iio_event_monitor program Peter Meerwald
2014-06-07 15:42 ` [PATCH 08/12] staging:iio: Fix iio_utils.h function prototypes Peter Meerwald
2014-06-07 15:42 ` [PATCH 09/12] staging:iio: Fix mention of INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED Peter Meerwald
2014-06-07 15:42 ` [PATCH 10/12] staging:iio: Fix error handling in generic_buffer example Peter Meerwald
2014-06-07 15:42 ` [PATCH 11/12] staging:iio-trig-periodic-rtc: Cleanup Peter Meerwald
2014-06-09 20:02   ` Jonathan Cameron
2014-06-09 20:04     ` Peter Meerwald
2014-06-09 20:14       ` Jonathan Cameron
2014-06-07 15:42 ` [PATCH 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0 Peter Meerwald
2014-06-09 20:05 ` [PATCH 00/12] misc IIO cleanup Jonathan Cameron

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=1402155772-1373-6-git-send-email-pmeerw@pmeerw.net \
    --to=pmeerw@pmeerw.net \
    --cc=jic23@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;
as well as URLs for NNTP newsgroup(s).