public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: David Heidelberg <david@ixit.cz>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Javier Carrasco <javier.carrasco.cruz@gmail.com>,
	Matti Vaittinen <mazziesaccount@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Emil Gedenryd <emil.gedenryd@axis.com>,
	Arthur Becker <arthur.becker@sentec.com>,
	Mudit Sharma <muditsharma.info@gmail.com>,
	Per-Daniel Olsson <perdaniel.olsson@axis.com>,
	Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>,
	Ivan Orlov <ivan.orlov0322@gmail.com>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v2 2/3] iio: light: Add support for AL3000a illuminance sensor
Date: Mon, 17 Feb 2025 14:20:24 +0000	[thread overview]
Message-ID: <20250217142024.1a7bea7e@jic23-huawei> (raw)
In-Reply-To: <CAPVz0n2s1mxuheAadhFMHnmm6DtdMYzLHaBQDB_TEF--tWktrw@mail.gmail.com>

On Sun, 16 Feb 2025 16:47:52 +0200
Svyatoslav Ryhel <clamor95@gmail.com> wrote:

> нд, 16 лют. 2025 р. о 16:44 Jonathan Cameron <jic23@kernel.org> пише:
> >
> >  
> > > > > +
> > > > > +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.
> >  
> 
> We do know relationship of these values to illuminance thanks to
> conversion table provided.

Then convention is treat them not as IIO_LIGHT but as IIO_INTENSITY
which is unit free.  IIO_LIGHT is only for when we know the value
we are providing to userspace is illuminance and measured in Lux.

Jonathan


> 
> > >  
> > > > Except this, LGTM.
> > > >
> > > > Documentation and DT patch:
> > > >
> > > > Reviewed-by: David Heidelberg <david@ixit.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,
> > > > > +};  
> >
> >  


  reply	other threads:[~2025-02-17 14:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-15 10:31 [PATCH v2 0/3] iio: light: add al3000a als support Svyatoslav Ryhel
2025-02-15 10:31 ` [PATCH v2 1/3] dt-bindings: iio: light: al3010: add al3000a support Svyatoslav Ryhel
2025-02-16 14:42   ` Jonathan Cameron
2025-02-16 14:44     ` Svyatoslav Ryhel
2025-02-17 14:18       ` Jonathan Cameron
2025-02-15 10:31 ` [PATCH v2 2/3] iio: light: Add support for AL3000a illuminance sensor Svyatoslav Ryhel
2025-02-15 14:12   ` David Heidelberg
2025-02-15 14:22     ` Svyatoslav Ryhel
2025-02-16 14:44       ` Jonathan Cameron
2025-02-16 14:47         ` Svyatoslav Ryhel
2025-02-17 14:20           ` Jonathan Cameron [this message]
2025-02-16 14:54   ` Jonathan Cameron
2025-02-16 15:00     ` Svyatoslav Ryhel
2025-02-17 14:24       ` Jonathan Cameron
2025-02-17 14:32         ` Svyatoslav Ryhel
2025-02-22 12:05           ` Jonathan Cameron
2025-02-22 12:11             ` Svyatoslav Ryhel
2025-02-15 10:31 ` [PATCH v2 3/3] ARM: tegra: tf101: Add al3000a illuminance sensor node Svyatoslav Ryhel

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=20250217142024.1a7bea7e@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arthur.becker@sentec.com \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=david@ixit.cz \
    --cc=devicetree@vger.kernel.org \
    --cc=emil.gedenryd@axis.com \
    --cc=ivan.orlov0322@gmail.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=muditsharma.info@gmail.com \
    --cc=perdaniel.olsson@axis.com \
    --cc=robh@kernel.org \
    --cc=subhajit.ghosh@tweaklogic.com \
    --cc=thierry.reding@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