From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "Patrick Fischer via B4 Relay"
<devnull+admin.tsv-stahl-riesa.de@kernel.org>,
admin@tsv-stahl-riesa.de, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Kevin Tsai" <ktsai@capellamicro.com>,
"Svyatoslav Ryhel" <clamor95@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: light: Add Capella CM3217 ambient light sensor driver
Date: Mon, 16 Nov 2026 11:23:28 +0200 [thread overview]
Message-ID: <avrLkP1IR449AwLy@ashevche-desk.local> (raw)
In-Reply-To: <20261114012906.6f66edce@jic23-hlaptop>
On Sat, Nov 14, 2026 at 01:29:06AM +0000, Jonathan Cameron wrote:
> On Fri, 13 Nov 2026 20:59:00 +0100
> Patrick Fischer via B4 Relay <devnull+admin.tsv-stahl-riesa.de@kernel.org> wrote:
...
> > +static int cm3217_probe(struct i2c_client *client)
> > +{
> > + struct device *dev = &client->dev;
> > + struct cm3217_data *data;
> > + struct iio_dev *indio_dev;
> > + u16 addr_lsb = CM3217_ADDR_CMD2_LSB;
> > + u32 reg[2];
> > + u8 cmd1, cmd2;
Keep reversed xmas tree order.
> > + int ret;
> > +
> > + indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> > + if (!indio_dev)
> > + return -ENOMEM;
> > +
> > + data = iio_priv(indio_dev);
> > + data->client = client;
> > + i2c_set_clientdata(client, indio_dev);
> > +
> > + ret = devm_mutex_init(dev, &data->lock);
> > + if (ret)
> > + return ret;
> > +
> > + ret = devm_regulator_get_enable(dev, "vdd");
> > + if (ret)
> > + return dev_err_probe(dev, ret, "failed to enable vdd supply\n");
> > +
> > + /* Without a firmware node (e.g. sysfs new_device) use the fixed one */
>
> I'd rather we handled that explicitly.
>
> if (dev_fwmode(dev))
>
> That way we can return an error if there is firmware but it's broken.
I think here we want
if (device_property_present()) {
...
} else {
addr_lsb = CM3217_ADDR_CMD2_LSB;
}
I really discourage people to check for FW node presence with dev_fwnode(dev).
This is a corner case which is in most cases needs better granularity (like
distinguishing the fwnode by type). But in general ideally it has not to be
used at all.
> > + if (!device_property_read_u32_array(dev, "reg", reg, ARRAY_SIZE(reg)))
> > + addr_lsb = reg[1];
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-16 9:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 19:58 [PATCH v3 0/2] iio: light: Add Capella CM3217 ambient light sensor Patrick Fischer via B4 Relay
2026-11-13 19:58 ` Patrick Fischer
2026-11-13 19:58 ` [PATCH v3 1/2] dt-bindings: iio: light: Add Capella CM3217 Patrick Fischer via B4 Relay
2026-11-13 19:58 ` Patrick Fischer
2026-11-14 1:30 ` Jonathan Cameron
2026-11-16 11:44 ` Krzysztof Kozlowski
2026-11-13 19:59 ` [PATCH v3 2/2] iio: light: Add Capella CM3217 ambient light sensor driver Patrick Fischer via B4 Relay
2026-11-13 19:59 ` Patrick Fischer
2026-11-14 1:29 ` Jonathan Cameron
2026-11-16 9:23 ` Andy Shevchenko [this message]
2026-11-17 3:10 ` Jonathan Cameron
2026-11-16 9:43 ` Andy Shevchenko
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=avrLkP1IR449AwLy@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=admin@tsv-stahl-riesa.de \
--cc=andy@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+admin.tsv-stahl-riesa.de@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=ktsai@capellamicro.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.