All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tristan Lelong <tristan@lelong.xyz>
To: Matt Ranostay <mranostay@gmail.com>
Cc: "Peter Meerwald" <pmeerw@pmeerw.net>,
	"Marek Vašut" <marex@denx.de>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Vladimir Barinov" <vladimir.barinov@cogentembedded.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR
Date: Wed, 5 Aug 2015 00:13:52 -0700	[thread overview]
Message-ID: <20150805071352.GA1662@lenderer> (raw)
In-Reply-To: <CAKzfze8uxGRv=GuTLYCDbZqw4yzF=V1935jfeM8M96sN7T-Oww@mail.gmail.com>

On Tue, Aug 04, 2015 at 06:45:22PM -0700, Matt Ranostay wrote:
> On Tue, Aug 4, 2015 at 1:35 PM, Tristan Lelong <tristan@lelong.xyz> wrote:
> > On Mon, Aug 03, 2015 at 01:21:08AM -0700, Matt Ranostay wrote:
> >> On Sun, Aug 2, 2015 at 11:48 PM, Peter Meerwald <pmeerw@pmeerw.net> wrote:
> >> > On Sun, 2 Aug 2015, Matt Ranostay wrote:
> >> >
> >> >> +
> >> >> +static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
> >> >> +{
> >> >> +     struct i2c_client *client = data->client;
> >> >> +     int tries = 10;
> >> >> +     int ret;
> >> >> +
> >> >> +     /* start sample */
> >> >> +     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
> >> >> +     if (ret < 0) {
> >> >> +             dev_err(&client->dev, "cannot send start measurement command");
> >> >> +             return ret;
> >> >> +     }
> >> >> +
> >> >> +     while (tries--) {
> >> >> +             usleep_range(1000, 2000);
> >> >> +
> >> >> +             ret = lidar_read_byte(data, LIDAR_REG_STATUS);
> >> >> +             if (ret < 0)
> >> >> +                     break;
> >> >> +
> >> >> +             /* return 0 since laser is likely pointed out of range */
> >> >> +             if (ret & LIDAR_REG_STATUS_INVALID) {
> >> >> +                     *reg = 0;
> >> >> +                     ret = 0;
> >> >> +                     break;
> >> >> +             }
> >> >> +
> >> >> +             /* sample ready to read */
> >> >> +             if (!(ret & LIDAR_REG_STATUS_READY)) {
> >> >> +                     ret = lidar_read_measurement(data, reg);
> >> >> +                     break;
> >> >> +             }
> >> >> +     }
> >> >> +
> >> >
> >> > what happens when the timeout occurs?
> >> > no error code is set
> >>
> >> Ah yes it should return an error code.  Would a -EIO be a logical choice?
> >>
> >
> > I would think -ETIMEDOUT to make more sense here.
> 
> Isn't that more applicable for a networking driver to use?

IMHO this error code is generic and should be used when a certain operation doesn't provide any result after a determined period of time. 
In your case, no measurement is available after 10 to 20 msec.

It is used in other iio drivers on similar use cases,
Although it often comes after wait_for_completion_timeout, the scenario is pretty similar:
- start measurement
- wait for measure to be ready

Regards

      reply	other threads:[~2015-08-05  7:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03  4:27 [PATCH v2 0/2] iio: proximity: add PulsedLight LIDAR sensor support Matt Ranostay
2015-08-03  4:27 ` Matt Ranostay
2015-08-03  4:27 ` [PATCH v2 1/2] devicetree: add PulsedLight vendor prefix Matt Ranostay
2015-08-03  4:27   ` Matt Ranostay
2015-08-03  4:27 ` [PATCH v2 2/2] iio: proximity: add support for PulsedLight LIDAR Matt Ranostay
2015-08-03  4:27   ` Matt Ranostay
2015-08-03  6:48   ` Peter Meerwald
2015-08-03  8:21     ` Matt Ranostay
2015-08-04 20:35       ` Tristan Lelong
2015-08-05  1:45         ` Matt Ranostay
2015-08-05  7:13           ` Tristan Lelong [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=20150805071352.GA1662@lenderer \
    --to=tristan@lelong.xyz \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=mranostay@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=vladimir.barinov@cogentembedded.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 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.