reset_control_get_optional() is implemented as a static inline function which calls reset_control_get() first and then handles the _optional part. Change this to implement a __reset_control_get() taking a bool optional argument. This is done as a preparation to implement __reset_control_bulk_get() in the next step which can reuse __reset_control_get(). Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- drivers/reset/core.c | 11 ++++++++--- include/linux/reset.h | 13 +++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 94bfad2067..679deee3c1 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -359,7 +359,7 @@ gpio_reset_control_get(struct device *dev, const char *id) * * Use of id names is optional. */ -struct reset_control *reset_control_get(struct device *dev, const char *id) +struct reset_control *__reset_control_get(struct device *dev, const char *id, bool optional) { struct reset_control *rstc; @@ -368,7 +368,7 @@ struct reset_control *reset_control_get(struct device *dev, const char *id) rstc = of_reset_control_get(dev->of_node, id); if (IS_ERR(rstc)) - return ERR_CAST(rstc); + goto err; /* * If there is no dedicated reset controller device, check if we have @@ -377,7 +377,7 @@ struct reset_control *reset_control_get(struct device *dev, const char *id) if (!rstc) { rstc = gpio_reset_control_get(dev, id); if (IS_ERR(rstc)) - return ERR_CAST(rstc); + goto err; } if (!rstc) @@ -386,6 +386,11 @@ struct reset_control *reset_control_get(struct device *dev, const char *id) rstc->dev = dev; return rstc; +err: + if (optional && rstc == ERR_PTR(-ENOENT)) + return NULL; + + return ERR_CAST(rstc); } EXPORT_SYMBOL_GPL(reset_control_get); diff --git a/include/linux/reset.h b/include/linux/reset.h index 7db3d3162a..183d7d55a0 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -13,7 +13,7 @@ int reset_control_reset(struct reset_control *rstc); int reset_control_assert(struct reset_control *rstc); int reset_control_deassert(struct reset_control *rstc); -struct reset_control *reset_control_get(struct device *dev, const char *id); +struct reset_control *__reset_control_get(struct device *dev, const char *id, bool optional); struct reset_control *of_reset_control_get(struct device_node *node, const char *id); void reset_control_put(struct reset_control *rstc); @@ -57,7 +57,7 @@ of_reset_control_get(struct device_node *node, const char *id) } static inline struct reset_control * -reset_control_get(struct device *dev, const char *id) +__reset_control_get(struct device *dev, const char *id, bool optional) { return NULL; } @@ -96,8 +96,13 @@ static inline struct reset_control *reset_control_array_get(struct device *dev) static inline struct reset_control *reset_control_get_optional(struct device *dev, const char *id) { - struct reset_control *rstc = reset_control_get(dev, id); - return rstc == ERR_PTR(-ENOENT) ? NULL : rstc; + return __reset_control_get(dev, id, true); +} + +static inline struct reset_control *reset_control_get(struct device *dev, + const char *id) +{ + return __reset_control_get(dev, id, false); } #endif -- 2.39.5