From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] reset: Fix of_reset_control_get() for consistent return values
Date: Mon, 8 Aug 2022 14:07:14 +0200 [thread overview]
Message-ID: <20220808120714.GA31528@pengutronix.de> (raw)
In-Reply-To: <20220805125931.1212228-1-a.fatoum@pengutronix.de>
On Fri, Aug 05, 2022 at 02:59:29PM +0200, Ahmad Fatoum wrote:
> When of_reset_control_get() is called without connection ID it returns
> -ENOENT when the 'resets' property doesn't exists or is an empty entry.
> However when a connection ID is given it returns -EINVAL when the 'resets'
> property doesn't exists or the requested name can't be found. This is
> because the error code returned by of_property_match_string() is just
> passed down as an index to of_parse_phandle_with_args(), which then
> returns -EINVAL.
>
> To get a consistent return value with both code paths we must return
> -ENOENT when of_property_match_string() fails.
> Signed-off-by: Alban Bedel <albeu@free.fr>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> [afa: ported from Linux 3d81216fde465e76c5eae98f61d3666163634395]
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> drivers/reset/core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 4355c3415eb0..93fbaeccafd2 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -236,8 +236,11 @@ struct reset_control *of_reset_control_get(struct device_node *node,
> {
> int index = 0;
>
> - if (id)
> + if (id) {
> index = of_property_match_string(node, "reset-names", id);
> + if (index < 0)
> + return ERR_PTR(-ENOENT);
> + }
>
> return of_reset_control_get_by_index(node, index);
> }
> --
> 2.30.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-08-08 12:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-05 12:59 Ahmad Fatoum
2022-08-05 12:59 ` [PATCH 2/3] reset: implement reset_control_get_optional() Ahmad Fatoum
2022-08-05 12:59 ` [PATCH 3/3] reset: implement reset_control_get_count() Ahmad Fatoum
2022-08-08 12:07 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220808120714.GA31528@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox