pm: Remove unused fields in pm_device

Several fields on struct pm_device are just necessary when
built with PM_DEVICE_RUNTIME.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-10-06 23:56:37 -07:00 committed by Christopher Friedt
commit 893977f3b4

View file

@ -86,6 +86,7 @@ enum pm_device_action {
* @brief Device PM info * @brief Device PM info
*/ */
struct pm_device { struct pm_device {
#ifdef CONFIG_PM_DEVICE_RUNTIME
/** Pointer to the device */ /** Pointer to the device */
const struct device *dev; const struct device *dev;
/** Lock to synchronize the get/put operations */ /** Lock to synchronize the get/put operations */
@ -93,18 +94,28 @@ struct pm_device {
/* Following are packed fields protected by #lock. */ /* Following are packed fields protected by #lock. */
/** Device pm enable flag */ /** Device pm enable flag */
bool enable : 1; bool enable : 1;
/* Device PM status flags. */
atomic_t flags;
/** Device usage count */ /** Device usage count */
uint32_t usage; uint32_t usage;
/** Device power state */
enum pm_device_state state;
/** Work object for asynchronous calls */ /** Work object for asynchronous calls */
struct k_work_delayable work; struct k_work_delayable work;
/** Event conditional var to listen to the sync request events */ /** Event conditional var to listen to the sync request events */
struct k_condvar condvar; struct k_condvar condvar;
#endif /* CONFIG_PM_DEVICE_RUNTIME */
/* Device PM status flags. */
atomic_t flags;
/** Device power state */
enum pm_device_state state;
}; };
#ifdef CONFIG_PM_DEVICE_RUNTIME
#define INIT_PM_DEVICE_RUNTIME(obj) \
.usage = 0U, \
.lock = Z_MUTEX_INITIALIZER(obj.lock), \
.condvar = Z_CONDVAR_INITIALIZER(obj.condvar),
#else
#define INIT_PM_DEVICE_RUNTIME(obj)
#endif /* CONFIG_PM_DEVICE_RUNTIME */
/** /**
* @brief Utility macro to initialize #pm_device. * @brief Utility macro to initialize #pm_device.
* *
@ -116,9 +127,7 @@ struct pm_device {
*/ */
#define Z_PM_DEVICE_INIT(obj, node_id) \ #define Z_PM_DEVICE_INIT(obj, node_id) \
{ \ { \
.usage = 0U, \ INIT_PM_DEVICE_RUNTIME(obj) \
.lock = Z_MUTEX_INITIALIZER(obj.lock), \
.condvar = Z_CONDVAR_INITIALIZER(obj.condvar), \
.state = PM_DEVICE_STATE_ACTIVE, \ .state = PM_DEVICE_STATE_ACTIVE, \
.flags = ATOMIC_INIT(COND_CODE_1( \ .flags = ATOMIC_INIT(COND_CODE_1( \
DT_NODE_EXISTS(node_id), \ DT_NODE_EXISTS(node_id), \