]> git.karo-electronics.de Git - linux-beck.git/commitdiff
reset: add reset_control_status helper function
authorDinh Nguyen <dinguyen@opensource.altera.com>
Fri, 10 Oct 2014 15:21:14 +0000 (10:21 -0500)
committerPhilipp Zabel <p.zabel@pengutronix.de>
Mon, 20 Oct 2014 08:11:29 +0000 (10:11 +0200)
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.

Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
drivers/reset/core.c
include/linux/reset-controller.h
include/linux/reset.h

index baeaf82d40d9f1982761d68ee1cf0c56cd6c346e..7955e00d04d49fca9f16d78f1fa50835c038bf46 100644 (file)
@@ -125,6 +125,21 @@ int reset_control_deassert(struct reset_control *rstc)
 }
 EXPORT_SYMBOL_GPL(reset_control_deassert);
 
+/**
+ * reset_control_status - 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.
+ * @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
index 41a4695fde08ca9414f6c541aaa16077b215d3d2..ce6b962ffed43d892aa1bea3749e923f0032ea1f 100644 (file)
@@ -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;
index 349f150ae12cb4f896eea2aafc73cfcb3fcfd26c..da5602bd77d75996f78114b7369b409ea52f007d 100644 (file)
@@ -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);
+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);