From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@google.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Wolfram Sang <wsa@kernel.org>, Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
chrome-platform@lists.linux.dev, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Douglas Anderson <dianders@chromium.org>,
Johan Hovold <johan@kernel.org>, Jiri Kosina <jikos@kernel.org>,
linux-i2c@vger.kernel.org
Subject: Re: [PATCH v4 2/6] regulator: Add regulator_of_get_optional() for pure DT regulator lookup
Date: Tue, 13 Aug 2024 14:22:20 +0300 [thread overview]
Message-ID: <ZrtB7NPmnqF5ya2A@smile.fi.intel.com> (raw)
In-Reply-To: <20240808095931.2649657-3-wenst@chromium.org>
On Thu, Aug 08, 2024 at 05:59:25PM +0800, Chen-Yu Tsai wrote:
> The to-be-introduced I2C component prober needs to enable regulator
> supplies (and toggle GPIO pins) for the various components it intends
> to probe. To support this, a new "pure DT lookup" method for getting
> regulator supplies is needed, since the device normally requesting
> the supply won't get created until after the component is probed to
> be available.
>
> This adds a new regulator_of_get_optional() for this purpose. The
> underlying code that support the existing regulator_get*() functions
> are extended to support this specific case.
...
> /**
> * regulator_dev_lookup - lookup a regulator device.
> * @dev: device for regulator "consumer".
> + * @node: device node for regulator supply lookup.
> + * Falls back to dev->of_node if NULL.
Please, avoid using dereferences in the comments. Use plain language:
"Falls back to the OF node of the @dev, if NULL." or alike.
> * @supply: Supply name or regulator ID.
> */
...
> static struct regulator_dev *regulator_dev_lookup(struct device *dev,
> + struct device_node *node,
This function has no of_ prefix in its name. If you want to make it for all,
please use fwnode instead. Otherwise I would expect a new one with of_ prefix.
(But I really prefer just agnostic, i.e. fwnode, approach!)
> const char *supply)
> {
> + bool pure_dt_lookup = false;
Redundant assignment.
> + pure_dt_lookup = (node && !dev);
>
> + /* Pure DT lookup should use given supply name directly */
> + if (!pure_dt_lookup)
> + regulator_supply_alias(&dev, &supply);
> +
> + if (!node && dev && dev->of_node)
The dev->of_node is redundant and with the above...
> + node = dev->of_node;
...this becomes as simple as
if (!node && dev)
> + /* Pure DT lookup stops here. */
> + if (pure_dt_lookup)
> + return ERR_PTR(-ENODEV);
Looking at this pure_dt_lookup and the above (somehow inverted) case I would
rather use (node && !dev) or (!node && dev) explicitly everywhere.
...
> +struct regulator *_regulator_get(struct device *dev, struct device_node *node,
> + const char *id, enum regulator_get_type get_type)
Again, no of_ prefix and function becomes OF-specific...
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-08-13 11:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 9:59 [PATCH v4 0/6] platform/chrome: Introduce DT hardware prober Chen-Yu Tsai
2024-08-08 9:59 ` [PATCH v4 1/6] of: dynamic: Add of_changeset_update_prop_string Chen-Yu Tsai
2024-08-13 11:11 ` Andy Shevchenko
2024-08-13 19:18 ` Rob Herring
2024-08-14 4:26 ` Chen-Yu Tsai
2024-08-08 9:59 ` [PATCH v4 2/6] regulator: Add regulator_of_get_optional() for pure DT regulator lookup Chen-Yu Tsai
2024-08-13 11:22 ` Andy Shevchenko [this message]
2024-08-08 9:59 ` [PATCH v4 3/6] i2c: Introduce OF component probe function Chen-Yu Tsai
2024-08-13 11:26 ` Andy Shevchenko
2024-08-15 9:55 ` Chen-Yu Tsai
2024-08-08 9:59 ` [PATCH v4 4/6] i2c: of-prober: Add GPIO and regulator support Chen-Yu Tsai
2024-08-13 11:41 ` Andy Shevchenko
2024-08-14 11:34 ` Chen-Yu Tsai
2024-08-14 13:53 ` Andy Shevchenko
2024-08-21 9:44 ` Chen-Yu Tsai
2024-08-08 9:59 ` [PATCH v4 5/6] platform/chrome: Introduce device tree hardware prober Chen-Yu Tsai
2024-08-13 11:46 ` Andy Shevchenko
2024-08-14 10:10 ` Chen-Yu Tsai
2024-08-14 13:41 ` Andy Shevchenko
2024-08-08 9:59 ` [PATCH v4 6/6] arm64: dts: mediatek: mt8173-elm-hana: Mark touchscreens and trackpads as fail Chen-Yu Tsai
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=ZrtB7NPmnqF5ya2A@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bleung@chromium.org \
--cc=broonie@kernel.org \
--cc=chrome-platform@lists.linux.dev \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=jikos@kernel.org \
--cc=johan@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=tzungbi@kernel.org \
--cc=wenst@chromium.org \
--cc=wsa@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;
as well as URLs for NNTP newsgroup(s).