aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/light/tsl2563.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-10-07 10:11:00 -0400
committerJonathan Cameron <jic23@kernel.org>2013-10-12 07:39:27 -0400
commit6d59747eb08092d65c186728938a5dcf329b03f0 (patch)
treef703cb1a82548b6d424cb6684fd3cc91737457bb /drivers/iio/light/tsl2563.c
parent5d6a25bad035981b3ceb768ae6164248004e226d (diff)
iio:tsl2563: Switch to new event config interface
Switch the tsl2563 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/light/tsl2563.c')
-rw-r--r--drivers/iio/light/tsl2563.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index ebb962c5c323..5e5d9dea22c5 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -526,6 +526,20 @@ error_ret:
526 return ret; 526 return ret;
527} 527}
528 528
529static const struct iio_event_spec tsl2563_events[] = {
530 {
531 .type = IIO_EV_TYPE_THRESH,
532 .dir = IIO_EV_DIR_RISING,
533 .mask_separate = BIT(IIO_EV_INFO_VALUE) |
534 BIT(IIO_EV_INFO_ENABLE),
535 }, {
536 .type = IIO_EV_TYPE_THRESH,
537 .dir = IIO_EV_DIR_FALLING,
538 .mask_separate = BIT(IIO_EV_INFO_VALUE) |
539 BIT(IIO_EV_INFO_ENABLE),
540 },
541};
542
529static const struct iio_chan_spec tsl2563_channels[] = { 543static const struct iio_chan_spec tsl2563_channels[] = {
530 { 544 {
531 .type = IIO_LIGHT, 545 .type = IIO_LIGHT,
@@ -538,10 +552,8 @@ static const struct iio_chan_spec tsl2563_channels[] = {
538 .channel2 = IIO_MOD_LIGHT_BOTH, 552 .channel2 = IIO_MOD_LIGHT_BOTH,
539 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 553 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
540 BIT(IIO_CHAN_INFO_CALIBSCALE), 554 BIT(IIO_CHAN_INFO_CALIBSCALE),
541 .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, 555 .event_spec = tsl2563_events,
542 IIO_EV_DIR_RISING) | 556 .num_event_specs = ARRAY_SIZE(tsl2563_events),
543 IIO_EV_BIT(IIO_EV_TYPE_THRESH,
544 IIO_EV_DIR_FALLING)),
545 }, { 557 }, {
546 .type = IIO_INTENSITY, 558 .type = IIO_INTENSITY,
547 .modified = 1, 559 .modified = 1,
@@ -552,12 +564,13 @@ static const struct iio_chan_spec tsl2563_channels[] = {
552}; 564};
553 565
554static int tsl2563_read_thresh(struct iio_dev *indio_dev, 566static int tsl2563_read_thresh(struct iio_dev *indio_dev,
555 u64 event_code, 567 const struct iio_chan_spec *chan, enum iio_event_type type,
556 int *val) 568 enum iio_event_direction dir, enum iio_event_info info, int *val,
569 int *val2)
557{ 570{
558 struct tsl2563_chip *chip = iio_priv(indio_dev); 571 struct tsl2563_chip *chip = iio_priv(indio_dev);
559 572
560 switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { 573 switch (dir) {
561 case IIO_EV_DIR_RISING: 574 case IIO_EV_DIR_RISING:
562 *val = chip->high_thres; 575 *val = chip->high_thres;
563 break; 576 break;
@@ -568,18 +581,19 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev,
568 return -EINVAL; 581 return -EINVAL;
569 } 582 }
570 583
571 return 0; 584 return IIO_VAL_INT;
572} 585}
573 586
574static int tsl2563_write_thresh(struct iio_dev *indio_dev, 587static int tsl2563_write_thresh(struct iio_dev *indio_dev,
575 u64 event_code, 588 const struct iio_chan_spec *chan, enum iio_event_type type,
576 int val) 589 enum iio_event_direction dir, enum iio_event_info info, int val,
590 int val2)
577{ 591{
578 struct tsl2563_chip *chip = iio_priv(indio_dev); 592 struct tsl2563_chip *chip = iio_priv(indio_dev);
579 int ret; 593 int ret;
580 u8 address; 594 u8 address;
581 595
582 if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) 596 if (dir == IIO_EV_DIR_RISING)
583 address = TSL2563_REG_HIGHLOW; 597 address = TSL2563_REG_HIGHLOW;
584 else 598 else
585 address = TSL2563_REG_LOWLOW; 599 address = TSL2563_REG_LOWLOW;
@@ -591,7 +605,7 @@ static int tsl2563_write_thresh(struct iio_dev *indio_dev,
591 ret = i2c_smbus_write_byte_data(chip->client, 605 ret = i2c_smbus_write_byte_data(chip->client,
592 TSL2563_CMD | (address + 1), 606 TSL2563_CMD | (address + 1),
593 (val >> 8) & 0xFF); 607 (val >> 8) & 0xFF);
594 if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) 608 if (dir == IIO_EV_DIR_RISING)
595 chip->high_thres = val; 609 chip->high_thres = val;
596 else 610 else
597 chip->low_thres = val; 611 chip->low_thres = val;
@@ -620,8 +634,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private)
620} 634}
621 635
622static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, 636static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
623 u64 event_code, 637 const struct iio_chan_spec *chan, enum iio_event_type type,
624 int state) 638 enum iio_event_direction dir, int state)
625{ 639{
626 struct tsl2563_chip *chip = iio_priv(indio_dev); 640 struct tsl2563_chip *chip = iio_priv(indio_dev);
627 int ret = 0; 641 int ret = 0;
@@ -662,7 +676,8 @@ out:
662} 676}
663 677
664static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, 678static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev,
665 u64 event_code) 679 const struct iio_chan_spec *chan, enum iio_event_type type,
680 enum iio_event_direction dir)
666{ 681{
667 struct tsl2563_chip *chip = iio_priv(indio_dev); 682 struct tsl2563_chip *chip = iio_priv(indio_dev);
668 int ret; 683 int ret;
@@ -687,10 +702,10 @@ static const struct iio_info tsl2563_info = {
687 .driver_module = THIS_MODULE, 702 .driver_module = THIS_MODULE,
688 .read_raw = &tsl2563_read_raw, 703 .read_raw = &tsl2563_read_raw,
689 .write_raw = &tsl2563_write_raw, 704 .write_raw = &tsl2563_write_raw,
690 .read_event_value = &tsl2563_read_thresh, 705 .read_event_value_new = &tsl2563_read_thresh,
691 .write_event_value = &tsl2563_write_thresh, 706 .write_event_value_new = &tsl2563_write_thresh,
692 .read_event_config = &tsl2563_read_interrupt_config, 707 .read_event_config_new = &tsl2563_read_interrupt_config,
693 .write_event_config = &tsl2563_write_interrupt_config, 708 .write_event_config_new = &tsl2563_write_interrupt_config,
694}; 709};
695 710
696static int tsl2563_probe(struct i2c_client *client, 711static int tsl2563_probe(struct i2c_client *client,