Skip to content

Commit faa06ac

Browse files
gmarullcarlescufi
authored andcommitted
pm: improve logging
List of improvements: - The PM logging module was only available if CONFIG_PM=y, however, it was also used by Device PM (which can be selected without PM). A new logging module has been created for Device PM. - Log level is passed to LOG_MODULE_(DECLARE|REGISTER) - Logger name has been adjusted to `pm` (was `power`) Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent e3ce785 commit faa06ac

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

subsys/pm/Kconfig

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ menuconfig PM
1515

1616
if PM
1717

18+
module = PM
19+
module-str = System Power Management
20+
source "subsys/logging/Kconfig.template.log_config"
21+
1822
config PM_STATS
1923
bool "System Power Management Stats"
2024
depends on STATS
@@ -23,11 +27,6 @@ config PM_STATS
2327

2428
source "subsys/pm/policy/Kconfig"
2529

26-
module = PM
27-
module-str = System Power Management
28-
source "subsys/logging/Kconfig.template.log_config"
29-
30-
3130
endif # PM
3231

3332
config HAS_NO_SYS_PM
@@ -49,11 +48,19 @@ config PM_DEVICE
4948
like turning off device clocks and peripherals. The device drivers
5049
may also save and restore states in these hook functions.
5150

51+
if PM_DEVICE
52+
53+
module = PM_DEVICE
54+
module-str = Device Power Management
55+
source "subsys/logging/Kconfig.template.log_config"
56+
5257
config PM_DEVICE_RUNTIME
5358
bool "Runtime Device Power Management"
54-
depends on PM_DEVICE
5559
help
5660
Enable Runtime Power Management to save power. With device runtime PM
5761
enabled, devices can be suspended or resumed based on the device
5862
usage even while the CPU or system is running.
63+
64+
endif # PM_DEVICE
65+
5966
endmenu

subsys/pm/device.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#include <device.h>
88
#include <pm/device.h>
99

10-
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
1110
#include <logging/log.h>
12-
LOG_MODULE_DECLARE(power);
11+
LOG_MODULE_REGISTER(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
1312

1413
#if defined(CONFIG_PM_DEVICE)
1514
extern const struct device *__pm_device_slots_start[];

subsys/pm/device_runtime.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
#include <sys/__assert.h>
88
#include <pm/device_runtime.h>
99

10-
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
1110
#include <logging/log.h>
12-
LOG_MODULE_DECLARE(power);
11+
LOG_MODULE_DECLARE(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
1312

1413
/* Device PM request type */
1514
#define PM_DEVICE_SYNC BIT(0)

subsys/pm/pm_ctrl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
#include <sys/atomic.h>
1111
#include <pm/state.h>
1212

13-
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
1413
#include <logging/log.h>
15-
LOG_MODULE_DECLARE(power);
14+
LOG_MODULE_DECLARE(pm, CONFIG_PM_LOG_LEVEL);
1615

1716
#define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)
1817

subsys/pm/power.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717
#include "pm_priv.h"
1818

1919
#define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)
20-
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL
2120
#include <logging/log.h>
22-
LOG_MODULE_REGISTER(power);
21+
LOG_MODULE_REGISTER(pm, CONFIG_PM_LOG_LEVEL);
2322

2423
static int post_ops_done = 1;
2524
static struct pm_state_info z_power_state;

0 commit comments

Comments
 (0)