Bump version to v1.5 and start work on adding 4.19 kernel suppot
[librecmc/librecmc.git] / target / linux / sunxi / patches-4.4 / 140-reset-add-of_reset_control_get_by_index.patch
1 From b4faa163a7ebae9faab5d0aefe70143e3379178b Mon Sep 17 00:00:00 2001
2 From: Vince Hsu <vinceh@nvidia.com>
3 Date: Mon, 13 Jul 2015 13:39:39 +0100
4 Subject: [PATCH] reset: add of_reset_control_get_by_index()
5
6 Add of_reset_control_get_by_index() to allow the drivers to get reset
7 device without knowing its name.
8
9 Signed-off-by: Vince Hsu <vinceh@nvidia.com>
10 [jonathanh@nvidia.com: Updated stub function to return -ENOTSUPP instead
11  of -ENOSYS which should only be used for system calls.]
12 Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
13 Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
14 ---
15  drivers/reset/core.c  | 40 +++++++++++++++++++++++++++++-----------
16  include/linux/reset.h |  9 +++++++++
17  2 files changed, 38 insertions(+), 11 deletions(-)
18
19 --- a/drivers/reset/core.c
20 +++ b/drivers/reset/core.c
21 @@ -141,27 +141,24 @@ int reset_control_status(struct reset_co
22  EXPORT_SYMBOL_GPL(reset_control_status);
23  
24  /**
25 - * of_reset_control_get - Lookup and obtain a reference to a reset controller.
26 + * of_reset_control_get_by_index - Lookup and obtain a reference to a reset
27 + * controller by index.
28   * @node: device to be reset by the controller
29 - * @id: reset line name
30 - *
31 - * Returns a struct reset_control or IS_ERR() condition containing errno.
32 + * @index: index of the reset controller
33   *
34 - * Use of id names is optional.
35 + * This is to be used to perform a list of resets for a device or power domain
36 + * in whatever order. Returns a struct reset_control or IS_ERR() condition
37 + * containing errno.
38   */
39 -struct reset_control *of_reset_control_get(struct device_node *node,
40 -                                          const char *id)
41 +struct reset_control *of_reset_control_get_by_index(struct device_node *node,
42 +                                          int index)
43  {
44         struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER);
45         struct reset_controller_dev *r, *rcdev;
46         struct of_phandle_args args;
47 -       int index = 0;
48         int rstc_id;
49         int ret;
50  
51 -       if (id)
52 -               index = of_property_match_string(node,
53 -                                                "reset-names", id);
54         ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
55                                          index, &args);
56         if (ret)
57 @@ -202,6 +199,27 @@ struct reset_control *of_reset_control_g
58  
59         return rstc;
60  }
61 +EXPORT_SYMBOL_GPL(of_reset_control_get_by_index);
62 +
63 +/**
64 + * of_reset_control_get - Lookup and obtain a reference to a reset controller.
65 + * @node: device to be reset by the controller
66 + * @id: reset line name
67 + *
68 + * Returns a struct reset_control or IS_ERR() condition containing errno.
69 + *
70 + * Use of id names is optional.
71 + */
72 +struct reset_control *of_reset_control_get(struct device_node *node,
73 +                                          const char *id)
74 +{
75 +       int index = 0;
76 +
77 +       if (id)
78 +               index = of_property_match_string(node,
79 +                                                "reset-names", id);
80 +       return of_reset_control_get_by_index(node, index);
81 +}
82  EXPORT_SYMBOL_GPL(of_reset_control_get);
83  
84  /**
85 --- a/include/linux/reset.h
86 +++ b/include/linux/reset.h
87 @@ -38,6 +38,9 @@ static inline struct reset_control *devm
88  struct reset_control *of_reset_control_get(struct device_node *node,
89                                            const char *id);
90  
91 +struct reset_control *of_reset_control_get_by_index(
92 +                                       struct device_node *node, int index);
93 +
94  #else
95  
96  static inline int reset_control_reset(struct reset_control *rstc)
97 @@ -106,6 +109,12 @@ static inline struct reset_control *of_r
98         return ERR_PTR(-ENOSYS);
99  }
100  
101 +static inline struct reset_control *of_reset_control_get_by_index(
102 +                               struct device_node *node, int index)
103 +{
104 +       return ERR_PTR(-ENOTSUPP);
105 +}
106 +
107  #endif /* CONFIG_RESET_CONTROLLER */
108  
109  #endif