From 89a4f36fc83fc7e709f49f1f5cc47a178fef5df1 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Fri, 26 Nov 2021 12:53:15 +0100 Subject: [PATCH] device: remove inclusion of pm/device.h The device PM subsystem _depends_ on device, not vice-versa. Devices only hold a reference to struct pm_device now, and initialize this reference with the value provided in Z_DEVICE_DEFINE. This requirement can be solved with a forward struct declaration, meaning there is no need to include device PM headers. Signed-off-by: Gerard Marull-Paretas --- drivers/display/display_st7735r.c | 1 + drivers/display/display_st7789v.c | 1 + drivers/entropy/entropy_neorv32_trng.c | 1 + drivers/ethernet/eth_mcux.c | 1 + drivers/flash/nrf_qspi_nor.c | 1 + drivers/flash/spi_flash_at45.c | 1 + drivers/gpio/gpio_dw.c | 1 + drivers/i2c/i2c_dw.c | 1 + drivers/i2c/i2c_nrfx_twi.c | 1 + drivers/i2c/i2c_nrfx_twim.c | 1 + drivers/interrupt_controller/intc_ioapic.c | 1 + drivers/interrupt_controller/intc_loapic.c | 1 + drivers/led/led_pwm.c | 1 + drivers/modem/modem_receiver.c | 1 + drivers/pwm/pwm_nrfx.c | 1 + drivers/sensor/apds9960/apds9960.c | 1 + drivers/sensor/bme280/bme280.c | 1 + drivers/sensor/bmp388/bmp388.c | 1 + drivers/sensor/bmp388/bmp388_trigger.c | 1 + drivers/sensor/bq274xx/bq274xx.c | 1 + drivers/sensor/fdc2x1x/fdc2x1x.c | 1 + drivers/sensor/ina219/ina219.c | 1 + drivers/sensor/lis2mdl/lis2mdl.c | 1 + drivers/sensor/lm77/lm77.c | 1 + drivers/sensor/qdec_nrfx/qdec_nrfx.c | 1 + drivers/sensor/sgp40/sgp40.c | 1 + drivers/sensor/si7210/si7210.c | 1 + drivers/sensor/vcnl4040/vcnl4040.c | 1 + drivers/serial/uart_neorv32.c | 1 + drivers/serial/uart_nrfx_uart.c | 1 + drivers/serial/uart_nrfx_uarte.c | 2 +- drivers/spi/spi_dw.c | 1 + drivers/spi/spi_nrfx_spi.c | 1 + drivers/spi/spi_nrfx_spim.c | 1 + include/device.h | 3 ++- include/pm/device.h | 1 + samples/boards/nrf/system_off/src/main.c | 1 + samples/subsys/pm/device_pm/src/dummy_driver.c | 1 + samples/subsys/pm/device_pm/src/dummy_parent.c | 1 + subsys/net/ip/net_shell.c | 1 + subsys/shell/modules/device_service.c | 1 + tests/net/pm/src/main.c | 1 + tests/subsys/pm/device_runtime_api/src/test_driver.c | 1 + tests/subsys/pm/device_wakeup_api/src/main.c | 2 +- tests/subsys/pm/power_mgmt/src/dummy_driver.c | 1 + 45 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/display/display_st7735r.c b/drivers/display/display_st7735r.c index 0678769eac4..aaa2002e712 100644 --- a/drivers/display/display_st7735r.c +++ b/drivers/display/display_st7735r.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/drivers/display/display_st7789v.c b/drivers/display/display_st7789v.c index 032170df8a4..3b999a314e7 100644 --- a/drivers/display/display_st7789v.c +++ b/drivers/display/display_st7789v.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/drivers/entropy/entropy_neorv32_trng.c b/drivers/entropy/entropy_neorv32_trng.c index 345871ac1af..eb217430de1 100644 --- a/drivers/entropy/entropy_neorv32_trng.c +++ b/drivers/entropy/entropy_neorv32_trng.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c index c3c53bcbaa0..0ea730b1759 100644 --- a/drivers/ethernet/eth_mcux.c +++ b/drivers/ethernet/eth_mcux.c @@ -30,6 +30,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #include #include +#include #if defined(CONFIG_PTP_CLOCK_MCUX) #include diff --git a/drivers/flash/nrf_qspi_nor.c b/drivers/flash/nrf_qspi_nor.c index 6f6914eab77..0793a86a35e 100644 --- a/drivers/flash/nrf_qspi_nor.c +++ b/drivers/flash/nrf_qspi_nor.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include LOG_MODULE_REGISTER(qspi_nor, CONFIG_FLASH_LOG_LEVEL); diff --git a/drivers/flash/spi_flash_at45.c b/drivers/flash/spi_flash_at45.c index 91192941129..0a4bb471a74 100644 --- a/drivers/flash/spi_flash_at45.c +++ b/drivers/flash/spi_flash_at45.c @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/drivers/gpio/gpio_dw.c b/drivers/gpio/gpio_dw.c index 3fe2c31b188..7ff6876f942 100644 --- a/drivers/gpio/gpio_dw.c +++ b/drivers/gpio/gpio_dw.c @@ -13,6 +13,7 @@ #include "gpio_dw.h" #include "gpio_utils.h" +#include #include #include #include diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c index b0227965f9e..7e79bd95826 100644 --- a/drivers/i2c/i2c_dw.c +++ b/drivers/i2c/i2c_dw.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/drivers/i2c/i2c_nrfx_twi.c b/drivers/i2c/i2c_nrfx_twi.c index 972c405d6b4..ad9784afe0a 100644 --- a/drivers/i2c/i2c_nrfx_twi.c +++ b/drivers/i2c/i2c_nrfx_twi.c @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/drivers/i2c/i2c_nrfx_twim.c b/drivers/i2c/i2c_nrfx_twim.c index 23cacc5494e..2db76890926 100644 --- a/drivers/i2c/i2c_nrfx_twim.c +++ b/drivers/i2c/i2c_nrfx_twim.c @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/drivers/interrupt_controller/intc_ioapic.c b/drivers/interrupt_controller/intc_ioapic.c index 60f6ce040bc..4e792aa41a2 100644 --- a/drivers/interrupt_controller/intc_ioapic.c +++ b/drivers/interrupt_controller/intc_ioapic.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include /* public API declarations */ diff --git a/drivers/interrupt_controller/intc_loapic.c b/drivers/interrupt_controller/intc_loapic.c index 73483175275..ed0a8ef387e 100644 --- a/drivers/interrupt_controller/intc_loapic.c +++ b/drivers/interrupt_controller/intc_loapic.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/led/led_pwm.c b/drivers/led/led_pwm.c index fb72d13ef6a..7e3e9d003bc 100644 --- a/drivers/led/led_pwm.c +++ b/drivers/led/led_pwm.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include diff --git a/drivers/modem/modem_receiver.c b/drivers/modem/modem_receiver.c index 0828e98eaff..051a04f3026 100644 --- a/drivers/modem/modem_receiver.c +++ b/drivers/modem/modem_receiver.c @@ -14,6 +14,7 @@ #include #include #include +#include #include diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 62664663941..e8a878c05dd 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -5,6 +5,7 @@ */ #include #include +#include #include #include diff --git a/drivers/sensor/apds9960/apds9960.c b/drivers/sensor/apds9960/apds9960.c index b9c98f96e94..9361a2a8093 100644 --- a/drivers/sensor/apds9960/apds9960.c +++ b/drivers/sensor/apds9960/apds9960.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/sensor/bme280/bme280.c b/drivers/sensor/bme280/bme280.c index 66810d00c6c..4d029ed396d 100644 --- a/drivers/sensor/bme280/bme280.c +++ b/drivers/sensor/bme280/bme280.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/drivers/sensor/bmp388/bmp388.c b/drivers/sensor/bmp388/bmp388.c index f1036507437..3ceecaccebe 100644 --- a/drivers/sensor/bmp388/bmp388.c +++ b/drivers/sensor/bmp388/bmp388.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "bmp388.h" diff --git a/drivers/sensor/bmp388/bmp388_trigger.c b/drivers/sensor/bmp388/bmp388_trigger.c index ff5af8d01a9..89069d72dcc 100644 --- a/drivers/sensor/bmp388/bmp388_trigger.c +++ b/drivers/sensor/bmp388/bmp388_trigger.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "bmp388.h" diff --git a/drivers/sensor/bq274xx/bq274xx.c b/drivers/sensor/bq274xx/bq274xx.c index f910da49fe4..18d4d96c27a 100644 --- a/drivers/sensor/bq274xx/bq274xx.c +++ b/drivers/sensor/bq274xx/bq274xx.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/sensor/fdc2x1x/fdc2x1x.c b/drivers/sensor/fdc2x1x/fdc2x1x.c index 352b59edc3c..a342bb4d43e 100644 --- a/drivers/sensor/fdc2x1x/fdc2x1x.c +++ b/drivers/sensor/fdc2x1x/fdc2x1x.c @@ -9,6 +9,7 @@ #define DT_DRV_COMPAT ti_fdc2x1x #include +#include #include #include #include diff --git a/drivers/sensor/ina219/ina219.c b/drivers/sensor/ina219/ina219.c index d127ee44fc7..25d26c24e4f 100644 --- a/drivers/sensor/ina219/ina219.c +++ b/drivers/sensor/ina219/ina219.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "ina219.h" diff --git a/drivers/sensor/lis2mdl/lis2mdl.c b/drivers/sensor/lis2mdl/lis2mdl.c index 7d521c0209c..08d6b55ed3b 100644 --- a/drivers/sensor/lis2mdl/lis2mdl.c +++ b/drivers/sensor/lis2mdl/lis2mdl.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include "lis2mdl.h" diff --git a/drivers/sensor/lm77/lm77.c b/drivers/sensor/lm77/lm77.c index 86bd5e1fc8e..23d55191a60 100644 --- a/drivers/sensor/lm77/lm77.c +++ b/drivers/sensor/lm77/lm77.c @@ -11,6 +11,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(lm77, CONFIG_SENSOR_LOG_LEVEL); diff --git a/drivers/sensor/qdec_nrfx/qdec_nrfx.c b/drivers/sensor/qdec_nrfx/qdec_nrfx.c index 70ce93d5ed5..6b6fa15c087 100644 --- a/drivers/sensor/qdec_nrfx/qdec_nrfx.c +++ b/drivers/sensor/qdec_nrfx/qdec_nrfx.c @@ -5,6 +5,7 @@ */ #include +#include #include #include diff --git a/drivers/sensor/sgp40/sgp40.c b/drivers/sensor/sgp40/sgp40.c index 909dceb2484..d9290e9cb3a 100644 --- a/drivers/sensor/sgp40/sgp40.c +++ b/drivers/sensor/sgp40/sgp40.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/drivers/sensor/si7210/si7210.c b/drivers/sensor/si7210/si7210.c index d2d131a5497..dc4b4eb6e3a 100644 --- a/drivers/sensor/si7210/si7210.c +++ b/drivers/sensor/si7210/si7210.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/sensor/vcnl4040/vcnl4040.c b/drivers/sensor/vcnl4040/vcnl4040.c index 1ce6a292418..ab2dd98e9c9 100644 --- a/drivers/sensor/vcnl4040/vcnl4040.c +++ b/drivers/sensor/vcnl4040/vcnl4040.c @@ -7,6 +7,7 @@ #define DT_DRV_COMPAT vishay_vcnl4040 #include "vcnl4040.h" +#include #include #include #include diff --git a/drivers/serial/uart_neorv32.c b/drivers/serial/uart_neorv32.c index d483023b1d7..c0513e68d5d 100644 --- a/drivers/serial/uart_neorv32.c +++ b/drivers/serial/uart_neorv32.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index d9d1849236e..75b5452bda4 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -9,6 +9,7 @@ */ #include +#include #include #ifdef CONFIG_PINCTRL diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 640920983bc..6a390deaee6 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -9,7 +9,7 @@ */ #include - +#include #include #include #include diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index e77f75bacc2..c931c637d7a 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -33,6 +33,7 @@ LOG_MODULE_REGISTER(spi_dw); #include #include #include +#include #include #include diff --git a/drivers/spi/spi_nrfx_spi.c b/drivers/spi/spi_nrfx_spi.c index 0863809faf1..a11ce60866a 100644 --- a/drivers/spi/spi_nrfx_spi.c +++ b/drivers/spi/spi_nrfx_spi.c @@ -5,6 +5,7 @@ */ #include +#include #include #define LOG_DOMAIN "spi_nrfx_spi" diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index 2ee1f575400..e434d68f3eb 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -5,6 +5,7 @@ */ #include +#include #ifdef CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58 #include #include diff --git a/include/device.h b/include/device.h index 87ba82505c2..b505fab8a40 100644 --- a/include/device.h +++ b/include/device.h @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -362,6 +361,8 @@ struct device_state { bool initialized : 1; }; +struct pm_device; + /** * @brief Runtime device structure (in ROM) per driver instance */ diff --git a/include/pm/device.h b/include/pm/device.h index 7878b140b16..8882d1f2edd 100644 --- a/include/pm/device.h +++ b/include/pm/device.h @@ -7,6 +7,7 @@ #ifndef ZEPHYR_INCLUDE_PM_DEVICE_H_ #define ZEPHYR_INCLUDE_PM_DEVICE_H_ +#include #include #include diff --git a/samples/boards/nrf/system_off/src/main.c b/samples/boards/nrf/system_off/src/main.c index 8988be0601b..91219edc19a 100644 --- a/samples/boards/nrf/system_off/src/main.c +++ b/samples/boards/nrf/system_off/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "retained.h" #include diff --git a/samples/subsys/pm/device_pm/src/dummy_driver.c b/samples/subsys/pm/device_pm/src/dummy_driver.c index 01736204c94..4df43c9022f 100644 --- a/samples/subsys/pm/device_pm/src/dummy_driver.c +++ b/samples/subsys/pm/device_pm/src/dummy_driver.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include "dummy_parent.h" diff --git a/samples/subsys/pm/device_pm/src/dummy_parent.c b/samples/subsys/pm/device_pm/src/dummy_parent.c index 8e6a5309629..fb3586c7f1c 100644 --- a/samples/subsys/pm/device_pm/src/dummy_parent.c +++ b/samples/subsys/pm/device_pm/src/dummy_parent.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include #include "dummy_parent.h" diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index 3f6260c0485..0a8a714fa36 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(net_shell, LOG_LEVEL_DBG); #include #include +#include #include #include #include diff --git a/subsys/shell/modules/device_service.c b/subsys/shell/modules/device_service.c index 367c3e08aec..c4c5c7567db 100644 --- a/subsys/shell/modules/device_service.c +++ b/subsys/shell/modules/device_service.c @@ -10,6 +10,7 @@ #include #include #include +#include #include extern const struct device __device_PRE_KERNEL_1_start[]; diff --git a/tests/net/pm/src/main.c b/tests/net/pm/src/main.c index c7167dfa831..2a10c94ddb7 100644 --- a/tests/net/pm/src/main.c +++ b/tests/net/pm/src/main.c @@ -8,6 +8,7 @@ #include #include +#include #include #include 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 332931b8a70..394e2e83e62 100644 --- a/tests/subsys/pm/device_runtime_api/src/test_driver.c +++ b/tests/subsys/pm/device_runtime_api/src/test_driver.c @@ -7,6 +7,7 @@ #include "test_driver.h" #include +#include struct test_driver_data { bool ongoing; diff --git a/tests/subsys/pm/device_wakeup_api/src/main.c b/tests/subsys/pm/device_wakeup_api/src/main.c index 54e4348def5..258a3fda104 100644 --- a/tests/subsys/pm/device_wakeup_api/src/main.c +++ b/tests/subsys/pm/device_wakeup_api/src/main.c @@ -6,8 +6,8 @@ #include #include -#include #include +#include #define DEV_NAME DT_NODELABEL(gpio0) diff --git a/tests/subsys/pm/power_mgmt/src/dummy_driver.c b/tests/subsys/pm/power_mgmt/src/dummy_driver.c index cf84701fae2..e8241a8890d 100644 --- a/tests/subsys/pm/power_mgmt/src/dummy_driver.c +++ b/tests/subsys/pm/power_mgmt/src/dummy_driver.c @@ -6,6 +6,7 @@ #include #include +#include #include #include "dummy_driver.h"