Skip to contentSkip to conversation

reset: add reset_control_status helper function

PATCH Superseded [email protected] 2 participants 2 messages Oct 9, 2014 – Oct 10, 2014 Reset controller framework

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 reset: add reset_control_status helper function

From: Dinh Nguyen <[email protected]>

There are cases where a system will want to read a reset status bit before doing any other toggling. Add a reset_control_status helper function to the reset controller API.

---
v2: reset_control_status should be returning an int, and add a comment about
status in reset-controller.h

---
 drivers/reset/core.c             | 13 +++++++++++++
 include/linux/reset-controller.h |  2 ++
 include/linux/reset.h            |  7 +++++++
 3 files changed, 22 insertions(+)
drivers/reset/core.c +13 -0
index baeaf82..1e7ff06 100644
@@ -126,6 +126,19 @@ int reset_control_deassert(struct reset_control *rstc)
 EXPORT_SYMBOL_GPL(reset_control_deassert);
 
 /**
+ * reset_control_status - returns a status of a reset bit
+ * @rstc: reset controller
+ */
+int reset_control_status(struct reset_control *rstc)
+{
+	if (rstc->rcdev->ops->status)
+		return rstc->rcdev->ops->status(rstc->rcdev, rstc->id);
+
+	return -ENOSYS;
+}
+EXPORT_SYMBOL_GPL(reset_control_status);
+
+/**
  * of_reset_control_get - Lookup and obtain a reference to a reset controller.
  * @node: device to be reset by the controller
  * @id: reset line name
include/linux/reset-controller.h +2 -0
index 41a4695..ce6b962 100644
@@ -12,11 +12,13 @@ struct reset_controller_dev;
  *         things to reset the device
  * @assert: manually assert the reset line, if supported
  * @deassert: manually deassert the reset line, if supported
+ * @status: return the status of the reset line, if supported
  */
 struct reset_control_ops {
 	int (*reset)(struct reset_controller_dev *rcdev, unsigned long id);
 	int (*assert)(struct reset_controller_dev *rcdev, unsigned long id);
 	int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id);
+	int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
 };
 
 struct module;
include/linux/reset.h +7 -0
index 349f150..f7c76f2 100644
@@ -10,6 +10,7 @@ struct reset_control;
 int reset_control_reset(struct reset_control *rstc);
 int reset_control_assert(struct reset_control *rstc);
 int reset_control_deassert(struct reset_control *rstc);
+unsigned int reset_control_status(struct reset_control *rstc);
 
 struct reset_control *reset_control_get(struct device *dev, const char *id);
 void reset_control_put(struct reset_control *rstc);
@@ -57,6 +58,12 @@ static inline int reset_control_deassert(struct reset_control *rstc)
 	return 0;
 }
 
+static inline int reset_control_status(struct reset_control *rstc)
+{
+	WARN_ON(1);
+	return 0;
+}
+
 static inline void reset_control_put(struct reset_control *rstc)
 {
 	WARN_ON(1);
Signature · 1 line
2.0.3
maintainer
#1 lore raw

Hi Dinh,

you forgot one s/^+unsigned int/+int/ below.

Am Donnerstag, den 09.10.2014, 15:44 -0500 schrieb [email protected]:
[...]

drivers/reset/core.c int reset_control_deassert(struct reset_control *rstc) · line 130

Quoted 6 lines
drivers/reset/core.c +2 -0
@@ -126,6 +126,19 @@ int reset_control_deassert(struct reset_control *rstc)
 EXPORT_SYMBOL_GPL(reset_control_deassert);
 
 /**
+ * reset_control_status - returns a status of a reset bit
+ * @rstc: reset controller

+ *
+ * Returns a negative errno if not supported, a positive value if the reset
+ * line is asserted, or zero if the reset line is not asserted.

Maybe add something like this?

[...]

Quoted 23 lines
include/linux/reset-controller.h +2 -0
index 41a4695..ce6b962 100644
@@ -12,11 +12,13 @@ struct reset_controller_dev;
  *         things to reset the device
  * @assert: manually assert the reset line, if supported
  * @deassert: manually deassert the reset line, if supported
+ * @status: return the status of the reset line, if supported
  */
 struct reset_control_ops {
 	int (*reset)(struct reset_controller_dev *rcdev, unsigned long id);
 	int (*assert)(struct reset_controller_dev *rcdev, unsigned long id);
 	int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id);
+	int (*status)(struct reset_controller_dev *rcdev, unsigned long id);
 };
 
 struct module;
include/linux/reset.h +0 -0
index 349f150..f7c76f2 100644

include/linux/reset.h struct reset_control; · line 13

Quoted 4 lines
include/linux/reset.h +1 -0
@@ -10,6 +10,7 @@ struct reset_control;
 int reset_control_reset(struct reset_control *rstc);
 int reset_control_assert(struct reset_control *rstc);
 int reset_control_deassert(struct reset_control *rstc);
+unsigned int reset_control_status(struct reset_control *rstc);

int

include/linux/reset.h struct reset_control; · line 16

Quoted 2 lines
include/linux/reset.h +0 -0
 struct reset_control *reset_control_get(struct device *dev, const char *id);
 void reset_control_put(struct reset_control *rstc);

[...]

regards
Philipp