diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-10-07 10:11:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-10-12 07:35:05 -0400 |
commit | 1eefd62b63e1c67d2c722a00e05fbe0742021c14 (patch) | |
tree | d13eb80b504905829520f011dfcb3957bfadb2d4 /drivers/iio | |
parent | e4ec84f83deb9792ee8277805ca03f9349dc1c93 (diff) |
iio:ad5421: Switch to new event config interface
Switch the ad5421 driver to the new IIO event config interface as the old one
is going to be removed.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/dac/ad5421.c | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 567c4bd546e5..c44afeb06f56 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c | |||
@@ -80,6 +80,29 @@ struct ad5421_state { | |||
80 | } data[2] ____cacheline_aligned; | 80 | } data[2] ____cacheline_aligned; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const struct iio_event_spec ad5421_current_event[] = { | ||
84 | { | ||
85 | .type = IIO_EV_TYPE_THRESH, | ||
86 | .dir = IIO_EV_DIR_RISING, | ||
87 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | ||
88 | BIT(IIO_EV_INFO_ENABLE), | ||
89 | }, { | ||
90 | .type = IIO_EV_TYPE_THRESH, | ||
91 | .dir = IIO_EV_DIR_FALLING, | ||
92 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | ||
93 | BIT(IIO_EV_INFO_ENABLE), | ||
94 | }, | ||
95 | }; | ||
96 | |||
97 | static const struct iio_event_spec ad5421_temp_event[] = { | ||
98 | { | ||
99 | .type = IIO_EV_TYPE_THRESH, | ||
100 | .dir = IIO_EV_DIR_RISING, | ||
101 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | | ||
102 | BIT(IIO_EV_INFO_ENABLE), | ||
103 | }, | ||
104 | }; | ||
105 | |||
83 | static const struct iio_chan_spec ad5421_channels[] = { | 106 | static const struct iio_chan_spec ad5421_channels[] = { |
84 | { | 107 | { |
85 | .type = IIO_CURRENT, | 108 | .type = IIO_CURRENT, |
@@ -92,13 +115,14 @@ static const struct iio_chan_spec ad5421_channels[] = { | |||
92 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | | 115 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | |
93 | BIT(IIO_CHAN_INFO_OFFSET), | 116 | BIT(IIO_CHAN_INFO_OFFSET), |
94 | .scan_type = IIO_ST('u', 16, 16, 0), | 117 | .scan_type = IIO_ST('u', 16, 16, 0), |
95 | .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | | 118 | .event_spec = ad5421_current_event, |
96 | IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING), | 119 | .num_event_specs = ARRAY_SIZE(ad5421_current_event), |
97 | }, | 120 | }, |
98 | { | 121 | { |
99 | .type = IIO_TEMP, | 122 | .type = IIO_TEMP, |
100 | .channel = -1, | 123 | .channel = -1, |
101 | .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING), | 124 | .event_spec = ad5421_temp_event, |
125 | .num_event_specs = ARRAY_SIZE(ad5421_temp_event), | ||
102 | }, | 126 | }, |
103 | }; | 127 | }; |
104 | 128 | ||
@@ -353,15 +377,15 @@ static int ad5421_write_raw(struct iio_dev *indio_dev, | |||
353 | } | 377 | } |
354 | 378 | ||
355 | static int ad5421_write_event_config(struct iio_dev *indio_dev, | 379 | static int ad5421_write_event_config(struct iio_dev *indio_dev, |
356 | u64 event_code, int state) | 380 | const struct iio_chan_spec *chan, enum iio_event_type type, |
381 | enum iio_event_direction dir, int state) | ||
357 | { | 382 | { |
358 | struct ad5421_state *st = iio_priv(indio_dev); | 383 | struct ad5421_state *st = iio_priv(indio_dev); |
359 | unsigned int mask; | 384 | unsigned int mask; |
360 | 385 | ||
361 | switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { | 386 | switch (chan->type) { |
362 | case IIO_CURRENT: | 387 | case IIO_CURRENT: |
363 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == | 388 | if (dir == IIO_EV_DIR_RISING) |
364 | IIO_EV_DIR_RISING) | ||
365 | mask = AD5421_FAULT_OVER_CURRENT; | 389 | mask = AD5421_FAULT_OVER_CURRENT; |
366 | else | 390 | else |
367 | mask = AD5421_FAULT_UNDER_CURRENT; | 391 | mask = AD5421_FAULT_UNDER_CURRENT; |
@@ -384,15 +408,15 @@ static int ad5421_write_event_config(struct iio_dev *indio_dev, | |||
384 | } | 408 | } |
385 | 409 | ||
386 | static int ad5421_read_event_config(struct iio_dev *indio_dev, | 410 | static int ad5421_read_event_config(struct iio_dev *indio_dev, |
387 | u64 event_code) | 411 | const struct iio_chan_spec *chan, enum iio_event_type type, |
412 | enum iio_event_direction dir) | ||
388 | { | 413 | { |
389 | struct ad5421_state *st = iio_priv(indio_dev); | 414 | struct ad5421_state *st = iio_priv(indio_dev); |
390 | unsigned int mask; | 415 | unsigned int mask; |
391 | 416 | ||
392 | switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { | 417 | switch (chan->type) { |
393 | case IIO_CURRENT: | 418 | case IIO_CURRENT: |
394 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == | 419 | if (dir == IIO_EV_DIR_RISING) |
395 | IIO_EV_DIR_RISING) | ||
396 | mask = AD5421_FAULT_OVER_CURRENT; | 420 | mask = AD5421_FAULT_OVER_CURRENT; |
397 | else | 421 | else |
398 | mask = AD5421_FAULT_UNDER_CURRENT; | 422 | mask = AD5421_FAULT_UNDER_CURRENT; |
@@ -407,12 +431,14 @@ static int ad5421_read_event_config(struct iio_dev *indio_dev, | |||
407 | return (bool)(st->fault_mask & mask); | 431 | return (bool)(st->fault_mask & mask); |
408 | } | 432 | } |
409 | 433 | ||
410 | static int ad5421_read_event_value(struct iio_dev *indio_dev, u64 event_code, | 434 | static int ad5421_read_event_value(struct iio_dev *indio_dev, |
411 | int *val) | 435 | const struct iio_chan_spec *chan, enum iio_event_type type, |
436 | enum iio_event_direction dir, enum iio_event_info info, int *val, | ||
437 | int *val2) | ||
412 | { | 438 | { |
413 | int ret; | 439 | int ret; |
414 | 440 | ||
415 | switch (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code)) { | 441 | switch (chan->type) { |
416 | case IIO_CURRENT: | 442 | case IIO_CURRENT: |
417 | ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA); | 443 | ret = ad5421_read(indio_dev, AD5421_REG_DAC_DATA); |
418 | if (ret < 0) | 444 | if (ret < 0) |
@@ -426,15 +452,15 @@ static int ad5421_read_event_value(struct iio_dev *indio_dev, u64 event_code, | |||
426 | return -EINVAL; | 452 | return -EINVAL; |
427 | } | 453 | } |
428 | 454 | ||
429 | return 0; | 455 | return IIO_VAL_INT; |
430 | } | 456 | } |
431 | 457 | ||
432 | static const struct iio_info ad5421_info = { | 458 | static const struct iio_info ad5421_info = { |
433 | .read_raw = ad5421_read_raw, | 459 | .read_raw = ad5421_read_raw, |
434 | .write_raw = ad5421_write_raw, | 460 | .write_raw = ad5421_write_raw, |
435 | .read_event_config = ad5421_read_event_config, | 461 | .read_event_config_new = ad5421_read_event_config, |
436 | .write_event_config = ad5421_write_event_config, | 462 | .write_event_config_new = ad5421_write_event_config, |
437 | .read_event_value = ad5421_read_event_value, | 463 | .read_event_value_new = ad5421_read_event_value, |
438 | .driver_module = THIS_MODULE, | 464 | .driver_module = THIS_MODULE, |
439 | }; | 465 | }; |
440 | 466 | ||