linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Matt Ranostay <mranostay@gmail.com>,
	marex@denx.de, matt@ohporter.com, pantelis.antoniou@gmail.com,
	jic23@kernel.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR
Date: Sun, 02 Aug 2015 11:45:01 +0200	[thread overview]
Message-ID: <55BDE69D.3010708@metafoo.de> (raw)
In-Reply-To: <1438401484-22101-3-git-send-email-mranostay@gmail.com>

On 08/01/2015 05:58 AM, Matt Ranostay wrote:
> +static int lidar_read_raw(struct iio_dev *indio_dev,
> +			  struct iio_chan_spec const *chan,
> +			  int *val, int *val2, long mask)
> +{
> +	struct lidar_data *data = iio_priv(indio_dev);
> +	int ret = -EINVAL;
> +
> +	if (iio_buffer_enabled(indio_dev) && mask == IIO_CHAN_INFO_RAW)
> +		return -EBUSY;

For this to work without race conditions you need to hold the
indio_dev->mlock while doing the check and until the conversion is done.

> +
> +	mutex_lock(&data->lock);
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW: {
> +		u16 reg;
> +
> +		ret = lidar_get_measurement(data, &reg);
> +		if (!ret) {
> +			*val = reg / 100;
> +			*val2 = (reg % 100) * 10000;
> +			ret = IIO_VAL_INT_PLUS_MICRO;
> +		}
> +		break;
> +	}


  parent reply	other threads:[~2015-08-02  9:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-01  3:58 [PATCH 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-01  3:58 ` [PATCH 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
2015-08-01  3:58 ` [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-01  8:39   ` Vladimir Barinov
2015-08-01 21:17     ` Jonathan Cameron
2015-08-01 22:22       ` Matt Ranostay
2015-08-02  7:36         ` Vladimir Barinov
2015-08-02 18:18         ` Jonathan Cameron
2015-08-02  9:42   ` Lars-Peter Clausen
2015-08-02 18:23     ` Jonathan Cameron
2015-08-02 18:39       ` Lars-Peter Clausen
2015-08-02 19:52         ` Jonathan Cameron
2015-08-02 21:28     ` Matt Ranostay
2015-08-03  8:00       ` Lars-Peter Clausen
2015-08-03  8:19         ` Matt Ranostay
2015-08-02  9:45   ` Lars-Peter Clausen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-08-12  6:01 [PATCH v5 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-12  6:01 ` [PATCH 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-16  8:24   ` Jonathan Cameron
2015-08-18  2:33     ` Matt Ranostay

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=55BDE69D.3010708@metafoo.de \
    --to=lars@metafoo.de \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=matt@ohporter.com \
    --cc=mranostay@gmail.com \
    --cc=pantelis.antoniou@gmail.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).