mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
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: Tue, 17 Nov 2026 03:10:57 +0000	[thread overview]
Message-ID: <20261117031057.58cb5e7e@jic23-hlaptop> (raw)
In-Reply-To: <avrLkP1IR449AwLy@ashevche-desk.local>

On Mon, 16 Nov 2026 11:23:28 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> 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.
I agree though in this particular case a property presence check doesn't
solve the same gap.  The intent was to pick up on the driver having been
force loaded without firmware.  Normally we'd just fail that given it
looks like it needs firmware. In practice it doesn't as the address this
give is always one greater than the device address.

Thinking more on that, just don't read it from firmware at all.  It's
fine that the binding wants to describe it, but we don't have to ask
the firmware when we know the answer.

Jonathan

> 
> > > +	if (!device_property_read_u32_array(dev, "reg", reg, ARRAY_SIZE(reg)))
> > > +		addr_lsb = reg[1];  
> 


  reply	other threads:[~2026-11-17  3:11 UTC|newest]

Thread overview: 9+ 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 ` [PATCH v3 1/2] dt-bindings: iio: light: Add Capella CM3217 Patrick Fischer via B4 Relay
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-14  1:29   ` Jonathan Cameron
2026-11-16  9:23     ` Andy Shevchenko
2026-11-17  3:10       ` Jonathan Cameron [this message]
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=20261117031057.58cb5e7e@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=admin@tsv-stahl-riesa.de \
    --cc=andriy.shevchenko@intel.com \
    --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=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 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®