diff mbox series

[RFC,1/3] reset: Add reset_controller_get_dev()

Message ID 20230518155649.516346-2-biju.das.jz@bp.renesas.com (mailing list archive)
State Under Review
Delegated to: Geert Uytterhoeven
Headers show
Series Support VBUSEN selection control for RZ/G2L | expand

Commit Message

Biju Das May 18, 2023, 3:56 p.m. UTC
Add support for finding the device associated with the reset controller.

A reset consumer can use this API to find the reset controller device
and then call the corresponding provider device to configure some register.
(eg: As per latest RZ/G2L HW manual Rev 1.30 RZ/G2L USB phy controller
IP exposes a register for vbus control selection)

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/reset/core.c             | 14 ++++++++++++++
 include/linux/reset-controller.h |  9 +++++++++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f0a076e94118..e85d268ada98 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -191,6 +191,20 @@  void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 }
 EXPORT_SYMBOL_GPL(reset_controller_add_lookup);
 
+/**
+ * reset_controller_get_dev - get reset controller device
+ * @rstc: reset controller
+ */
+struct reset_controller_dev *
+reset_controller_get_dev(struct reset_control *rstc)
+{
+	if (!rstc)
+		return NULL;
+
+	return rstc->rcdev;
+}
+EXPORT_SYMBOL_GPL(reset_controller_get_dev);
+
 static inline struct reset_control_array *
 rstc_to_array(struct reset_control *rstc) {
 	return container_of(rstc, struct reset_control_array, base);
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h
index 0fa4f60e1186..304f79b3eb44 100644
--- a/include/linux/reset-controller.h
+++ b/include/linux/reset-controller.h
@@ -5,6 +5,7 @@ 
 #include <linux/list.h>
 
 struct reset_controller_dev;
+struct reset_control;
 
 /**
  * struct reset_control_ops - reset controller driver callbacks
@@ -89,6 +90,8 @@  int devm_reset_controller_register(struct device *dev,
 
 void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 				 unsigned int num_entries);
+
+struct reset_controller_dev *reset_controller_get_dev(struct reset_control *rstc);
 #else
 static inline int reset_controller_register(struct reset_controller_dev *rcdev)
 {
@@ -109,6 +112,12 @@  static inline void reset_controller_add_lookup(struct reset_control_lookup *look
 					       unsigned int num_entries)
 {
 }
+
+static inline struct reset_controller_dev *
+reset_controller_get_dev(struct reset_control *rstc)
+{
+	return 0;
+}
 #endif
 
 #endif