From: Chen-Yu Tsai <wenst@chromium.org>
To: Mark Brown <broonie@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Andi Shyti <andi.shyti@kernel.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
Benson Leung <bleung@chromium.org>,
Tzung-Bi Shih <tzungbi@kernel.org>,
linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
chrome-platform@lists.linux.dev, linux-input@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 5/8] i2c: of-prober: Let cleanup op know if a device was found
Date: Tue, 1 Sep 2026 15:49:23 +0800 [thread overview]
Message-ID: <20260901074930.764550-6-wenst@chromium.org> (raw)
In-Reply-To: <20260901074930.764550-1-wenst@chromium.org>
The prober's cleanup op may want to do things differently if a device
was found, such as wait for the actual device driver to pick up
resources.
Add a parameter to the cleanup op to pass this information in.
Also fix up an incorrect reference in i2c_of_probe_ops's kernel-doc.
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
Changes since v5:
- New patch
---
drivers/i2c/i2c-core-of-prober.c | 8 ++++++--
include/linux/i2c-of-prober.h | 7 ++++---
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-prober.c
index f9f3c0ef93ff..97ef58bb4c04 100644
--- a/drivers/i2c/i2c-core-of-prober.c
+++ b/drivers/i2c/i2c-core-of-prober.c
@@ -130,6 +130,7 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf
const struct i2c_of_probe_ops *ops;
const char *type;
struct i2c_adapter *i2c;
+ bool device_found;
int ret;
ops = cfg->ops ?: &i2c_of_probe_dummy_ops;
@@ -159,6 +160,7 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf
if (ret)
goto out_put_i2c_adapter;
+ device_found = false;
for_each_child_of_node_with_prefix(i2c_node, node, type) {
union i2c_smbus_data data;
u32 addr;
@@ -171,12 +173,13 @@ int i2c_of_probe_component(struct device *dev, const struct i2c_of_probe_cfg *cf
/* Found a device that is responding */
if (ops->cleanup_early)
ops->cleanup_early(dev, ctx);
+ device_found = true;
ret = i2c_of_probe_enable_node(dev, node);
break;
}
if (ops->cleanup)
- ops->cleanup(dev, ctx);
+ ops->cleanup(dev, ctx, device_found && !ret);
out_put_i2c_adapter:
i2c_put_adapter(i2c);
@@ -388,12 +391,13 @@ EXPORT_SYMBOL_NS_GPL(i2c_of_probe_simple_cleanup_early, "I2C_OF_PROBER");
* i2c_of_probe_simple_cleanup - Clean up and release resources for I2C OF prober simple helpers
* @dev: Pointer to the &struct device of the caller, only used for dev_printk() messages
* @data: Pointer to &struct i2c_of_probe_simple_ctx helper context.
+ * @device_enabled: True if a device was found and enabled.
*
* * If a GPIO line was found and not yet released, set its value to the opposite of that
* set in i2c_of_probe_simple_enable() and release it.
* * If a regulator supply was found, disable that regulator and release it.
*/
-void i2c_of_probe_simple_cleanup(struct device *dev, void *data)
+void i2c_of_probe_simple_cleanup(struct device *dev, void *data, bool device_enabled)
{
struct i2c_of_probe_simple_ctx *ctx = data;
diff --git a/include/linux/i2c-of-prober.h b/include/linux/i2c-of-prober.h
index bb6d47f50ee5..f28a40780d1f 100644
--- a/include/linux/i2c-of-prober.h
+++ b/include/linux/i2c-of-prober.h
@@ -45,7 +45,7 @@ struct i2c_of_probe_ops {
*
* Only called if a matching component is actually found. If none are found,
* resources that would have been released in this callback should be released in
- * @free_resourcs_late instead.
+ * @cleanup instead.
*/
void (*cleanup_early)(struct device *dev, void *data);
@@ -53,8 +53,9 @@ struct i2c_of_probe_ops {
* @cleanup: Opposite of @enable to balance refcounts and free resources after probing.
*
* Should check if resources were already freed by @cleanup_early.
+ * |device_enabled| is true is a component was found and was enabled.
*/
- void (*cleanup)(struct device *dev, void *data);
+ void (*cleanup)(struct device *dev, void *data, bool device_enabled);
};
/**
@@ -131,7 +132,7 @@ struct i2c_of_probe_simple_ctx {
int i2c_of_probe_simple_enable(struct device *dev, struct device_node *bus_node, void *data);
void i2c_of_probe_simple_cleanup_early(struct device *dev, void *data);
-void i2c_of_probe_simple_cleanup(struct device *dev, void *data);
+void i2c_of_probe_simple_cleanup(struct device *dev, void *data, bool device_enabled);
extern struct i2c_of_probe_ops i2c_of_probe_simple_ops;
--
2.55.0.897.gb25b4bd76c-goog
next prev parent reply other threads:[~2026-09-01 7:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 7:49 [PATCH v6 0/8] arm64: mediatek: Chromebook trackpad supply fixes Chen-Yu Tsai
2026-09-01 7:49 ` [PATCH v6 1/8] regulator: core: Add "enable and wait" functions Chen-Yu Tsai
2026-09-01 8:03 ` sashiko-bot
2026-10-05 17:09 ` Mark Brown
2026-09-01 7:49 ` [PATCH v6 2/8] Input: elan_i2c - Wait for initialization after enabling regulator supply Chen-Yu Tsai
2026-09-01 7:49 ` [PATCH v6 3/8] HID: i2c-hid-of: skip post-power-on delay if powered on sufficiently long Chen-Yu Tsai
2026-09-01 8:01 ` sashiko-bot
2026-09-01 7:49 ` [PATCH v6 4/8] i2c: of-prober: " Chen-Yu Tsai
2026-09-01 8:02 ` sashiko-bot
2026-09-01 7:49 ` Chen-Yu Tsai [this message]
2026-09-01 7:49 ` [PATCH v6 6/8] i2c: of-prober: Defer regulator_disable() on successful probe in simple helper Chen-Yu Tsai
2026-09-01 7:49 ` [PATCH v6 7/8] arm64: dts: mediatek: mt8173-elm-hana: Unmark trackpad supply as always-on Chen-Yu Tsai
2026-09-01 7:49 ` [PATCH v6 8/8] arm64: dts: mediatek: mt8192-asurada-spherion: Add Synaptics trackpad's supply 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=20260901074930.764550-6-wenst@chromium.org \
--to=wenst@chromium.org \
--cc=andi.shyti@kernel.org \
--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=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=tzungbi@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.