lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250217142024.1a7bea7e@jic23-huawei>
Date: Mon, 17 Feb 2025 14:20:24 +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

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

> нд, 16 лют. 2025 р. о 16:44 Jonathan Cameron <jic23@...nel.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@...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

Powered by Openwall GNU/*/Linux Powered by OpenVZ