mirror of https://github.com/hak5/openwrt-owl.git
40 lines
1.3 KiB
Diff
40 lines
1.3 KiB
Diff
From 7fd7a26b60090a7df15f30ba10b0d39cbbd6a94e Mon Sep 17 00:00:00 2001
|
|
From: Alban Bedel <albeu@free.fr>
|
|
Date: Tue, 1 Sep 2015 17:28:31 +0200
|
|
Subject: [PATCH] reset: Fix of_reset_control_get() for consistent return
|
|
values
|
|
|
|
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>
|
|
---
|
|
drivers/reset/core.c | 5 ++++-
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
|
--- a/drivers/reset/core.c
|
|
+++ b/drivers/reset/core.c
|
|
@@ -215,9 +215,12 @@ struct reset_control *of_reset_control_g
|
|
{
|
|
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);
|
|
}
|
|
EXPORT_SYMBOL_GPL(of_reset_control_get);
|