Commit 6d59747e authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron

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: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 5d6a25ba
...@@ -526,6 +526,20 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ...@@ -526,6 +526,20 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
return ret; return ret;
} }
static const struct iio_event_spec tsl2563_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),
},
};
static const struct iio_chan_spec tsl2563_channels[] = { static const struct iio_chan_spec tsl2563_channels[] = {
{ {
.type = IIO_LIGHT, .type = IIO_LIGHT,
...@@ -538,10 +552,8 @@ static const struct iio_chan_spec tsl2563_channels[] = { ...@@ -538,10 +552,8 @@ static const struct iio_chan_spec tsl2563_channels[] = {
.channel2 = IIO_MOD_LIGHT_BOTH, .channel2 = IIO_MOD_LIGHT_BOTH,
.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 = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, .event_spec = tsl2563_events,
IIO_EV_DIR_RISING) | .num_event_specs = ARRAY_SIZE(tsl2563_events),
IIO_EV_BIT(IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING)),
}, { }, {
.type = IIO_INTENSITY, .type = IIO_INTENSITY,
.modified = 1, .modified = 1,
...@@ -552,12 +564,13 @@ static const struct iio_chan_spec tsl2563_channels[] = { ...@@ -552,12 +564,13 @@ static const struct iio_chan_spec tsl2563_channels[] = {
}; };
static int tsl2563_read_thresh(struct iio_dev *indio_dev, static int tsl2563_read_thresh(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan, enum iio_event_type type,
int *val) enum iio_event_direction dir, enum iio_event_info info, int *val,
int *val2)
{ {
struct tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { switch (dir) {
case IIO_EV_DIR_RISING: case IIO_EV_DIR_RISING:
*val = chip->high_thres; *val = chip->high_thres;
break; break;
...@@ -568,18 +581,19 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev, ...@@ -568,18 +581,19 @@ static int tsl2563_read_thresh(struct iio_dev *indio_dev,
return -EINVAL; return -EINVAL;
} }
return 0; return IIO_VAL_INT;
} }
static int tsl2563_write_thresh(struct iio_dev *indio_dev, static int tsl2563_write_thresh(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan, enum iio_event_type type,
int val) enum iio_event_direction dir, enum iio_event_info info, int val,
int val2)
{ {
struct tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
int ret; int ret;
u8 address; u8 address;
if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) if (dir == IIO_EV_DIR_RISING)
address = TSL2563_REG_HIGHLOW; address = TSL2563_REG_HIGHLOW;
else else
address = TSL2563_REG_LOWLOW; address = TSL2563_REG_LOWLOW;
...@@ -591,7 +605,7 @@ static int tsl2563_write_thresh(struct iio_dev *indio_dev, ...@@ -591,7 +605,7 @@ static int tsl2563_write_thresh(struct iio_dev *indio_dev,
ret = i2c_smbus_write_byte_data(chip->client, ret = i2c_smbus_write_byte_data(chip->client,
TSL2563_CMD | (address + 1), TSL2563_CMD | (address + 1),
(val >> 8) & 0xFF); (val >> 8) & 0xFF);
if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) if (dir == IIO_EV_DIR_RISING)
chip->high_thres = val; chip->high_thres = val;
else else
chip->low_thres = val; chip->low_thres = val;
...@@ -620,8 +634,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private) ...@@ -620,8 +634,8 @@ static irqreturn_t tsl2563_event_handler(int irq, void *private)
} }
static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
u64 event_code, const struct iio_chan_spec *chan, enum iio_event_type type,
int state) enum iio_event_direction dir, int state)
{ {
struct tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
int ret = 0; int ret = 0;
...@@ -662,7 +676,8 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, ...@@ -662,7 +676,8 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
} }
static int tsl2563_read_interrupt_config(struct iio_dev *indio_dev, static int tsl2563_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 tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
int ret; int ret;
...@@ -687,10 +702,10 @@ static const struct iio_info tsl2563_info = { ...@@ -687,10 +702,10 @@ static const struct iio_info tsl2563_info = {
.driver_module = THIS_MODULE, .driver_module = THIS_MODULE,
.read_raw = &tsl2563_read_raw, .read_raw = &tsl2563_read_raw,
.write_raw = &tsl2563_write_raw, .write_raw = &tsl2563_write_raw,
.read_event_value = &tsl2563_read_thresh, .read_event_value_new = &tsl2563_read_thresh,
.write_event_value = &tsl2563_write_thresh, .write_event_value_new = &tsl2563_write_thresh,
.read_event_config = &tsl2563_read_interrupt_config, .read_event_config_new = &tsl2563_read_interrupt_config,
.write_event_config = &tsl2563_write_interrupt_config, .write_event_config_new = &tsl2563_write_interrupt_config,
}; };
static int tsl2563_probe(struct i2c_client *client, static int tsl2563_probe(struct i2c_client *client,
......
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