From: Artem Shimko <a.shimko.dev@gmail.com>
To: gregkh@linuxfoundation.org, lee.jones@linaro.org,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: Artem Shimko <a.shimko.dev@gmail.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] reset: add of_reset_control_get_optional_shared() helper
Date: Mon, 17 Nov 2025 18:40:26 +0300 [thread overview]
Message-ID: <20251117154027.3708807-1-a.shimko.dev@gmail.com> (raw)
Add a new reset control helper function to support shared optional
reset lines in device tree. Some hardware platforms have reset
controllers that are shared among multiple devices and may not be
present in all configurations.
Implement of_reset_control_get_optional_shared() by extending the
existing reset control framework with RESET_CONTROL_OPTIONAL_SHARED
flag handling. The function combines the behaviors of optional and
shared reset controls, returning NULL when reset line is not specified
and allowing shared access when it exists.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
Hello,
In the syscon MFD driver, we use of_reset_control_get_optional_exclusive()
to obtain reset control, but due to the characteristics of my board (NDA),
I need to use shared instead of exclusive reset control. After testing,
everything works correctly with this implementation.
Thank you for your consideration.
--
Regards,
Artem
include/linux/reset.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/reset.h b/include/linux/reset.h
index 840d75d172f6..5600e2602491 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -547,6 +547,26 @@ static inline struct reset_control *of_reset_control_get_shared(
return __of_reset_control_get(node, id, 0, RESET_CONTROL_SHARED);
}
+/**
+ * of_reset_control_get_optional_shared - Lookup and obtain an optional shared
+ * reference to a reset controller.
+ * @node: device to be reset by the controller
+ * @id: reset line name
+ *
+ * Optional variant of of_reset_control_get_shared(). If the requested reset
+ * is not specified in the device tree, this function returns NULL instead of
+ * an error.
+ *
+ * Returns a struct reset_control or IS_ERR() condition containing errno.
+ *
+ * Use of id names is optional.
+ */
+static inline struct reset_control *of_reset_control_get_optional_shared(
+ struct device_node *node, const char *id)
+{
+ return __of_reset_control_get(node, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
+}
+
/**
* of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
* reference to a reset controller
--
2.43.0
reply other threads:[~2025-11-17 15:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251117154027.3708807-1-a.shimko.dev@gmail.com \
--to=a.shimko.dev@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
/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®