Commit d8408e98 authored by Michał Mirosław's avatar Michał Mirosław Committed by Jonathan Cameron

iio: accel: kxcjk1013: extract report_motion_event() from interrupt handler

Extract reporting of motion event direction from interrupt handler,
as it is not supported by KXTF9.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent f74e440c
...@@ -1030,25 +1030,15 @@ static const struct iio_trigger_ops kxcjk1013_trigger_ops = { ...@@ -1030,25 +1030,15 @@ static const struct iio_trigger_ops kxcjk1013_trigger_ops = {
.try_reenable = kxcjk1013_trig_try_reen, .try_reenable = kxcjk1013_trig_try_reen,
}; };
static irqreturn_t kxcjk1013_event_handler(int irq, void *private) static void kxcjk1013_report_motion_event(struct iio_dev *indio_dev)
{ {
struct iio_dev *indio_dev = private;
struct kxcjk1013_data *data = iio_priv(indio_dev); struct kxcjk1013_data *data = iio_priv(indio_dev);
int ret;
ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_SRC1);
if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_int_src1\n");
goto ack_intr;
}
if (ret & KXCJK1013_REG_INT_SRC1_BIT_WUFS) { int ret = i2c_smbus_read_byte_data(data->client,
ret = i2c_smbus_read_byte_data(data->client,
KXCJK1013_REG_INT_SRC2); KXCJK1013_REG_INT_SRC2);
if (ret < 0) { if (ret < 0) {
dev_err(&data->client->dev, dev_err(&data->client->dev, "Error reading reg_int_src2\n");
"Error reading reg_int_src2\n"); return;
goto ack_intr;
} }
if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN) if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN)
...@@ -1059,6 +1049,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private) ...@@ -1059,6 +1049,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING), IIO_EV_DIR_FALLING),
data->timestamp); data->timestamp);
if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP) if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP)
iio_push_event(indio_dev, iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL, IIO_MOD_EVENT_CODE(IIO_ACCEL,
...@@ -1068,7 +1059,6 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private) ...@@ -1068,7 +1059,6 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
IIO_EV_DIR_RISING), IIO_EV_DIR_RISING),
data->timestamp); data->timestamp);
if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN) if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN)
iio_push_event(indio_dev, iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL, IIO_MOD_EVENT_CODE(IIO_ACCEL,
...@@ -1077,6 +1067,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private) ...@@ -1077,6 +1067,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING), IIO_EV_DIR_FALLING),
data->timestamp); data->timestamp);
if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP) if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP)
iio_push_event(indio_dev, iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL, IIO_MOD_EVENT_CODE(IIO_ACCEL,
...@@ -1094,6 +1085,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private) ...@@ -1094,6 +1085,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING), IIO_EV_DIR_FALLING),
data->timestamp); data->timestamp);
if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP) if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP)
iio_push_event(indio_dev, iio_push_event(indio_dev,
IIO_MOD_EVENT_CODE(IIO_ACCEL, IIO_MOD_EVENT_CODE(IIO_ACCEL,
...@@ -1102,6 +1094,22 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private) ...@@ -1102,6 +1094,22 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING), IIO_EV_DIR_RISING),
data->timestamp); data->timestamp);
}
static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
{
struct iio_dev *indio_dev = private;
struct kxcjk1013_data *data = iio_priv(indio_dev);
int ret;
ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_SRC1);
if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_int_src1\n");
goto ack_intr;
}
if (ret & KXCJK1013_REG_INT_SRC1_BIT_WUFS) {
kxcjk1013_report_motion_event(indio_dev);
} }
ack_intr: ack_intr:
......
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