From: Jonathan Cameron <jic23@kernel.org>
To: Vlad Dogaru <vlad.dogaru@intel.com>,
srinivas.pandruvada@linux.intel.com, irina.tirdea@intel.com,
octavian.purdila@intel.com, linux-iio@vger.kernel.org
Cc: adriana.reus@intel.com
Subject: Re: [PATCH 2/2] iio: gyro: bmg160: decouple buffer and triggers
Date: Sun, 17 May 2015 10:27:55 +0100 [thread overview]
Message-ID: <55585F1B.3060601@kernel.org> (raw)
In-Reply-To: <1431523809-13824-3-git-send-email-vlad.dogaru@intel.com>
On 13/05/15 14:30, Vlad Dogaru wrote:
> Make it possible to use buffering with an external trigger, such as one
> based on sysfs or hrtimer.
>
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Thanks,
Glad to see these sort of restrictions being relaxed.
Jonathan
> ---
> drivers/iio/gyro/bmg160.c | 56 +++++++++++++++++++++++++++--------------------
> 1 file changed, 32 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
> index d36af62..460bf71 100644
> --- a/drivers/iio/gyro/bmg160.c
> +++ b/drivers/iio/gyro/bmg160.c
> @@ -737,17 +737,6 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
> return 0;
> }
>
> -static int bmg160_validate_trigger(struct iio_dev *indio_dev,
> - struct iio_trigger *trig)
> -{
> - struct bmg160_data *data = iio_priv(indio_dev);
> -
> - if (data->dready_trig != trig && data->motion_trig != trig)
> - return -EINVAL;
> -
> - return 0;
> -}
> -
> static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 400 1000 2000");
>
> static IIO_CONST_ATTR(in_anglvel_scale_available,
> @@ -809,7 +798,6 @@ static const struct iio_info bmg160_info = {
> .write_event_value = bmg160_write_event,
> .write_event_config = bmg160_write_event_config,
> .read_event_config = bmg160_read_event_config,
> - .validate_trigger = bmg160_validate_trigger,
> .driver_module = THIS_MODULE,
> };
>
> @@ -984,6 +972,27 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private)
>
> }
>
> +static int bmg160_buffer_preenable(struct iio_dev *indio_dev)
> +{
> + struct bmg160_data *data = iio_priv(indio_dev);
> +
> + return bmg160_set_power_state(data, true);
> +}
> +
> +static int bmg160_buffer_postdisable(struct iio_dev *indio_dev)
> +{
> + struct bmg160_data *data = iio_priv(indio_dev);
> +
> + return bmg160_set_power_state(data, false);
> +}
> +
> +static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
> + .preenable = bmg160_buffer_preenable,
> + .postenable = iio_triggered_buffer_postenable,
> + .predisable = iio_triggered_buffer_predisable,
> + .postdisable = bmg160_buffer_postdisable,
> +};
> +
> static int bmg160_gpio_probe(struct i2c_client *client,
> struct bmg160_data *data)
>
> @@ -1100,16 +1109,16 @@ static int bmg160_probe(struct i2c_client *client,
> data->motion_trig = NULL;
> goto err_trigger_unregister;
> }
> + }
>
> - ret = iio_triggered_buffer_setup(indio_dev,
> - iio_pollfunc_store_time,
> - bmg160_trigger_handler,
> - NULL);
> - if (ret < 0) {
> - dev_err(&client->dev,
> - "iio triggered buffer setup failed\n");
> - goto err_trigger_unregister;
> - }
> + ret = iio_triggered_buffer_setup(indio_dev,
> + iio_pollfunc_store_time,
> + bmg160_trigger_handler,
> + &bmg160_buffer_setup_ops);
> + if (ret < 0) {
> + dev_err(&client->dev,
> + "iio triggered buffer setup failed\n");
> + goto err_trigger_unregister;
> }
>
> ret = iio_device_register(indio_dev);
> @@ -1132,8 +1141,7 @@ static int bmg160_probe(struct i2c_client *client,
> err_iio_unregister:
> iio_device_unregister(indio_dev);
> err_buffer_cleanup:
> - if (data->dready_trig)
> - iio_triggered_buffer_cleanup(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
> err_trigger_unregister:
> if (data->dready_trig)
> iio_trigger_unregister(data->dready_trig);
> @@ -1153,9 +1161,9 @@ static int bmg160_remove(struct i2c_client *client)
> pm_runtime_put_noidle(&client->dev);
>
> iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
>
> if (data->dready_trig) {
> - iio_triggered_buffer_cleanup(indio_dev);
> iio_trigger_unregister(data->dready_trig);
> iio_trigger_unregister(data->motion_trig);
> }
>
prev parent reply other threads:[~2015-05-17 9:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 13:30 [PATCH 0/2] iio: gyro: bmg160: decouple buffer from triggers Vlad Dogaru
2015-05-13 13:30 ` [PATCH 1/2] iio: gyro: bmg160: remove redundant field Vlad Dogaru
2015-05-17 9:25 ` Jonathan Cameron
2015-05-13 13:30 ` [PATCH 2/2] iio: gyro: bmg160: decouple buffer and triggers Vlad Dogaru
2015-05-17 9:27 ` Jonathan Cameron [this message]
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=55585F1B.3060601@kernel.org \
--to=jic23@kernel.org \
--cc=adriana.reus@intel.com \
--cc=irina.tirdea@intel.com \
--cc=linux-iio@vger.kernel.org \
--cc=octavian.purdila@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=vlad.dogaru@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).