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 <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-10-27 13:39:12 +02:00 committed by Carles Cufí
parent e3ce7859db
commit faa06ac4b1
5 changed files with 17 additions and 14 deletions

View File

@ -15,6 +15,10 @@ menuconfig PM
if PM
module = PM
module-str = System Power Management
source "subsys/logging/Kconfig.template.log_config"
config PM_STATS
bool "System Power Management Stats"
depends on STATS
@ -23,11 +27,6 @@ config PM_STATS
source "subsys/pm/policy/Kconfig"
module = PM
module-str = System Power Management
source "subsys/logging/Kconfig.template.log_config"
endif # PM
config HAS_NO_SYS_PM
@ -49,11 +48,19 @@ config PM_DEVICE
like turning off device clocks and peripherals. The device drivers
may also save and restore states in these hook functions.
if PM_DEVICE
module = PM_DEVICE
module-str = Device Power Management
source "subsys/logging/Kconfig.template.log_config"
config PM_DEVICE_RUNTIME
bool "Runtime Device Power Management"
depends on PM_DEVICE
help
Enable Runtime Power Management to save power. With device runtime PM
enabled, devices can be suspended or resumed based on the device
usage even while the CPU or system is running.
endif # PM_DEVICE
endmenu

View File

@ -7,9 +7,8 @@
#include <device.h>
#include <pm/device.h>
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
#include <logging/log.h>
LOG_MODULE_DECLARE(power);
LOG_MODULE_REGISTER(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
#if defined(CONFIG_PM_DEVICE)
extern const struct device *__pm_device_slots_start[];

View File

@ -7,9 +7,8 @@
#include <sys/__assert.h>
#include <pm/device_runtime.h>
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
#include <logging/log.h>
LOG_MODULE_DECLARE(power);
LOG_MODULE_DECLARE(pm_device, CONFIG_PM_DEVICE_LOG_LEVEL);
/* Device PM request type */
#define PM_DEVICE_SYNC BIT(0)

View File

@ -10,9 +10,8 @@
#include <sys/atomic.h>
#include <pm/state.h>
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
#include <logging/log.h>
LOG_MODULE_DECLARE(power);
LOG_MODULE_DECLARE(pm, CONFIG_PM_LOG_LEVEL);
#define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)

View File

@ -17,9 +17,8 @@
#include "pm_priv.h"
#define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(power);
LOG_MODULE_REGISTER(pm, CONFIG_PM_LOG_LEVEL);
static int post_ops_done = 1;
static struct pm_state_info z_power_state;