Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reset: add reset_control_status helper function

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>

authored by

Dinh Nguyen and committed by
Philipp Zabel
729de41b f114040e

+24
+15
drivers/reset/core.c
··· 126 126 EXPORT_SYMBOL_GPL(reset_control_deassert); 127 127 128 128 /** 129 + * reset_control_status - returns a negative errno if not supported, a 130 + * positive value if the reset line is asserted, or zero if the reset 131 + * line is not asserted. 132 + * @rstc: reset controller 133 + */ 134 + int reset_control_status(struct reset_control *rstc) 135 + { 136 + if (rstc->rcdev->ops->status) 137 + return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); 138 + 139 + return -ENOSYS; 140 + } 141 + EXPORT_SYMBOL_GPL(reset_control_status); 142 + 143 + /** 129 144 * of_reset_control_get - Lookup and obtain a reference to a reset controller. 130 145 * @node: device to be reset by the controller 131 146 * @id: reset line name
+2
include/linux/reset-controller.h
··· 12 12 * things to reset the device 13 13 * @assert: manually assert the reset line, if supported 14 14 * @deassert: manually deassert the reset line, if supported 15 + * @status: return the status of the reset line, if supported 15 16 */ 16 17 struct reset_control_ops { 17 18 int (*reset)(struct reset_controller_dev *rcdev, unsigned long id); 18 19 int (*assert)(struct reset_controller_dev *rcdev, unsigned long id); 19 20 int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id); 21 + int (*status)(struct reset_controller_dev *rcdev, unsigned long id); 20 22 }; 21 23 22 24 struct module;
+7
include/linux/reset.h
··· 10 10 int reset_control_reset(struct reset_control *rstc); 11 11 int reset_control_assert(struct reset_control *rstc); 12 12 int reset_control_deassert(struct reset_control *rstc); 13 + int reset_control_status(struct reset_control *rstc); 13 14 14 15 struct reset_control *reset_control_get(struct device *dev, const char *id); 15 16 void reset_control_put(struct reset_control *rstc); ··· 53 52 } 54 53 55 54 static inline int reset_control_deassert(struct reset_control *rstc) 55 + { 56 + WARN_ON(1); 57 + return 0; 58 + } 59 + 60 + static inline int reset_control_status(struct reset_control *rstc) 56 61 { 57 62 WARN_ON(1); 58 63 return 0;