Skip to content

Commit 0782f9c

Browse files
mniestrojnashif
authored andcommitted
power: device: provide device_pm_state_str() with CONFIG_PM=n
So far device_pm_state_str() was built only when CONFIG_PM=y (former CONFIG_SYSTEM_POWER_MANAGEMENT=y). 'device list' shell command (CONFIG_DEVICE_SHELL=y) is using that function when CONFIG_PM_DEVICE=y. This resulted in build failures when CONFIG_PM=n, as linker could not find its implementation. Build device_pm_state_str() function regardless of CONFIG_PM value, so device shell module builds successfully in every case. Signed-off-by: Marcin Niestroj <[email protected]>
1 parent ae4e4b7 commit 0782f9c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

subsys/power/device.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,6 @@ static device_idx_t num_pm;
6060
/* Number of devices successfully suspended. */
6161
static device_idx_t num_susp;
6262

63-
const char *device_pm_state_str(uint32_t state)
64-
{
65-
switch (state) {
66-
case DEVICE_PM_ACTIVE_STATE:
67-
return "active";
68-
case DEVICE_PM_LOW_POWER_STATE:
69-
return "low power";
70-
case DEVICE_PM_SUSPEND_STATE:
71-
return "suspend";
72-
case DEVICE_PM_FORCE_SUSPEND_STATE:
73-
return "force suspend";
74-
case DEVICE_PM_OFF_STATE:
75-
return "off";
76-
default:
77-
return "";
78-
}
79-
}
80-
8163
static int _pm_devices(uint32_t state)
8264
{
8365
num_susp = 0;
@@ -183,3 +165,21 @@ void pm_create_device_list(void)
183165
}
184166
}
185167
#endif /* defined(CONFIG_PM) */
168+
169+
const char *device_pm_state_str(uint32_t state)
170+
{
171+
switch (state) {
172+
case DEVICE_PM_ACTIVE_STATE:
173+
return "active";
174+
case DEVICE_PM_LOW_POWER_STATE:
175+
return "low power";
176+
case DEVICE_PM_SUSPEND_STATE:
177+
return "suspend";
178+
case DEVICE_PM_FORCE_SUSPEND_STATE:
179+
return "force suspend";
180+
case DEVICE_PM_OFF_STATE:
181+
return "off";
182+
default:
183+
return "";
184+
}
185+
}

0 commit comments

Comments
 (0)