kernel: refresh patches for kernel 4.4
[openwrt/openwrt.git] / target / linux / sunxi / patches-4.4 / 141-reset-fix-of_reset_control_get.patch
1 From 7fd7a26b60090a7df15f30ba10b0d39cbbd6a94e Mon Sep 17 00:00:00 2001
2 From: Alban Bedel <albeu@free.fr>
3 Date: Tue, 1 Sep 2015 17:28:31 +0200
4 Subject: [PATCH] reset: Fix of_reset_control_get() for consistent return
5 values
6
7 When of_reset_control_get() is called without connection ID it returns
8 -ENOENT when the 'resets' property doesn't exists or is an empty entry.
9 However when a connection ID is given it returns -EINVAL when the 'resets'
10 property doesn't exists or the requested name can't be found. This is
11 because the error code returned by of_property_match_string() is just
12 passed down as an index to of_parse_phandle_with_args(), which then
13 returns -EINVAL.
14
15 To get a consistent return value with both code paths we must return
16 -ENOENT when of_property_match_string() fails.
17
18 Signed-off-by: Alban Bedel <albeu@free.fr>
19 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
20 ---
21 drivers/reset/core.c | 5 ++++-
22 1 file changed, 4 insertions(+), 1 deletion(-)
23
24 --- a/drivers/reset/core.c
25 +++ b/drivers/reset/core.c
26 @@ -215,9 +215,12 @@ struct reset_control *of_reset_control_g
27 {
28 int index = 0;
29
30 - if (id)
31 + if (id) {
32 index = of_property_match_string(node,
33 "reset-names", id);
34 + if (index < 0)
35 + return ERR_PTR(-ENOENT);
36 + }
37 return of_reset_control_get_by_index(node, index);
38 }
39 EXPORT_SYMBOL_GPL(of_reset_control_get);