Re: [PATCH 1/3] reset: Do not register resource data for missing resets

From: Philipp Zabel
Date: Wed Nov 20 2019 - 09:43:20 EST


Hi Geert,

thank you for the patches!

On Wed, 2019-11-20 at 15:26 +0100, Geert Uytterhoeven wrote:
> When an optional reset is not present, __devm_reset_control_get() and
> devm_reset_control_array_get() still register resource data to release
> the non-existing reset on cleanup, which is futile.
>
> Fix this by skipping NULL reset control pointers.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---
> drivers/reset/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index ca1d49146f611435..55245f485b3819da 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -787,7 +787,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
> return ERR_PTR(-ENOMEM);
>
> rstc = __reset_control_get(dev, id, index, shared, optional, acquired);
> - if (!IS_ERR(rstc)) {
> + if (rstc && !IS_ERR(rstc)) {

Could you change this to use IS_ERR_OR_NULL, both here and below?

> *ptr = rstc;
> devres_add(dev, ptr);
> } else {
> @@ -930,7 +930,7 @@ devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
> return ERR_PTR(-ENOMEM);
>
> rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
> - if (IS_ERR(rstc)) {
> + if (!rstc || IS_ERR(rstc)) {
> devres_free(devres);
> return rstc;
> }

Same for patch 3, which otherwise looks fine.

regards
Philipp