From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/7] iio: bu27034: Add a read only HWARDWAREGAIN
Date: Sun, 7 Jul 2024 14:14:10 +0100 [thread overview]
Message-ID: <20240707141410.16e6dbbe@jic23-huawei> (raw)
In-Reply-To: <ec349847cc994f3bd632e99b408a31e7c70581d0.1720176341.git.mazziesaccount@gmail.com>
On Fri, 5 Jul 2024 13:55:49 +0300
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
Typo in patch title. If nothing much else comes up I can fix whilst applying.
> The ROHM BU27034 light sensor has two data channels for measuring
> different frequencies of light. The result from these channels is
> combined into Lux value while the raw channel values are reported via
> intensity channels.
>
> Both of the intensity channels have adjustable gain setting which
> impacts the scale of the raw channels. Eg, doubling the gain will double
> the values read from the raw channels, which halves the scale value. The
> integration time can also be set for the sensor. This does also have an
> impact to the scale of the intensity channels because increasing the
> integration time will also increase the values reported via the raw
> channels.
>
> Impact of integration time to the scale and the fact that the scale value
> does not start from '1', can make it hard for a human reader to compute the
> gain values based on the scale.
>
> Add read-only HARDWAREGAIN to help debugging.
>
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Rest of this series looks good to me and I'm fine making appropriate tweaks
for stuff I identified whilst applying.
Will give a bit of time for DT maintainers to look at the renames and check
we haven't missed anything subtle there.
Jonathan
>
> ---
> Revision history:
> v1 => v2:
> - fix switch case fallthrough warning by adding explicit return
> ---
> drivers/iio/light/rohm-bu27034.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/rohm-bu27034.c b/drivers/iio/light/rohm-bu27034.c
> index ec4f9bef83f8..76711c3cdf7c 100644
> --- a/drivers/iio/light/rohm-bu27034.c
> +++ b/drivers/iio/light/rohm-bu27034.c
> @@ -148,7 +148,8 @@ static const struct iio_itime_sel_mul bu27034_itimes[] = {
> .type = IIO_INTENSITY, \
> .channel = BU27034_CHAN_##_name, \
> .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
> - BIT(IIO_CHAN_INFO_SCALE), \
> + BIT(IIO_CHAN_INFO_SCALE) | \
> + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \
> .info_mask_separate_available = BIT(IIO_CHAN_INFO_SCALE), \
> .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME), \
> .info_mask_shared_by_all_available = \
> @@ -989,6 +990,13 @@ static int bu27034_read_raw(struct iio_dev *idev,
>
> return IIO_VAL_INT_PLUS_MICRO;
>
> + case IIO_CHAN_INFO_HARDWAREGAIN:
> + ret = bu27034_get_gain(data, chan->channel, val);
> + if (ret)
> + return ret;
> +
> + return IIO_VAL_INT;
> +
> case IIO_CHAN_INFO_SCALE:
> return bu27034_get_scale(data, chan->channel, val, val2);
>
> @@ -1033,12 +1041,17 @@ static int bu27034_write_raw_get_fmt(struct iio_dev *indio_dev,
> struct iio_chan_spec const *chan,
> long mask)
> {
> + struct bu27034_data *data = iio_priv(indio_dev);
>
> switch (mask) {
> case IIO_CHAN_INFO_SCALE:
> return IIO_VAL_INT_PLUS_NANO;
> case IIO_CHAN_INFO_INT_TIME:
> return IIO_VAL_INT_PLUS_MICRO;
> + case IIO_CHAN_INFO_HARDWAREGAIN:
> + dev_dbg(data->dev,
> + "HARDWAREGAIN is read-only, use scale to set\n");
> + return -EINVAL;
> default:
> return -EINVAL;
> }
next prev parent reply other threads:[~2024-07-07 13:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 10:53 [PATCH v2 0/7] ROHM BU27034NUC to ROHM BU27034ANUC Matti Vaittinen
2024-07-05 10:54 ` [PATCH v2 1/7] dt-bindings: iio: BU27034 => BU27034ANUC Matti Vaittinen
2024-07-07 13:05 ` Jonathan Cameron
2024-07-08 12:43 ` Matti Vaittinen
2024-07-08 17:06 ` Conor Dooley
2024-07-05 10:54 ` [PATCH v2 2/7] dt-bindings: iio: rename bu27034 file Matti Vaittinen
2024-07-08 17:05 ` Conor Dooley
2024-07-09 18:33 ` Matti Vaittinen
2024-07-13 11:00 ` Jonathan Cameron
2024-07-05 10:54 ` [PATCH v2 3/7] bu27034: ROHM BU27034NUC to BU27034ANUC Matti Vaittinen
2024-07-05 10:55 ` [PATCH v2 4/7] bu27034: ROHM BU27034NUC to BU27034ANUC drop data2 Matti Vaittinen
2024-07-05 10:55 ` [PATCH v2 5/7] bu27034: ROHM BU27034ANUC correct gains and times Matti Vaittinen
2024-07-05 10:55 ` [PATCH v2 6/7] bu27034: ROHM BU27034ANUC correct lux calculation Matti Vaittinen
2024-07-05 10:55 ` [PATCH v2 7/7] iio: bu27034: Add a read only HWARDWAREGAIN Matti Vaittinen
2024-07-07 13:14 ` Jonathan Cameron [this message]
2024-07-13 11:01 ` [PATCH v2 0/7] ROHM BU27034NUC to ROHM BU27034ANUC Jonathan Cameron
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=20240707141410.16e6dbbe@jic23-huawei \
--to=jic23@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.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