All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jeff LaBundy <jeff@labundy.com>
Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH v2] iio: light: lv0104cs: Add support for LV0104CS light sensor
Date: Sat, 3 Mar 2018 14:57:29 +0000	[thread overview]
Message-ID: <20180303145729.40142639@archlinux> (raw)
In-Reply-To: <20180225023808.GA2301@labundy.com>

On Sat, 24 Feb 2018 20:38:08 -0600
Jeff LaBundy <jeff@labundy.com> wrote:

<snip>
> > > +static int lv0104cs_get_lux(struct lv0104cs_private *lv0104cs,
> > > +				int *val, int *val2)
> > > +{
> > > +	u8 regval = LV0104CS_REGVAL_MEASURE;
> > > +	u16 adc_output;
> > > +	int ret;
> > > +
> > > +	regval |= lv0104cs_scales[lv0104cs->scale].regval;
> > > +	regval |= lv0104cs_int_times[lv0104cs->int_time].regval;
> > > +	ret = lv0104cs_write_reg(lv0104cs, regval);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	/* wait for integration time to pass (with margin) */
> > > +	switch (lv0104cs->int_time) {
> > > +	case LV0104CS_INTEG_12_5MS:
> > > +		msleep(50);
> > > +		break;
> > > +
> > > +	case LV0104CS_INTEG_100MS:
> > > +		msleep(150);
> > > +		break;
> > > +
> > > +	case LV0104CS_INTEG_200MS:
> > > +		msleep(250);
> > > +		break;
> > > +
> > > +	default:
> > > +		return -EINVAL;
> > > +	}
> > > +
> > > +	ret = lv0104cs_read_adc(lv0104cs, &adc_output);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	ret = lv0104cs_write_reg(lv0104cs, LV0104CS_REGVAL_SLEEP);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > > +	/* convert ADC output to lux */
> > > +	switch (lv0104cs->scale) {
> > > +	case LV0104CS_SCALE_0_25X:  
> > Hmm.  Given how simple the scale application is and the fact
> > that we aren't trying dynamic control (which makes this complex)
> > we 'could' go for the IIO default option of providing the raw
> > value and letting userspace deal with the calibration.
> > 
> > However, this is a slow device (fairly anyway) so the
> > cost of conversion is trivial and we are unlikely to ever want
> > to bother with a buffered interface on this I think things
> > are fine as you have them.  
> 
> Sure thing, I'll leave this as-is. The reason for having chosen
> PROCESSED is because the device's ADC output already includes the
> effects of CALIBSCALE, so the device technically does not offer
> a RAW output on its own. Therefore I have presented a PROCESSED
> value that includes the SCALE that was in place when the measurement
> was captured.
It's normal for a device to already include the effect of a
calibscale as they are often done by tweaking a DAC in the
analog section of the sensor circuit.  So don't let that
argue against providing a _RAW value.

The answer is still fine though, just thought I'd comment on the
reasoning ;)

<snip>

      reply	other threads:[~2018-03-03 14:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 14:58 [PATCH] iio: light: lv0104cs: Add support for LV0104CS light sensor Jeff LaBundy
2018-02-14 15:58 ` Peter Meerwald-Stadler
2018-02-15  4:46   ` Jeff LaBundy
2018-02-17 17:13     ` Jonathan Cameron
2018-02-17 19:18       ` Jeff LaBundy
2018-02-18 18:25 ` [PATCH v2] " Jeff LaBundy
2018-02-24 12:02   ` Jonathan Cameron
2018-02-25  2:38     ` Jeff LaBundy
2018-03-03 14:57       ` 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=20180303145729.40142639@archlinux \
    --to=jic23@kernel.org \
    --cc=jeff@labundy.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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.