linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>,
	"Purdila, Octavian" <octavian.purdila@intel.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"Dogaru, Vlad" <vlad.dogaru@intel.com>
Subject: Re: [PATCH] iio: accel: bmc150: decouple buffer and triggers
Date: Sun, 17 May 2015 10:58:17 +0100	[thread overview]
Message-ID: <55586639.20409@kernel.org> (raw)
In-Reply-To: <1431463799.11262.40.camel@spandruv-DESK3.jf.intel.com>

On 12/05/15 21:51, Pandruvada, Srinivas wrote:
> On Tue, 2015-05-12 at 19:17 +0300, Octavian Purdila wrote:
>> On Tue, May 12, 2015 at 5:03 PM, Vlad Dogaru <vlad.dogaru@intel.com> wrote:
>>>
>>> If the interrupt pins are not available, we should still be able to use
>>> the buffer with an external trigger.  However, we won't be able to use
>>> the hardware fifo since we have no means of signalling when the
>>> watermark is reached.
>>>
>>> I also added a comment to indicate that the timestamps in
>>> bmc150_accel_data are only used for hardware fifo, since initially I was
>>> confused about duplication with pf->timestamp.
>>>
>>> Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
>>
>> Srinivas can you also please take a look?
>>
>> The timestamp now has a slight delay (we take in the poll irq handler
>> instead of the irq handler) but I think that is negligible, so:
> This should be fine.
Should be very small as it's a very short chain of function calls later.
Applied to the togreg branch of iio.git.

Thanks,

