From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 07/18] staging:iio:lis3l02dq: Switch to new event config interface
Date: Mon, 30 Sep 2013 21:55:55 +0100 [thread overview]
Message-ID: <5249E55B.8040205@kernel.org> (raw)
In-Reply-To: <1380200317-19355-7-git-send-email-lars@metafoo.de>
On 09/26/13 13:58, Lars-Peter Clausen wrote:
> Switch the lis3l02dq 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>
Hi Lars,
As this one is in staging, lets take advantage of the fact that we now
have the ability to have shared elements. It's an ABI change so I wouldn't
suggest this for drivers outside staging.
The threshold value is shared by all channels (only one address to write) for each
of the two types.
> ---
> drivers/staging/iio/accel/lis3l02dq_core.c | 53 ++++++++++++++++++++----------
> 1 file changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
> index bb852dc..5cd9c45 100644
> --- a/drivers/staging/iio/accel/lis3l02dq_core.c
> +++ b/drivers/staging/iio/accel/lis3l02dq_core.c
> @@ -190,14 +190,20 @@ static u8 lis3l02dq_axis_map[3][3] = {
> };
>
> static int lis3l02dq_read_thresh(struct iio_dev *indio_dev,
> - u64 e,
> + const struct iio_chan_spec *chan,
> + enum iio_event_type type,
> + enum iio_event_direction dir,
> + enum iio_event_info info,
> int *val)
> {
> return lis3l02dq_read_reg_s16(indio_dev, LIS3L02DQ_REG_THS_L_ADDR, val);
> }
>
> static int lis3l02dq_write_thresh(struct iio_dev *indio_dev,
> - u64 event_code,
> + const struct iio_chan_spec *chan,
> + enum iio_event_type type,
> + enum iio_event_direction dir,
> + enum iio_event_info info,
> int val)
> {
> u16 value = val;
> @@ -503,9 +509,19 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
> return IRQ_HANDLED;
> }
>
> -#define LIS3L02DQ_EVENT_MASK \
> - (IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING) | \
> - IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_FALLING))
> +static const struct iio_event_spec lis3l02dq_event[] = {
> + {
> + .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),
> + }
> +};
>
> #define LIS3L02DQ_CHAN(index, mod) \
> { \
> @@ -523,7 +539,8 @@ static irqreturn_t lis3l02dq_event_handler(int irq, void *private)
> .realbits = 12, \
> .storagebits = 16, \
> }, \
> - .event_mask = LIS3L02DQ_EVENT_MASK, \
> + .event_spec = lis3l02dq_event, \
> + .num_event_specs = ARRAY_SIZE(lis3l02dq_event), \
> }
>
> static const struct iio_chan_spec lis3l02dq_channels[] = {
> @@ -535,14 +552,14 @@ static const struct iio_chan_spec lis3l02dq_channels[] = {
>
>
> static int lis3l02dq_read_event_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)
> {
>
> u8 val;
> int ret;
> - u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 +
> - (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
> - IIO_EV_DIR_RISING)));
> + u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING)));
> ret = lis3l02dq_spi_read_reg_8(indio_dev,
> LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
> &val);
> @@ -587,16 +604,16 @@ error_ret:
> }
>
> static int lis3l02dq_write_event_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 state)
> {
> int ret = 0;
> u8 val, control;
> u8 currentlyset;
> bool changed = false;
> - u8 mask = (1 << (IIO_EVENT_CODE_EXTRACT_MODIFIER(event_code)*2 +
> - (IIO_EVENT_CODE_EXTRACT_DIR(event_code) ==
> - IIO_EV_DIR_RISING)));
> + u8 mask = (1 << (chan->channel2*2 + (dir == IIO_EV_DIR_RISING)));
>
> mutex_lock(&indio_dev->mlock);
> /* read current control */
> @@ -654,10 +671,10 @@ static const struct attribute_group lis3l02dq_attribute_group = {
> static const struct iio_info lis3l02dq_info = {
> .read_raw = &lis3l02dq_read_raw,
> .write_raw = &lis3l02dq_write_raw,
> - .read_event_value = &lis3l02dq_read_thresh,
> - .write_event_value = &lis3l02dq_write_thresh,
> - .write_event_config = &lis3l02dq_write_event_config,
> - .read_event_config = &lis3l02dq_read_event_config,
> + .read_event_value_new = &lis3l02dq_read_thresh,
> + .write_event_value_new = &lis3l02dq_write_thresh,
> + .write_event_config_new = &lis3l02dq_write_event_config,
> + .read_event_config_new = &lis3l02dq_read_event_config,
> .driver_module = THIS_MODULE,
> .attrs = &lis3l02dq_attribute_group,
> };
>
next prev parent reply other threads:[~2013-09-30 19:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-26 12:58 [PATCH 01/18] iio: Extend the event config interface Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 02/18] iio:max1363: Switch to new " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 03/18] iio:ad5421: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 04/18] iio:gp2ap020a00f: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 05/18] iio:tsl2563: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 06/18] iio:apds9300: Use " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 07/18] staging:iio:lis3l02dq: Switch to " Lars-Peter Clausen
2013-09-30 20:55 ` Jonathan Cameron [this message]
2013-10-01 7:51 ` Lars-Peter Clausen
2013-10-01 9:14 ` Jonathan Cameron
2013-09-26 12:58 ` [PATCH 08/18] staging:iio:sca3000: Switch to new " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 09/18] staging:iio:ad7291: Switch to new event " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 10/18] staging:iio:ad799x: " Lars-Peter Clausen
2013-09-30 20:59 ` Jonathan Cameron
2013-09-26 12:58 ` [PATCH 11/18] staging:iio:ad7150: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 12/18] staging:iio:simple_dummy: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 13/18] staging:iio:tsl2x7x: " Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 14/18] iio: Remove support for the legacy " Lars-Peter Clausen
2013-09-30 21:05 ` Jonathan Cameron
2013-10-01 7:52 ` Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 15/18] iio: Add a hysteresis event info attribute Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 16/18] staging:iio:ad799x: Simplify threshold register look-up Lars-Peter Clausen
2013-09-26 12:58 ` [PATCH 17/18] staging:iio:ad799x: Use event spec for threshold hysteresis Lars-Peter Clausen
2013-09-30 21:10 ` Jonathan Cameron
2013-09-26 12:58 ` [PATCH 18/18] staging:iio:ad7291: " Lars-Peter Clausen
2013-09-29 18:44 ` [PATCH 01/18] iio: Extend the event config interface Jonathan Cameron
2013-09-29 18:56 ` Lars-Peter Clausen
2013-09-29 20:17 ` Jonathan Cameron
2013-09-29 19:35 ` Lars-Peter Clausen
2013-09-30 20:54 ` Jonathan Cameron
2013-10-04 8:38 ` Lars-Peter Clausen
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=5249E55B.8040205@kernel.org \
--to=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
/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.