Commit 3ea48e01 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

staging:iio:tsl2x7x: Switch to new event config interface

Switch the tsl2x7x driver to the new IIO event config interface as the old one
is going to be removed.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Cc: Jon Brenner <jbrenner@taosinc.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent bda624b0
...@@ -124,11 +124,6 @@ ...@@ -124,11 +124,6 @@
#define TSL2X7X_mA13 0xD0 #define TSL2X7X_mA13 0xD0
#define TSL2X7X_MAX_TIMER_CNT (0xFF) #define TSL2X7X_MAX_TIMER_CNT (0xFF)
/*Common device IIO EventMask */
#define TSL2X7X_EVENT_MASK \
(IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING)),
#define TSL2X7X_MIN_ITIME 3 #define TSL2X7X_MIN_ITIME 3
/* TAOS txx2x7x Device family members */ /* TAOS txx2x7x Device family members */
...@@ -1222,12 +1217,14 @@ static ssize_t tsl2x7x_do_prox_calibrate(struct device *dev, ...@@ -1222,12 +1217,14 @@ static ssize_t tsl2x7x_do_prox_calibrate(struct device *dev,
} }
static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev, static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev,
u64 event_code) const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir)
{ {
struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev);
int ret; int ret;
if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) if (chan->type == IIO_INTENSITY)
ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x10); ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x10);
else else
ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x20); ret = !!(chip->tsl2x7x_settings.interrupts_en & 0x20);
...@@ -1236,12 +1233,14 @@ static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev, ...@@ -1236,12 +1233,14 @@ static int tsl2x7x_read_interrupt_config(struct iio_dev *indio_dev,
} }
static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev, static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
int val) int val)
{ {
struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev);
if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) { if (chan->type == IIO_INTENSITY) {
if (val) if (val)
chip->tsl2x7x_settings.interrupts_en |= 0x10; chip->tsl2x7x_settings.interrupts_en |= 0x10;
else else
...@@ -1259,13 +1258,16 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev, ...@@ -1259,13 +1258,16 @@ static int tsl2x7x_write_interrupt_config(struct iio_dev *indio_dev,
} }
static int tsl2x7x_write_thresh(struct iio_dev *indio_dev, static int tsl2x7x_write_thresh(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan,
int val) enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info,
int val, int val2)
{ {
struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev);
if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) { if (chan->type == IIO_INTENSITY) {
switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { switch (dir) {
case IIO_EV_DIR_RISING: case IIO_EV_DIR_RISING:
chip->tsl2x7x_settings.als_thresh_high = val; chip->tsl2x7x_settings.als_thresh_high = val;
break; break;
...@@ -1276,7 +1278,7 @@ static int tsl2x7x_write_thresh(struct iio_dev *indio_dev, ...@@ -1276,7 +1278,7 @@ static int tsl2x7x_write_thresh(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
} else { } else {
switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { switch (dir) {
case IIO_EV_DIR_RISING: case IIO_EV_DIR_RISING:
chip->tsl2x7x_settings.prox_thres_high = val; chip->tsl2x7x_settings.prox_thres_high = val;
break; break;
...@@ -1294,13 +1296,16 @@ static int tsl2x7x_write_thresh(struct iio_dev *indio_dev, ...@@ -1294,13 +1296,16 @@ static int tsl2x7x_write_thresh(struct iio_dev *indio_dev,
} }
static int tsl2x7x_read_thresh(struct iio_dev *indio_dev, static int tsl2x7x_read_thresh(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan,
int *val) enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info,
int *val, int *val2)
{ {
struct tsl2X7X_chip *chip = iio_priv(indio_dev); struct tsl2X7X_chip *chip = iio_priv(indio_dev);
if (IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(event_code) == IIO_INTENSITY) { if (chan->type == IIO_INTENSITY) {
switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { switch (dir) {
case IIO_EV_DIR_RISING: case IIO_EV_DIR_RISING:
*val = chip->tsl2x7x_settings.als_thresh_high; *val = chip->tsl2x7x_settings.als_thresh_high;
break; break;
...@@ -1311,7 +1316,7 @@ static int tsl2x7x_read_thresh(struct iio_dev *indio_dev, ...@@ -1311,7 +1316,7 @@ static int tsl2x7x_read_thresh(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
} else { } else {
switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { switch (dir) {
case IIO_EV_DIR_RISING: case IIO_EV_DIR_RISING:
*val = chip->tsl2x7x_settings.prox_thres_high; *val = chip->tsl2x7x_settings.prox_thres_high;
break; break;
...@@ -1323,7 +1328,7 @@ static int tsl2x7x_read_thresh(struct iio_dev *indio_dev, ...@@ -1323,7 +1328,7 @@ static int tsl2x7x_read_thresh(struct iio_dev *indio_dev,
} }
} }
return 0; return IIO_VAL_INT;
} }
static int tsl2x7x_read_raw(struct iio_dev *indio_dev, static int tsl2x7x_read_raw(struct iio_dev *indio_dev,
...@@ -1667,10 +1672,10 @@ static const struct iio_info tsl2X7X_device_info[] = { ...@@ -1667,10 +1672,10 @@ static const struct iio_info tsl2X7X_device_info[] = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2x7x_read_raw, .read_raw = &tsl2x7x_read_raw,
.write_raw = &tsl2x7x_write_raw, .write_raw = &tsl2x7x_write_raw,
.read_event_value = &tsl2x7x_read_thresh, .read_event_value_new = &tsl2x7x_read_thresh,
.write_event_value = &tsl2x7x_write_thresh, .write_event_value_new = &tsl2x7x_write_thresh,
.read_event_config = &tsl2x7x_read_interrupt_config, .read_event_config_new = &tsl2x7x_read_interrupt_config,
.write_event_config = &tsl2x7x_write_interrupt_config, .write_event_config_new = &tsl2x7x_write_interrupt_config,
}, },
[PRX] = { [PRX] = {
.attrs = &tsl2X7X_device_attr_group_tbl[PRX], .attrs = &tsl2X7X_device_attr_group_tbl[PRX],
...@@ -1678,10 +1683,10 @@ static const struct iio_info tsl2X7X_device_info[] = { ...@@ -1678,10 +1683,10 @@ static const struct iio_info tsl2X7X_device_info[] = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2x7x_read_raw, .read_raw = &tsl2x7x_read_raw,
.write_raw = &tsl2x7x_write_raw, .write_raw = &tsl2x7x_write_raw,
.read_event_value = &tsl2x7x_read_thresh, .read_event_value_new = &tsl2x7x_read_thresh,
.write_event_value = &tsl2x7x_write_thresh, .write_event_value_new = &tsl2x7x_write_thresh,
.read_event_config = &tsl2x7x_read_interrupt_config, .read_event_config_new = &tsl2x7x_read_interrupt_config,
.write_event_config = &tsl2x7x_write_interrupt_config, .write_event_config_new = &tsl2x7x_write_interrupt_config,
}, },
[ALSPRX] = { [ALSPRX] = {
.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX], .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX],
...@@ -1689,10 +1694,10 @@ static const struct iio_info tsl2X7X_device_info[] = { ...@@ -1689,10 +1694,10 @@ static const struct iio_info tsl2X7X_device_info[] = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2x7x_read_raw, .read_raw = &tsl2x7x_read_raw,
.write_raw = &tsl2x7x_write_raw, .write_raw = &tsl2x7x_write_raw,
.read_event_value = &tsl2x7x_read_thresh, .read_event_value_new = &tsl2x7x_read_thresh,
.write_event_value = &tsl2x7x_write_thresh, .write_event_value_new = &tsl2x7x_write_thresh,
.read_event_config = &tsl2x7x_read_interrupt_config, .read_event_config_new = &tsl2x7x_read_interrupt_config,
.write_event_config = &tsl2x7x_write_interrupt_config, .write_event_config_new = &tsl2x7x_write_interrupt_config,
}, },
[PRX2] = { [PRX2] = {
.attrs = &tsl2X7X_device_attr_group_tbl[PRX2], .attrs = &tsl2X7X_device_attr_group_tbl[PRX2],
...@@ -1700,10 +1705,10 @@ static const struct iio_info tsl2X7X_device_info[] = { ...@@ -1700,10 +1705,10 @@ static const struct iio_info tsl2X7X_device_info[] = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2x7x_read_raw, .read_raw = &tsl2x7x_read_raw,
.write_raw = &tsl2x7x_write_raw, .write_raw = &tsl2x7x_write_raw,
.read_event_value = &tsl2x7x_read_thresh, .read_event_value_new = &tsl2x7x_read_thresh,
.write_event_value = &tsl2x7x_write_thresh, .write_event_value_new = &tsl2x7x_write_thresh,
.read_event_config = &tsl2x7x_read_interrupt_config, .read_event_config_new = &tsl2x7x_read_interrupt_config,
.write_event_config = &tsl2x7x_write_interrupt_config, .write_event_config_new = &tsl2x7x_write_interrupt_config,
}, },
[ALSPRX2] = { [ALSPRX2] = {
.attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2], .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2],
...@@ -1711,10 +1716,24 @@ static const struct iio_info tsl2X7X_device_info[] = { ...@@ -1711,10 +1716,24 @@ static const struct iio_info tsl2X7X_device_info[] = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2x7x_read_raw, .read_raw = &tsl2x7x_read_raw,
.write_raw = &tsl2x7x_write_raw, .write_raw = &tsl2x7x_write_raw,
.read_event_value = &tsl2x7x_read_thresh, .read_event_value_new = &tsl2x7x_read_thresh,
.write_event_value = &tsl2x7x_write_thresh, .write_event_value_new = &tsl2x7x_write_thresh,
.read_event_config = &tsl2x7x_read_interrupt_config, .read_event_config_new = &tsl2x7x_read_interrupt_config,
.write_event_config = &tsl2x7x_write_interrupt_config, .write_event_config_new = &tsl2x7x_write_interrupt_config,
},
};
static const struct iio_event_spec tsl2x7x_events[] = {
{
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_RISING,
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
BIT(IIO_EV_INFO_ENABLE),
}, {
.type = IIO_EV_TYPE_THRESH,
.dir = IIO_EV_DIR_FALLING,
.mask_separate = BIT(IIO_EV_INFO_VALUE) |
BIT(IIO_EV_INFO_ENABLE),
}, },
}; };
...@@ -1733,7 +1752,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1733,7 +1752,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBSCALE) | BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS), BIT(IIO_CHAN_INFO_CALIBBIAS),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, { }, {
.type = IIO_INTENSITY, .type = IIO_INTENSITY,
.indexed = 1, .indexed = 1,
...@@ -1750,7 +1770,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1750,7 +1770,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, },
}, },
.chan_table_elements = 1, .chan_table_elements = 1,
...@@ -1770,7 +1791,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1770,7 +1791,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBSCALE) | BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS), BIT(IIO_CHAN_INFO_CALIBBIAS),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, { }, {
.type = IIO_INTENSITY, .type = IIO_INTENSITY,
.indexed = 1, .indexed = 1,
...@@ -1781,7 +1803,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1781,7 +1803,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.indexed = 1, .indexed = 1,
.channel = 0, .channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, },
}, },
.chan_table_elements = 4, .chan_table_elements = 4,
...@@ -1795,7 +1818,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1795,7 +1818,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.channel = 0, .channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBSCALE), BIT(IIO_CHAN_INFO_CALIBSCALE),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, },
}, },
.chan_table_elements = 1, .chan_table_elements = 1,
...@@ -1815,7 +1839,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1815,7 +1839,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBSCALE) | BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS), BIT(IIO_CHAN_INFO_CALIBBIAS),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, { }, {
.type = IIO_INTENSITY, .type = IIO_INTENSITY,
.indexed = 1, .indexed = 1,
...@@ -1827,7 +1852,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = { ...@@ -1827,7 +1852,8 @@ static const struct tsl2x7x_chip_info tsl2x7x_chip_info_tbl[] = {
.channel = 0, .channel = 0,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBSCALE), BIT(IIO_CHAN_INFO_CALIBSCALE),
.event_mask = TSL2X7X_EVENT_MASK .event_spec = tsl2x7x_events,
.num_event_specs = ARRAY_SIZE(tsl2x7x_events),
}, },
}, },
.chan_table_elements = 4, .chan_table_elements = 4,
......
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