reset: add reset_control_status helper function
PATCH 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.
--- drivers/reset/core.c | 13 +++++++++++++ include/linux/reset-controller.h | 1 + include/linux/reset.h | 7 +++++++ 3 files changed, 21 insertions(+)
drivers/reset/core.c +13 -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 +*/ +unsigned 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 +1 -0
@@ -17,6 +17,7 @@ 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); +unsigned int (*status)(struct reset_controller_dev *rcdev,unsigned long id); };struct module ;
include/linux/reset.h +7 -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);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 unsigned 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
Philipp Zabel
maintainerHi Dinh,
thank you for the patch. Just two small issues below:
Am Mittwoch, den 08.10.2014, 17:45 -0500 schrieb [email protected]:
[...]
Quoted 5 lines
drivers/reset/core.c +1
-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
drivers/reset/core.c int reset_control_deassert(struct reset_control *rstc) · line 139
Quoted 10 lines
drivers/reset/core.c +10
-0+* @rstc: reset controller +*/ +unsigned 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);
Since this function can return negative error numbers, please make the return value of reset_control_status int. That also means that drivers must not set the MSB when returning status.
Quoted 10 lines
drivers/reset/core.c +2
-0+ +/** * 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 +0
-0
include/linux/reset-controller.h struct reset_control_ops { · line 21
Quoted 5 lines
include/linux/reset-controller.h +1
-0@@ -17,6 +17,7 @@ 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); +unsigned int (*status)(struct reset_controller_dev *rcdev,unsigned long id); };
Please change the return value of the status callback to int and describe it in the kerneldoc comment above. It should probably be mentioned that the returned status value must be >= 0 except in error cases.
regards
Philipp
Hi Philipp,
Quoted 9 lines · Philipp Zabel
Hi Dinh,
thank you for the patch. Just two small issues below:
Am Mittwoch, den 08.10.2014, 17:45 -0500 schrieb [email protected]:
[...]Quoted 3 lines
drivers/reset/core.c +0
-0@@ -126,6 +126,19 @@ int reset_control_deassert(struct reset_control *rstc)EXPORT_SYMBOL_GPL (reset_control_deassert);
Quoted 16 lines
drivers/reset/core.c int reset_control_deassert(struct reset_control *rstc) · line 139
Quoted 12 lines
drivers/reset/core.c +11
-0/** +* reset_control_status - returns a status of a reset bit +* @rstc: reset controller +*/ +unsigned 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);Since this function can return negative error numbers, please make the return value of
reset_control_statusint. That also means that drivers must not set the MSB when returning status.
Ah yes...Don't why I changed it to unsigned int for the return.
Quoted 13 lines
Quoted 13 lines
drivers/reset/core.c +2
-0+ +/** * 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 +0
-0@@ -17,6 +17,7 @@ struct reset_control_ops {int (*reset)(struct reset_controller_dev *rcdev,unsigned long id);int (*assert)(struct reset_controller_dev *rcdev,unsigned long id);
Quoted 9 lines
include/linux/reset-controller.h struct reset_control_ops { · line 21
Quoted 3 lines
include/linux/reset-controller.h +1
-0int (*deassert)(struct reset_controller_dev *rcdev,unsigned long id); +unsigned int (*status)(struct reset_controller_dev *rcdev,unsigned long id); };Please change the return value of the status callback to int and describe it in the kerneldoc comment above. It should probably be mentioned that the returned status value must be >= 0 except in error cases.
Will do for V2...
Dinh