* [PATCH 4/6] staging:iio:ad7291 fix defines
@ 2014-07-08 11:06 Hartmut Knaack
2014-07-08 20:13 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Hartmut Knaack @ 2014-07-08 11:06 UTC (permalink / raw)
To: linux-iio; +Cc: Jonathan Cameron, Lars-Peter Clausen
Use BIT and GENMASK, remove unused defines, use AD7291_VOLTAGE_OFFSET
definition and move AD7291_BITS.
Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
---
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index b868c64..8ff3536 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -46,31 +46,27 @@
#define AD7291_VOLTAGE_ALERT_STATUS 0x1F
#define AD7291_T_ALERT_STATUS 0x20
+#define AD7291_BITS 12
#define AD7291_VOLTAGE_LIMIT_COUNT 8
/*
* AD7291 command
*/
-#define AD7291_AUTOCYCLE (1 << 0)
-#define AD7291_RESET (1 << 1)
-#define AD7291_ALERT_CLEAR (1 << 2)
-#define AD7291_ALERT_POLARITY (1 << 3)
-#define AD7291_EXT_REF (1 << 4)
-#define AD7291_NOISE_DELAY (1 << 5)
-#define AD7291_T_SENSE_MASK (1 << 7)
-#define AD7291_VOLTAGE_MASK 0xFF00
-#define AD7291_VOLTAGE_OFFSET 0x8
+#define AD7291_AUTOCYCLE BIT(0)
+#define AD7291_RESET BIT(1)
+#define AD7291_ALERT_CLEAR BIT(2)
+#define AD7291_ALERT_POLARITY BIT(3)
+#define AD7291_EXT_REF BIT(4)
+#define AD7291_NOISE_DELAY BIT(5)
+#define AD7291_T_SENSE_MASK BIT(7)
+#define AD7291_VOLTAGE_MASK GENMASK(15, 8)
+#define AD7291_VOLTAGE_OFFSET 8
/*
* AD7291 value masks
*/
-#define AD7291_CHANNEL_MASK 0xF000
-#define AD7291_BITS 12
-#define AD7291_VALUE_MASK 0xFFF
-#define AD7291_T_VALUE_SIGN 0x400
-#define AD7291_T_VALUE_FLOAT_OFFSET 2
-#define AD7291_T_VALUE_FLOAT_MASK 0x2
+#define AD7291_VALUE_MASK GENMASK(11, 0)
struct ad7291_chip_info {
struct i2c_client *client;
@@ -172,7 +168,7 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
offset = chan->channel;
break;
case IIO_TEMP:
- offset = 8;
+ offset = AD7291_VOLTAGE_OFFSET;
break;
}
@@ -246,7 +242,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev,
switch (chan->type) {
case IIO_VOLTAGE:
- if (chip->c_mask & (1 << (15 - chan->channel)))
+ if (chip->c_mask & BIT(15 - chan->channel))
return 1;
else
return 0;
@@ -331,7 +327,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
}
/* Enable this channel alone */
regval = chip->command & (~AD7291_VOLTAGE_MASK);
- regval |= 1 << (15 - chan->channel);
+ regval |= BIT(15 - chan->channel);
ret = ad7291_i2c_write(chip, AD7291_COMMAND, regval);
if (ret < 0) {
mutex_unlock(&chip->state_lock);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4/6] staging:iio:ad7291 fix defines
2014-07-08 11:06 [PATCH 4/6] staging:iio:ad7291 fix defines Hartmut Knaack
@ 2014-07-08 20:13 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-07-08 20:13 UTC (permalink / raw)
To: Hartmut Knaack, linux-iio; +Cc: Lars-Peter Clausen
On 08/07/14 12:06, Hartmut Knaack wrote:
> Use BIT and GENMASK, remove unused defines, use AD7291_VOLTAGE_OFFSET
> definition and move AD7291_BITS.
>
> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Applied with some fuzz due to dropped patch 3 and changing fix -> cleanup
in the patch title for the reasons I put in the previous email.
> ---
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index b868c64..8ff3536 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -46,31 +46,27 @@
> #define AD7291_VOLTAGE_ALERT_STATUS 0x1F
> #define AD7291_T_ALERT_STATUS 0x20
>
> +#define AD7291_BITS 12
> #define AD7291_VOLTAGE_LIMIT_COUNT 8
>
>
> /*
> * AD7291 command
> */
> -#define AD7291_AUTOCYCLE (1 << 0)
> -#define AD7291_RESET (1 << 1)
> -#define AD7291_ALERT_CLEAR (1 << 2)
> -#define AD7291_ALERT_POLARITY (1 << 3)
> -#define AD7291_EXT_REF (1 << 4)
> -#define AD7291_NOISE_DELAY (1 << 5)
> -#define AD7291_T_SENSE_MASK (1 << 7)
> -#define AD7291_VOLTAGE_MASK 0xFF00
> -#define AD7291_VOLTAGE_OFFSET 0x8
> +#define AD7291_AUTOCYCLE BIT(0)
> +#define AD7291_RESET BIT(1)
> +#define AD7291_ALERT_CLEAR BIT(2)
> +#define AD7291_ALERT_POLARITY BIT(3)
> +#define AD7291_EXT_REF BIT(4)
> +#define AD7291_NOISE_DELAY BIT(5)
> +#define AD7291_T_SENSE_MASK BIT(7)
> +#define AD7291_VOLTAGE_MASK GENMASK(15, 8)
> +#define AD7291_VOLTAGE_OFFSET 8
>
> /*
> * AD7291 value masks
> */
> -#define AD7291_CHANNEL_MASK 0xF000
> -#define AD7291_BITS 12
> -#define AD7291_VALUE_MASK 0xFFF
> -#define AD7291_T_VALUE_SIGN 0x400
> -#define AD7291_T_VALUE_FLOAT_OFFSET 2
> -#define AD7291_T_VALUE_FLOAT_MASK 0x2
> +#define AD7291_VALUE_MASK GENMASK(11, 0)
>
> struct ad7291_chip_info {
> struct i2c_client *client;
> @@ -172,7 +168,7 @@ static unsigned int ad7291_threshold_reg(const struct iio_chan_spec *chan,
> offset = chan->channel;
> break;
> case IIO_TEMP:
> - offset = 8;
> + offset = AD7291_VOLTAGE_OFFSET;
> break;
> }
>
> @@ -246,7 +242,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev,
>
> switch (chan->type) {
> case IIO_VOLTAGE:
> - if (chip->c_mask & (1 << (15 - chan->channel)))
> + if (chip->c_mask & BIT(15 - chan->channel))
> return 1;
> else
> return 0;
> @@ -331,7 +327,7 @@ static int ad7291_read_raw(struct iio_dev *indio_dev,
> }
> /* Enable this channel alone */
> regval = chip->command & (~AD7291_VOLTAGE_MASK);
> - regval |= 1 << (15 - chan->channel);
> + regval |= BIT(15 - chan->channel);
> ret = ad7291_i2c_write(chip, AD7291_COMMAND, regval);
> if (ret < 0) {
> mutex_unlock(&chip->state_lock);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-08 20:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-08 11:06 [PATCH 4/6] staging:iio:ad7291 fix defines Hartmut Knaack
2014-07-08 20:13 ` Jonathan Cameron
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).