From: Jonathan Cameron <jic23@kernel.org>
To: Vlad Dogaru <vlad.dogaru@intel.com>,
irina.tirdea@intel.com, linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: magn: bmc150: decouple buffer and trigger
Date: Sat, 13 Jun 2015 19:04:52 +0100 [thread overview]
Message-ID: <557C70C4.7090501@kernel.org> (raw)
In-Reply-To: <1434097899-13984-2-git-send-email-vlad.dogaru@intel.com>
On 12/06/15 09:31, Vlad Dogaru wrote:
> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Looks good to me. Will let it sit for a while to give Irina and others
time to comment though. We are looking at the next cycle now anyway so
no rush!
Jonathan
> ---
> drivers/iio/magnetometer/bmc150_magn.c | 69 +++++++++++++++++++---------------
> 1 file changed, 38 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
> index d4c1788..a0e64f1 100644
> --- a/drivers/iio/magnetometer/bmc150_magn.c
> +++ b/drivers/iio/magnetometer/bmc150_magn.c
> @@ -588,17 +588,6 @@ static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
> }
> }
>
> -static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev,
> - struct iio_trigger *trig)
> -{
> - struct bmc150_magn_data *data = iio_priv(indio_dev);
> -
> - if (data->dready_trig != trig)
> - return -EINVAL;
> -
> - return 0;
> -}
> -
> static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> @@ -659,7 +648,6 @@ static const struct iio_info bmc150_magn_info = {
> .attrs = &bmc150_magn_attrs_group,
> .read_raw = bmc150_magn_read_raw,
> .write_raw = bmc150_magn_write_raw,
> - .validate_trigger = bmc150_magn_validate_trigger,
> .driver_module = THIS_MODULE,
> };
>
> @@ -682,7 +670,7 @@ static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
> pf->timestamp);
>
> err:
> - iio_trigger_notify_done(data->dready_trig);
> + iio_trigger_notify_done(indio_dev->trig);
>
> return IRQ_HANDLED;
> }
> @@ -827,6 +815,27 @@ static const struct iio_trigger_ops bmc150_magn_trigger_ops = {
> .owner = THIS_MODULE,
> };
>
> +static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev)
> +{
> + struct bmc150_magn_data *data = iio_priv(indio_dev);
> +
> + return bmc150_magn_set_power_state(data, true);
> +}
> +
> +static int bmc150_magn_buffer_postdisable(struct iio_dev *indio_dev)
> +{
> + struct bmc150_magn_data *data = iio_priv(indio_dev);
> +
> + return bmc150_magn_set_power_state(data, false);
> +}
> +
> +static const struct iio_buffer_setup_ops bmc150_magn_buffer_setup_ops = {
> + .preenable = bmc150_magn_buffer_preenable,
> + .postenable = iio_triggered_buffer_postenable,
> + .predisable = iio_triggered_buffer_predisable,
> + .postdisable = bmc150_magn_buffer_postdisable,
> +};
> +
> static int bmc150_magn_gpio_probe(struct i2c_client *client)
> {
> struct device *dev;
> @@ -932,16 +941,6 @@ static int bmc150_magn_probe(struct i2c_client *client,
> goto err_poweroff;
> }
>
> - ret = iio_triggered_buffer_setup(indio_dev,
> - &iio_pollfunc_store_time,
> - bmc150_magn_trigger_handler,
> - NULL);
> - if (ret < 0) {
> - dev_err(&client->dev,
> - "iio triggered buffer setup failed\n");
> - goto err_trigger_unregister;
> - }
> -
> ret = request_threaded_irq(client->irq,
> iio_trigger_generic_data_rdy_poll,
> NULL,
> @@ -951,14 +950,24 @@ static int bmc150_magn_probe(struct i2c_client *client,
> if (ret < 0) {
> dev_err(&client->dev, "request irq %d failed\n",
> client->irq);
> - goto err_buffer_cleanup;
> + goto err_trigger_unregister;
> }
> }
>
> + ret = iio_triggered_buffer_setup(indio_dev,
> + iio_pollfunc_store_time,
> + bmc150_magn_trigger_handler,
> + &bmc150_magn_buffer_setup_ops);
> + if (ret < 0) {
> + dev_err(&client->dev,
> + "iio triggered buffer setup failed\n");
> + goto err_free_irq;
> + }
> +
> ret = iio_device_register(indio_dev);
> if (ret < 0) {
> dev_err(&client->dev, "unable to register iio device\n");
> - goto err_free_irq;
> + goto err_buffer_cleanup;
> }
>
> ret = pm_runtime_set_active(&client->dev);
> @@ -976,12 +985,11 @@ static int bmc150_magn_probe(struct i2c_client *client,
>
> err_iio_unregister:
> iio_device_unregister(indio_dev);
> +err_buffer_cleanup:
> + iio_triggered_buffer_cleanup(indio_dev);
> err_free_irq:
> if (client->irq > 0)
> free_irq(client->irq, data->dready_trig);
> -err_buffer_cleanup:
> - if (data->dready_trig)
> - iio_triggered_buffer_cleanup(indio_dev);
> err_trigger_unregister:
> if (data->dready_trig)
> iio_trigger_unregister(data->dready_trig);
> @@ -1000,14 +1008,13 @@ static int bmc150_magn_remove(struct i2c_client *client)
> pm_runtime_put_noidle(&client->dev);
>
> iio_device_unregister(indio_dev);
> + iio_triggered_buffer_cleanup(indio_dev);
>
> if (client->irq > 0)
> free_irq(data->client->irq, data->dready_trig);
>
> - if (data->dready_trig) {
> - iio_triggered_buffer_cleanup(indio_dev);
> + if (data->dready_trig)
> iio_trigger_unregister(data->dready_trig);
> - }
>
> mutex_lock(&data->mutex);
> bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
>
next prev parent reply other threads:[~2015-06-13 18:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 8:31 [PATCH 0/2] iio: bmc150: buffer cleanup and support for a new chip Vlad Dogaru
2015-06-12 8:31 ` [PATCH 1/2] iio: magn: bmc150: decouple buffer and trigger Vlad Dogaru
2015-06-13 18:04 ` Jonathan Cameron [this message]
2015-06-23 14:18 ` Tirdea, Irina
2015-06-21 13:57 ` Jonathan Cameron
2015-06-12 8:31 ` [PATCH 2/2] iio: magn: bmc150: add support for bmc156 Vlad Dogaru
2015-06-21 13:57 ` 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=557C70C4.7090501@kernel.org \
--to=jic23@kernel.org \
--cc=irina.tirdea@intel.com \
--cc=linux-iio@vger.kernel.org \
--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