Skip to content

Commit 8b0d345

Browse files
gmarullcfriedt
authored andcommitted
pm: device: use z_device_get_all_static
Use the internal function z_device_get_all_static helper function instead of using __device_start and __device_end directly. Some other minor adjustments have been done (e.g. reduce *dev scope to the for loop). An issue on the range of the for loop in _pm_devices has also been fixed. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 7e7b222 commit 8b0d345

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

subsys/pm/device.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#include <logging/log.h>
1515
LOG_MODULE_DECLARE(power);
1616

17-
extern const struct device __device_start[];
18-
extern const struct device __device_end[];
19-
2017
#if defined(CONFIG_PM)
2118
extern const struct device *__pm_device_slots_start[];
2219

@@ -25,10 +22,14 @@ static size_t num_susp;
2522

2623
static int _pm_devices(enum pm_device_state state)
2724
{
28-
const struct device *dev;
25+
const struct device *devs;
26+
size_t devc;
27+
28+
devc = z_device_get_all_static(&devs);
29+
2930
num_susp = 0;
3031

31-
for (dev = (__device_end - 1); dev > __device_start; dev--) {
32+
for (const struct device *dev = devs + devc - 1; dev >= devs; dev--) {
3233
int ret;
3334

3435
/* ignore busy devices */
@@ -177,13 +178,15 @@ int pm_device_state_get(const struct device *dev,
177178

178179
bool pm_device_is_any_busy(void)
179180
{
180-
const struct device *dev = __device_start;
181+
const struct device *devs;
182+
size_t devc;
183+
184+
devc = z_device_get_all_static(&devs);
181185

182-
while (dev < __device_end) {
186+
for (const struct device *dev = devs; dev < (devs + devc); dev++) {
183187
if (atomic_test_bit(dev->pm->flags, PM_DEVICE_FLAG_BUSY)) {
184188
return true;
185189
}
186-
++dev;
187190
}
188191

189192
return false;

0 commit comments

Comments
 (0)