All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/12] misc IIO cleanup
@ 2014-06-12  5:00 Peter Meerwald
  2014-06-12  5:00 ` [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros Peter Meerwald
                   ` (11 more replies)
  0 siblings, 12 replies; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23

v2 doesn't change the periodic rtc trigger name and just moves iio-trig-sysfs
documentation to ABI/testing (instead of merging with sysfs-bus-iio)

Peter Meerwald (12):
  iio:adc:ad5791: Use BIT() and GENMASK() macros
  iio:adc:ad5504: Use BIT() and GENMASK() macros
  iio:adc:ad7887: Use BIT() and GENMASK() macros
  iio:adc:ad7476: Use GENMASK() macro
  iio:adc:ad7298: Use BIT() and GENMASK() macros
  iio: Move documentation of iio-trig-sysfs to ABI/testing
  staging:iio: Update iio_event_monitor program
  staging:iio: Fix iio_utils.h function prototypes
  staging:iio: Fix mention of INDIO_RING_TRIGGERED to
    INDIO_BUFFER_TRIGGERED
  staging:iio: Fix error handling in generic_buffer example
  staging:iio-trig-periodic-rtc: Cleanup
  staging:iio-trig-periodic-rtc: Allow to reset frequency to 0

 .../ABI/testing/sysfs-bus-iio-trigger-sysfs        | 11 ++++++++
 drivers/iio/adc/ad7298.c                           | 21 +++++++---------
 drivers/iio/adc/ad7476.c                           |  5 ++--
 drivers/iio/adc/ad7887.c                           | 21 ++++++++--------
 drivers/iio/dac/ad5504.c                           | 11 ++++----
 drivers/iio/dac/ad5791.c                           | 29 +++++++++++-----------
 drivers/staging/iio/Documentation/generic_buffer.c |  9 ++++---
 .../staging/iio/Documentation/iio_event_monitor.c  | 10 ++++++++
 drivers/staging/iio/Documentation/iio_utils.h      |  6 ++---
 .../iio/Documentation/sysfs-bus-iio-trigger-sysfs  | 11 --------
 drivers/staging/iio/Documentation/trigger.txt      |  2 +-
 .../staging/iio/trigger/iio-trig-periodic-rtc.c    | 26 +++++++++++++------
 12 files changed, 90 insertions(+), 72 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
 delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs

-- 
1.9.1

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

