From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Herman van Hazendonk <github.com@herrie.org>
Cc: linux-iio@vger.kernel.org, jic23@kernel.org,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
masneyb@onstation.org
Subject: Re: [PATCH 1/1] iio: light: isl29018: support cover-glass gain compensation via DT
Date: Thu, 4 Jun 2026 10:17:58 +0300 [thread overview]
Message-ID: <aiEmplRsQnvlacCD@ashevche-desk.local> (raw)
In-Reply-To: <20260604054723.2983181-2-github.com@herrie.org>
On Thu, Jun 04, 2026 at 07:47:23AM +0200, Herman van Hazendonk wrote:
> Boards that mount the sensor under a tinted or coated cover glass need
> to compensate for the optical loss before downstream consumers can map
> the reading onto a useful lux range. The driver already exposes a
> runtime knob through in_illuminance0_calibscale, but every user has to
> re-apply it after every reboot (or rely on a board-specific udev rule),
> and a power-of-two cover gain like 100x is a hardware constant of the
> board rather than a policy choice that belongs in userspace.
>
> Add an "isil,cover-comp-gain" device-tree property that seeds calibscale
> at probe, mirroring the pattern tsl2563.c already uses for the same
> class of problem (amstaos,cover-comp-gain). The default stays 1 so
> existing systems are unaffected, and userspace can still re-tune via
> the sysfs attribute afterwards.
Haven't DT schema patches needed to go separately?
...
> + /*
> + * Allow boards that mount the sensor behind tinted / coated cover
> + * glass to bake the optical-loss compensation into firmware via
> + * "isil,cover-comp-gain", following the precedent set by
> + * tsl2563.c. The value seeds calibscale (default 1), so userspace
> + * can still retune through in_illuminance0_calibscale.
> + */
> chip->calibscale = 1;
> + device_property_read_u32(&client->dev, "isil,cover-comp-gain",
> + &chip->calibscale);
With
struct device *dev = &client->dev;
at the top of the function this will be made shorter.
Additionally the above approach won't be accurate when property is present in
DT but by some reason can't be retrieved. It will puzzle the user. That's why
the robust approach is
struct device *dev = &client->dev;
const char *propname;
...
propname = "isil,cover-comp-gain";
if (device_property_present(dev, &chip->calibscale)) {
ret = device_property_read_u32(dev, propname, &chip->calibscale);
if (ret)
return ret; // optionally dev_err_probe()
} else {
chip->calibscale = 1;
}
Taking the expansion of this pattern we might need to actually introduce a full
set of device_property_read_*_optional() to make this churn less required.
Perhaps for v7.3.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-06-04 7:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 5:47 [PATCH 0/1] iio: light: isl29018: " Herman van Hazendonk
2026-06-04 5:47 ` [PATCH 1/1] iio: light: isl29018: support " Herman van Hazendonk
2026-06-04 7:17 ` Andy Shevchenko [this message]
2026-06-04 7:22 ` Joshua Crofts
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=aiEmplRsQnvlacCD@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=github.com@herrie.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masneyb@onstation.org \
--cc=nuno.sa@analog.com \
--cc=robh@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
all inboxes | Powered by JetHome®