From: "Javier Carrasco" <javier.carrasco.cruz@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>
Cc: "Matti Vaittinen" <mazziesaccount@gmail.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
<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: Mon, 23 Dec 2024 16:01:30 +0100 [thread overview]
Message-ID: <D6J65ERWRL0K.3VNWPTLGI07RT@gmail.com> (raw)
In-Reply-To: <20241223112932.5d3439c3@jic23-huawei>
On Mon Dec 23, 2024 at 12:29 PM CET, Jonathan Cameron wrote:
> On Fri, 20 Dec 2024 20:28:29 +0100
> Javier Carrasco <javier.carrasco.cruz@gmail.com> 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>
>
> Hi Javier,
>
> A few non fix related changes that make no functional difference made
> it in here. Those should be done in a additional patch after this one
> (to make the backport more minimal).
>
> This change is large enough I probably won't directly apply it as a fix anyway.
> Most likely it's material for the next merge window that will then get
> backported after it is upstream. That will give a small window in which
> the broken code is in a release kernel, but it should hit stable at .2/.3 or
> so and no one sane builds product before that point!
>
> Thanks,
>
> Jonathan
>
I am fine with applying this patch later if you think it makes more
sense. A couple of diffs will go away after dropping the code style
issues and the 'val' check, but it will still be a bit over 200 lines.
I am planning to fix the old veml6030 with a similar approach
after the iio-gts helpers become available. That code has been broken
from the beginning (around 5 years ago), and it did not seem to bother
anyone, so in that case it will make even more sense to apply it in the
merge window.
> > - ret = regmap_field_write(data->rf.gain, new_gain);
> > - if (ret) {
> > - dev_err(data->dev, "failed to set gain: %d\n", ret);
> > + ret = iio_gts_find_gain_sel_in_times(&data->gts, val, val2, &gain_sel,
> > + &time_sel);
> > + if (ret)
> > return ret;
> > +
> > + if (it_idx != time_sel) {
>
> Not part of this series, but might be worth turning on regcache for this driver.
> Then you can do this sort of write unconditionally as it will hit in the cache
> and do nothing anyway. Mind you, this isn't a high performance path, so maybe
> just write it anyway.
>
That makes sense, I will add a follow-up patch to use regcache. Even
though it is not a high performance path, doing it right will not cost
much more effort.
> > @@ -309,9 +323,12 @@ static int veml3235_write_raw(struct iio_dev *indio_dev,
> > {
> > switch (mask) {
> > case IIO_CHAN_INFO_INT_TIME:
> > - return veml3235_set_it(indio_dev, val, val2);
> > + if (val)
> > + return -EINVAL;
>
> This yanking of the test out of the set function is fine, but maybe
> as a precursor patch so as to reduce noise in the main change.
>
> I'm not sure it's technically necessary either. More of a sensible
> cleanup?
>
Actually, it could just stay as it was before by checking val
internally, which drops this diff. I will do that for v2.
> > +
> > + return veml3235_set_it(indio_dev, val2);
> > case IIO_CHAN_INFO_SCALE:
> > - return veml3235_set_gain(indio_dev, val, val2);
> > + return veml3235_set_scale(indio_dev, val, val2);
> > static const struct iio_info veml3235_info = {
> > - .read_raw = veml3235_read_raw,
> > - .read_avail = veml3235_read_avail,
> > + .read_raw = veml3235_read_raw,
> > + .read_avail = veml3235_read_avail,
>
> Whilst it would be good to fix that indent, doesn't belong in this patch
> as it means the reader has to check very carefully that there are no subtle
> changes in this line. Feel free to send a follow up white space cleanup
> patch that clearly states it makes not functional changes though.
>
I will move the code style fixes to another patch. I was a bit too lazy
here :)
Thanks for your feedback and best regards,
Javier Carrasco
prev parent reply other threads:[~2024-12-23 15:01 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
2024-12-22 16:13 ` Javier Carrasco
2024-12-23 11:29 ` Jonathan Cameron
2024-12-23 15:01 ` Javier Carrasco [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=D6J65ERWRL0K.3VNWPTLGI07RT@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@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).