Linux IIO development
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH 2/2] iio: veml3235: fix scale to conform to ABI
Date: Sun, 22 Dec 2024 15:43:16 +0200	[thread overview]
Message-ID: <b4b8ab5e-7b94-4919-98a4-1525be903954@gmail.com> (raw)
In-Reply-To: <20241220-veml3235_scale-v1-2-b43b190bbb6a@gmail.com>

On 20/12/2024 21:28, Javier Carrasco wrote:
> The current scale is not ABI-compliant as it is just the sensor gain
> instead of the value that acts as a multiplier to be applied to the raw
> value (there is no offset).
> 
> Use the iio-gts helpers to obtain the proper scale values according to
> the gain and integration time to match the resolution tables from the
> datasheet.
> 
> Fixes: c5a23f80c164 ("iio: light: add support for veml3235")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---

...

> +static const struct iio_itime_sel_mul veml3235_it_sel[] = {
> +	GAIN_SCALE_ITIME_US(50000, 0, 1),
> +	GAIN_SCALE_ITIME_US(100000, 1, 2),
> +	GAIN_SCALE_ITIME_US(200000, 2, 4),
> +	GAIN_SCALE_ITIME_US(400000, 3, 8),
> +	GAIN_SCALE_ITIME_US(800000, 4, 16),
>   };
>   
> -static const int veml3235_scale_vals[] = { 1, 2, 4, 8 };
> +/*
> + * The MSB (DG) doubles the value of the rest of the field, which leads to
> + * two possible combinations to obtain gain = 2 and gain = 4. The gain
> + * handlding can be simplified by restricting DG = 1 to the only gain that
> + * really requires it, gain = 8. Note that "X10" is a reserved value.

Just a question - do you ensure there is no "invalid" register values? I 
think Jonathan has prefered doing this by writing known initialization 
values at probe.

I *think* the GTS should survive cases where multiple bit patterns can 
be used to represent same gain/time - but I don't remember this for sure.

I didn't have the time to do a proper thorough review - sorry. Still, 
what I browsed quickly looked good :) Thanks!

Yours,
	-- Matti

  reply	other threads:[~2024-12-22 13:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 19:28 [PATCH 0/2] iio: light: fix scale in veml3235 and add helpers to iio-gts Javier Carrasco
2024-12-20 19:28 ` [PATCH 1/2] iio: gts-helper: add helpers to ease searches of gain_sel and new_gain Javier Carrasco
2024-12-21 18:19   ` Matti Vaittinen
2024-12-23 11:17     ` Jonathan Cameron
2024-12-20 19:28 ` [PATCH 2/2] iio: veml3235: fix scale to conform to ABI Javier Carrasco
2024-12-22 13:43   ` Matti Vaittinen [this message]
2024-12-22 16:13     ` Javier Carrasco
2024-12-23 11:29   ` Jonathan Cameron
2024-12-23 15:01     ` Javier Carrasco

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=b4b8ab5e-7b94-4919-98a4-1525be903954@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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