From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Chang Yu <marcus.yu.56@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Shi Hao" <i.shihao.999@gmail.com>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
"Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/2] iio: light: add AS7343 multi-spectral sensor driver
Date: Thu, 24 Sep 2026 21:22:05 +0300 [thread overview]
Message-ID: <arVqTWVw-eIZEcrR@ashevche-desk.local> (raw)
In-Reply-To: <20260919235145.48273-3-marcus.yu.56@gmail.com>
On Sat, Sep 19, 2026 at 04:51:45PM -0700, Chang Yu wrote:
> Add a driver for the AMS AS7343 14-channel multi-spectral sensor.
>
> The AS7343 is a 14-channel spectral sensor featuring 11 visible
> channels, 1 near-infrared channel, 1 clear channel (VIS), and 1
> flicker detection channel.
>
> The driver exposes 12 spectral channels (11 visible light and 1
> near-infrared) via sysfs. Runtime PM is implemented to stop
> measurements when the device is suspended or torn down. Power is
> never cut (PON=1 always) to preserve register values.
>
> Future patches will add configurable gain and integration time,
> interrupt support, buffered reads, VIS channel, and flicker
> detection.
...
> +#include <linux/build_bug.h>
This is unusual to meet...
...
> +static inline u8 as7343_atime_steps(unsigned int step)
> +{
> + BUILD_BUG_ON(step < 1 || step > 256);
How is this any useful? The step == 1 gives the result 0, the step 256,
255 respectively. This covers the whole range of the returned variable
(u8).
> + return step - 1;
> +}
> +
> +static inline u16 as7343_astep_x2780ns(unsigned int n)
> +{
> + BUILD_BUG_ON(n < 1 || n > 65535);
> + return n - 1;
> +}
Ditto.
...
TL;DR: I do not see anything meaningful from these BUILD_BUG_ON():s.
It's not a problem if the result gives just wrapped-up value. Or is it?
...
> +static int as7343_read_label(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan, char *label)
> +{
> + int channel = chan->channel;
Why signed?
Also split assignment, it will make code more maintainable.
> + if (channel < 0 || channel >= ARRAY_SIZE(as7343_channel_labels))
> + return -EINVAL;
> +
> + return sysfs_emit(label, "%s\n", as7343_channel_labels[channel]);
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-09-24 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 23:51 [PATCH v5 0/2] Add support for AS7343 multi-spectral sensor Chang Yu
2026-09-19 23:51 ` [PATCH v5 1/2] dt-bindings: iio: light: add as7343 Chang Yu
2026-09-20 0:26 ` Jonathan Cameron
2026-09-19 23:51 ` [PATCH v5 2/2] iio: light: add AS7343 multi-spectral sensor driver Chang Yu
2026-09-20 0:26 ` Jonathan Cameron
2026-09-21 4:21 ` Chang Yu
2026-09-24 18:22 ` Andy Shevchenko [this message]
2026-09-24 22:02 ` Jose A. Perez de Azpillaga
2026-09-25 0:52 ` Chang Yu
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=arVqTWVw-eIZEcrR@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=azpijr@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=i.shihao.999@gmail.com \
--cc=jic23@kernel.org \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcus.yu.56@gmail.com \
--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®