linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald <pmeerw@pmeerw.net>, linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros
Date: Sat, 14 Jun 2014 15:46:33 +0100	[thread overview]
Message-ID: <539C6049.4000908@kernel.org> (raw)
In-Reply-To: <1402549229-4449-2-git-send-email-pmeerw@pmeerw.net>

On 12/06/14 06:00, Peter Meerwald wrote:
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Applied to the togreg branch of iio.git.

As I stated deep in another thread, I'm not that fussed about the
BIT() stuff and am not going to push for this everywhere in IIO,
but getting rid of the GENMASK is well worth doing and I don't
'mind' people doing the BIT bits....

J
> ---
>   drivers/iio/dac/ad5791.c | 29 ++++++++++++++---------------
>   1 file changed, 14 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c
> index ae49afe..5ba785f 100644
> --- a/drivers/iio/dac/ad5791.c
> +++ b/drivers/iio/dac/ad5791.c
> @@ -16,17 +16,16 @@
>   #include <linux/sysfs.h>
>   #include <linux/regulator/consumer.h>
>   #include <linux/module.h>
> +#include <linux/bitops.h>
>
>   #include <linux/iio/iio.h>
>   #include <linux/iio/sysfs.h>
>   #include <linux/iio/dac/ad5791.h>
>
> -#define AD5791_RES_MASK(x)		((1 << (x)) - 1)
> -#define AD5791_DAC_MASK			AD5791_RES_MASK(20)
> -#define AD5791_DAC_MSB			(1 << 19)
> +#define AD5791_DAC_MASK			GENMASK(19, 0)
>
> -#define AD5791_CMD_READ			(1 << 23)
> -#define AD5791_CMD_WRITE		(0 << 23)
> +#define AD5791_CMD_READ			BIT(23)
> +#define AD5791_CMD_WRITE		0
>   #define AD5791_ADDR(addr)		((addr) << 20)
>
>   /* Registers */
> @@ -37,11 +36,11 @@
>   #define AD5791_ADDR_SW_CTRL		4
>
>   /* Control Register */
> -#define AD5791_CTRL_RBUF		(1 << 1)
> -#define AD5791_CTRL_OPGND		(1 << 2)
> -#define AD5791_CTRL_DACTRI		(1 << 3)
> -#define AD5791_CTRL_BIN2SC		(1 << 4)
> -#define AD5791_CTRL_SDODIS		(1 << 5)
> +#define AD5791_CTRL_RBUF		BIT(1)
> +#define AD5791_CTRL_OPGND		BIT(2)
> +#define AD5791_CTRL_DACTRI		BIT(3)
> +#define AD5791_CTRL_BIN2SC		BIT(4)
> +#define AD5791_CTRL_SDODIS		BIT(5)
>   #define AD5761_CTRL_LINCOMP(x)		((x) << 6)
>
>   #define AD5791_LINCOMP_0_10		0
> @@ -54,9 +53,9 @@
>   #define AD5780_LINCOMP_10_20		12
>
>   /* Software Control Register */
> -#define AD5791_SWCTRL_LDAC		(1 << 0)
> -#define AD5791_SWCTRL_CLR		(1 << 1)
> -#define AD5791_SWCTRL_RESET		(1 << 2)
> +#define AD5791_SWCTRL_LDAC		BIT(0)
> +#define AD5791_SWCTRL_CLR		BIT(1)
> +#define AD5791_SWCTRL_RESET		BIT(2)
>
>   #define AD5791_DAC_PWRDN_6K		0
>   #define AD5791_DAC_PWRDN_3STATE		1
> @@ -72,7 +71,7 @@ struct ad5791_chip_info {
>
>   /**
>    * struct ad5791_state - driver instance specific data
> - * @us:			spi_device
> + * @spi:			spi_device
>    * @reg_vdd:		positive supply regulator
>    * @reg_vss:		negative supply regulator
>    * @chip_info:		chip model specific constants
> @@ -328,7 +327,7 @@ static int ad5791_write_raw(struct iio_dev *indio_dev,
>
>   	switch (mask) {
>   	case IIO_CHAN_INFO_RAW:
> -		val &= AD5791_RES_MASK(chan->scan_type.realbits);
> +		val &= GENMASK(chan->scan_type.realbits - 1, 0);
>   		val <<= chan->scan_type.shift;
>
>   		return ad5791_spi_write(st, chan->address, val);
>


  reply	other threads:[~2014-06-14 14:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
2014-06-12  5:00 ` [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros Peter Meerwald
2014-06-14 14:46   ` Jonathan Cameron [this message]
2014-06-12  5:00 ` [PATCH v2 02/12] iio:adc:ad5504: " Peter Meerwald
2014-06-14 14:49   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 03/12] iio:adc:ad7887: " Peter Meerwald
2014-06-14 15:03   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro Peter Meerwald
2014-06-14 15:04   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros Peter Meerwald
2014-06-14 15:04   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 06/12] iio: Move documentation of iio-trig-sysfs to ABI/testing Peter Meerwald
2014-06-14 15:05   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 07/12] staging:iio: Update iio_event_monitor program Peter Meerwald
2014-06-14 15:08   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 08/12] staging:iio: Fix iio_utils.h function prototypes Peter Meerwald
2014-06-14 15:08   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 09/12] staging:iio: Fix mention of INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED Peter Meerwald
2014-06-14 15:08   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 10/12] staging:iio: Fix error handling in generic_buffer example Peter Meerwald
2014-06-14 15:09   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup Peter Meerwald
2014-06-14 15:11   ` Jonathan Cameron
2014-06-12  5:00 ` [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0 Peter Meerwald
2014-06-14 15:12   ` 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=539C6049.4000908@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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).