Message ID | 1492514488-27385-2-git-send-email-vivek.gautam@codeaurora.org |
---|---|
State | Superseded |
Headers | show |
On Tue, 2017-04-18 at 16:51 +0530, Vivek Gautam wrote: > Count number of reset phandles available with the device node > to know the resets a given device has. > > Cc: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> > --- > drivers/reset/core.c | 23 +++++++++++++++++++++++ > include/linux/reset.h | 6 ++++++ > 2 files changed, 29 insertions(+) > > diff --git a/drivers/reset/core.c b/drivers/reset/core.c > index cd739d2fa160..f0a06a7aca93 100644 > --- a/drivers/reset/core.c > +++ b/drivers/reset/core.c > @@ -465,3 +465,26 @@ int device_reset(struct device *dev) > return ret; > } > EXPORT_SYMBOL_GPL(device_reset); > + > +/** > + * of_reset_control_get_count - Count number of resets available with a device > + * > + * @node: device node that contains 'resets'. > + * > + * Returns positive reset count on success, or error number on failure and > + * on count being zero. > + */ > +int of_reset_control_get_count(struct device_node *node) > +{ > + int count; > + > + if (!node) > + return -EINVAL; > + > + count = of_count_phandle_with_args(node, "resets", "#reset-cells"); > + if (count == 0) > + count = -ENOENT; > + > + return count; > +} > +EXPORT_SYMBOL_GPL(of_reset_control_get_count); This doesn't need to be public anymore. You can make it static and merge it into the second patch. regards Philipp -- To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/19/2017 03:55 PM, Philipp Zabel wrote: > On Tue, 2017-04-18 at 16:51 +0530, Vivek Gautam wrote: >> Count number of reset phandles available with the device node >> to know the resets a given device has. >> >> Cc: Philipp Zabel <p.zabel@pengutronix.de> >> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> >> --- >> drivers/reset/core.c | 23 +++++++++++++++++++++++ >> include/linux/reset.h | 6 ++++++ >> 2 files changed, 29 insertions(+) >> >> diff --git a/drivers/reset/core.c b/drivers/reset/core.c >> index cd739d2fa160..f0a06a7aca93 100644 >> --- a/drivers/reset/core.c >> +++ b/drivers/reset/core.c >> @@ -465,3 +465,26 @@ int device_reset(struct device *dev) >> return ret; >> } >> EXPORT_SYMBOL_GPL(device_reset); >> + >> +/** >> + * of_reset_control_get_count - Count number of resets available with a device >> + * >> + * @node: device node that contains 'resets'. >> + * >> + * Returns positive reset count on success, or error number on failure and >> + * on count being zero. >> + */ >> +int of_reset_control_get_count(struct device_node *node) >> +{ >> + int count; >> + >> + if (!node) >> + return -EINVAL; >> + >> + count = of_count_phandle_with_args(node, "resets", "#reset-cells"); >> + if (count == 0) >> + count = -ENOENT; >> + >> + return count; >> +} >> +EXPORT_SYMBOL_GPL(of_reset_control_get_count); > This doesn't need to be public anymore. You can make it static and merge > it into the second patch. Thanks for reviewing the series. Sure, make sense to make it static and squash in the second patch. Best Regards Vivek > > regards > Philipp >
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index cd739d2fa160..f0a06a7aca93 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -465,3 +465,26 @@ int device_reset(struct device *dev) return ret; } EXPORT_SYMBOL_GPL(device_reset); + +/** + * of_reset_control_get_count - Count number of resets available with a device + * + * @node: device node that contains 'resets'. + * + * Returns positive reset count on success, or error number on failure and + * on count being zero. + */ +int of_reset_control_get_count(struct device_node *node) +{ + int count; + + if (!node) + return -EINVAL; + + count = of_count_phandle_with_args(node, "resets", "#reset-cells"); + if (count == 0) + count = -ENOENT; + + return count; +} +EXPORT_SYMBOL_GPL(of_reset_control_get_count); diff --git a/include/linux/reset.h b/include/linux/reset.h index 13d8681210d5..1b5a6aafd3e6 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -24,6 +24,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev, bool optional); int __must_check device_reset(struct device *dev); +int of_reset_control_get_count(struct device_node *node); static inline int device_reset_optional(struct device *dev) { @@ -89,6 +90,11 @@ static inline struct reset_control *__devm_reset_control_get( return optional ? NULL : ERR_PTR(-ENOTSUPP); } +static inline int of_reset_control_get_count(struct device_node *node) +{ + return -ENOTSUPP; +} + #endif /* CONFIG_RESET_CONTROLLER */ /**
Count number of reset phandles available with the device node to know the resets a given device has. Cc: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org> --- drivers/reset/core.c | 23 +++++++++++++++++++++++ include/linux/reset.h | 6 ++++++ 2 files changed, 29 insertions(+)