All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/6] staging:iio:ad7291 define alert register bits
@ 2014-07-08 11:06 Hartmut Knaack
  2014-07-08 20:16 ` 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

Define some names for alert register bits and apply them to
ad7291_event_handler().

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 06eb0c0..a257f78 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -68,6 +68,17 @@
  */
 #define AD7291_VALUE_MASK		GENMASK(11, 0)
 
+/*
+ * AD7291 alert register bits
+ */
+#define AD7291_T_LOW			BIT(0)
+#define AD7291_T_HIGH			BIT(1)
+#define AD7291_T_AVG_LOW		BIT(2)
+#define AD7291_T_AVG_HIGH		BIT(3)
+#define AD7291_V_LOW(x)			BIT((x) * 2)
+#define AD7291_V_HIGH(x)		BIT((x) * 2 + 1)
+
+
 struct ad7291_chip_info {
 	struct i2c_client	*client;
 	struct regulator	*reg;
@@ -122,14 +133,14 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
 	ad7291_i2c_write(chip, AD7291_COMMAND, command);
 
 	/* For now treat t_sense and t_sense_average the same */
-	if ((t_status & (1 << 0)) || (t_status & (1 << 2)))
+	if ((t_status & AD7291_T_LOW) || (t_status & AD7291_T_AVG_LOW))
 		iio_push_event(indio_dev,
 			       IIO_UNMOD_EVENT_CODE(IIO_TEMP,
 						    0,
 						    IIO_EV_TYPE_THRESH,
 						    IIO_EV_DIR_FALLING),
 			       timestamp);
-	if ((t_status & (1 << 1)) || (t_status & (1 << 3)))
+	if ((t_status & AD7291_T_HIGH) || (t_status & AD7291_T_AVG_HIGH))
 		iio_push_event(indio_dev,
 			       IIO_UNMOD_EVENT_CODE(IIO_TEMP,
 						    0,
@@ -137,18 +148,18 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
 						    IIO_EV_DIR_RISING),
 			       timestamp);
 
-	for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) {
-		if (v_status & (1 << i))
+	for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) {
+		if (v_status & AD7291_V_LOW(i))
 			iio_push_event(indio_dev,
 				       IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
-							    i/2,
+							    i,
 							    IIO_EV_TYPE_THRESH,
 							    IIO_EV_DIR_FALLING),
 				       timestamp);
-		if (v_status & (1 << (i + 1)))
+		if (v_status & AD7291_V_HIGH(i))
 			iio_push_event(indio_dev,
 				       IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
-							    i/2,
+							    i,
 							    IIO_EV_TYPE_THRESH,
 							    IIO_EV_DIR_RISING),
 				       timestamp);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 6/6] staging:iio:ad7291 define alert register bits
  2014-07-08 11:06 [PATCH 6/6] staging:iio:ad7291 define alert register bits Hartmut Knaack
@ 2014-07-08 20:16 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2014-07-08 20:16 UTC (permalink / raw)
  To: Hartmut Knaack, linux-iio; +Cc: Lars-Peter Clausen

On 08/07/14 12:06, Hartmut Knaack wrote:
> Define some names for alert register bits and apply them to
> ad7291_event_handler().
>
> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Applied to the togreg branch of iio.git

Thanks for looking at this driver in such detail!

I'll apply the move patch shortly so that's another one out of staging
:)

> ---
> diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
> index 06eb0c0..a257f78 100644
> --- a/drivers/staging/iio/adc/ad7291.c
> +++ b/drivers/staging/iio/adc/ad7291.c
> @@ -68,6 +68,17 @@
>    */
>   #define AD7291_VALUE_MASK		GENMASK(11, 0)
>
> +/*
> + * AD7291 alert register bits
> + */
> +#define AD7291_T_LOW			BIT(0)
> +#define AD7291_T_HIGH			BIT(1)
> +#define AD7291_T_AVG_LOW		BIT(2)
> +#define AD7291_T_AVG_HIGH		BIT(3)
> +#define AD7291_V_LOW(x)			BIT((x) * 2)
> +#define AD7291_V_HIGH(x)		BIT((x) * 2 + 1)
> +
> +
>   struct ad7291_chip_info {
>   	struct i2c_client	*client;
>   	struct regulator	*reg;
> @@ -122,14 +133,14 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
>   	ad7291_i2c_write(chip, AD7291_COMMAND, command);
>
>   	/* For now treat t_sense and t_sense_average the same */
> -	if ((t_status & (1 << 0)) || (t_status & (1 << 2)))
> +	if ((t_status & AD7291_T_LOW) || (t_status & AD7291_T_AVG_LOW))
>   		iio_push_event(indio_dev,
>   			       IIO_UNMOD_EVENT_CODE(IIO_TEMP,
>   						    0,
>   						    IIO_EV_TYPE_THRESH,
>   						    IIO_EV_DIR_FALLING),
>   			       timestamp);
> -	if ((t_status & (1 << 1)) || (t_status & (1 << 3)))
> +	if ((t_status & AD7291_T_HIGH) || (t_status & AD7291_T_AVG_HIGH))
>   		iio_push_event(indio_dev,
>   			       IIO_UNMOD_EVENT_CODE(IIO_TEMP,
>   						    0,
> @@ -137,18 +148,18 @@ static irqreturn_t ad7291_event_handler(int irq, void *private)
>   						    IIO_EV_DIR_RISING),
>   			       timestamp);
>
> -	for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT*2; i += 2) {
> -		if (v_status & (1 << i))
> +	for (i = 0; i < AD7291_VOLTAGE_LIMIT_COUNT; i++) {
> +		if (v_status & AD7291_V_LOW(i))
>   			iio_push_event(indio_dev,
>   				       IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
> -							    i/2,
> +							    i,
>   							    IIO_EV_TYPE_THRESH,
>   							    IIO_EV_DIR_FALLING),
>   				       timestamp);
> -		if (v_status & (1 << (i + 1)))
> +		if (v_status & AD7291_V_HIGH(i))
>   			iio_push_event(indio_dev,
>   				       IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE,
> -							    i/2,
> +							    i,
>   							    IIO_EV_TYPE_THRESH,
>   							    IIO_EV_DIR_RISING),
>   				       timestamp);
> --
> 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:14 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 6/6] staging:iio:ad7291 define alert register bits Hartmut Knaack
2014-07-08 20:16 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.