hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/cpuidle/cpuidle-arm.c
....@@ -1,16 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ARM/ARM64 generic CPU idle driver.
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) "CPUidle arm: " fmt
1310
11
+#include <linux/cpu_cooling.h>
1412 #include <linux/cpuidle.h>
1513 #include <linux/cpumask.h>
1614 #include <linux/cpu_pm.h>
....@@ -18,7 +16,6 @@
1816 #include <linux/module.h>
1917 #include <linux/of.h>
2018 #include <linux/slab.h>
21
-#include <linux/topology.h>
2219
2320 #include <asm/cpuidle.h>
2421
....@@ -82,7 +79,6 @@
8279 {
8380 int ret;
8481 struct cpuidle_driver *drv;
85
- struct cpuidle_device *dev;
8682
8783 drv = kmemdup(&arm_idle_driver, sizeof(*drv), GFP_KERNEL);
8884 if (!drv)
....@@ -110,42 +106,29 @@
110106 ret = arm_cpuidle_init(cpu);
111107
112108 /*
113
- * Allow the initialization to continue for other CPUs, if the reported
114
- * failure is a HW misconfiguration/breakage (-ENXIO).
109
+ * Allow the initialization to continue for other CPUs, if the
110
+ * reported failure is a HW misconfiguration/breakage (-ENXIO).
111
+ *
112
+ * Some platforms do not support idle operations
113
+ * (arm_cpuidle_init() returning -EOPNOTSUPP), we should
114
+ * not flag this case as an error, it is a valid
115
+ * configuration.
115116 */
116117 if (ret) {
117
- pr_err("CPU %d failed to init idle CPU ops\n", cpu);
118
+ if (ret != -EOPNOTSUPP)
119
+ pr_err("CPU %d failed to init idle CPU ops\n", cpu);
118120 ret = ret == -ENXIO ? 0 : ret;
119121 goto out_kfree_drv;
120122 }
121123
122
- ret = cpuidle_register_driver(drv);
123
- if (ret) {
124
- if (ret != -EBUSY)
125
- pr_err("Failed to register cpuidle driver\n");
124
+ ret = cpuidle_register(drv, NULL);
125
+ if (ret)
126126 goto out_kfree_drv;
127
- }
128127
129
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
130
- if (!dev) {
131
- ret = -ENOMEM;
132
- goto out_unregister_drv;
133
- }
134
- dev->cpu = cpu;
135
-
136
- ret = cpuidle_register_device(dev);
137
- if (ret) {
138
- pr_err("Failed to register cpuidle device for CPU %d\n",
139
- cpu);
140
- goto out_kfree_dev;
141
- }
128
+ cpuidle_cooling_register(drv);
142129
143130 return 0;
144131
145
-out_kfree_dev:
146
- kfree(dev);
147
-out_unregister_drv:
148
- cpuidle_unregister_driver(drv);
149132 out_kfree_drv:
150133 kfree(drv);
151134 return ret;
....@@ -176,9 +159,7 @@
176159 while (--cpu >= 0) {
177160 dev = per_cpu(cpuidle_devices, cpu);
178161 drv = cpuidle_get_cpu_driver(dev);
179
- cpuidle_unregister_device(dev);
180
- cpuidle_unregister_driver(drv);
181
- kfree(dev);
162
+ cpuidle_unregister(drv);
182163 kfree(drv);
183164 }
184165