[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251117154027.3708807-1-a.shimko.dev@gmail.com>
Date: Mon, 17 Nov 2025 18:40:26 +0300
From: Artem Shimko <a.shimko.dev@...il.com>
To: gregkh@...uxfoundation.org,
lee.jones@...aro.org,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: Artem Shimko <a.shimko.dev@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] reset: add of_reset_control_get_optional_shared() helper
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@...il.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
Powered by blists - more mailing lists