diff options
| author | Ulf Hansson <ulf.hansson@linaro.org> | 2019-04-10 04:20:23 -0400 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-04-12 04:59:37 -0400 |
| commit | 0865d20c50741e1d37d4a1108764e5e45a83973e (patch) | |
| tree | e56d052d6b47bfce9e317db78a21f7aef599d857 | |
| parent | f0f6ad9092601d95729ce14ec6da3b5055e18714 (diff) | |
drivers: firmware: psci: Split psci_dt_cpu_init_idle()
Split the psci_dt_cpu_init_idle() function into two functions. This
makes the code clearer and provides better re-usability.
Co-developed-by: Lina Iyer <lina.iyer@linaro.org>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
| -rw-r--r-- | drivers/firmware/psci/psci.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index c80ec1d03274..9788bfc1cf8b 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c | |||
| @@ -270,9 +270,26 @@ static int __init psci_features(u32 psci_func_id) | |||
| 270 | #ifdef CONFIG_CPU_IDLE | 270 | #ifdef CONFIG_CPU_IDLE |
| 271 | static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); | 271 | static DEFINE_PER_CPU_READ_MOSTLY(u32 *, psci_power_state); |
| 272 | 272 | ||
| 273 | static int psci_dt_parse_state_node(struct device_node *np, u32 *state) | ||
| 274 | { | ||
| 275 | int err = of_property_read_u32(np, "arm,psci-suspend-param", state); | ||
| 276 | |||
| 277 | if (err) { | ||
| 278 | pr_warn("%pOF missing arm,psci-suspend-param property\n", np); | ||
| 279 | return err; | ||
| 280 | } | ||
| 281 | |||
| 282 | if (!psci_power_state_is_valid(*state)) { | ||
| 283 | pr_warn("Invalid PSCI power state %#x\n", *state); | ||
| 284 | return -EINVAL; | ||
| 285 | } | ||
| 286 | |||
| 287 | return 0; | ||
| 288 | } | ||
| 289 | |||
| 273 | static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) | 290 | static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) |
| 274 | { | 291 | { |
| 275 | int i, ret, count = 0; | 292 | int i, ret = 0, count = 0; |
| 276 | u32 *psci_states; | 293 | u32 *psci_states; |
| 277 | struct device_node *state_node; | 294 | struct device_node *state_node; |
| 278 | 295 | ||
| @@ -291,29 +308,16 @@ static int psci_dt_cpu_init_idle(struct device_node *cpu_node, int cpu) | |||
| 291 | return -ENOMEM; | 308 | return -ENOMEM; |
| 292 | 309 | ||
| 293 | for (i = 0; i < count; i++) { | 310 | for (i = 0; i < count; i++) { |
| 294 | u32 state; | ||
| 295 | |||
| 296 | state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); | 311 | state_node = of_parse_phandle(cpu_node, "cpu-idle-states", i); |
| 312 | ret = psci_dt_parse_state_node(state_node, &psci_states[i]); | ||
| 313 | of_node_put(state_node); | ||
| 297 | 314 | ||
| 298 | ret = of_property_read_u32(state_node, | 315 | if (ret) |
| 299 | "arm,psci-suspend-param", | ||
| 300 | &state); | ||
| 301 | if (ret) { | ||
| 302 | pr_warn(" * %pOF missing arm,psci-suspend-param property\n", | ||
| 303 | state_node); | ||
| 304 | of_node_put(state_node); | ||
| 305 | goto free_mem; | 316 | goto free_mem; |
| 306 | } | ||
| 307 | 317 | ||
| 308 | of_node_put(state_node); | 318 | pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); |
| 309 | pr_debug("psci-power-state %#x index %d\n", state, i); | ||
| 310 | if (!psci_power_state_is_valid(state)) { | ||
| 311 | pr_warn("Invalid PSCI power state %#x\n", state); | ||
| 312 | ret = -EINVAL; | ||
| 313 | goto free_mem; | ||
| 314 | } | ||
| 315 | psci_states[i] = state; | ||
| 316 | } | 319 | } |
| 320 | |||
| 317 | /* Idle states parsed correctly, initialize per-cpu pointer */ | 321 | /* Idle states parsed correctly, initialize per-cpu pointer */ |
| 318 | per_cpu(psci_power_state, cpu) = psci_states; | 322 | per_cpu(psci_power_state, cpu) = psci_states; |
| 319 | return 0; | 323 | return 0; |