Jonathan
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
>>
>> Reviewed-by: Octavian Purdila <octavian.purdila@intel.com>
>>
>>> ---
>>>  drivers/iio/accel/bmc150-accel.c | 55 +++++++++++++++++++++++++---------------
>>>  1 file changed, 35 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
>>> index 73e8773..4e70f51 100644
>>> --- a/drivers/iio/accel/bmc150-accel.c
>>> +++ b/drivers/iio/accel/bmc150-accel.c
>>> @@ -196,7 +196,7 @@ struct bmc150_accel_data {
>>>         u32 slope_thres;
>>>         u32 range;
>>>         int ev_enable_state;
>>> -       int64_t timestamp, old_timestamp;
>>> +       int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
>>>         const struct bmc150_accel_chip_info *chip_info;
>>>  };
>>>
>>> @@ -1183,7 +1183,6 @@ static const struct iio_info bmc150_accel_info = {
>>>         .write_event_value      = bmc150_accel_write_event,
>>>         .write_event_config     = bmc150_accel_write_event_config,
>>>         .read_event_config      = bmc150_accel_read_event_config,
>>> -       .validate_trigger       = bmc150_accel_validate_trigger,
>>>         .driver_module          = THIS_MODULE,
>>>  };
>>>
>>> @@ -1222,7 +1221,7 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
>>>         mutex_unlock(&data->mutex);
>>>
>>>         iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
>>> -                                          data->timestamp);
>>> +                                          pf->timestamp);
>>>  err_read:
>>>         iio_trigger_notify_done(indio_dev->trig);
>>>
>>> @@ -1535,6 +1534,13 @@ static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data)
>>>         return ret;
>>>  }
>>>
>>> +static int bmc150_accel_buffer_preenable(struct iio_dev *indio_dev)
>>> +{
>>> +       struct bmc150_accel_data *data = iio_priv(indio_dev);
>>> +
>>> +       return bmc150_accel_set_power_state(data, true);
>>> +}
>>> +
>>>  static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev)
>>>  {
>>>         struct bmc150_accel_data *data = iio_priv(indio_dev);
>>> @@ -1591,9 +1597,18 @@ out:
>>>         return 0;
>>>  }
>>>
>>> +static int bmc150_accel_buffer_postdisable(struct iio_dev *indio_dev)
>>> +{
>>> +       struct bmc150_accel_data *data = iio_priv(indio_dev);
>>> +
>>> +       return bmc150_accel_set_power_state(data, false);
>>> +}
>>> +
>>>  static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = {
>>> +       .preenable = bmc150_accel_buffer_preenable,
>>>         .postenable = bmc150_accel_buffer_postenable,
>>>         .predisable = bmc150_accel_buffer_predisable,
>>> +       .postdisable = bmc150_accel_buffer_postdisable,
>>>  };
>>>
>>>  static int bmc150_accel_probe(struct i2c_client *client,
>>> @@ -1636,6 +1651,15 @@ static int bmc150_accel_probe(struct i2c_client *client,
>>>         indio_dev->modes = INDIO_DIRECT_MODE;
>>>         indio_dev->info = &bmc150_accel_info;
>>>
>>> +       ret = iio_triggered_buffer_setup(indio_dev,
>>> +                                        &iio_pollfunc_store_time,
>>> +                                        bmc150_accel_trigger_handler,
>>> +                                        &bmc150_accel_buffer_ops);
>>> +       if (ret < 0) {
>>> +               dev_err(&client->dev, "Failed: iio triggered buffer setup\n");
>>> +               return ret;
>>> +       }
>>> +
>>>         if (client->irq < 0)
>>>                 client->irq = bmc150_accel_gpio_probe(client, data);
>>>
>>> @@ -1648,7 +1672,7 @@ static int bmc150_accel_probe(struct i2c_client *client,
>>>                                                 BMC150_ACCEL_IRQ_NAME,
>>>                                                 indio_dev);
>>>                 if (ret)
>>> -                       return ret;
>>> +                       goto err_buffer_cleanup;
>>>
>>>                 /*
>>>                  * Set latched mode interrupt. While certain interrupts are
>>> @@ -1661,24 +1685,14 @@ static int bmc150_accel_probe(struct i2c_client *client,
>>>                                              BMC150_ACCEL_INT_MODE_LATCH_RESET);
>>>                 if (ret < 0) {
>>>                         dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n");
>>> -                       return ret;
>>> +                       goto err_buffer_cleanup;
>>>                 }
>>>
>>>                 bmc150_accel_interrupts_setup(indio_dev, data);
>>>
>>>                 ret = bmc150_accel_triggers_setup(indio_dev, data);
>>>                 if (ret)
>>> -                       return ret;
>>> -
>>> -               ret = iio_triggered_buffer_setup(indio_dev,
>>> -                                                &iio_pollfunc_store_time,
>>> -                                                bmc150_accel_trigger_handler,
>>> -                                                &bmc150_accel_buffer_ops);
>>> -               if (ret < 0) {
>>> -                       dev_err(&client->dev,
>>> -                               "Failed: iio triggered buffer setup\n");
>>> -                       goto err_trigger_unregister;
>>> -               }
>>> +                       goto err_buffer_cleanup;
>>>
>>>                 if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) ||
>>>                     i2c_check_functionality(client->adapter,
>>> @@ -1692,7 +1706,7 @@ static int bmc150_accel_probe(struct i2c_client *client,
>>>         ret = iio_device_register(indio_dev);
>>>         if (ret < 0) {
>>>                 dev_err(&client->dev, "Unable to register iio device\n");
>>> -               goto err_buffer_cleanup;
>>> +               goto err_trigger_unregister;
>>>         }
>>>
>>>         ret = pm_runtime_set_active(&client->dev);
>>> @@ -1708,11 +1722,10 @@ static int bmc150_accel_probe(struct i2c_client *client,
>>>
>>>  err_iio_unregister:
>>>         iio_device_unregister(indio_dev);
>>> -err_buffer_cleanup:
>>> -       if (indio_dev->pollfunc)
>>> -               iio_triggered_buffer_cleanup(indio_dev);
>>>  err_trigger_unregister:
>>>         bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
>>> +err_buffer_cleanup:
>>> +       iio_triggered_buffer_cleanup(indio_dev);
>>>
>>>         return ret;
>>>  }
>>> @@ -1730,6 +1743,8 @@ static int bmc150_accel_remove(struct i2c_client *client)
>>>
>>>         bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
>>>
>>> +       iio_triggered_buffer_cleanup(indio_dev);
>>> +
>>>         mutex_lock(&data->mutex);
>>>         bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0);
>>>         mutex_unlock(&data->mutex);
>>> --
>>> 1.9.1
>>>
> 
> N�����r��y���b�X��ǧv�^�)޺{.n�+����{��*"��^n�r���z�\x1a��h����&��\x1e�G���h�\x03(�階�ݢj"��\x1a�^[m�����z�ޖ���f���h���~�mml==
> 


      reply	other threads:[~2015-05-17  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:03 [PATCH] iio: accel: bmc150: decouple buffer and triggers Vlad Dogaru
2015-05-12 16:17 ` Octavian Purdila
2015-05-12 20:51   ` Pandruvada, Srinivas
2015-05-17  9:58     ` 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=55586639.20409@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=srinivas.pandruvada@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).