* [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
@ 2014-06-12  5:00 ` Peter Meerwald
  2014-06-14 14:46   ` Jonathan Cameron
  2014-06-12  5:00 ` [PATCH v2 02/12] iio:adc:ad5504: " Peter Meerwald
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
 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);
-- 
1.9.1


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

* [PATCH v2 02/12] iio:adc:ad5504: Use BIT() and GENMASK() macros
  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-12  5:00 ` Peter Meerwald
  2014-06-14 14:49   ` Jonathan Cameron
  2014-06-12  5:00 ` [PATCH v2 03/12] iio:adc:ad7887: " Peter Meerwald
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5504.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 1e64493..c917dd2 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -15,17 +15,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/events.h>
 #include <linux/iio/dac/ad5504.h>
 
-#define AD5505_BITS			12
-#define AD5504_RES_MASK			((1 << (AD5505_BITS)) - 1)
-
-#define AD5504_CMD_READ			(1 << 15)
-#define AD5504_CMD_WRITE		(0 << 15)
+#define AD5504_RES_MASK			GENMASK(11, 0)
+#define AD5504_CMD_READ			BIT(15)
+#define AD5504_CMD_WRITE		0
 #define AD5504_ADDR(addr)		((addr) << 12)
 
 /* Registers */
@@ -42,7 +41,7 @@
 
 /**
  * struct ad5446_state - driver instance specific data
- * @us:			spi_device
+ * @spi:			spi_device
  * @reg:		supply regulator
  * @vref_mv:		actual reference voltage used
  * @pwr_down_mask	power down mask
-- 
1.9.1


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

* [PATCH v2 03/12] iio:adc:ad7887: Use BIT() and GENMASK() macros
  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-12  5:00 ` [PATCH v2 02/12] iio:adc:ad5504: " Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7887.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
index 749a6ca..2fd012e 100644
--- a/drivers/iio/adc/ad7887.c
+++ b/drivers/iio/adc/ad7887.c
@@ -15,6 +15,7 @@
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -25,14 +26,14 @@
 
 #include <linux/platform_data/ad7887.h>
 
-#define AD7887_REF_DIS		(1 << 5) /* on-chip reference disable */
-#define AD7887_DUAL		(1 << 4) /* dual-channel mode */
-#define AD7887_CH_AIN1		(1 << 3) /* convert on channel 1, DUAL=1 */
-#define AD7887_CH_AIN0		(0 << 3) /* convert on channel 0, DUAL=0,1 */
-#define AD7887_PM_MODE1		(0)	 /* CS based shutdown */
-#define AD7887_PM_MODE2		(1)	 /* full on */
-#define AD7887_PM_MODE3		(2)	 /* auto shutdown after conversion */
-#define AD7887_PM_MODE4		(3)	 /* standby mode */
+#define AD7887_REF_DIS		BIT(5)	/* on-chip reference disable */
+#define AD7887_DUAL		BIT(4)	/* dual-channel mode */
+#define AD7887_CH_AIN1		BIT(3)	/* convert on channel 1, DUAL=1 */
+#define AD7887_CH_AIN0		0	/* convert on channel 0, DUAL=0,1 */
+#define AD7887_PM_MODE1		0	/* CS based shutdown */
+#define AD7887_PM_MODE2		1	/* full on */
+#define AD7887_PM_MODE3		2	/* auto shutdown after conversion */
+#define AD7887_PM_MODE4		3	/* standby mode */
 
 enum ad7887_channels {
 	AD7887_CH0,
@@ -40,8 +41,6 @@ enum ad7887_channels {
 	AD7887_CH1,
 };
 
-#define RES_MASK(bits)	((1 << (bits)) - 1)
-
 /**
  * struct ad7887_chip_info - chip specifc information
  * @int_vref_mv:	the internal reference voltage
@@ -167,7 +166,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
 		if (ret < 0)
 			return ret;
 		*val = ret >> chan->scan_type.shift;
-		*val &= RES_MASK(chan->scan_type.realbits);
+		*val &= GENMASK(chan->scan_type.realbits - 1, 0);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
 		if (st->reg) {
-- 
1.9.1


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

* [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (2 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 03/12] iio:adc:ad7887: " Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/adc/ad7476.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index d141d45..ce400ec 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -14,6 +14,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/bitops.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -21,8 +22,6 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#define RES_MASK(bits)	((1 << (bits)) - 1)
-
 struct ad7476_state;
 
 struct ad7476_chip_info {
@@ -117,7 +116,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
 		if (ret < 0)
 			return ret;
 		*val = (ret >> st->chip_info->channel[0].scan_type.shift) &
-			RES_MASK(st->chip_info->channel[0].scan_type.realbits);
+			GENMASK(st->chip_info->channel[0].scan_type.realbits - 1, 0);
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
 		if (!st->chip_info->int_vref_uv) {
-- 
1.9.1


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

* [PATCH v2 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (3 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
 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


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

* [PATCH v2 06/12] iio: Move documentation of iio-trig-sysfs to ABI/testing
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (4 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

iio-trig-sysfs has left staging with commit e64e7d5c

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs         | 11 +++++++++++
 drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
 delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs

diff --git a/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs b/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
new file mode 100644
index 0000000..5235e6c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
@@ -0,0 +1,11 @@
+What:		/sys/bus/iio/devices/triggerX/trigger_now
+KernelVersion:	2.6.38
+Contact:	linux-iio@vger.kernel.org
+Description:
+		This file is provided by the iio-trig-sysfs stand-alone trigger
+		driver. Writing this file with any value triggers an event
+		driven driver, associated with this trigger, to capture data
+		into an in kernel buffer. This approach can be valuable during
+		automated testing or in situations, where other trigger methods
+		are not applicable. For example no RTC or spare GPIOs.
+		X is the IIO index of the trigger.
diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs b/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
deleted file mode 100644
index 5235e6c..0000000
--- a/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
+++ /dev/null
@@ -1,11 +0,0 @@
-What:		/sys/bus/iio/devices/triggerX/trigger_now
-KernelVersion:	2.6.38
-Contact:	linux-iio@vger.kernel.org
-Description:
-		This file is provided by the iio-trig-sysfs stand-alone trigger
-		driver. Writing this file with any value triggers an event
-		driven driver, associated with this trigger, to capture data
-		into an in kernel buffer. This approach can be valuable during
-		automated testing or in situations, where other trigger methods
-		are not applicable. For example no RTC or spare GPIOs.
-		X is the IIO index of the trigger.
-- 
1.9.1


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

* [PATCH v2 07/12] staging:iio: Update iio_event_monitor program
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (5 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 06/12] iio: Move documentation of iio-trig-sysfs to ABI/testing Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

add types recently added

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/Documentation/iio_event_monitor.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
index 3a9b000..cb35a97 100644
--- a/drivers/staging/iio/Documentation/iio_event_monitor.c
+++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
@@ -46,6 +46,9 @@ static const char * const iio_chan_type_name_spec[] = {
 	[IIO_TIMESTAMP] = "timestamp",
 	[IIO_CAPACITANCE] = "capacitance",
 	[IIO_ALTVOLTAGE] = "altvoltage",
+	[IIO_CCT] = "cct",
+	[IIO_PRESSURE] = "pressure",
+	[IIO_HUMIDITYRELATIVE] = "humidityrelative",
 };
 
 static const char * const iio_ev_type_text[] = {
@@ -70,6 +73,8 @@ static const char * const iio_modifier_names[] = {
 	[IIO_MOD_LIGHT_IR] = "ir",
 	[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
 	[IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
+	[IIO_MOD_LIGHT_BOTH] = "both",
+	[IIO_MOD_LIGHT_IR] = "ir",
 	[IIO_MOD_LIGHT_CLEAR] = "clear",
 	[IIO_MOD_LIGHT_RED] = "red",
 	[IIO_MOD_LIGHT_GREEN] = "green",
@@ -100,6 +105,9 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_TIMESTAMP:
 	case IIO_CAPACITANCE:
 	case IIO_ALTVOLTAGE:
+	case IIO_CCT:
+	case IIO_PRESSURE:
+	case IIO_HUMIDITYRELATIVE:
 		break;
 	default:
 		return false;
@@ -114,6 +122,8 @@ static bool event_is_known(struct iio_event_data *event)
 	case IIO_MOD_LIGHT_IR:
 	case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
 	case IIO_MOD_SUM_SQUARED_X_Y_Z:
+	case IIO_MOD_LIGHT_BOTH:
+	case IIO_MOD_LIGHT_IR:
 	case IIO_MOD_LIGHT_CLEAR:
 	case IIO_MOD_LIGHT_RED:
 	case IIO_MOD_LIGHT_GREEN:
-- 
1.9.1


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

* [PATCH v2 08/12] staging:iio: Fix iio_utils.h function prototypes
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (6 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 07/12] staging:iio: Update iio_event_monitor program Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/Documentation/iio_utils.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
index a9cfc06..0973a09 100644
--- a/drivers/staging/iio/Documentation/iio_utils.h
+++ b/drivers/staging/iio/Documentation/iio_utils.h
@@ -633,7 +633,7 @@ error_free:
 
 int read_sysfs_float(char *filename, char *basedir, float *val)
 {
-	float ret = 0;
+	int ret = 0;
 	FILE  *sysfsfp;
 	char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
 	if (temp == NULL) {
@@ -653,9 +653,9 @@ error_free:
 	return ret;
 }
 
-read_sysfs_string(const char *filename, const char *basedir, char *str)
+int read_sysfs_string(const char *filename, const char *basedir, char *str)
 {
-	float ret = 0;
+	int ret = 0;
 	FILE  *sysfsfp;
 	char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
 	if (temp == NULL) {
-- 
1.9.1


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

* [PATCH v2 09/12] staging:iio: Fix mention of INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (7 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 08/12] staging:iio: Fix iio_utils.h function prototypes Peter Meerwald
@ 2014-06-12  5:00 ` 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
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/Documentation/trigger.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt
index 64e2e08..7c0e505 100644
--- a/drivers/staging/iio/Documentation/trigger.txt
+++ b/drivers/staging/iio/Documentation/trigger.txt
@@ -31,5 +31,5 @@ consumers.
 Trigger Consumers
 
 Currently triggers are only used for the filling of software
-buffers and as such any device supporting INDIO_RING_TRIGGERED has the
+buffers and as such any device supporting INDIO_BUFFER_TRIGGERED has the
 consumer interface automatically created.
-- 
1.9.1


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

* [PATCH v2 10/12] staging:iio: Fix error handling in generic_buffer example
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (8 preceding siblings ...)
  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-12  5:00 ` 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-12  5:00 ` [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0 Peter Meerwald
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

read() does not return -EAGAIN
read() returns -1 and the errno value needs to be checked for -EAGAIN

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/Documentation/generic_buffer.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
index 40d0eca..044ea19 100644
--- a/drivers/staging/iio/Documentation/generic_buffer.c
+++ b/drivers/staging/iio/Documentation/generic_buffer.c
@@ -305,9 +305,12 @@ int main(int argc, char **argv)
 		read_size = read(fp,
 				 data,
 				 toread*scan_size);
-		if (read_size == -EAGAIN) {
-			printf("nothing available\n");
-			continue;
+		if (read_size < 0) {
+			if (errno == -EAGAIN) {
+				printf("nothing available\n");
+				continue;
+			} else
+				break;
 		}
 		for (i = 0; i < read_size/scan_size; i++)
 			process_scan(data + scan_size*i,
-- 
1.9.1


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

* [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (9 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 10/12] staging:iio: Fix error handling in generic_buffer example Peter Meerwald
@ 2014-06-12  5:00 ` 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
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

Fix extra space in module description
Silence output about trigger frequency when trigger gets enabled/disabled
Add dash to make trigger name look nicer (periodicrtc0 -> periodic-rtc0)

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
index 38ecb4b..362a54a 100644
--- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
+++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
@@ -33,7 +33,7 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
 	struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
 	if (trig_info->frequency == 0)
 		return -EINVAL;
-	dev_info(&trig_info->rtc->dev, "trigger frequency is %d\n",
+	dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
 			trig_info->frequency);
 	return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
 }
@@ -128,8 +128,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
 		iio_trigger_set_drvdata(trig, trig_info);
 		trig->ops = &iio_prtc_trigger_ops;
 		/* RTC access */
-		trig_info->rtc
-			= rtc_class_open(pdata[i]);
+		trig_info->rtc = rtc_class_open(pdata[i]);
 		if (trig_info->rtc == NULL) {
 			ret = -EINVAL;
 			goto error_free_trig_info;
@@ -199,5 +198,5 @@ static struct platform_driver iio_trig_periodic_rtc_driver = {
 module_platform_driver(iio_trig_periodic_rtc_driver);
 
 MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
-MODULE_DESCRIPTION("Periodic realtime clock  trigger for the iio subsystem");
+MODULE_DESCRIPTION("Periodic realtime clock trigger for the iio subsystem");
 MODULE_LICENSE("GPL v2");
-- 
1.9.1


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

* [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0
  2014-06-12  5:00 [PATCH v2 00/12] misc IIO cleanup Peter Meerwald
                   ` (10 preceding siblings ...)
  2014-06-12  5:00 ` [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup Peter Meerwald
@ 2014-06-12  5:00 ` Peter Meerwald
  2014-06-14 15:12   ` Jonathan Cameron
  11 siblings, 1 reply; 25+ messages in thread
From: Peter Meerwald @ 2014-06-12  5:00 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, Peter Meerwald

periodic rtc trigger initially has frequency 0

it is possible to change trigger frequency on-the-fly, but it is not
possible to set frequency back to 0

this patch allows to set trigger frequency to 0, thereby disabling
the rtc interrupt

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
index 362a54a..b5108a1 100644
--- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
+++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
@@ -26,16 +26,22 @@ struct iio_prtc_trigger_info {
 	struct rtc_device *rtc;
 	int frequency;
 	struct rtc_task task;
+	bool state;
 };
 
 static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
 {
 	struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
-	if (trig_info->frequency == 0)
+	int ret;
+	if (trig_info->frequency == 0 && state)
 		return -EINVAL;
 	dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
 			trig_info->frequency);
-	return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
+	ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
+	if (ret == 0)
+		trig_info->state = state;
+
+	return ret;
 }
 
 static ssize_t iio_trig_periodic_read_freq(struct device *dev,
@@ -61,7 +67,14 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
 	if (ret)
 		goto error_ret;
 
-	ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
+	if (val > 0) {
+		ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
+		if (ret == 0 && trig_info->state && trig_info->frequency == 0)
+			ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 1);
+	} else if (val == 0) {
+		ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
+	} else
+		ret = -EINVAL;
 	if (ret)
 		goto error_ret;
 
-- 
1.9.1


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

* Re: [PATCH v2 01/12] iio:adc:ad5791: Use BIT() and GENMASK() macros
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 14:46 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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);
>


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

* Re: [PATCH v2 02/12] iio:adc:ad5504: Use BIT() and GENMASK() macros
  2014-06-12  5:00 ` [PATCH v2 02/12] iio:adc:ad5504: " Peter Meerwald
@ 2014-06-14 14:49   ` Jonathan Cameron
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 14:49 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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>
I would have ever so slightly preferred the kernel doc fix
to be in another patch, but ah well.

Applied to the togreg branch of iio.git

Thanks,
> ---
>   drivers/iio/dac/ad5504.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index 1e64493..c917dd2 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -15,17 +15,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/events.h>
>   #include <linux/iio/dac/ad5504.h>
>
> -#define AD5505_BITS			12
> -#define AD5504_RES_MASK			((1 << (AD5505_BITS)) - 1)
> -
> -#define AD5504_CMD_READ			(1 << 15)
> -#define AD5504_CMD_WRITE		(0 << 15)
> +#define AD5504_RES_MASK			GENMASK(11, 0)
> +#define AD5504_CMD_READ			BIT(15)
> +#define AD5504_CMD_WRITE		0
>   #define AD5504_ADDR(addr)		((addr) << 12)
>
>   /* Registers */
> @@ -42,7 +41,7 @@
>
>   /**
>    * struct ad5446_state - driver instance specific data
> - * @us:			spi_device
> + * @spi:			spi_device
>    * @reg:		supply regulator
>    * @vref_mv:		actual reference voltage used
>    * @pwr_down_mask	power down mask
>


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

* Re: [PATCH v2 03/12] iio:adc:ad7887: Use BIT() and GENMASK() macros
  2014-06-12  5:00 ` [PATCH v2 03/12] iio:adc:ad7887: " Peter Meerwald
@ 2014-06-14 15:03   ` Jonathan Cameron
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:03 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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

thanks
> ---
>   drivers/iio/adc/ad7887.c | 21 ++++++++++-----------
>   1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c
> index 749a6ca..2fd012e 100644
> --- a/drivers/iio/adc/ad7887.c
> +++ b/drivers/iio/adc/ad7887.c
> @@ -15,6 +15,7 @@
>   #include <linux/err.h>
>   #include <linux/module.h>
>   #include <linux/interrupt.h>
> +#include <linux/bitops.h>
>
>   #include <linux/iio/iio.h>
>   #include <linux/iio/sysfs.h>
> @@ -25,14 +26,14 @@
>
>   #include <linux/platform_data/ad7887.h>
>
> -#define AD7887_REF_DIS		(1 << 5) /* on-chip reference disable */
> -#define AD7887_DUAL		(1 << 4) /* dual-channel mode */
> -#define AD7887_CH_AIN1		(1 << 3) /* convert on channel 1, DUAL=1 */
> -#define AD7887_CH_AIN0		(0 << 3) /* convert on channel 0, DUAL=0,1 */
> -#define AD7887_PM_MODE1		(0)	 /* CS based shutdown */
> -#define AD7887_PM_MODE2		(1)	 /* full on */
> -#define AD7887_PM_MODE3		(2)	 /* auto shutdown after conversion */
> -#define AD7887_PM_MODE4		(3)	 /* standby mode */
> +#define AD7887_REF_DIS		BIT(5)	/* on-chip reference disable */
> +#define AD7887_DUAL		BIT(4)	/* dual-channel mode */
> +#define AD7887_CH_AIN1		BIT(3)	/* convert on channel 1, DUAL=1 */
> +#define AD7887_CH_AIN0		0	/* convert on channel 0, DUAL=0,1 */
> +#define AD7887_PM_MODE1		0	/* CS based shutdown */
> +#define AD7887_PM_MODE2		1	/* full on */
> +#define AD7887_PM_MODE3		2	/* auto shutdown after conversion */
> +#define AD7887_PM_MODE4		3	/* standby mode */
>
>   enum ad7887_channels {
>   	AD7887_CH0,
> @@ -40,8 +41,6 @@ enum ad7887_channels {
>   	AD7887_CH1,
>   };
>
> -#define RES_MASK(bits)	((1 << (bits)) - 1)
> -
>   /**
>    * struct ad7887_chip_info - chip specifc information
>    * @int_vref_mv:	the internal reference voltage
> @@ -167,7 +166,7 @@ static int ad7887_read_raw(struct iio_dev *indio_dev,
>   		if (ret < 0)
>   			return ret;
>   		*val = ret >> chan->scan_type.shift;
> -		*val &= RES_MASK(chan->scan_type.realbits);
> +		*val &= GENMASK(chan->scan_type.realbits - 1, 0);
>   		return IIO_VAL_INT;
>   	case IIO_CHAN_INFO_SCALE:
>   		if (st->reg) {
>


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

* Re: [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro
  2014-06-12  5:00 ` [PATCH v2 04/12] iio:adc:ad7476: Use GENMASK() macro Peter Meerwald
@ 2014-06-14 15:04   ` Jonathan Cameron
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:04 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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

Thanks,
> ---
>   drivers/iio/adc/ad7476.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
> index d141d45..ce400ec 100644
> --- a/drivers/iio/adc/ad7476.c
> +++ b/drivers/iio/adc/ad7476.c
> @@ -14,6 +14,7 @@
>   #include <linux/regulator/consumer.h>
>   #include <linux/err.h>
>   #include <linux/module.h>
> +#include <linux/bitops.h>
>
>   #include <linux/iio/iio.h>
>   #include <linux/iio/sysfs.h>
> @@ -21,8 +22,6 @@
>   #include <linux/iio/trigger_consumer.h>
>   #include <linux/iio/triggered_buffer.h>
>
> -#define RES_MASK(bits)	((1 << (bits)) - 1)
> -
>   struct ad7476_state;
>
>   struct ad7476_chip_info {
> @@ -117,7 +116,7 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,
>   		if (ret < 0)
>   			return ret;
>   		*val = (ret >> st->chip_info->channel[0].scan_type.shift) &
> -			RES_MASK(st->chip_info->channel[0].scan_type.realbits);
> +			GENMASK(st->chip_info->channel[0].scan_type.realbits - 1, 0);
>   		return IIO_VAL_INT;
>   	case IIO_CHAN_INFO_SCALE:
>   		if (!st->chip_info->int_vref_uv) {
>


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

* Re: [PATCH v2 05/12] iio:adc:ad7298: Use BIT() and GENMASK() macros
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:04 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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

Thanks,
> ---
>   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:
>


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

* Re: [PATCH v2 06/12] iio: Move documentation of iio-trig-sysfs to ABI/testing
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:05 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

On 12/06/14 06:00, Peter Meerwald wrote:
> iio-trig-sysfs has left staging with commit e64e7d5c
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Thanks,

Applied to the togreg branch of iio.git

J
> ---
>   Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs         | 11 +++++++++++
>   drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs | 11 -----------
>   2 files changed, 11 insertions(+), 11 deletions(-)
>   create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
>   delete mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs b/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
> new file mode 100644
> index 0000000..5235e6c
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-bus-iio-trigger-sysfs
> @@ -0,0 +1,11 @@
> +What:		/sys/bus/iio/devices/triggerX/trigger_now
> +KernelVersion:	2.6.38
> +Contact:	linux-iio@vger.kernel.org
> +Description:
> +		This file is provided by the iio-trig-sysfs stand-alone trigger
> +		driver. Writing this file with any value triggers an event
> +		driven driver, associated with this trigger, to capture data
> +		into an in kernel buffer. This approach can be valuable during
> +		automated testing or in situations, where other trigger methods
> +		are not applicable. For example no RTC or spare GPIOs.
> +		X is the IIO index of the trigger.
> diff --git a/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs b/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
> deleted file mode 100644
> index 5235e6c..0000000
> --- a/drivers/staging/iio/Documentation/sysfs-bus-iio-trigger-sysfs
> +++ /dev/null
> @@ -1,11 +0,0 @@
> -What:		/sys/bus/iio/devices/triggerX/trigger_now
> -KernelVersion:	2.6.38
> -Contact:	linux-iio@vger.kernel.org
> -Description:
> -		This file is provided by the iio-trig-sysfs stand-alone trigger
> -		driver. Writing this file with any value triggers an event
> -		driven driver, associated with this trigger, to capture data
> -		into an in kernel buffer. This approach can be valuable during
> -		automated testing or in situations, where other trigger methods
> -		are not applicable. For example no RTC or spare GPIOs.
> -		X is the IIO index of the trigger.
>


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

* Re: [PATCH v2 07/12] staging:iio: Update iio_event_monitor program
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:08 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

On 12/06/14 06:00, Peter Meerwald wrote:
> add types recently added
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

Thanks,
> ---
>   drivers/staging/iio/Documentation/iio_event_monitor.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/drivers/staging/iio/Documentation/iio_event_monitor.c b/drivers/staging/iio/Documentation/iio_event_monitor.c
> index 3a9b000..cb35a97 100644
> --- a/drivers/staging/iio/Documentation/iio_event_monitor.c
> +++ b/drivers/staging/iio/Documentation/iio_event_monitor.c
> @@ -46,6 +46,9 @@ static const char * const iio_chan_type_name_spec[] = {
>   	[IIO_TIMESTAMP] = "timestamp",
>   	[IIO_CAPACITANCE] = "capacitance",
>   	[IIO_ALTVOLTAGE] = "altvoltage",
> +	[IIO_CCT] = "cct",
> +	[IIO_PRESSURE] = "pressure",
> +	[IIO_HUMIDITYRELATIVE] = "humidityrelative",
>   };
>
>   static const char * const iio_ev_type_text[] = {
> @@ -70,6 +73,8 @@ static const char * const iio_modifier_names[] = {
>   	[IIO_MOD_LIGHT_IR] = "ir",
>   	[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
>   	[IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
> +	[IIO_MOD_LIGHT_BOTH] = "both",
> +	[IIO_MOD_LIGHT_IR] = "ir",
>   	[IIO_MOD_LIGHT_CLEAR] = "clear",
>   	[IIO_MOD_LIGHT_RED] = "red",
>   	[IIO_MOD_LIGHT_GREEN] = "green",
> @@ -100,6 +105,9 @@ static bool event_is_known(struct iio_event_data *event)
>   	case IIO_TIMESTAMP:
>   	case IIO_CAPACITANCE:
>   	case IIO_ALTVOLTAGE:
> +	case IIO_CCT:
> +	case IIO_PRESSURE:
> +	case IIO_HUMIDITYRELATIVE:
>   		break;
>   	default:
>   		return false;
> @@ -114,6 +122,8 @@ static bool event_is_known(struct iio_event_data *event)
>   	case IIO_MOD_LIGHT_IR:
>   	case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
>   	case IIO_MOD_SUM_SQUARED_X_Y_Z:
> +	case IIO_MOD_LIGHT_BOTH:
> +	case IIO_MOD_LIGHT_IR:
>   	case IIO_MOD_LIGHT_CLEAR:
>   	case IIO_MOD_LIGHT_RED:
>   	case IIO_MOD_LIGHT_GREEN:
>


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

* Re: [PATCH v2 08/12] staging:iio: Fix iio_utils.h function prototypes
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:08 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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

Thanks
> ---
>   drivers/staging/iio/Documentation/iio_utils.h | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/Documentation/iio_utils.h b/drivers/staging/iio/Documentation/iio_utils.h
> index a9cfc06..0973a09 100644
> --- a/drivers/staging/iio/Documentation/iio_utils.h
> +++ b/drivers/staging/iio/Documentation/iio_utils.h
> @@ -633,7 +633,7 @@ error_free:
>
>   int read_sysfs_float(char *filename, char *basedir, float *val)
>   {
> -	float ret = 0;
> +	int ret = 0;
>   	FILE  *sysfsfp;
>   	char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
>   	if (temp == NULL) {
> @@ -653,9 +653,9 @@ error_free:
>   	return ret;
>   }
>
> -read_sysfs_string(const char *filename, const char *basedir, char *str)
> +int read_sysfs_string(const char *filename, const char *basedir, char *str)
>   {
> -	float ret = 0;
> +	int ret = 0;
>   	FILE  *sysfsfp;
>   	char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
>   	if (temp == NULL) {
>


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

* Re: [PATCH v2 09/12] staging:iio: Fix mention of INDIO_RING_TRIGGERED to INDIO_BUFFER_TRIGGERED
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:08 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

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

Thanks,
> ---
>   drivers/staging/iio/Documentation/trigger.txt | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt
> index 64e2e08..7c0e505 100644
> --- a/drivers/staging/iio/Documentation/trigger.txt
> +++ b/drivers/staging/iio/Documentation/trigger.txt
> @@ -31,5 +31,5 @@ consumers.
>   Trigger Consumers
>
>   Currently triggers are only used for the filling of software
> -buffers and as such any device supporting INDIO_RING_TRIGGERED has the
> +buffers and as such any device supporting INDIO_BUFFER_TRIGGERED has the
>   consumer interface automatically created.
>


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

* Re: [PATCH v2 10/12] staging:iio: Fix error handling in generic_buffer example
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:09 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

On 12/06/14 06:00, Peter Meerwald wrote:
> read() does not return -EAGAIN
> read() returns -1 and the errno value needs to be checked for -EAGAIN
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

thanks
> ---
>   drivers/staging/iio/Documentation/generic_buffer.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/Documentation/generic_buffer.c b/drivers/staging/iio/Documentation/generic_buffer.c
> index 40d0eca..044ea19 100644
> --- a/drivers/staging/iio/Documentation/generic_buffer.c
> +++ b/drivers/staging/iio/Documentation/generic_buffer.c
> @@ -305,9 +305,12 @@ int main(int argc, char **argv)
>   		read_size = read(fp,
>   				 data,
>   				 toread*scan_size);
> -		if (read_size == -EAGAIN) {
> -			printf("nothing available\n");
> -			continue;
> +		if (read_size < 0) {
> +			if (errno == -EAGAIN) {
> +				printf("nothing available\n");
> +				continue;
> +			} else
> +				break;
>   		}
>   		for (i = 0; i < read_size/scan_size; i++)
>   			process_scan(data + scan_size*i,
>


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

* Re: [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup
  2014-06-12  5:00 ` [PATCH v2 11/12] staging:iio-trig-periodic-rtc: Cleanup Peter Meerwald
@ 2014-06-14 15:11   ` Jonathan Cameron
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:11 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

On 12/06/14 06:00, Peter Meerwald wrote:
> Fix extra space in module description
> Silence output about trigger frequency when trigger gets enabled/disabled
> Add dash to make trigger name look nicer (periodicrtc0 -> periodic-rtc0)
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Modified the description to not mention the dash that is no longer here..
Applied to the togreg branch of iio.git

Thanks,
> ---
>   drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> index 38ecb4b..362a54a 100644
> --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> @@ -33,7 +33,7 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
>   	struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
>   	if (trig_info->frequency == 0)
>   		return -EINVAL;
> -	dev_info(&trig_info->rtc->dev, "trigger frequency is %d\n",
> +	dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
>   			trig_info->frequency);
>   	return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
>   }
> @@ -128,8 +128,7 @@ static int iio_trig_periodic_rtc_probe(struct platform_device *dev)
>   		iio_trigger_set_drvdata(trig, trig_info);
>   		trig->ops = &iio_prtc_trigger_ops;
>   		/* RTC access */
> -		trig_info->rtc
> -			= rtc_class_open(pdata[i]);
> +		trig_info->rtc = rtc_class_open(pdata[i]);
>   		if (trig_info->rtc == NULL) {
>   			ret = -EINVAL;
>   			goto error_free_trig_info;
> @@ -199,5 +198,5 @@ static struct platform_driver iio_trig_periodic_rtc_driver = {
>   module_platform_driver(iio_trig_periodic_rtc_driver);
>
>   MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>");
> -MODULE_DESCRIPTION("Periodic realtime clock  trigger for the iio subsystem");
> +MODULE_DESCRIPTION("Periodic realtime clock trigger for the iio subsystem");
>   MODULE_LICENSE("GPL v2");
>


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

* Re: [PATCH v2 12/12] staging:iio-trig-periodic-rtc: Allow to reset frequency to 0
  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
  0 siblings, 0 replies; 25+ messages in thread
From: Jonathan Cameron @ 2014-06-14 15:12 UTC (permalink / raw)
  To: Peter Meerwald, linux-iio

On 12/06/14 06:00, Peter Meerwald wrote:
> periodic rtc trigger initially has frequency 0
>
> it is possible to change trigger frequency on-the-fly, but it is not
> possible to set frequency back to 0
>
> this patch allows to set trigger frequency to 0, thereby disabling
> the rtc interrupt
>
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

thanks,
> ---
>   drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 19 ++++++++++++++++---
>   1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> index 362a54a..b5108a1 100644
> --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c
> @@ -26,16 +26,22 @@ struct iio_prtc_trigger_info {
>   	struct rtc_device *rtc;
>   	int frequency;
>   	struct rtc_task task;
> +	bool state;
>   };
>
>   static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state)
>   {
>   	struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
> -	if (trig_info->frequency == 0)
> +	int ret;
> +	if (trig_info->frequency == 0 && state)
>   		return -EINVAL;
>   	dev_dbg(&trig_info->rtc->dev, "trigger frequency is %d\n",
>   			trig_info->frequency);
> -	return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
> +	ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, state);
> +	if (ret == 0)
> +		trig_info->state = state;
> +
> +	return ret;
>   }
>
>   static ssize_t iio_trig_periodic_read_freq(struct device *dev,
> @@ -61,7 +67,14 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
>   	if (ret)
>   		goto error_ret;
>
> -	ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
> +	if (val > 0) {
> +		ret = rtc_irq_set_freq(trig_info->rtc, &trig_info->task, val);
> +		if (ret == 0 && trig_info->state && trig_info->frequency == 0)
> +			ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 1);
> +	} else if (val == 0) {
> +		ret = rtc_irq_set_state(trig_info->rtc, &trig_info->task, 0);
> +	} else
> +		ret = -EINVAL;
>   	if (ret)
>   		goto error_ret;
>
>


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

end of thread, other threads:[~2014-06-14 15:10 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.