From 39f21dc11627e7c457beccfe737a2939f897d092 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 22 Oct 2021 10:40:08 +0200 Subject: [PATCH] tests: pm: use new PM macros Use PM_DEVICE_STATE_DEFINE to define PM state. Signed-off-by: Gerard Marull-Paretas --- tests/benchmarks/footprints/src/pm_device.c | 4 +++- tests/kernel/device/src/dummy_driver.c | 4 +++- tests/net/pm/src/main.c | 4 +++- tests/subsys/pm/device_runtime_api/src/test_driver.c | 4 +++- tests/subsys/pm/power_mgmt/src/dummy_driver.c | 6 ++++-- tests/subsys/pm/power_mgmt/src/main.c | 12 +++++++++--- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/benchmarks/footprints/src/pm_device.c b/tests/benchmarks/footprints/src/pm_device.c index 09e6b6f088e..1b0f6b5f9b9 100644 --- a/tests/benchmarks/footprints/src/pm_device.c +++ b/tests/benchmarks/footprints/src/pm_device.c @@ -28,8 +28,10 @@ static int dummy_device_pm_action(const struct device *dev, } /* Define a driver with and without power management enabled */ +PM_DEVICE_DEFINE(dummy_pm_driver, dummy_device_pm_action); + DEVICE_DEFINE(dummy_pm_driver, DUMMY_PM_DRIVER_NAME, &dummy_init, - dummy_device_pm_action, NULL, NULL, APPLICATION, + PM_DEVICE_REF(dummy_pm_driver), NULL, NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL); DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, &dummy_init, diff --git a/tests/kernel/device/src/dummy_driver.c b/tests/kernel/device/src/dummy_driver.c index a6dcd2c2fb3..39e5783c067 100644 --- a/tests/kernel/device/src/dummy_driver.c +++ b/tests/kernel/device/src/dummy_driver.c @@ -40,8 +40,10 @@ int dummy_pm_action(const struct device *dev, enum pm_device_action action) /** * @cond INTERNAL_HIDDEN */ +PM_DEVICE_DEFINE(dummy_driver, dummy_pm_action); + DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, dummy_init, - dummy_pm_action, NULL, NULL, POST_KERNEL, + PM_DEVICE_REF(dummy_driver), NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs); /** diff --git a/tests/net/pm/src/main.c b/tests/net/pm/src/main.c index 70c6ad8e398..d7d6e5a5a55 100644 --- a/tests/net/pm/src/main.c +++ b/tests/net/pm/src/main.c @@ -99,8 +99,10 @@ static struct dummy_api fake_dev_if_api = { #define _ETH_L2_LAYER DUMMY_L2 #define _ETH_L2_CTX_TYPE NET_L2_GET_CTX_TYPE(DUMMY_L2) +PM_DEVICE_DEFINE(fake_dev, fake_dev_pm_action); + NET_DEVICE_INIT(fake_dev, "fake_dev", - fake_dev_init, fake_dev_pm_action, + fake_dev_init, PM_DEVICE_REF(fake_dev), &fake_dev_context_data, NULL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &fake_dev_if_api, _ETH_L2_LAYER, _ETH_L2_CTX_TYPE, 127); diff --git a/tests/subsys/pm/device_runtime_api/src/test_driver.c b/tests/subsys/pm/device_runtime_api/src/test_driver.c index bc476e9b7b6..332931b8a70 100644 --- a/tests/subsys/pm/device_runtime_api/src/test_driver.c +++ b/tests/subsys/pm/device_runtime_api/src/test_driver.c @@ -61,8 +61,10 @@ int test_driver_init(const struct device *dev) return 0; } +PM_DEVICE_DEFINE(test_driver, test_driver_action); + static struct test_driver_data data; DEVICE_DEFINE(test_driver, "test_driver", &test_driver_init, - test_driver_action, &data, NULL, POST_KERNEL, + PM_DEVICE_REF(test_driver), &data, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL); diff --git a/tests/subsys/pm/power_mgmt/src/dummy_driver.c b/tests/subsys/pm/power_mgmt/src/dummy_driver.c index 9909b20a0ee..cf84701fae2 100644 --- a/tests/subsys/pm/power_mgmt/src/dummy_driver.c +++ b/tests/subsys/pm/power_mgmt/src/dummy_driver.c @@ -36,6 +36,8 @@ int dummy_init(const struct device *dev) return 0; } +PM_DEVICE_DEFINE(dummy_driver, dummy_device_pm_action); + DEVICE_DEFINE(dummy_driver, DUMMY_DRIVER_NAME, &dummy_init, - dummy_device_pm_action, NULL, NULL, APPLICATION, - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs); + PM_DEVICE_REF(dummy_driver), NULL, NULL, APPLICATION, + CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs); diff --git a/tests/subsys/pm/power_mgmt/src/main.c b/tests/subsys/pm/power_mgmt/src/main.c index b55ab526013..2e2a3b326a8 100644 --- a/tests/subsys/pm/power_mgmt/src/main.c +++ b/tests/subsys/pm/power_mgmt/src/main.c @@ -70,8 +70,10 @@ static int device_a_pm_action(const struct device *dev, return 0; } +PM_DEVICE_DT_DEFINE(DT_INST(0, test_device_pm), device_a_pm_action); + DEVICE_DT_DEFINE(DT_INST(0, test_device_pm), device_init, - device_a_pm_action, NULL, NULL, + PM_DEVICE_DT_REF(DT_INST(0, test_device_pm)), NULL, NULL, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL); @@ -113,8 +115,10 @@ static int device_b_pm_action(const struct device *dev, return 0; } +PM_DEVICE_DT_DEFINE(DT_INST(1, test_device_pm), device_b_pm_action); + DEVICE_DT_DEFINE(DT_INST(1, test_device_pm), device_init, - device_b_pm_action, NULL, NULL, + PM_DEVICE_DT_REF(DT_INST(1, test_device_pm)), NULL, NULL, PRE_KERNEL_2, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL); @@ -127,8 +131,10 @@ static int device_c_pm_action(const struct device *dev, return 0; } +PM_DEVICE_DT_DEFINE(DT_INST(2, test_device_pm), device_c_pm_action); + DEVICE_DT_DEFINE(DT_INST(2, test_device_pm), device_init, - device_c_pm_action, NULL, NULL, + PM_DEVICE_DT_REF(DT_INST(2, test_device_pm)), NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, NULL);