[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250216144436.70ff78c3@jic23-huawei>
Date: Sun, 16 Feb 2025 14:44:36 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Svyatoslav Ryhel <clamor95@...il.com>
Cc: David Heidelberg <david@...t.cz>, Lars-Peter Clausen <lars@...afoo.de>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Thierry Reding
<thierry.reding@...il.com>, Jonathan Hunter <jonathanh@...dia.com>, Javier
Carrasco <javier.carrasco.cruz@...il.com>, Matti Vaittinen
<mazziesaccount@...il.com>, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com>, Emil Gedenryd
<emil.gedenryd@...s.com>, Arthur Becker <arthur.becker@...tec.com>, Mudit
Sharma <muditsharma.info@...il.com>, Per-Daniel Olsson
<perdaniel.olsson@...s.com>, Subhajit Ghosh
<subhajit.ghosh@...aklogic.com>, Ivan Orlov <ivan.orlov0322@...il.com>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-tegra@...r.kernel.org
Subject: Re: [PATCH v2 2/3] iio: light: Add support for AL3000a illuminance
sensor
> > > +
> > > +static int al3000a_read_raw(struct iio_dev *indio_dev,
> > > + struct iio_chan_spec const *chan, int *val,
> > > + int *val2, long mask)
> > > +{
> > > + struct al3000a_data *data = iio_priv(indio_dev);
> > > + int ret, gain;
> > > +
> > > + switch (mask) {
> > > + case IIO_CHAN_INFO_RAW:
> > > + ret = regmap_read(data->regmap, AL3000A_REG_DATA, &gain);
> > > + if (ret < 0)
> > > + return ret;
> > > +
> > > + *val = lux_table[gain & AL3000A_GAIN_MASK];
> >
> > Why did you chosen to do post-processing in the RAW channel instead
> > doing it in INFO_SCALE (same as al3010 does)?
> >
>
> From my observation INFO_SCALE will just perform multiplication of RAW
> to SCALE. In this case values which are read are not actual raw values
> of illumination. Next is my assumption (since there is no datasheet),
> but values obtained from register are similar to values from adc
> thermal sensors, they need be converted via reference table to get
> actual data.
Please add a comment somewhere here to say that we don't know the
relationship of these values to illuminance hence providing
_RAW and _SCALE would not be helpful.
>
> > Except this, LGTM.
> >
> > Documentation and DT patch:
> >
> > Reviewed-by: David Heidelberg <david@...t.cz>
> > > +
> > > + return IIO_VAL_INT;
> > > + case IIO_CHAN_INFO_SCALE:
> > > + *val = 1;
> > > +
Don't do this. The above lack of known relationship has to be
expressed by not providing the _scale attribute.
> > > + return IIO_VAL_INT;
> > > + default:
> > > + return -EINVAL;
> > > + }
> > > +}
> > > +
> > > +static const struct iio_info al3000a_info = {
> > > + .read_raw = al3000a_read_raw,
> > > +};
Powered by blists - more mailing lists