From: Jonathan Cameron <jic23@kernel.org>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 2/6] iio: accel: kxcjk1013: extract report_motion_event() from interrupt handler
Date: Sun, 20 Aug 2017 11:01:42 +0100 [thread overview]
Message-ID: <20170820110142.6ead44ca@archlinux> (raw)
In-Reply-To: <d6bd9449c675651882e4c3b63e107480493a170b.1502979014.git.mirq-linux@rere.qmqm.pl>
On Thu, 17 Aug 2017 16:21:36 +0200
Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> Extract reporting of motion event direction from interrupt handler,
> as it is not supported by KXTF9.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
This uses register naming changes that aren't introduced until patch 3.
I've asked you to drop those anyway so this will get cleaned up when
you do that.
Jonathan
> ---
> drivers/iio/accel/kxcjk-1013.c | 124 +++++++++++++++++++++--------------------
> 1 file changed, 65 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
> index 33e4b98f39fc..80a6508d6370 100644
> --- a/drivers/iio/accel/kxcjk-1013.c
> +++ b/drivers/iio/accel/kxcjk-1013.c
> @@ -1027,6 +1027,70 @@ static const struct iio_trigger_ops kxcjk1013_trigger_ops = {
> .owner = THIS_MODULE,
> };
>
> +static void kxcjk1013_report_motion_event(struct iio_dev *indio_dev)
> +{
> + struct kxcjk1013_data *data = iio_priv(indio_dev);
> +
> + int ret = i2c_smbus_read_byte_data(data->client,
> + KXCJK1013_REG_INT_SRC2);
> + if (ret < 0) {
> + dev_err(&data->client->dev, "Error reading reg_int_src2\n");
> + return;
> + }
> +
> + if (ret & KXREG_MOTION_INT_BIT_XN)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_X,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_FALLING),
> + data->timestamp);
> + if (ret & KXREG_MOTION_INT_BIT_XP)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_X,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_RISING),
> + data->timestamp);
> +
> +
> + if (ret & KXREG_MOTION_INT_BIT_YN)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_Y,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_FALLING),
> + data->timestamp);
> + if (ret & KXREG_MOTION_INT_BIT_YP)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_Y,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_RISING),
> + data->timestamp);
> +
> + if (ret & KXREG_MOTION_INT_BIT_ZN)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_Z,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_FALLING),
> + data->timestamp);
> + if (ret & KXREG_MOTION_INT_BIT_ZP)
> + iio_push_event(indio_dev,
> + IIO_MOD_EVENT_CODE(IIO_ACCEL,
> + 0,
> + IIO_MOD_Z,
> + IIO_EV_TYPE_THRESH,
> + IIO_EV_DIR_RISING),
> + data->timestamp);
> +}
> +
> static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
> {
> struct iio_dev *indio_dev = private;
> @@ -1040,65 +1104,7 @@ static irqreturn_t kxcjk1013_event_handler(int irq, void *private)
> }
>
> if (ret & 0x02) {
> - ret = i2c_smbus_read_byte_data(data->client,
> - KXCJK1013_REG_INT_SRC2);
> - if (ret < 0) {
> - dev_err(&data->client->dev,
> - "Error reading reg_int_src2\n");
> - goto ack_intr;
> - }
> -
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_XN)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_X,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_FALLING),
> - data->timestamp);
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_XP)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_X,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_RISING),
> - data->timestamp);
> -
> -
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_YN)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_Y,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_FALLING),
> - data->timestamp);
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_YP)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_Y,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_RISING),
> - data->timestamp);
> -
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZN)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_Z,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_FALLING),
> - data->timestamp);
> - if (ret & KXCJK1013_REG_INT_SRC2_BIT_ZP)
> - iio_push_event(indio_dev,
> - IIO_MOD_EVENT_CODE(IIO_ACCEL,
> - 0,
> - IIO_MOD_Z,
> - IIO_EV_TYPE_THRESH,
> - IIO_EV_DIR_RISING),
> - data->timestamp);
> + kxcjk1013_report_motion_event(indio_dev);
> }
>
> ack_intr:
next prev parent reply other threads:[~2017-08-20 10:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-17 14:21 [PATCH 0/6] iio: accel: kxcjk1003: support Kionix KXTF9 Michał Mirosław
2017-08-17 14:21 ` [PATCH 1/6] iio: accel: kxcjk1003: refactor ODR setting Michał Mirosław
2017-08-20 10:02 ` Jonathan Cameron
2017-08-17 14:21 ` [PATCH 2/6] iio: accel: kxcjk1013: extract report_motion_event() from interrupt handler Michał Mirosław
2017-08-20 10:01 ` Jonathan Cameron [this message]
2017-08-17 14:21 ` [PATCH 3/6] iio: accel: kxcjk1013: rename registers for KXTF9 compatibility Michał Mirosław
2017-08-20 9:52 ` Jonathan Cameron
2017-08-21 21:45 ` Michał Mirosław
2017-08-22 12:47 ` Jonathan Cameron
2017-08-17 14:21 ` [PATCH 5/6] iio: accel: kxcjk1013: make sampling_frequency_avail per-type Michał Mirosław
2017-08-20 9:57 ` Jonathan Cameron
2017-08-17 14:21 ` [PATCH 4/6] iio: accel: kxcjk1013: make sysfs/sampling_frequency_avail dynamic Michał Mirosław
2017-08-20 9:53 ` Jonathan Cameron
2017-08-17 14:21 ` [PATCH 6/6] iio: accel: kxcjk1013: add support for KXTF9 Michał Mirosław
2017-08-20 10:00 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170820110142.6ead44ca@archlinux \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.