Commit b576590d authored by Michael Hennerich's avatar Michael Hennerich Committed by Greg Kroah-Hartman

staging:iio:adc:ad7291: introduce IIO_EVENT_CODE_EXTRACT_CHAN_TYPE and use accordingly

Fix channel type handling
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 94c93dbd
...@@ -314,7 +314,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev, ...@@ -314,7 +314,7 @@ static int ad7291_read_event_value(struct iio_dev *indio_dev,
u16 uval; u16 uval;
s16 signval; s16 signval;
switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] reg = ad7291_limit_regs[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]
[!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) == [!(IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
...@@ -350,7 +350,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev, ...@@ -350,7 +350,7 @@ static int ad7291_write_event_value(struct iio_dev *indio_dev,
u8 reg; u8 reg;
s16 signval; s16 signval;
switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
if (val > 0xFFF || val < 0) if (val > 0xFFF || val < 0)
return -EINVAL; return -EINVAL;
...@@ -378,7 +378,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev, ...@@ -378,7 +378,7 @@ static int ad7291_read_event_config(struct iio_dev *indio_dev,
/* To be enabled the channel must simply be on. If any are enabled /* To be enabled the channel must simply be on. If any are enabled
we are in continuous sampling mode */ we are in continuous sampling mode */
switch (IIO_EVENT_CODE_EXTRACT_TYPE(event_code)) { switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
if (chip->c_mask & if (chip->c_mask &
(1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code))) (1 << IIO_EVENT_CODE_EXTRACT_NUM(event_code)))
......
...@@ -146,8 +146,11 @@ enum iio_event_direction { ...@@ -146,8 +146,11 @@ enum iio_event_direction {
IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0) IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0)
#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF) #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF)
#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
/* Event code number extraction depends on which type of event we have. /* Event code number extraction depends on which type of event we have.
* Perhaps review this function in the future*/ * Perhaps review this function in the future*/
#define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF) #define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment