Skip to content

Commit ee7c34c

Browse files
storulfrafaeljw
authored andcommitted
cpuidle: psci: Convert PM domain to platform driver
To enable support for deferred probing and to allow implementation of the ->sync_state() callback from subsequent changes, let's convert into a platform driver. Reviewed-by: Lina Iyer <[email protected]> Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 166bf83 commit ee7c34c

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

drivers/cpuidle/cpuidle-psci-domain.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/cpu.h>
1313
#include <linux/device.h>
1414
#include <linux/kernel.h>
15+
#include <linux/platform_device.h>
1516
#include <linux/pm_domain.h>
1617
#include <linux/pm_runtime.h>
1718
#include <linux/psci.h>
@@ -42,8 +43,8 @@ static int psci_pd_power_off(struct generic_pm_domain *pd)
4243
return 0;
4344
}
4445

45-
static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states,
46-
int state_count)
46+
static int psci_pd_parse_state_nodes(struct genpd_power_state *states,
47+
int state_count)
4748
{
4849
int i, ret;
4950
u32 psci_state, *psci_state_buf;
@@ -72,7 +73,7 @@ static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states,
7273
return ret;
7374
}
7475

75-
static int __init psci_pd_parse_states(struct device_node *np,
76+
static int psci_pd_parse_states(struct device_node *np,
7677
struct genpd_power_state **states, int *state_count)
7778
{
7879
int ret;
@@ -100,7 +101,7 @@ static void psci_pd_free_states(struct genpd_power_state *states,
100101
kfree(states);
101102
}
102103

103-
static int __init psci_pd_init(struct device_node *np)
104+
static int psci_pd_init(struct device_node *np)
104105
{
105106
struct generic_pm_domain *pd;
106107
struct psci_pd_provider *pd_provider;
@@ -167,7 +168,7 @@ static int __init psci_pd_init(struct device_node *np)
167168
return ret;
168169
}
169170

170-
static void __init psci_pd_remove(void)
171+
static void psci_pd_remove(void)
171172
{
172173
struct psci_pd_provider *pd_provider, *it;
173174
struct generic_pm_domain *genpd;
@@ -185,7 +186,7 @@ static void __init psci_pd_remove(void)
185186
}
186187
}
187188

188-
static int __init psci_pd_init_topology(struct device_node *np, bool add)
189+
static int psci_pd_init_topology(struct device_node *np, bool add)
189190
{
190191
struct device_node *node;
191192
struct of_phandle_args child, parent;
@@ -211,24 +212,24 @@ static int __init psci_pd_init_topology(struct device_node *np, bool add)
211212
return 0;
212213
}
213214

214-
static int __init psci_pd_add_topology(struct device_node *np)
215+
static int psci_pd_add_topology(struct device_node *np)
215216
{
216217
return psci_pd_init_topology(np, true);
217218
}
218219

219-
static void __init psci_pd_remove_topology(struct device_node *np)
220+
static void psci_pd_remove_topology(struct device_node *np)
220221
{
221222
psci_pd_init_topology(np, false);
222223
}
223224

224-
static const struct of_device_id psci_of_match[] __initconst = {
225+
static const struct of_device_id psci_of_match[] = {
225226
{ .compatible = "arm,psci-1.0" },
226227
{}
227228
};
228229

229-
static int __init psci_idle_init_domains(void)
230+
static int psci_cpuidle_domain_probe(struct platform_device *pdev)
230231
{
231-
struct device_node *np = of_find_matching_node(NULL, psci_of_match);
232+
struct device_node *np = pdev->dev.of_node;
232233
struct device_node *node;
233234
int ret = 0, pd_count = 0;
234235

@@ -237,7 +238,7 @@ static int __init psci_idle_init_domains(void)
237238

238239
/* Currently limit the hierarchical topology to be used in OSI mode. */
239240
if (!psci_has_osi_support())
240-
goto out;
241+
return 0;
241242

242243
/*
243244
* Parse child nodes for the "#power-domain-cells" property and
@@ -256,7 +257,7 @@ static int __init psci_idle_init_domains(void)
256257

257258
/* Bail out if not using the hierarchical CPU topology. */
258259
if (!pd_count)
259-
goto out;
260+
return 0;
260261

261262
/* Link genpd masters/subdomains to model the CPU topology. */
262263
ret = psci_pd_add_topology(np);
@@ -271,20 +272,30 @@ static int __init psci_idle_init_domains(void)
271272
goto remove_pd;
272273
}
273274

274-
of_node_put(np);
275275
pr_info("Initialized CPU PM domain topology\n");
276-
return pd_count;
276+
return 0;
277277

278278
put_node:
279279
of_node_put(node);
280280
remove_pd:
281281
if (pd_count)
282282
psci_pd_remove();
283283
pr_err("failed to create CPU PM domains ret=%d\n", ret);
284-
out:
285-
of_node_put(np);
286284
return ret;
287285
}
286+
287+
static struct platform_driver psci_cpuidle_domain_driver = {
288+
.probe = psci_cpuidle_domain_probe,
289+
.driver = {
290+
.name = "psci-cpuidle-domain",
291+
.of_match_table = psci_of_match,
292+
},
293+
};
294+
295+
static int __init psci_idle_init_domains(void)
296+
{
297+
return platform_driver_register(&psci_cpuidle_domain_driver);
298+
}
288299
subsys_initcall(psci_idle_init_domains);
289300

290301
struct device *psci_dt_attach_cpu(int cpu)

0 commit comments

Comments
 (0)