From ff96bf519acdb3b99f9bfe07667a9020d5015395 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 6 Dec 2014 06:00:00 +0000 Subject: [PATCH] iio:adc:ad5791: Use BIT() and GENMASK() macros Signed-off-by: Peter Meerwald Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- 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 ae49afe2b380..5ba785f18589 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -16,17 +16,16 @@ #include #include #include +#include #include #include #include -#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); -- 2.39.5