hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/cpuidle/dt_idle_states.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * DT idle states parsing code.
34 *
45 * Copyright (C) 2014 ARM Ltd.
56 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #define pr_fmt(fmt) "DT idle-states: " fmt
....@@ -22,16 +19,12 @@
2219 #include "dt_idle_states.h"
2320
2421 static int init_state_node(struct cpuidle_state *idle_state,
25
- const struct of_device_id *matches,
22
+ const struct of_device_id *match_id,
2623 struct device_node *state_node)
2724 {
2825 int err;
29
- const struct of_device_id *match_id;
3026 const char *desc;
3127
32
- match_id = of_match_node(matches, state_node);
33
- if (!match_id)
34
- return -ENODEV;
3528 /*
3629 * CPUidle drivers are expected to initialize the const void *data
3730 * pointer of the passed in struct of_device_id array to the idle
....@@ -118,8 +111,7 @@
118111 for (cpu = cpumask_next(cpumask_first(cpumask), cpumask);
119112 cpu < nr_cpu_ids; cpu = cpumask_next(cpu, cpumask)) {
120113 cpu_node = of_cpu_device_node_get(cpu);
121
- curr_state_node = of_parse_phandle(cpu_node, "cpu-idle-states",
122
- idx);
114
+ curr_state_node = of_get_cpu_state_node(cpu_node, idx);
123115 if (state_node != curr_state_node)
124116 valid = false;
125117
....@@ -160,6 +152,7 @@
160152 {
161153 struct cpuidle_state *idle_state;
162154 struct device_node *state_node, *cpu_node;
155
+ const struct of_device_id *match_id;
163156 int i, err = 0;
164157 const cpumask_t *cpumask;
165158 unsigned int state_idx = start_idx;
....@@ -176,9 +169,15 @@
176169 cpu_node = of_cpu_device_node_get(cpumask_first(cpumask));
177170
178171 for (i = 0; ; i++) {
179
- state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i);
172
+ state_node = of_get_cpu_state_node(cpu_node, i);
180173 if (!state_node)
181174 break;
175
+
176
+ match_id = of_match_node(matches, state_node);
177
+ if (!match_id) {
178
+ err = -ENODEV;
179
+ break;
180
+ }
182181
183182 if (!of_device_is_available(state_node)) {
184183 of_node_put(state_node);
....@@ -198,7 +197,7 @@
198197 }
199198
200199 idle_state = &drv->states[state_idx++];
201
- err = init_state_node(idle_state, matches, state_node);
200
+ err = init_state_node(idle_state, match_id, state_node);
202201 if (err) {
203202 pr_err("Parsing idle state node %pOF failed with err %d\n",
204203 state_node, err);