linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: "Michele De Candia (VT)"
	<michele.decandia-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
Cc: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	giometti-k2GhghHVRtY@public.gmane.org
Subject: Re: [PATCH] TSL2550 driver bugfix
Date: Sun, 12 Jul 2009 10:52:37 +0200	[thread overview]
Message-ID: <20090712105237.01e11954@hyperion.delvare> (raw)
In-Reply-To: <20090711202030.52ffbddb-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>

On Sat, 11 Jul 2009 20:20:30 +0200, Jean Delvare wrote:
> For another, I do hit the case c1 > c0 from times to times, in
> particular when I move the sensor in dark areas. Do you hit this as
> well? This might be specific to the serial evaluation module I'm using,
> it is very slow and this might cause c0 and c1 to be sampled at
> significantly different times (say 200 ms apart.) If the light
> conditions change meanwhile, this can explain why c1 > c0.

Scratch this theory. Reading the TSL2550 datasheet again, I understand
that sampling happens continuously and is unrelated to I2C reads.
Sampling of each channel takes 400 ms in standard mode, so c0 and c1
samplings are _always_ 400 ms apart, regardless of how fast the I2C
interface is. So you should be able do see the problem too.

This also means that the code in tsl2550_get_adc_value() is more
complex than it needs to be. The only case where it makes sense to wait
400 ms to get a reading is right after power-up. 400 ms after power-up,
c0 will always have a valid value, and after 800 ms c1 will always have
a valid value as well. So I propose to simplify tsl2550_get_adc_value()
and just return -EAGAIN if there is no valid reading. In practice I
doubt we'll ever hit it.

> I am not
> sure what to do in this case. We can return -EAGAIN and let user-space
> retry. But we could also restart the computation automatically in this
> case. Of course if the problem only affects the evaluation module then
> we don't really care.

Thinking some more about this: if we want to retry then we will have to
wait at least 400 ms to read c0 again, and if it's not enough 400 more
ms to read c1 again. And even then, there's no guarantee the new
readings will be OK if the light conditions are still changing. This is
an intrinsic weakness of the TSL2550 that both channels are sampled
sequentially. I doubt we want to let the user wait for the lux value
for several seconds, so returning -EAGAIN seems OK to me.

But I am not using the light sensor a lot myself, so my practical
experience is rather limited, thus I would welcome comments and
opinions on this.

-- 
Jean Delvare

  parent reply	other threads:[~2009-07-12  8:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30 15:31 [PATCH] TSL2550 driver bugfix Michele De Candia (VT)
     [not found] ` <4A4A2FBC.1060804-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
2009-06-30 16:41   ` Jonathan Cameron
     [not found]     ` <4A4A4036.3000408-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2009-07-01  8:12       ` Michele De Candia (VT)
     [not found]         ` <4A4B1A71.20101-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
2009-07-01 10:00           ` Jonathan Cameron
     [not found]             ` <4A4B7904.5010301@valueteam.com>
     [not found]               ` <4A4B7904.5010301-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
2009-07-01 16:06                 ` Jonathan Cameron
2009-07-11 18:20           ` Jean Delvare
     [not found]             ` <20090711202030.52ffbddb-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-12  8:52               ` Jean Delvare [this message]
     [not found]                 ` <20090712105237.01e11954-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-13  7:56                   ` Michele De Candia (VT)
     [not found]                     ` <4A5AE89A.8000000-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
2009-07-13  8:44                       ` Jean Delvare
     [not found]                         ` <4A5B011F.8030507@valueteam.com>
     [not found]                           ` <4A5B011F.8030507-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org>
2009-07-13 10:06                             ` Rodolfo Giometti
2009-07-13 19:17                             ` Jean Delvare

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=20090712105237.01e11954@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=giometti-k2GhghHVRtY@public.gmane.org \
    --cc=jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=michele.decandia-EZxuzQJkuwwybS5Ee8rs3A@public.gmane.org \
    /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).