diff --git a/arch/arc/core/arc_smp.c b/arch/arc/core/arc_smp.c index 8232824ba5a341..80377e2fbc0ea4 100644 --- a/arch/arc/core/arc_smp.c +++ b/arch/arc/core/arc_smp.c @@ -108,7 +108,7 @@ void arch_sched_ipi(void) } } -static int arc_smp_init(struct device *dev) +static int arc_smp_init(const struct device *dev) { ARG_UNUSED(dev); struct arc_connect_bcr bcr; diff --git a/arch/arc/core/cache.c b/arch/arc/core/cache.c index 5e3604ab9687f8..d78abdbea4d073 100644 --- a/arch/arc/core/cache.c +++ b/arch/arc/core/cache.c @@ -149,7 +149,7 @@ size_t arch_cache_line_size_get(void) #endif } -static int init_dcache(struct device *unused) +static int init_dcache(const struct device *unused) { ARG_UNUSED(unused); diff --git a/arch/arc/core/mpu/arc_mpu_v2_internal.h b/arch/arc/core/mpu/arc_mpu_v2_internal.h index de28e3a0c6470d..a6e73f1c8bd349 100644 --- a/arch/arc/core/mpu/arc_mpu_v2_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v2_internal.h @@ -374,7 +374,7 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write) * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int arc_mpu_init(struct device *arg) +static int arc_mpu_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/arch/arc/core/mpu/arc_mpu_v3_internal.h b/arch/arc/core/mpu/arc_mpu_v3_internal.h index ad9ae921f431e8..196b3515d704f1 100644 --- a/arch/arc/core/mpu/arc_mpu_v3_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v3_internal.h @@ -824,7 +824,7 @@ int arc_core_mpu_buffer_validate(void *addr, size_t size, int write) * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int arc_mpu_init(struct device *arg) +static int arc_mpu_init(const struct device *arg) { ARG_UNUSED(arg); uint32_t num_regions; diff --git a/arch/arc/core/secureshield/arc_sjli.c b/arch/arc/core/secureshield/arc_sjli.c index 8a62b0bde25215..c82eab2ecffde9 100644 --- a/arch/arc/core/secureshield/arc_sjli.c +++ b/arch/arc/core/secureshield/arc_sjli.c @@ -48,7 +48,7 @@ static void sjli_table_init(void) /* * @brief initializaiton of secureshield related functions. */ -static int arc_secureshield_init(struct device *arg) +static int arc_secureshield_init(const struct device *arg) { sjli_table_init(); diff --git a/arch/arm/core/aarch32/cortex_m/mpu/arm_mpu.c b/arch/arm/core/aarch32/cortex_m/mpu/arm_mpu.c index 2c0a3bbffe1e49..0abd3dfc674f7d 100644 --- a/arch/arm/core/aarch32/cortex_m/mpu/arm_mpu.c +++ b/arch/arm/core/aarch32/cortex_m/mpu/arm_mpu.c @@ -300,7 +300,7 @@ void arm_core_mpu_configure_dynamic_mpu_regions(const struct k_mem_partition * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int arm_mpu_init(struct device *arg) +static int arm_mpu_init(const struct device *arg) { uint32_t r_index; diff --git a/arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c b/arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c index d15528a67641fd..5dd76f4ece8aa2 100644 --- a/arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c +++ b/arch/arm/core/aarch32/cortex_m/mpu/nxp_mpu.c @@ -598,7 +598,7 @@ void arm_core_mpu_configure_dynamic_mpu_regions(const struct k_mem_partition * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int nxp_mpu_init(struct device *arg) +static int nxp_mpu_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/arch/arm/core/aarch64/arm_mmu.c b/arch/arm/core/aarch64/arm_mmu.c index 8683e8b7dfd299..3807f1a19d9c72 100644 --- a/arch/arm/core/aarch64/arm_mmu.c +++ b/arch/arm/core/aarch64/arm_mmu.c @@ -426,7 +426,7 @@ static void enable_mmu_el1(unsigned int flags) * This function provides the default configuration mechanism for the Memory * Management Unit (MMU). */ -static int arm_mmu_init(struct device *arg) +static int arm_mmu_init(const struct device *arg) { uint64_t val; unsigned int idx, flags = 0; diff --git a/arch/x86/core/ia32/cache.c b/arch/x86/core/ia32/cache.c index 3c1b0cd7e7ccc3..732d7d2c4d7d21 100644 --- a/arch/x86/core/ia32/cache.c +++ b/arch/x86/core/ia32/cache.c @@ -86,7 +86,7 @@ size_t arch_cache_line_size_get(void) #endif } -static int init_cache(struct device *unused) +static int init_cache(const struct device *unused) { ARG_UNUSED(unused); diff --git a/arch/x86/core/multiboot.c b/arch/x86/core/multiboot.c index cb0d14a950d3fe..2cb81fed2efc76 100644 --- a/arch/x86/core/multiboot.c +++ b/arch/x86/core/multiboot.c @@ -109,7 +109,7 @@ static struct framebuf_dev_data multiboot_framebuf_data = { .height = CONFIG_MULTIBOOT_FRAMEBUF_Y }; -static int multiboot_framebuf_init(struct device *dev) +static int multiboot_framebuf_init(const struct device *dev) { struct framebuf_dev_data *data = FRAMEBUF_DATA(dev); struct multiboot_info *info = &multiboot_info; diff --git a/arch/x86/core/spec_ctrl.c b/arch/x86/core/spec_ctrl.c index 25a44d69ee97ad..6e19953ee59001 100644 --- a/arch/x86/core/spec_ctrl.c +++ b/arch/x86/core/spec_ctrl.c @@ -37,7 +37,7 @@ static uint32_t cpuid_extended_features(void) return edx; } -static int spec_ctrl_init(struct device *dev) +static int spec_ctrl_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index 46ccf10858fc1a..889b256cc23e72 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -408,7 +408,7 @@ void z_x86_dump_page_tables(pentry_t *ptables) #define DUMP_PAGE_TABLES 0 #if DUMP_PAGE_TABLES -static int dump_kernel_tables(struct device *unused) +static int dump_kernel_tables(const struct device *unused) { z_x86_dump_page_tables(&z_x86_kernel_ptables); diff --git a/boards/arc/em_starterkit/pmodmux.c b/boards/arc/em_starterkit/pmodmux.c index f41689b3d5cc07..7c875b1967e9a7 100644 --- a/boards/arc/em_starterkit/pmodmux.c +++ b/boards/arc/em_starterkit/pmodmux.c @@ -124,7 +124,7 @@ #define PM6_LR_CSS_STAT ((1 << BIT2) << PM6_OFFSET) -static int pmod_mux_init(struct device *device) +static int pmod_mux_init(const struct device *device) { volatile uint32_t *mux_regs = (uint32_t *)(PMODMUX_BASE_ADDR); diff --git a/boards/arc/hsdk/pinmux.c b/boards/arc/hsdk/pinmux.c index 9c38130d150533..1927fbc25eaf19 100644 --- a/boards/arc/hsdk/pinmux.c +++ b/boards/arc/hsdk/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int board_pinmux_init(struct device *device) +static int board_pinmux_init(const struct device *device) { ARG_UNUSED(device); - struct device *pinmux = device_get_binding(CONFIG_PINMUX_NAME); + const struct device *pinmux = device_get_binding(CONFIG_PINMUX_NAME); if (pinmux == NULL) { return -ENXIO; diff --git a/boards/arm/96b_aerocore2/pinmux.c b/boards/arm/96b_aerocore2/pinmux.c index 023dfe1ab216bf..7caaf7e30291aa 100644 --- a/boards/arm/96b_aerocore2/pinmux.c +++ b/boards/arm/96b_aerocore2/pinmux.c @@ -98,7 +98,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_argonkey/pinmux.c b/boards/arm/96b_argonkey/pinmux.c index 6ab9fec42fa00e..8854dcc4bfbc19 100644 --- a/boards/arm/96b_argonkey/pinmux.c +++ b/boards/arm/96b_argonkey/pinmux.c @@ -56,7 +56,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_avenger96/pinmux.c b/boards/arm/96b_avenger96/pinmux.c index 992bbb0e58de86..977a68ef03de03 100644 --- a/boards/arm/96b_avenger96/pinmux.c +++ b/boards/arm/96b_avenger96/pinmux.c @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_carbon/pinmux.c b/boards/arm/96b_carbon/pinmux.c index d283af8b9cf731..bfb75335b02165 100644 --- a/boards/arm/96b_carbon/pinmux.c +++ b/boards/arm/96b_carbon/pinmux.c @@ -56,7 +56,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_meerkat96/pinmux.c b/boards/arm/96b_meerkat96/pinmux.c index b985c10b81d8e9..ad797875c27427 100644 --- a/boards/arm/96b_meerkat96/pinmux.c +++ b/boards/arm/96b_meerkat96/pinmux.c @@ -7,7 +7,7 @@ #include #include "device_imx.h" -static int meerakt96_pinmux_init(struct device *dev) +static int meerakt96_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/96b_neonkey/pinmux.c b/boards/arm/96b_neonkey/pinmux.c index fbed1837c4fb6d..2199772d328eb7 100644 --- a/boards/arm/96b_neonkey/pinmux.c +++ b/boards/arm/96b_neonkey/pinmux.c @@ -40,7 +40,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_stm32_sensor_mez/pinmux.c b/boards/arm/96b_stm32_sensor_mez/pinmux.c index a0225ace59d0e0..82daff5bd0c82b 100644 --- a/boards/arm/96b_stm32_sensor_mez/pinmux.c +++ b/boards/arm/96b_stm32_sensor_mez/pinmux.c @@ -86,7 +86,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/96b_wistrio/pinmux.c b/boards/arm/96b_wistrio/pinmux.c index 9606c80df83dc5..a10b78d0ecbd8b 100644 --- a/boards/arm/96b_wistrio/pinmux.c +++ b/boards/arm/96b_wistrio/pinmux.c @@ -40,10 +40,10 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PB7, STM32_PUSHPULL_PULLUP}, }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); - struct device *gpioa, *gpiob, *gpioh; + const struct device *gpioa, *gpiob, *gpioh; stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf)); diff --git a/boards/arm/actinius_icarus/board.c b/boards/arm/actinius_icarus/board.c index b34f02432353b1..2579469b8ae1e2 100644 --- a/boards/arm/actinius_icarus/board.c +++ b/boards/arm/actinius_icarus/board.c @@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(board_control, CONFIG_BOARD_ICARUS_LOG_LEVEL); static void select_sim(void) { - struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); + const struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); if (!port) { LOG_ERR("Could not get GPIO Device Binding"); @@ -31,7 +31,7 @@ static void select_sim(void) #endif } -static int board_actinius_icarus_init(struct device *dev) +static int board_actinius_icarus_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/adafruit_feather_m0_basic_proto/pinmux.c b/boards/arm/adafruit_feather_m0_basic_proto/pinmux.c index c3a8caa570d0fa..3445e8f1852328 100644 --- a/boards/arm/adafruit_feather_m0_basic_proto/pinmux.c +++ b/boards/arm/adafruit_feather_m0_basic_proto/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); #if (ATMEL_SAM0_DT_SERCOM_CHECK(4, atmel_sam0_spi) && CONFIG_SPI_SAM0) - struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); #endif ARG_UNUSED(dev); diff --git a/boards/arm/adafruit_feather_stm32f405/pinmux.c b/boards/arm/adafruit_feather_stm32f405/pinmux.c index 501785290092b8..3eef255e5b6edd 100644 --- a/boards/arm/adafruit_feather_stm32f405/pinmux.c +++ b/boards/arm/adafruit_feather_stm32f405/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/adafruit_itsybitsy_m4_express/pinmux.c b/boards/arm/adafruit_itsybitsy_m4_express/pinmux.c index 5bb102678b67f6..7599c0e93d8fe7 100644 --- a/boards/arm/adafruit_itsybitsy_m4_express/pinmux.c +++ b/boards/arm/adafruit_itsybitsy_m4_express/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/adafruit_trinket_m0/pinmux.c b/boards/arm/adafruit_trinket_m0/pinmux.c index d8b1beec5812ad..60d7b1ad361f2e 100644 --- a/boards/arm/adafruit_trinket_m0/pinmux.c +++ b/boards/arm/adafruit_trinket_m0/pinmux.c @@ -8,9 +8,9 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); ARG_UNUSED(dev); diff --git a/boards/arm/arduino_nano_33_iot/pinmux.c b/boards/arm/arduino_nano_33_iot/pinmux.c index 223e78ab89acbc..fd283cc7d564d0 100644 --- a/boards/arm/arduino_nano_33_iot/pinmux.c +++ b/boards/arm/arduino_nano_33_iot/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/arduino_zero/pinmux.c b/boards/arm/arduino_zero/pinmux.c index f16f563a8cf99f..15f84e18393ddb 100644 --- a/boards/arm/arduino_zero/pinmux.c +++ b/boards/arm/arduino_zero/pinmux.c @@ -8,10 +8,10 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/atsamd20_xpro/pinmux.c b/boards/arm/atsamd20_xpro/pinmux.c index 0d5791419ca2aa..f7095ec6c8d5eb 100644 --- a/boards/arm/atsamd20_xpro/pinmux.c +++ b/boards/arm/atsamd20_xpro/pinmux.c @@ -8,10 +8,10 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/atsamd21_xpro/pinmux.c b/boards/arm/atsamd21_xpro/pinmux.c index 529f6a55ed14d1..d34d34594eadc3 100644 --- a/boards/arm/atsamd21_xpro/pinmux.c +++ b/boards/arm/atsamd21_xpro/pinmux.c @@ -8,10 +8,10 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/atsame54_xpro/pinmux.c b/boards/arm/atsame54_xpro/pinmux.c index 94bd38427afc75..28581770ce791b 100644 --- a/boards/arm/atsame54_xpro/pinmux.c +++ b/boards/arm/atsame54_xpro/pinmux.c @@ -8,12 +8,12 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding("PINMUX_A"); - struct device *muxb = device_get_binding("PINMUX_B"); - struct device *muxc = device_get_binding("PINMUX_C"); - struct device *muxd = device_get_binding("PINMUX_D"); + const struct device *muxa = device_get_binding("PINMUX_A"); + const struct device *muxb = device_get_binding("PINMUX_B"); + const struct device *muxc = device_get_binding("PINMUX_C"); + const struct device *muxd = device_get_binding("PINMUX_D"); ARG_UNUSED(dev); ARG_UNUSED(muxa); diff --git a/boards/arm/atsamr21_xpro/pinmux.c b/boards/arm/atsamr21_xpro/pinmux.c index 9c571299234cb4..2b5cc97b6b69ac 100644 --- a/boards/arm/atsamr21_xpro/pinmux.c +++ b/boards/arm/atsamr21_xpro/pinmux.c @@ -9,11 +9,11 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); - struct device *muxc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_c))); + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); + const struct device *muxc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_c))); ARG_UNUSED(dev); diff --git a/boards/arm/b_l072z_lrwan1/pinmux.c b/boards/arm/b_l072z_lrwan1/pinmux.c index 86ae577e15c951..2b2565f0782351 100644 --- a/boards/arm/b_l072z_lrwan1/pinmux.c +++ b/boards/arm/b_l072z_lrwan1/pinmux.c @@ -48,7 +48,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/b_l4s5i_iot01a/pinmux.c b/boards/arm/b_l4s5i_iot01a/pinmux.c index 1584b7c50ae416..e0300385db5290 100644 --- a/boards/arm/b_l4s5i_iot01a/pinmux.c +++ b/boards/arm/b_l4s5i_iot01a/pinmux.c @@ -53,7 +53,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/black_f407ve/pinmux.c b/boards/arm/black_f407ve/pinmux.c index aa961a91e43e45..7a0bbd9c999841 100644 --- a/boards/arm/black_f407ve/pinmux.c +++ b/boards/arm/black_f407ve/pinmux.c @@ -49,7 +49,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_black_f407ve_init(struct device *port) +static int pinmux_black_f407ve_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/black_f407zg_pro/pinmux.c b/boards/arm/black_f407zg_pro/pinmux.c index d6d0e4e3945403..e3e3f5ae6d9e03 100644 --- a/boards/arm/black_f407zg_pro/pinmux.c +++ b/boards/arm/black_f407zg_pro/pinmux.c @@ -50,7 +50,7 @@ static const struct pin_config pinconf[] = { }; -static int pinmux_black_f407zg_init(struct device *port) +static int pinmux_black_f407zg_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/blackpill_f411ce/pinmux.c b/boards/arm/blackpill_f411ce/pinmux.c index 2d472725735ca1..c4782efacac851 100644 --- a/boards/arm/blackpill_f411ce/pinmux.c +++ b/boards/arm/blackpill_f411ce/pinmux.c @@ -44,7 +44,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/cc3220sf_launchxl/pinmux.c b/boards/arm/cc3220sf_launchxl/pinmux.c index 3b2c13ed2376be..80ffb514204b35 100644 --- a/boards/arm/cc3220sf_launchxl/pinmux.c +++ b/boards/arm/cc3220sf_launchxl/pinmux.c @@ -91,7 +91,7 @@ #define I2C_CC32XX_PIN_16_I2C_SCL 0x90F /*!< PIN 16 is used for I2C_SCL */ #define I2C_CC32XX_PIN_17_I2C_SDA 0x910 /*!< PIN 17 is used for I2C_SDA */ -int pinmux_initialize(struct device *port) +int pinmux_initialize(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/cc3235sf_launchxl/pinmux.c b/boards/arm/cc3235sf_launchxl/pinmux.c index 7892075cc13f56..032a42fb01f28d 100644 --- a/boards/arm/cc3235sf_launchxl/pinmux.c +++ b/boards/arm/cc3235sf_launchxl/pinmux.c @@ -66,7 +66,7 @@ #define I2C_CC32XX_PIN_16_I2C_SCL 0x90F /*!< PIN 16 is used for I2C_SCL */ #define I2C_CC32XX_PIN_17_I2C_SDA 0x910 /*!< PIN 17 is used for I2C_SDA */ -int pinmux_initialize(struct device *port) +int pinmux_initialize(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/circuitdojo_feather_nrf9160/board.c b/boards/arm/circuitdojo_feather_nrf9160/board.c index 64892247466949..097d5d498a64ce 100644 --- a/boards/arm/circuitdojo_feather_nrf9160/board.c +++ b/boards/arm/circuitdojo_feather_nrf9160/board.c @@ -10,12 +10,12 @@ #define GPIO0 DT_LABEL(DT_NODELABEL(gpio0)) #define POWER_LATCH_PIN 31 -static int board_circuitdojo_feather_nrf9160_init(struct device *dev) +static int board_circuitdojo_feather_nrf9160_init(const struct device *dev) { ARG_UNUSED(dev); /* Get the device binding */ - struct device *gpio = device_get_binding(GPIO0); + const struct device *gpio = device_get_binding(GPIO0); if (gpio == NULL) { return -ENODEV; } diff --git a/boards/arm/colibri_imx7d_m4/pinmux.c b/boards/arm/colibri_imx7d_m4/pinmux.c index 3ce4a3ba07c4bb..833a2685dfb610 100644 --- a/boards/arm/colibri_imx7d_m4/pinmux.c +++ b/boards/arm/colibri_imx7d_m4/pinmux.c @@ -7,7 +7,7 @@ #include #include "device_imx.h" -static int colibri_imx7d_m4_pinmux_init(struct device *dev) +static int colibri_imx7d_m4_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/cy8ckit_062_wifi_bt_m0/pinmux.c b/boards/arm/cy8ckit_062_wifi_bt_m0/pinmux.c index 24aec0a958f4b0..21d003f6789b67 100644 --- a/boards/arm/cy8ckit_062_wifi_bt_m0/pinmux.c +++ b/boards/arm/cy8ckit_062_wifi_bt_m0/pinmux.c @@ -13,7 +13,7 @@ #include "pinmux/pinmux.h" -static int pinmux_init(struct device *port) +static int pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/cy8ckit_062_wifi_bt_m4/pinmux.c b/boards/arm/cy8ckit_062_wifi_bt_m4/pinmux.c index 24aec0a958f4b0..21d003f6789b67 100644 --- a/boards/arm/cy8ckit_062_wifi_bt_m4/pinmux.c +++ b/boards/arm/cy8ckit_062_wifi_bt_m4/pinmux.c @@ -13,7 +13,7 @@ #include "pinmux/pinmux.h" -static int pinmux_init(struct device *port) +static int pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/degu_evk/board.c b/boards/arm/degu_evk/board.c index 1b53d47c6fde16..52b2f01f3df717 100644 --- a/boards/arm/degu_evk/board.c +++ b/boards/arm/degu_evk/board.c @@ -7,13 +7,13 @@ #include #include -static int board_degu_evk_init(struct device *dev) +static int board_degu_evk_init(const struct device *dev) { ARG_UNUSED(dev); - struct device *gpio0 = + const struct device *gpio0 = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); - struct device *gpio1 = + const struct device *gpio1 = device_get_binding(DT_LABEL(DT_NODELABEL(gpio1))); /* diff --git a/boards/arm/disco_l475_iot1/pinmux.c b/boards/arm/disco_l475_iot1/pinmux.c index 122e2931cca0af..b83610c4f9c6d9 100644 --- a/boards/arm/disco_l475_iot1/pinmux.c +++ b/boards/arm/disco_l475_iot1/pinmux.c @@ -58,7 +58,7 @@ static const struct pin_config pinconf[] = { }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/dragino_lsn50/pinmux.c b/boards/arm/dragino_lsn50/pinmux.c index 3135092c02d82a..39af9b25fdc9e5 100644 --- a/boards/arm/dragino_lsn50/pinmux.c +++ b/boards/arm/dragino_lsn50/pinmux.c @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/efm32gg_stk3701a/board.c b/boards/arm/efm32gg_stk3701a/board.c index 2cbbd64f50dcfe..6075e7d88c497b 100644 --- a/boards/arm/efm32gg_stk3701a/board.c +++ b/boards/arm/efm32gg_stk3701a/board.c @@ -11,9 +11,9 @@ #include #include "em_cmu.h" -static int efm32gg_stk3701a_init(struct device *dev) +static int efm32gg_stk3701a_init(const struct device *dev) { - struct device *cur_dev; + const struct device *cur_dev; ARG_UNUSED(dev); diff --git a/boards/arm/efm32hg_slstk3400a/board.c b/boards/arm/efm32hg_slstk3400a/board.c index f8485af46861e0..e6b5bc5d423fda 100644 --- a/boards/arm/efm32hg_slstk3400a/board.c +++ b/boards/arm/efm32hg_slstk3400a/board.c @@ -9,9 +9,9 @@ #include #include -static int efm32hg_slstk3400a_init(struct device *dev) +static int efm32hg_slstk3400a_init(const struct device *dev) { - struct device *bce_dev; /* Board Controller Enable Gpio Device */ + const struct device *bce_dev; /* Board Controller Enable Gpio Device */ ARG_UNUSED(dev); diff --git a/boards/arm/efm32pg_stk3402a/board.c b/boards/arm/efm32pg_stk3402a/board.c index 65ffc219ad73bc..99eea511e2a614 100644 --- a/boards/arm/efm32pg_stk3402a/board.c +++ b/boards/arm/efm32pg_stk3402a/board.c @@ -9,9 +9,9 @@ #include #include -static int efm32pg_stk3402a_init(struct device *dev) +static int efm32pg_stk3402a_init(const struct device *dev) { - struct device *bce_dev; /* Board Controller Enable Gpio Device */ + const struct device *bce_dev; /* Board Controller Enable Gpio Device */ ARG_UNUSED(dev); diff --git a/boards/arm/efm32wg_stk3800/board.c b/boards/arm/efm32wg_stk3800/board.c index 26ce8287f21591..de6960a7ad3e7b 100644 --- a/boards/arm/efm32wg_stk3800/board.c +++ b/boards/arm/efm32wg_stk3800/board.c @@ -9,9 +9,9 @@ #include #include -static int efm32wg_stk3800_init(struct device *dev) +static int efm32wg_stk3800_init(const struct device *dev) { - struct device *bce_dev; /* Board Controller Enable Gpio Device */ + const struct device *bce_dev; /* Board Controller Enable Gpio Device */ ARG_UNUSED(dev); diff --git a/boards/arm/efr32_radio/board.c b/boards/arm/efr32_radio/board.c index 9689ead6f15699..7b9f6833aa70a3 100644 --- a/boards/arm/efr32_radio/board.c +++ b/boards/arm/efr32_radio/board.c @@ -17,9 +17,9 @@ #define VCOM_ENABLE_GPIO_PIN 5 #endif /* CONFIG_BOARD_EFR32_RADIO_BRD4180A */ -static int efr32_radio_init(struct device *dev) +static int efr32_radio_init(const struct device *dev) { - struct device *vce_dev; /* Virtual COM Port Enable GPIO Device */ + const struct device *vce_dev; /* Virtual COM Port Enable GPIO Device */ ARG_UNUSED(dev); diff --git a/boards/arm/efr32mg_sltb004a/board.c b/boards/arm/efr32mg_sltb004a/board.c index 792b5ee28f2067..aff8fbd5706992 100644 --- a/boards/arm/efr32mg_sltb004a/board.c +++ b/boards/arm/efr32mg_sltb004a/board.c @@ -9,9 +9,9 @@ #include #include -static int efr32mg_sltb004a_init(struct device *dev) +static int efr32mg_sltb004a_init(const struct device *dev) { - struct device *cur_dev; + const struct device *cur_dev; ARG_UNUSED(dev); diff --git a/boards/arm/frdm_k22f/pinmux.c b/boards/arm/frdm_k22f/pinmux.c index 477470fc06b4b6..5cf1427434feca 100644 --- a/boards/arm/frdm_k22f/pinmux.c +++ b/boards/arm/frdm_k22f/pinmux.c @@ -8,28 +8,28 @@ #include #include -static int frdm_k22f_pinmux_init(struct device *dev) +static int frdm_k22f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - struct device *portd = + const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - struct device *porte = + const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/frdm_k64f/pinmux.c b/boards/arm/frdm_k64f/pinmux.c index 8e96be37042c95..8f798e446ce388 100644 --- a/boards/arm/frdm_k64f/pinmux.c +++ b/boards/arm/frdm_k64f/pinmux.c @@ -8,28 +8,28 @@ #include #include -static int frdm_k64f_pinmux_init(struct device *dev) +static int frdm_k64f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - struct device *portd = + const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - struct device *porte = + const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/frdm_k82f/pinmux.c b/boards/arm/frdm_k82f/pinmux.c index 89a433eef17927..3a59b8e9a42238 100644 --- a/boards/arm/frdm_k82f/pinmux.c +++ b/boards/arm/frdm_k82f/pinmux.c @@ -8,28 +8,28 @@ #include #include -static int frdm_k82f_pinmux_init(struct device *dev) +static int frdm_k82f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - __unused struct device *porta = + __unused const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - __unused struct device *portb = + __unused const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - __unused struct device *portc = + __unused const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - __unused struct device *portd = + __unused const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - __unused struct device *porte = + __unused const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/frdm_kl25z/pinmux.c b/boards/arm/frdm_kl25z/pinmux.c index 936639a4ead261..e0f8489b2f0c8e 100644 --- a/boards/arm/frdm_kl25z/pinmux.c +++ b/boards/arm/frdm_kl25z/pinmux.c @@ -8,28 +8,28 @@ #include #include -static int frdm_kl25z_pinmux_init(struct device *dev) +static int frdm_kl25z_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #if defined(CONFIG_PINMUX_MCUX_PORTC) - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - struct device *portd = + const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #if defined(CONFIG_PINMUX_MCUX_PORTE) - struct device *porte = + const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/frdm_kw41z/pinmux.c b/boards/arm/frdm_kw41z/pinmux.c index c27637da47a5f5..2cf28ab3d0b148 100644 --- a/boards/arm/frdm_kw41z/pinmux.c +++ b/boards/arm/frdm_kw41z/pinmux.c @@ -8,20 +8,20 @@ #include #include -static int frdm_kw41z_pinmux_init(struct device *dev) +static int frdm_kw41z_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif diff --git a/boards/arm/google_kukui/pinmux.c b/boards/arm/google_kukui/pinmux.c index a2edcc7db88db9..39d6f0f6f52f26 100644 --- a/boards/arm/google_kukui/pinmux.c +++ b/boards/arm/google_kukui/pinmux.c @@ -27,7 +27,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/hexiwear_k64/pinmux.c b/boards/arm/hexiwear_k64/pinmux.c index ad37ab157395d1..91fbb86432525f 100644 --- a/boards/arm/hexiwear_k64/pinmux.c +++ b/boards/arm/hexiwear_k64/pinmux.c @@ -9,24 +9,24 @@ #include #include -static int hexiwear_k64_pinmux_init(struct device *dev) +static int hexiwear_k64_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - struct device *portd = + const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - struct device *porte = + const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif @@ -52,7 +52,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev) /* 3V3B_EN */ pinmux_pin_set(portb, 12, PORT_PCR_MUX(kPORT_MuxAsGpio)); - struct device *gpiob = + const struct device *gpiob = device_get_binding(DT_LABEL(DT_NODELABEL(gpiob))); gpio_pin_configure(gpiob, 12, GPIO_OUTPUT_LOW); @@ -84,13 +84,13 @@ static int hexiwear_k64_pinmux_init(struct device *dev) #endif #if defined(CONFIG_MAX30101) && DT_NODE_HAS_STATUS(DT_NODELABEL(gpioa), okay) - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); /* LDO - MAX30101 power supply */ pinmux_pin_set(porta, 29, PORT_PCR_MUX(kPORT_MuxAsGpio)); - struct device *gpioa = + const struct device *gpioa = device_get_binding(DT_LABEL(DT_NODELABEL(gpioa))); gpio_pin_configure(gpioa, 29, GPIO_OUTPUT_HIGH); @@ -99,7 +99,7 @@ static int hexiwear_k64_pinmux_init(struct device *dev) #ifdef CONFIG_BATTERY_SENSE pinmux_pin_set(portc, 14, PORT_PCR_MUX(kPORT_MuxAsGpio)); - struct device *gpioc = + const struct device *gpioc = device_get_binding(DT_LABEL(DT_NODELABEL(gpioc))); gpio_pin_configure(gpioc, 14, GPIO_OUTPUT_LOW); diff --git a/boards/arm/hexiwear_kw40z/pinmux.c b/boards/arm/hexiwear_kw40z/pinmux.c index 76c2c8af6c693a..6a578f6d77f333 100644 --- a/boards/arm/hexiwear_kw40z/pinmux.c +++ b/boards/arm/hexiwear_kw40z/pinmux.c @@ -8,17 +8,17 @@ #include #include -static int hexiwear_kw40z_pinmux_init(struct device *dev) +static int hexiwear_kw40z_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif diff --git a/boards/arm/ip_k66f/pinmux.c b/boards/arm/ip_k66f/pinmux.c index 05c40983c29467..1d1e7f4e239fc7 100644 --- a/boards/arm/ip_k66f/pinmux.c +++ b/boards/arm/ip_k66f/pinmux.c @@ -8,22 +8,22 @@ #include #include -static int ip_k66f_pinmux_init(struct device *dev) +static int ip_k66f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - struct device *porte = + const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/lpcxpresso54114/pinmux.c b/boards/arm/lpcxpresso54114/pinmux.c index 258382f3b06828..c47e2029c031de 100644 --- a/boards/arm/lpcxpresso54114/pinmux.c +++ b/boards/arm/lpcxpresso54114/pinmux.c @@ -9,17 +9,17 @@ #include #include -static int lpcxpresso_54114_pinmux_init(struct device *dev) +static int lpcxpresso_54114_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_LPC_PORT0 - struct device *port0 = + const struct device *port0 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_LPC_PORT1 - struct device *port1 = + const struct device *port1 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif diff --git a/boards/arm/lpcxpresso55s16/pinmux.c b/boards/arm/lpcxpresso55s16/pinmux.c index 0156944ef56f24..de71c9d25ea37f 100644 --- a/boards/arm/lpcxpresso55s16/pinmux.c +++ b/boards/arm/lpcxpresso55s16/pinmux.c @@ -9,17 +9,17 @@ #include #include -static int lpcxpresso_55s16_pinmux_init(struct device *dev) +static int lpcxpresso_55s16_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_LPC_PORT0 - __unused struct device *port0 = + __unused const struct device *port0 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_LPC_PORT1 - __unused struct device *port1 = + __unused const struct device *port1 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif diff --git a/boards/arm/lpcxpresso55s69/pinmux.c b/boards/arm/lpcxpresso55s69/pinmux.c index 939f99ee952fb7..8dbce690327775 100644 --- a/boards/arm/lpcxpresso55s69/pinmux.c +++ b/boards/arm/lpcxpresso55s69/pinmux.c @@ -9,17 +9,17 @@ #include #include -static int lpcxpresso_55s69_pinmux_init(struct device *dev) +static int lpcxpresso_55s69_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_LPC_PORT0 - struct device *port0 = + const struct device *port0 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_LPC_PORT1 - struct device *port1 = + const struct device *port1 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT1_NAME); #endif diff --git a/boards/arm/mec1501modular_assy6885/pinmux.c b/boards/arm/mec1501modular_assy6885/pinmux.c index 015bf431da6d42..a5a4f9fa0edd10 100644 --- a/boards/arm/mec1501modular_assy6885/pinmux.c +++ b/boards/arm/mec1501modular_assy6885/pinmux.c @@ -13,22 +13,22 @@ struct pinmux_ports_t { #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_000_036), okay) - struct device *porta; + const struct device *porta; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_040_076), okay) - struct device *portb; + const struct device *portb; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_100_136), okay) - struct device *portc; + const struct device *portc; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_140_176), okay) - struct device *portd; + const struct device *portd; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_200_236), okay) - struct device *porte; + const struct device *porte; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_240_276), okay) - struct device *portf; + const struct device *portf; #endif }; @@ -122,38 +122,38 @@ static void configure_debug_interface(void) #endif /* CONFIG_SOC_MEC1501_DEBUG_WITHOUT_TRACING */ } -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); struct pinmux_ports_t pinmux_ports; #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_000_036), okay) - struct device *porta = + const struct device *porta = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_000_036))); pinmux_ports.porta = porta; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_040_076), okay) - struct device *portb = + const struct device *portb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_040_076))); pinmux_ports.portb = portb; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_100_136), okay) - struct device *portc = + const struct device *portc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_100_136))); pinmux_ports.portc = portc; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_140_176), okay) - struct device *portd = + const struct device *portd = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_140_176))); pinmux_ports.portd = portd; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_200_236), okay) - struct device *porte = + const struct device *porte = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_200_236))); pinmux_ports.porte = porte; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_240_276), okay) - struct device *portf = + const struct device *portf = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_240_276))); pinmux_ports.portf = portf; #endif diff --git a/boards/arm/mec15xxevb_assy6853/pinmux.c b/boards/arm/mec15xxevb_assy6853/pinmux.c index 5ccb4244feff38..dd54c7640a0c1d 100644 --- a/boards/arm/mec15xxevb_assy6853/pinmux.c +++ b/boards/arm/mec15xxevb_assy6853/pinmux.c @@ -13,22 +13,22 @@ struct pinmux_ports_t { #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_000_036), okay) - struct device *porta; + const struct device *porta; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_040_076), okay) - struct device *portb; + const struct device *portb; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_100_136), okay) - struct device *portc; + const struct device *portc; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_140_176), okay) - struct device *portd; + const struct device *portd; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_200_236), okay) - struct device *porte; + const struct device *porte; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_240_276), okay) - struct device *portf; + const struct device *portf; #endif }; @@ -124,38 +124,38 @@ static void configure_debug_interface(void) #endif /* CONFIG_SOC_MEC1501_DEBUG_WITHOUT_TRACING */ } -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); struct pinmux_ports_t pinmux_ports; #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_000_036), okay) - struct device *porta = + const struct device *porta = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_000_036))); pinmux_ports.porta = porta; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_040_076), okay) - struct device *portb = + const struct device *portb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_040_076))); pinmux_ports.portb = portb; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_100_136), okay) - struct device *portc = + const struct device *portc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_100_136))); pinmux_ports.portc = portc; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_140_176), okay) - struct device *portd = + const struct device *portd = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_140_176))); pinmux_ports.portd = portd; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_200_236), okay) - struct device *porte = + const struct device *porte = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_200_236))); pinmux_ports.porte = porte; #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmux_240_276), okay) - struct device *portf = + const struct device *portf = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_240_276))); pinmux_ports.portf = portf; #endif diff --git a/boards/arm/mec2016evb_assy6797/pinmux.c b/boards/arm/mec2016evb_assy6797/pinmux.c index 6f3e93bc2489e4..93a4057719e8ad 100644 --- a/boards/arm/mec2016evb_assy6797/pinmux.c +++ b/boards/arm/mec2016evb_assy6797/pinmux.c @@ -10,7 +10,7 @@ #include "soc.h" -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mikroe_mini_m4_for_stm32/pinmux.c b/boards/arm/mikroe_mini_m4_for_stm32/pinmux.c index ddb144e787bf35..920108af9fc94d 100644 --- a/boards/arm/mikroe_mini_m4_for_stm32/pinmux.c +++ b/boards/arm/mikroe_mini_m4_for_stm32/pinmux.c @@ -39,7 +39,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/mimx8mm_evk/pinmux.c b/boards/arm/mimx8mm_evk/pinmux.c index 91131f7035362f..f2a72b18121273 100644 --- a/boards/arm/mimx8mm_evk/pinmux.c +++ b/boards/arm/mimx8mm_evk/pinmux.c @@ -7,7 +7,7 @@ #include #include -static int mimx8mm_evk_pinmux_init(struct device *dev) +static int mimx8mm_evk_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mimxrt1010_evk/pinmux.c b/boards/arm/mimxrt1010_evk/pinmux.c index 2d941cb9be341e..dc5c52c8f640fe 100644 --- a/boards/arm/mimxrt1010_evk/pinmux.c +++ b/boards/arm/mimxrt1010_evk/pinmux.c @@ -8,7 +8,7 @@ #include #include -static int mimxrt1010_evk_init(struct device *dev) +static int mimxrt1010_evk_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mimxrt1015_evk/pinmux.c b/boards/arm/mimxrt1015_evk/pinmux.c index d96148e1ac90a7..5adad957f6f970 100644 --- a/boards/arm/mimxrt1015_evk/pinmux.c +++ b/boards/arm/mimxrt1015_evk/pinmux.c @@ -8,7 +8,7 @@ #include #include -static int mimxrt1015_evk_init(struct device *dev) +static int mimxrt1015_evk_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mimxrt1020_evk/pinmux.c b/boards/arm/mimxrt1020_evk/pinmux.c index 5a0781c2752b38..db4806d49e0a57 100644 --- a/boards/arm/mimxrt1020_evk/pinmux.c +++ b/boards/arm/mimxrt1020_evk/pinmux.c @@ -16,7 +16,7 @@ static gpio_pin_config_t enet_gpio_config = { }; #endif -static int mimxrt1020_evk_init(struct device *dev) +static int mimxrt1020_evk_init(const struct device *dev) { ARG_UNUSED(dev); @@ -148,7 +148,7 @@ static int mimxrt1020_evk_init(struct device *dev) } #if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET -static int mimxrt1020_evk_phy_reset(struct device *dev) +static int mimxrt1020_evk_phy_reset(const struct device *dev) { /* RESET PHY chip. */ k_busy_wait(USEC_PER_MSEC * 10U); diff --git a/boards/arm/mimxrt1050_evk/pinmux.c b/boards/arm/mimxrt1050_evk/pinmux.c index be9b8f6079af8f..02884a871bc215 100644 --- a/boards/arm/mimxrt1050_evk/pinmux.c +++ b/boards/arm/mimxrt1050_evk/pinmux.c @@ -102,7 +102,7 @@ static void mimxrt1050_evk_usdhc_pinmux( } #endif -static int mimxrt1050_evk_init(struct device *dev) +static int mimxrt1050_evk_init(const struct device *dev) { ARG_UNUSED(dev); @@ -317,7 +317,7 @@ static int mimxrt1050_evk_init(struct device *dev) } #if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET -static int mimxrt1050_evk_phy_reset(struct device *dev) +static int mimxrt1050_evk_phy_reset(const struct device *dev) { /* RESET PHY chip. */ k_busy_wait(USEC_PER_MSEC * 10U); diff --git a/boards/arm/mimxrt1060_evk/pinmux.c b/boards/arm/mimxrt1060_evk/pinmux.c index bab14ac5901640..1213d529af6eb8 100644 --- a/boards/arm/mimxrt1060_evk/pinmux.c +++ b/boards/arm/mimxrt1060_evk/pinmux.c @@ -85,7 +85,7 @@ static void mimxrt1060_evk_usdhc_pinmux(uint16_t nusdhc, bool init, uint32_t spe } #endif -static int mimxrt1060_evk_init(struct device *dev) +static int mimxrt1060_evk_init(const struct device *dev) { ARG_UNUSED(dev); @@ -272,7 +272,7 @@ static int mimxrt1060_evk_init(struct device *dev) } #if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET -static int mimxrt1060_evk_phy_reset(struct device *dev) +static int mimxrt1060_evk_phy_reset(const struct device *dev) { /* RESET PHY chip. */ k_busy_wait(USEC_PER_MSEC * 10U); diff --git a/boards/arm/mimxrt1064_evk/pinmux.c b/boards/arm/mimxrt1064_evk/pinmux.c index 0d243c945a6ef7..d2e750db37743f 100644 --- a/boards/arm/mimxrt1064_evk/pinmux.c +++ b/boards/arm/mimxrt1064_evk/pinmux.c @@ -85,7 +85,7 @@ static void mimxrt1064_evk_usdhc_pinmux(uint16_t nusdhc, bool init, uint32_t spe } #endif -static int mimxrt1064_evk_init(struct device *dev) +static int mimxrt1064_evk_init(const struct device *dev) { ARG_UNUSED(dev); @@ -276,7 +276,7 @@ static int mimxrt1064_evk_init(struct device *dev) } #if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET -static int mimxrt1064_evk_phy_reset(struct device *dev) +static int mimxrt1064_evk_phy_reset(const struct device *dev) { /* RESET PHY chip. */ k_busy_wait(USEC_PER_MSEC * 10U); diff --git a/boards/arm/mimxrt685_evk/pinmux.c b/boards/arm/mimxrt685_evk/pinmux.c index 99cd13a11b56df..3abf2220e67547 100644 --- a/boards/arm/mimxrt685_evk/pinmux.c +++ b/boards/arm/mimxrt685_evk/pinmux.c @@ -7,7 +7,7 @@ #include #include -static int mimxrt685_evk_pinmux_init(struct device *dev) +static int mimxrt685_evk_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mm_swiftio/pinmux.c b/boards/arm/mm_swiftio/pinmux.c index 1f3d989f6b3928..82ff3279785bd5 100644 --- a/boards/arm/mm_swiftio/pinmux.c +++ b/boards/arm/mm_swiftio/pinmux.c @@ -102,7 +102,7 @@ static void mm_swiftio_usdhc_pinmux( } #endif -static int mm_swiftio_init(struct device *dev) +static int mm_swiftio_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/mps2_an385/pinmux.c b/boards/arm/mps2_an385/pinmux.c index b9d4bd40d52b35..56a62a856a293a 100644 --- a/boards/arm/mps2_an385/pinmux.c +++ b/boards/arm/mps2_an385/pinmux.c @@ -155,7 +155,7 @@ static void arm_mps2_pinmux_defaults(void) CMSDK_AHB_GPIO2_DEV->altfuncset = gpio_2; } -static int arm_mps2_pinmux_init(struct device *port) +static int arm_mps2_pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/mps2_an521/pinmux.c b/boards/arm/mps2_an521/pinmux.c index 116736f3dd7a31..5bd038bd211707 100644 --- a/boards/arm/mps2_an521/pinmux.c +++ b/boards/arm/mps2_an521/pinmux.c @@ -155,7 +155,7 @@ static void arm_mps2_pinmux_defaults(void) CMSDK_AHB_GPIO2_DEV->altfuncset = gpio_2; } -static int arm_mps2_pinmux_init(struct device *port) +static int arm_mps2_pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nrf52840dongle_nrf52840/board.c b/boards/arm/nrf52840dongle_nrf52840/board.c index dd0f0d44bdcc2b..fb614b2fc30d3b 100644 --- a/boards/arm/nrf52840dongle_nrf52840/board.c +++ b/boards/arm/nrf52840dongle_nrf52840/board.c @@ -7,7 +7,7 @@ #include #include -static int board_nrf52840dongle_nrf52840_init(struct device *dev) +static int board_nrf52840dongle_nrf52840_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c b/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c index d956f37d4ed77a..a09bfe4cf58c3c 100644 --- a/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c +++ b/boards/arm/nrf5340dk_nrf5340/nrf5340_cpunet_reset.c @@ -67,7 +67,7 @@ static void remoteproc_mgr_config(void) } #endif /* !CONFIG_TRUSTED_EXECUTION_NONSECURE */ -static int remoteproc_mgr_boot(struct device *dev) +static int remoteproc_mgr_boot(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/nrf9160_innblue21/innblue21_board_init.c b/boards/arm/nrf9160_innblue21/innblue21_board_init.c index 7db1bf2387a028..590c4b4acba591 100644 --- a/boards/arm/nrf9160_innblue21/innblue21_board_init.c +++ b/boards/arm/nrf9160_innblue21/innblue21_board_init.c @@ -11,7 +11,7 @@ #define VDD_5V0_PWR_CTRL_GPIO_PIN 21 /* ENABLE_5V0_BOOST --> speed sensor */ /* Configures the pin as output and sets them high. */ -static void config_pin(struct device *gpio, int pin) +static void config_pin(const struct device *gpio, int pin) { int err; @@ -26,9 +26,9 @@ static void config_pin(struct device *gpio, int pin) k_sleep(K_MSEC(10)); } -static int pwr_ctrl_init(struct device *dev) +static int pwr_ctrl_init(const struct device *dev) { - struct device *gpio; + const struct device *gpio; /* Get handle of the GPIO device. */ gpio = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); diff --git a/boards/arm/nrf9160_innblue22/innblue22_board_init.c b/boards/arm/nrf9160_innblue22/innblue22_board_init.c index 732625ea826fb1..5c9f9fb6b34c9c 100644 --- a/boards/arm/nrf9160_innblue22/innblue22_board_init.c +++ b/boards/arm/nrf9160_innblue22/innblue22_board_init.c @@ -9,9 +9,9 @@ #define VDD_5V0_PWR_CTRL_GPIO_PIN 21 /* ENABLE_5V0_BOOST --> speed sensor */ -static int pwr_ctrl_init(struct device *dev) +static int pwr_ctrl_init(const struct device *dev) { - struct device *gpio; + const struct device *gpio; int err = -ENODEV; /* Get handle of the GPIO device. */ diff --git a/boards/arm/nrf9160dk_nrf52840/board.c b/boards/arm/nrf9160dk_nrf52840/board.c index 58ae7608b43e07..3cb162e64444b5 100644 --- a/boards/arm/nrf9160dk_nrf52840/board.c +++ b/boards/arm/nrf9160dk_nrf52840/board.c @@ -171,7 +171,8 @@ static void config_print(void) IS_ENABLED(CONFIG_BOARD_NRF9160DK_SWITCH1_ARDUINO)); } -static int pins_configure(struct device *port, const struct pin_config cfg[], +static int pins_configure(const struct device *port, + const struct pin_config cfg[], size_t pins) { int err; @@ -197,7 +198,7 @@ static int pins_configure(struct device *port, const struct pin_config cfg[], return 0; } -static void chip_reset(struct device *gpio, +static void chip_reset(const struct device *gpio, struct gpio_callback *cb, uint32_t pins) { const uint32_t stamp = k_cycle_get_32(); @@ -208,7 +209,7 @@ static void chip_reset(struct device *gpio, NVIC_SystemReset(); } -static void reset_pin_wait_low(struct device *port, uint32_t pin) +static void reset_pin_wait_low(const struct device *port, uint32_t pin) { int val; @@ -218,11 +219,12 @@ static void reset_pin_wait_low(struct device *port, uint32_t pin) } while (val > 0); } -static int reset_pin_configure(struct device *p0, struct device *p1) +static int reset_pin_configure(const struct device *p0, + const struct device *p1) { int err; uint32_t pin = 0; - struct device *port = NULL; + const struct device *port = NULL; static struct gpio_callback gpio_ctx; @@ -283,11 +285,11 @@ static int reset_pin_configure(struct device *p0, struct device *p1) return 0; } -static int init(struct device *dev) +static int init(const struct device *dev) { int rc; - struct device *p0; - struct device *p1; + const struct device *p0; + const struct device *p1; p0 = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); if (!p0) { diff --git a/boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c b/boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c index bd0516644ee345..3227ec5dfe6c6a 100644 --- a/boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c +++ b/boards/arm/nrf9160dk_nrf9160/nrf52840_reset.c @@ -16,11 +16,11 @@ BUILD_ASSERT(RESET_PIN > 16 && RESET_PIN < 24, "Selected pin is not connected to nRF52840"); -int bt_hci_transport_setup(struct device *h4) +int bt_hci_transport_setup(const struct device *h4) { int err; char c; - struct device *port; + const struct device *port; port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0))); if (!port) { diff --git a/boards/arm/nucleo_f030r8/pinmux.c b/boards/arm/nucleo_f030r8/pinmux.c index 3c7c0684f427af..ceb0ed02671a86 100644 --- a/boards/arm/nucleo_f030r8/pinmux.c +++ b/boards/arm/nucleo_f030r8/pinmux.c @@ -49,7 +49,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f070rb/pinmux.c b/boards/arm/nucleo_f070rb/pinmux.c index a553dddce2c9da..aed9ba1d3e3b9d 100644 --- a/boards/arm/nucleo_f070rb/pinmux.c +++ b/boards/arm/nucleo_f070rb/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f091rc/pinmux.c b/boards/arm/nucleo_f091rc/pinmux.c index 84c0dfd04a9241..8bbbced95a2eaa 100644 --- a/boards/arm/nucleo_f091rc/pinmux.c +++ b/boards/arm/nucleo_f091rc/pinmux.c @@ -45,7 +45,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f103rb/pinmux.c b/boards/arm/nucleo_f103rb/pinmux.c index b1bda2fbefbcd5..6df16ea269431d 100644 --- a/boards/arm/nucleo_f103rb/pinmux.c +++ b/boards/arm/nucleo_f103rb/pinmux.c @@ -50,7 +50,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f207zg/pinmux.c b/boards/arm/nucleo_f207zg/pinmux.c index 67ae3b8be0ed6a..0f3bd2686c77d0 100644 --- a/boards/arm/nucleo_f207zg/pinmux.c +++ b/boards/arm/nucleo_f207zg/pinmux.c @@ -47,7 +47,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f302r8/pinmux.c b/boards/arm/nucleo_f302r8/pinmux.c index 22212bf776eaf2..a044a5568d23a4 100644 --- a/boards/arm/nucleo_f302r8/pinmux.c +++ b/boards/arm/nucleo_f302r8/pinmux.c @@ -46,7 +46,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f303re/pinmux.c b/boards/arm/nucleo_f303re/pinmux.c index 5405094d0306da..c05b2817825309 100644 --- a/boards/arm/nucleo_f303re/pinmux.c +++ b/boards/arm/nucleo_f303re/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f334r8/pinmux.c b/boards/arm/nucleo_f334r8/pinmux.c index fbb9548cdef793..f484d1d0ffb9b4 100644 --- a/boards/arm/nucleo_f334r8/pinmux.c +++ b/boards/arm/nucleo_f334r8/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f401re/pinmux.c b/boards/arm/nucleo_f401re/pinmux.c index 966fbdd195a89c..979b1067e69518 100644 --- a/boards/arm/nucleo_f401re/pinmux.c +++ b/boards/arm/nucleo_f401re/pinmux.c @@ -50,7 +50,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f411re/pinmux.c b/boards/arm/nucleo_f411re/pinmux.c index c9bebe4d040775..02441ad94d0959 100644 --- a/boards/arm/nucleo_f411re/pinmux.c +++ b/boards/arm/nucleo_f411re/pinmux.c @@ -45,7 +45,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f412zg/pinmux.c b/boards/arm/nucleo_f412zg/pinmux.c index e4e2353065761c..971d345e61d916 100644 --- a/boards/arm/nucleo_f412zg/pinmux.c +++ b/boards/arm/nucleo_f412zg/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f413zh/pinmux.c b/boards/arm/nucleo_f413zh/pinmux.c index 17bfc1fc5974b7..59df50bc6c552f 100644 --- a/boards/arm/nucleo_f413zh/pinmux.c +++ b/boards/arm/nucleo_f413zh/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f429zi/pinmux.c b/boards/arm/nucleo_f429zi/pinmux.c index 040545e3f4b351..52d67b0a95a72f 100644 --- a/boards/arm/nucleo_f429zi/pinmux.c +++ b/boards/arm/nucleo_f429zi/pinmux.c @@ -56,7 +56,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f446re/pinmux.c b/boards/arm/nucleo_f446re/pinmux.c index bd4ae68bac643e..e313814767c74c 100644 --- a/boards/arm/nucleo_f446re/pinmux.c +++ b/boards/arm/nucleo_f446re/pinmux.c @@ -44,7 +44,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f746zg/pinmux.c b/boards/arm/nucleo_f746zg/pinmux.c index e072bd983152aa..49374a4db2b5a2 100644 --- a/boards/arm/nucleo_f746zg/pinmux.c +++ b/boards/arm/nucleo_f746zg/pinmux.c @@ -73,7 +73,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f756zg/pinmux.c b/boards/arm/nucleo_f756zg/pinmux.c index a63774624784ef..f45e25f3786c6d 100644 --- a/boards/arm/nucleo_f756zg/pinmux.c +++ b/boards/arm/nucleo_f756zg/pinmux.c @@ -66,7 +66,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_f767zi/pinmux.c b/boards/arm/nucleo_f767zi/pinmux.c index 60ac8d4178aaf9..a4224d5d56e6dc 100644 --- a/boards/arm/nucleo_f767zi/pinmux.c +++ b/boards/arm/nucleo_f767zi/pinmux.c @@ -73,7 +73,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_g071rb/pinmux.c b/boards/arm/nucleo_g071rb/pinmux.c index 647da76e722f33..32b763c7b536f6 100644 --- a/boards/arm/nucleo_g071rb/pinmux.c +++ b/boards/arm/nucleo_g071rb/pinmux.c @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_g431rb/pinmux.c b/boards/arm/nucleo_g431rb/pinmux.c index 13aabe1e720064..df758fc0d802b5 100644 --- a/boards/arm/nucleo_g431rb/pinmux.c +++ b/boards/arm/nucleo_g431rb/pinmux.c @@ -63,7 +63,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_g474re/pinmux.c b/boards/arm/nucleo_g474re/pinmux.c index 8242e0abd982ca..7f37fc21898399 100644 --- a/boards/arm/nucleo_g474re/pinmux.c +++ b/boards/arm/nucleo_g474re/pinmux.c @@ -63,7 +63,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_h743zi/pinmux.c b/boards/arm/nucleo_h743zi/pinmux.c index d57669d2109774..fa4053b4214019 100644 --- a/boards/arm/nucleo_h743zi/pinmux.c +++ b/boards/arm/nucleo_h743zi/pinmux.c @@ -30,7 +30,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_h745zi_q/pinmux.c b/boards/arm/nucleo_h745zi_q/pinmux.c index df81e99f2b56bd..597d1cc183498a 100644 --- a/boards/arm/nucleo_h745zi_q/pinmux.c +++ b/boards/arm/nucleo_h745zi_q/pinmux.c @@ -51,7 +51,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l053r8/pinmux.c b/boards/arm/nucleo_l053r8/pinmux.c index 9e46dc821970c3..82308d9230f298 100644 --- a/boards/arm/nucleo_l053r8/pinmux.c +++ b/boards/arm/nucleo_l053r8/pinmux.c @@ -33,7 +33,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l073rz/pinmux.c b/boards/arm/nucleo_l073rz/pinmux.c index 3f4cff174fefe0..1ee0a96cc011c2 100644 --- a/boards/arm/nucleo_l073rz/pinmux.c +++ b/boards/arm/nucleo_l073rz/pinmux.c @@ -39,7 +39,7 @@ static const struct pin_config pinconf[] = { #endif /* dac1 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l152re/pinmux.c b/boards/arm/nucleo_l152re/pinmux.c index 8e29793e176723..7dadc4d7b4b75d 100644 --- a/boards/arm/nucleo_l152re/pinmux.c +++ b/boards/arm/nucleo_l152re/pinmux.c @@ -29,7 +29,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l432kc/pinmux.c b/boards/arm/nucleo_l432kc/pinmux.c index eea2ba83bb4545..f8161a3ad397fd 100644 --- a/boards/arm/nucleo_l432kc/pinmux.c +++ b/boards/arm/nucleo_l432kc/pinmux.c @@ -44,7 +44,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l452re/pinmux.c b/boards/arm/nucleo_l452re/pinmux.c index 61d0b8b8384db0..92acd71f8b80d4 100644 --- a/boards/arm/nucleo_l452re/pinmux.c +++ b/boards/arm/nucleo_l452re/pinmux.c @@ -43,7 +43,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l476rg/pinmux.c b/boards/arm/nucleo_l476rg/pinmux.c index a6e7b837c16721..bc2d088da0efae 100644 --- a/boards/arm/nucleo_l476rg/pinmux.c +++ b/boards/arm/nucleo_l476rg/pinmux.c @@ -71,7 +71,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l496zg/pinmux.c b/boards/arm/nucleo_l496zg/pinmux.c index 840bc0b39b1539..cbfd3d9080be6f 100644 --- a/boards/arm/nucleo_l496zg/pinmux.c +++ b/boards/arm/nucleo_l496zg/pinmux.c @@ -44,7 +44,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l4r5zi/pinmux.c b/boards/arm/nucleo_l4r5zi/pinmux.c index a55c871386629b..769a346c920c48 100644 --- a/boards/arm/nucleo_l4r5zi/pinmux.c +++ b/boards/arm/nucleo_l4r5zi/pinmux.c @@ -72,7 +72,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_l552ze_q/pinmux.c b/boards/arm/nucleo_l552ze_q/pinmux.c index 4bf853eec6b0b6..f05430459f7caf 100644 --- a/boards/arm/nucleo_l552ze_q/pinmux.c +++ b/boards/arm/nucleo_l552ze_q/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/nucleo_wb55rg/pinmux.c b/boards/arm/nucleo_wb55rg/pinmux.c index f94a36cd920336..82aca601de159a 100644 --- a/boards/arm/nucleo_wb55rg/pinmux.c +++ b/boards/arm/nucleo_wb55rg/pinmux.c @@ -50,7 +50,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/olimex_stm32_e407/pinmux.c b/boards/arm/olimex_stm32_e407/pinmux.c index f3312188487041..aa5116f2ee5e76 100644 --- a/boards/arm/olimex_stm32_e407/pinmux.c +++ b/boards/arm/olimex_stm32_e407/pinmux.c @@ -52,7 +52,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/olimex_stm32_h103/pinmux.c b/boards/arm/olimex_stm32_h103/pinmux.c index 40d37127fd106d..04a6d4eebd3ca8 100644 --- a/boards/arm/olimex_stm32_h103/pinmux.c +++ b/boards/arm/olimex_stm32_h103/pinmux.c @@ -64,7 +64,7 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PC4, STM32F1_PINMUX_FUNC_PC4_ADC12_IN14}, }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/olimex_stm32_h407/pinmux.c b/boards/arm/olimex_stm32_h407/pinmux.c index bd330bdff57859..c5ebbb7735f26d 100644 --- a/boards/arm/olimex_stm32_h407/pinmux.c +++ b/boards/arm/olimex_stm32_h407/pinmux.c @@ -32,7 +32,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/olimex_stm32_p405/pinmux.c b/boards/arm/olimex_stm32_p405/pinmux.c index ac9babb61cc0dc..5d6d05367d0336 100644 --- a/boards/arm/olimex_stm32_p405/pinmux.c +++ b/boards/arm/olimex_stm32_p405/pinmux.c @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/olimexino_stm32/pinmux.c b/boards/arm/olimexino_stm32/pinmux.c index 641d700a0712f4..61c99d056a8fc8 100644 --- a/boards/arm/olimexino_stm32/pinmux.c +++ b/boards/arm/olimexino_stm32/pinmux.c @@ -64,7 +64,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/particle_argon/board.c b/boards/arm/particle_argon/board.c index e0ed973704f02e..a6d559cb34023a 100644 --- a/boards/arm/particle_argon/board.c +++ b/boards/arm/particle_argon/board.c @@ -11,7 +11,7 @@ static inline void external_antenna(bool on) { - struct device *ufl_gpio_dev, *pcb_gpio_dev; + const struct device *ufl_gpio_dev, *pcb_gpio_dev; ufl_gpio_dev = device_get_binding(SKY_UFLn_GPIO_NAME); if (!ufl_gpio_dev) { @@ -35,7 +35,7 @@ static inline void external_antenna(bool on) : GPIO_OUTPUT_ACTIVE)); } -static int board_particle_argon_init(struct device *dev) +static int board_particle_argon_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/particle_boron/board.c b/boards/arm/particle_boron/board.c index bcfa7183a94dfd..0e5714a3efa555 100644 --- a/boards/arm/particle_boron/board.c +++ b/boards/arm/particle_boron/board.c @@ -11,7 +11,7 @@ static inline void external_antenna(bool on) { - struct device *gpio_dev; + const struct device *gpio_dev; /* * On power-up the SKY13351 is left uncontrolled, so neither @@ -30,14 +30,14 @@ static inline void external_antenna(bool on) : GPIO_OUTPUT_INACTIVE)); } -static int board_particle_boron_init(struct device *dev) +static int board_particle_boron_init(const struct device *dev) { ARG_UNUSED(dev); external_antenna(false); #if defined(CONFIG_MODEM_UBLOX_SARA) - struct device *gpio_dev; + const struct device *gpio_dev; /* Enable the serial buffer for SARA-R4 modem */ gpio_dev = device_get_binding(SERIAL_BUFFER_ENABLE_GPIO_NAME); diff --git a/boards/arm/particle_xenon/board.c b/boards/arm/particle_xenon/board.c index 9b9246b4f80308..dc10fdcc08ced8 100644 --- a/boards/arm/particle_xenon/board.c +++ b/boards/arm/particle_xenon/board.c @@ -11,7 +11,7 @@ static inline void external_antenna(bool on) { - struct device *ufl_gpio_dev, *pcb_gpio_dev; + const struct device *ufl_gpio_dev, *pcb_gpio_dev; ufl_gpio_dev = device_get_binding(SKY_UFLn_GPIO_NAME); if (!ufl_gpio_dev) { @@ -35,7 +35,7 @@ static inline void external_antenna(bool on) : GPIO_OUTPUT_ACTIVE)); } -static int board_particle_xenon_init(struct device *dev) +static int board_particle_xenon_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/pico_pi_m4/pinmux.c b/boards/arm/pico_pi_m4/pinmux.c index b448408455855f..0c43e45df1b1a3 100644 --- a/boards/arm/pico_pi_m4/pinmux.c +++ b/boards/arm/pico_pi_m4/pinmux.c @@ -8,7 +8,7 @@ #include #include "device_imx.h" -static int pico_pi_m4_pinmux_init(struct device *dev) +static int pico_pi_m4_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/qemu_cortex_m0/nrf_timer_timer.c b/boards/arm/qemu_cortex_m0/nrf_timer_timer.c index bd85e189c70a08..75668117575d3b 100644 --- a/boards/arm/qemu_cortex_m0/nrf_timer_timer.c +++ b/boards/arm/qemu_cortex_m0/nrf_timer_timer.c @@ -160,7 +160,7 @@ void timer0_nrf_isr(void *arg) z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : (dticks > 0)); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/boards/arm/reel_board/board.c b/boards/arm/reel_board/board.c index e3b409d0a77629..3e9b649b5927b0 100644 --- a/boards/arm/reel_board/board.c +++ b/boards/arm/reel_board/board.c @@ -10,7 +10,7 @@ /* Peripheral voltage ON/OFF GPIO */ #define PERIPH_PON_PIN 0 -static int board_reel_board_init(struct device *dev) +static int board_reel_board_init(const struct device *dev) { ARG_UNUSED(dev); volatile NRF_GPIO_Type *gpio = NRF_P1; diff --git a/boards/arm/sam4e_xpro/pinmux.c b/boards/arm/sam4e_xpro/pinmux.c index 244a68893a086a..961f522f3cf7e1 100644 --- a/boards/arm/sam4e_xpro/pinmux.c +++ b/boards/arm/sam4e_xpro/pinmux.c @@ -6,7 +6,7 @@ #include -static int sam4e_xpro_init(struct device *dev) +static int sam4e_xpro_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/sam_e70_xplained/pinmux.c b/boards/arm/sam_e70_xplained/pinmux.c index 70fc506692bd59..301207e1f2282d 100644 --- a/boards/arm/sam_e70_xplained/pinmux.c +++ b/boards/arm/sam_e70_xplained/pinmux.c @@ -23,7 +23,7 @@ static const struct soc_gpio_pin pwm_ext2_pin8 = { }; #endif -static int sam_e70_xplained_init(struct device *dev) +static int sam_e70_xplained_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/sam_v71_xult/pinmux.c b/boards/arm/sam_v71_xult/pinmux.c index 60be81fe83205e..452cdc087a0da0 100644 --- a/boards/arm/sam_v71_xult/pinmux.c +++ b/boards/arm/sam_v71_xult/pinmux.c @@ -24,7 +24,7 @@ static const struct soc_gpio_pin pwm_ext2_pin8 = { }; #endif -static int sam_v71_xplained_init(struct device *dev) +static int sam_v71_xplained_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/seeeduino_xiao/pinmux.c b/boards/arm/seeeduino_xiao/pinmux.c index 279294af44e55e..3a7ec75bf0afb8 100644 --- a/boards/arm/seeeduino_xiao/pinmux.c +++ b/boards/arm/seeeduino_xiao/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int board_pinmux_init(struct device *dev) +static int board_pinmux_init(const struct device *dev) { - struct device *muxa = + const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a))); - struct device *muxb = + const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b))); ARG_UNUSED(dev); diff --git a/boards/arm/sensortile_box/pinmux.c b/boards/arm/sensortile_box/pinmux.c index eea15a0ec2b0bb..323fc07df57e34 100644 --- a/boards/arm/sensortile_box/pinmux.c +++ b/boards/arm/sensortile_box/pinmux.c @@ -55,7 +55,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/steval_fcu001v1/pinmux.c b/boards/arm/steval_fcu001v1/pinmux.c index 1533ace21271da..49aaaa03012a1e 100644 --- a/boards/arm/steval_fcu001v1/pinmux.c +++ b/boards/arm/steval_fcu001v1/pinmux.c @@ -27,7 +27,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm3210c_eval/pinmux.c b/boards/arm/stm3210c_eval/pinmux.c index 522389fd779fd1..c021259d72c127 100644 --- a/boards/arm/stm3210c_eval/pinmux.c +++ b/boards/arm/stm3210c_eval/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32373c_eval/pinmux.c b/boards/arm/stm32373c_eval/pinmux.c index 1081edb9f3deda..c4f86ac8540b69 100644 --- a/boards/arm/stm32373c_eval/pinmux.c +++ b/boards/arm/stm32373c_eval/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32_min_dev/pinmux.c b/boards/arm/stm32_min_dev/pinmux.c index 216e7c4c7c8e64..4f3af12e924f65 100644 --- a/boards/arm/stm32_min_dev/pinmux.c +++ b/boards/arm/stm32_min_dev/pinmux.c @@ -62,7 +62,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f030_demo/pinmux.c b/boards/arm/stm32f030_demo/pinmux.c index f7e0b734085b3f..fed05d26b59cd9 100644 --- a/boards/arm/stm32f030_demo/pinmux.c +++ b/boards/arm/stm32f030_demo/pinmux.c @@ -21,7 +21,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f072_eval/pinmux.c b/boards/arm/stm32f072_eval/pinmux.c index 94ba344ac1e9b9..fc62423c339ddf 100644 --- a/boards/arm/stm32f072_eval/pinmux.c +++ b/boards/arm/stm32f072_eval/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f072b_disco/pinmux.c b/boards/arm/stm32f072b_disco/pinmux.c index d2383c4e0448ec..5c1298d36a9044 100644 --- a/boards/arm/stm32f072b_disco/pinmux.c +++ b/boards/arm/stm32f072b_disco/pinmux.c @@ -39,7 +39,7 @@ static const struct pin_config pinconf[] = { }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f0_disco/pinmux.c b/boards/arm/stm32f0_disco/pinmux.c index 95365d90e6c371..e2c1b7cc9e05fa 100644 --- a/boards/arm/stm32f0_disco/pinmux.c +++ b/boards/arm/stm32f0_disco/pinmux.c @@ -25,7 +25,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f3_disco/pinmux.c b/boards/arm/stm32f3_disco/pinmux.c index c4544dbd9641d7..c19a2e84c3a348 100644 --- a/boards/arm/stm32f3_disco/pinmux.c +++ b/boards/arm/stm32f3_disco/pinmux.c @@ -59,7 +59,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f411e_disco/pinmux.c b/boards/arm/stm32f411e_disco/pinmux.c index 044d81c857c599..10aeb9b52f52f2 100644 --- a/boards/arm/stm32f411e_disco/pinmux.c +++ b/boards/arm/stm32f411e_disco/pinmux.c @@ -27,7 +27,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f412g_disco/pinmux.c b/boards/arm/stm32f412g_disco/pinmux.c index 2bfcac9286307c..92e351b494e339 100644 --- a/boards/arm/stm32f412g_disco/pinmux.c +++ b/boards/arm/stm32f412g_disco/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f429i_disc1/pinmux.c b/boards/arm/stm32f429i_disc1/pinmux.c index 08d055fb8c286f..9e439d68c868ec 100644 --- a/boards/arm/stm32f429i_disc1/pinmux.c +++ b/boards/arm/stm32f429i_disc1/pinmux.c @@ -44,7 +44,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f469i_disco/pinmux.c b/boards/arm/stm32f469i_disco/pinmux.c index 5928a2276acbb9..0cad2d7032eada 100644 --- a/boards/arm/stm32f469i_disco/pinmux.c +++ b/boards/arm/stm32f469i_disco/pinmux.c @@ -38,7 +38,7 @@ static const struct pin_config pinconf[] = { }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f4_disco/pinmux.c b/boards/arm/stm32f4_disco/pinmux.c index c64836a15fd3d8..67fbc48839ad5e 100644 --- a/boards/arm/stm32f4_disco/pinmux.c +++ b/boards/arm/stm32f4_disco/pinmux.c @@ -39,7 +39,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f723e_disco/pinmux.c b/boards/arm/stm32f723e_disco/pinmux.c index dc12651ba2e104..e476ed144b835b 100644 --- a/boards/arm/stm32f723e_disco/pinmux.c +++ b/boards/arm/stm32f723e_disco/pinmux.c @@ -45,7 +45,7 @@ static const struct pin_config pinconf[] = { #endif /* CONFIG_USB_DC_STM32 */ }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f746g_disco/pinmux.c b/boards/arm/stm32f746g_disco/pinmux.c index 9c9f21bc792870..f7664f8fe45284 100644 --- a/boards/arm/stm32f746g_disco/pinmux.c +++ b/boards/arm/stm32f746g_disco/pinmux.c @@ -70,7 +70,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32f769i_disco/pinmux.c b/boards/arm/stm32f769i_disco/pinmux.c index 9a25b526e6c5cf..4dcfffff823b32 100644 --- a/boards/arm/stm32f769i_disco/pinmux.c +++ b/boards/arm/stm32f769i_disco/pinmux.c @@ -46,7 +46,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32g0316_disco/pinmux.c b/boards/arm/stm32g0316_disco/pinmux.c index 7f926060572f11..121137726c9e42 100644 --- a/boards/arm/stm32g0316_disco/pinmux.c +++ b/boards/arm/stm32g0316_disco/pinmux.c @@ -17,7 +17,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32h747i_disco/pinmux.c b/boards/arm/stm32h747i_disco/pinmux.c index 11c2282f32246e..b865cd316e1b74 100644 --- a/boards/arm/stm32h747i_disco/pinmux.c +++ b/boards/arm/stm32h747i_disco/pinmux.c @@ -24,7 +24,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32l1_disco/pinmux.c b/boards/arm/stm32l1_disco/pinmux.c index 4f97759c4c76cb..716cb856205ee7 100644 --- a/boards/arm/stm32l1_disco/pinmux.c +++ b/boards/arm/stm32l1_disco/pinmux.c @@ -51,7 +51,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32l476g_disco/pinmux.c b/boards/arm/stm32l476g_disco/pinmux.c index dca866d90df24e..e23927a5137c0c 100644 --- a/boards/arm/stm32l476g_disco/pinmux.c +++ b/boards/arm/stm32l476g_disco/pinmux.c @@ -20,7 +20,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32l496g_disco/pinmux.c b/boards/arm/stm32l496g_disco/pinmux.c index f7a2c1a127b606..2e2beb7cadaeb4 100644 --- a/boards/arm/stm32l496g_disco/pinmux.c +++ b/boards/arm/stm32l496g_disco/pinmux.c @@ -50,7 +50,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32mp157c_dk2/pinmux.c b/boards/arm/stm32mp157c_dk2/pinmux.c index 5f42992f1c74a5..3bfd78ddd511a7 100644 --- a/boards/arm/stm32mp157c_dk2/pinmux.c +++ b/boards/arm/stm32mp157c_dk2/pinmux.c @@ -46,7 +46,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/stm32vl_disco/pinmux.c b/boards/arm/stm32vl_disco/pinmux.c index 0e64c8c307d032..f378fc9c0dd639 100644 --- a/boards/arm/stm32vl_disco/pinmux.c +++ b/boards/arm/stm32vl_disco/pinmux.c @@ -55,7 +55,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/thingy52_nrf52832/board.c b/boards/arm/thingy52_nrf52832/board.c index 5782b9b6bd745a..3adbbb3f4cdcff 100644 --- a/boards/arm/thingy52_nrf52832/board.c +++ b/boards/arm/thingy52_nrf52832/board.c @@ -16,10 +16,10 @@ struct pwr_ctrl_cfg { uint32_t pin; }; -static int pwr_ctrl_init(struct device *dev) +static int pwr_ctrl_init(const struct device *dev) { const struct pwr_ctrl_cfg *cfg = dev->config; - struct device *gpio; + const struct device *gpio; gpio = device_get_binding(cfg->port); if (!gpio) { diff --git a/boards/arm/twr_ke18f/pinmux.c b/boards/arm/twr_ke18f/pinmux.c index 2b22f29da79c26..d5783d4870b97d 100644 --- a/boards/arm/twr_ke18f/pinmux.c +++ b/boards/arm/twr_ke18f/pinmux.c @@ -8,29 +8,29 @@ #include #include -static int twr_ke18f_pinmux_init(struct device *dev) +static int twr_ke18f_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - __unused struct device *porta = + __unused const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - __unused struct device *portb = + __unused const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - __unused struct device *portc = + __unused const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - __unused struct device *portd = + __unused const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - __unused struct device *porte = + __unused const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/twr_kv58f220m/pinmux.c b/boards/arm/twr_kv58f220m/pinmux.c index f8dd54361869d4..df488ddf046d02 100644 --- a/boards/arm/twr_kv58f220m/pinmux.c +++ b/boards/arm/twr_kv58f220m/pinmux.c @@ -8,28 +8,28 @@ #include #include -static int twr_kv58f220m_pinmux_init(struct device *dev) +static int twr_kv58f220m_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - __unused struct device *porta = + __unused const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - __unused struct device *portb = + __unused const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - __unused struct device *portc = + __unused const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - __unused struct device *portd = + __unused const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTE - __unused struct device *porte = + __unused const struct device *porte = device_get_binding(CONFIG_PINMUX_MCUX_PORTE_NAME); #endif diff --git a/boards/arm/udoo_neo_full_m4/pinmux.c b/boards/arm/udoo_neo_full_m4/pinmux.c index 155990f0a1736c..aab685df25175d 100644 --- a/boards/arm/udoo_neo_full_m4/pinmux.c +++ b/boards/arm/udoo_neo_full_m4/pinmux.c @@ -7,7 +7,7 @@ #include #include "device_imx.h" -static int udoo_neo_full_m4_init(struct device *dev) +static int udoo_neo_full_m4_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/boards/arm/usb_kw24d512/pinmux.c b/boards/arm/usb_kw24d512/pinmux.c index c9ef4821d0cd06..73bd5c1bb9ac3c 100644 --- a/boards/arm/usb_kw24d512/pinmux.c +++ b/boards/arm/usb_kw24d512/pinmux.c @@ -8,24 +8,24 @@ #include #include -static int usb_kw24d512_pinmux_init(struct device *dev) +static int usb_kw24d512_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #ifdef CONFIG_PINMUX_MCUX_PORTA - struct device *porta = + const struct device *porta = device_get_binding(CONFIG_PINMUX_MCUX_PORTA_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTB - struct device *portb = + const struct device *portb = device_get_binding(CONFIG_PINMUX_MCUX_PORTB_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTC - struct device *portc = + const struct device *portc = device_get_binding(CONFIG_PINMUX_MCUX_PORTC_NAME); #endif #ifdef CONFIG_PINMUX_MCUX_PORTD - struct device *portd = + const struct device *portd = device_get_binding(CONFIG_PINMUX_MCUX_PORTD_NAME); #endif diff --git a/boards/arm/v2m_beetle/pinmux.c b/boards/arm/v2m_beetle/pinmux.c index 4ebcd8781b3ed2..3892499cc00c5f 100644 --- a/boards/arm/v2m_beetle/pinmux.c +++ b/boards/arm/v2m_beetle/pinmux.c @@ -135,7 +135,7 @@ static void arm_v2m_beetle_pinmux_defaults(void) CMSDK_AHB_GPIO1_DEV->data |= (0x1 << 15); } -static int arm_v2m_beetle_pinmux_init(struct device *port) +static int arm_v2m_beetle_pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/v2m_musca/pinmux.c b/boards/arm/v2m_musca/pinmux.c index be78dd15ac0b22..3434fb9edeb978 100644 --- a/boards/arm/v2m_musca/pinmux.c +++ b/boards/arm/v2m_musca/pinmux.c @@ -58,7 +58,7 @@ static void arm_musca_pinmux_defaults(void) } #endif -static int arm_musca_pinmux_init(struct device *port) +static int arm_musca_pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/v2m_musca_b1/pinmux.c b/boards/arm/v2m_musca_b1/pinmux.c index 1d3d4074a08266..f1e45e616b0699 100644 --- a/boards/arm/v2m_musca_b1/pinmux.c +++ b/boards/arm/v2m_musca_b1/pinmux.c @@ -59,7 +59,7 @@ static void arm_musca_b1_pinmux_defaults(void) } #endif -static int arm_musca_pinmux_init(struct device *port) +static int arm_musca_pinmux_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/arm/warp7_m4/pinmux.c b/boards/arm/warp7_m4/pinmux.c index 0955dab1fd60c2..6ecb5d9edfe54e 100644 --- a/boards/arm/warp7_m4/pinmux.c +++ b/boards/arm/warp7_m4/pinmux.c @@ -7,7 +7,7 @@ #include #include "device_imx.h" -static int warp7_m4_pinmux_init(struct device *dev) +static int warp7_m4_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #if defined(CONFIG_FXOS8700) || defined(CONFIG_FXAS21002) diff --git a/boards/arm/waveshare_open103z/pinmux.c b/boards/arm/waveshare_open103z/pinmux.c index 4bd82f5c897d7e..6d362b7b56d99f 100644 --- a/boards/arm/waveshare_open103z/pinmux.c +++ b/boards/arm/waveshare_open103z/pinmux.c @@ -62,7 +62,7 @@ static const struct pin_config pinconf[] = { #endif }; -static int pinmux_stm32_init(struct device *port) +static int pinmux_stm32_init(const struct device *port) { ARG_UNUSED(port); diff --git a/boards/posix/nrf52_bsim/bstests_entry.c b/boards/posix/nrf52_bsim/bstests_entry.c index d192f53e37d444..1e1cf4216f4a01 100644 --- a/boards/posix/nrf52_bsim/bstests_entry.c +++ b/boards/posix/nrf52_bsim/bstests_entry.c @@ -191,7 +191,7 @@ bool bst_irq_sniffer(int irq_number) } } -static int bst_fake_device_driver_pre2_init(struct device *arg) +static int bst_fake_device_driver_pre2_init(const struct device *arg) { ARG_UNUSED(arg); if (current_test && current_test->test_fake_ddriver_prekernel_f) { @@ -200,7 +200,7 @@ static int bst_fake_device_driver_pre2_init(struct device *arg) return 0; } -static int bst_fake_device_driver_post_init(struct device *arg) +static int bst_fake_device_driver_post_init(const struct device *arg) { ARG_UNUSED(arg); if (current_test && current_test->test_fake_ddriver_postkernel_f) { diff --git a/boards/posix/nrf52_bsim/trace_hook.c b/boards/posix/nrf52_bsim/trace_hook.c index 89436c1d404b1f..b2feb9590b8ddd 100644 --- a/boards/posix/nrf52_bsim/trace_hook.c +++ b/boards/posix/nrf52_bsim/trace_hook.c @@ -59,7 +59,7 @@ void posix_flush_stdout(void) * * @return 0 if successful, otherwise failed. */ -static int printk_init(struct device *arg) +static int printk_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/boards/riscv/hifive1/pinmux.c b/boards/riscv/hifive1/pinmux.c index 6e36f159fc63f8..9be8df7e651b34 100644 --- a/boards/riscv/hifive1/pinmux.c +++ b/boards/riscv/hifive1/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int hifive1_pinmux_init(struct device *dev) +static int hifive1_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); - struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME); + const struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME); /* UART0 RX */ pinmux_pin_set(p, 16, SIFIVE_PINMUX_IOF0); diff --git a/boards/riscv/hifive1_revb/pinmux.c b/boards/riscv/hifive1_revb/pinmux.c index 605645da960bc0..6ff750e5ca0eeb 100644 --- a/boards/riscv/hifive1_revb/pinmux.c +++ b/boards/riscv/hifive1_revb/pinmux.c @@ -8,11 +8,11 @@ #include #include -static int hifive1_revb_pinmux_init(struct device *dev) +static int hifive1_revb_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); - struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME); + const struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME); #ifdef CONFIG_UART_SIFIVE #ifdef CONFIG_UART_SIFIVE_PORT_0 diff --git a/boards/riscv/rv32m1_vega/pinmux.c b/boards/riscv/rv32m1_vega/pinmux.c index 365120f4f3f28c..2a13a14d097cc0 100644 --- a/boards/riscv/rv32m1_vega/pinmux.c +++ b/boards/riscv/rv32m1_vega/pinmux.c @@ -10,33 +10,33 @@ #include #ifdef CONFIG_BT_CTLR_DEBUG_PINS -struct device *vega_debug_portb; -struct device *vega_debug_portc; -struct device *vega_debug_portd; +const struct device *vega_debug_portb; +const struct device *vega_debug_portc; +const struct device *vega_debug_portd; #endif -static int rv32m1_vega_pinmux_init(struct device *dev) +static int rv32m1_vega_pinmux_init(const struct device *dev) { ARG_UNUSED(dev); #if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) - __unused struct device *porta = + __unused const struct device *porta = device_get_binding(DT_LABEL(DT_NODELABEL(porta))); #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(portb), okay) - __unused struct device *portb = + __unused const struct device *portb = device_get_binding(DT_LABEL(DT_NODELABEL(portb))); #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(portc), okay) - __unused struct device *portc = + __unused const struct device *portc = device_get_binding(DT_LABEL(DT_NODELABEL(portc))); #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(portd), okay) - __unused struct device *portd = + __unused const struct device *portd = device_get_binding(DT_LABEL(DT_NODELABEL(portd))); #endif #if DT_NODE_HAS_STATUS(DT_NODELABEL(porte), okay) - __unused struct device *porte = + __unused const struct device *porte = device_get_binding(DT_LABEL(DT_NODELABEL(porte))); #endif @@ -112,7 +112,7 @@ static int rv32m1_vega_pinmux_init(struct device *dev) pinmux_pin_set(portd, 4, PORT_PCR_MUX(kPORT_MuxAsGpio)); pinmux_pin_set(portd, 5, PORT_PCR_MUX(kPORT_MuxAsGpio)); - struct device *gpio_dev = + const struct device *gpio_dev = device_get_binding(DT_LABEL(DT_NODELABEL(gpiob))); gpio_pin_configure(gpio_dev, 29, GPIO_OUTPUT); diff --git a/boards/xtensa/intel_s1000_crb/pinmux.c b/boards/xtensa/intel_s1000_crb/pinmux.c index 93fa51738e5465..510f84770419c3 100644 --- a/boards/xtensa/intel_s1000_crb/pinmux.c +++ b/boards/xtensa/intel_s1000_crb/pinmux.c @@ -21,9 +21,9 @@ * Please note that a call to pinmux_pin_set is only needed when a setting * that is not default is required */ -static int intel_s1000_pinmux_init(struct device *dev) +static int intel_s1000_pinmux_init(const struct device *dev) { - struct device *pinmux; + const struct device *pinmux; pinmux = device_get_binding(CONFIG_PINMUX_NAME); diff --git a/doc/reference/power_management/index.rst b/doc/reference/power_management/index.rst index 3c12e77f70e437..f43c15585423ab 100644 --- a/doc/reference/power_management/index.rst +++ b/doc/reference/power_management/index.rst @@ -299,7 +299,7 @@ Get Device List .. code-block:: c - size_t z_device_get_all_static(struct device **device_list); + size_t z_device_get_all_static(struct device const **device_list); The Zephyr RTOS kernel internally maintains a list of all devices in the system. The SOC interface uses this API to get the device list. The SOC interface can use the list to diff --git a/drivers/adc/adc_context.h b/drivers/adc/adc_context.h index 6c86d71e042b55..8138a14276759a 100644 --- a/drivers/adc/adc_context.h +++ b/drivers/adc/adc_context.h @@ -206,7 +206,7 @@ static inline void adc_context_start_read(struct adc_context *ctx, * function if required and takes further actions accordingly. */ static inline void adc_context_on_sampling_done(struct adc_context *ctx, - struct device *dev) + const struct device *dev) { if (ctx->sequence.options) { adc_sequence_callback callback = ctx->options.callback; diff --git a/drivers/adc/adc_handlers.c b/drivers/adc/adc_handlers.c index 954f09e7f40a9a..175ad4799b72b8 100644 --- a/drivers/adc/adc_handlers.c +++ b/drivers/adc/adc_handlers.c @@ -8,8 +8,8 @@ #include #include -static inline int z_vrfy_adc_channel_setup(struct device *dev, - const struct adc_channel_cfg *user_channel_cfg) +static inline int z_vrfy_adc_channel_setup(const struct device *dev, + const struct adc_channel_cfg *user_channel_cfg) { struct adc_channel_cfg channel_cfg; @@ -18,7 +18,8 @@ static inline int z_vrfy_adc_channel_setup(struct device *dev, (struct adc_channel_cfg *)user_channel_cfg, sizeof(struct adc_channel_cfg))); - return z_impl_adc_channel_setup((struct device *)dev, &channel_cfg); + return z_impl_adc_channel_setup((const struct device *)dev, + &channel_cfg); } #include @@ -47,8 +48,8 @@ static bool copy_sequence(struct adc_sequence *dst, return true; } -static inline int z_vrfy_adc_read(struct device *dev, - const struct adc_sequence *user_sequence) +static inline int z_vrfy_adc_read(const struct device *dev, + const struct adc_sequence *user_sequence) { struct adc_sequence sequence; @@ -63,14 +64,14 @@ static inline int z_vrfy_adc_read(struct device *dev, "ADC sequence callbacks forbidden from user mode")); } - return z_impl_adc_read((struct device *)dev, &sequence); + return z_impl_adc_read((const struct device *)dev, &sequence); } #include #ifdef CONFIG_ADC_ASYNC -static inline int z_vrfy_adc_read_async(struct device *dev, - const struct adc_sequence *user_sequence, - struct k_poll_signal *async) +static inline int z_vrfy_adc_read_async(const struct device *dev, + const struct adc_sequence *user_sequence, + struct k_poll_signal *async) { struct adc_sequence sequence; struct adc_sequence_options options; @@ -85,7 +86,7 @@ static inline int z_vrfy_adc_read_async(struct device *dev, } Z_OOPS(Z_SYSCALL_OBJ(async, K_OBJ_POLL_SIGNAL)); - return z_impl_adc_read_async((struct device *)dev, &sequence, + return z_impl_adc_read_async((const struct device *)dev, &sequence, (struct k_poll_signal *)async); } #include diff --git a/drivers/adc/adc_lmp90xxx.c b/drivers/adc/adc_lmp90xxx.c index 8b9961b13b101f..0c4c20019c323b 100644 --- a/drivers/adc/adc_lmp90xxx.c +++ b/drivers/adc/adc_lmp90xxx.c @@ -122,7 +122,7 @@ struct lmp90xxx_config { struct lmp90xxx_data { struct adc_context ctx; - struct device *spi_dev; + const struct device *spi_dev; struct spi_cs_control spi_cs; struct gpio_callback drdyb_cb; struct k_mutex ura_lock; @@ -173,7 +173,8 @@ static inline uint8_t lmp90xxx_inst2_sz(size_t len) } } -static int lmp90xxx_read_reg(struct device *dev, uint8_t addr, uint8_t *dptr, +static int lmp90xxx_read_reg(const struct device *dev, uint8_t addr, + uint8_t *dptr, size_t len) { const struct lmp90xxx_config *config = dev->config; @@ -242,12 +243,14 @@ static int lmp90xxx_read_reg(struct device *dev, uint8_t addr, uint8_t *dptr, return err; } -static int lmp90xxx_read_reg8(struct device *dev, uint8_t addr, uint8_t *val) +static int lmp90xxx_read_reg8(const struct device *dev, uint8_t addr, + uint8_t *val) { return lmp90xxx_read_reg(dev, addr, val, sizeof(val)); } -static int lmp90xxx_write_reg(struct device *dev, uint8_t addr, uint8_t *dptr, +static int lmp90xxx_write_reg(const struct device *dev, uint8_t addr, + uint8_t *dptr, size_t len) { const struct lmp90xxx_config *config = dev->config; @@ -306,12 +309,13 @@ static int lmp90xxx_write_reg(struct device *dev, uint8_t addr, uint8_t *dptr, return err; } -static int lmp90xxx_write_reg8(struct device *dev, uint8_t addr, uint8_t val) +static int lmp90xxx_write_reg8(const struct device *dev, uint8_t addr, + uint8_t val) { return lmp90xxx_write_reg(dev, addr, &val, sizeof(val)); } -static int lmp90xxx_soft_reset(struct device *dev) +static int lmp90xxx_soft_reset(const struct device *dev) { int err; @@ -326,7 +330,8 @@ static int lmp90xxx_soft_reset(struct device *dev) LMP90XXX_REG_AND_CNV_RST); } -static inline bool lmp90xxx_has_channel(struct device *dev, uint8_t channel) +static inline bool lmp90xxx_has_channel(const struct device *dev, + uint8_t channel) { const struct lmp90xxx_config *config = dev->config; @@ -337,7 +342,7 @@ static inline bool lmp90xxx_has_channel(struct device *dev, uint8_t channel) } } -static inline bool lmp90xxx_has_input(struct device *dev, uint8_t input) +static inline bool lmp90xxx_has_input(const struct device *dev, uint8_t input) { const struct lmp90xxx_config *config = dev->config; @@ -377,7 +382,7 @@ static inline int lmp90xxx_acq_time_to_odr(uint16_t acq_time) return -EINVAL; } -static int lmp90xxx_adc_channel_setup(struct device *dev, +static int lmp90xxx_adc_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { struct lmp90xxx_data *data = dev->data; @@ -494,7 +499,7 @@ static int lmp90xxx_validate_buffer_size(const struct adc_sequence *sequence) return 0; } -static int lmp90xxx_adc_start_read(struct device *dev, +static int lmp90xxx_adc_start_read(const struct device *dev, const struct adc_sequence *sequence) { const struct lmp90xxx_config *config = dev->config; @@ -525,7 +530,7 @@ static int lmp90xxx_adc_start_read(struct device *dev, return adc_context_wait_for_completion(&data->ctx); } -static int lmp90xxx_adc_read_async(struct device *dev, +static int lmp90xxx_adc_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -539,7 +544,7 @@ static int lmp90xxx_adc_read_async(struct device *dev, return err; } -static int lmp90xxx_adc_read(struct device *dev, +static int lmp90xxx_adc_read(const struct device *dev, const struct adc_sequence *sequence) { return lmp90xxx_adc_read_async(dev, sequence, NULL); @@ -567,7 +572,8 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, } } -static int lmp90xxx_adc_read_channel(struct device *dev, uint8_t channel, +static int lmp90xxx_adc_read_channel(const struct device *dev, + uint8_t channel, int32_t *result) { const struct lmp90xxx_config *config = dev->config; @@ -647,7 +653,7 @@ static int lmp90xxx_adc_read_channel(struct device *dev, uint8_t channel, return 0; } -static void lmp90xxx_acquisition_thread(struct device *dev) +static void lmp90xxx_acquisition_thread(const struct device *dev) { struct lmp90xxx_data *data = dev->data; uint8_t bgcalcn = LMP90XXX_BGCALN(0x3); /* Default to BgCalMode3 */ @@ -699,7 +705,7 @@ static void lmp90xxx_acquisition_thread(struct device *dev) } } -static void lmp90xxx_drdyb_callback(struct device *port, +static void lmp90xxx_drdyb_callback(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct lmp90xxx_data *data = @@ -710,7 +716,7 @@ static void lmp90xxx_drdyb_callback(struct device *port, } #ifdef CONFIG_ADC_LMP90XXX_GPIO -int lmp90xxx_gpio_set_output(struct device *dev, uint8_t pin) +int lmp90xxx_gpio_set_output(const struct device *dev, uint8_t pin) { struct lmp90xxx_data *data = dev->data; int err = 0; @@ -735,7 +741,7 @@ int lmp90xxx_gpio_set_output(struct device *dev, uint8_t pin) return err; } -int lmp90xxx_gpio_set_input(struct device *dev, uint8_t pin) +int lmp90xxx_gpio_set_input(const struct device *dev, uint8_t pin) { struct lmp90xxx_data *data = dev->data; int err = 0; @@ -760,7 +766,8 @@ int lmp90xxx_gpio_set_input(struct device *dev, uint8_t pin) return err; } -int lmp90xxx_gpio_set_pin_value(struct device *dev, uint8_t pin, bool value) +int lmp90xxx_gpio_set_pin_value(const struct device *dev, uint8_t pin, + bool value) { struct lmp90xxx_data *data = dev->data; int err = 0; @@ -787,7 +794,8 @@ int lmp90xxx_gpio_set_pin_value(struct device *dev, uint8_t pin, bool value) return err; } -int lmp90xxx_gpio_get_pin_value(struct device *dev, uint8_t pin, bool *value) +int lmp90xxx_gpio_get_pin_value(const struct device *dev, uint8_t pin, + bool *value) { struct lmp90xxx_data *data = dev->data; int err = 0; @@ -809,7 +817,8 @@ int lmp90xxx_gpio_get_pin_value(struct device *dev, uint8_t pin, bool *value) return err; } -int lmp90xxx_gpio_port_get_raw(struct device *dev, gpio_port_value_t *value) +int lmp90xxx_gpio_port_get_raw(const struct device *dev, + gpio_port_value_t *value) { struct lmp90xxx_data *data = dev->data; uint8_t tmp; @@ -825,7 +834,7 @@ int lmp90xxx_gpio_port_get_raw(struct device *dev, gpio_port_value_t *value) return err; } -int lmp90xxx_gpio_port_set_masked_raw(struct device *dev, +int lmp90xxx_gpio_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -848,7 +857,8 @@ int lmp90xxx_gpio_port_set_masked_raw(struct device *dev, return err; } -int lmp90xxx_gpio_port_set_bits_raw(struct device *dev, gpio_port_pins_t pins) +int lmp90xxx_gpio_port_set_bits_raw(const struct device *dev, + gpio_port_pins_t pins) { struct lmp90xxx_data *data = dev->data; int err = 0; @@ -869,7 +879,7 @@ int lmp90xxx_gpio_port_set_bits_raw(struct device *dev, gpio_port_pins_t pins) return err; } -int lmp90xxx_gpio_port_clear_bits_raw(struct device *dev, +int lmp90xxx_gpio_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { struct lmp90xxx_data *data = dev->data; @@ -891,7 +901,8 @@ int lmp90xxx_gpio_port_clear_bits_raw(struct device *dev, return err; } -int lmp90xxx_gpio_port_toggle_bits(struct device *dev, gpio_port_pins_t pins) +int lmp90xxx_gpio_port_toggle_bits(const struct device *dev, + gpio_port_pins_t pins) { struct lmp90xxx_data *data = dev->data; uint8_t tmp; @@ -912,11 +923,11 @@ int lmp90xxx_gpio_port_toggle_bits(struct device *dev, gpio_port_pins_t pins) #endif /* CONFIG_ADC_LMP90XXX_GPIO */ -static int lmp90xxx_init(struct device *dev) +static int lmp90xxx_init(const struct device *dev) { const struct lmp90xxx_config *config = dev->config; struct lmp90xxx_data *data = dev->data; - struct device *drdyb_dev; + const struct device *drdyb_dev; k_tid_t tid; int err; diff --git a/drivers/adc/adc_mchp_xec.c b/drivers/adc/adc_mchp_xec.c index 11e73ea53c3745..83228e47a4a01e 100644 --- a/drivers/adc/adc_mchp_xec.c +++ b/drivers/adc/adc_mchp_xec.c @@ -76,7 +76,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, } } -static int adc_xec_channel_setup(struct device *dev, +static int adc_xec_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE; @@ -146,7 +146,7 @@ static bool adc_xec_validate_buffer_size(const struct adc_sequence *sequence) return true; } -static int adc_xec_start_read(struct device *dev, +static int adc_xec_start_read(const struct device *dev, const struct adc_sequence *sequence) { struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE; @@ -191,7 +191,7 @@ static int adc_xec_start_read(struct device *dev, return adc_context_wait_for_completion(&data->ctx); } -static int adc_xec_read(struct device *dev, +static int adc_xec_read(const struct device *dev, const struct adc_sequence *sequence) { struct adc_xec_data *data = dev->data; @@ -205,7 +205,7 @@ static int adc_xec_read(struct device *dev, } #if defined(CONFIG_ADC_ASYNC) -static int adc_xec_read_async(struct device *dev, +static int adc_xec_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -220,7 +220,7 @@ static int adc_xec_read_async(struct device *dev, } #endif /* CONFIG_ADC_ASYNC */ -static void xec_adc_get_sample(struct device *dev) +static void xec_adc_get_sample(const struct device *dev) { struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE; struct adc_xec_data *data = dev->data; @@ -251,7 +251,7 @@ static void xec_adc_get_sample(struct device *dev) adc_regs->status_reg = ch_status; } -static void adc_xec_isr(struct device *dev) +static void adc_xec_isr(const struct device *dev) { struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE; struct adc_xec_data *data = dev->data; @@ -282,7 +282,7 @@ struct adc_driver_api adc_xec_api = { .ref_internal = XEC_ADC_VREF_ANALOG, }; -static int adc_xec_init(struct device *dev) +static int adc_xec_init(const struct device *dev) { struct adc_xec_regs *adc_regs = ADC_XEC_REG_BASE; struct adc_xec_data *data = dev->data; diff --git a/drivers/adc/adc_mcp320x.c b/drivers/adc/adc_mcp320x.c index b5987dbe0da452..e109d4f589084b 100644 --- a/drivers/adc/adc_mcp320x.c +++ b/drivers/adc/adc_mcp320x.c @@ -36,7 +36,7 @@ struct mcp320x_config { struct mcp320x_data { struct adc_context ctx; - struct device *spi_dev; + const struct device *spi_dev; struct spi_cs_control spi_cs; uint16_t *buffer; uint16_t *repeat_buffer; @@ -49,7 +49,7 @@ struct mcp320x_data { CONFIG_ADC_MCP320X_ACQUISITION_THREAD_STACK_SIZE); }; -static int mcp320x_channel_setup(struct device *dev, +static int mcp320x_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { const struct mcp320x_config *config = dev->config; @@ -83,7 +83,7 @@ static int mcp320x_channel_setup(struct device *dev, return 0; } -static int mcp320x_validate_buffer_size(struct device *dev, +static int mcp320x_validate_buffer_size(const struct device *dev, const struct adc_sequence *sequence) { const struct mcp320x_config *config = dev->config; @@ -109,7 +109,7 @@ static int mcp320x_validate_buffer_size(struct device *dev, return 0; } -static int mcp320x_start_read(struct device *dev, +static int mcp320x_start_read(const struct device *dev, const struct adc_sequence *sequence) { const struct mcp320x_config *config = dev->config; @@ -139,7 +139,7 @@ static int mcp320x_start_read(struct device *dev, return adc_context_wait_for_completion(&data->ctx); } -static int mcp320x_read_async(struct device *dev, +static int mcp320x_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -153,7 +153,7 @@ static int mcp320x_read_async(struct device *dev, return err; } -static int mcp320x_read(struct device *dev, +static int mcp320x_read(const struct device *dev, const struct adc_sequence *sequence) { return mcp320x_read_async(dev, sequence, NULL); @@ -179,7 +179,8 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, } } -static int mcp320x_read_channel(struct device *dev, uint8_t channel, uint16_t *result) +static int mcp320x_read_channel(const struct device *dev, uint8_t channel, + uint16_t *result) { const struct mcp320x_config *config = dev->config; struct mcp320x_data *data = dev->data; @@ -237,7 +238,7 @@ static int mcp320x_read_channel(struct device *dev, uint8_t channel, uint16_t *r return 0; } -static void mcp320x_acquisition_thread(struct device *dev) +static void mcp320x_acquisition_thread(const struct device *dev) { struct mcp320x_data *data = dev->data; uint16_t result = 0; @@ -271,7 +272,7 @@ static void mcp320x_acquisition_thread(struct device *dev) } } -static int mcp320x_init(struct device *dev) +static int mcp320x_init(const struct device *dev) { const struct mcp320x_config *config = dev->config; struct mcp320x_data *data = dev->data; diff --git a/drivers/adc/adc_mcux_adc12.c b/drivers/adc/adc_mcux_adc12.c index 78a93897b97211..fc8fd6e7e3b939 100644 --- a/drivers/adc/adc_mcux_adc12.c +++ b/drivers/adc/adc_mcux_adc12.c @@ -25,11 +25,11 @@ struct mcux_adc12_config { adc12_clock_divider_t clock_div; adc12_reference_voltage_source_t ref_src; uint32_t sample_clk_count; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_adc12_data { - struct device *dev; + const struct device *dev; struct adc_context ctx; uint16_t *buffer; uint16_t *repeat_buffer; @@ -37,7 +37,7 @@ struct mcux_adc12_data { uint8_t channel_id; }; -static int mcux_adc12_channel_setup(struct device *dev, +static int mcux_adc12_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { uint8_t channel_id = channel_cfg->channel_id; @@ -70,7 +70,7 @@ static int mcux_adc12_channel_setup(struct device *dev, return 0; } -static int mcux_adc12_start_read(struct device *dev, +static int mcux_adc12_start_read(const struct device *dev, const struct adc_sequence *sequence) { const struct mcux_adc12_config *config = dev->config; @@ -130,7 +130,7 @@ static int mcux_adc12_start_read(struct device *dev, return error; } -static int mcux_adc12_read_async(struct device *dev, +static int mcux_adc12_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -144,13 +144,13 @@ static int mcux_adc12_read_async(struct device *dev, return error; } -static int mcux_adc12_read(struct device *dev, +static int mcux_adc12_read(const struct device *dev, const struct adc_sequence *sequence) { return mcux_adc12_read_async(dev, sequence, NULL); } -static void mcux_adc12_start_channel(struct device *dev) +static void mcux_adc12_start_channel(const struct device *dev) { const struct mcux_adc12_config *config = dev->config; struct mcux_adc12_data *data = dev->data; @@ -190,7 +190,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, static void mcux_adc12_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_adc12_config *config = dev->config; struct mcux_adc12_data *data = dev->data; ADC_Type *base = config->base; @@ -211,7 +211,7 @@ static void mcux_adc12_isr(void *arg) } } -static int mcux_adc12_init(struct device *dev) +static int mcux_adc12_init(const struct device *dev) { const struct mcux_adc12_config *config = dev->config; struct mcux_adc12_data *data = dev->data; diff --git a/drivers/adc/adc_mcux_adc16.c b/drivers/adc/adc_mcux_adc16.c index 9012da579f8e59..5be4ef6ed5a059 100644 --- a/drivers/adc/adc_mcux_adc16.c +++ b/drivers/adc/adc_mcux_adc16.c @@ -19,11 +19,11 @@ LOG_MODULE_REGISTER(adc_mcux_adc16); struct mcux_adc16_config { ADC_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_adc16_data { - struct device *dev; + const struct device *dev; struct adc_context ctx; uint16_t *buffer; uint16_t *repeat_buffer; @@ -31,7 +31,7 @@ struct mcux_adc16_data { uint8_t channel_id; }; -static int mcux_adc16_channel_setup(struct device *dev, +static int mcux_adc16_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { uint8_t channel_id = channel_cfg->channel_id; @@ -64,7 +64,8 @@ static int mcux_adc16_channel_setup(struct device *dev, return 0; } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { const struct mcux_adc16_config *config = dev->config; struct mcux_adc16_data *data = dev->data; @@ -131,7 +132,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) return error; } -static int mcux_adc16_read(struct device *dev, +static int mcux_adc16_read(const struct device *dev, const struct adc_sequence *sequence) { struct mcux_adc16_data *data = dev->data; @@ -145,7 +146,7 @@ static int mcux_adc16_read(struct device *dev, } #ifdef CONFIG_ADC_ASYNC -static int mcux_adc16_read_async(struct device *dev, +static int mcux_adc16_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -160,7 +161,7 @@ static int mcux_adc16_read_async(struct device *dev, } #endif -static void mcux_adc16_start_channel(struct device *dev) +static void mcux_adc16_start_channel(const struct device *dev) { const struct mcux_adc16_config *config = dev->config; struct mcux_adc16_data *data = dev->data; @@ -204,7 +205,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, static void mcux_adc16_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_adc16_config *config = dev->config; struct mcux_adc16_data *data = dev->data; ADC_Type *base = config->base; @@ -225,7 +226,7 @@ static void mcux_adc16_isr(void *arg) } } -static int mcux_adc16_init(struct device *dev) +static int mcux_adc16_init(const struct device *dev) { const struct mcux_adc16_config *config = dev->config; struct mcux_adc16_data *data = dev->data; diff --git a/drivers/adc/adc_nrfx_adc.c b/drivers/adc/adc_nrfx_adc.c index 7d40437e03f679..bfa99ff7bbb9f8 100644 --- a/drivers/adc/adc_nrfx_adc.c +++ b/drivers/adc/adc_nrfx_adc.c @@ -31,7 +31,7 @@ static nrfx_adc_channel_t m_channels[CONFIG_ADC_NRFX_ADC_CHANNEL_COUNT]; /* Implementation of the ADC driver API function: adc_channel_setup. */ -static int adc_nrfx_channel_setup(struct device *dev, +static int adc_nrfx_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { uint8_t channel_id = channel_cfg->channel_id; @@ -136,7 +136,8 @@ static int check_buffer_size(const struct adc_sequence *sequence, return 0; } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { int error; uint32_t selected_channels = sequence->channels; @@ -210,7 +211,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) } /* Implementation of the ADC driver API function: adc_read. */ -static int adc_nrfx_read(struct device *dev, +static int adc_nrfx_read(const struct device *dev, const struct adc_sequence *sequence) { int error; @@ -224,7 +225,7 @@ static int adc_nrfx_read(struct device *dev, #ifdef CONFIG_ADC_ASYNC /* Implementation of the ADC driver API function: adc_read_sync. */ -static int adc_nrfx_read_async(struct device *dev, +static int adc_nrfx_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -242,14 +243,14 @@ DEVICE_DECLARE(adc_0); static void event_handler(const nrfx_adc_evt_t *p_event) { - struct device *dev = DEVICE_GET(adc_0); + const struct device *dev = DEVICE_GET(adc_0); if (p_event->type == NRFX_ADC_EVT_DONE) { adc_context_on_sampling_done(&m_data.ctx, dev); } } -static int init_adc(struct device *dev) +static int init_adc(const struct device *dev) { const nrfx_adc_config_t config = NRFX_ADC_DEFAULT_CONFIG; diff --git a/drivers/adc/adc_nrfx_saadc.c b/drivers/adc/adc_nrfx_saadc.c index 77b98f4533dcd4..b0ca9c93b0c699 100644 --- a/drivers/adc/adc_nrfx_saadc.c +++ b/drivers/adc/adc_nrfx_saadc.c @@ -28,7 +28,7 @@ static struct driver_data m_data = { /* Implementation of the ADC driver API function: adc_channel_setup. */ -static int adc_nrfx_channel_setup(struct device *dev, +static int adc_nrfx_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { nrf_saadc_channel_config_t config = { @@ -253,7 +253,8 @@ static int check_buffer_size(const struct adc_sequence *sequence, return 0; } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { int error; uint32_t selected_channels = sequence->channels; @@ -337,7 +338,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) } /* Implementation of the ADC driver API function: adc_read. */ -static int adc_nrfx_read(struct device *dev, +static int adc_nrfx_read(const struct device *dev, const struct adc_sequence *sequence) { int error; @@ -351,7 +352,7 @@ static int adc_nrfx_read(struct device *dev, #ifdef CONFIG_ADC_ASYNC /* Implementation of the ADC driver API function: adc_read_async. */ -static int adc_nrfx_read_async(struct device *dev, +static int adc_nrfx_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -367,7 +368,7 @@ static int adc_nrfx_read_async(struct device *dev, static void saadc_irq_handler(void *param) { - struct device *dev = (struct device *)param; + const struct device *dev = (const struct device *)param; if (nrf_saadc_event_check(NRF_SAADC, NRF_SAADC_EVENT_END)) { nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END); @@ -393,7 +394,7 @@ static void saadc_irq_handler(void *param) DEVICE_DECLARE(adc_0); -static int init_saadc(struct device *dev) +static int init_saadc(const struct device *dev) { nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_END); nrf_saadc_event_clear(NRF_SAADC, NRF_SAADC_EVENT_CALIBRATEDONE); diff --git a/drivers/adc/adc_sam0.c b/drivers/adc/adc_sam0.c index f6783226a06335..3e0f31c43797a8 100644 --- a/drivers/adc/adc_sam0.c +++ b/drivers/adc/adc_sam0.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(adc_sam0, CONFIG_ADC_LOG_LEVEL); struct adc_sam0_data { struct adc_context ctx; - struct device *dev; + const struct device *dev; uint16_t *buffer; @@ -55,7 +55,7 @@ struct adc_sam0_cfg { uint32_t freq; uint16_t prescaler; - void (*config_func)(struct device *dev); + void (*config_func)(const struct device *dev); }; #define DEV_CFG(dev) \ @@ -74,7 +74,7 @@ static void wait_synchronization(Adc *const adc) #endif } -static int adc_sam0_acquisition_to_clocks(struct device *dev, +static int adc_sam0_acquisition_to_clocks(const struct device *dev, uint16_t acquisition_time) { const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); @@ -119,7 +119,7 @@ static int adc_sam0_acquisition_to_clocks(struct device *dev, return (int)scaled_acq; } -static int adc_sam0_channel_setup(struct device *dev, +static int adc_sam0_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); @@ -281,7 +281,7 @@ static int adc_sam0_channel_setup(struct device *dev, return 0; } -static void adc_sam0_start_conversion(struct device *dev) +static void adc_sam0_start_conversion(const struct device *dev) { const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); Adc *const adc = cfg->regs; @@ -333,7 +333,8 @@ static int check_buffer_size(const struct adc_sequence *sequence, return 0; } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); struct adc_sam0_data *data = DEV_DATA(dev); @@ -415,7 +416,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) return error; } -static int adc_sam0_read(struct device *dev, +static int adc_sam0_read(const struct device *dev, const struct adc_sequence *sequence) { struct adc_sam0_data *data = DEV_DATA(dev); @@ -430,7 +431,7 @@ static int adc_sam0_read(struct device *dev, static void adc_sam0_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct adc_sam0_data *data = DEV_DATA(dev); const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); Adc *const adc = cfg->regs; @@ -454,7 +455,7 @@ static void adc_sam0_isr(void *arg) adc_context_on_sampling_done(&data->ctx, dev); } -static int adc_sam0_init(struct device *dev) +static int adc_sam0_init(const struct device *dev) { const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); struct adc_sam0_data *data = DEV_DATA(dev); @@ -498,7 +499,7 @@ static int adc_sam0_init(struct device *dev) } #ifdef CONFIG_ADC_ASYNC -static int adc_sam0_read_async(struct device *dev, +static int adc_sam0_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { diff --git a/drivers/adc/adc_sam_afec.c b/drivers/adc/adc_sam_afec.c index 6693a6a026f664..95a6edecd624c5 100644 --- a/drivers/adc/adc_sam_afec.c +++ b/drivers/adc/adc_sam_afec.c @@ -33,11 +33,11 @@ LOG_MODULE_REGISTER(adc_sam_afec); #define CONF_ADC_PRESCALER ((SOC_ATMEL_SAM_MCK_FREQ_HZ / 15000000) - 1) -typedef void (*cfg_func_t)(struct device *dev); +typedef void (*cfg_func_t)(const struct device *dev); struct adc_sam_data { struct adc_context ctx; - struct device *dev; + const struct device *dev; /* Pointer to the buffer in the sequence. */ uint16_t *buffer; @@ -68,7 +68,7 @@ struct adc_sam_cfg { #define DEV_DATA(dev) \ ((struct adc_sam_data *)(dev)->data) -static int adc_sam_channel_setup(struct device *dev, +static int adc_sam_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg) { const struct adc_sam_cfg * const cfg = DEV_CFG(dev); @@ -118,7 +118,7 @@ static int adc_sam_channel_setup(struct device *dev, return 0; } -static void adc_sam_start_conversion(struct device *dev) +static void adc_sam_start_conversion(const struct device *dev) { const struct adc_sam_cfg *const cfg = DEV_CFG(dev); struct adc_sam_data *data = DEV_DATA(dev); @@ -183,7 +183,8 @@ static int check_buffer_size(const struct adc_sequence *sequence, return 0; } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { struct adc_sam_data *data = DEV_DATA(dev); int error = 0; @@ -247,7 +248,7 @@ static int start_read(struct device *dev, const struct adc_sequence *sequence) return error; } -static int adc_sam_read(struct device *dev, +static int adc_sam_read(const struct device *dev, const struct adc_sequence *sequence) { struct adc_sam_data *data = DEV_DATA(dev); @@ -260,7 +261,7 @@ static int adc_sam_read(struct device *dev, return error; } -static int adc_sam_init(struct device *dev) +static int adc_sam_init(const struct device *dev) { const struct adc_sam_cfg *const cfg = DEV_CFG(dev); struct adc_sam_data *data = DEV_DATA(dev); @@ -301,7 +302,7 @@ static int adc_sam_init(struct device *dev) } #ifdef CONFIG_ADC_ASYNC -static int adc_sam_read_async(struct device *dev, +static int adc_sam_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -326,7 +327,7 @@ static const struct adc_driver_api adc_sam_api = { static void adc_sam_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct adc_sam_data *data = DEV_DATA(dev); const struct adc_sam_cfg *const cfg = DEV_CFG(dev); Afec *const afec = cfg->regs; diff --git a/drivers/adc/adc_shell.c b/drivers/adc/adc_shell.c index e80ed421db187c..7ec0de69d93c0e 100644 --- a/drivers/adc/adc_shell.c +++ b/drivers/adc/adc_shell.c @@ -118,7 +118,7 @@ static int get_adc_from_list(char *name) static int cmd_adc_channel(const struct shell *shell, size_t argc, char **argv) { int retval = 0; - struct device *adc_dev; + const struct device *adc_dev; int chosen_adc; if (argc != args_no.channel) { @@ -175,7 +175,7 @@ static const struct gain_string_to_enum gain_list[] = { static int cmd_adc_gain(const struct shell *shell, size_t argc, char **argv) { int retval = -EINVAL; - struct device *adc_dev; + const struct device *adc_dev; int chosen_adc; int i; @@ -207,7 +207,7 @@ static int cmd_adc_gain(const struct shell *shell, size_t argc, char **argv) static int cmd_adc_acq(const struct shell *shell, size_t argc, char **argv) { int retval = 0; - struct device *adc_dev; + const struct device *adc_dev; int chosen_adc; uint16_t acq_time; @@ -255,7 +255,7 @@ static int cmd_adc_acq(const struct shell *shell, size_t argc, char **argv) static int cmd_adc_reso(const struct shell *shell, size_t argc, char **argv) { int retval = 0; - struct device *adc_dev; + const struct device *adc_dev; int chosen_adc; if (argc != args_no.resolution || @@ -305,7 +305,7 @@ static const struct reference_string_to_enum reference_list[] = { static int cmd_adc_ref(const struct shell *shell, size_t argc, char **argv) { int retval = -EINVAL; - struct device *adc_dev; + const struct device *adc_dev; int chosen_adc; int i; @@ -339,7 +339,7 @@ static int cmd_adc_read(const struct shell *shell, size_t argc, char **argv) { int retval = 0; int chosen_adc = -1; - struct device *adc_dev; + const struct device *adc_dev; uint16_t m_sample_buffer[BUFFER_SIZE]; if (argc != args_no.read) { diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index 29c38f226e3d85..36a499d13835ee 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -203,7 +203,7 @@ static const uint32_t table_samp_time[] = { struct adc_stm32_data { struct adc_context ctx; - struct device *dev; + const struct device *dev; uint16_t *buffer; uint16_t *repeat_buffer; @@ -220,7 +220,7 @@ struct adc_stm32_cfg { void (*irq_cfg_func)(void); struct stm32_pclken pclken; - struct device *p_dev; + const struct device *p_dev; }; static int check_buffer_size(const struct adc_sequence *sequence, @@ -243,7 +243,7 @@ static int check_buffer_size(const struct adc_sequence *sequence, return 0; } -static void adc_stm32_start_conversion(struct device *dev) +static void adc_stm32_start_conversion(const struct device *dev) { const struct adc_stm32_cfg *config = dev->config; ADC_TypeDef *adc = (ADC_TypeDef *)config->base; @@ -263,7 +263,8 @@ static void adc_stm32_start_conversion(struct device *dev) #endif } -static int start_read(struct device *dev, const struct adc_sequence *sequence) +static int start_read(const struct device *dev, + const struct adc_sequence *sequence) { const struct adc_stm32_cfg *config = dev->config; struct adc_stm32_data *data = dev->data; @@ -387,7 +388,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx, static void adc_stm32_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct adc_stm32_data *data = (struct adc_stm32_data *)dev->data; const struct adc_stm32_cfg *config = (const struct adc_stm32_cfg *)dev->config; @@ -400,7 +401,7 @@ static void adc_stm32_isr(void *arg) LOG_DBG("ISR triggered."); } -static int adc_stm32_read(struct device *dev, +static int adc_stm32_read(const struct device *dev, const struct adc_sequence *sequence) { struct adc_stm32_data *data = dev->data; @@ -414,7 +415,7 @@ static int adc_stm32_read(struct device *dev, } #ifdef CONFIG_ADC_ASYNC -static int adc_stm32_read_async(struct device *dev, +static int adc_stm32_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -446,7 +447,7 @@ static int adc_stm32_check_acq_time(uint16_t acq_time) return -EINVAL; } -static void adc_stm32_setup_speed(struct device *dev, uint8_t id, +static void adc_stm32_setup_speed(const struct device *dev, uint8_t id, uint8_t acq_time_index) { const struct adc_stm32_cfg *config = @@ -463,8 +464,8 @@ static void adc_stm32_setup_speed(struct device *dev, uint8_t id, #endif } -static int adc_stm32_channel_setup(struct device *dev, - const struct adc_channel_cfg *channel_cfg) +static int adc_stm32_channel_setup(const struct device *dev, + const struct adc_channel_cfg *channel_cfg) { #if defined(CONFIG_SOC_SERIES_STM32F0X) || defined(CONFIG_SOC_SERIES_STM32L0X) struct adc_stm32_data *data = dev->data; @@ -520,7 +521,7 @@ static int adc_stm32_channel_setup(struct device *dev, !defined(CONFIG_SOC_SERIES_STM32F7X) && \ !defined(CONFIG_SOC_SERIES_STM32F1X) && \ !defined(CONFIG_SOC_SERIES_STM32L1X) -static void adc_stm32_calib(struct device *dev) +static void adc_stm32_calib(const struct device *dev) { const struct adc_stm32_cfg *config = (const struct adc_stm32_cfg *)dev->config; @@ -542,11 +543,11 @@ static void adc_stm32_calib(struct device *dev) } #endif -static int adc_stm32_init(struct device *dev) +static int adc_stm32_init(const struct device *dev) { struct adc_stm32_data *data = dev->data; const struct adc_stm32_cfg *config = dev->config; - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); ADC_TypeDef *adc = (ADC_TypeDef *)config->base; diff --git a/drivers/audio/intel_dmic.c b/drivers/audio/intel_dmic.c index 23185be9647bef..d43565a05fb9ce 100644 --- a/drivers/audio/intel_dmic.c +++ b/drivers/audio/intel_dmic.c @@ -133,7 +133,7 @@ static struct _dmic_pdata { uint8_t num_streams; uint8_t reserved; struct _stream_data streams[DMIC_MAX_STREAMS]; - struct device *dma_dev; + const struct device *dma_dev; } dmic_private; static inline void dmic_parse_channel_map(uint32_t channel_map_lo, @@ -714,8 +714,9 @@ static int source_ipm_helper(struct pdm_chan_cfg *config, uint32_t *source_mask, return ipm; } -static int configure_registers(struct device *dev, - struct dmic_configuration *hw_cfg, struct dmic_cfg *config) +static int configure_registers(const struct device *dev, + struct dmic_configuration *hw_cfg, + struct dmic_cfg *config) { uint8_t skew; uint8_t swap_mask; @@ -949,7 +950,7 @@ static int configure_registers(struct device *dev, return 0; } -static void dmic_dma_callback(struct device *dev, void *arg, +static void dmic_dma_callback(const struct device *dev, void *arg, uint32_t chan, int err_code) { void *buffer; @@ -1005,7 +1006,7 @@ static void dmic_dma_callback(struct device *dev, void *arg, } } -static int dmic_set_config(struct device *dev, struct dmic_cfg *config) +static int dmic_set_config(const struct device *dev, struct dmic_cfg *config) { struct decim_modes modes_a; struct decim_modes modes_b; @@ -1108,7 +1109,7 @@ static int dmic_set_config(struct device *dev, struct dmic_cfg *config) } /* start the DMIC for capture */ -static void dmic_start(struct device *dev) +static void dmic_start(const struct device *dev) { struct _stream_data *stream; unsigned int key; @@ -1258,7 +1259,8 @@ static void dmic_stop(void) } } -static int dmic_trigger_device(struct device *dev, enum dmic_trigger cmd) +static int dmic_trigger_device(const struct device *dev, + enum dmic_trigger cmd) { unsigned int key; @@ -1293,7 +1295,7 @@ static inline uint8_t dmic_parse_clk_skew_map(uint32_t skew_map, uint8_t pdm) return (uint8_t)((skew_map >> ((pdm & BIT_MASK(3)) * 4U)) & BIT_MASK(4)); } -static int dmic_initialize_device(struct device *dev) +static int dmic_initialize_device(const struct device *dev) { int stream; struct _stream_data *stream_data; @@ -1316,7 +1318,8 @@ static int dmic_initialize_device(struct device *dev) return 0; } -static int dmic_configure_device(struct device *dev, struct dmic_cfg *config) +static int dmic_configure_device(const struct device *dev, + struct dmic_cfg *config) { int ret = 0; @@ -1334,8 +1337,8 @@ static int dmic_configure_device(struct device *dev, struct dmic_cfg *config) return ret; } -static int dmic_read_device(struct device *dev, uint8_t stream, - void **buffer, size_t *size, int32_t timeout) +static int dmic_read_device(const struct device *dev, uint8_t stream, + void **buffer, size_t *size, int32_t timeout) { int ret; diff --git a/drivers/audio/mpxxdtyy-i2s.c b/drivers/audio/mpxxdtyy-i2s.c index 04265698b0bc0f..ea2dd9413163c3 100644 --- a/drivers/audio/mpxxdtyy-i2s.c +++ b/drivers/audio/mpxxdtyy-i2s.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(mpxxdtyy); K_MEM_SLAB_DEFINE(rx_pdm_i2s_mslab, PDM_BLOCK_MAX_SIZE_BYTES, NUM_RX_BLOCKS, 1); -int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer, +int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer, size_t *size, int32_t timeout) { int ret; @@ -51,7 +51,7 @@ int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer, return 0; } -int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd) +int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd) { int ret; struct mpxxdtyy_data *const data = DEV_DATA(dev); @@ -89,7 +89,7 @@ int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd) return 0; } -int mpxxdtyy_i2s_configure(struct device *dev, struct dmic_cfg *cfg) +int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg) { int ret; struct mpxxdtyy_data *const data = DEV_DATA(dev); diff --git a/drivers/audio/mpxxdtyy.c b/drivers/audio/mpxxdtyy.c index 88d422926ccbd3..3a6b916ce0c853 100644 --- a/drivers/audio/mpxxdtyy.c +++ b/drivers/audio/mpxxdtyy.c @@ -45,7 +45,7 @@ static uint8_t right_channel(uint8_t a, uint8_t b) return ch_demux[a & CHANNEL_MASK] | (ch_demux[b & CHANNEL_MASK] << 4); } -uint16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg) +uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg) { struct mpxxdtyy_data *const data = DEV_DATA(dev); TPDMFilter_InitStruct *pdm_filter = &data->pdm_filter[0]; @@ -148,7 +148,7 @@ static const struct _dmic_ops mpxxdtyy_driver_api = { #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) */ }; -static int mpxxdtyy_initialize(struct device *dev) +static int mpxxdtyy_initialize(const struct device *dev) { struct mpxxdtyy_data *const data = DEV_DATA(dev); diff --git a/drivers/audio/mpxxdtyy.h b/drivers/audio/mpxxdtyy.h index a096e216409f6d..4bad70cdd457d4 100644 --- a/drivers/audio/mpxxdtyy.h +++ b/drivers/audio/mpxxdtyy.h @@ -25,23 +25,23 @@ extern "C" { ((struct mpxxdtyy_data *const)(dev)->data) struct mpxxdtyy_data { - struct device *comm_master; + const struct device *comm_master; enum dmic_state state; TPDMFilter_InitStruct pdm_filter[2]; size_t pcm_mem_size; struct k_mem_slab *pcm_mem_slab; }; -uint16_t sw_filter_lib_init(struct device *dev, struct dmic_cfg *cfg); +uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg); int sw_filter_lib_run(TPDMFilter_InitStruct *pdm_filter, void *pdm_block, void *pcm_block, size_t pdm_size, size_t pcm_size); #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) -int mpxxdtyy_i2s_read(struct device *dev, uint8_t stream, void **buffer, +int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer, size_t *size, int32_t timeout); -int mpxxdtyy_i2s_trigger(struct device *dev, enum dmic_trigger cmd); -int mpxxdtyy_i2s_configure(struct device *dev, struct dmic_cfg *cfg); +int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd); +int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg); #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) */ #ifdef __cplusplus diff --git a/drivers/audio/tlv320dac310x.c b/drivers/audio/tlv320dac310x.c index b2b5512e504b71..3c7ecc0d618224 100644 --- a/drivers/audio/tlv320dac310x.c +++ b/drivers/audio/tlv320dac310x.c @@ -25,10 +25,10 @@ LOG_MODULE_REGISTER(tlv320dac310x); #define CODEC_OUTPUT_VOLUME_MIN (-78 * 2) struct codec_driver_config { - struct device *i2c_device; + const struct device *i2c_device; const char *i2c_dev_name; uint8_t i2c_address; - struct device *gpio_device; + const struct device *gpio_device; const char *gpio_dev_name; uint32_t gpio_pin; int gpio_flags; @@ -55,25 +55,28 @@ static struct codec_driver_data codec_device_data; #define DEV_DATA(dev) \ ((struct codec_driver_data *const)(dev)->data) -static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val); -static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val); -static void codec_soft_reset(struct device *dev); -static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg); -static int codec_configure_clocks(struct device *dev, - struct audio_codec_cfg *cfg); -static int codec_configure_filters(struct device *dev, audio_dai_cfg_t *cfg); +static void codec_write_reg(const struct device *dev, struct reg_addr reg, + uint8_t val); +static void codec_read_reg(const struct device *dev, struct reg_addr reg, + uint8_t *val); +static void codec_soft_reset(const struct device *dev); +static int codec_configure_dai(const struct device *dev, audio_dai_cfg_t *cfg); +static int codec_configure_clocks(const struct device *dev, + struct audio_codec_cfg *cfg); +static int codec_configure_filters(const struct device *dev, + audio_dai_cfg_t *cfg); static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg); -static void codec_configure_output(struct device *dev); -static int codec_set_output_volume(struct device *dev, int vol); +static void codec_configure_output(const struct device *dev); +static int codec_set_output_volume(const struct device *dev, int vol); #if (LOG_LEVEL >= LOG_LEVEL_DEBUG) -static void codec_read_all_regs(struct device *dev); +static void codec_read_all_regs(const struct device *dev); #define CODEC_DUMP_REGS(dev) codec_read_all_regs((dev)) #else #define CODEC_DUMP_REGS(dev) #endif -static int codec_initialize(struct device *dev) +static int codec_initialize(const struct device *dev) { struct codec_driver_config *const dev_cfg = DEV_CFG(dev); @@ -96,8 +99,8 @@ static int codec_initialize(struct device *dev) return 0; } -static int codec_configure(struct device *dev, - struct audio_codec_cfg *cfg) +static int codec_configure(const struct device *dev, + struct audio_codec_cfg *cfg) { struct codec_driver_config *const dev_cfg = DEV_CFG(dev); int ret; @@ -127,7 +130,7 @@ static int codec_configure(struct device *dev, return ret; } -static void codec_start_output(struct device *dev) +static void codec_start_output(const struct device *dev) { /* powerup DAC channels */ codec_write_reg(dev, DATA_PATH_SETUP_ADDR, DAC_LR_POWERUP_DEFAULT); @@ -138,7 +141,7 @@ static void codec_start_output(struct device *dev) CODEC_DUMP_REGS(dev); } -static void codec_stop_output(struct device *dev) +static void codec_stop_output(const struct device *dev) { /* mute DAC channels */ codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_MUTE_DEFAULT); @@ -147,21 +150,22 @@ static void codec_stop_output(struct device *dev) codec_write_reg(dev, DATA_PATH_SETUP_ADDR, DAC_LR_POWERDN_DEFAULT); } -static void codec_mute_output(struct device *dev) +static void codec_mute_output(const struct device *dev) { /* mute DAC channels */ codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_MUTE_DEFAULT); } -static void codec_unmute_output(struct device *dev) +static void codec_unmute_output(const struct device *dev) { /* unmute DAC channels */ codec_write_reg(dev, VOL_CTRL_ADDR, VOL_CTRL_UNMUTE_DEFAULT); } -static int codec_set_property(struct device *dev, - audio_property_t property, audio_channel_t channel, - audio_property_value_t val) +static int codec_set_property(const struct device *dev, + audio_property_t property, + audio_channel_t channel, + audio_property_value_t val) { /* individual channel control not currently supported */ if (channel != AUDIO_CHANNEL_ALL) { @@ -189,13 +193,14 @@ static int codec_set_property(struct device *dev, return -EINVAL; } -static int codec_apply_properties(struct device *dev) +static int codec_apply_properties(const struct device *dev) { /* nothing to do because there is nothing cached */ return 0; } -static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val) +static void codec_write_reg(const struct device *dev, struct reg_addr reg, + uint8_t val) { struct codec_driver_data *const dev_data = DEV_DATA(dev); struct codec_driver_config *const dev_cfg = DEV_CFG(dev); @@ -213,7 +218,8 @@ static void codec_write_reg(struct device *dev, struct reg_addr reg, uint8_t val reg.page, reg.reg_addr, val); } -static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val) +static void codec_read_reg(const struct device *dev, struct reg_addr reg, + uint8_t *val) { struct codec_driver_data *const dev_data = DEV_DATA(dev); struct codec_driver_config *const dev_cfg = DEV_CFG(dev); @@ -231,13 +237,13 @@ static void codec_read_reg(struct device *dev, struct reg_addr reg, uint8_t *val reg.page, reg.reg_addr, *val); } -static void codec_soft_reset(struct device *dev) +static void codec_soft_reset(const struct device *dev) { /* soft reset the DAC */ codec_write_reg(dev, SOFT_RESET_ADDR, SOFT_RESET_ASSERT); } -static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg) +static int codec_configure_dai(const struct device *dev, audio_dai_cfg_t *cfg) { uint8_t val; @@ -274,8 +280,8 @@ static int codec_configure_dai(struct device *dev, audio_dai_cfg_t *cfg) return 0; } -static int codec_configure_clocks(struct device *dev, - struct audio_codec_cfg *cfg) +static int codec_configure_clocks(const struct device *dev, + struct audio_codec_cfg *cfg) { int dac_clk, mod_clk; struct i2s_config *i2s; @@ -373,7 +379,8 @@ static int codec_configure_clocks(struct device *dev, return 0; } -static int codec_configure_filters(struct device *dev, audio_dai_cfg_t *cfg) +static int codec_configure_filters(const struct device *dev, + audio_dai_cfg_t *cfg) { enum proc_block proc_blk; @@ -413,7 +420,7 @@ static enum osr_multiple codec_get_osr_multiple(audio_dai_cfg_t *cfg) return osr; } -static void codec_configure_output(struct device *dev) +static void codec_configure_output(const struct device *dev) { uint8_t val; @@ -453,7 +460,7 @@ static void codec_configure_output(struct device *dev) codec_write_reg(dev, HEADPHONE_DRV_ADDR, val); } -static int codec_set_output_volume(struct device *dev, int vol) +static int codec_set_output_volume(const struct device *dev, int vol) { uint8_t vol_val; int vol_index; @@ -492,7 +499,7 @@ static int codec_set_output_volume(struct device *dev, int vol) } #if (LOG_LEVEL >= LOG_LEVEL_DEBUG) -static void codec_read_all_regs(struct device *dev) +static void codec_read_all_regs(const struct device *dev) { uint8_t val; diff --git a/drivers/bluetooth/hci/h4.c b/drivers/bluetooth/hci/h4.c index 3831f053d4f494..04777157e4480d 100644 --- a/drivers/bluetooth/hci/h4.c +++ b/drivers/bluetooth/hci/h4.c @@ -67,7 +67,7 @@ static struct { .fifo = Z_FIFO_INITIALIZER(tx.fifo), }; -static struct device *h4_dev; +static const struct device *h4_dev; static inline void h4_get_type(void) { @@ -219,7 +219,7 @@ static void rx_thread(void *p1, void *p2, void *p3) } } -static size_t h4_discard(struct device *uart, size_t len) +static size_t h4_discard(const struct device *uart, size_t len) { uint8_t buf[33]; @@ -391,7 +391,7 @@ static inline void process_rx(void) } } -static void bt_uart_isr(struct device *unused, void *user_data) +static void bt_uart_isr(const struct device *unused, void *user_data) { ARG_UNUSED(unused); ARG_UNUSED(user_data); @@ -423,7 +423,7 @@ static int h4_send(struct net_buf *buf) * * @return 0 on success, negative error value on failure */ -int __weak bt_hci_transport_setup(struct device *dev) +int __weak bt_hci_transport_setup(const struct device *dev) { h4_discard(h4_dev, 32); return 0; @@ -461,7 +461,7 @@ static const struct bt_hci_driver drv = { .send = h4_send, }; -static int bt_uart_init(struct device *unused) +static int bt_uart_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/hci/h5.c b/drivers/bluetooth/hci/h5.c index 0fa0bd7efc75d5..863f5462afa18f 100644 --- a/drivers/bluetooth/hci/h5.c +++ b/drivers/bluetooth/hci/h5.c @@ -125,7 +125,7 @@ static const uint8_t conf_rsp[] = { 0x04, 0x7b }; #define SIG_BUF_SIZE (BT_BUF_RESERVE + MAX_SIG_LEN) NET_BUF_POOL_DEFINE(h5_pool, SIGNAL_COUNT, SIG_BUF_SIZE, 0, NULL); -static struct device *h5_dev; +static const struct device *h5_dev; static void h5_reset_rx(void) { @@ -405,7 +405,7 @@ static inline struct net_buf *get_evt_buf(uint8_t evt) return bt_buf_get_evt(evt, false, K_NO_WAIT); } -static void bt_uart_isr(struct device *unused, void *user_data) +static void bt_uart_isr(const struct device *unused, void *user_data) { static int remaining; uint8_t byte; @@ -747,7 +747,7 @@ static const struct bt_hci_driver drv = { .send = h5_queue, }; -static int bt_uart_init(struct device *unused) +static int bt_uart_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/hci/ipm_stm32wb.c b/drivers/bluetooth/hci/ipm_stm32wb.c index c59bcdc22df224..bae45b4d7438b7 100644 --- a/drivers/bluetooth/hci/ipm_stm32wb.c +++ b/drivers/bluetooth/hci/ipm_stm32wb.c @@ -526,7 +526,7 @@ static const struct bt_hci_driver drv = { .send = bt_ipm_send, }; -static int _bt_ipm_init(struct device *unused) +static int _bt_ipm_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/hci/rpmsg.c b/drivers/bluetooth/hci/rpmsg.c index d1f70c83534514..1622a25f58b267 100644 --- a/drivers/bluetooth/hci/rpmsg.c +++ b/drivers/bluetooth/hci/rpmsg.c @@ -200,7 +200,7 @@ static const struct bt_hci_driver drv = { .bus = BT_HCI_DRIVER_BUS_IPM, }; -static int bt_rpmsg_init(struct device *unused) +static int bt_rpmsg_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/hci/rpmsg_nrf53.c b/drivers/bluetooth/hci/rpmsg_nrf53.c index d79fdda307a740..1013076b36da40 100644 --- a/drivers/bluetooth/hci/rpmsg_nrf53.c +++ b/drivers/bluetooth/hci/rpmsg_nrf53.c @@ -24,8 +24,8 @@ static K_KERNEL_STACK_DEFINE(bt_rpmsg_rx_thread_stack, CONFIG_BT_RPMSG_NRF53_RX_STACK_SIZE); static struct k_thread bt_rpmsg_rx_thread_data; -static struct device *ipm_tx_handle; -static struct device *ipm_rx_handle; +static const struct device *ipm_tx_handle; +static const struct device *ipm_rx_handle; /* Configuration defines */ @@ -115,7 +115,7 @@ const struct virtio_dispatch dispatch = { .notify = virtio_notify, }; -static void ipm_callback(struct device *dev, void *context, +static void ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { BT_DBG("Got callback of id %u", id); diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index 59161c7a6093da..1bd709a19a6d7e 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -68,8 +68,8 @@ static uint8_t rxmsg[SPI_MAX_MSG_LEN]; static uint8_t txmsg[SPI_MAX_MSG_LEN]; -static struct device *irq_dev; -static struct device *rst_dev; +static const struct device *irq_dev; +static const struct device *rst_dev; static struct gpio_callback gpio_cb; @@ -105,7 +105,7 @@ void spi_dump_message(const uint8_t *pre, uint8_t *buf, uint8_t size) {} #endif #if defined(CONFIG_BT_SPI_BLUENRG) -static struct device *cs_dev; +static const struct device *cs_dev; /* Define a limit when reading IRQ high */ /* It can be required to be increased for */ /* some particular cases. */ @@ -126,7 +126,7 @@ struct bluenrg_aci_cmd_ll_param { static int bt_spi_send_aci_config_data_controller_mode(void); #endif /* CONFIG_BT_BLUENRG_ACI */ -static struct device *spi_dev; +static const struct device *spi_dev; static struct spi_config spi_conf = { .frequency = DT_INST_PROP(0, spi_max_frequency), @@ -166,7 +166,8 @@ static inline uint16_t bt_spi_get_evt(uint8_t *rxmsg) return (rxmsg[EVT_VENDOR_CODE_MSB] << 8) | rxmsg[EVT_VENDOR_CODE_LSB]; } -static void bt_spi_isr(struct device *unused1, struct gpio_callback *unused2, +static void bt_spi_isr(const struct device *unused1, + struct gpio_callback *unused2, uint32_t unused3) { BT_DBG(""); @@ -528,7 +529,7 @@ static const struct bt_hci_driver drv = { .send = bt_spi_send, }; -static int bt_spi_init(struct device *unused) +static int bt_spi_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/hci/userchan.c b/drivers/bluetooth/hci/userchan.c index a137e5245d2e05..8901f7c54a2ae6 100644 --- a/drivers/bluetooth/hci/userchan.c +++ b/drivers/bluetooth/hci/userchan.c @@ -204,7 +204,7 @@ static const struct bt_hci_driver drv = { .send = uc_send, }; -static int bt_uc_init(struct device *unused) +static int bt_uc_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/drivers/bluetooth/util.h b/drivers/bluetooth/util.h index 74bd38dd94aa5d..9b2dd60662c826 100644 --- a/drivers/bluetooth/util.h +++ b/drivers/bluetooth/util.h @@ -6,7 +6,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -static inline void bt_uart_drain(struct device *dev) +static inline void bt_uart_drain(const struct device *dev) { uint8_t c; diff --git a/drivers/can/can_common.c b/drivers/can/can_common.c index 556a278e33410f..c1bbc59b84092a 100644 --- a/drivers/can/can_common.c +++ b/drivers/can/can_common.c @@ -39,7 +39,7 @@ static void can_msgq_put(struct zcan_frame *frame, void *arg) } } -int z_impl_can_attach_msgq(struct device *dev, struct k_msgq *msg_q, +int z_impl_can_attach_msgq(const struct device *dev, struct k_msgq *msg_q, const struct zcan_filter *filter) { const struct can_driver_api *api = dev->api; @@ -128,7 +128,7 @@ static void can_work_isr_put(struct zcan_frame *frame, void *arg) k_work_submit_to_queue(work->work_queue, &work->work_item); } -int can_attach_workq(struct device *dev, struct k_work_q *work_q, +int can_attach_workq(const struct device *dev, struct k_work_q *work_q, struct zcan_work *work, can_rx_callback_t callback, void *callback_arg, const struct zcan_filter *filter) diff --git a/drivers/can/can_handlers.c b/drivers/can/can_handlers.c index 2fbe95075a40d1..bc91fd3dfe1402 100644 --- a/drivers/can/can_handlers.c +++ b/drivers/can/can_handlers.c @@ -7,18 +7,20 @@ #include #include -static inline int z_vrfy_can_configure(struct device *dev, enum can_mode mode, +static inline int z_vrfy_can_configure(const struct device *dev, + enum can_mode mode, uint32_t bitrate) { Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, configure)); - return z_impl_can_configure((struct device *)dev, (enum can_mode)mode, - (uint32_t)bitrate); + return z_impl_can_configure((const struct device *)dev, + (enum can_mode)mode, + (uint32_t)bitrate); } #include -static inline int z_vrfy_can_send(struct device *dev, +static inline int z_vrfy_can_send(const struct device *dev, const struct zcan_frame *msg, k_timeout_t timeout, can_tx_callback_t callback_isr, @@ -35,15 +37,15 @@ static inline int z_vrfy_can_send(struct device *dev, Z_OOPS(Z_SYSCALL_MEMORY_READ((void *)callback_arg, sizeof(void *))); - return z_impl_can_send((struct device *)dev, - (const struct zcan_frame *)msg, - (k_timeout_t)timeout, - (can_tx_callback_t) callback_isr, - (void *)callback_arg); + return z_impl_can_send((const struct device *)dev, + (const struct zcan_frame *)msg, + (k_timeout_t)timeout, + (can_tx_callback_t) callback_isr, + (void *)callback_arg); } #include -static inline int z_vrfy_can_attach_msgq(struct device *dev, +static inline int z_vrfy_can_attach_msgq(const struct device *dev, struct k_msgq *msgq, const struct zcan_filter *filter) { @@ -53,23 +55,23 @@ static inline int z_vrfy_can_attach_msgq(struct device *dev, sizeof(struct zcan_filter))); Z_OOPS(Z_SYSCALL_OBJ(msgq, K_OBJ_MSGQ)); - return z_impl_can_attach_msgq((struct device *)dev, - (struct k_msgq *)msgq, - (const struct zcan_filter *) filter); + return z_impl_can_attach_msgq((const struct device *)dev, + (struct k_msgq *)msgq, + (const struct zcan_filter *) filter); } #include -static inline void z_vrfy_can_detach(struct device *dev, int filter_id) +static inline void z_vrfy_can_detach(const struct device *dev, int filter_id) { Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, detach)); - z_impl_can_detach((struct device *)dev, (int)filter_id); + z_impl_can_detach((const struct device *)dev, (int)filter_id); } #include static inline -enum can_state z_vrfy_can_get_state(struct device *dev, +enum can_state z_vrfy_can_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { @@ -85,7 +87,8 @@ enum can_state z_vrfy_can_get_state(struct device *dev, #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -static inline int z_vrfy_can_recover(struct device *dev, k_timeout_t timeout) +static inline int z_vrfy_can_recover(const struct device *dev, + k_timeout_t timeout) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_CAN)); diff --git a/drivers/can/can_loopback.c b/drivers/can/can_loopback.c index cfde6ada487a57..ac36af86e07b02 100644 --- a/drivers/can/can_loopback.c +++ b/drivers/can/can_loopback.c @@ -88,7 +88,8 @@ void tx_thread(void *data_arg, void *arg2, void *arg3) } } -int can_loopback_send(struct device *dev, const struct zcan_frame *frame, +int can_loopback_send(const struct device *dev, + const struct zcan_frame *frame, k_timeout_t timeout, can_tx_callback_t callback, void *callback_arg) { @@ -144,7 +145,7 @@ static inline int get_free_filter(struct can_loopback_filter *filters) return CAN_NO_FREE_FILTER; } -int can_loopback_attach_isr(struct device *dev, can_rx_callback_t isr, +int can_loopback_attach_isr(const struct device *dev, can_rx_callback_t isr, void *cb_arg, const struct zcan_filter *filter) { @@ -182,7 +183,7 @@ int can_loopback_attach_isr(struct device *dev, can_rx_callback_t isr, return filter_id; } -void can_loopback_detach(struct device *dev, int filter_id) +void can_loopback_detach(const struct device *dev, int filter_id) { struct can_loopback_data *data = DEV_DATA(dev); @@ -192,7 +193,7 @@ void can_loopback_detach(struct device *dev, int filter_id) k_mutex_unlock(&data->mtx); } -int can_loopback_configure(struct device *dev, enum can_mode mode, +int can_loopback_configure(const struct device *dev, enum can_mode mode, uint32_t bitrate) { struct can_loopback_data *data = DEV_DATA(dev); @@ -203,7 +204,7 @@ int can_loopback_configure(struct device *dev, enum can_mode mode, return 0; } -static enum can_state can_loopback_get_state(struct device *dev, +static enum can_state can_loopback_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { ARG_UNUSED(dev); @@ -217,7 +218,7 @@ static enum can_state can_loopback_get_state(struct device *dev, } #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -int can_loopback_recover(struct device *dev, k_timeout_t timeout) +int can_loopback_recover(const struct device *dev, k_timeout_t timeout) { ARG_UNUSED(dev); ARG_UNUSED(timeout); @@ -226,7 +227,7 @@ int can_loopback_recover(struct device *dev, k_timeout_t timeout) } #endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */ -static void can_loopback_register_state_change_isr(struct device *dev, +static void can_loopback_register_state_change_isr(const struct device *dev, can_state_change_isr_t isr) { ARG_UNUSED(dev); @@ -246,7 +247,7 @@ static const struct can_driver_api can_api_funcs = { }; -static int can_loopback_init(struct device *dev) +static int can_loopback_init(const struct device *dev) { struct can_loopback_data *data = DEV_DATA(dev); k_tid_t tx_tid; @@ -285,9 +286,9 @@ DEVICE_AND_API_INIT(can_loopback_1, CONFIG_CAN_LOOPBACK_DEV_NAME, #include "socket_can_generic.h" -static int socket_can_init_1(struct device *dev) +static int socket_can_init_1(const struct device *dev) { - struct device *can_dev = DEVICE_GET(can_loopback_1); + const struct device *can_dev = DEVICE_GET(can_loopback_1); struct socket_can_context *socket_context = dev->data; LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)", diff --git a/drivers/can/can_mcp2515.c b/drivers/can/can_mcp2515.c index ad455154554d7e..b9f96a04c9dbf9 100644 --- a/drivers/can/can_mcp2515.c +++ b/drivers/can/can_mcp2515.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(mcp2515_can); #include "can_mcp2515.h" -static int mcp2515_cmd_soft_reset(struct device *dev) +static int mcp2515_cmd_soft_reset(const struct device *dev) { uint8_t cmd_buf[] = { MCP2515_OPCODE_RESET }; @@ -31,7 +31,8 @@ static int mcp2515_cmd_soft_reset(struct device *dev) return spi_write(DEV_DATA(dev)->spi, &DEV_DATA(dev)->spi_cfg, &tx); } -static int mcp2515_cmd_bit_modify(struct device *dev, uint8_t reg_addr, uint8_t mask, +static int mcp2515_cmd_bit_modify(const struct device *dev, uint8_t reg_addr, + uint8_t mask, uint8_t data) { uint8_t cmd_buf[] = { MCP2515_OPCODE_BIT_MODIFY, reg_addr, mask, data }; @@ -46,7 +47,7 @@ static int mcp2515_cmd_bit_modify(struct device *dev, uint8_t reg_addr, uint8_t return spi_write(DEV_DATA(dev)->spi, &DEV_DATA(dev)->spi_cfg, &tx); } -static int mcp2515_cmd_write_reg(struct device *dev, uint8_t reg_addr, +static int mcp2515_cmd_write_reg(const struct device *dev, uint8_t reg_addr, uint8_t *buf_data, uint8_t buf_len) { uint8_t cmd_buf[] = { MCP2515_OPCODE_WRITE, reg_addr }; @@ -76,8 +77,8 @@ static int mcp2515_cmd_write_reg(struct device *dev, uint8_t reg_addr, * 4: TX Buffer 2, Start at TXB2SIDH (0x51) * 5: TX Buffer 2, Start at TXB2D0 (0x56) */ -static int mcp2515_cmd_load_tx_buffer(struct device *dev, uint8_t abc, - uint8_t *buf_data, uint8_t buf_len) +static int mcp2515_cmd_load_tx_buffer(const struct device *dev, uint8_t abc, + uint8_t *buf_data, uint8_t buf_len) { __ASSERT(abc <= 5, "abc <= 5"); @@ -101,7 +102,7 @@ static int mcp2515_cmd_load_tx_buffer(struct device *dev, uint8_t abc, * opcode that respectively initiate transmission for buffers TXB0, TXB1 and * TXB2. */ -static int mcp2515_cmd_rts(struct device *dev, uint8_t nnn) +static int mcp2515_cmd_rts(const struct device *dev, uint8_t nnn) { __ASSERT(nnn < BIT(MCP2515_TX_CNT), "nnn < BIT(MCP2515_TX_CNT)"); @@ -117,7 +118,7 @@ static int mcp2515_cmd_rts(struct device *dev, uint8_t nnn) return spi_write(DEV_DATA(dev)->spi, &DEV_DATA(dev)->spi_cfg, &tx); } -static int mcp2515_cmd_read_reg(struct device *dev, uint8_t reg_addr, +static int mcp2515_cmd_read_reg(const struct device *dev, uint8_t reg_addr, uint8_t *buf_data, uint8_t buf_len) { uint8_t cmd_buf[] = { MCP2515_OPCODE_READ, reg_addr }; @@ -152,8 +153,8 @@ static int mcp2515_cmd_read_reg(struct device *dev, uint8_t reg_addr, * 2: Receive Buffer 1, Start at RXB1SIDH (0x71) * 3: Receive Buffer 1, Start at RXB1D0 (0x76) */ -static int mcp2515_cmd_read_rx_buffer(struct device *dev, uint8_t nm, - uint8_t *buf_data, uint8_t buf_len) +static int mcp2515_cmd_read_rx_buffer(const struct device *dev, uint8_t nm, + uint8_t *buf_data, uint8_t buf_len) { __ASSERT(nm <= 0x03, "nm <= 0x03"); @@ -253,7 +254,7 @@ static void mcp2515_convert_mcp2515frame_to_zcanframe(const uint8_t *source, } } -const int mcp2515_set_mode(struct device *dev, uint8_t mcp2515_mode) +const int mcp2515_set_mode(const struct device *dev, uint8_t mcp2515_mode) { uint8_t canstat; @@ -271,7 +272,7 @@ const int mcp2515_set_mode(struct device *dev, uint8_t mcp2515_mode) return 0; } -static int mcp2515_get_mode(struct device *dev, uint8_t *mode) +static int mcp2515_get_mode(const struct device *dev, uint8_t *mode) { uint8_t canstat; @@ -289,7 +290,7 @@ static int mcp2515_get_mode(struct device *dev, uint8_t *mode) return 0; } -static int mcp2515_configure(struct device *dev, enum can_mode mode, +static int mcp2515_configure(const struct device *dev, enum can_mode mode, uint32_t bitrate) { const struct mcp2515_config *dev_cfg = DEV_CFG(dev); @@ -422,9 +423,10 @@ static int mcp2515_configure(struct device *dev, enum can_mode mode, return ret; } -static int mcp2515_send(struct device *dev, const struct zcan_frame *msg, - k_timeout_t timeout, can_tx_callback_t callback, - void *callback_arg) +static int mcp2515_send(const struct device *dev, + const struct zcan_frame *msg, + k_timeout_t timeout, can_tx_callback_t callback, + void *callback_arg) { struct mcp2515_data *dev_data = DEV_DATA(dev); uint8_t tx_idx = 0U; @@ -484,7 +486,8 @@ static int mcp2515_send(struct device *dev, const struct zcan_frame *msg, return 0; } -static int mcp2515_attach_isr(struct device *dev, can_rx_callback_t rx_cb, +static int mcp2515_attach_isr(const struct device *dev, + can_rx_callback_t rx_cb, void *cb_arg, const struct zcan_filter *filter) { @@ -518,7 +521,7 @@ static int mcp2515_attach_isr(struct device *dev, can_rx_callback_t rx_cb, return filter_idx; } -static void mcp2515_detach(struct device *dev, int filter_nr) +static void mcp2515_detach(const struct device *dev, int filter_nr) { struct mcp2515_data *dev_data = DEV_DATA(dev); @@ -527,7 +530,7 @@ static void mcp2515_detach(struct device *dev, int filter_nr) k_mutex_unlock(&dev_data->mutex); } -static void mcp2515_register_state_change_isr(struct device *dev, +static void mcp2515_register_state_change_isr(const struct device *dev, can_state_change_isr_t isr) { struct mcp2515_data *dev_data = DEV_DATA(dev); @@ -559,7 +562,8 @@ static uint8_t mcp2515_filter_match(struct zcan_frame *msg, return 1; } -static void mcp2515_rx_filter(struct device *dev, struct zcan_frame *msg) +static void mcp2515_rx_filter(const struct device *dev, + struct zcan_frame *msg) { struct mcp2515_data *dev_data = DEV_DATA(dev); uint8_t filter_idx = 0U; @@ -588,7 +592,7 @@ static void mcp2515_rx_filter(struct device *dev, struct zcan_frame *msg) k_mutex_unlock(&dev_data->mutex); } -static void mcp2515_rx(struct device *dev, uint8_t rx_idx) +static void mcp2515_rx(const struct device *dev, uint8_t rx_idx) { __ASSERT(rx_idx < MCP2515_RX_CNT, "rx_idx < MCP2515_RX_CNT"); @@ -605,7 +609,7 @@ static void mcp2515_rx(struct device *dev, uint8_t rx_idx) mcp2515_rx_filter(dev, &msg); } -static void mcp2515_tx_done(struct device *dev, uint8_t tx_idx) +static void mcp2515_tx_done(const struct device *dev, uint8_t tx_idx) { struct mcp2515_data *dev_data = DEV_DATA(dev); @@ -621,7 +625,7 @@ static void mcp2515_tx_done(struct device *dev, uint8_t tx_idx) k_sem_give(&dev_data->tx_sem); } -static enum can_state mcp2515_get_state(struct device *dev, +static enum can_state mcp2515_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { uint8_t eflg; @@ -657,7 +661,7 @@ static enum can_state mcp2515_get_state(struct device *dev, return CAN_ERROR_ACTIVE; } -static void mcp2515_handle_errors(struct device *dev) +static void mcp2515_handle_errors(const struct device *dev) { struct mcp2515_data *dev_data = DEV_DATA(dev); can_state_change_isr_t state_change_isr = dev_data->state_change_isr; @@ -673,14 +677,14 @@ static void mcp2515_handle_errors(struct device *dev) } #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -static void mcp2515_recover(struct device *dev, k_timeout_t timeout) +static void mcp2515_recover(const struct device *dev, k_timeout_t timeout) { ARG_UNUSED(dev); ARG_UNUSED(timeout); } #endif -static void mcp2515_handle_interrupts(struct device *dev) +static void mcp2515_handle_interrupts(const struct device *dev) { const struct mcp2515_config *dev_cfg = DEV_CFG(dev); struct mcp2515_data *dev_data = DEV_DATA(dev); @@ -748,7 +752,7 @@ static void mcp2515_handle_interrupts(struct device *dev) } } -static void mcp2515_int_thread(struct device *dev) +static void mcp2515_int_thread(const struct device *dev) { struct mcp2515_data *dev_data = DEV_DATA(dev); @@ -758,7 +762,7 @@ static void mcp2515_int_thread(struct device *dev) } } -static void mcp2515_int_gpio_callback(struct device *dev, +static void mcp2515_int_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mcp2515_data *dev_data = @@ -780,7 +784,7 @@ static const struct can_driver_api can_api_funcs = { }; -static int mcp2515_init(struct device *dev) +static int mcp2515_init(const struct device *dev) { const struct mcp2515_config *dev_cfg = DEV_CFG(dev); struct mcp2515_data *dev_data = DEV_DATA(dev); diff --git a/drivers/can/can_mcp2515.h b/drivers/can/can_mcp2515.h index e6eb5a3420bbca..4313d3b04f798f 100644 --- a/drivers/can/can_mcp2515.h +++ b/drivers/can/can_mcp2515.h @@ -26,14 +26,14 @@ struct mcp2515_tx_cb { struct mcp2515_data { /* spi device data */ - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control spi_cs_ctrl; #endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */ /* interrupt data */ - struct device *int_gpio; + const struct device *int_gpio; struct gpio_callback int_gpio_cb; struct k_thread int_thread; k_thread_stack_t *int_thread_stack; diff --git a/drivers/can/can_mcux_flexcan.c b/drivers/can/can_mcux_flexcan.c index d924ab0113b3d0..c286d36f555d5e 100644 --- a/drivers/can/can_mcux_flexcan.c +++ b/drivers/can/can_mcux_flexcan.c @@ -60,7 +60,7 @@ struct mcux_flexcan_config { uint32_t prop_seg; uint32_t phase_seg1; uint32_t phase_seg2; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_flexcan_rx_callback { @@ -92,12 +92,13 @@ struct mcux_flexcan_data { can_state_change_isr_t state_change_isr; }; -static int mcux_flexcan_configure(struct device *dev, enum can_mode mode, +static int mcux_flexcan_configure(const struct device *dev, + enum can_mode mode, uint32_t bitrate) { const struct mcux_flexcan_config *config = dev->config; flexcan_config_t flexcan_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; clock_dev = device_get_binding(config->clock_name); @@ -245,7 +246,8 @@ static int mcux_get_tx_alloc(struct mcux_flexcan_data *data) return alloc >= MCUX_FLEXCAN_MAX_TX ? -1 : alloc; } -static int mcux_flexcan_send(struct device *dev, const struct zcan_frame *msg, +static int mcux_flexcan_send(const struct device *dev, + const struct zcan_frame *msg, k_timeout_t timeout, can_tx_callback_t callback_isr, void *callback_arg) { @@ -295,7 +297,8 @@ static int mcux_flexcan_send(struct device *dev, const struct zcan_frame *msg, return CAN_TX_OK; } -static int mcux_flexcan_attach_isr(struct device *dev, can_rx_callback_t isr, +static int mcux_flexcan_attach_isr(const struct device *dev, + can_rx_callback_t isr, void *callback_arg, const struct zcan_filter *filter) { @@ -350,7 +353,7 @@ static int mcux_flexcan_attach_isr(struct device *dev, can_rx_callback_t isr, return alloc; } -static void mcux_flexcan_register_state_change_isr(struct device *dev, +static void mcux_flexcan_register_state_change_isr(const struct device *dev, can_state_change_isr_t isr) { struct mcux_flexcan_data *data = dev->data; @@ -358,7 +361,7 @@ static void mcux_flexcan_register_state_change_isr(struct device *dev, data->state_change_isr = isr; } -static enum can_state mcux_flexcan_get_state(struct device *dev, +static enum can_state mcux_flexcan_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { const struct mcux_flexcan_config *config = dev->config; @@ -384,7 +387,7 @@ static enum can_state mcux_flexcan_get_state(struct device *dev, } #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -int mcux_flexcan_recover(struct device *dev, k_timeout_t timeout) +int mcux_flexcan_recover(const struct device *dev, k_timeout_t timeout) { const struct mcux_flexcan_config *config = dev->config; int ret = 0; @@ -412,7 +415,7 @@ int mcux_flexcan_recover(struct device *dev, k_timeout_t timeout) } #endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */ -static void mcux_flexcan_detach(struct device *dev, int filter_id) +static void mcux_flexcan_detach(const struct device *dev, int filter_id) { const struct mcux_flexcan_config *config = dev->config; struct mcux_flexcan_data *data = dev->data; @@ -440,7 +443,7 @@ static void mcux_flexcan_detach(struct device *dev, int filter_id) k_mutex_unlock(&data->rx_mutex); } -static inline void mcux_flexcan_transfer_error_status(struct device *dev, +static inline void mcux_flexcan_transfer_error_status(const struct device *dev, uint32_t error) { const struct mcux_flexcan_config *config = dev->config; @@ -517,7 +520,7 @@ static inline void mcux_flexcan_transfer_error_status(struct device *dev, } } -static inline void mcux_flexcan_transfer_tx_idle(struct device *dev, +static inline void mcux_flexcan_transfer_tx_idle(const struct device *dev, uint32_t mb) { struct mcux_flexcan_data *data = dev->data; @@ -542,7 +545,7 @@ static inline void mcux_flexcan_transfer_tx_idle(struct device *dev, } } -static inline void mcux_flexcan_transfer_rx_idle(struct device *dev, +static inline void mcux_flexcan_transfer_rx_idle(const struct device *dev, uint32_t mb) { const struct mcux_flexcan_config *config = dev->config; @@ -583,7 +586,7 @@ static void mcux_flexcan_transfer_callback(CAN_Type *base, status_t status, uint32_t result, void *userData) { - struct device *dev = (struct device *)userData; + const struct device *dev = (const struct device *)userData; switch (status) { case kStatus_FLEXCAN_UnHandled: @@ -609,14 +612,14 @@ static void mcux_flexcan_transfer_callback(CAN_Type *base, static void mcux_flexcan_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_flexcan_config *config = dev->config; struct mcux_flexcan_data *data = dev->data; FLEXCAN_TransferHandleIRQ(config->base, &data->handle); } -static int mcux_flexcan_init(struct device *dev) +static int mcux_flexcan_init(const struct device *dev) { const struct mcux_flexcan_config *config = dev->config; struct mcux_flexcan_data *data = dev->data; @@ -661,7 +664,7 @@ static const struct can_driver_api mcux_flexcan_driver_api = { }; #if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) -static void mcux_flexcan_config_func_0(struct device *dev); +static void mcux_flexcan_config_func_0(const struct device *dev); static const struct mcux_flexcan_config mcux_flexcan_config_0 = { .base = (CAN_Type *) DT_INST_REG_ADDR(0), @@ -685,7 +688,7 @@ DEVICE_AND_API_INIT(can_mcux_flexcan_0, DT_INST_LABEL(0), &mcux_flexcan_config_0, POST_KERNEL, CONFIG_CAN_INIT_PRIORITY, &mcux_flexcan_driver_api); -static void mcux_flexcan_config_func_0(struct device *dev) +static void mcux_flexcan_config_func_0(const struct device *dev) { #if DT_INST_IRQ_HAS_NAME(0, rx_warning) IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, rx_warning, irq), @@ -731,9 +734,9 @@ static void mcux_flexcan_config_func_0(struct device *dev) #include "socket_can_generic.h" -static int socket_can_init_0(struct device *dev) +static int socket_can_init_0(const struct device *dev) { - struct device *can_dev = DEVICE_GET(can_mcux_flexcan_0); + const struct device *can_dev = DEVICE_GET(can_mcux_flexcan_0); struct socket_can_context *socket_context = dev->data; LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)", @@ -763,7 +766,7 @@ NET_DEVICE_INIT(socket_can_flexcan_0, SOCKET_CAN_NAME_1, socket_can_init_0, #endif /* DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) */ #if DT_NODE_HAS_STATUS(DT_DRV_INST(1), okay) -static void mcux_flexcan_config_func_1(struct device *dev); +static void mcux_flexcan_config_func_1(const struct device *dev); static const struct mcux_flexcan_config mcux_flexcan_config_1 = { .base = (CAN_Type *) DT_INST_REG_ADDR(1), @@ -787,7 +790,7 @@ DEVICE_AND_API_INIT(can_mcux_flexcan_1, DT_INST_LABEL(1), &mcux_flexcan_config_1, POST_KERNEL, CONFIG_CAN_INIT_PRIORITY, &mcux_flexcan_driver_api); -static void mcux_flexcan_config_func_1(struct device *dev) +static void mcux_flexcan_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, warning, irq), DT_INST_IRQ_BY_NAME(1, warning, priority), diff --git a/drivers/can/can_net.c b/drivers/can/can_net.c index ee3839714ea24d..9c9c1ce72b0a57 100644 --- a/drivers/can/can_net.c +++ b/drivers/can/can_net.c @@ -16,7 +16,7 @@ struct mcast_filter_mapping { }; struct net_can_context { - struct device *can_dev; + const struct device *can_dev; struct net_if *iface; int recv_filter_id; struct mcast_filter_mapping mcast_mapping[NET_IF_MAX_IPV6_MADDR]; @@ -88,7 +88,8 @@ static inline void can_set_lladdr(struct net_pkt *pkt, struct zcan_frame *frame) net_buf_pull(buf, sizeof(uint16_t)); } -static int net_can_send(struct device *dev, const struct zcan_frame *frame, +static int net_can_send(const struct device *dev, + const struct zcan_frame *frame, can_tx_callback_t cb, void *cb_arg, k_timeout_t timeout) { struct net_can_context *ctx = dev->data; @@ -172,7 +173,7 @@ static inline int attach_mcast_filter(struct net_can_context *ctx, static void mcast_cb(struct net_if *iface, const struct in6_addr *addr, bool is_joined) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_can_context *ctx = dev->data; struct mcast_filter_mapping *filter_mapping; int filter_id; @@ -205,7 +206,7 @@ static void mcast_cb(struct net_if *iface, const struct in6_addr *addr, static void net_can_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_can_context *ctx = dev->data; ctx->iface = iface; @@ -217,7 +218,7 @@ static void net_can_iface_init(struct net_if *iface) net_if_mcast_mon_register(&mcast_monitor, iface, mcast_cb); } -static int can_attach_filter(struct device *dev, can_rx_callback_t cb, +static int can_attach_filter(const struct device *dev, can_rx_callback_t cb, void *cb_arg, const struct zcan_filter *filter) { @@ -226,7 +227,7 @@ static int can_attach_filter(struct device *dev, can_rx_callback_t cb, return can_attach_isr(ctx->can_dev, cb, cb_arg, filter); } -static void can_detach_filter(struct device *dev, int filter_id) +static void can_detach_filter(const struct device *dev, int filter_id) { struct net_can_context *ctx = dev->data; @@ -312,7 +313,7 @@ static inline int can_attach_all_mcast_filter(struct net_can_context *ctx) } #endif /*CONFIG_NET_L2_CANBUS_ETH_TRANSLATOR*/ -static int can_enable(struct device *dev, bool enable) +static int can_enable(const struct device *dev, bool enable) { struct net_can_context *ctx = dev->data; @@ -370,9 +371,9 @@ static struct net_can_api net_can_api_inst = { .enable = can_enable, }; -static int net_can_init(struct device *dev) +static int net_can_init(const struct device *dev) { - struct device *can_dev; + const struct device *can_dev; struct net_can_context *ctx = dev->data; can_dev = device_get_binding(DT_CHOSEN_ZEPHYR_CAN_PRIMARY_LABEL); diff --git a/drivers/can/can_shell.c b/drivers/can/can_shell.c index 8a911c353fcc46..b414c8c6f641f2 100644 --- a/drivers/can/can_shell.c +++ b/drivers/can/can_shell.c @@ -209,7 +209,7 @@ static void print_frame(struct zcan_frame *frame, void *arg) static int cmd_config(const struct shell *shell, size_t argc, char **argv) { - struct device *can_dev; + const struct device *can_dev; int pos = 1; bool silent = false, loopback = false; enum can_mode mode; @@ -257,7 +257,7 @@ static int cmd_config(const struct shell *shell, size_t argc, char **argv) static int cmd_send(const struct shell *shell, size_t argc, char **argv) { - struct device *can_dev; + const struct device *can_dev; int pos = 1; bool rtr = false, ext = false; struct zcan_frame frame; @@ -308,7 +308,7 @@ static int cmd_send(const struct shell *shell, size_t argc, char **argv) static int cmd_attach(const struct shell *shell, size_t argc, char **argv) { - struct device *can_dev; + const struct device *can_dev; int pos = 1; bool rtr = false, ext = false, rtr_mask = false; struct zcan_filter filter; @@ -384,7 +384,7 @@ static int cmd_attach(const struct shell *shell, size_t argc, char **argv) static int cmd_detach(const struct shell *shell, size_t argc, char **argv) { - struct device *can_dev; + const struct device *can_dev; char *end_ptr; long id; diff --git a/drivers/can/can_stm32.c b/drivers/can/can_stm32.c index e7649a53d28bd9..a60a89763aac92 100644 --- a/drivers/can/can_stm32.c +++ b/drivers/can/can_stm32.c @@ -175,12 +175,12 @@ void can_stm32_tx_isr_handler(CAN_TypeDef *can, struct can_stm32_data *data) static void can_stm32_isr(void *arg) { - struct device *dev; + const struct device *dev; struct can_stm32_data *data; const struct can_stm32_config *cfg; CAN_TypeDef *can; - dev = (struct device *)arg; + dev = (const struct device *)arg; data = DEV_DATA(dev); cfg = DEV_CFG(dev); can = cfg->can; @@ -197,12 +197,12 @@ static void can_stm32_isr(void *arg) static void can_stm32_rx_isr(void *arg) { - struct device *dev; + const struct device *dev; struct can_stm32_data *data; const struct can_stm32_config *cfg; CAN_TypeDef *can; - dev = (struct device *)arg; + dev = (const struct device *)arg; data = DEV_DATA(dev); cfg = DEV_CFG(dev); can = cfg->can; @@ -212,12 +212,12 @@ static void can_stm32_rx_isr(void *arg) static void can_stm32_tx_isr(void *arg) { - struct device *dev; + const struct device *dev; struct can_stm32_data *data; const struct can_stm32_config *cfg; CAN_TypeDef *can; - dev = (struct device *)arg; + dev = (const struct device *)arg; data = DEV_DATA(dev); cfg = DEV_CFG(dev); can = cfg->can; @@ -227,12 +227,12 @@ static void can_stm32_tx_isr(void *arg) static void can_stm32_state_change_isr(void *arg) { - struct device *dev; + const struct device *dev; struct can_stm32_data *data; const struct can_stm32_config *cfg; CAN_TypeDef *can; - dev = (struct device *)arg; + dev = (const struct device *)arg; data = DEV_DATA(dev); cfg = DEV_CFG(dev); can = cfg->can; @@ -297,14 +297,14 @@ static int can_leave_sleep_mode(CAN_TypeDef *can) return 0; } -int can_stm32_runtime_configure(struct device *dev, enum can_mode mode, +int can_stm32_runtime_configure(const struct device *dev, enum can_mode mode, uint32_t bitrate) { CAN_HandleTypeDef hcan; const struct can_stm32_config *cfg = DEV_CFG(dev); CAN_TypeDef *can = cfg->can; struct can_stm32_data *data = DEV_DATA(dev); - struct device *clock; + const struct device *clock; uint32_t clock_rate; uint32_t prescaler; uint32_t reg_mode; @@ -383,7 +383,7 @@ int can_stm32_runtime_configure(struct device *dev, enum can_mode mode, return ret; } -static int can_stm32_init(struct device *dev) +static int can_stm32_init(const struct device *dev) { const struct can_stm32_config *cfg = DEV_CFG(dev); struct can_stm32_data *data = DEV_DATA(dev); @@ -391,7 +391,7 @@ static int can_stm32_init(struct device *dev) #if DT_NODE_HAS_STATUS(DT_NODELABEL(can2), okay) CAN_TypeDef *master_can = cfg->master_can; #endif - struct device *clock; + const struct device *clock; int ret; k_mutex_init(&data->inst_mutex); @@ -458,7 +458,7 @@ static int can_stm32_init(struct device *dev) return 0; } -static void can_stm32_register_state_change_isr(struct device *dev, +static void can_stm32_register_state_change_isr(const struct device *dev, can_state_change_isr_t isr) { struct can_stm32_data *data = DEV_DATA(dev); @@ -474,7 +474,7 @@ static void can_stm32_register_state_change_isr(struct device *dev, } } -static enum can_state can_stm32_get_state(struct device *dev, +static enum can_state can_stm32_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { const struct can_stm32_config *cfg = DEV_CFG(dev); @@ -500,7 +500,7 @@ static enum can_state can_stm32_get_state(struct device *dev, } #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -int can_stm32_recover(struct device *dev, k_timeout_t timeout) +int can_stm32_recover(const struct device *dev, k_timeout_t timeout) { const struct can_stm32_config *cfg = DEV_CFG(dev); struct can_stm32_data *data = DEV_DATA(dev); @@ -541,7 +541,7 @@ int can_stm32_recover(struct device *dev, k_timeout_t timeout) #endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */ -int can_stm32_send(struct device *dev, const struct zcan_frame *msg, +int can_stm32_send(const struct device *dev, const struct zcan_frame *msg, k_timeout_t timeout, can_tx_callback_t callback, void *callback_arg) { @@ -951,7 +951,8 @@ static inline int can_stm32_set_filter(const struct zcan_filter *filter, return filter_nr; } -static inline int can_stm32_attach(struct device *dev, can_rx_callback_t cb, +static inline int can_stm32_attach(const struct device *dev, + can_rx_callback_t cb, void *cb_arg, const struct zcan_filter *filter) { @@ -970,7 +971,7 @@ static inline int can_stm32_attach(struct device *dev, can_rx_callback_t cb, return filter_nr; } -int can_stm32_attach_isr(struct device *dev, can_rx_callback_t isr, +int can_stm32_attach_isr(const struct device *dev, can_rx_callback_t isr, void *cb_arg, const struct zcan_filter *filter) { @@ -983,7 +984,7 @@ int can_stm32_attach_isr(struct device *dev, can_rx_callback_t isr, return filter_nr; } -void can_stm32_detach(struct device *dev, int filter_nr) +void can_stm32_detach(const struct device *dev, int filter_nr) { const struct can_stm32_config *cfg = DEV_CFG(dev); struct can_stm32_data *data = DEV_DATA(dev); @@ -1103,9 +1104,9 @@ static void config_can_1_irq(CAN_TypeDef *can) #include "socket_can_generic.h" -static int socket_can_init_1(struct device *dev) +static int socket_can_init_1(const struct device *dev) { - struct device *can_dev = DEVICE_GET(can_stm32_1); + const struct device *can_dev = DEVICE_GET(can_stm32_1); struct socket_can_context *socket_context = dev->data; LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)", @@ -1186,9 +1187,9 @@ static void config_can_2_irq(CAN_TypeDef *can) #include "socket_can_generic.h" -static int socket_can_init_2(struct device *dev) +static int socket_can_init_2(const struct device *dev) { - struct device *can_dev = DEVICE_GET(can_stm32_2); + const struct device *can_dev = DEVICE_GET(can_stm32_2); struct socket_can_context *socket_context = dev->data; LOG_DBG("Init socket CAN device %p (%s) for dev %p (%s)", diff --git a/drivers/can/socket_can_generic.h b/drivers/can/socket_can_generic.h index 46512d9e7985a4..77dfdae622bf5e 100644 --- a/drivers/can/socket_can_generic.h +++ b/drivers/can/socket_can_generic.h @@ -24,7 +24,7 @@ CAN_DEFINE_MSGQ(socket_can_msgq, 5); K_KERNEL_STACK_DEFINE(rx_thread_stack, RX_THREAD_STACK_SIZE); struct socket_can_context { - struct device *can_dev; + const struct device *can_dev; struct net_if *iface; struct k_msgq *msgq; @@ -35,7 +35,7 @@ struct socket_can_context { static inline void socket_can_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct socket_can_context *socket_context = dev->data; socket_context->iface = iface; @@ -53,7 +53,8 @@ static inline void tx_irq_callback(uint32_t error_flags, void *arg) } /* This is called by net_if.c when packet is about to be sent */ -static inline int socket_can_send(struct device *dev, struct net_pkt *pkt) +static inline int socket_can_send(const struct device *dev, + struct net_pkt *pkt) { struct socket_can_context *socket_context = dev->data; int ret; @@ -75,7 +76,7 @@ static inline int socket_can_send(struct device *dev, struct net_pkt *pkt) return -ret; } -static inline int socket_can_setsockopt(struct device *dev, void *obj, +static inline int socket_can_setsockopt(const struct device *dev, void *obj, int level, int optname, const void *optval, socklen_t optlen) { @@ -102,7 +103,7 @@ static inline int socket_can_setsockopt(struct device *dev, void *obj, return 0; } -static inline void socket_can_close(struct device *dev, int filter_id) +static inline void socket_can_close(const struct device *dev, int filter_id) { struct socket_can_context *socket_context = dev->data; diff --git a/drivers/clock_control/beetle_clock_control.c b/drivers/clock_control/beetle_clock_control.c index b6eb1c46759be0..79132c2780ffd6 100644 --- a/drivers/clock_control/beetle_clock_control.c +++ b/drivers/clock_control/beetle_clock_control.c @@ -80,7 +80,7 @@ static inline void beetle_apb_set_clock_off(uint8_t bit, bit, state); } -static inline int beetle_clock_control_on(struct device *dev, +static inline int beetle_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { struct arm_clock_control_t *beetle_cc = @@ -104,7 +104,7 @@ static inline int beetle_clock_control_on(struct device *dev, return 0; } -static inline int beetle_clock_control_off(struct device *dev, +static inline int beetle_clock_control_off(const struct device *dev, clock_control_subsys_t sub_system) { struct arm_clock_control_t *beetle_cc = @@ -127,9 +127,9 @@ static inline int beetle_clock_control_off(struct device *dev, return 0; } -static int beetle_clock_control_get_subsys_rate(struct device *clock, - clock_control_subsys_t sub_system, - uint32_t *rate) +static int beetle_clock_control_get_subsys_rate(const struct device *clock, + clock_control_subsys_t sub_system, + uint32_t *rate) { #ifdef CONFIG_CLOCK_CONTROL_BEETLE_ENABLE_PLL const struct beetle_clock_control_cfg_t * const cfg = @@ -215,7 +215,7 @@ static int beetle_pll_enable(uint32_t mainclk) } #endif /* CONFIG_CLOCK_CONTROL_BEETLE_ENABLE_PLL */ -static int beetle_clock_control_init(struct device *dev) +static int beetle_clock_control_init(const struct device *dev) { #ifdef CONFIG_CLOCK_CONTROL_BEETLE_ENABLE_PLL const struct beetle_clock_control_cfg_t * const cfg = diff --git a/drivers/clock_control/clock_control_esp32.c b/drivers/clock_control/clock_control_esp32.c index 57ab494a02f052..b5322c244d694a 100644 --- a/drivers/clock_control/clock_control_esp32.c +++ b/drivers/clock_control/clock_control_esp32.c @@ -201,7 +201,7 @@ static void cpuclk_pll_configure(uint32_t xtal_freq, uint32_t cpu_freq) REG_WRITE(APB_CTRL_PLL_TICK_CONF_REG, PLL_APB_CLK_FREQ - 1); } -static int clock_control_esp32_on(struct device *dev, +static int clock_control_esp32_on(const struct device *dev, clock_control_subsys_t sys) { ARG_UNUSED(dev); @@ -215,7 +215,7 @@ static int clock_control_esp32_on(struct device *dev, return 0; } -static int clock_control_esp32_off(struct device *dev, +static int clock_control_esp32_off(const struct device *dev, clock_control_subsys_t sys) { ARG_UNUSED(dev); @@ -229,7 +229,7 @@ static int clock_control_esp32_off(struct device *dev, return 0; } -static enum clock_control_status clock_control_esp32_get_status(struct device *dev, +static enum clock_control_status clock_control_esp32_get_status(const struct device *dev, clock_control_subsys_t sys) { ARG_UNUSED(dev); @@ -242,7 +242,7 @@ static enum clock_control_status clock_control_esp32_get_status(struct device *d return CLOCK_CONTROL_STATUS_OFF; } -static int clock_control_esp32_get_rate(struct device *dev, +static int clock_control_esp32_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -264,7 +264,7 @@ static int clock_control_esp32_get_rate(struct device *dev, } } -static int clock_control_esp32_init(struct device *dev) +static int clock_control_esp32_init(const struct device *dev) { struct esp32_clock_config *cfg = DEV_CFG(dev); diff --git a/drivers/clock_control/clock_control_lpc11u6x.c b/drivers/clock_control/clock_control_lpc11u6x.c index 15f0a3ef6c8d2f..123f8038a359f1 100644 --- a/drivers/clock_control/clock_control_lpc11u6x.c +++ b/drivers/clock_control/clock_control_lpc11u6x.c @@ -90,7 +90,7 @@ static void syscon_ahb_clock_enable(struct lpc11u6x_syscon_regs *syscon, */ static void pinmux_enable_sysosc(void) { - struct device *pinmux_dev; + const struct device *pinmux_dev; uint32_t pin, func; pinmux_dev = device_get_binding( @@ -148,7 +148,7 @@ static void syscon_frg_deinit(struct lpc11u6x_syscon_regs *syscon) syscon_peripheral_reset(syscon, LPC11U6X_PRESET_CTRL_FRG, true); } -static int lpc11u6x_clock_control_on(struct device *dev, +static int lpc11u6x_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { const struct lpc11u6x_syscon_config *cfg = DEV_CFG(dev); @@ -220,8 +220,8 @@ static int lpc11u6x_clock_control_on(struct device *dev, return ret; } -static int lpc11u6x_clock_control_off(struct device *dev, - clock_control_subsys_t sub_system) +static int lpc11u6x_clock_control_off(const struct device *dev, + clock_control_subsys_t sub_system) { const struct lpc11u6x_syscon_config *cfg = DEV_CFG(dev); struct lpc11u6x_syscon_data *data = DEV_DATA(dev); @@ -294,7 +294,7 @@ static int lpc11u6x_clock_control_off(struct device *dev, } -static int lpc11u6x_clock_control_get_rate(struct device *dev, +static int lpc11u6x_clock_control_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -317,7 +317,7 @@ static int lpc11u6x_clock_control_get_rate(struct device *dev, return 0; } -static int lpc11u6x_syscon_init(struct device *dev) +static int lpc11u6x_syscon_init(const struct device *dev) { const struct lpc11u6x_syscon_config *cfg = DEV_CFG(dev); struct lpc11u6x_syscon_data *data = DEV_DATA(dev); diff --git a/drivers/clock_control/clock_control_mcux_ccm.c b/drivers/clock_control/clock_control_mcux_ccm.c index 305c2c936fdb5f..e9ea3f2dc85892 100644 --- a/drivers/clock_control/clock_control_mcux_ccm.c +++ b/drivers/clock_control/clock_control_mcux_ccm.c @@ -24,19 +24,19 @@ static const clock_name_t lpspi_clocks[] = { }; #endif -static int mcux_ccm_on(struct device *dev, +static int mcux_ccm_on(const struct device *dev, clock_control_subsys_t sub_system) { return 0; } -static int mcux_ccm_off(struct device *dev, +static int mcux_ccm_off(const struct device *dev, clock_control_subsys_t sub_system) { return 0; } -static int mcux_ccm_get_subsys_rate(struct device *dev, +static int mcux_ccm_get_subsys_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -115,7 +115,7 @@ static int mcux_ccm_get_subsys_rate(struct device *dev, return 0; } -static int mcux_ccm_init(struct device *dev) +static int mcux_ccm_init(const struct device *dev) { return 0; } diff --git a/drivers/clock_control/clock_control_mcux_mcg.c b/drivers/clock_control/clock_control_mcux_mcg.c index cd3d8224118c93..16e5869532271a 100644 --- a/drivers/clock_control/clock_control_mcux_mcg.c +++ b/drivers/clock_control/clock_control_mcux_mcg.c @@ -18,17 +18,19 @@ #include LOG_MODULE_REGISTER(clock_control_mcg); -static int mcux_mcg_on(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_mcg_on(const struct device *dev, + clock_control_subsys_t sub_system) { return 0; } -static int mcux_mcg_off(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_mcg_off(const struct device *dev, + clock_control_subsys_t sub_system) { return 0; } -static int mcux_mcg_get_rate(struct device *dev, +static int mcux_mcg_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -48,7 +50,7 @@ static int mcux_mcg_get_rate(struct device *dev, return 0; } -static int mcux_mcg_init(struct device *dev) +static int mcux_mcg_init(const struct device *dev) { return 0; } diff --git a/drivers/clock_control/clock_control_mcux_pcc.c b/drivers/clock_control/clock_control_mcux_pcc.c index e67933d9d011a8..a5c8d84c8e39da 100644 --- a/drivers/clock_control/clock_control_mcux_pcc.c +++ b/drivers/clock_control/clock_control_mcux_pcc.c @@ -28,7 +28,7 @@ struct mcux_pcc_config { #define MAKE_PCC_REGADDR(base, offset) ((base) + (offset)) #endif -static inline clock_ip_name_t clock_ip(struct device *dev, +static inline clock_ip_name_t clock_ip(const struct device *dev, clock_control_subsys_t sub_system) { uint32_t offset = POINTER_TO_UINT(sub_system); @@ -36,19 +36,21 @@ static inline clock_ip_name_t clock_ip(struct device *dev, return MAKE_PCC_REGADDR(DEV_BASE(dev), offset); } -static int mcux_pcc_on(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_pcc_on(const struct device *dev, + clock_control_subsys_t sub_system) { CLOCK_EnableClock(clock_ip(dev, sub_system)); return 0; } -static int mcux_pcc_off(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_pcc_off(const struct device *dev, + clock_control_subsys_t sub_system) { CLOCK_DisableClock(clock_ip(dev, sub_system)); return 0; } -static int mcux_pcc_get_rate(struct device *dev, +static int mcux_pcc_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -56,7 +58,7 @@ static int mcux_pcc_get_rate(struct device *dev, return 0; } -static int mcux_pcc_init(struct device *dev) +static int mcux_pcc_init(const struct device *dev) { return 0; } diff --git a/drivers/clock_control/clock_control_mcux_scg.c b/drivers/clock_control/clock_control_mcux_scg.c index 2d7d0653a0ff11..14f448459d5136 100644 --- a/drivers/clock_control/clock_control_mcux_scg.c +++ b/drivers/clock_control/clock_control_mcux_scg.c @@ -18,17 +18,19 @@ #include LOG_MODULE_REGISTER(clock_control_scg); -static int mcux_scg_on(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_scg_on(const struct device *dev, + clock_control_subsys_t sub_system) { return 0; } -static int mcux_scg_off(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_scg_off(const struct device *dev, + clock_control_subsys_t sub_system) { return 0; } -static int mcux_scg_get_rate(struct device *dev, +static int mcux_scg_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -92,7 +94,7 @@ static int mcux_scg_get_rate(struct device *dev, return 0; } -static int mcux_scg_init(struct device *dev) +static int mcux_scg_init(const struct device *dev) { #if DT_INST_NODE_HAS_PROP(0, clkout_source) CLOCK_SetClkOutSel(DT_INST_PROP(0, clkout_source)); diff --git a/drivers/clock_control/clock_control_mcux_sim.c b/drivers/clock_control/clock_control_mcux_sim.c index 552785f7120aca..0587512b68ed7c 100644 --- a/drivers/clock_control/clock_control_mcux_sim.c +++ b/drivers/clock_control/clock_control_mcux_sim.c @@ -15,7 +15,8 @@ #include LOG_MODULE_REGISTER(clock_control); -static int mcux_sim_on(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_sim_on(const struct device *dev, + clock_control_subsys_t sub_system) { clock_ip_name_t clock_ip_name = (clock_ip_name_t) sub_system; @@ -24,7 +25,8 @@ static int mcux_sim_on(struct device *dev, clock_control_subsys_t sub_system) return 0; } -static int mcux_sim_off(struct device *dev, clock_control_subsys_t sub_system) +static int mcux_sim_off(const struct device *dev, + clock_control_subsys_t sub_system) { clock_ip_name_t clock_ip_name = (clock_ip_name_t) sub_system; @@ -33,7 +35,7 @@ static int mcux_sim_off(struct device *dev, clock_control_subsys_t sub_system) return 0; } -static int mcux_sim_get_subsys_rate(struct device *dev, +static int mcux_sim_get_subsys_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -75,7 +77,7 @@ static int mcux_sim_get_subsys_rate(struct device *dev, #endif #endif -static int mcux_sim_init(struct device *dev) +static int mcux_sim_init(const struct device *dev) { #ifdef NXP_KINETIS_SIM_CLKOUT_DIVIDER SIM->CHIPCTL = (SIM->CHIPCTL & ~SIM_CHIPCTL_CLKOUTDIV_MASK) diff --git a/drivers/clock_control/clock_control_npcx.c b/drivers/clock_control/clock_control_npcx.c index 7fed97ca2eb084..af428f776ad4cf 100644 --- a/drivers/clock_control/clock_control_npcx.c +++ b/drivers/clock_control/clock_control_npcx.c @@ -32,7 +32,7 @@ struct npcx_pcc_config { (struct pmc_reg *)(DRV_CONFIG(dev)->base_pmc) /* Clock controller local functions */ -static inline int npcx_clock_control_on(struct device *dev, +static inline int npcx_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { ARG_UNUSED(dev); @@ -44,7 +44,7 @@ static inline int npcx_clock_control_on(struct device *dev, return 0; } -static inline int npcx_clock_control_off(struct device *dev, +static inline int npcx_clock_control_off(const struct device *dev, clock_control_subsys_t sub_system) { ARG_UNUSED(dev); @@ -56,9 +56,9 @@ static inline int npcx_clock_control_off(struct device *dev, return 0; } -static int npcx_clock_control_get_subsys_rate(struct device *dev, - clock_control_subsys_t sub_system, - uint32_t *rate) +static int npcx_clock_control_get_subsys_rate(const struct device *dev, + clock_control_subsys_t sub_system, + uint32_t *rate) { ARG_UNUSED(dev); struct npcx_clk_cfg *clk_cfg = (struct npcx_clk_cfg *)(sub_system); @@ -101,7 +101,7 @@ static struct clock_control_driver_api npcx_clock_control_api = { .get_rate = npcx_clock_control_get_subsys_rate, }; -static int npcx_clock_control_init(struct device *dev) +static int npcx_clock_control_init(const struct device *dev) { struct cdcg_reg *inst_cdcg = HAL_CDCG_INST(dev); uint32_t pmc_base = DRV_CONFIG(dev)->base_pmc; diff --git a/drivers/clock_control/clock_control_nrf.c b/drivers/clock_control/clock_control_nrf.c index 2ac3d1439bbd02..283f88aeccc8af 100644 --- a/drivers/clock_control/clock_control_nrf.c +++ b/drivers/clock_control/clock_control_nrf.c @@ -79,17 +79,16 @@ static atomic_t hfclk_users; static uint64_t hf_start_tstamp; static uint64_t hf_stop_tstamp; -static struct nrf_clock_control_sub_data *get_sub_data(struct device *dev, - enum clock_control_nrf_type type) +static struct nrf_clock_control_sub_data *get_sub_data(const struct device *dev, + enum clock_control_nrf_type type) { struct nrf_clock_control_data *data = dev->data; return &data->subsys[type]; } -static const struct nrf_clock_control_sub_config *get_sub_config( - struct device *dev, - enum clock_control_nrf_type type) +static const struct nrf_clock_control_sub_config *get_sub_config(const struct device *dev, + enum clock_control_nrf_type type) { const struct nrf_clock_control_config *config = dev->config; @@ -97,8 +96,8 @@ static const struct nrf_clock_control_sub_config *get_sub_config( return &config->subsys[type]; } -static struct onoff_manager *get_onoff_manager(struct device *dev, - enum clock_control_nrf_type type) +static struct onoff_manager *get_onoff_manager(const struct device *dev, + enum clock_control_nrf_type type) { struct nrf_clock_control_data *data = dev->data; @@ -113,7 +112,7 @@ struct onoff_manager *z_nrf_clock_control_get_onoff(clock_control_subsys_t sys) (enum clock_control_nrf_type)sys); } -static enum clock_control_status get_status(struct device *dev, +static enum clock_control_status get_status(const struct device *dev, clock_control_subsys_t subsys) { enum clock_control_nrf_type type = (enum clock_control_nrf_type)subsys; @@ -167,7 +166,7 @@ static void set_on_state(uint32_t *flags) irq_unlock(key); } -static void clkstarted_handle(struct device *dev, +static void clkstarted_handle(const struct device *dev, enum clock_control_nrf_type type) { struct nrf_clock_control_sub_data *sub_data = get_sub_data(dev, type); @@ -300,7 +299,8 @@ void z_nrf_clock_bt_ctlr_hf_release(void) hfclk_stop(); } -static int stop(struct device *dev, clock_control_subsys_t subsys, uint32_t ctx) +static int stop(const struct device *dev, clock_control_subsys_t subsys, + uint32_t ctx) { enum clock_control_nrf_type type = (enum clock_control_nrf_type)subsys; struct nrf_clock_control_sub_data *subdata = get_sub_data(dev, type); @@ -318,12 +318,13 @@ static int stop(struct device *dev, clock_control_subsys_t subsys, uint32_t ctx) return 0; } -static int api_stop(struct device *dev, clock_control_subsys_t subsys) +static int api_stop(const struct device *dev, clock_control_subsys_t subsys) { return stop(dev, subsys, CTX_API); } -static int async_start(struct device *dev, clock_control_subsys_t subsys, +static int async_start(const struct device *dev, + clock_control_subsys_t subsys, struct clock_control_async_data *data, uint32_t ctx) { enum clock_control_nrf_type type = (enum clock_control_nrf_type)subsys; @@ -343,13 +344,13 @@ static int async_start(struct device *dev, clock_control_subsys_t subsys, return 0; } -static int api_start(struct device *dev, clock_control_subsys_t subsys, +static int api_start(const struct device *dev, clock_control_subsys_t subsys, struct clock_control_async_data *data) { return async_start(dev, subsys, data, CTX_API); } -static void blocking_start_callback(struct device *dev, +static void blocking_start_callback(const struct device *dev, clock_control_subsys_t subsys, void *user_data) { @@ -358,7 +359,8 @@ static void blocking_start_callback(struct device *dev, k_sem_give(sem); } -static int api_blocking_start(struct device *dev, clock_control_subsys_t subsys) +static int api_blocking_start(const struct device *dev, + clock_control_subsys_t subsys) { struct k_sem sem = Z_SEM_INITIALIZER(sem, 0, 1); struct clock_control_async_data data = { @@ -396,7 +398,7 @@ static void onoff_stop(struct onoff_manager *mgr, notify(mgr, res); } -static void onoff_started_callback(struct device *dev, +static void onoff_started_callback(const struct device *dev, clock_control_subsys_t sys, void *user_data) { @@ -468,7 +470,7 @@ void z_nrf_clock_control_lf_on(enum nrf_lfclk_start_mode start_mode) static void clock_event_handler(nrfx_clock_evt_type_t event) { - struct device *dev = DEVICE_GET(clock_nrf); + const struct device *dev = DEVICE_GET(clock_nrf); switch (event) { case NRFX_CLOCK_EVT_HFCLK_STARTED: @@ -503,7 +505,7 @@ static void clock_event_handler(nrfx_clock_evt_type_t event) } } -static int clk_init(struct device *dev) +static int clk_init(const struct device *dev) { nrfx_err_t nrfx_err; int err; diff --git a/drivers/clock_control/clock_control_rv32m1_pcc.c b/drivers/clock_control/clock_control_rv32m1_pcc.c index a81f76b42a44ea..f3afe39a9fcbcb 100644 --- a/drivers/clock_control/clock_control_rv32m1_pcc.c +++ b/drivers/clock_control/clock_control_rv32m1_pcc.c @@ -21,7 +21,7 @@ struct rv32m1_pcc_config { #define DEV_CFG(dev) ((struct rv32m1_pcc_config *)(dev->config)) #define DEV_BASE(dev) (DEV_CFG(dev)->base_address) -static inline clock_ip_name_t clock_ip(struct device *dev, +static inline clock_ip_name_t clock_ip(const struct device *dev, clock_control_subsys_t sub_system) { uint32_t offset = POINTER_TO_UINT(sub_system); @@ -29,19 +29,21 @@ static inline clock_ip_name_t clock_ip(struct device *dev, return MAKE_PCC_REGADDR(DEV_BASE(dev), offset); } -static int rv32m1_pcc_on(struct device *dev, clock_control_subsys_t sub_system) +static int rv32m1_pcc_on(const struct device *dev, + clock_control_subsys_t sub_system) { CLOCK_EnableClock(clock_ip(dev, sub_system)); return 0; } -static int rv32m1_pcc_off(struct device *dev, clock_control_subsys_t sub_system) +static int rv32m1_pcc_off(const struct device *dev, + clock_control_subsys_t sub_system) { CLOCK_DisableClock(clock_ip(dev, sub_system)); return 0; } -static int rv32m1_pcc_get_rate(struct device *dev, +static int rv32m1_pcc_get_rate(const struct device *dev, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -49,7 +51,7 @@ static int rv32m1_pcc_get_rate(struct device *dev, return 0; } -static int rv32m1_pcc_init(struct device *dev) +static int rv32m1_pcc_init(const struct device *dev) { return 0; } diff --git a/drivers/clock_control/clock_stm32_ll_common.c b/drivers/clock_control/clock_stm32_ll_common.c index 8e956d41f4abc7..4ea6cd4b536210 100644 --- a/drivers/clock_control/clock_stm32_ll_common.c +++ b/drivers/clock_control/clock_stm32_ll_common.c @@ -77,7 +77,7 @@ static uint32_t get_bus_clock(uint32_t clock, uint32_t prescaler) return clock / prescaler; } -static inline int stm32_clock_control_on(struct device *dev, +static inline int stm32_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -129,7 +129,7 @@ static inline int stm32_clock_control_on(struct device *dev, } -static inline int stm32_clock_control_off(struct device *dev, +static inline int stm32_clock_control_off(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -180,7 +180,7 @@ static inline int stm32_clock_control_off(struct device *dev, } -static int stm32_clock_control_get_subsys_rate(struct device *clock, +static int stm32_clock_control_get_subsys_rate(const struct device *clock, clock_control_subsys_t sub_system, uint32_t *rate) { @@ -283,7 +283,7 @@ static inline void stm32_clock_control_mco_init(void) #endif /* CONFIG_CLOCK_STM32_MCO2_SRC_NOCLOCK */ } -static int stm32_clock_control_init(struct device *dev) +static int stm32_clock_control_init(const struct device *dev) { LL_UTILS_ClkInitTypeDef s_ClkInitStruct; uint32_t hclk_prescaler; diff --git a/drivers/clock_control/clock_stm32_ll_h7.c b/drivers/clock_control/clock_stm32_ll_h7.c index e84413c2e88725..45c3d2b6e4f21c 100644 --- a/drivers/clock_control/clock_stm32_ll_h7.c +++ b/drivers/clock_control/clock_stm32_ll_h7.c @@ -298,7 +298,7 @@ static int32_t get_vco_input_range(uint32_t pllsrc_clock, uint32_t divm) #endif /* ! CONFIG_CPU_CORTEX_M4 */ -static inline int stm32_clock_control_on(struct device *dev, +static inline int stm32_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -347,7 +347,7 @@ static inline int stm32_clock_control_on(struct device *dev, return rc; } -static inline int stm32_clock_control_off(struct device *dev, +static inline int stm32_clock_control_off(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -395,9 +395,9 @@ static inline int stm32_clock_control_off(struct device *dev, return rc; } -static int stm32_clock_control_get_subsys_rate(struct device *clock, - clock_control_subsys_t sub_system, - uint32_t *rate) +static int stm32_clock_control_get_subsys_rate(const struct device *clock, + clock_control_subsys_t sub_system, + uint32_t *rate) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); /* @@ -456,7 +456,7 @@ static struct clock_control_driver_api stm32_clock_control_api = { .get_rate = stm32_clock_control_get_subsys_rate, }; -static int stm32_clock_control_init(struct device *dev) +static int stm32_clock_control_init(const struct device *dev) { #if !defined(CONFIG_CPU_CORTEX_M4) diff --git a/drivers/clock_control/clock_stm32_ll_mp1.c b/drivers/clock_control/clock_stm32_ll_mp1.c index bb5d7d224c6b63..2a14bc90fde707 100644 --- a/drivers/clock_control/clock_stm32_ll_mp1.c +++ b/drivers/clock_control/clock_stm32_ll_mp1.c @@ -12,7 +12,7 @@ /** * @brief fill in AHB/APB buses configuration structure */ -static inline int stm32_clock_control_on(struct device *dev, +static inline int stm32_clock_control_on(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -63,7 +63,7 @@ static inline int stm32_clock_control_on(struct device *dev, return 0; } -static inline int stm32_clock_control_off(struct device *dev, +static inline int stm32_clock_control_off(const struct device *dev, clock_control_subsys_t sub_system) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -114,9 +114,9 @@ static inline int stm32_clock_control_off(struct device *dev, return 0; } -static int stm32_clock_control_get_subsys_rate(struct device *clock, - clock_control_subsys_t sub_system, - uint32_t *rate) +static int stm32_clock_control_get_subsys_rate(const struct device *clock, + clock_control_subsys_t sub_system, + uint32_t *rate) { struct stm32_pclken *pclken = (struct stm32_pclken *)(sub_system); @@ -399,7 +399,7 @@ static struct clock_control_driver_api stm32_clock_control_api = { .get_rate = stm32_clock_control_get_subsys_rate, }; -static int stm32_clock_control_init(struct device *dev) +static int stm32_clock_control_init(const struct device *dev) { ARG_UNUSED(dev); return 0; diff --git a/drivers/clock_control/nrf_clock_calibration.c b/drivers/clock_control/nrf_clock_calibration.c index cc42aa2a1865ad..a498d9b625f929 100644 --- a/drivers/clock_control/nrf_clock_calibration.c +++ b/drivers/clock_control/nrf_clock_calibration.c @@ -48,7 +48,7 @@ static void cal_lf_callback(struct onoff_manager *mgr, static struct onoff_client cli; static struct onoff_manager *mgrs; -static struct device *temp_sensor; +static const struct device *temp_sensor; static void measure_temperature(struct k_work *work); static K_WORK_DEFINE(temp_measure_work, measure_temperature); @@ -226,7 +226,7 @@ static void measure_temperature(struct k_work *work) #define TEMP_NODE DT_INST(0, nordic_nrf_temp) #if DT_NODE_HAS_STATUS(TEMP_NODE, okay) -static inline struct device *temp_device(void) +static inline const struct device *temp_device(void) { return device_get_binding(DT_LABEL(TEMP_NODE)); } @@ -242,7 +242,7 @@ void z_nrf_clock_calibration_init(struct onoff_manager *onoff_mgrs) } #if CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP -static int temp_sensor_init(struct device *arg) +static int temp_sensor_init(const struct device *arg) { temp_sensor = temp_device(); diff --git a/drivers/console/gsm_mux.c b/drivers/console/gsm_mux.c index 25495c4c8de1af..81149e8b914572 100644 --- a/drivers/console/gsm_mux.c +++ b/drivers/console/gsm_mux.c @@ -75,7 +75,7 @@ struct gsm_mux { /* UART device to use. This device is the real UART, not the * muxed one. */ - struct device *uart; + const struct device *uart; /* Buf to use when TX mux packet (hdr + data). For RX it only contains * the data (not hdr). @@ -134,7 +134,7 @@ struct gsm_dlci { dlci_command_cb_t command_cb; gsm_mux_dlci_created_cb_t dlci_created_cb; void *user_data; - struct device *uart; + const struct device *uart; enum gsm_dlci_state state; enum gsm_dlci_mode mode; int num; @@ -975,7 +975,8 @@ static struct gsm_dlci *gsm_dlci_get_free(void) } static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *mux, uint8_t address, - struct device *uart, gsm_mux_dlci_created_cb_t dlci_created_cb, + const struct device *uart, + gsm_mux_dlci_created_cb_t dlci_created_cb, void *user_data) { struct gsm_dlci *dlci; @@ -1037,7 +1038,7 @@ static int gsm_mux_process_pkt(struct gsm_mux *mux) } if (dlci == NULL) { - struct device *uart; + const struct device *uart; uart = uart_mux_find(dlci_address); if (uart == NULL) { @@ -1398,7 +1399,7 @@ static void dlci_done(struct gsm_dlci *dlci, bool connected) } int gsm_dlci_create(struct gsm_mux *mux, - struct device *uart, + const struct device *uart, int dlci_address, gsm_mux_dlci_created_cb_t dlci_created_cb, void *user_data, @@ -1438,7 +1439,7 @@ int gsm_dlci_id(struct gsm_dlci *dlci) return dlci->num; } -struct gsm_mux *gsm_mux_create(struct device *uart) +struct gsm_mux *gsm_mux_create(const struct device *uart) { struct gsm_mux *mux = NULL; int i; diff --git a/drivers/console/gsm_mux.h b/drivers/console/gsm_mux.h index 9a113a559fcc13..7a4e888d8d3fe7 100644 --- a/drivers/console/gsm_mux.h +++ b/drivers/console/gsm_mux.h @@ -20,7 +20,7 @@ struct gsm_dlci; void gsm_mux_recv_buf(struct gsm_mux *mux, uint8_t *buf, int len); int gsm_mux_send(struct gsm_mux *mux, uint8_t dlci_address, const uint8_t *buf, size_t size); -struct gsm_mux *gsm_mux_create(struct device *uart); +struct gsm_mux *gsm_mux_create(const struct device *uart); int gsm_mux_disconnect(struct gsm_mux *mux, k_timeout_t timeout); void gsm_mux_init(void); @@ -29,7 +29,7 @@ typedef void (*gsm_mux_dlci_created_cb_t)(struct gsm_dlci *dlci, void *user_data); int gsm_dlci_create(struct gsm_mux *mux, - struct device *uart, + const struct device *uart, int dlci_address, gsm_mux_dlci_created_cb_t dlci_created_cb, void *user_data, diff --git a/drivers/console/ipm_console_receiver.c b/drivers/console/ipm_console_receiver.c index 79856683decc59..ed023d90ba5c21 100644 --- a/drivers/console/ipm_console_receiver.c +++ b/drivers/console/ipm_console_receiver.c @@ -21,12 +21,12 @@ static void ipm_console_thread(void *arg1, void *arg2, void *arg3) uint8_t size32; uint16_t type; int ret, key; - struct device *d; + const struct device *d; const struct ipm_console_receiver_config_info *config_info; struct ipm_console_receiver_runtime_data *driver_data; int pos; - d = (struct device *)arg1; + d = (const struct device *)arg1; driver_data = d->data; config_info = d->config; ARG_UNUSED(arg2); @@ -84,10 +84,11 @@ static void ipm_console_thread(void *arg1, void *arg2, void *arg3) } } -static void ipm_console_receive_callback(struct device *ipm_dev, void *context, +static void ipm_console_receive_callback(const struct device *ipm_dev, + void *context, uint32_t id, volatile void *data) { - struct device *d; + const struct device *d; struct ipm_console_receiver_runtime_data *driver_data; int ret; @@ -115,12 +116,12 @@ static void ipm_console_receive_callback(struct device *ipm_dev, void *context, } -int ipm_console_receiver_init(struct device *d) +int ipm_console_receiver_init(const struct device *d) { const struct ipm_console_receiver_config_info *config_info = d->config; struct ipm_console_receiver_runtime_data *driver_data = d->data; - struct device *ipm; + const struct device *ipm; ipm = device_get_binding(config_info->bind_to); diff --git a/drivers/console/ipm_console_sender.c b/drivers/console/ipm_console_sender.c index df033aa66ba76e..b453cdffd23c95 100644 --- a/drivers/console/ipm_console_sender.c +++ b/drivers/console/ipm_console_sender.c @@ -13,7 +13,7 @@ #include #include -static struct device *ipm_console_device; +static const struct device *ipm_console_device; static int consoleOut(int character) { @@ -33,7 +33,7 @@ static int consoleOut(int character) extern void __printk_hook_install(int (*fn)(int)); extern void __stdout_hook_install(int (*fn)(int)); -int ipm_console_sender_init(struct device *d) +int ipm_console_sender_init(const struct device *d) { const struct ipm_console_sender_config_info *config_info; diff --git a/drivers/console/native_posix_console.c b/drivers/console/native_posix_console.c index 92fa3dbf306da2..227e1fb85481e9 100644 --- a/drivers/console/native_posix_console.c +++ b/drivers/console/native_posix_console.c @@ -256,7 +256,7 @@ static void native_stdio_runner(void *p1, void *p2, void *p3) } #endif /* CONFIG_NATIVE_POSIX_STDIN_CONSOLE */ -static int native_posix_console_init(struct device *arg) +static int native_posix_console_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/drivers/console/ram_console.c b/drivers/console/ram_console.c index d568f50f18a7e3..7dc304eb269631 100644 --- a/drivers/console/ram_console.c +++ b/drivers/console/ram_console.c @@ -26,7 +26,7 @@ static int ram_console_out(int character) return character; } -static int ram_console_init(struct device *d) +static int ram_console_init(const struct device *d) { ARG_UNUSED(d); __printk_hook_install(ram_console_out); diff --git a/drivers/console/rtt_console.c b/drivers/console/rtt_console.c index 555aac130c076b..281156c48fc18b 100644 --- a/drivers/console/rtt_console.c +++ b/drivers/console/rtt_console.c @@ -78,7 +78,7 @@ static int rtt_console_out(int character) return character; } -static int rtt_console_init(struct device *d) +static int rtt_console_init(const struct device *d) { ARG_UNUSED(d); diff --git a/drivers/console/semihost_console.c b/drivers/console/semihost_console.c index fbe276cdbfaeb2..51106c7adc87c4 100644 --- a/drivers/console/semihost_console.c +++ b/drivers/console/semihost_console.c @@ -26,7 +26,7 @@ static int semihost_console_out(int ch) return ch; } -static int semihost_console_init(struct device *dev) +static int semihost_console_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 5d84660f0272ca..74d1013d26c769 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -35,7 +35,7 @@ #include "mgmt/serial.h" #endif -static struct device *uart_console_dev; +static const struct device *uart_console_dev; #ifdef CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS @@ -131,7 +131,8 @@ static uint8_t (*completion_cb)(char *line, uint8_t len); #define ANSI_HOME 'H' #define ANSI_DEL '~' -static int read_uart(struct device *uart, uint8_t *buf, unsigned int size) +static int read_uart(const struct device *uart, uint8_t *buf, + unsigned int size) { int rx; @@ -431,7 +432,7 @@ static bool handle_mcumgr(struct console_input *cmd, uint8_t byte) #endif /* CONFIG_UART_CONSOLE_MCUMGR */ -static void uart_console_isr(struct device *unused, void *user_data) +static void uart_console_isr(const struct device *unused, void *user_data) { ARG_UNUSED(unused); ARG_UNUSED(user_data); @@ -590,7 +591,7 @@ static void uart_console_hook_install(void) * * @return 0 if successful, otherwise failed. */ -static int uart_console_init(struct device *arg) +static int uart_console_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/drivers/console/uart_mcumgr.c b/drivers/console/uart_mcumgr.c index 8a1fca58af46e1..245eb7d5e7bf6e 100644 --- a/drivers/console/uart_mcumgr.c +++ b/drivers/console/uart_mcumgr.c @@ -16,7 +16,7 @@ #include #include -static struct device *uart_mcumgr_dev; +static const struct device *uart_mcumgr_dev; /** Callback to execute when a valid fragment has been received. */ static uart_mcumgr_recv_fn *uart_mgumgr_recv_cb; @@ -115,7 +115,7 @@ static struct uart_mcumgr_rx_buf *uart_mcumgr_rx_byte(uint8_t byte) /** * ISR that is called when UART bytes are received. */ -static void uart_mcumgr_isr(struct device *unused, void *user_data) +static void uart_mcumgr_isr(const struct device *unused, void *user_data) { struct uart_mcumgr_rx_buf *rx_buf; uint8_t buf[32]; @@ -162,7 +162,7 @@ int uart_mcumgr_send(const uint8_t *data, int len) return mcumgr_serial_tx_pkt(data, len, uart_mcumgr_send_raw, NULL); } -static void uart_mcumgr_setup(struct device *uart) +static void uart_mcumgr_setup(const struct device *uart) { uint8_t c; diff --git a/drivers/console/uart_mux.c b/drivers/console/uart_mux.c index 0769e600d23350..091d24089e5b0c 100644 --- a/drivers/console/uart_mux.c +++ b/drivers/console/uart_mux.c @@ -42,7 +42,7 @@ static struct k_work_q uart_mux_workq; */ struct uart_mux { /* The real UART device that is shared between muxed UARTs */ - struct device *uart; + const struct device *uart; /* GSM mux related to this UART */ struct gsm_mux *mux; @@ -97,7 +97,7 @@ struct uart_mux_dev_data { struct uart_mux_config cfg; /* This UART mux device */ - struct device *dev; + const struct device *dev; /* The UART device where we are running on top of */ struct uart_mux *real_uart; @@ -228,7 +228,7 @@ static void uart_mux_tx_work(struct k_work *work) ring_buf_get_finish(dev_data->tx_ringbuf, len); } -static int uart_mux_init(struct device *dev) +static int uart_mux_init(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -253,7 +253,7 @@ static int uart_mux_init(struct device *dev) * data from it in uart_mux_rx_work(), we push the data to GSM mux API which * will call proper callbacks to pass data to correct recipient. */ -static void uart_mux_isr(struct device *uart, void *user_data) +static void uart_mux_isr(const struct device *uart, void *user_data) { struct uart_mux *real_uart = user_data; int rx = 0; @@ -279,7 +279,7 @@ static void uart_mux_isr(struct device *uart, void *user_data) } } -static void uart_mux_flush_isr(struct device *dev) +static void uart_mux_flush_isr(const struct device *dev) { uint8_t c; @@ -311,7 +311,7 @@ static void dlci_created_cb(struct gsm_dlci *dlci, bool connected, } } -static int init_real_uart(struct device *mux, struct device *uart, +static int init_real_uart(const struct device *mux, const struct device *uart, struct uart_mux **mux_uart) { bool found = false; @@ -374,7 +374,7 @@ static int init_real_uart(struct device *mux, struct device *uart, } /* This will bind the physical (real) UART to this muxed UART */ -static int attach(struct device *mux_uart, struct device *uart, +static int attach(const struct device *mux_uart, const struct device *uart, int dlci_address, uart_mux_attach_cb_t cb, void *user_data) { @@ -427,7 +427,7 @@ static int attach(struct device *mux_uart, struct device *uart, return -ENOENT; } -static int uart_mux_poll_in(struct device *dev, unsigned char *p_char) +static int uart_mux_poll_in(const struct device *dev, unsigned char *p_char) { ARG_UNUSED(dev); ARG_UNUSED(p_char); @@ -435,7 +435,8 @@ static int uart_mux_poll_in(struct device *dev, unsigned char *p_char) return -ENOTSUP; } -static void uart_mux_poll_out(struct device *dev, unsigned char out_char) +static void uart_mux_poll_out(const struct device *dev, + unsigned char out_char) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -446,14 +447,14 @@ static void uart_mux_poll_out(struct device *dev, unsigned char out_char) (void)gsm_dlci_send(dev_data->dlci, &out_char, 1); } -static int uart_mux_err_check(struct device *dev) +static int uart_mux_err_check(const struct device *dev) { ARG_UNUSED(dev); return -ENOTSUP; } -static int uart_mux_configure(struct device *dev, +static int uart_mux_configure(const struct device *dev, const struct uart_config *cfg) { ARG_UNUSED(dev); @@ -462,7 +463,8 @@ static int uart_mux_configure(struct device *dev, return -ENOTSUP; } -static int uart_mux_config_get(struct device *dev, struct uart_config *cfg) +static int uart_mux_config_get(const struct device *dev, + struct uart_config *cfg) { ARG_UNUSED(dev); ARG_UNUSED(cfg); @@ -470,7 +472,8 @@ static int uart_mux_config_get(struct device *dev, struct uart_config *cfg) return -ENOTSUP; } -static int uart_mux_fifo_fill(struct device *dev, const uint8_t *tx_data, int len) +static int uart_mux_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { struct uart_mux_dev_data *dev_data; size_t wrote; @@ -504,7 +507,8 @@ static int uart_mux_fifo_fill(struct device *dev, const uint8_t *tx_data, int le return wrote; } -static int uart_mux_fifo_read(struct device *dev, uint8_t *rx_data, const int size) +static int uart_mux_fifo_read(const struct device *dev, uint8_t *rx_data, + const int size) { struct uart_mux_dev_data *dev_data; uint32_t len; @@ -531,7 +535,7 @@ static int uart_mux_fifo_read(struct device *dev, uint8_t *rx_data, const int si return len; } -static void uart_mux_irq_tx_enable(struct device *dev) +static void uart_mux_irq_tx_enable(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -546,7 +550,7 @@ static void uart_mux_irq_tx_enable(struct device *dev) } } -static void uart_mux_irq_tx_disable(struct device *dev) +static void uart_mux_irq_tx_disable(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -557,7 +561,7 @@ static void uart_mux_irq_tx_disable(struct device *dev) dev_data->tx_enabled = false; } -static int uart_mux_irq_tx_ready(struct device *dev) +static int uart_mux_irq_tx_ready(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -572,7 +576,7 @@ static int uart_mux_irq_tx_ready(struct device *dev) return dev_data->tx_ready; } -static void uart_mux_irq_rx_enable(struct device *dev) +static void uart_mux_irq_rx_enable(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -587,7 +591,7 @@ static void uart_mux_irq_rx_enable(struct device *dev) } } -static void uart_mux_irq_rx_disable(struct device *dev) +static void uart_mux_irq_rx_disable(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -598,14 +602,14 @@ static void uart_mux_irq_rx_disable(struct device *dev) dev_data->rx_enabled = false; } -static int uart_mux_irq_tx_complete(struct device *dev) +static int uart_mux_irq_tx_complete(const struct device *dev) { ARG_UNUSED(dev); return -ENOTSUP; } -static int uart_mux_irq_rx_ready(struct device *dev) +static int uart_mux_irq_rx_ready(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -620,17 +624,17 @@ static int uart_mux_irq_rx_ready(struct device *dev) return dev_data->rx_ready; } -static void uart_mux_irq_err_enable(struct device *dev) +static void uart_mux_irq_err_enable(const struct device *dev) { ARG_UNUSED(dev); } -static void uart_mux_irq_err_disable(struct device *dev) +static void uart_mux_irq_err_disable(const struct device *dev) { ARG_UNUSED(dev); } -static int uart_mux_irq_is_pending(struct device *dev) +static int uart_mux_irq_is_pending(const struct device *dev) { struct uart_mux_dev_data *dev_data = DEV_DATA(dev); @@ -649,14 +653,14 @@ static int uart_mux_irq_is_pending(struct device *dev) return 0; } -static int uart_mux_irq_update(struct device *dev) +static int uart_mux_irq_update(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void uart_mux_irq_callback_set(struct device *dev, +static void uart_mux_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data) { @@ -694,7 +698,7 @@ static struct uart_mux_driver_api uart_mux_driver_api = { .attach = attach, }; -struct device *uart_mux_alloc(void) +const struct device *uart_mux_alloc(void) { sys_snode_t *sn, *sns; @@ -715,14 +719,14 @@ struct device *uart_mux_alloc(void) } #ifdef CONFIG_USERSPACE -static inline struct device *z_vrfy_uart_mux_find(int dlci_address) +static inline const struct device *z_vrfy_uart_mux_find(int dlci_address) { return z_impl_uart_mux_find(dlci_address); } #include #endif /* CONFIG_USERSPACE */ -struct device *z_impl_uart_mux_find(int dlci_address) +const struct device *z_impl_uart_mux_find(int dlci_address) { sys_snode_t *sn, *sns; @@ -746,7 +750,7 @@ struct device *z_impl_uart_mux_find(int dlci_address) return NULL; } -int uart_mux_send(struct device *uart, const uint8_t *buf, size_t size) +int uart_mux_send(const struct device *uart, const uint8_t *buf, size_t size) { struct uart_mux_dev_data *dev_data = DEV_DATA(uart); @@ -777,7 +781,8 @@ int uart_mux_send(struct device *uart, const uint8_t *buf, size_t size) return 0; } -int uart_mux_recv(struct device *mux, struct gsm_dlci *dlci, uint8_t *data, +int uart_mux_recv(const struct device *mux, struct gsm_dlci *dlci, + uint8_t *data, size_t len) { struct uart_mux_dev_data *dev_data = DEV_DATA(mux); @@ -853,7 +858,7 @@ UTIL_LISTIFY(CONFIG_UART_MUX_DEVICE_COUNT, DEFINE_UART_MUX_CFG_DATA, _) UTIL_LISTIFY(CONFIG_UART_MUX_DEVICE_COUNT, DEFINE_UART_MUX_DEV_DATA, _) UTIL_LISTIFY(CONFIG_UART_MUX_DEVICE_COUNT, DEFINE_UART_MUX_DEVICE, _) -static int init_uart_mux(struct device *device) +static int init_uart_mux(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/console/uart_mux_internal.h b/drivers/console/uart_mux_internal.h index a1e7ceaa5e7ea3..4f0b507988b5db 100644 --- a/drivers/console/uart_mux_internal.h +++ b/drivers/console/uart_mux_internal.h @@ -20,7 +20,7 @@ extern "C" { * * @return 0 if data was sent, <0 if error */ -int uart_mux_send(struct device *uart, const uint8_t *buf, size_t size); +int uart_mux_send(const struct device *uart, const uint8_t *buf, size_t size); /** * @brief Receive unmuxed data. @@ -33,7 +33,7 @@ int uart_mux_send(struct device *uart, const uint8_t *buf, size_t size); * @retval >=0 No errors, number of bytes received * @retval <0 Error */ -int uart_mux_recv(struct device *mux, struct gsm_dlci *dlci, +int uart_mux_recv(const struct device *mux, struct gsm_dlci *dlci, uint8_t *data, size_t len); #ifdef __cplusplus diff --git a/drivers/console/uart_pipe.c b/drivers/console/uart_pipe.c index 61469aace3a4d6..5c1dfd4d02fc29 100644 --- a/drivers/console/uart_pipe.c +++ b/drivers/console/uart_pipe.c @@ -21,14 +21,14 @@ LOG_MODULE_REGISTER(uart_pipe, CONFIG_UART_CONSOLE_LOG_LEVEL); #include #include -static struct device *uart_pipe_dev; +static const struct device *uart_pipe_dev; static uint8_t *recv_buf; static size_t recv_buf_len; static uart_pipe_recv_cb app_cb; static size_t recv_off; -static void uart_pipe_rx(struct device *dev) +static void uart_pipe_rx(const struct device *dev) { /* As per the API, the interrupt may be an edge so keep * reading from the FIFO until it's empty. @@ -53,7 +53,7 @@ static void uart_pipe_rx(struct device *dev) } } -static void uart_pipe_isr(struct device *dev, void *user_data) +static void uart_pipe_isr(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); @@ -77,7 +77,7 @@ int uart_pipe_send(const uint8_t *data, int len) return 0; } -static void uart_pipe_setup(struct device *uart) +static void uart_pipe_setup(const struct device *uart) { uint8_t c; diff --git a/drivers/console/xtensa_sim_console.c b/drivers/console/xtensa_sim_console.c index beb33670ff1d46..0d4b8e357f74eb 100644 --- a/drivers/console/xtensa_sim_console.c +++ b/drivers/console/xtensa_sim_console.c @@ -63,7 +63,7 @@ static void xt_sim_console_hook_install(void) * @brief Initialize the console/debug port * @return 0 if successful, otherwise failed. */ -static int xt_sim_console_init(struct device *arg) +static int xt_sim_console_init(const struct device *arg) { ARG_UNUSED(arg); xt_sim_console_hook_install(); diff --git a/drivers/counter/counter_cmos.c b/drivers/counter/counter_cmos.c index 9ed3c208dabb8e..35cde315f684b6 100644 --- a/drivers/counter/counter_cmos.c +++ b/drivers/counter/counter_cmos.c @@ -128,7 +128,7 @@ static uint32_t hinnant(int y, int m, int d) * This function is long, but linear and easy to follow. */ -int get_value(struct device *dev, uint32_t *ticks) +int get_value(const struct device *dev, uint32_t *ticks) { struct state state, state2; uint64_t *pun = (uint64_t *) &state; @@ -192,7 +192,7 @@ int get_value(struct device *dev, uint32_t *ticks) return 0; } -static int init(struct device *dev) +static int init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/counter/counter_gecko_rtcc.c b/drivers/counter/counter_gecko_rtcc.c index 0b919f594f589e..46c5da47e1af75 100644 --- a/drivers/counter/counter_gecko_rtcc.c +++ b/drivers/counter/counter_gecko_rtcc.c @@ -67,7 +67,7 @@ static uint8_t chan_id2cc_idx(uint8_t chan_id) return cc_idx; } -static int counter_gecko_start(struct device *dev) +static int counter_gecko_start(const struct device *dev) { ARG_UNUSED(dev); @@ -76,7 +76,7 @@ static int counter_gecko_start(struct device *dev) return 0; } -static int counter_gecko_stop(struct device *dev) +static int counter_gecko_stop(const struct device *dev) { ARG_UNUSED(dev); @@ -85,7 +85,7 @@ static int counter_gecko_stop(struct device *dev) return 0; } -static int counter_gecko_get_value(struct device *dev, uint32_t *ticks) +static int counter_gecko_get_value(const struct device *dev, uint32_t *ticks) { ARG_UNUSED(dev); @@ -93,7 +93,7 @@ static int counter_gecko_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int counter_gecko_set_top_value(struct device *dev, +static int counter_gecko_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { struct counter_gecko_data *const dev_data = DEV_DATA(dev); @@ -146,21 +146,21 @@ static int counter_gecko_set_top_value(struct device *dev, return err; } -static uint32_t counter_gecko_get_top_value(struct device *dev) +static uint32_t counter_gecko_get_top_value(const struct device *dev) { ARG_UNUSED(dev); return RTCC_ChannelCCVGet(1); } -static uint32_t counter_gecko_get_max_relative_alarm(struct device *dev) +static uint32_t counter_gecko_get_max_relative_alarm(const struct device *dev) { ARG_UNUSED(dev); return RTCC_ChannelCCVGet(1); } -static int counter_gecko_set_alarm(struct device *dev, uint8_t chan_id, +static int counter_gecko_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { uint32_t count = RTCC_CounterGet(); @@ -204,7 +204,8 @@ static int counter_gecko_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int counter_gecko_cancel_alarm(struct device *dev, uint8_t chan_id) +static int counter_gecko_cancel_alarm(const struct device *dev, + uint8_t chan_id) { struct counter_gecko_data *const dev_data = DEV_DATA(dev); @@ -224,14 +225,14 @@ static int counter_gecko_cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static uint32_t counter_gecko_get_pending_int(struct device *dev) +static uint32_t counter_gecko_get_pending_int(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int counter_gecko_init(struct device *dev) +static int counter_gecko_init(const struct device *dev) { const struct counter_gecko_config *const dev_cfg = DEV_CFG(dev); @@ -335,7 +336,7 @@ DEVICE_DECLARE(counter_gecko_0); ISR_DIRECT_DECLARE(counter_gecko_isr_0) { - struct device *const dev = DEVICE_GET(counter_gecko_0); + const struct device *dev = DEVICE_GET(counter_gecko_0); struct counter_gecko_data *const dev_data = DEV_DATA(dev); counter_alarm_callback_t alarm_callback; uint32_t count = RTCC_CounterGet(); diff --git a/drivers/counter/counter_handlers.c b/drivers/counter/counter_handlers.c index 0a78a54764116c..2c15838e5e41ff 100644 --- a/drivers/counter/counter_handlers.c +++ b/drivers/counter/counter_handlers.c @@ -11,10 +11,10 @@ * instance and return an integral value */ #define COUNTER_HANDLER(name) \ - static inline int z_vrfy_counter_##name(struct device *dev) \ + static inline int z_vrfy_counter_##name(const struct device *dev) \ { \ Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, name)); \ - return z_impl_counter_ ## name((struct device *)dev); \ + return z_impl_counter_ ## name((const struct device *)dev); \ } COUNTER_HANDLER(get_pending_int) @@ -64,17 +64,18 @@ static inline uint64_t z_vrfy_counter_ticks_to_us(const struct device *dev, } #include -static inline int z_vrfy_counter_get_value(struct device *dev, +static inline int z_vrfy_counter_get_value(const struct device *dev, uint32_t *ticks) { Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, get_value)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(ticks, sizeof(*ticks))); - return z_impl_counter_get_value((struct device *)dev, ticks); + return z_impl_counter_get_value((const struct device *)dev, ticks); } #include -static inline int z_vrfy_counter_set_channel_alarm(struct device *dev, - uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) +static inline int z_vrfy_counter_set_channel_alarm(const struct device *dev, + uint8_t chan_id, + const struct counter_alarm_cfg *alarm_cfg) { struct counter_alarm_cfg cfg_copy; @@ -82,22 +83,23 @@ static inline int z_vrfy_counter_set_channel_alarm(struct device *dev, Z_OOPS(z_user_from_copy(&cfg_copy, alarm_cfg, sizeof(cfg_copy))); Z_OOPS(Z_SYSCALL_VERIFY_MSG(cfg_copy.callback == 0, "callbacks may not be set from user mode")); - return z_impl_counter_set_channel_alarm((struct device *)dev, - (uint8_t)chan_id, (const struct counter_alarm_cfg *)&cfg_copy); + return z_impl_counter_set_channel_alarm((const struct device *)dev, + (uint8_t)chan_id, + (const struct counter_alarm_cfg *)&cfg_copy); } #include -static inline int z_vrfy_counter_cancel_channel_alarm(struct device *dev, +static inline int z_vrfy_counter_cancel_channel_alarm(const struct device *dev, uint8_t chan_id) { Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, cancel_alarm)); - return z_vrfy_counter_cancel_channel_alarm((struct device *)dev, + return z_vrfy_counter_cancel_channel_alarm((const struct device *)dev, (uint8_t)chan_id); } #include -static inline int z_vrfy_counter_set_top_value(struct device *dev, +static inline int z_vrfy_counter_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { @@ -107,46 +109,48 @@ static inline int z_vrfy_counter_set_top_value(struct device *dev, Z_OOPS(z_user_from_copy(&cfg_copy, cfg, sizeof(cfg_copy))); Z_OOPS(Z_SYSCALL_VERIFY_MSG(cfg_copy.callback == 0, "callbacks may not be set from user mode")); - return z_impl_counter_set_top_value((struct device *)dev, + return z_impl_counter_set_top_value((const struct device *)dev, (const struct counter_top_cfg *) &cfg_copy); } #include -static inline uint32_t z_vrfy_counter_get_top_value(struct device *dev) +static inline uint32_t z_vrfy_counter_get_top_value(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, get_top_value)); - return z_impl_counter_get_top_value((struct device *)dev); + return z_impl_counter_get_top_value((const struct device *)dev); } #include static inline uint32_t z_vrfy_counter_get_max_top_value(const struct device *dev) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_COUNTER)); - return z_impl_counter_get_max_top_value((struct device *)dev); + return z_impl_counter_get_max_top_value((const struct device *)dev); } #include -static inline uint32_t z_vrfy_counter_get_max_relative_alarm(struct device *dev) +static inline uint32_t z_vrfy_counter_get_max_relative_alarm(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, get_max_relative_alarm)); - return z_impl_counter_get_max_relative_alarm((struct device *)dev); + return z_impl_counter_get_max_relative_alarm((const struct device *)dev); } #include -static inline uint32_t z_vrfy_counter_get_guard_period(struct device *dev, +static inline uint32_t z_vrfy_counter_get_guard_period(const struct device *dev, uint32_t flags) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_COUNTER)); - return z_impl_counter_get_guard_period((struct device *)dev, flags); + return z_impl_counter_get_guard_period((const struct device *)dev, + flags); } #include -static inline int z_vrfy_counter_set_guard_period(struct device *dev, +static inline int z_vrfy_counter_set_guard_period(const struct device *dev, uint32_t ticks, uint32_t flags) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_COUNTER)); - return z_impl_counter_set_guard_period((struct device *)dev, ticks, + return z_impl_counter_set_guard_period((const struct device *)dev, + ticks, flags); } #include diff --git a/drivers/counter/counter_imx_epit.c b/drivers/counter/counter_imx_epit.c index a1a3e9e14e88c3..b2bfc2b9e44499 100644 --- a/drivers/counter/counter_imx_epit.c +++ b/drivers/counter/counter_imx_epit.c @@ -23,7 +23,7 @@ struct imx_epit_data { volatile void *user_data; }; -static inline const struct imx_epit_config *get_epit_config(struct device *dev) +static inline const struct imx_epit_config *get_epit_config(const struct device *dev) { return CONTAINER_OF(dev->config, struct imx_epit_config, info); @@ -31,7 +31,7 @@ static inline const struct imx_epit_config *get_epit_config(struct device *dev) static void imx_epit_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; EPIT_Type *base = get_epit_config(dev)->base; struct imx_epit_data *driver_data = dev->data; @@ -42,7 +42,7 @@ static void imx_epit_isr(void *arg) } } -static void imx_epit_init(struct device *dev) +static void imx_epit_init(const struct device *dev) { struct imx_epit_config *config = (struct imx_epit_config *) get_epit_config(dev); @@ -61,7 +61,7 @@ static void imx_epit_init(struct device *dev) EPIT_Init(base, &epit_config); } -static int imx_epit_start(struct device *dev) +static int imx_epit_start(const struct device *dev) { EPIT_Type *base = get_epit_config(dev)->base; @@ -77,7 +77,7 @@ static int imx_epit_start(struct device *dev) return 0; } -static int imx_epit_stop(struct device *dev) +static int imx_epit_stop(const struct device *dev) { EPIT_Type *base = get_epit_config(dev)->base; @@ -87,7 +87,7 @@ static int imx_epit_stop(struct device *dev) return 0; } -static int imx_epit_get_value(struct device *dev, uint32_t *ticks) +static int imx_epit_get_value(const struct device *dev, uint32_t *ticks) { EPIT_Type *base = get_epit_config(dev)->base; @@ -96,7 +96,7 @@ static int imx_epit_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int imx_epit_set_top_value(struct device *dev, +static int imx_epit_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { EPIT_Type *base = get_epit_config(dev)->base; @@ -121,21 +121,21 @@ static int imx_epit_set_top_value(struct device *dev, return 0; } -static uint32_t imx_epit_get_pending_int(struct device *dev) +static uint32_t imx_epit_get_pending_int(const struct device *dev) { EPIT_Type *base = get_epit_config(dev)->base; return EPIT_GetStatusFlag(base) ? 1U : 0U; } -static uint32_t imx_epit_get_top_value(struct device *dev) +static uint32_t imx_epit_get_top_value(const struct device *dev) { EPIT_Type *base = get_epit_config(dev)->base; return EPIT_GetCounterLoadValue(base); } -static uint32_t imx_epit_get_max_relative_alarm(struct device *dev) +static uint32_t imx_epit_get_max_relative_alarm(const struct device *dev) { return COUNTER_MAX_RELOAD; } diff --git a/drivers/counter/counter_ll_stm32_rtc.c b/drivers/counter/counter_ll_stm32_rtc.c index d56fae22691d89..97c55ea3d3c6e4 100644 --- a/drivers/counter/counter_ll_stm32_rtc.c +++ b/drivers/counter/counter_ll_stm32_rtc.c @@ -61,10 +61,10 @@ struct rtc_stm32_data { ((const struct rtc_stm32_config * const)(dev)->config) -static void rtc_stm32_irq_config(struct device *dev); +static void rtc_stm32_irq_config(const struct device *dev); -static int rtc_stm32_start(struct device *dev) +static int rtc_stm32_start(const struct device *dev) { ARG_UNUSED(dev); @@ -76,7 +76,7 @@ static int rtc_stm32_start(struct device *dev) } -static int rtc_stm32_stop(struct device *dev) +static int rtc_stm32_stop(const struct device *dev) { ARG_UNUSED(dev); @@ -88,7 +88,7 @@ static int rtc_stm32_stop(struct device *dev) } -static uint32_t rtc_stm32_read(struct device *dev) +static uint32_t rtc_stm32_read(const struct device *dev) { struct tm now = { 0 }; time_t ts; @@ -124,13 +124,13 @@ static uint32_t rtc_stm32_read(struct device *dev) return ticks; } -static int rtc_stm32_get_value(struct device *dev, uint32_t *ticks) +static int rtc_stm32_get_value(const struct device *dev, uint32_t *ticks) { *ticks = rtc_stm32_read(dev); return 0; } -static int rtc_stm32_set_alarm(struct device *dev, uint8_t chan_id, +static int rtc_stm32_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { struct tm alarm_tm; @@ -193,7 +193,7 @@ static int rtc_stm32_set_alarm(struct device *dev, uint8_t chan_id, } -static int rtc_stm32_cancel_alarm(struct device *dev, uint8_t chan_id) +static int rtc_stm32_cancel_alarm(const struct device *dev, uint8_t chan_id) { LL_RTC_DisableWriteProtection(RTC); LL_RTC_ClearFlag_ALRA(RTC); @@ -207,13 +207,13 @@ static int rtc_stm32_cancel_alarm(struct device *dev, uint8_t chan_id) } -static uint32_t rtc_stm32_get_pending_int(struct device *dev) +static uint32_t rtc_stm32_get_pending_int(const struct device *dev) { return LL_RTC_IsActiveFlag_ALRA(RTC) != 0; } -static uint32_t rtc_stm32_get_top_value(struct device *dev) +static uint32_t rtc_stm32_get_top_value(const struct device *dev) { const struct counter_config_info *info = dev->config; @@ -221,7 +221,7 @@ static uint32_t rtc_stm32_get_top_value(struct device *dev) } -static int rtc_stm32_set_top_value(struct device *dev, +static int rtc_stm32_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { const struct counter_config_info *info = dev->config; @@ -237,7 +237,7 @@ static int rtc_stm32_set_top_value(struct device *dev, } -static uint32_t rtc_stm32_get_max_relative_alarm(struct device *dev) +static uint32_t rtc_stm32_get_max_relative_alarm(const struct device *dev) { const struct counter_config_info *info = dev->config; @@ -247,7 +247,7 @@ static uint32_t rtc_stm32_get_max_relative_alarm(struct device *dev) void rtc_stm32_isr(void *arg) { - struct device *const dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct rtc_stm32_data *data = DEV_DATA(dev); counter_alarm_callback_t alarm_callback = data->callback; @@ -275,9 +275,9 @@ void rtc_stm32_isr(void *arg) } -static int rtc_stm32_init(struct device *dev) +static int rtc_stm32_init(const struct device *dev) { - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); const struct rtc_stm32_config *cfg = DEV_CFG(dev); __ASSERT_NO_MSG(clk); @@ -413,7 +413,7 @@ DEVICE_AND_API_INIT(rtc_stm32, DT_INST_LABEL(0), &rtc_stm32_init, &rtc_data, &rtc_config, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &rtc_stm32_driver_api); -static void rtc_stm32_irq_config(struct device *dev) +static void rtc_stm32_irq_config(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/counter/counter_mchp_xec.c b/drivers/counter/counter_mchp_xec.c index caa381616df930..c0174ad4cb27f6 100644 --- a/drivers/counter/counter_mchp_xec.c +++ b/drivers/counter/counter_mchp_xec.c @@ -57,7 +57,7 @@ struct counter_xec_data { #define COUNTER_XEC_DATA(_dev) \ ((struct counter_xec_data *)dev->data) -static int counter_xec_start(struct device *dev) +static int counter_xec_start(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); @@ -72,7 +72,7 @@ static int counter_xec_start(struct device *dev) return 0; } -static int counter_xec_stop(struct device *dev) +static int counter_xec_stop(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); uint32_t reg; @@ -98,7 +98,7 @@ static int counter_xec_stop(struct device *dev) return 0; } -static int counter_xec_get_value(struct device *dev, uint32_t *ticks) +static int counter_xec_get_value(const struct device *dev, uint32_t *ticks) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); @@ -106,7 +106,7 @@ static int counter_xec_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int counter_xec_set_alarm(struct device *dev, uint8_t chan_id, +static int counter_xec_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); @@ -151,7 +151,7 @@ static int counter_xec_set_alarm(struct device *dev, uint8_t chan_id, } -static int counter_xec_cancel_alarm(struct device *dev, uint8_t chan_id) +static int counter_xec_cancel_alarm(const struct device *dev, uint8_t chan_id) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); struct counter_xec_data *data = COUNTER_XEC_DATA(dev); @@ -172,21 +172,21 @@ static int counter_xec_cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static uint32_t counter_xec_get_pending_int(struct device *dev) +static uint32_t counter_xec_get_pending_int(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); return counter->STS; } -static uint32_t counter_xec_get_top_value(struct device *dev) +static uint32_t counter_xec_get_top_value(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); return counter->PRLD; } -static int counter_xec_set_top_value(struct device *dev, +static int counter_xec_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); @@ -241,14 +241,14 @@ static int counter_xec_set_top_value(struct device *dev, return ret; } -static uint32_t counter_xec_get_max_relative_alarm(struct device *dev) +static uint32_t counter_xec_get_max_relative_alarm(const struct device *dev) { const struct counter_xec_config *counter_cfg = COUNTER_XEC_CONFIG(dev); return counter_cfg->info.max_top_value; } -static void counter_xec_isr(struct device *dev) +static void counter_xec_isr(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); const struct counter_xec_config *counter_cfg = COUNTER_XEC_CONFIG(dev); @@ -287,7 +287,7 @@ static const struct counter_driver_api counter_xec_api = { .get_max_relative_alarm = counter_xec_get_max_relative_alarm, }; -static int counter_xec_init(struct device *dev) +static int counter_xec_init(const struct device *dev) { BTMR_Type *counter = COUNTER_XEC_REG_BASE(dev); const struct counter_xec_config *counter_cfg = COUNTER_XEC_CONFIG(dev); diff --git a/drivers/counter/counter_mcux_gpt.c b/drivers/counter/counter_mcux_gpt.c index d05240cf8e831c..efb9ff3739d700 100644 --- a/drivers/counter/counter_mcux_gpt.c +++ b/drivers/counter/counter_mcux_gpt.c @@ -26,7 +26,7 @@ struct mcux_gpt_data { void *top_user_data; }; -static int mcux_gpt_start(struct device *dev) +static int mcux_gpt_start(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; @@ -35,7 +35,7 @@ static int mcux_gpt_start(struct device *dev) return 0; } -static int mcux_gpt_stop(struct device *dev) +static int mcux_gpt_stop(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; @@ -44,7 +44,7 @@ static int mcux_gpt_stop(struct device *dev) return 0; } -static int mcux_gpt_get_value(struct device *dev, uint32_t *ticks) +static int mcux_gpt_get_value(const struct device *dev, uint32_t *ticks) { const struct mcux_gpt_config *config = dev->config; @@ -52,7 +52,7 @@ static int mcux_gpt_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int mcux_gpt_set_alarm(struct device *dev, uint8_t chan_id, +static int mcux_gpt_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { const struct mcux_gpt_config *config = dev->config; @@ -84,7 +84,7 @@ static int mcux_gpt_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int mcux_gpt_cancel_alarm(struct device *dev, uint8_t chan_id) +static int mcux_gpt_cancel_alarm(const struct device *dev, uint8_t chan_id) { const struct mcux_gpt_config *config = dev->config; struct mcux_gpt_data *data = dev->data; @@ -102,7 +102,7 @@ static int mcux_gpt_cancel_alarm(struct device *dev, uint8_t chan_id) void mcux_gpt_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; const struct mcux_gpt_config *config = dev->config; struct mcux_gpt_data *data = dev->data; uint32_t current = GPT_GetCurrentTimerCount(config->base); @@ -126,14 +126,14 @@ void mcux_gpt_isr(void *p) } } -static uint32_t mcux_gpt_get_pending_int(struct device *dev) +static uint32_t mcux_gpt_get_pending_int(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; return GPT_GetStatusFlags(config->base, kGPT_OutputCompare1Flag); } -static int mcux_gpt_set_top_value(struct device *dev, +static int mcux_gpt_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { const struct mcux_gpt_config *config = dev->config; @@ -153,21 +153,21 @@ static int mcux_gpt_set_top_value(struct device *dev, return 0; } -static uint32_t mcux_gpt_get_top_value(struct device *dev) +static uint32_t mcux_gpt_get_top_value(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; return config->info.max_top_value; } -static uint32_t mcux_gpt_get_max_relative_alarm(struct device *dev) +static uint32_t mcux_gpt_get_max_relative_alarm(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; return config->info.max_top_value; } -static int mcux_gpt_init(struct device *dev) +static int mcux_gpt_init(const struct device *dev) { const struct mcux_gpt_config *config = dev->config; gpt_config_t gptConfig; diff --git a/drivers/counter/counter_mcux_lptmr.c b/drivers/counter/counter_mcux_lptmr.c index d4c86b1430472f..0c7ca5db7d16c4 100644 --- a/drivers/counter/counter_mcux_lptmr.c +++ b/drivers/counter/counter_mcux_lptmr.c @@ -18,7 +18,7 @@ struct mcux_lptmr_config { lptmr_timer_mode_t mode; lptmr_pin_select_t pin; lptmr_pin_polarity_t polarity; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_lptmr_data { @@ -26,7 +26,7 @@ struct mcux_lptmr_data { void *top_user_data; }; -static int mcux_lptmr_start(struct device *dev) +static int mcux_lptmr_start(const struct device *dev) { const struct mcux_lptmr_config *config = dev->config; @@ -37,7 +37,7 @@ static int mcux_lptmr_start(struct device *dev) return 0; } -static int mcux_lptmr_stop(struct device *dev) +static int mcux_lptmr_stop(const struct device *dev) { const struct mcux_lptmr_config *config = dev->config; @@ -48,7 +48,7 @@ static int mcux_lptmr_stop(struct device *dev) return 0; } -static int mcux_lptmr_get_value(struct device *dev, uint32_t *ticks) +static int mcux_lptmr_get_value(const struct device *dev, uint32_t *ticks) { const struct mcux_lptmr_config *config = dev->config; @@ -57,8 +57,8 @@ static int mcux_lptmr_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int mcux_lptmr_set_top_value(struct device *dev, - const struct counter_top_cfg *cfg) +static int mcux_lptmr_set_top_value(const struct device *dev, + const struct counter_top_cfg *cfg) { const struct mcux_lptmr_config *config = dev->config; struct mcux_lptmr_data *data = dev->data; @@ -85,7 +85,7 @@ static int mcux_lptmr_set_top_value(struct device *dev, return 0; } -static uint32_t mcux_lptmr_get_pending_int(struct device *dev) +static uint32_t mcux_lptmr_get_pending_int(const struct device *dev) { const struct mcux_lptmr_config *config = dev->config; uint32_t mask = LPTMR_CSR_TCF_MASK | LPTMR_CSR_TIE_MASK; @@ -96,14 +96,14 @@ static uint32_t mcux_lptmr_get_pending_int(struct device *dev) return ((flags & mask) == mask); } -static uint32_t mcux_lptmr_get_top_value(struct device *dev) +static uint32_t mcux_lptmr_get_top_value(const struct device *dev) { const struct mcux_lptmr_config *config = dev->config; return (config->base->CMR & LPTMR_CMR_COMPARE_MASK) + 1U; } -static uint32_t mcux_lptmr_get_max_relative_alarm(struct device *dev) +static uint32_t mcux_lptmr_get_max_relative_alarm(const struct device *dev) { ARG_UNUSED(dev); @@ -113,7 +113,7 @@ static uint32_t mcux_lptmr_get_max_relative_alarm(struct device *dev) static void mcux_lptmr_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct mcux_lptmr_config *config = dev->config; struct mcux_lptmr_data *data = dev->data; uint32_t flags; @@ -126,7 +126,7 @@ static void mcux_lptmr_isr(void *arg) } } -static int mcux_lptmr_init(struct device *dev) +static int mcux_lptmr_init(const struct device *dev) { const struct mcux_lptmr_config *config = dev->config; lptmr_config_t lptmr_config; @@ -210,7 +210,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, #if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) static struct mcux_lptmr_data mcux_lptmr_data_0; -static void mcux_lptmr_irq_config_0(struct device *dev); +static void mcux_lptmr_irq_config_0(const struct device *dev); static struct mcux_lptmr_config mcux_lptmr_config_0 = { .info = { @@ -248,7 +248,7 @@ DEVICE_AND_API_INIT(mcux_lptmr_0, DT_INST_LABEL(0), POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_lptmr_driver_api); -static void mcux_lptmr_irq_config_0(struct device *dev) +static void mcux_lptmr_irq_config_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), mcux_lptmr_isr, DEVICE_GET(mcux_lptmr_0), 0); diff --git a/drivers/counter/counter_mcux_pit.c b/drivers/counter/counter_mcux_pit.c index 290fa797ebfd7f..9d002ff3a26f7e 100644 --- a/drivers/counter/counter_mcux_pit.c +++ b/drivers/counter/counter_mcux_pit.c @@ -18,7 +18,7 @@ struct mcux_pit_config { PIT_Type *base; bool enableRunInDebug; pit_chnl_t pit_channel; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_pit_data { @@ -28,7 +28,7 @@ struct mcux_pit_data { void *top_user_data; }; -static uint32_t mcux_pit_get_top_value(struct device *dev) +static uint32_t mcux_pit_get_top_value(const struct device *dev) { const struct mcux_pit_config *config = dev->config; pit_chnl_t channel = config->pit_channel; @@ -36,7 +36,7 @@ static uint32_t mcux_pit_get_top_value(struct device *dev) return config->base->CHANNEL[channel].LDVAL; } -static int mcux_pit_start(struct device *dev) +static int mcux_pit_start(const struct device *dev) { const struct mcux_pit_config *config = dev->config; @@ -47,7 +47,7 @@ static int mcux_pit_start(struct device *dev) return 0; } -static int mcux_pit_stop(struct device *dev) +static int mcux_pit_stop(const struct device *dev) { const struct mcux_pit_config *config = dev->config; @@ -58,7 +58,7 @@ static int mcux_pit_stop(struct device *dev) return 0; } -static int mcux_pit_get_value(struct device *dev, uint32_t *ticks) +static int mcux_pit_get_value(const struct device *dev, uint32_t *ticks) { const struct mcux_pit_config *config = dev->config; @@ -67,7 +67,7 @@ static int mcux_pit_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int mcux_pit_set_top_value(struct device *dev, +static int mcux_pit_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { const struct mcux_pit_config *config = dev->config; @@ -96,7 +96,7 @@ static int mcux_pit_set_top_value(struct device *dev, return 0; } -static uint32_t mcux_pit_get_pending_int(struct device *dev) +static uint32_t mcux_pit_get_pending_int(const struct device *dev) { const struct mcux_pit_config *config = dev->config; uint32_t mask = PIT_TFLG_TIF_MASK; @@ -107,7 +107,7 @@ static uint32_t mcux_pit_get_pending_int(struct device *dev) return ((flags & mask) == mask); } -static uint32_t mcux_pit_get_max_relative_alarm(struct device *dev) +static uint32_t mcux_pit_get_max_relative_alarm(const struct device *dev) { const struct mcux_pit_config *config = dev->config; @@ -116,7 +116,7 @@ static uint32_t mcux_pit_get_max_relative_alarm(struct device *dev) static void mcux_pit_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct mcux_pit_config *config = dev->config; struct mcux_pit_data *data = dev->data; uint32_t flags; @@ -136,7 +136,7 @@ static void mcux_pit_isr(void *arg) } } -static int mcux_pit_set_alarm(struct device *dev, uint8_t chan_id, +static int mcux_pit_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { const struct mcux_pit_config *config = dev->config; @@ -163,7 +163,7 @@ static int mcux_pit_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int mcux_pit_cancel_alarm(struct device *dev, uint8_t chan_id) +static int mcux_pit_cancel_alarm(const struct device *dev, uint8_t chan_id) { const struct mcux_pit_config *config = dev->config; struct mcux_pit_data *data = dev->data; @@ -180,7 +180,7 @@ static int mcux_pit_cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static int mcux_pit_init(struct device *dev) +static int mcux_pit_init(const struct device *dev) { const struct mcux_pit_config *config = (struct mcux_pit_config *)dev->config; @@ -221,7 +221,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, static struct mcux_pit_data mcux_pit_data_0; -static void mcux_pit_irq_config_0(struct device *dev); +static void mcux_pit_irq_config_0(const struct device *dev); static const struct mcux_pit_config mcux_pit_config_0 = { .info = { @@ -238,7 +238,7 @@ DEVICE_AND_API_INIT(mcux_pit_0, DT_INST_LABEL(0), &mcux_pit_init, &mcux_pit_data_0, &mcux_pit_config_0, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_pit_driver_api); -static void mcux_pit_irq_config_0(struct device *dev) +static void mcux_pit_irq_config_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_IDX(0, 0, irq), DT_INST_IRQ_BY_IDX(0, 0, priority), mcux_pit_isr, diff --git a/drivers/counter/counter_mcux_rtc.c b/drivers/counter/counter_mcux_rtc.c index 4692070bdaadf1..f6b035b0d2ef1a 100644 --- a/drivers/counter/counter_mcux_rtc.c +++ b/drivers/counter/counter_mcux_rtc.c @@ -23,10 +23,10 @@ struct mcux_rtc_data { struct mcux_rtc_config { struct counter_config_info info; RTC_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; -static int mcux_rtc_start(struct device *dev) +static int mcux_rtc_start(const struct device *dev) { const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = @@ -41,7 +41,7 @@ static int mcux_rtc_start(struct device *dev) return 0; } -static int mcux_rtc_stop(struct device *dev) +static int mcux_rtc_stop(const struct device *dev) { const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = @@ -59,7 +59,7 @@ static int mcux_rtc_stop(struct device *dev) return 0; } -static uint32_t mcux_rtc_read(struct device *dev) +static uint32_t mcux_rtc_read(const struct device *dev) { const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = @@ -81,13 +81,13 @@ static uint32_t mcux_rtc_read(struct device *dev) return ticks; } -static int mcux_rtc_get_value(struct device *dev, uint32_t *ticks) +static int mcux_rtc_get_value(const struct device *dev, uint32_t *ticks) { *ticks = mcux_rtc_read(dev); return 0; } -static int mcux_rtc_set_alarm(struct device *dev, uint8_t chan_id, +static int mcux_rtc_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { const struct counter_config_info *info = dev->config; @@ -127,7 +127,7 @@ static int mcux_rtc_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int mcux_rtc_cancel_alarm(struct device *dev, uint8_t chan_id) +static int mcux_rtc_cancel_alarm(const struct device *dev, uint8_t chan_id) { struct mcux_rtc_data *data = dev->data; @@ -141,7 +141,7 @@ static int mcux_rtc_cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static int mcux_rtc_set_top_value(struct device *dev, +static int mcux_rtc_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { const struct counter_config_info *info = dev->config; @@ -166,7 +166,7 @@ static int mcux_rtc_set_top_value(struct device *dev, return 0; } -static uint32_t mcux_rtc_get_pending_int(struct device *dev) +static uint32_t mcux_rtc_get_pending_int(const struct device *dev) { const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = @@ -175,14 +175,14 @@ static uint32_t mcux_rtc_get_pending_int(struct device *dev) return RTC_GetStatusFlags(config->base) & RTC_SR_TAF_MASK; } -static uint32_t mcux_rtc_get_top_value(struct device *dev) +static uint32_t mcux_rtc_get_top_value(const struct device *dev) { const struct counter_config_info *info = dev->config; return info->max_top_value; } -static uint32_t mcux_rtc_get_max_relative_alarm(struct device *dev) +static uint32_t mcux_rtc_get_max_relative_alarm(const struct device *dev) { const struct counter_config_info *info = dev->config; @@ -191,7 +191,7 @@ static uint32_t mcux_rtc_get_max_relative_alarm(struct device *dev) static void mcux_rtc_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = CONTAINER_OF(info, struct mcux_rtc_config, info); @@ -231,7 +231,7 @@ static void mcux_rtc_isr(void *arg) RTC_StartTimer(config->base); } -static int mcux_rtc_init(struct device *dev) +static int mcux_rtc_init(const struct device *dev) { const struct counter_config_info *info = dev->config; const struct mcux_rtc_config *config = @@ -264,7 +264,7 @@ static const struct counter_driver_api mcux_rtc_driver_api = { static struct mcux_rtc_data mcux_rtc_data_0; -static void mcux_rtc_irq_config_0(struct device *dev); +static void mcux_rtc_irq_config_0(const struct device *dev); static struct mcux_rtc_config mcux_rtc_config_0 = { .base = (RTC_Type *)DT_INST_REG_ADDR(0), @@ -283,7 +283,7 @@ DEVICE_AND_API_INIT(rtc, DT_INST_LABEL(0), &mcux_rtc_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_rtc_driver_api); -static void mcux_rtc_irq_config_0(struct device *dev) +static void mcux_rtc_irq_config_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/counter/counter_native_posix.c b/drivers/counter/counter_native_posix.c index b22e036e9958fb..9b28b9849836d6 100644 --- a/drivers/counter/counter_native_posix.c +++ b/drivers/counter/counter_native_posix.c @@ -20,7 +20,7 @@ static struct counter_alarm_cfg pending_alarm; static bool is_alarm_pending; -static struct device *device; +static const struct device *device; static void counter_isr(void *arg) { @@ -34,7 +34,7 @@ static void counter_isr(void *arg) } } -static int ctr_init(struct device *dev) +static int ctr_init(const struct device *dev) { device = dev; is_alarm_pending = false; @@ -47,7 +47,7 @@ static int ctr_init(struct device *dev) return 0; } -static int ctr_start(struct device *dev) +static int ctr_start(const struct device *dev) { ARG_UNUSED(dev); @@ -55,7 +55,7 @@ static int ctr_start(struct device *dev) return 0; } -static int ctr_stop(struct device *dev) +static int ctr_stop(const struct device *dev) { ARG_UNUSED(dev); @@ -63,7 +63,7 @@ static int ctr_stop(struct device *dev) return 0; } -static int ctr_get_value(struct device *dev, uint32_t *ticks) +static int ctr_get_value(const struct device *dev, uint32_t *ticks) { ARG_UNUSED(dev); @@ -71,13 +71,13 @@ static int ctr_get_value(struct device *dev, uint32_t *ticks) return 0; } -static uint32_t ctr_get_pending_int(struct device *dev) +static uint32_t ctr_get_pending_int(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int ctr_set_top_value(struct device *dev, +static int ctr_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { ARG_UNUSED(dev); @@ -87,17 +87,17 @@ static int ctr_set_top_value(struct device *dev, return -ENOTSUP; } -static uint32_t ctr_get_top_value(struct device *dev) +static uint32_t ctr_get_top_value(const struct device *dev) { return TOP_VALUE; } -static uint32_t ctr_get_max_relative_alarm(struct device *dev) +static uint32_t ctr_get_max_relative_alarm(const struct device *dev) { return TOP_VALUE; } -static int ctr_set_alarm(struct device *dev, uint8_t chan_id, +static int ctr_set_alarm(const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { ARG_UNUSED(dev); @@ -121,7 +121,7 @@ static int ctr_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int ctr_cancel_alarm(struct device *dev, uint8_t chan_id) +static int ctr_cancel_alarm(const struct device *dev, uint8_t chan_id) { ARG_UNUSED(dev); diff --git a/drivers/counter/counter_nrfx_rtc.c b/drivers/counter/counter_nrfx_rtc.c index f9a6ae2503c122..bb249f1cf9001d 100644 --- a/drivers/counter/counter_nrfx_rtc.c +++ b/drivers/counter/counter_nrfx_rtc.c @@ -66,38 +66,37 @@ struct counter_nrfx_config { LOG_INSTANCE_PTR_DECLARE(log); }; -static inline struct counter_nrfx_data *get_dev_data(struct device *dev) +static inline struct counter_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct counter_nrfx_config *get_nrfx_config( - struct device *dev) +static inline const struct counter_nrfx_config *get_nrfx_config(const struct device *dev) { return CONTAINER_OF(dev->config, struct counter_nrfx_config, info); } -static int start(struct device *dev) +static int start(const struct device *dev) { nrf_rtc_task_trigger(get_nrfx_config(dev)->rtc, NRF_RTC_TASK_START); return 0; } -static int stop(struct device *dev) +static int stop(const struct device *dev) { nrf_rtc_task_trigger(get_nrfx_config(dev)->rtc, NRF_RTC_TASK_STOP); return 0; } -static uint32_t read(struct device *dev) +static uint32_t read(const struct device *dev) { return nrf_rtc_counter_get(get_nrfx_config(dev)->rtc); } -static int get_value(struct device *dev, uint32_t *ticks) +static int get_value(const struct device *dev, uint32_t *ticks) { *ticks = read(dev); return 0; @@ -112,7 +111,8 @@ static inline bool is_bit_mask(uint32_t val) /* Function calculates distance between to values assuming that one first * argument is in front and that values wrap. */ -static uint32_t ticks_sub(struct device *dev, uint32_t val, uint32_t old, uint32_t top) +static uint32_t ticks_sub(const struct device *dev, uint32_t val, + uint32_t old, uint32_t top) { if (IS_FIXED_TOP(dev)) { return (val - old) & COUNTER_MAX_TOP_VALUE; @@ -137,7 +137,8 @@ static uint32_t skip_zero_on_custom_top(uint32_t val, uint32_t top) return val; } -static uint32_t ticks_add(struct device *dev, uint32_t val1, uint32_t val2, uint32_t top) +static uint32_t ticks_add(const struct device *dev, uint32_t val1, + uint32_t val2, uint32_t top) { uint32_t sum = val1 + val2; @@ -154,7 +155,7 @@ static uint32_t ticks_add(struct device *dev, uint32_t val1, uint32_t val2, uint return skip_zero_on_custom_top(sum, top); } -static void set_cc_int_pending(struct device *dev, uint8_t chan) +static void set_cc_int_pending(const struct device *dev, uint8_t chan) { atomic_or(&get_dev_data(dev)->ipend_adj, BIT(chan)); NRFX_IRQ_PENDING_SET(NRFX_IRQ_NUMBER_GET(get_nrfx_config(dev)->rtc)); @@ -173,7 +174,7 @@ static void set_cc_int_pending(struct device *dev, uint8_t chan) * is used in the callback to return original CC value which was requested by * the user. */ -static void handle_next_tick_case(struct device *dev, uint8_t chan, +static void handle_next_tick_case(const struct device *dev, uint8_t chan, uint32_t now, uint32_t val) { val = ticks_add(dev, val, 1, get_dev_data(dev)->top); @@ -215,7 +216,8 @@ static void handle_next_tick_case(struct device *dev, uint8_t chan, * enabled. * */ -static int set_cc(struct device *dev, uint8_t chan, uint32_t val, uint32_t flags) +static int set_cc(const struct device *dev, uint8_t chan, uint32_t val, + uint32_t flags) { __ASSERT_NO_MSG(get_dev_data(dev)->guard_period < get_dev_data(dev)->top); @@ -321,7 +323,7 @@ static int set_cc(struct device *dev, uint8_t chan, uint32_t val, uint32_t flags return err; } -static int set_channel_alarm(struct device *dev, uint8_t chan, +static int set_channel_alarm(const struct device *dev, uint8_t chan, const struct counter_alarm_cfg *alarm_cfg) { const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); @@ -342,7 +344,7 @@ static int set_channel_alarm(struct device *dev, uint8_t chan, return set_cc(dev, chan, alarm_cfg->ticks, alarm_cfg->flags); } -static void disable(struct device *dev, uint8_t chan) +static void disable(const struct device *dev, uint8_t chan) { const struct counter_nrfx_config *config = get_nrfx_config(dev); NRF_RTC_Type *rtc = config->rtc; @@ -354,14 +356,14 @@ static void disable(struct device *dev, uint8_t chan) config->ch_data[chan].callback = NULL; } -static int cancel_alarm(struct device *dev, uint8_t chan_id) +static int cancel_alarm(const struct device *dev, uint8_t chan_id) { disable(dev, chan_id); return 0; } -static int ppi_setup(struct device *dev, uint8_t chan) +static int ppi_setup(const struct device *dev, uint8_t chan) { #if CONFIG_COUNTER_RTC_WITH_PPI_WRAP const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); @@ -404,7 +406,7 @@ static int ppi_setup(struct device *dev, uint8_t chan) return 0; } -static void ppi_free(struct device *dev, uint8_t chan) +static void ppi_free(const struct device *dev, uint8_t chan) { #if CONFIG_COUNTER_RTC_WITH_PPI_WRAP const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); @@ -433,13 +435,13 @@ static void ppi_free(struct device *dev, uint8_t chan) /* Return true if counter must be cleared by the CPU. It is cleared * automatically in case of max top value or PPI usage. */ -static bool sw_wrap_required(struct device *dev) +static bool sw_wrap_required(const struct device *dev) { return (get_dev_data(dev)->top != COUNTER_MAX_TOP_VALUE) && !IS_PPI_WRAP(dev); } -static int set_fixed_top_value(struct device *dev, +static int set_fixed_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { NRF_RTC_Type *rtc = get_nrfx_config(dev)->rtc; @@ -463,7 +465,8 @@ static int set_fixed_top_value(struct device *dev, return 0; } -static int set_top_value(struct device *dev, const struct counter_top_cfg *cfg) +static int set_top_value(const struct device *dev, + const struct counter_top_cfg *cfg) { const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); NRF_RTC_Type *rtc = nrfx_config->rtc; @@ -517,12 +520,12 @@ static int set_top_value(struct device *dev, const struct counter_top_cfg *cfg) return err; } -static uint32_t get_pending_int(struct device *dev) +static uint32_t get_pending_int(const struct device *dev) { return 0; } -static int init_rtc(struct device *dev, uint32_t prescaler) +static int init_rtc(const struct device *dev, uint32_t prescaler) { const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); struct counter_top_cfg top_cfg = { @@ -544,28 +547,29 @@ static int init_rtc(struct device *dev, uint32_t prescaler) return err; } -static uint32_t get_top_value(struct device *dev) +static uint32_t get_top_value(const struct device *dev) { return get_dev_data(dev)->top; } -static uint32_t get_max_relative_alarm(struct device *dev) +static uint32_t get_max_relative_alarm(const struct device *dev) { return get_dev_data(dev)->top; } -static uint32_t get_guard_period(struct device *dev, uint32_t flags) +static uint32_t get_guard_period(const struct device *dev, uint32_t flags) { return get_dev_data(dev)->guard_period; } -static int set_guard_period(struct device *dev, uint32_t guard, uint32_t flags) +static int set_guard_period(const struct device *dev, uint32_t guard, + uint32_t flags) { get_dev_data(dev)->guard_period = guard; return 0; } -static void top_irq_handle(struct device *dev) +static void top_irq_handle(const struct device *dev) { NRF_RTC_Type *rtc = get_nrfx_config(dev)->rtc; counter_top_callback_t cb = get_dev_data(dev)->top_cb; @@ -591,7 +595,7 @@ static void top_irq_handle(struct device *dev) } } -static void alarm_irq_handle(struct device *dev, uint32_t chan) +static void alarm_irq_handle(const struct device *dev, uint32_t chan) { NRF_RTC_Type *rtc = get_nrfx_config(dev)->rtc; nrf_rtc_event_t evt = RTC_CHANNEL_EVENT_ADDR(chan); @@ -625,7 +629,7 @@ static void alarm_irq_handle(struct device *dev, uint32_t chan) } } -static void irq_handler(struct device *dev) +static void irq_handler(const struct device *dev) { top_irq_handle(dev); diff --git a/drivers/counter/counter_nrfx_timer.c b/drivers/counter/counter_nrfx_timer.c index 78573e263b1311..0e1c5ad87cd180 100644 --- a/drivers/counter/counter_nrfx_timer.c +++ b/drivers/counter/counter_nrfx_timer.c @@ -50,19 +50,18 @@ struct counter_timer_config { nrf_timer_frequency_t freq; }; -static inline struct counter_nrfx_data *get_dev_data(struct device *dev) +static inline struct counter_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct counter_nrfx_config *get_nrfx_config( - struct device *dev) +static inline const struct counter_nrfx_config *get_nrfx_config(const struct device *dev) { return CONTAINER_OF(dev->config, struct counter_nrfx_config, info); } -static int start(struct device *dev) +static int start(const struct device *dev) { nrf_timer_task_trigger(get_nrfx_config(dev)->timer, NRF_TIMER_TASK_START); @@ -70,7 +69,7 @@ static int start(struct device *dev) return 0; } -static int stop(struct device *dev) +static int stop(const struct device *dev) { nrf_timer_task_trigger(get_nrfx_config(dev)->timer, NRF_TIMER_TASK_SHUTDOWN); @@ -78,17 +77,17 @@ static int stop(struct device *dev) return 0; } -static uint32_t get_top_value(struct device *dev) +static uint32_t get_top_value(const struct device *dev) { return nrf_timer_cc_get(get_nrfx_config(dev)->timer, TOP_CH); } -static uint32_t get_max_relative_alarm(struct device *dev) +static uint32_t get_max_relative_alarm(const struct device *dev) { return get_top_value(dev); } -static uint32_t read(struct device *dev) +static uint32_t read(const struct device *dev) { NRF_TIMER_Type *timer = get_nrfx_config(dev)->timer; @@ -98,7 +97,7 @@ static uint32_t read(struct device *dev) return nrf_timer_cc_get(timer, COUNTER_READ_CC); } -static int get_value(struct device *dev, uint32_t *ticks) +static int get_value(const struct device *dev, uint32_t *ticks) { *ticks = read(dev); return 0; @@ -133,13 +132,14 @@ static uint32_t ticks_sub(uint32_t val, uint32_t old, uint32_t top) return (val >= old) ? (val - old) : val + top + 1 - old; } -static void set_cc_int_pending(struct device *dev, uint8_t chan) +static void set_cc_int_pending(const struct device *dev, uint8_t chan) { atomic_or(&get_dev_data(dev)->cc_int_pending, BIT(chan)); NRFX_IRQ_PENDING_SET(NRFX_IRQ_NUMBER_GET(get_nrfx_config(dev)->timer)); } -static int set_cc(struct device *dev, uint8_t id, uint32_t val, uint32_t flags) +static int set_cc(const struct device *dev, uint8_t id, uint32_t val, + uint32_t flags) { __ASSERT_NO_MSG(get_dev_data(dev)->guard_period < get_top_value(dev)); bool absolute = flags & COUNTER_ALARM_CFG_ABSOLUTE; @@ -212,7 +212,7 @@ static int set_cc(struct device *dev, uint8_t id, uint32_t val, uint32_t flags) return err; } -static int set_alarm(struct device *dev, uint8_t chan, +static int set_alarm(const struct device *dev, uint8_t chan, const struct counter_alarm_cfg *alarm_cfg) { const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); @@ -232,7 +232,7 @@ static int set_alarm(struct device *dev, uint8_t chan, return set_cc(dev, chan, alarm_cfg->ticks, alarm_cfg->flags); } -static int cancel_alarm(struct device *dev, uint8_t chan_id) +static int cancel_alarm(const struct device *dev, uint8_t chan_id) { const struct counter_nrfx_config *config = get_nrfx_config(dev); uint32_t int_mask = nrf_timer_compare_int_get(ID_TO_CC(chan_id)); @@ -243,7 +243,8 @@ static int cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static int set_top_value(struct device *dev, const struct counter_top_cfg *cfg) +static int set_top_value(const struct device *dev, + const struct counter_top_cfg *cfg) { const struct counter_nrfx_config *nrfx_config = get_nrfx_config(dev); NRF_TIMER_Type *timer = get_nrfx_config(dev)->timer; @@ -282,12 +283,12 @@ static int set_top_value(struct device *dev, const struct counter_top_cfg *cfg) return err; } -static uint32_t get_pending_int(struct device *dev) +static uint32_t get_pending_int(const struct device *dev) { return 0; } -static int init_timer(struct device *dev, +static int init_timer(const struct device *dev, const struct counter_timer_config *config) { NRF_TIMER_Type *reg = get_nrfx_config(dev)->timer; @@ -303,12 +304,13 @@ static int init_timer(struct device *dev, return 0; } -static uint32_t get_guard_period(struct device *dev, uint32_t flags) +static uint32_t get_guard_period(const struct device *dev, uint32_t flags) { return get_dev_data(dev)->guard_period; } -static int set_guard_period(struct device *dev, uint32_t guard, uint32_t flags) +static int set_guard_period(const struct device *dev, uint32_t guard, + uint32_t flags) { __ASSERT_NO_MSG(guard < get_top_value(dev)); @@ -316,7 +318,7 @@ static int set_guard_period(struct device *dev, uint32_t guard, uint32_t flags) return 0; } -static void top_irq_handle(struct device *dev) +static void top_irq_handle(const struct device *dev) { NRF_TIMER_Type *reg = get_nrfx_config(dev)->timer; counter_top_callback_t cb = get_dev_data(dev)->top_cb; @@ -329,7 +331,7 @@ static void top_irq_handle(struct device *dev) } } -static void alarm_irq_handle(struct device *dev, uint32_t id) +static void alarm_irq_handle(const struct device *dev, uint32_t id) { uint32_t cc = ID_TO_CC(id); NRF_TIMER_Type *reg = get_nrfx_config(dev)->timer; @@ -359,7 +361,7 @@ static void alarm_irq_handle(struct device *dev, uint32_t id) } } -static void irq_handler(struct device *dev) +static void irq_handler(const struct device *dev) { top_irq_handle(dev); diff --git a/drivers/counter/counter_sam0_tc32.c b/drivers/counter/counter_sam0_tc32.c index c3bc888e140bfb..6e101a73fe3b2c 100644 --- a/drivers/counter/counter_sam0_tc32.c +++ b/drivers/counter/counter_sam0_tc32.c @@ -38,7 +38,7 @@ struct counter_sam0_tc32_config { #endif uint16_t prescaler; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; #define DEV_CFG(dev) ((const struct counter_sam0_tc32_config *const) \ @@ -76,7 +76,7 @@ static void read_synchronize_count(TcCount32 *regs) #endif } -static int counter_sam0_tc32_start(struct device *dev) +static int counter_sam0_tc32_start(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -90,7 +90,7 @@ static int counter_sam0_tc32_start(struct device *dev) return 0; } -static int counter_sam0_tc32_stop(struct device *dev) +static int counter_sam0_tc32_stop(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -106,7 +106,7 @@ static int counter_sam0_tc32_stop(struct device *dev) return 0; } -static uint32_t counter_sam0_tc32_read(struct device *dev) +static uint32_t counter_sam0_tc32_read(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -115,13 +115,15 @@ static uint32_t counter_sam0_tc32_read(struct device *dev) return tc->COUNT.reg; } -static int counter_sam0_tc32_get_value(struct device *dev, uint32_t *ticks) +static int counter_sam0_tc32_get_value(const struct device *dev, + uint32_t *ticks) { *ticks = counter_sam0_tc32_read(dev); return 0; } -static void counter_sam0_tc32_relative_alarm(struct device *dev, uint32_t ticks) +static void counter_sam0_tc32_relative_alarm(const struct device *dev, + uint32_t ticks) { struct counter_sam0_tc32_data *data = DEV_DATA(dev); const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); @@ -179,7 +181,8 @@ static void counter_sam0_tc32_relative_alarm(struct device *dev, uint32_t ticks) tc->INTENSET.reg = TC_INTFLAG_MC1; } -static int counter_sam0_tc32_set_alarm(struct device *dev, uint8_t chan_id, +static int counter_sam0_tc32_set_alarm(const struct device *dev, + uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) { struct counter_sam0_tc32_data *data = DEV_DATA(dev); @@ -216,7 +219,8 @@ static int counter_sam0_tc32_set_alarm(struct device *dev, uint8_t chan_id, return 0; } -static int counter_sam0_tc32_cancel_alarm(struct device *dev, uint8_t chan_id) +static int counter_sam0_tc32_cancel_alarm(const struct device *dev, + uint8_t chan_id) { struct counter_sam0_tc32_data *data = DEV_DATA(dev); const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); @@ -234,8 +238,8 @@ static int counter_sam0_tc32_cancel_alarm(struct device *dev, uint8_t chan_id) return 0; } -static int counter_sam0_tc32_set_top_value(struct device *dev, - const struct counter_top_cfg *top_cfg) +static int counter_sam0_tc32_set_top_value(const struct device *dev, + const struct counter_top_cfg *top_cfg) { struct counter_sam0_tc32_data *data = DEV_DATA(dev); const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); @@ -280,7 +284,7 @@ static int counter_sam0_tc32_set_top_value(struct device *dev, return err; } -static uint32_t counter_sam0_tc32_get_pending_int(struct device *dev) +static uint32_t counter_sam0_tc32_get_pending_int(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -288,7 +292,7 @@ static uint32_t counter_sam0_tc32_get_pending_int(struct device *dev) return tc->INTFLAG.reg & (TC_INTFLAG_MC0 | TC_INTFLAG_MC1); } -static uint32_t counter_sam0_tc32_get_top_value(struct device *dev) +static uint32_t counter_sam0_tc32_get_top_value(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -301,14 +305,14 @@ static uint32_t counter_sam0_tc32_get_top_value(struct device *dev) return tc->CC[0].reg; } -static uint32_t counter_sam0_tc32_get_max_relative_alarm(struct device *dev) +static uint32_t counter_sam0_tc32_get_max_relative_alarm(const struct device *dev) { return counter_sam0_tc32_get_top_value(dev) - 1; } static void counter_sam0_tc32_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct counter_sam0_tc32_data *data = DEV_DATA(dev); const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; @@ -335,7 +339,7 @@ static void counter_sam0_tc32_isr(void *arg) } } -static int counter_sam0_tc32_initialize(struct device *dev) +static int counter_sam0_tc32_initialize(const struct device *dev) { const struct counter_sam0_tc32_config *const cfg = DEV_CFG(dev); TcCount32 *tc = cfg->regs; diff --git a/drivers/counter/maxim_ds3231.c b/drivers/counter/maxim_ds3231.c index 6a18f820e958fe..93706233158959 100644 --- a/drivers/counter/maxim_ds3231.c +++ b/drivers/counter/maxim_ds3231.c @@ -77,9 +77,9 @@ struct ds3231_config { }; struct ds3231_data { - struct device *ds3231; - struct device *i2c; - struct device *isw; + const struct device *ds3231; + const struct device *i2c; + const struct device *isw; struct register_map registers; struct k_sem lock; @@ -144,7 +144,7 @@ struct ds3231_data { * * Caches and returns the value with the changes applied. */ -static int sc_ctrl(struct device *dev, +static int sc_ctrl(const struct device *dev, uint8_t set, uint8_t clear) { @@ -168,7 +168,7 @@ static int sc_ctrl(struct device *dev, return rc; } -int maxim_ds3231_ctrl_update(struct device *dev, +int maxim_ds3231_ctrl_update(const struct device *dev, uint8_t set_bits, uint8_t clear_bits) { @@ -194,7 +194,7 @@ int maxim_ds3231_ctrl_update(struct device *dev, * Returns the value as originally read (disregarding the effect of * clears and sets). */ -static inline int rsc_stat(struct device *dev, +static inline int rsc_stat(const struct device *dev, uint8_t set, uint8_t clear) { @@ -226,7 +226,7 @@ static inline int rsc_stat(struct device *dev, return rc; } -int maxim_ds3231_stat_update(struct device *dev, +int maxim_ds3231_stat_update(const struct device *dev, uint8_t set_bits, uint8_t clear_bits) { @@ -245,7 +245,7 @@ int maxim_ds3231_stat_update(struct device *dev, * Look for current users of the interrupt/square-wave signal and * enable monitoring iff at least one consumer is active. */ -static void validate_isw_monitoring(struct device *dev) +static void validate_isw_monitoring(const struct device *dev) { struct ds3231_data *data = dev->data; const struct ds3231_config *cfg = dev->config; @@ -446,7 +446,7 @@ static uint32_t decode_rtc(struct ds3231_data *data) return data->rtc_registers; } -static int update_registers(struct device *dev) +static int update_registers(const struct device *dev) { struct ds3231_data *data = dev->data; const struct ds3231_config *cfg = dev->config; @@ -467,7 +467,7 @@ static int update_registers(struct device *dev) return 0; } -int maxim_ds3231_get_alarm(struct device *dev, +int maxim_ds3231_get_alarm(const struct device *dev, uint8_t id, struct maxim_ds3231_alarm *cp) { @@ -514,7 +514,7 @@ int maxim_ds3231_get_alarm(struct device *dev, return rv; } -static int cancel_alarm(struct device *dev, +static int cancel_alarm(const struct device *dev, uint8_t id) { struct ds3231_data *data = dev->data; @@ -525,7 +525,7 @@ static int cancel_alarm(struct device *dev, return sc_ctrl(dev, 0, MAXIM_DS3231_ALARM1 << id); } -static int ds3231_counter_cancel_alarm(struct device *dev, +static int ds3231_counter_cancel_alarm(const struct device *dev, uint8_t id) { struct ds3231_data *data = dev->data; @@ -552,7 +552,7 @@ static int ds3231_counter_cancel_alarm(struct device *dev, return rv; } -static int set_alarm(struct device *dev, +static int set_alarm(const struct device *dev, uint8_t id, const struct maxim_ds3231_alarm *cp) { @@ -601,7 +601,7 @@ static int set_alarm(struct device *dev, return rc; } -int maxim_ds3231_set_alarm(struct device *dev, +int maxim_ds3231_set_alarm(const struct device *dev, uint8_t id, const struct maxim_ds3231_alarm *cp) { @@ -616,7 +616,7 @@ int maxim_ds3231_set_alarm(struct device *dev, return rc; } -int maxim_ds3231_check_alarms(struct device *dev) +int maxim_ds3231_check_alarms(const struct device *dev) { struct ds3231_data *data = dev->data; const struct register_map *rp = &data->registers; @@ -638,7 +638,7 @@ int maxim_ds3231_check_alarms(struct device *dev) return rv; } -static int check_handled_alarms(struct device *dev) +static int check_handled_alarms(const struct device *dev) { struct ds3231_data *data = dev->data; const struct register_map *rp = &data->registers; @@ -659,7 +659,7 @@ static int check_handled_alarms(struct device *dev) return rv; } -static void counter_alarm_forwarder(struct device *dev, +static void counter_alarm_forwarder(const struct device *dev, uint8_t id, uint32_t syncclock, void *ud) @@ -671,7 +671,7 @@ static void alarm_worker(struct k_work *work) { struct ds3231_data *data = CONTAINER_OF(work, struct ds3231_data, alarm_work); - struct device *ds3231 = data->ds3231; + const struct device *ds3231 = data->ds3231; const struct ds3231_config *cfg = ds3231->config; k_sem_take(&data->lock, K_FOREVER); @@ -747,7 +747,7 @@ static void sqw_worker(struct k_work *work) syncclock - data->isw_syncclock); } -static int read_time(struct device *dev, +static int read_time(const struct device *dev, time_t *time) { struct ds3231_data *data = dev->data; @@ -765,7 +765,7 @@ static int read_time(struct device *dev, return rc; } -static int ds3231_counter_get_value(struct device *dev, +static int ds3231_counter_get_value(const struct device *dev, uint32_t *ticks) { struct ds3231_data *data = dev->data; @@ -784,7 +784,7 @@ static int ds3231_counter_get_value(struct device *dev, return rc; } -static void sync_finish(struct device *dev, +static void sync_finish(const struct device *dev, int rc) { struct ds3231_data *data = dev->data; @@ -816,7 +816,7 @@ static void sync_finish(struct device *dev, } } -static void sync_prep_read(struct device *dev) +static void sync_prep_read(const struct device *dev) { struct ds3231_data *data = dev->data; int rc = sc_ctrl(dev, 0U, MAXIM_DS3231_REG_CTRL_INTCN @@ -830,7 +830,7 @@ static void sync_prep_read(struct device *dev) validate_isw_monitoring(dev); } -static void sync_finish_read(struct device *dev) +static void sync_finish_read(const struct device *dev) { struct ds3231_data *data = dev->data; time_t time = 0; @@ -851,7 +851,7 @@ static void sync_timer_handler(struct k_timer *tmr) k_work_submit(&data->sync_work); } -static void sync_prep_write(struct device *dev) +static void sync_prep_write(const struct device *dev) { struct ds3231_data *data = dev->data; uint32_t syncclock = maxim_ds3231_read_syncclock(dev); @@ -883,7 +883,7 @@ static void sync_prep_write(struct device *dev) LOG_INF("sync %u in %u ms after %u", (uint32_t)when, rem_ms, syncclock); } -static void sync_finish_write(struct device *dev) +static void sync_finish_write(const struct device *dev) { struct ds3231_data *data = dev->data; const struct ds3231_config *cfg = dev->config; @@ -967,7 +967,7 @@ static void sync_worker(struct k_work *work) } } -static void isw_gpio_callback(struct device *port, +static void isw_gpio_callback(const struct device *port, struct gpio_callback *cb, uint32_t pins) { @@ -984,7 +984,7 @@ static void isw_gpio_callback(struct device *port, } } -int z_impl_maxim_ds3231_get_syncpoint(struct device *dev, +int z_impl_maxim_ds3231_get_syncpoint(const struct device *dev, struct maxim_ds3231_syncpoint *syncpoint) { struct ds3231_data *data = dev->data; @@ -1004,7 +1004,7 @@ int z_impl_maxim_ds3231_get_syncpoint(struct device *dev, return rv; } -int maxim_ds3231_synchronize(struct device *dev, +int maxim_ds3231_synchronize(const struct device *dev, struct sys_notify *notify) { struct ds3231_data *data = dev->data; @@ -1042,7 +1042,7 @@ int maxim_ds3231_synchronize(struct device *dev, return rv; } -int z_impl_maxim_ds3231_req_syncpoint(struct device *dev, +int z_impl_maxim_ds3231_req_syncpoint(const struct device *dev, struct k_poll_signal *sig) { struct ds3231_data *data = dev->data; @@ -1075,7 +1075,7 @@ int z_impl_maxim_ds3231_req_syncpoint(struct device *dev, return rv; } -int maxim_ds3231_set(struct device *dev, +int maxim_ds3231_set(const struct device *dev, const struct maxim_ds3231_syncpoint *syncpoint, struct sys_notify *notify) { @@ -1115,11 +1115,11 @@ int maxim_ds3231_set(struct device *dev, return rv; } -static int ds3231_init(struct device *dev) +static int ds3231_init(const struct device *dev) { struct ds3231_data *data = dev->data; const struct ds3231_config *cfg = dev->config; - struct device *i2c = device_get_binding(cfg->bus_name); + const struct device *i2c = device_get_binding(cfg->bus_name); int rc; /* Initialize and take the lock */ @@ -1155,7 +1155,7 @@ static int ds3231_init(struct device *dev) */ if (cfg->isw_gpios.ctrl != NULL) { - struct device *gpio = device_get_binding(cfg->isw_gpios.ctrl); + const struct device *gpio = device_get_binding(cfg->isw_gpios.ctrl); if (gpio == NULL) { LOG_WRN("Failed to get INTn/SQW GPIO %s", @@ -1199,17 +1199,17 @@ static int ds3231_init(struct device *dev) return rc; } -static int ds3231_counter_start(struct device *dev) +static int ds3231_counter_start(const struct device *dev) { return -EALREADY; } -static int ds3231_counter_stop(struct device *dev) +static int ds3231_counter_stop(const struct device *dev) { return -ENOTSUP; } -int ds3231_counter_set_alarm(struct device *dev, +int ds3231_counter_set_alarm(const struct device *dev, uint8_t id, const struct counter_alarm_cfg *alarm_cfg) { @@ -1265,23 +1265,23 @@ int ds3231_counter_set_alarm(struct device *dev, return rc; } -static uint32_t ds3231_counter_get_top_value(struct device *dev) +static uint32_t ds3231_counter_get_top_value(const struct device *dev) { return UINT32_MAX; } -static uint32_t ds3231_counter_get_pending_int(struct device *dev) +static uint32_t ds3231_counter_get_pending_int(const struct device *dev) { return 0; } -static int ds3231_counter_set_top_value(struct device *dev, +static int ds3231_counter_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { return -ENOTSUP; } -static uint32_t ds3231_counter_get_max_relative_alarm(struct device *dev) +static uint32_t ds3231_counter_get_max_relative_alarm(const struct device *dev) { return UINT32_MAX; } @@ -1333,7 +1333,7 @@ DEVICE_AND_API_INIT(ds3231_0, DT_INST_LABEL(0), #include -int z_vrfy_maxim_ds3231_get_syncpoint(struct device *dev, +int z_vrfy_maxim_ds3231_get_syncpoint(const struct device *dev, struct maxim_ds3231_syncpoint *syncpoint) { struct maxim_ds3231_syncpoint value; @@ -1353,7 +1353,7 @@ int z_vrfy_maxim_ds3231_get_syncpoint(struct device *dev, #include -int z_vrfy_maxim_ds3231_req_syncpoint(struct device *dev, +int z_vrfy_maxim_ds3231_req_syncpoint(const struct device *dev, struct k_poll_signal *sig) { Z_OOPS(Z_SYSCALL_SPECIFIC_DRIVER(dev, K_OBJ_DRIVER_COUNTER, &ds3231_api)); diff --git a/drivers/counter/timer_dtmr_cmsdk_apb.c b/drivers/counter/timer_dtmr_cmsdk_apb.c index 0b8c700d4e88de..45e70aef550e5e 100644 --- a/drivers/counter/timer_dtmr_cmsdk_apb.c +++ b/drivers/counter/timer_dtmr_cmsdk_apb.c @@ -15,7 +15,7 @@ #include "dualtimer_cmsdk_apb.h" -typedef void (*dtimer_config_func_t)(struct device *dev); +typedef void (*dtimer_config_func_t)(const struct device *dev); struct dtmr_cmsdk_apb_cfg { struct counter_config_info info; @@ -35,7 +35,7 @@ struct dtmr_cmsdk_apb_dev_data { uint32_t load; }; -static int dtmr_cmsdk_apb_start(struct device *dev) +static int dtmr_cmsdk_apb_start(const struct device *dev) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; struct dtmr_cmsdk_apb_dev_data *data = dev->data; @@ -49,7 +49,7 @@ static int dtmr_cmsdk_apb_start(struct device *dev) return 0; } -static int dtmr_cmsdk_apb_stop(struct device *dev) +static int dtmr_cmsdk_apb_stop(const struct device *dev) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -59,7 +59,7 @@ static int dtmr_cmsdk_apb_stop(struct device *dev) return 0; } -static int dtmr_cmsdk_apb_get_value(struct device *dev, uint32_t *ticks) +static int dtmr_cmsdk_apb_get_value(const struct device *dev, uint32_t *ticks) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; struct dtmr_cmsdk_apb_dev_data *data = dev->data; @@ -68,7 +68,7 @@ static int dtmr_cmsdk_apb_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int dtmr_cmsdk_apb_set_top_value(struct device *dev, +static int dtmr_cmsdk_apb_set_top_value(const struct device *dev, const struct counter_top_cfg *top_cfg) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -102,7 +102,7 @@ static int dtmr_cmsdk_apb_set_top_value(struct device *dev, return 0; } -static uint32_t dtmr_cmsdk_apb_get_top_value(struct device *dev) +static uint32_t dtmr_cmsdk_apb_get_top_value(const struct device *dev) { struct dtmr_cmsdk_apb_dev_data *data = dev->data; @@ -111,7 +111,7 @@ static uint32_t dtmr_cmsdk_apb_get_top_value(struct device *dev) return ticks; } -static uint32_t dtmr_cmsdk_apb_get_pending_int(struct device *dev) +static uint32_t dtmr_cmsdk_apb_get_pending_int(const struct device *dev) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -129,7 +129,7 @@ static const struct counter_driver_api dtmr_cmsdk_apb_api = { static void dtmr_cmsdk_apb_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct dtmr_cmsdk_apb_dev_data *data = dev->data; const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -139,13 +139,13 @@ static void dtmr_cmsdk_apb_isr(void *arg) } } -static int dtmr_cmsdk_apb_init(struct device *dev) +static int dtmr_cmsdk_apb_init(const struct device *dev) { const struct dtmr_cmsdk_apb_cfg * const cfg = dev->config; #ifdef CONFIG_CLOCK_CONTROL /* Enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(CONFIG_ARM_CLOCK_CONTROL_DEV_NAME); #ifdef CONFIG_SOC_SERIES_BEETLE diff --git a/drivers/counter/timer_tmr_cmsdk_apb.c b/drivers/counter/timer_tmr_cmsdk_apb.c index 192d71ecbbd430..27f1af614efca1 100644 --- a/drivers/counter/timer_tmr_cmsdk_apb.c +++ b/drivers/counter/timer_tmr_cmsdk_apb.c @@ -15,7 +15,7 @@ #include "timer_cmsdk_apb.h" -typedef void (*timer_config_func_t)(struct device *dev); +typedef void (*timer_config_func_t)(const struct device *dev); struct tmr_cmsdk_apb_cfg { struct counter_config_info info; @@ -36,7 +36,7 @@ struct tmr_cmsdk_apb_dev_data { uint32_t load; }; -static int tmr_cmsdk_apb_start(struct device *dev) +static int tmr_cmsdk_apb_start(const struct device *dev) { const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -50,7 +50,7 @@ static int tmr_cmsdk_apb_start(struct device *dev) return 0; } -static int tmr_cmsdk_apb_stop(struct device *dev) +static int tmr_cmsdk_apb_stop(const struct device *dev) { const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -60,7 +60,7 @@ static int tmr_cmsdk_apb_stop(struct device *dev) return 0; } -static int tmr_cmsdk_apb_get_value(struct device *dev, uint32_t *ticks) +static int tmr_cmsdk_apb_get_value(const struct device *dev, uint32_t *ticks) { const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -71,7 +71,7 @@ static int tmr_cmsdk_apb_get_value(struct device *dev, uint32_t *ticks) return 0; } -static int tmr_cmsdk_apb_set_top_value(struct device *dev, +static int tmr_cmsdk_apb_set_top_value(const struct device *dev, const struct counter_top_cfg *top_cfg) { const struct tmr_cmsdk_apb_cfg * const cfg = @@ -101,7 +101,7 @@ static int tmr_cmsdk_apb_set_top_value(struct device *dev, return 0; } -static uint32_t tmr_cmsdk_apb_get_top_value(struct device *dev) +static uint32_t tmr_cmsdk_apb_get_top_value(const struct device *dev) { struct tmr_cmsdk_apb_dev_data *data = dev->data; @@ -110,7 +110,7 @@ static uint32_t tmr_cmsdk_apb_get_top_value(struct device *dev) return ticks; } -static uint32_t tmr_cmsdk_apb_get_pending_int(struct device *dev) +static uint32_t tmr_cmsdk_apb_get_pending_int(const struct device *dev) { const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -129,7 +129,7 @@ static const struct counter_driver_api tmr_cmsdk_apb_api = { static void tmr_cmsdk_apb_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct tmr_cmsdk_apb_dev_data *data = dev->data; const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; @@ -140,14 +140,14 @@ static void tmr_cmsdk_apb_isr(void *arg) } } -static int tmr_cmsdk_apb_init(struct device *dev) +static int tmr_cmsdk_apb_init(const struct device *dev) { const struct tmr_cmsdk_apb_cfg * const cfg = dev->config; #ifdef CONFIG_CLOCK_CONTROL /* Enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(CONFIG_ARM_CLOCK_CONTROL_DEV_NAME); #ifdef CONFIG_SOC_SERIES_BEETLE diff --git a/drivers/crypto/crypto_ataes132a.c b/drivers/crypto/crypto_ataes132a.c index 5aadea1b34b487..2fca272a4e61dd 100644 --- a/drivers/crypto/crypto_ataes132a.c +++ b/drivers/crypto/crypto_ataes132a.c @@ -37,7 +37,7 @@ static void ataes132a_init_states(void) } } -static int ataes132a_send_command(struct device *dev, uint8_t opcode, +static int ataes132a_send_command(const struct device *dev, uint8_t opcode, uint8_t mode, uint8_t *params, uint8_t nparams, uint8_t *response, uint8_t *nresponse) @@ -164,7 +164,7 @@ static int ataes132a_send_command(struct device *dev, uint8_t opcode, return 0; } -int ataes132a_init(struct device *dev) +int ataes132a_init(const struct device *dev) { struct ataes132a_device_data *ataes132a = dev->data; const struct ataes132a_device_config *cfg = dev->config; @@ -189,7 +189,7 @@ int ataes132a_init(struct device *dev) return 0; } -int ataes132a_aes_ccm_decrypt(struct device *dev, +int ataes132a_aes_ccm_decrypt(const struct device *dev, uint8_t key_id, struct ataes132a_mac_mode *mac_mode, struct ataes132a_mac_packet *mac_packet, @@ -389,7 +389,7 @@ int ataes132a_aes_ccm_decrypt(struct device *dev, return 0; } -int ataes132a_aes_ccm_encrypt(struct device *dev, +int ataes132a_aes_ccm_encrypt(const struct device *dev, uint8_t key_id, struct ataes132a_mac_mode *mac_mode, struct cipher_aead_pkt *aead_op, @@ -577,7 +577,7 @@ int ataes132a_aes_ccm_encrypt(struct device *dev, return 0; } -int ataes132a_aes_ecb_block(struct device *dev, +int ataes132a_aes_ecb_block(const struct device *dev, uint8_t key_id, struct cipher_pkt *pkt) { @@ -668,7 +668,7 @@ int ataes132a_aes_ecb_block(struct device *dev, static int do_ccm_encrypt_mac(struct cipher_ctx *ctx, struct cipher_aead_pkt *aead_op, uint8_t *nonce) { - struct device *dev = ctx->device; + const struct device *dev = ctx->device; struct ataes132a_driver_state *state = ctx->drv_sessn_state; struct ataes132a_mac_mode mac_mode; uint8_t key_id; @@ -717,7 +717,7 @@ static int do_ccm_encrypt_mac(struct cipher_ctx *ctx, static int do_ccm_decrypt_auth(struct cipher_ctx *ctx, struct cipher_aead_pkt *aead_op, uint8_t *nonce) { - struct device *dev = ctx->device; + const struct device *dev = ctx->device; struct ataes132a_driver_state *state = ctx->drv_sessn_state; struct ataes132a_mac_mode mac_mode; uint8_t key_id; @@ -762,7 +762,7 @@ static int do_ccm_decrypt_auth(struct cipher_ctx *ctx, static int do_block(struct cipher_ctx *ctx, struct cipher_pkt *pkt) { - struct device *dev = ctx->device; + const struct device *dev = ctx->device; struct ataes132a_driver_state *state = ctx->drv_sessn_state; uint8_t key_id; @@ -780,7 +780,7 @@ static int do_block(struct cipher_ctx *ctx, struct cipher_pkt *pkt) return ataes132a_aes_ecb_block(dev, key_id, pkt); } -static int ataes132a_session_free(struct device *dev, +static int ataes132a_session_free(const struct device *dev, struct cipher_ctx *session) { struct ataes132a_driver_state *state = session->drv_sessn_state; @@ -792,7 +792,8 @@ static int ataes132a_session_free(struct device *dev, return 0; } -static int ataes132a_session_setup(struct device *dev, struct cipher_ctx *ctx, +static int ataes132a_session_setup(const struct device *dev, + struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, enum cipher_op op_type) { @@ -876,7 +877,7 @@ static int ataes132a_session_setup(struct device *dev, struct cipher_ctx *ctx, return 0; } -static int ataes132a_query_caps(struct device *dev) +static int ataes132a_query_caps(const struct device *dev) { return (CAP_OPAQUE_KEY_HNDL | CAP_SEPARATE_IO_BUFS | CAP_SYNC_OPS | CAP_AUTONONCE); diff --git a/drivers/crypto/crypto_ataes132a_priv.h b/drivers/crypto/crypto_ataes132a_priv.h index 00bbe827cab7c4..15a8c02f0777da 100644 --- a/drivers/crypto/crypto_ataes132a_priv.h +++ b/drivers/crypto/crypto_ataes132a_priv.h @@ -136,7 +136,7 @@ void ataes132a_atmel_crc(uint8_t *input, uint8_t length, *(uint16_t *)output = crc << 8 | crc >> 8; } -static inline int burst_write_i2c(struct device *dev, uint16_t dev_addr, +static inline int burst_write_i2c(const struct device *dev, uint16_t dev_addr, uint16_t start_addr, uint8_t *buf, uint8_t num_bytes) { @@ -158,7 +158,7 @@ static inline int burst_write_i2c(struct device *dev, uint16_t dev_addr, } -static inline int burst_read_i2c(struct device *dev, uint16_t dev_addr, +static inline int burst_read_i2c(const struct device *dev, uint16_t dev_addr, uint16_t start_addr, uint8_t *buf, uint8_t num_bytes) { @@ -179,13 +179,13 @@ static inline int burst_read_i2c(struct device *dev, uint16_t dev_addr, return api->transfer(dev, msg, 2, dev_addr); } -static inline int read_reg_i2c(struct device *dev, uint16_t dev_addr, +static inline int read_reg_i2c(const struct device *dev, uint16_t dev_addr, uint16_t reg_addr, uint8_t *value) { return burst_read_i2c(dev, dev_addr, reg_addr, value, 1); } -static inline int write_reg_i2c(struct device *dev, uint16_t dev_addr, +static inline int write_reg_i2c(const struct device *dev, uint16_t dev_addr, uint16_t reg_addr, uint8_t value) { return burst_write_i2c(dev, dev_addr, reg_addr, &value, 1); @@ -198,7 +198,7 @@ struct ataes132a_device_config { }; struct ataes132a_device_data { - struct device *i2c; + const struct device *i2c; uint8_t command_buffer[64]; struct k_sem device_sem; }; @@ -252,7 +252,7 @@ struct ataes132a_mac_mode { * * @return Returns 0 in case of success and an error code otherwise. */ -int ataes132a_init(struct device *i2c_dev); +int ataes132a_init(const struct device *i2c_dev); /** * @brief ATAES132A CCM decrypt function @@ -311,7 +311,7 @@ int ataes132a_init(struct device *i2c_dev); * * @return Returns 0 in case of success and an error code otherwise. */ -int ataes132a_aes_ccm_decrypt(struct device *i2c_dev, +int ataes132a_aes_ccm_decrypt(const struct device *i2c_dev, uint8_t key_id, struct ataes132a_mac_mode *mac_mode, struct ataes132a_mac_packet *mac_packet, @@ -359,7 +359,7 @@ int ataes132a_aes_ccm_decrypt(struct device *i2c_dev, * * @return Returns 0 in case of success and an error code otherwise. */ -int ataes132a_aes_ccm_encrypt(struct device *i2c_dev, +int ataes132a_aes_ccm_encrypt(const struct device *i2c_dev, uint8_t key_id, struct ataes132a_mac_mode *mac_mode, struct cipher_aead_pkt *aead_op, @@ -387,7 +387,7 @@ int ataes132a_aes_ccm_encrypt(struct device *i2c_dev, * * @return Returns 0 in case of success and an error code otherwise. */ -int ataes132a_aes_ecb_block(struct device *i2c_dev, +int ataes132a_aes_ecb_block(const struct device *i2c_dev, uint8_t key_id, struct cipher_pkt *pkt); diff --git a/drivers/crypto/crypto_mtls_shim.c b/drivers/crypto/crypto_mtls_shim.c index b6e85a1f44fc23..6d971121970504 100644 --- a/drivers/crypto/crypto_mtls_shim.c +++ b/drivers/crypto/crypto_mtls_shim.c @@ -300,9 +300,10 @@ static int mtls_get_unused_session_index(void) return -1; } -static int mtls_session_setup(struct device *dev, struct cipher_ctx *ctx, - enum cipher_algo algo, enum cipher_mode mode, - enum cipher_op op_type) +static int mtls_session_setup(const struct device *dev, + struct cipher_ctx *ctx, + enum cipher_algo algo, enum cipher_mode mode, + enum cipher_op op_type) { mbedtls_aes_context *aes_ctx; mbedtls_ccm_context *ccm_ctx; @@ -431,7 +432,7 @@ static int mtls_session_setup(struct device *dev, struct cipher_ctx *ctx, return ret; } -static int mtls_session_free(struct device *dev, struct cipher_ctx *ctx) +static int mtls_session_free(const struct device *dev, struct cipher_ctx *ctx) { struct mtls_shim_session *mtls_session = (struct mtls_shim_session *)ctx->drv_sessn_state; @@ -450,12 +451,12 @@ static int mtls_session_free(struct device *dev, struct cipher_ctx *ctx) return 0; } -static int mtls_query_caps(struct device *dev) +static int mtls_query_caps(const struct device *dev) { return MTLS_SUPPORT; } -static int mtls_shim_init(struct device *dev) +static int mtls_shim_init(const struct device *dev) { return 0; } diff --git a/drivers/crypto/crypto_nrf_ecb.c b/drivers/crypto/crypto_nrf_ecb.c index 09712136efe4aa..2815fcfa7e8338 100644 --- a/drivers/crypto/crypto_nrf_ecb.c +++ b/drivers/crypto/crypto_nrf_ecb.c @@ -63,7 +63,7 @@ static int do_ecb_encrypt(struct cipher_ctx *ctx, struct cipher_pkt *pkt) return 0; } -static int nrf_ecb_driver_init(struct device *dev) +static int nrf_ecb_driver_init(const struct device *dev) { ARG_UNUSED(dev); @@ -72,14 +72,15 @@ static int nrf_ecb_driver_init(struct device *dev) return 0; } -static int nrf_ecb_query_caps(struct device *dev) +static int nrf_ecb_query_caps(const struct device *dev) { ARG_UNUSED(dev); return (CAP_RAW_KEY | CAP_SEPARATE_IO_BUFS | CAP_SYNC_OPS); } -static int nrf_ecb_session_setup(struct device *dev, struct cipher_ctx *ctx, +static int nrf_ecb_session_setup(const struct device *dev, + struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, enum cipher_op op_type) { @@ -118,7 +119,8 @@ static int nrf_ecb_session_setup(struct device *dev, struct cipher_ctx *ctx, return 0; } -static int nrf_ecb_session_free(struct device *dev, struct cipher_ctx *sessn) +static int nrf_ecb_session_free(const struct device *dev, + struct cipher_ctx *sessn) { ARG_UNUSED(dev); ARG_UNUSED(sessn); diff --git a/drivers/crypto/crypto_stm32.c b/drivers/crypto/crypto_stm32.c index 8ba0cc1bfd4cd5..5bdbc5a422a77e 100644 --- a/drivers/crypto/crypto_stm32.c +++ b/drivers/crypto/crypto_stm32.c @@ -237,7 +237,7 @@ static int crypto_stm32_ctr_decrypt(struct cipher_ctx *ctx, return ret; } -static int crypto_stm32_get_unused_session_index(struct device *dev) +static int crypto_stm32_get_unused_session_index(const struct device *dev) { int i; @@ -258,7 +258,7 @@ static int crypto_stm32_get_unused_session_index(struct device *dev) return -1; } -static int crypto_stm32_session_setup(struct device *dev, +static int crypto_stm32_session_setup(const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, @@ -382,7 +382,7 @@ static int crypto_stm32_session_setup(struct device *dev, return 0; } -static int crypto_stm32_session_free(struct device *dev, +static int crypto_stm32_session_free(const struct device *dev, struct cipher_ctx *ctx) { int i; @@ -416,14 +416,14 @@ static int crypto_stm32_session_free(struct device *dev, return 0; } -static int crypto_stm32_query_caps(struct device *dev) +static int crypto_stm32_query_caps(const struct device *dev) { return CRYP_SUPPORT; } -static int crypto_stm32_init(struct device *dev) +static int crypto_stm32_init(const struct device *dev) { - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); struct crypto_stm32_data *data = CRYPTO_STM32_DATA(dev); const struct crypto_stm32_config *cfg = CRYPTO_STM32_CFG(dev); diff --git a/drivers/crypto/crypto_tc_shim.c b/drivers/crypto/crypto_tc_shim.c index 49bdee3c2420a8..c923867b88e7ce 100644 --- a/drivers/crypto/crypto_tc_shim.c +++ b/drivers/crypto/crypto_tc_shim.c @@ -190,9 +190,9 @@ static int get_unused_session(void) return i; } -static int tc_session_setup(struct device *dev, struct cipher_ctx *ctx, - enum cipher_algo algo, enum cipher_mode mode, - enum cipher_op op_type) +static int tc_session_setup(const struct device *dev, struct cipher_ctx *ctx, + enum cipher_algo algo, enum cipher_mode mode, + enum cipher_op op_type) { struct tc_shim_drv_state *data; int idx; @@ -286,12 +286,12 @@ static int tc_session_setup(struct device *dev, struct cipher_ctx *ctx, return 0; } -static int tc_query_caps(struct device *dev) +static int tc_query_caps(const struct device *dev) { return (CAP_RAW_KEY | CAP_SEPARATE_IO_BUFS | CAP_SYNC_OPS); } -static int tc_session_free(struct device *dev, struct cipher_ctx *sessn) +static int tc_session_free(const struct device *dev, struct cipher_ctx *sessn) { struct tc_shim_drv_state *data = sessn->drv_sessn_state; @@ -302,7 +302,7 @@ static int tc_session_free(struct device *dev, struct cipher_ctx *sessn) return 0; } -static int tc_shim_init(struct device *dev) +static int tc_shim_init(const struct device *dev) { int i; diff --git a/drivers/dac/dac_dacx0508.c b/drivers/dac/dac_dacx0508.c index 66957b7168e303..c9cb38404808f8 100644 --- a/drivers/dac/dac_dacx0508.c +++ b/drivers/dac/dac_dacx0508.c @@ -42,13 +42,14 @@ struct dacx0508_config { }; struct dacx0508_data { - struct device *spi_dev; + const struct device *spi_dev; struct spi_cs_control spi_cs; struct spi_config spi_cfg; uint8_t configured; }; -static int dacx0508_reg_read(struct device *dev, uint8_t addr, uint8_t *data) +static int dacx0508_reg_read(const struct device *dev, uint8_t addr, + uint8_t *data) { struct dacx0508_data *dev_data = dev->data; const struct spi_buf buf[2] = { @@ -96,7 +97,8 @@ static int dacx0508_reg_read(struct device *dev, uint8_t addr, uint8_t *data) return 0; } -static int dacx0508_reg_write(struct device *dev, uint8_t addr, uint8_t *data) +static int dacx0508_reg_write(const struct device *dev, uint8_t addr, + uint8_t *data) { struct dacx0508_data *dev_data = dev->data; const struct spi_buf buf[2] = { @@ -122,7 +124,7 @@ static int dacx0508_reg_write(struct device *dev, uint8_t addr, uint8_t *data) return spi_write(dev_data->spi_dev, &dev_data->spi_cfg, &tx); } -int dacx0508_reg_update(struct device *dev, uint8_t addr, +int dacx0508_reg_update(const struct device *dev, uint8_t addr, uint16_t mask, bool setting) { uint8_t regval[2] = {0, }; @@ -152,7 +154,7 @@ int dacx0508_reg_update(struct device *dev, uint8_t addr, return 0; } -static int dacx0508_channel_setup(struct device *dev, +static int dacx0508_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) { const struct dacx0508_config *config = dev->config; @@ -173,7 +175,7 @@ static int dacx0508_channel_setup(struct device *dev, return 0; } -static int dacx0508_write_value(struct device *dev, uint8_t channel, +static int dacx0508_write_value(const struct device *dev, uint8_t channel, uint32_t value) { const struct dacx0508_config *config = dev->config; @@ -208,7 +210,7 @@ static int dacx0508_write_value(struct device *dev, uint8_t channel, return 0; } -static int dacx0508_soft_reset(struct device *dev) +static int dacx0508_soft_reset(const struct device *dev) { uint8_t regval[2] = {0, DACX0508_MASK_TRIGGER_SOFT_RESET}; int ret; @@ -222,7 +224,7 @@ static int dacx0508_soft_reset(struct device *dev) return 0; } -static int dacx0508_device_id_check(struct device *dev) +static int dacx0508_device_id_check(const struct device *dev) { const struct dacx0508_config *config = dev->config; uint8_t regval[2] = {0, }; @@ -252,7 +254,7 @@ static int dacx0508_device_id_check(struct device *dev) return 0; } -static int dacx0508_setup(struct device *dev) +static int dacx0508_setup(const struct device *dev) { const struct dacx0508_config *config = dev->config; uint8_t regval[2] = {0, }, tmp = 0; @@ -329,7 +331,7 @@ static int dacx0508_setup(struct device *dev) return 0; } -static int dacx0508_init(struct device *dev) +static int dacx0508_init(const struct device *dev) { const struct dacx0508_config *config = dev->config; struct dacx0508_data *data = dev->data; diff --git a/drivers/dac/dac_handlers.c b/drivers/dac/dac_handlers.c index e6da298e4b729b..59fe3a6e05371f 100644 --- a/drivers/dac/dac_handlers.c +++ b/drivers/dac/dac_handlers.c @@ -8,8 +8,8 @@ #include #include -static inline int z_vrfy_dac_channel_setup(struct device *dev, - const struct dac_channel_cfg *user_channel_cfg) +static inline int z_vrfy_dac_channel_setup(const struct device *dev, + const struct dac_channel_cfg *user_channel_cfg) { struct dac_channel_cfg channel_cfg; @@ -18,15 +18,17 @@ static inline int z_vrfy_dac_channel_setup(struct device *dev, (struct dac_channel_cfg *)user_channel_cfg, sizeof(struct dac_channel_cfg))); - return z_impl_dac_channel_setup((struct device *)dev, &channel_cfg); + return z_impl_dac_channel_setup((const struct device *)dev, + &channel_cfg); } #include -static inline int z_vrfy_dac_write_value(struct device *dev, - uint8_t channel, uint32_t value) +static inline int z_vrfy_dac_write_value(const struct device *dev, + uint8_t channel, uint32_t value) { Z_OOPS(Z_SYSCALL_DRIVER_DAC(dev, write_value)); - return z_impl_dac_write_value((struct device *)dev, channel, value); + return z_impl_dac_write_value((const struct device *)dev, channel, + value); } #include diff --git a/drivers/dac/dac_mcux_dac.c b/drivers/dac/dac_mcux_dac.c index 9ae96f3f4bfc73..e16d0915eae630 100644 --- a/drivers/dac/dac_mcux_dac.c +++ b/drivers/dac/dac_mcux_dac.c @@ -24,7 +24,7 @@ struct mcux_dac_data { bool configured; }; -static int mcux_dac_channel_setup(struct device *dev, +static int mcux_dac_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) { const struct mcux_dac_config *config = dev->config; @@ -52,7 +52,8 @@ static int mcux_dac_channel_setup(struct device *dev, return 0; } -static int mcux_dac_write_value(struct device *dev, uint8_t channel, uint32_t value) +static int mcux_dac_write_value(const struct device *dev, uint8_t channel, + uint32_t value) { const struct mcux_dac_config *config = dev->config; struct mcux_dac_data *data = dev->data; @@ -81,7 +82,7 @@ static int mcux_dac_write_value(struct device *dev, uint8_t channel, uint32_t va return 0; } -static int mcux_dac_init(struct device *dev) +static int mcux_dac_init(const struct device *dev) { return 0; } diff --git a/drivers/dac/dac_mcux_dac32.c b/drivers/dac/dac_mcux_dac32.c index c6b6fd9ebdb0ef..b3d17257740dd7 100644 --- a/drivers/dac/dac_mcux_dac32.c +++ b/drivers/dac/dac_mcux_dac32.c @@ -25,7 +25,7 @@ struct mcux_dac32_data { bool configured; }; -static int mcux_dac32_channel_setup(struct device *dev, +static int mcux_dac32_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) { const struct mcux_dac32_config *config = dev->config; @@ -57,7 +57,8 @@ static int mcux_dac32_channel_setup(struct device *dev, return 0; } -static int mcux_dac32_write_value(struct device *dev, uint8_t channel, uint32_t value) +static int mcux_dac32_write_value(const struct device *dev, uint8_t channel, + uint32_t value) { const struct mcux_dac32_config *config = dev->config; struct mcux_dac32_data *data = dev->data; @@ -86,7 +87,7 @@ static int mcux_dac32_write_value(struct device *dev, uint8_t channel, uint32_t return 0; } -static int mcux_dac32_init(struct device *dev) +static int mcux_dac32_init(const struct device *dev) { return 0; } diff --git a/drivers/dac/dac_sam0.c b/drivers/dac/dac_sam0.c index a62cb67cc375e0..086a5380794af7 100644 --- a/drivers/dac/dac_sam0.c +++ b/drivers/dac/dac_sam0.c @@ -31,7 +31,7 @@ struct dac_sam0_cfg { #define DEV_CFG(dev) ((const struct dac_sam0_cfg *const)(dev)->config) /* Write to the DAC. */ -static int dac_sam0_write_value(struct device *dev, uint8_t channel, +static int dac_sam0_write_value(const struct device *dev, uint8_t channel, uint32_t value) { const struct dac_sam0_cfg *const cfg = DEV_CFG(dev); @@ -46,7 +46,7 @@ static int dac_sam0_write_value(struct device *dev, uint8_t channel, * Setup the channel. As the SAM0 has one fixed width channel, this validates * the input and does nothing else. */ -static int dac_sam0_channel_setup(struct device *dev, +static int dac_sam0_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) { if (channel_cfg->channel_id != 0) { @@ -60,7 +60,7 @@ static int dac_sam0_channel_setup(struct device *dev, } /* Initialise and enable the DAC. */ -static int dac_sam0_init(struct device *dev) +static int dac_sam0_init(const struct device *dev) { const struct dac_sam0_cfg *const cfg = DEV_CFG(dev); Dac *regs = cfg->regs; diff --git a/drivers/dac/dac_shell.c b/drivers/dac/dac_shell.c index 1a2346443e844e..b80365f979ddd7 100644 --- a/drivers/dac/dac_shell.c +++ b/drivers/dac/dac_shell.c @@ -30,7 +30,7 @@ static const struct args_index args_indx = { static int cmd_setup(const struct shell *shell, size_t argc, char **argv) { struct dac_channel_cfg cfg; - struct device *dac; + const struct device *dac; int err; dac = device_get_binding(argv[args_indx.device]); @@ -53,7 +53,7 @@ static int cmd_setup(const struct shell *shell, size_t argc, char **argv) static int cmd_write_value(const struct shell *shell, size_t argc, char **argv) { - struct device *dac; + const struct device *dac; uint8_t channel; uint32_t value; int err; diff --git a/drivers/dac/dac_stm32.c b/drivers/dac/dac_stm32.c index 1ffe0259093716..fb128191e85fb3 100644 --- a/drivers/dac/dac_stm32.c +++ b/drivers/dac/dac_stm32.c @@ -50,7 +50,7 @@ struct dac_stm32_data { uint8_t resolution; }; -static int dac_stm32_write_value(struct device *dev, +static int dac_stm32_write_value(const struct device *dev, uint8_t channel, uint32_t value) { struct dac_stm32_data *data = dev->data; @@ -73,7 +73,7 @@ static int dac_stm32_write_value(struct device *dev, return 0; } -static int dac_stm32_channel_setup(struct device *dev, +static int dac_stm32_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg) { struct dac_stm32_data *data = dev->data; @@ -107,12 +107,12 @@ static int dac_stm32_channel_setup(struct device *dev, return 0; } -static int dac_stm32_init(struct device *dev) +static int dac_stm32_init(const struct device *dev) { const struct dac_stm32_cfg *cfg = dev->config; /* enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); if (clock_control_on(clk, diff --git a/drivers/display/display_dummy.c b/drivers/display/display_dummy.c index 36a9499a6446d9..76009cd9dbebaf 100644 --- a/drivers/display/display_dummy.c +++ b/drivers/display/display_dummy.c @@ -14,7 +14,7 @@ struct dummy_display_data { static struct dummy_display_data dummy_display_data; -static int dummy_display_init(struct device *dev) +static int dummy_display_init(const struct device *dev) { struct dummy_display_data *disp_data = (struct dummy_display_data *)dev->data; diff --git a/drivers/display/display_ili9340.c b/drivers/display/display_ili9340.c index b5c93661393771..9b94eed18e8463 100644 --- a/drivers/display/display_ili9340.c +++ b/drivers/display/display_ili9340.c @@ -21,10 +21,10 @@ LOG_MODULE_REGISTER(display_ili9340); struct ili9340_data { #if DT_INST_NODE_HAS_PROP(0, reset_gpios) - struct device *reset_gpio; + const struct device *reset_gpio; #endif - struct device *command_data_gpio; - struct device *spi_dev; + const struct device *command_data_gpio; + const struct device *spi_dev; struct spi_config spi_config; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control cs_ctrl; @@ -47,7 +47,7 @@ static void ili9340_exit_sleep(struct ili9340_data *data) k_sleep(K_MSEC(120)); } -static int ili9340_init(struct device *dev) +static int ili9340_init(const struct device *dev) { struct ili9340_data *data = (struct ili9340_data *)dev->data; diff --git a/drivers/display/display_mcux_elcdif.c b/drivers/display/display_mcux_elcdif.c index 4e23ae170089a5..93eb33fa7b32fa 100644 --- a/drivers/display/display_mcux_elcdif.c +++ b/drivers/display/display_mcux_elcdif.c @@ -25,7 +25,7 @@ K_MEM_POOL_DEFINE(mcux_elcdif_pool, struct mcux_elcdif_config { LCDIF_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); elcdif_rgb_mode_config_t rgb_mode; enum display_pixel_format pixel_format; uint8_t bits_per_pixel; @@ -166,7 +166,7 @@ static void mcux_elcdif_get_capabilities(const struct device *dev, static void mcux_elcdif_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_elcdif_config *config = dev->config; struct mcux_elcdif_data *data = dev->data; uint32_t status; @@ -177,7 +177,7 @@ static void mcux_elcdif_isr(void *arg) k_sem_give(&data->sem); } -static int mcux_elcdif_init(struct device *dev) +static int mcux_elcdif_init(const struct device *dev) { const struct mcux_elcdif_config *config = dev->config; struct mcux_elcdif_data *data = dev->data; @@ -225,7 +225,7 @@ static const struct display_driver_api mcux_elcdif_api = { .set_orientation = mcux_elcdif_set_orientation, }; -static void mcux_elcdif_config_func_1(struct device *dev); +static void mcux_elcdif_config_func_1(const struct device *dev); static struct mcux_elcdif_config mcux_elcdif_config_1 = { .base = (LCDIF_Type *) DT_INST_REG_ADDR(0), @@ -260,7 +260,7 @@ DEVICE_AND_API_INIT(mcux_elcdif_1, DT_INST_LABEL(0), POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_elcdif_api); -static void mcux_elcdif_config_func_1(struct device *dev) +static void mcux_elcdif_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/display/display_sdl.c b/drivers/display/display_sdl.c index d979bbbab70860..394976fca9a0e3 100644 --- a/drivers/display/display_sdl.c +++ b/drivers/display/display_sdl.c @@ -26,7 +26,7 @@ struct sdl_display_data { static struct sdl_display_data sdl_display_data; -static int sdl_display_init(struct device *dev) +static int sdl_display_init(const struct device *dev) { struct sdl_display_data *disp_data = (struct sdl_display_data *)dev->data; diff --git a/drivers/display/display_st7789v.c b/drivers/display/display_st7789v.c index c6feb0db5aeb14..3e0b6d4931020a 100644 --- a/drivers/display/display_st7789v.c +++ b/drivers/display/display_st7789v.c @@ -37,16 +37,16 @@ static uint8_t st7789v_ram_param[] = DT_INST_PROP(0, ram_param); static uint8_t st7789v_rgb_param[] = DT_INST_PROP(0, rgb_param); struct st7789v_data { - struct device *spi_dev; + const struct device *spi_dev; struct spi_config spi_config; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control cs_ctrl; #endif #if DT_INST_NODE_HAS_PROP(0, reset_gpios) - struct device *reset_gpio; + const struct device *reset_gpio; #endif - struct device *cmd_data_gpio; + const struct device *cmd_data_gpio; uint16_t height; uint16_t width; @@ -334,7 +334,7 @@ static void st7789v_lcd_init(struct st7789v_data *p_st7789v) sizeof(st7789v_rgb_param)); } -static int st7789v_init(struct device *dev) +static int st7789v_init(const struct device *dev) { struct st7789v_data *data = (struct st7789v_data *)dev->data; @@ -408,7 +408,7 @@ static void st7789v_enter_sleep(struct st7789v_data *data) st7789v_transmit(data, ST7789V_CMD_SLEEP_IN, NULL, 0); } -static int st7789v_pm_control(struct device *dev, uint32_t ctrl_command, +static int st7789v_pm_control(const struct device *dev, uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/display/gd7965.c b/drivers/display/gd7965.c index 925e638ae90ab4..9d0f4fb3d547a8 100644 --- a/drivers/display/gd7965.c +++ b/drivers/display/gd7965.c @@ -57,10 +57,10 @@ LOG_MODULE_REGISTER(gd7965, CONFIG_DISPLAY_LOG_LEVEL); struct gd7965_data { - struct device *reset; - struct device *dc; - struct device *busy; - struct device *spi_dev; + const struct device *reset; + const struct device *dc; + const struct device *busy; + const struct device *spi_dev; struct spi_config spi_config; #if defined(GD7965_CS_CNTRL) struct spi_cs_control cs_ctrl; @@ -280,7 +280,7 @@ static int gd7965_set_pixel_format(const struct device *dev, return -ENOTSUP; } -static int gd7965_clear_and_write_buffer(struct device *dev, +static int gd7965_clear_and_write_buffer(const struct device *dev, uint8_t pattern, bool update) { struct display_buffer_descriptor desc = { @@ -312,7 +312,7 @@ static int gd7965_clear_and_write_buffer(struct device *dev, return 0; } -static int gd7965_controller_init(struct device *dev) +static int gd7965_controller_init(const struct device *dev) { struct gd7965_data *driver = dev->data; uint8_t tmp[GD7965_TRES_REG_LENGTH]; @@ -390,7 +390,7 @@ static int gd7965_controller_init(struct device *dev) return 0; } -static int gd7965_init(struct device *dev) +static int gd7965_init(const struct device *dev) { struct gd7965_data *driver = dev->data; diff --git a/drivers/display/grove_lcd_rgb.c b/drivers/display/grove_lcd_rgb.c index cc893de37692d9..34f189c75c5788 100644 --- a/drivers/display/grove_lcd_rgb.c +++ b/drivers/display/grove_lcd_rgb.c @@ -28,7 +28,7 @@ struct command { }; struct glcd_data { - struct device *i2c; + const struct device *i2c; uint8_t input_set; uint8_t display_switch; uint8_t function; @@ -85,7 +85,7 @@ static uint8_t color_define[][3] = { /******************************************** * PRIVATE FUNCTIONS *******************************************/ -static void rgb_reg_set(struct device * const i2c, uint8_t addr, uint8_t dta) +static void rgb_reg_set(const struct device *i2c, uint8_t addr, uint8_t dta) { uint8_t data[2] = { addr, dta }; @@ -102,7 +102,7 @@ static inline void sleep(uint32_t sleep_in_ms) /******************************************** * PUBLIC FUNCTIONS *******************************************/ -void glcd_print(struct device *port, char *data, uint32_t size) +void glcd_print(const struct device *port, char *data, uint32_t size) { const struct glcd_driver * const rom = (const struct glcd_driver *) port->config; @@ -117,7 +117,7 @@ void glcd_print(struct device *port, char *data, uint32_t size) } -void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row) +void glcd_cursor_pos_set(const struct device *port, uint8_t col, uint8_t row) { const struct glcd_driver * const rom = (const struct glcd_driver *) port->config; @@ -138,7 +138,7 @@ void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row) } -void glcd_clear(struct device *port) +void glcd_clear(const struct device *port) { const struct glcd_driver * const rom = (const struct glcd_driver *) port->config; @@ -151,7 +151,7 @@ void glcd_clear(struct device *port) } -void glcd_display_state_set(struct device *port, uint8_t opt) +void glcd_display_state_set(const struct device *port, uint8_t opt) { const struct glcd_driver * const rom = (const struct glcd_driver *) port->config; @@ -168,7 +168,7 @@ void glcd_display_state_set(struct device *port, uint8_t opt) } -uint8_t glcd_display_state_get(struct device *port) +uint8_t glcd_display_state_get(const struct device *port) { struct glcd_data *dev = port->data; @@ -176,7 +176,7 @@ uint8_t glcd_display_state_get(struct device *port) } -void glcd_input_state_set(struct device *port, uint8_t opt) +void glcd_input_state_set(const struct device *port, uint8_t opt) { const struct glcd_driver * const rom = port->config; struct glcd_data *dev = port->data; @@ -191,7 +191,7 @@ void glcd_input_state_set(struct device *port, uint8_t opt) } -uint8_t glcd_input_state_get(struct device *port) +uint8_t glcd_input_state_get(const struct device *port) { struct glcd_data *dev = port->data; @@ -199,7 +199,7 @@ uint8_t glcd_input_state_get(struct device *port) } -void glcd_color_select(struct device *port, uint8_t color) +void glcd_color_select(const struct device *port, uint8_t color) { if (color > 3) { LOG_WRN("selected color is too high a value"); @@ -211,7 +211,8 @@ void glcd_color_select(struct device *port, uint8_t color) } -void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b) +void glcd_color_set(const struct device *port, uint8_t r, uint8_t g, + uint8_t b) { struct glcd_data * const dev = port->data; @@ -221,7 +222,7 @@ void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b) } -void glcd_function_set(struct device *port, uint8_t opt) +void glcd_function_set(const struct device *port, uint8_t opt) { const struct glcd_driver * const rom = port->config; struct glcd_data *dev = port->data; @@ -237,7 +238,7 @@ void glcd_function_set(struct device *port, uint8_t opt) } -uint8_t glcd_function_get(struct device *port) +uint8_t glcd_function_get(const struct device *port) { struct glcd_data *dev = port->data; @@ -245,7 +246,7 @@ uint8_t glcd_function_get(struct device *port) } -int glcd_initialize(struct device *port) +int glcd_initialize(const struct device *port) { struct glcd_data *dev = port->data; uint8_t cmd; diff --git a/drivers/display/mb_display.c b/drivers/display/mb_display.c index 3b4f043451d82a..1e3568395f5ea8 100644 --- a/drivers/display/mb_display.c +++ b/drivers/display/mb_display.c @@ -82,7 +82,7 @@ #define SCROLL_DEFAULT_DURATION_MS 80 struct mb_display { - struct device *dev; /* GPIO device */ + const struct device *dev; /* GPIO device */ struct k_timer timer; /* Rendering timer */ @@ -426,7 +426,7 @@ struct mb_display *mb_display_get(void) return &display; } -static int mb_display_init(struct device *dev) +static int mb_display_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/display/ssd1306.c b/drivers/display/ssd1306.c index b42d7e5d8e0b75..4d5e65490e675b 100644 --- a/drivers/display/ssd1306.c +++ b/drivers/display/ssd1306.c @@ -47,8 +47,8 @@ LOG_MODULE_REGISTER(ssd1306, CONFIG_DISPLAY_LOG_LEVEL); #endif struct ssd1306_data { - struct device *reset; - struct device *i2c; + const struct device *reset; + const struct device *i2c; uint8_t contrast; uint8_t scan_mode; }; @@ -77,7 +77,7 @@ static inline int ssd1306_reg_update(struct ssd1306_data *driver, uint8_t reg, reg, mask, val); } -static inline int ssd1306_set_panel_orientation(struct device *dev) +static inline int ssd1306_set_panel_orientation(const struct device *dev) { struct ssd1306_data *driver = dev->data; uint8_t cmd_buf[] = { @@ -95,7 +95,7 @@ static inline int ssd1306_set_panel_orientation(struct device *dev) DT_INST_REG_ADDR(0)); } -static inline int ssd1306_set_timing_setting(struct device *dev) +static inline int ssd1306_set_timing_setting(const struct device *dev) { struct ssd1306_data *driver = dev->data; uint8_t cmd_buf[] = { @@ -117,7 +117,7 @@ static inline int ssd1306_set_timing_setting(struct device *dev) DT_INST_REG_ADDR(0)); } -static inline int ssd1306_set_hardware_config(struct device *dev) +static inline int ssd1306_set_hardware_config(const struct device *dev) { struct ssd1306_data *driver = dev->data; uint8_t cmd_buf[] = { @@ -350,7 +350,7 @@ static int ssd1306_set_pixel_format(const struct device *dev, return -ENOTSUP; } -static int ssd1306_init_device(struct device *dev) +static int ssd1306_init_device(const struct device *dev) { struct ssd1306_data *driver = dev->data; @@ -410,7 +410,7 @@ static int ssd1306_init_device(struct device *dev) return 0; } -static int ssd1306_init(struct device *dev) +static int ssd1306_init(const struct device *dev) { struct ssd1306_data *driver = dev->data; diff --git a/drivers/display/ssd16xx.c b/drivers/display/ssd16xx.c index 676521e0a4ec8e..d23e34d7cfe95a 100644 --- a/drivers/display/ssd16xx.c +++ b/drivers/display/ssd16xx.c @@ -59,10 +59,10 @@ LOG_MODULE_REGISTER(ssd16xx); #define SSD16XX_TR_SCALE_FACTOR 256U struct ssd16xx_data { - struct device *reset; - struct device *dc; - struct device *busy; - struct device *spi_dev; + const struct device *reset; + const struct device *dc; + const struct device *busy; + const struct device *spi_dev; struct spi_config spi_config; #if defined(SSD16XX_CS_CNTRL) struct spi_cs_control cs_ctrl; @@ -384,7 +384,7 @@ static int ssd16xx_set_pixel_format(const struct device *dev, return -ENOTSUP; } -static int ssd16xx_clear_cntlr_mem(struct device *dev, uint8_t ram_cmd, +static int ssd16xx_clear_cntlr_mem(const struct device *dev, uint8_t ram_cmd, bool update) { struct ssd16xx_data *driver = dev->data; @@ -433,7 +433,7 @@ static int ssd16xx_clear_cntlr_mem(struct device *dev, uint8_t ram_cmd, return 0; } -static inline int ssd16xx_load_ws_from_otp(struct device *dev) +static inline int ssd16xx_load_ws_from_otp(const struct device *dev) { struct ssd16xx_data *driver = dev->data; uint8_t tmp[2]; @@ -500,7 +500,7 @@ static inline int ssd16xx_load_ws_from_otp(struct device *dev) #endif } -static int ssd16xx_load_ws_initial(struct device *dev) +static int ssd16xx_load_ws_initial(const struct device *dev) { #if DT_INST_NODE_HAS_PROP(0, lut_initial) struct ssd16xx_data *driver = dev->data; @@ -519,7 +519,7 @@ static int ssd16xx_load_ws_initial(struct device *dev) return 0; } -static int ssd16xx_load_ws_default(struct device *dev) +static int ssd16xx_load_ws_default(const struct device *dev) { #if DT_INST_NODE_HAS_PROP(0, lut_default) struct ssd16xx_data *driver = dev->data; @@ -536,7 +536,7 @@ static int ssd16xx_load_ws_default(struct device *dev) return 0; } -static int ssd16xx_controller_init(struct device *dev) +static int ssd16xx_controller_init(const struct device *dev) { int err; uint8_t tmp[3]; @@ -641,7 +641,7 @@ static int ssd16xx_controller_init(struct device *dev) return ssd16xx_clear_cntlr_mem(dev, SSD16XX_CMD_WRITE_RAM, true); } -static int ssd16xx_init(struct device *dev) +static int ssd16xx_init(const struct device *dev) { struct ssd16xx_data *driver = dev->data; diff --git a/drivers/dma/dma_dw.c b/drivers/dma/dma_dw.c index a42278e3f09e64..9ceec285424bd7 100644 --- a/drivers/dma/dma_dw.c +++ b/drivers/dma/dma_dw.c @@ -55,7 +55,7 @@ static ALWAYS_INLINE uint32_t dw_read(uint32_t dma_base, uint32_t reg) static void dw_dma_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); struct dw_dma_dev_data *const dev_data = DEV_DATA(dev); struct dma_chan_data *chan_data; @@ -116,7 +116,7 @@ static void dw_dma_isr(void *arg) } } -static int dw_dma_config(struct device *dev, uint32_t channel, +static int dw_dma_config(const struct device *dev, uint32_t channel, struct dma_config *cfg) { struct dw_dma_dev_data *const dev_data = DEV_DATA(dev); @@ -250,8 +250,8 @@ static int dw_dma_config(struct device *dev, uint32_t channel, return 0; } -static int dw_dma_reload(struct device *dev, uint32_t channel, - uint32_t src, uint32_t dst, size_t size) +static int dw_dma_reload(const struct device *dev, uint32_t channel, + uint32_t src, uint32_t dst, size_t size) { struct dw_dma_dev_data *const dev_data = DEV_DATA(dev); const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -269,7 +269,7 @@ static int dw_dma_reload(struct device *dev, uint32_t channel, return 0; } -static int dw_dma_transfer_start(struct device *dev, uint32_t channel) +static int dw_dma_transfer_start(const struct device *dev, uint32_t channel) { const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -283,7 +283,7 @@ static int dw_dma_transfer_start(struct device *dev, uint32_t channel) return 0; } -static int dw_dma_transfer_stop(struct device *dev, uint32_t channel) +static int dw_dma_transfer_stop(const struct device *dev, uint32_t channel) { const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -296,7 +296,7 @@ static int dw_dma_transfer_stop(struct device *dev, uint32_t channel) return 0; } -static void dw_dma_setup(struct device *dev) +static void dw_dma_setup(const struct device *dev) { const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); struct dw_dma_dev_data *const dev_data = DEV_DATA(dev); @@ -339,7 +339,7 @@ static void dw_dma_setup(struct device *dev) } } -static int dw_dma_init(struct device *dev) +static int dw_dma_init(const struct device *dev) { const struct dw_dma_dev_cfg *const dev_cfg = DEV_CFG(dev); diff --git a/drivers/dma/dma_handlers.c b/drivers/dma/dma_handlers.c index 5cae00927bbdd3..6e74685e430584 100644 --- a/drivers/dma/dma_handlers.c +++ b/drivers/dma/dma_handlers.c @@ -11,16 +11,16 @@ * the validity of the channel ID and returning -errno if it's bogus */ -static inline int z_vrfy_dma_start(struct device *dev, uint32_t channel) +static inline int z_vrfy_dma_start(const struct device *dev, uint32_t channel) { Z_OOPS(Z_SYSCALL_DRIVER_DMA(dev, start)); - return z_impl_dma_start((struct device *)dev, channel); + return z_impl_dma_start((const struct device *)dev, channel); } #include -static inline int z_vrfy_dma_stop(struct device *dev, uint32_t channel) +static inline int z_vrfy_dma_stop(const struct device *dev, uint32_t channel) { Z_OOPS(Z_SYSCALL_DRIVER_DMA(dev, stop)); - return z_impl_dma_stop((struct device *)dev, channel); + return z_impl_dma_stop((const struct device *)dev, channel); } #include diff --git a/drivers/dma/dma_mcux_edma.c b/drivers/dma/dma_mcux_edma.c index 753278118c547f..1da8bb252de248 100644 --- a/drivers/dma/dma_mcux_edma.c +++ b/drivers/dma/dma_mcux_edma.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(dma_mcux_edma, CONFIG_DMA_LOG_LEVEL); struct dma_mcux_edma_config { DMA_Type *base; DMAMUX_Type *dmamux_base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; static __aligned(32) edma_tcd_t @@ -37,7 +37,7 @@ static __aligned(32) edma_tcd_t struct call_back { edma_transfer_config_t transferConfig; edma_handle_t edma_handle; - struct device *dev; + const struct device *dev; void *user_data; dma_callback_t dma_callback; enum dma_channel_direction dir; @@ -137,7 +137,7 @@ static void channel_irq(edma_handle_t *handle) static void dma_mcux_edma_irq_handler(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; int i = 0; LOG_DBG("IRQ CALLED"); @@ -169,7 +169,7 @@ static void dma_mcux_edma_error_irq_handler(void *arg) { int i = 0; uint32_t flag = 0; - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; for (i = 0; i < DT_INST_PROP(0, dma_channels); i++) { if (DEV_CHANNEL_DATA(dev, i)->busy) { @@ -188,7 +188,7 @@ static void dma_mcux_edma_error_irq_handler(void *arg) } /* Configure a channel */ -static int dma_mcux_edma_configure(struct device *dev, uint32_t channel, +static int dma_mcux_edma_configure(const struct device *dev, uint32_t channel, struct dma_config *config) { edma_handle_t *p_handle = DEV_EDMA_HANDLE(dev, channel); @@ -338,7 +338,7 @@ static int dma_mcux_edma_configure(struct device *dev, uint32_t channel, return 0; } -static int dma_mcux_edma_start(struct device *dev, uint32_t channel) +static int dma_mcux_edma_start(const struct device *dev, uint32_t channel) { struct call_back *data = DEV_CHANNEL_DATA(dev, channel); @@ -350,7 +350,7 @@ static int dma_mcux_edma_start(struct device *dev, uint32_t channel) return 0; } -static int dma_mcux_edma_stop(struct device *dev, uint32_t channel) +static int dma_mcux_edma_stop(const struct device *dev, uint32_t channel) { struct dma_mcux_edma_data *data = DEV_DATA(dev); @@ -366,7 +366,7 @@ static int dma_mcux_edma_stop(struct device *dev, uint32_t channel) return 0; } -static int dma_mcux_edma_reload(struct device *dev, uint32_t channel, +static int dma_mcux_edma_reload(const struct device *dev, uint32_t channel, uint32_t src, uint32_t dst, size_t size) { struct call_back *data = DEV_CHANNEL_DATA(dev, channel); @@ -377,7 +377,8 @@ static int dma_mcux_edma_reload(struct device *dev, uint32_t channel, return 0; } -static int dma_mcux_edma_get_status(struct device *dev, uint32_t channel, +static int dma_mcux_edma_get_status(const struct device *dev, + uint32_t channel, struct dma_status *status) { edma_tcd_t *tcdRegs; @@ -411,7 +412,7 @@ static const struct dma_driver_api dma_mcux_edma_api = { .get_status = dma_mcux_edma_get_status, }; -static int dma_mcux_edma_init(struct device *dev) +static int dma_mcux_edma_init(const struct device *dev) { edma_config_t userConfig = { 0 }; @@ -425,7 +426,7 @@ static int dma_mcux_edma_init(struct device *dev) return 0; } -static void dma_imx_config_func_0(struct device *dev); +static void dma_imx_config_func_0(const struct device *dev); static const struct dma_mcux_edma_config dma_config_0 = { .base = (DMA_Type *)DT_INST_REG_ADDR(0), @@ -441,7 +442,7 @@ DEVICE_AND_API_INIT(dma_mcux_edma_0, CONFIG_DMA_0_NAME, &dma_mcux_edma_init, &dma_data, &dma_config_0, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &dma_mcux_edma_api); -void dma_imx_config_func_0(struct device *dev) +void dma_imx_config_func_0(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/dma/dma_mcux_lpc.c b/drivers/dma/dma_mcux_lpc.c index 0327bfea575d8b..e8378f86058b6a 100644 --- a/drivers/dma/dma_mcux_lpc.c +++ b/drivers/dma/dma_mcux_lpc.c @@ -22,13 +22,13 @@ LOG_MODULE_REGISTER(dma_mcux_lpc, CONFIG_DMA_LOG_LEVEL); struct dma_mcux_lpc_config { DMA_Type *base; uint32_t num_of_channels; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct call_back { dma_transfer_config_t *transferConfig; dma_handle_t dma_handle; - struct device *dev; + const struct device *dev; void *user_data; dma_callback_t dma_callback; enum dma_channel_direction dir; @@ -75,7 +75,7 @@ static void nxp_lpc_dma_callback(dma_handle_t *handle, void *param, /* Handles DMA interrupts and dispatches to the individual channel */ static void dma_mcux_lpc_irq_handler(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; DMA_IRQHandle(DEV_BASE(dev)); /* @@ -89,8 +89,8 @@ static void dma_mcux_lpc_irq_handler(void *arg) } /* Configure a channel */ -static int dma_mcux_lpc_configure(struct device *dev, uint32_t channel, - struct dma_config *config) +static int dma_mcux_lpc_configure(const struct device *dev, uint32_t channel, + struct dma_config *config) { dma_handle_t *p_handle; struct call_back *data; @@ -240,7 +240,7 @@ static int dma_mcux_lpc_configure(struct device *dev, uint32_t channel, return 0; } -static int dma_mcux_lpc_start(struct device *dev, uint32_t channel) +static int dma_mcux_lpc_start(const struct device *dev, uint32_t channel) { uint32_t virtual_channel = DEV_DATA(dev)->channel_index[channel]; struct call_back *data = DEV_CHANNEL_DATA(dev, virtual_channel); @@ -252,7 +252,7 @@ static int dma_mcux_lpc_start(struct device *dev, uint32_t channel) return 0; } -static int dma_mcux_lpc_stop(struct device *dev, uint32_t channel) +static int dma_mcux_lpc_stop(const struct device *dev, uint32_t channel) { uint32_t virtual_channel = DEV_DATA(dev)->channel_index[channel]; struct call_back *data = DEV_CHANNEL_DATA(dev, virtual_channel); @@ -265,8 +265,8 @@ static int dma_mcux_lpc_stop(struct device *dev, uint32_t channel) return 0; } -static int dma_mcux_lpc_reload(struct device *dev, uint32_t channel, - uint32_t src, uint32_t dst, size_t size) +static int dma_mcux_lpc_reload(const struct device *dev, uint32_t channel, + uint32_t src, uint32_t dst, size_t size) { uint32_t virtual_channel = DEV_DATA(dev)->channel_index[channel]; struct call_back *data = DEV_CHANNEL_DATA(dev, virtual_channel); @@ -277,8 +277,8 @@ static int dma_mcux_lpc_reload(struct device *dev, uint32_t channel, return 0; } -static int dma_mcux_lpc_get_status(struct device *dev, uint32_t channel, - struct dma_status *status) +static int dma_mcux_lpc_get_status(const struct device *dev, uint32_t channel, + struct dma_status *status) { uint32_t virtual_channel = DEV_DATA(dev)->channel_index[channel]; struct call_back *data = DEV_CHANNEL_DATA(dev, virtual_channel); @@ -297,7 +297,7 @@ static int dma_mcux_lpc_get_status(struct device *dev, uint32_t channel, return 0; } -static int dma_mcux_lpc_init(struct device *dev) +static int dma_mcux_lpc_init(const struct device *dev) { struct dma_mcux_lpc_dma_data *data = DEV_DATA(dev); int size_channel_data; @@ -357,7 +357,7 @@ static const struct dma_driver_api dma_mcux_lpc_api = { }; #define DMA_MCUX_LPC_CONFIG_FUNC(n) \ - static void dma_mcux_lpc_config_func_##n(struct device *dev) \ + static void dma_mcux_lpc_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/dma/dma_nios2_msgdma.c b/drivers/dma/dma_nios2_msgdma.c index 9edd63a8eadfac..7f170786e7f673 100644 --- a/drivers/dma/dma_nios2_msgdma.c +++ b/drivers/dma/dma_nios2_msgdma.c @@ -35,7 +35,7 @@ struct nios2_msgdma_dev_cfg { static void nios2_msgdma_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct nios2_msgdma_dev_cfg *cfg = DEV_CFG(dev); /* Call Altera HAL driver ISR */ @@ -44,7 +44,7 @@ static void nios2_msgdma_isr(void *arg) static void nios2_msgdma_callback(void *context) { - struct device *dev = (struct device *)context; + const struct device *dev = (const struct device *)context; struct nios2_msgdma_dev_cfg *dev_cfg = DEV_CFG(dev); int err_code; uint32_t status; @@ -64,7 +64,7 @@ static void nios2_msgdma_callback(void *context) dev_cfg->dma_callback(dev, dev_cfg->user_data, 0, err_code); } -static int nios2_msgdma_config(struct device *dev, uint32_t channel, +static int nios2_msgdma_config(const struct device *dev, uint32_t channel, struct dma_config *cfg) { struct nios2_msgdma_dev_cfg *dev_cfg = DEV_CFG(dev); @@ -149,7 +149,8 @@ static int nios2_msgdma_config(struct device *dev, uint32_t channel, return status; } -static int nios2_msgdma_transfer_start(struct device *dev, uint32_t channel) +static int nios2_msgdma_transfer_start(const struct device *dev, + uint32_t channel) { struct nios2_msgdma_dev_cfg *cfg = DEV_CFG(dev); int status; @@ -172,7 +173,8 @@ static int nios2_msgdma_transfer_start(struct device *dev, uint32_t channel) return status; } -static int nios2_msgdma_transfer_stop(struct device *dev, uint32_t channel) +static int nios2_msgdma_transfer_stop(const struct device *dev, + uint32_t channel) { struct nios2_msgdma_dev_cfg *cfg = DEV_CFG(dev); int ret = -EIO; @@ -205,7 +207,7 @@ static const struct dma_driver_api nios2_msgdma_driver_api = { /* DMA0 */ DEVICE_DECLARE(dma0_nios2); -static int nios2_msgdma0_initialize(struct device *dev) +static int nios2_msgdma0_initialize(const struct device *dev) { struct nios2_msgdma_dev_cfg *dev_cfg = DEV_CFG(dev); diff --git a/drivers/dma/dma_pl330.c b/drivers/dma/dma_pl330.c index ed5ec5fa5cf840..7b2dc641412e2a 100644 --- a/drivers/dma/dma_pl330.c +++ b/drivers/dma/dma_pl330.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(dma_pl330); #define BYTE_WIDTH(burst_size) (1 << (burst_size)) -static int dma_pl330_submit(struct device *dev, uint64_t dst, +static int dma_pl330_submit(const struct device *dev, uint64_t dst, uint64_t src, uint32_t channel, uint32_t size); static void dma_pl330_get_counter(struct dma_pl330_ch_internal *ch_handle, @@ -162,7 +162,7 @@ static inline void dma_pl330_gen_op(uint8_t opcode, uint32_t addr, uint32_t val) sys_write8(val, addr + 1); } -static int dma_pl330_setup_ch(struct device *dev, +static int dma_pl330_setup_ch(const struct device *dev, struct dma_pl330_ch_internal *ch_dat, int ch) { @@ -267,7 +267,7 @@ static int dma_pl330_setup_ch(struct device *dev, return 0; } -static int dma_pl330_start_dma_ch(struct device *dev, +static int dma_pl330_start_dma_ch(const struct device *dev, uint32_t reg_base, int ch, int secure) { struct dma_pl330_dev_data *const dev_data = DEV_DATA(dev); @@ -321,7 +321,7 @@ static int dma_pl330_wait(uint32_t reg_base, int ch) return 0; } -static int dma_pl330_xfer(struct device *dev, uint64_t dst, +static int dma_pl330_xfer(const struct device *dev, uint64_t dst, uint64_t src, uint32_t size, uint32_t channel, uint32_t *xfer_size) { @@ -383,7 +383,7 @@ static int dma_pl330_xfer(struct device *dev, uint64_t dst, } #if CONFIG_DMA_64BIT -static int dma_pl330_handle_boundary(struct device *dev, uint64_t dst, +static int dma_pl330_handle_boundary(const struct device *dev, uint64_t dst, uint64_t src, uint32_t channel, uint32_t size) { @@ -431,7 +431,8 @@ static int dma_pl330_handle_boundary(struct device *dev, uint64_t dst, } #endif -static int dma_pl330_submit(struct device *dev, uint64_t dst, uint64_t src, +static int dma_pl330_submit(const struct device *dev, uint64_t dst, + uint64_t src, uint32_t channel, uint32_t size) { int ret; @@ -469,7 +470,7 @@ static int dma_pl330_submit(struct device *dev, uint64_t dst, uint64_t src, return 0; } -static int dma_pl330_configure(struct device *dev, uint32_t channel, +static int dma_pl330_configure(const struct device *dev, uint32_t channel, struct dma_config *cfg) { struct dma_pl330_dev_data *const dev_data = DEV_DATA(dev); @@ -519,7 +520,8 @@ static int dma_pl330_configure(struct device *dev, uint32_t channel, return 0; } -static int dma_pl330_transfer_start(struct device *dev, uint32_t channel) +static int dma_pl330_transfer_start(const struct device *dev, + uint32_t channel) { struct dma_pl330_dev_data *const dev_data = DEV_DATA(dev); struct dma_pl330_ch_config *channel_cfg; @@ -547,7 +549,7 @@ static int dma_pl330_transfer_start(struct device *dev, uint32_t channel) return 0; } -static int dma_pl330_transfer_stop(struct device *dev, uint32_t channel) +static int dma_pl330_transfer_stop(const struct device *dev, uint32_t channel) { if (channel >= MAX_DMA_CHANNELS) { return -EINVAL; @@ -557,7 +559,7 @@ static int dma_pl330_transfer_stop(struct device *dev, uint32_t channel) return 0; } -static int dma_pl330_initialize(struct device *dev) +static int dma_pl330_initialize(const struct device *dev) { const struct dma_pl330_config *const dev_cfg = DEV_CFG(dev); struct dma_pl330_dev_data *const dev_data = DEV_DATA(dev); diff --git a/drivers/dma/dma_sam0.c b/drivers/dma/dma_sam0.c index 538b3fdd23a043..b0504481dc88f4 100644 --- a/drivers/dma/dma_sam0.c +++ b/drivers/dma/dma_sam0.c @@ -33,7 +33,7 @@ struct dma_sam0_data { /* Handles DMA interrupts and dispatches to the individual channel */ static void dma_sam0_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct dma_sam0_data *data = DEV_DATA(dev); struct dma_sam0_channel *chdata; uint16_t pend = DMA_REGS->INTPEND.reg; @@ -63,7 +63,7 @@ static void dma_sam0_isr(void *arg) } /* Configure a channel */ -static int dma_sam0_config(struct device *dev, uint32_t channel, +static int dma_sam0_config(const struct device *dev, uint32_t channel, struct dma_config *config) { struct dma_sam0_data *data = DEV_DATA(dev); @@ -265,7 +265,7 @@ static int dma_sam0_config(struct device *dev, uint32_t channel, return -EINVAL; } -static int dma_sam0_start(struct device *dev, uint32_t channel) +static int dma_sam0_start(const struct device *dev, uint32_t channel) { int key = irq_lock(); @@ -296,7 +296,7 @@ static int dma_sam0_start(struct device *dev, uint32_t channel) return 0; } -static int dma_sam0_stop(struct device *dev, uint32_t channel) +static int dma_sam0_stop(const struct device *dev, uint32_t channel) { int key = irq_lock(); @@ -316,7 +316,7 @@ static int dma_sam0_stop(struct device *dev, uint32_t channel) return 0; } -static int dma_sam0_reload(struct device *dev, uint32_t channel, +static int dma_sam0_reload(const struct device *dev, uint32_t channel, uint32_t src, uint32_t dst, size_t size) { struct dma_sam0_data *data = DEV_DATA(dev); @@ -360,7 +360,7 @@ static int dma_sam0_reload(struct device *dev, uint32_t channel, return -EINVAL; } -static int dma_sam0_get_status(struct device *dev, uint32_t channel, +static int dma_sam0_get_status(const struct device *dev, uint32_t channel, struct dma_status *stat) { struct dma_sam0_data *data = DEV_DATA(dev); @@ -407,7 +407,7 @@ DEVICE_DECLARE(dma_sam0_0); irq_enable(DT_INST_IRQ_BY_IDX(0, n, irq)); \ } while (0) -static int dma_sam0_init(struct device *dev) +static int dma_sam0_init(const struct device *dev) { struct dma_sam0_data *data = DEV_DATA(dev); diff --git a/drivers/dma/dma_sam_xdmac.c b/drivers/dma/dma_sam_xdmac.c index dec24e09bb0cdd..1d140decdc8b38 100644 --- a/drivers/dma/dma_sam_xdmac.c +++ b/drivers/dma/dma_sam_xdmac.c @@ -53,7 +53,7 @@ struct sam_xdmac_dev_data { static void sam_xdmac_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct sam_xdmac_dev_cfg *const dev_cfg = DEV_CFG(dev); struct sam_xdmac_dev_data *const dev_data = DEV_DATA(dev); Xdmac *const xdmac = dev_cfg->regs; @@ -82,7 +82,7 @@ static void sam_xdmac_isr(void *arg) } } -int sam_xdmac_channel_configure(struct device *dev, uint32_t channel, +int sam_xdmac_channel_configure(const struct device *dev, uint32_t channel, struct sam_xdmac_channel_config *param) { const struct sam_xdmac_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -124,7 +124,7 @@ int sam_xdmac_channel_configure(struct device *dev, uint32_t channel, return 0; } -int sam_xdmac_transfer_configure(struct device *dev, uint32_t channel, +int sam_xdmac_transfer_configure(const struct device *dev, uint32_t channel, struct sam_xdmac_transfer_config *param) { const struct sam_xdmac_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -176,7 +176,7 @@ int sam_xdmac_transfer_configure(struct device *dev, uint32_t channel, return 0; } -static int sam_xdmac_config(struct device *dev, uint32_t channel, +static int sam_xdmac_config(const struct device *dev, uint32_t channel, struct dma_config *cfg) { struct sam_xdmac_dev_data *const dev_data = DEV_DATA(dev); @@ -270,7 +270,7 @@ static int sam_xdmac_config(struct device *dev, uint32_t channel, return ret; } -int sam_xdmac_transfer_start(struct device *dev, uint32_t channel) +int sam_xdmac_transfer_start(const struct device *dev, uint32_t channel) { Xdmac *const xdmac = DEV_CFG(dev)->regs; @@ -291,7 +291,7 @@ int sam_xdmac_transfer_start(struct device *dev, uint32_t channel) return 0; } -int sam_xdmac_transfer_stop(struct device *dev, uint32_t channel) +int sam_xdmac_transfer_stop(const struct device *dev, uint32_t channel) { Xdmac *const xdmac = DEV_CFG(dev)->regs; @@ -316,7 +316,7 @@ int sam_xdmac_transfer_stop(struct device *dev, uint32_t channel) return 0; } -static int sam_xdmac_initialize(struct device *dev) +static int sam_xdmac_initialize(const struct device *dev) { const struct sam_xdmac_dev_cfg *const dev_cfg = DEV_CFG(dev); Xdmac *const xdmac = dev_cfg->regs; diff --git a/drivers/dma/dma_stm32.c b/drivers/dma/dma_stm32.c index 02237ed6144ea1..776a61f98546c8 100644 --- a/drivers/dma/dma_stm32.c +++ b/drivers/dma/dma_stm32.c @@ -36,7 +36,7 @@ static uint32_t table_p_size[] = { LL_DMA_PDATAALIGN_WORD, }; -static void dma_stm32_dump_stream_irq(struct device *dev, uint32_t id) +static void dma_stm32_dump_stream_irq(const struct device *dev, uint32_t id) { const struct dma_stm32_config *config = dev->config; DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); @@ -44,7 +44,7 @@ static void dma_stm32_dump_stream_irq(struct device *dev, uint32_t id) stm32_dma_dump_stream_irq(dma, id); } -static void dma_stm32_clear_stream_irq(struct device *dev, uint32_t id) +static void dma_stm32_clear_stream_irq(const struct device *dev, uint32_t id) { const struct dma_stm32_config *config = dev->config; DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); @@ -56,7 +56,7 @@ static void dma_stm32_clear_stream_irq(struct device *dev, uint32_t id) static void dma_stm32_irq_handler(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct dma_stm32_data *data = dev->data; const struct dma_stm32_config *config = dev->config; DMA_TypeDef *dma = (DMA_TypeDef *)(config->base); @@ -233,7 +233,7 @@ static int dma_stm32_get_periph_increment(enum dma_addr_adj increment, } #ifdef CONFIG_DMAMUX_STM32 -int dma_stm32_configure(struct device *dev, uint32_t id, +int dma_stm32_configure(const struct device *dev, uint32_t id, struct dma_config *config) #else static int dma_stm32_configure(struct device *dev, uint32_t id, @@ -470,7 +470,7 @@ static int dma_stm32_disable_stream(DMA_TypeDef *dma, uint32_t id) } #ifdef CONFIG_DMAMUX_STM32 -int dma_stm32_reload(struct device *dev, uint32_t id, +int dma_stm32_reload(const struct device *dev, uint32_t id, uint32_t src, uint32_t dst, size_t size) #else static int dma_stm32_reload(struct device *dev, uint32_t id, @@ -519,7 +519,7 @@ static int dma_stm32_reload(struct device *dev, uint32_t id, } #ifdef CONFIG_DMAMUX_STM32 -int dma_stm32_start(struct device *dev, uint32_t id) +int dma_stm32_start(const struct device *dev, uint32_t id) #else static int dma_stm32_start(struct device *dev, uint32_t id) #endif /* CONFIG_DMAMUX_STM32 */ @@ -544,7 +544,7 @@ static int dma_stm32_start(struct device *dev, uint32_t id) } #ifdef CONFIG_DMAMUX_STM32 -int dma_stm32_stop(struct device *dev, uint32_t id) +int dma_stm32_stop(const struct device *dev, uint32_t id) #else static int dma_stm32_stop(struct device *dev, uint32_t id) #endif /* CONFIG_DMAMUX_STM32 */ @@ -580,11 +580,11 @@ static int dma_stm32_stop(struct device *dev, uint32_t id) struct k_mem_block block; -static int dma_stm32_init(struct device *dev) +static int dma_stm32_init(const struct device *dev) { struct dma_stm32_data *data = dev->data; const struct dma_stm32_config *config = dev->config; - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); if (clock_control_on(clk, @@ -620,7 +620,7 @@ static int dma_stm32_init(struct device *dev) return 0; } -static int dma_stm32_get_status(struct device *dev, uint32_t id, +static int dma_stm32_get_status(const struct device *dev, uint32_t id, struct dma_status *stat) { const struct dma_stm32_config *config = dev->config; @@ -692,7 +692,7 @@ do { \ #if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) DMA_INIT(0); -static void dma_stm32_config_irq_0(struct device *dev) +static void dma_stm32_config_irq_0(const struct device *dev) { struct dma_stm32_data *data = dev->data; @@ -718,7 +718,7 @@ static void dma_stm32_config_irq_0(struct device *dev) #if DT_NODE_HAS_STATUS(DT_DRV_INST(1), okay) DMA_INIT(1); -static void dma_stm32_config_irq_1(struct device *dev) +static void dma_stm32_config_irq_1(const struct device *dev) { struct dma_stm32_data *data = dev->data; diff --git a/drivers/dma/dma_stm32.h b/drivers/dma/dma_stm32.h index bdf4185b1f6d9e..363677509ef370 100644 --- a/drivers/dma/dma_stm32.h +++ b/drivers/dma/dma_stm32.h @@ -30,7 +30,7 @@ struct dma_stm32_data { struct dma_stm32_config { struct stm32_pclken pclken; - void (*config_irq)(struct device *dev); + void (*config_irq)(const struct device *dev); bool support_m2m; uint32_t base; }; @@ -75,12 +75,12 @@ uint32_t stm32_dma_get_pburst(struct dma_config *config, bool source_periph); #ifdef CONFIG_DMAMUX_STM32 /* dma_stm32_ api functions are exported to the dmamux_stm32 */ -int dma_stm32_configure(struct device *dev, uint32_t id, +int dma_stm32_configure(const struct device *dev, uint32_t id, struct dma_config *config); -int dma_stm32_reload(struct device *dev, uint32_t id, +int dma_stm32_reload(const struct device *dev, uint32_t id, uint32_t src, uint32_t dst, size_t size); -int dma_stm32_start(struct device *dev, uint32_t id); -int dma_stm32_stop(struct device *dev, uint32_t id); +int dma_stm32_start(const struct device *dev, uint32_t id); +int dma_stm32_stop(const struct device *dev, uint32_t id); #endif /* CONFIG_DMAMUX_STM32 */ #endif /* DMA_STM32_H_*/ diff --git a/drivers/dma/dmamux_stm32.c b/drivers/dma/dmamux_stm32.c index 35905920288ef3..37c9cd171ee818 100644 --- a/drivers/dma/dmamux_stm32.c +++ b/drivers/dma/dmamux_stm32.c @@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(dmamux_stm32, CONFIG_DMA_LOG_LEVEL); #define DT_DRV_COMPAT st_stm32_dmamux -int dmamux_stm32_configure(struct device *dev, uint32_t id, +int dmamux_stm32_configure(const struct device *dev, uint32_t id, struct dma_config *config) { /* device is the dmamux, id is the dmamux channel from 0 */ @@ -75,7 +75,7 @@ int dmamux_stm32_configure(struct device *dev, uint32_t id, return 0; } -int dmamux_stm32_start(struct device *dev, uint32_t id) +int dmamux_stm32_start(const struct device *dev, uint32_t id) { const struct dmamux_stm32_config *dev_config = dev->config; struct dmamux_stm32_data *data = dev->data; @@ -95,7 +95,7 @@ int dmamux_stm32_start(struct device *dev, uint32_t id) return 0; } -int dmamux_stm32_stop(struct device *dev, uint32_t id) +int dmamux_stm32_stop(const struct device *dev, uint32_t id) { const struct dmamux_stm32_config *dev_config = dev->config; struct dmamux_stm32_data *data = dev->data; @@ -115,7 +115,7 @@ int dmamux_stm32_stop(struct device *dev, uint32_t id) return 0; } -int dmamux_stm32_reload(struct device *dev, uint32_t id, +int dmamux_stm32_reload(const struct device *dev, uint32_t id, uint32_t src, uint32_t dst, size_t size) { const struct dmamux_stm32_config *dev_config = dev->config; @@ -137,11 +137,11 @@ int dmamux_stm32_reload(struct device *dev, uint32_t id, return 0; } -static int dmamux_stm32_init(struct device *dev) +static int dmamux_stm32_init(const struct device *dev) { struct dmamux_stm32_data *data = dev->data; const struct dmamux_stm32_config *config = dev->config; - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); if (clock_control_on(clk, diff --git a/drivers/dma/dmamux_stm32.h b/drivers/dma/dmamux_stm32.h index 1cb19f3781e043..f3e4bfbd533375 100644 --- a/drivers/dma/dmamux_stm32.h +++ b/drivers/dma/dmamux_stm32.h @@ -9,7 +9,7 @@ /* this is the configuration of one dmamux channel */ struct dmamux_stm32_channel { - struct device *dev_dma; /* pointer to the associated dma instance */ + const struct device *dev_dma; /* pointer to the associated dma instance */ uint8_t dma_id; /* ref of the associated dma stream for this instance */ }; diff --git a/drivers/eeprom/eeprom_at2x.c b/drivers/eeprom/eeprom_at2x.c index 1436e16bf712e1..f4630430c6ffa5 100644 --- a/drivers/eeprom/eeprom_at2x.c +++ b/drivers/eeprom/eeprom_at2x.c @@ -54,16 +54,16 @@ struct eeprom_at2x_config { }; struct eeprom_at2x_data { - struct device *bus_dev; + const struct device *bus_dev; #ifdef CONFIG_EEPROM_AT25 struct spi_config spi_cfg; struct spi_cs_control spi_cs; #endif /* CONFIG_EEPROM_AT25 */ - struct device *wp_gpio_dev; + const struct device *wp_gpio_dev; struct k_mutex lock; }; -static inline int eeprom_at2x_write_protect(struct device *dev) +static inline int eeprom_at2x_write_protect(const struct device *dev) { const struct eeprom_at2x_config *config = dev->config; struct eeprom_at2x_data *data = dev->data; @@ -75,7 +75,7 @@ static inline int eeprom_at2x_write_protect(struct device *dev) return gpio_pin_set(data->wp_gpio_dev, config->wp_gpio_pin, 1); } -static inline int eeprom_at2x_write_enable(struct device *dev) +static inline int eeprom_at2x_write_enable(const struct device *dev) { const struct eeprom_at2x_config *config = dev->config; struct eeprom_at2x_data *data = dev->data; @@ -87,7 +87,7 @@ static inline int eeprom_at2x_write_enable(struct device *dev) return gpio_pin_set(data->wp_gpio_dev, config->wp_gpio_pin, 0); } -static int eeprom_at2x_read(struct device *dev, off_t offset, void *buf, +static int eeprom_at2x_read(const struct device *dev, off_t offset, void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -115,7 +115,8 @@ static int eeprom_at2x_read(struct device *dev, off_t offset, void *buf, return 0; } -static size_t eeprom_at2x_limit_write_count(struct device *dev, off_t offset, +static size_t eeprom_at2x_limit_write_count(const struct device *dev, + off_t offset, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -136,7 +137,8 @@ static size_t eeprom_at2x_limit_write_count(struct device *dev, off_t offset, return count; } -static int eeprom_at2x_write(struct device *dev, off_t offset, const void *buf, +static int eeprom_at2x_write(const struct device *dev, off_t offset, + const void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -191,7 +193,7 @@ static int eeprom_at2x_write(struct device *dev, off_t offset, const void *buf, return ret; } -static size_t eeprom_at2x_size(struct device *dev) +static size_t eeprom_at2x_size(const struct device *dev) { const struct eeprom_at2x_config *config = dev->config; @@ -199,7 +201,7 @@ static size_t eeprom_at2x_size(struct device *dev) } #ifdef CONFIG_EEPROM_AT24 -static int eeprom_at24_read(struct device *dev, off_t offset, void *buf, +static int eeprom_at24_read(const struct device *dev, off_t offset, void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -233,7 +235,7 @@ static int eeprom_at24_read(struct device *dev, off_t offset, void *buf, return err; } -static int eeprom_at24_write(struct device *dev, off_t offset, +static int eeprom_at24_write(const struct device *dev, off_t offset, const void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -280,7 +282,7 @@ static int eeprom_at24_write(struct device *dev, off_t offset, #endif /* CONFIG_EEPROM_AT24 */ #ifdef CONFIG_EEPROM_AT25 -static int eeprom_at25_rdsr(struct device *dev, uint8_t *status) +static int eeprom_at25_rdsr(const struct device *dev, uint8_t *status) { struct eeprom_at2x_data *data = dev->data; uint8_t rdsr[2] = { EEPROM_AT25_RDSR, 0 }; @@ -311,7 +313,7 @@ static int eeprom_at25_rdsr(struct device *dev, uint8_t *status) return err; } -static int eeprom_at25_wait_for_idle(struct device *dev) +static int eeprom_at25_wait_for_idle(const struct device *dev) { const struct eeprom_at2x_config *config = dev->config; int64_t timeout; @@ -339,7 +341,7 @@ static int eeprom_at25_wait_for_idle(struct device *dev) return -EBUSY; } -static int eeprom_at25_read(struct device *dev, off_t offset, void *buf, +static int eeprom_at25_read(const struct device *dev, off_t offset, void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -405,7 +407,7 @@ static int eeprom_at25_read(struct device *dev, off_t offset, void *buf, return spi_transceive(data->bus_dev, &data->spi_cfg, &tx, &rx); } -static int eeprom_at25_wren(struct device *dev) +static int eeprom_at25_wren(const struct device *dev) { struct eeprom_at2x_data *data = dev->data; uint8_t cmd = EEPROM_AT25_WREN; @@ -421,7 +423,7 @@ static int eeprom_at25_wren(struct device *dev) return spi_write(data->bus_dev, &data->spi_cfg, &tx); } -static int eeprom_at25_write(struct device *dev, off_t offset, +static int eeprom_at25_write(const struct device *dev, off_t offset, const void *buf, size_t len) { const struct eeprom_at2x_config *config = dev->config; @@ -482,7 +484,7 @@ static int eeprom_at25_write(struct device *dev, off_t offset, } #endif /* CONFIG_EEPROM_AT25 */ -static int eeprom_at2x_init(struct device *dev) +static int eeprom_at2x_init(const struct device *dev) { const struct eeprom_at2x_config *config = dev->config; struct eeprom_at2x_data *data = dev->data; diff --git a/drivers/eeprom/eeprom_handlers.c b/drivers/eeprom/eeprom_handlers.c index c2057f47d7e1f6..34b4cc858fe432 100644 --- a/drivers/eeprom/eeprom_handlers.c +++ b/drivers/eeprom/eeprom_handlers.c @@ -7,29 +7,30 @@ #include #include -static inline int z_vrfy_eeprom_read(struct device *dev, off_t offset, +static inline int z_vrfy_eeprom_read(const struct device *dev, off_t offset, void *data, size_t len) { Z_OOPS(Z_SYSCALL_DRIVER_EEPROM(dev, read)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, len)); - return z_impl_eeprom_read((struct device *)dev, offset, (void *)data, + return z_impl_eeprom_read((const struct device *)dev, offset, + (void *)data, len); } #include -static inline int z_vrfy_eeprom_write(struct device *dev, off_t offset, +static inline int z_vrfy_eeprom_write(const struct device *dev, off_t offset, const void *data, size_t len) { Z_OOPS(Z_SYSCALL_DRIVER_EEPROM(dev, write)); Z_OOPS(Z_SYSCALL_MEMORY_READ(data, len)); - return z_impl_eeprom_write((struct device *)dev, offset, + return z_impl_eeprom_write((const struct device *)dev, offset, (const void *)data, len); } #include -static inline size_t z_vrfy_eeprom_get_size(struct device *dev) +static inline size_t z_vrfy_eeprom_get_size(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_EEPROM(dev, size)); - return z_impl_eeprom_get_size((struct device *)dev); + return z_impl_eeprom_get_size((const struct device *)dev); } #include diff --git a/drivers/eeprom/eeprom_lpc11u6x.c b/drivers/eeprom/eeprom_lpc11u6x.c index b1786e2d69413e..bf584d96eeeb5c 100644 --- a/drivers/eeprom/eeprom_lpc11u6x.c +++ b/drivers/eeprom/eeprom_lpc11u6x.c @@ -27,7 +27,7 @@ struct eeprom_lpc11u6x_config { size_t size; }; -static int eeprom_lpc11u6x_read(struct device *dev, +static int eeprom_lpc11u6x_read(const struct device *dev, off_t offset, void *data, size_t len) { const struct eeprom_lpc11u6x_config *config = dev->config; @@ -60,7 +60,7 @@ static int eeprom_lpc11u6x_read(struct device *dev, return 0; } -static int eeprom_lpc11u6x_write(struct device *dev, +static int eeprom_lpc11u6x_write(const struct device *dev, off_t offset, const void *data, size_t len) { const struct eeprom_lpc11u6x_config *config = dev->config; @@ -93,14 +93,14 @@ static int eeprom_lpc11u6x_write(struct device *dev, return 0; } -static size_t eeprom_lpc11u6x_size(struct device *dev) +static size_t eeprom_lpc11u6x_size(const struct device *dev) { const struct eeprom_lpc11u6x_config *config = dev->config; return config->size; } -static int eeprom_lpc11u6x_init(struct device *dev) +static int eeprom_lpc11u6x_init(const struct device *dev) { return 0; } diff --git a/drivers/eeprom/eeprom_shell.c b/drivers/eeprom/eeprom_shell.c index 1d8e53499ec968..57e8629155e642 100644 --- a/drivers/eeprom/eeprom_shell.c +++ b/drivers/eeprom/eeprom_shell.c @@ -32,7 +32,7 @@ static const struct args_index args_indx = { static int cmd_read(const struct shell *shell, size_t argc, char **argv) { uint8_t buf[CONFIG_EEPROM_SHELL_BUFFER_SIZE]; - struct device *eeprom; + const struct device *eeprom; off_t offset; size_t len; int err; @@ -70,7 +70,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char **argv) { uint8_t wr_buf[CONFIG_EEPROM_SHELL_BUFFER_SIZE]; uint8_t rd_buf[CONFIG_EEPROM_SHELL_BUFFER_SIZE]; - struct device *eeprom; + const struct device *eeprom; unsigned long byte; off_t offset; size_t len; @@ -129,7 +129,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char **argv) static int cmd_size(const struct shell *shell, size_t argc, char **argv) { - struct device *eeprom; + const struct device *eeprom; eeprom = device_get_binding(argv[args_indx.device]); if (!eeprom) { @@ -145,7 +145,7 @@ static int cmd_fill(const struct shell *shell, size_t argc, char **argv) { uint8_t wr_buf[CONFIG_EEPROM_SHELL_BUFFER_SIZE]; uint8_t rd_buf[CONFIG_EEPROM_SHELL_BUFFER_SIZE]; - struct device *eeprom; + const struct device *eeprom; unsigned long pattern; off_t offset; size_t len; diff --git a/drivers/eeprom/eeprom_simulator.c b/drivers/eeprom/eeprom_simulator.c index b47f4409d3a17a..8c3603487d4358 100644 --- a/drivers/eeprom/eeprom_simulator.c +++ b/drivers/eeprom/eeprom_simulator.c @@ -93,7 +93,8 @@ static const char default_eeprom_file_path[] = "eeprom.bin"; static uint8_t mock_eeprom[DT_INST_PROP(0, size)]; #endif /* CONFIG_ARCH_POSIX */ -static int eeprom_range_is_valid(struct device *dev, off_t offset, size_t len) +static int eeprom_range_is_valid(const struct device *dev, off_t offset, + size_t len) { const struct eeprom_sim_config *config = DEV_CONFIG(dev); @@ -104,7 +105,7 @@ static int eeprom_range_is_valid(struct device *dev, off_t offset, size_t len) return 0; } -static int eeprom_sim_read(struct device *dev, off_t offset, void *data, +static int eeprom_sim_read(const struct device *dev, off_t offset, void *data, size_t len) { if (!len) { @@ -133,7 +134,8 @@ static int eeprom_sim_read(struct device *dev, off_t offset, void *data, return 0; } -static int eeprom_sim_write(struct device *dev, off_t offset, const void *data, +static int eeprom_sim_write(const struct device *dev, off_t offset, + const void *data, size_t len) { const struct eeprom_sim_config *config = DEV_CONFIG(dev); @@ -192,7 +194,7 @@ static int eeprom_sim_write(struct device *dev, off_t offset, const void *data, return 0; } -static size_t eeprom_sim_size(struct device *dev) +static size_t eeprom_sim_size(const struct device *dev) { const struct eeprom_sim_config *config = DEV_CONFIG(dev); @@ -212,7 +214,7 @@ static const struct eeprom_sim_config eeprom_sim_config_0 = { #ifdef CONFIG_ARCH_POSIX -static int eeprom_mock_init(struct device *dev) +static int eeprom_mock_init(const struct device *dev) { if (eeprom_file_path == NULL) { eeprom_file_path = default_eeprom_file_path; @@ -247,7 +249,7 @@ static int eeprom_mock_init(struct device *dev) #else -static int eeprom_mock_init(struct device *dev) +static int eeprom_mock_init(const struct device *dev) { memset(mock_eeprom, 0xFF, ARRAY_SIZE(mock_eeprom)); return 0; @@ -255,7 +257,7 @@ static int eeprom_mock_init(struct device *dev) #endif /* CONFIG_ARCH_POSIX */ -static int eeprom_sim_init(struct device *dev) +static int eeprom_sim_init(const struct device *dev) { SYNC_INIT(); STATS_INIT_AND_REG(eeprom_sim_stats, STATS_SIZE_32, "eeprom_sim_stats"); diff --git a/drivers/eeprom/eeprom_stm32.c b/drivers/eeprom/eeprom_stm32.c index 52ac53d5be2ba5..1aa275781110f4 100644 --- a/drivers/eeprom/eeprom_stm32.c +++ b/drivers/eeprom/eeprom_stm32.c @@ -20,7 +20,8 @@ struct eeprom_stm32_config { size_t size; }; -static int eeprom_stm32_read(struct device *dev, off_t offset, void *buf, +static int eeprom_stm32_read(const struct device *dev, off_t offset, + void *buf, size_t len) { const struct eeprom_stm32_config *config = dev->config; @@ -50,7 +51,7 @@ static int eeprom_stm32_read(struct device *dev, off_t offset, void *buf, return 0; } -static int eeprom_stm32_write(struct device *dev, off_t offset, +static int eeprom_stm32_write(const struct device *dev, off_t offset, const void *buf, size_t len) { const struct eeprom_stm32_config *config = dev->config; @@ -98,14 +99,14 @@ static int eeprom_stm32_write(struct device *dev, off_t offset, return ret; } -static size_t eeprom_stm32_size(struct device *dev) +static size_t eeprom_stm32_size(const struct device *dev) { const struct eeprom_stm32_config *config = dev->config; return config->size; } -static int eeprom_stm32_init(struct device *dev) +static int eeprom_stm32_init(const struct device *dev) { return 0; } diff --git a/drivers/entropy/entropy_cc13xx_cc26xx.c b/drivers/entropy/entropy_cc13xx_cc26xx.c index 57d25811b21538..736d4a13ff8d82 100644 --- a/drivers/entropy/entropy_cc13xx_cc26xx.c +++ b/drivers/entropy/entropy_cc13xx_cc26xx.c @@ -43,7 +43,7 @@ struct entropy_cc13xx_cc26xx_data { DEVICE_DECLARE(entropy_cc13xx_cc26xx); static inline struct entropy_cc13xx_cc26xx_data * -get_dev_data(struct device *dev) +get_dev_data(const struct device *dev) { return dev->data; } @@ -100,7 +100,8 @@ static void handle_shutdown_ovf(void) sys_write32(off, TRNG_BASE + TRNG_O_FROEN); } -static int entropy_cc13xx_cc26xx_get_entropy(struct device *dev, uint8_t *buf, +static int entropy_cc13xx_cc26xx_get_entropy(const struct device *dev, + uint8_t *buf, uint16_t len) { struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); @@ -176,8 +177,9 @@ static void entropy_cc13xx_cc26xx_isr(void *arg) } } -static int entropy_cc13xx_cc26xx_get_entropy_isr(struct device *dev, - uint8_t *buf, uint16_t len, uint32_t flags) +static int entropy_cc13xx_cc26xx_get_entropy_isr(const struct device *dev, + uint8_t *buf, uint16_t len, + uint32_t flags) { struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); uint16_t cnt; @@ -249,7 +251,7 @@ static int entropy_cc13xx_cc26xx_get_entropy_isr(struct device *dev, static int post_notify_fxn(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg) { - struct device *dev = (struct device *)clientArg; + const struct device *dev = (const struct device *)clientArg; int ret = Power_NOTIFYDONE; int16_t res_id; @@ -268,8 +270,8 @@ static int post_notify_fxn(unsigned int eventType, uintptr_t eventArg, #endif #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int entropy_cc13xx_cc26xx_set_power_state(struct device *dev, - uint32_t new_state) +static int entropy_cc13xx_cc26xx_set_power_state(const struct device *dev, + uint32_t new_state) { struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); int ret = 0; @@ -293,8 +295,10 @@ static int entropy_cc13xx_cc26xx_set_power_state(struct device *dev, return ret; } -static int entropy_cc13xx_cc26xx_pm_control(struct device *dev, - uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) +static int entropy_cc13xx_cc26xx_pm_control(const struct device *dev, + uint32_t ctrl_command, + void *context, device_pm_cb cb, + void *arg) { struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); int ret = 0; @@ -319,7 +323,7 @@ static int entropy_cc13xx_cc26xx_pm_control(struct device *dev, } #endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ -static int entropy_cc13xx_cc26xx_init(struct device *dev) +static int entropy_cc13xx_cc26xx_init(const struct device *dev) { struct entropy_cc13xx_cc26xx_data *data = get_dev_data(dev); diff --git a/drivers/entropy/entropy_esp32.c b/drivers/entropy/entropy_esp32.c index 42d5efa8c3d79b..f470e66077f9c1 100644 --- a/drivers/entropy/entropy_esp32.c +++ b/drivers/entropy/entropy_esp32.c @@ -28,7 +28,8 @@ static inline uint32_t entropy_esp32_get_u32(void) return *rng_data_reg; } -static int entropy_esp32_get_entropy(struct device *device, uint8_t *buf, uint16_t len) +static int entropy_esp32_get_entropy(const struct device *device, + uint8_t *buf, uint16_t len) { while (len) { uint32_t v = entropy_esp32_get_u32(); @@ -47,7 +48,7 @@ static int entropy_esp32_get_entropy(struct device *device, uint8_t *buf, uint16 return 0; } -static int entropy_esp32_init(struct device *device) +static int entropy_esp32_init(const struct device *device) { return 0; } diff --git a/drivers/entropy/entropy_gecko_trng.c b/drivers/entropy/entropy_gecko_trng.c index c5b3de52ca67d2..2f191c55f22b9b 100644 --- a/drivers/entropy/entropy_gecko_trng.c +++ b/drivers/entropy/entropy_gecko_trng.c @@ -30,8 +30,9 @@ static void entropy_gecko_trng_read(uint8_t *output, size_t len) } } -static int entropy_gecko_trng_get_entropy(struct device *dev, uint8_t *buffer, - uint16_t length) +static int entropy_gecko_trng_get_entropy(const struct device *dev, + uint8_t *buffer, + uint16_t length) { size_t count = 0; size_t available; @@ -53,8 +54,9 @@ static int entropy_gecko_trng_get_entropy(struct device *dev, uint8_t *buffer, return 0; } -static int entropy_gecko_trng_get_entropy_isr(struct device *dev, uint8_t *buf, - uint16_t len, uint32_t flags) +static int entropy_gecko_trng_get_entropy_isr(const struct device *dev, + uint8_t *buf, + uint16_t len, uint32_t flags) { if ((flags & ENTROPY_BUSYWAIT) == 0U) { @@ -82,7 +84,7 @@ static int entropy_gecko_trng_get_entropy_isr(struct device *dev, uint8_t *buf, } } -static int entropy_gecko_trng_init(struct device *device) +static int entropy_gecko_trng_init(const struct device *device) { /* Enable the TRNG0 clock. */ CMU_ClockEnable(cmuClock_TRNG0, true); diff --git a/drivers/entropy/entropy_handlers.c b/drivers/entropy/entropy_handlers.c index 56719c0f97685b..badbb8c4c73144 100644 --- a/drivers/entropy/entropy_handlers.c +++ b/drivers/entropy/entropy_handlers.c @@ -7,13 +7,14 @@ #include #include -static inline int z_vrfy_entropy_get_entropy(struct device *dev, +static inline int z_vrfy_entropy_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t len) { Z_OOPS(Z_SYSCALL_DRIVER_ENTROPY(dev, get_entropy)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buffer, len)); - return z_impl_entropy_get_entropy((struct device *)dev, (uint8_t *)buffer, - len); + return z_impl_entropy_get_entropy((const struct device *)dev, + (uint8_t *)buffer, + len); } #include diff --git a/drivers/entropy/entropy_litex.c b/drivers/entropy/entropy_litex.c index d5b1b1bac23bf2..17a4db1b3280d0 100644 --- a/drivers/entropy/entropy_litex.c +++ b/drivers/entropy/entropy_litex.c @@ -33,7 +33,7 @@ static inline unsigned int prbs_read(volatile uint32_t *reg_status, return result; } -static int entropy_prbs_get_entropy(struct device *dev, uint8_t *buffer, +static int entropy_prbs_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length) { while (length > 0) { @@ -50,7 +50,7 @@ static int entropy_prbs_get_entropy(struct device *dev, uint8_t *buffer, return 0; } -static int entropy_prbs_init(struct device *dev) +static int entropy_prbs_init(const struct device *dev) { return 0; } diff --git a/drivers/entropy/entropy_mcux_rng.c b/drivers/entropy/entropy_mcux_rng.c index 58de190d8ca7c3..b98d7aba1ffd8f 100644 --- a/drivers/entropy/entropy_mcux_rng.c +++ b/drivers/entropy/entropy_mcux_rng.c @@ -17,7 +17,8 @@ struct mcux_entropy_config { RNG_Type *base; }; -static int entropy_mcux_rng_get_entropy(struct device *dev, uint8_t *buffer, +static int entropy_mcux_rng_get_entropy(const struct device *dev, + uint8_t *buffer, uint16_t length) { const struct mcux_entropy_config *config = dev->config; @@ -39,14 +40,14 @@ static const struct mcux_entropy_config entropy_mcux_config = { .base = (RNG_Type *)DT_INST_REG_ADDR(0) }; -static int entropy_mcux_rng_init(struct device *); +static int entropy_mcux_rng_init(const struct device *); DEVICE_AND_API_INIT(entropy_mcux_rng, DT_INST_LABEL(0), entropy_mcux_rng_init, NULL, &entropy_mcux_config, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_mcux_rng_api_funcs); -static int entropy_mcux_rng_init(struct device *dev) +static int entropy_mcux_rng_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/entropy/entropy_mcux_rnga.c b/drivers/entropy/entropy_mcux_rnga.c index f46313fc510e19..3aaa8f6032da41 100644 --- a/drivers/entropy/entropy_mcux_rnga.c +++ b/drivers/entropy/entropy_mcux_rnga.c @@ -38,8 +38,9 @@ static uint8_t entropy_mcux_rnga_get_uint8(void) return output; } -static int entropy_mcux_rnga_get_entropy(struct device *dev, uint8_t *buffer, - uint16_t length) +static int entropy_mcux_rnga_get_entropy(const struct device *dev, + uint8_t *buffer, + uint16_t length) { int i; @@ -56,14 +57,14 @@ static const struct entropy_driver_api entropy_mcux_rnga_api_funcs = { .get_entropy = entropy_mcux_rnga_get_entropy }; -static int entropy_mcux_rnga_init(struct device *); +static int entropy_mcux_rnga_init(const struct device *); DEVICE_AND_API_INIT(entropy_mcux_rnga, DT_INST_LABEL(0), entropy_mcux_rnga_init, NULL, NULL, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_mcux_rnga_api_funcs); -static int entropy_mcux_rnga_init(struct device *dev) +static int entropy_mcux_rnga_init(const struct device *dev) { uint32_t seed = k_cycle_get_32(); diff --git a/drivers/entropy/entropy_mcux_trng.c b/drivers/entropy/entropy_mcux_trng.c index bb015a4f3a274f..5fdc63da9e87b0 100644 --- a/drivers/entropy/entropy_mcux_trng.c +++ b/drivers/entropy/entropy_mcux_trng.c @@ -17,7 +17,8 @@ struct mcux_entropy_config { TRNG_Type *base; }; -static int entropy_mcux_trng_get_entropy(struct device *dev, uint8_t *buffer, +static int entropy_mcux_trng_get_entropy(const struct device *dev, + uint8_t *buffer, uint16_t length) { const struct mcux_entropy_config *config = dev->config; @@ -39,14 +40,14 @@ static struct mcux_entropy_config entropy_mcux_config = { .base = (TRNG_Type *)DT_INST_REG_ADDR(0) }; -static int entropy_mcux_trng_init(struct device *); +static int entropy_mcux_trng_init(const struct device *); DEVICE_AND_API_INIT(entropy_mcux_trng, DT_INST_LABEL(0), entropy_mcux_trng_init, NULL, &entropy_mcux_config, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_mcux_trng_api_funcs); -static int entropy_mcux_trng_init(struct device *dev) +static int entropy_mcux_trng_init(const struct device *dev) { const struct mcux_entropy_config *config = dev->config; trng_config_t conf; diff --git a/drivers/entropy/entropy_nrf5.c b/drivers/entropy/entropy_nrf5.c index 6d319f02f38499..6798af07f0a2d1 100644 --- a/drivers/entropy/entropy_nrf5.c +++ b/drivers/entropy/entropy_nrf5.c @@ -227,7 +227,8 @@ static void isr(void *arg) } } -static int entropy_nrf5_get_entropy(struct device *device, uint8_t *buf, uint16_t len) +static int entropy_nrf5_get_entropy(const struct device *device, uint8_t *buf, + uint16_t len) { /* Check if this API is called on correct driver instance. */ __ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(device)); @@ -253,7 +254,8 @@ static int entropy_nrf5_get_entropy(struct device *device, uint8_t *buf, uint16_ return 0; } -static int entropy_nrf5_get_entropy_isr(struct device *dev, uint8_t *buf, uint16_t len, +static int entropy_nrf5_get_entropy_isr(const struct device *dev, + uint8_t *buf, uint16_t len, uint32_t flags) { uint16_t cnt = len; @@ -322,7 +324,7 @@ static int entropy_nrf5_get_entropy_isr(struct device *dev, uint8_t *buf, uint16 return cnt; } -static int entropy_nrf5_init(struct device *device); +static int entropy_nrf5_init(const struct device *device); static const struct entropy_driver_api entropy_nrf5_api_funcs = { .get_entropy = entropy_nrf5_get_entropy, @@ -334,7 +336,7 @@ DEVICE_AND_API_INIT(entropy_nrf5, DT_INST_LABEL(0), PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_nrf5_api_funcs); -static int entropy_nrf5_init(struct device *device) +static int entropy_nrf5_init(const struct device *device) { /* Check if this API is called on correct driver instance. */ __ASSERT_NO_MSG(&entropy_nrf5_data == DEV_DATA(device)); diff --git a/drivers/entropy/entropy_rv32m1_trng.c b/drivers/entropy/entropy_rv32m1_trng.c index e3b01822290f6c..249796ac7e7f7c 100644 --- a/drivers/entropy/entropy_rv32m1_trng.c +++ b/drivers/entropy/entropy_rv32m1_trng.c @@ -17,8 +17,9 @@ struct rv32m1_entropy_config { TRNG_Type *base; }; -static int entropy_rv32m1_trng_get_entropy(struct device *dev, uint8_t *buffer, - uint16_t length) +static int entropy_rv32m1_trng_get_entropy(const struct device *dev, + uint8_t *buffer, + uint16_t length) { const struct rv32m1_entropy_config *config = dev->config; status_t status; @@ -39,14 +40,14 @@ static struct rv32m1_entropy_config entropy_rv32m1_config = { .base = (TRNG_Type *)DT_INST_REG_ADDR(0) }; -static int entropy_rv32m1_trng_init(struct device *); +static int entropy_rv32m1_trng_init(const struct device *); DEVICE_AND_API_INIT(entropy_rv32m1_trng, DT_INST_LABEL(0), entropy_rv32m1_trng_init, NULL, &entropy_rv32m1_config, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &entropy_rv32m1_trng_api_funcs); -static int entropy_rv32m1_trng_init(struct device *dev) +static int entropy_rv32m1_trng_init(const struct device *dev) { const struct rv32m1_entropy_config *config = dev->config; trng_config_t conf; diff --git a/drivers/entropy/entropy_sam.c b/drivers/entropy/entropy_sam.c index 59f56d1a2737fa..9b9700b5964dbb 100644 --- a/drivers/entropy/entropy_sam.c +++ b/drivers/entropy/entropy_sam.c @@ -72,8 +72,9 @@ static int entropy_sam_wait_ready(Trng * const trng, uint32_t flags) return 0; } -static int entropy_sam_get_entropy_internal(struct device *dev, uint8_t *buffer, - uint16_t length, uint32_t flags) +static int entropy_sam_get_entropy_internal(const struct device *dev, + uint8_t *buffer, + uint16_t length, uint32_t flags) { Trng *const trng = DEV_CFG(dev)->regs; @@ -98,14 +99,15 @@ static int entropy_sam_get_entropy_internal(struct device *dev, uint8_t *buffer, return 0; } -static int entropy_sam_get_entropy(struct device *dev, uint8_t *buffer, +static int entropy_sam_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length) { return entropy_sam_get_entropy_internal(dev, buffer, length, 0); } -static int entropy_sam_get_entropy_isr(struct device *dev, uint8_t *buffer, - uint16_t length, uint32_t flags) +static int entropy_sam_get_entropy_isr(const struct device *dev, + uint8_t *buffer, + uint16_t length, uint32_t flags) { uint16_t cnt = length; @@ -152,7 +154,7 @@ static int entropy_sam_get_entropy_isr(struct device *dev, uint8_t *buffer, } } -static int entropy_sam_init(struct device *dev) +static int entropy_sam_init(const struct device *dev) { Trng *const trng = DEV_CFG(dev)->regs; diff --git a/drivers/entropy/entropy_stm32.c b/drivers/entropy/entropy_stm32.c index e1fdc5c9b0c774..8665b61c18c83a 100644 --- a/drivers/entropy/entropy_stm32.c +++ b/drivers/entropy/entropy_stm32.c @@ -70,7 +70,7 @@ struct entropy_stm32_rng_dev_cfg { struct entropy_stm32_rng_dev_data { RNG_TypeDef *rng; - struct device *clock; + const struct device *clock; struct k_sem sem_lock; struct k_sem sem_sync; @@ -241,8 +241,9 @@ static void stm32_rng_isr(void *arg) } } -static int entropy_stm32_rng_get_entropy(struct device *device, uint8_t *buf, - uint16_t len) +static int entropy_stm32_rng_get_entropy(const struct device *device, + uint8_t *buf, + uint16_t len) { /* Check if this API is called on correct driver instance. */ __ASSERT_NO_MSG(&entropy_stm32_rng_data == DEV_DATA(device)); @@ -269,7 +270,8 @@ static int entropy_stm32_rng_get_entropy(struct device *device, uint8_t *buf, return 0; } -static int entropy_stm32_rng_get_entropy_isr(struct device *dev, uint8_t *buf, +static int entropy_stm32_rng_get_entropy_isr(const struct device *dev, + uint8_t *buf, uint16_t len, uint32_t flags) { @@ -337,7 +339,7 @@ static int entropy_stm32_rng_get_entropy_isr(struct device *dev, uint8_t *buf, return cnt; } -static int entropy_stm32_rng_init(struct device *dev) +static int entropy_stm32_rng_init(const struct device *dev) { struct entropy_stm32_rng_dev_data *dev_data; const struct entropy_stm32_rng_dev_cfg *dev_cfg; diff --git a/drivers/entropy/fake_entropy_native_posix.c b/drivers/entropy/fake_entropy_native_posix.c index 1da1b1bb9c6d6f..e969eb868d3c34 100644 --- a/drivers/entropy/fake_entropy_native_posix.c +++ b/drivers/entropy/fake_entropy_native_posix.c @@ -25,7 +25,8 @@ static unsigned int seed = 0x5678; -static int entropy_native_posix_get_entropy(struct device *dev, uint8_t *buffer, +static int entropy_native_posix_get_entropy(const struct device *dev, + uint8_t *buffer, uint16_t length) { ARG_UNUSED(dev); @@ -47,7 +48,8 @@ static int entropy_native_posix_get_entropy(struct device *dev, uint8_t *buffer, return 0; } -static int entropy_native_posix_get_entropy_isr(struct device *dev, uint8_t *buf, +static int entropy_native_posix_get_entropy_isr(const struct device *dev, + uint8_t *buf, uint16_t len, uint32_t flags) { ARG_UNUSED(flags); @@ -59,7 +61,7 @@ static int entropy_native_posix_get_entropy_isr(struct device *dev, uint8_t *buf return entropy_native_posix_get_entropy(dev, buf, len); } -static int entropy_native_posix_init(struct device *dev) +static int entropy_native_posix_init(const struct device *dev) { ARG_UNUSED(dev); srandom(seed); diff --git a/drivers/espi/espi_handlers.c b/drivers/espi/espi_handlers.c index 6e8dff328a5957..8178d9ee71099a 100644 --- a/drivers/espi/espi_handlers.c +++ b/drivers/espi/espi_handlers.c @@ -8,7 +8,8 @@ #include -static inline int z_vrfy_espi_config(struct device *dev, struct espi_cfg *cfg) +static inline int z_vrfy_espi_config(const struct device *dev, + struct espi_cfg *cfg) { struct espi_cfg cfg_copy; @@ -20,7 +21,7 @@ static inline int z_vrfy_espi_config(struct device *dev, struct espi_cfg *cfg) } #include -static inline bool z_vrfy_espi_get_channel_status(struct device *dev, +static inline bool z_vrfy_espi_get_channel_status(const struct device *dev, enum espi_channel ch) { Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, get_channel_status)); @@ -29,7 +30,7 @@ static inline bool z_vrfy_espi_get_channel_status(struct device *dev, } #include -static inline int z_vrfy_espi_read_lpc_request(struct device *dev, +static inline int z_vrfy_espi_read_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -45,7 +46,7 @@ static inline int z_vrfy_espi_read_lpc_request(struct device *dev, } #include -static inline int z_vrfy_espi_write_lpc_request(struct device *dev, +static inline int z_vrfy_espi_write_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -58,7 +59,7 @@ static inline int z_vrfy_espi_write_lpc_request(struct device *dev, } #include -static inline int z_vrfy_espi_send_vwire(struct device *dev, +static inline int z_vrfy_espi_send_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t level) { @@ -68,7 +69,7 @@ static inline int z_vrfy_espi_send_vwire(struct device *dev, } #include -static inline int z_vrfy_espi_receive_vwire(struct device *dev, +static inline int z_vrfy_espi_receive_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t *level) { @@ -84,7 +85,7 @@ static inline int z_vrfy_espi_receive_vwire(struct device *dev, } #include -static inline int z_vrfy_espi_read_request(struct device *dev, +static inline int z_vrfy_espi_read_request(const struct device *dev, struct espi_request_packet *req) { int ret; @@ -104,7 +105,7 @@ static inline int z_vrfy_espi_read_request(struct device *dev, } #include -static inline int z_vrfy_espi_write_request(struct device *dev, +static inline int z_vrfy_espi_write_request(const struct device *dev, struct espi_request_packet *req) { int ret; @@ -121,7 +122,7 @@ static inline int z_vrfy_espi_write_request(struct device *dev, } #include -static inline int z_vrfy_espi_send_oob(struct device *dev, +static inline int z_vrfy_espi_send_oob(const struct device *dev, struct espi_oob_packet *pckt) { int ret; @@ -138,7 +139,7 @@ static inline int z_vrfy_espi_send_oob(struct device *dev, } #include -static inline int z_vrfy_espi_receive_oob(struct device *dev, +static inline int z_vrfy_espi_receive_oob(const struct device *dev, struct espi_oob_packet *pckt) { int ret; @@ -157,7 +158,7 @@ static inline int z_vrfy_espi_receive_oob(struct device *dev, } #include -static inline int z_vrfy_espi_read_flash(struct device *dev, +static inline int z_vrfy_espi_read_flash(const struct device *dev, struct espi_flash_packet *pckt) { int ret; @@ -176,7 +177,7 @@ static inline int z_vrfy_espi_read_flash(struct device *dev, } #include -static inline int z_vrfy_espi_write_flash(struct device *dev, +static inline int z_vrfy_espi_write_flash(const struct device *dev, struct espi_flash_packet *pckt) { int ret; @@ -193,7 +194,7 @@ static inline int z_vrfy_espi_write_flash(struct device *dev, } #include -static inline int z_vrfy_espi_flash_erase(struct device *dev, +static inline int z_vrfy_espi_flash_erase(const struct device *dev, struct espi_flash_packet *pckt) { int ret; diff --git a/drivers/espi/espi_mchp_xec.c b/drivers/espi/espi_mchp_xec.c index 18b18c233ae372..3086e5858626ee 100644 --- a/drivers/espi/espi_mchp_xec.c +++ b/drivers/espi/espi_mchp_xec.c @@ -55,7 +55,7 @@ LOG_MODULE_REGISTER(espi, CONFIG_ESPI_LOG_LEVEL); struct espi_isr { uint32_t girq_bit; - void (*the_isr)(struct device *dev); + void (*the_isr)(const struct device *dev); }; struct espi_xec_config { @@ -203,7 +203,7 @@ static uint32_t slave_rx_mem[MAX_OOB_BUFFER_SIZE]; static uint32_t slave_tx_mem[MAX_OOB_BUFFER_SIZE]; static uint32_t slave_mem[MAX_SLAVE_BUFFER_SIZE]; -static int espi_xec_configure(struct device *dev, struct espi_cfg *cfg) +static int espi_xec_configure(const struct device *dev, struct espi_cfg *cfg) { uint8_t iomode = 0; uint8_t cap0 = ESPI_CAP_REGS->GLB_CAP0; @@ -294,7 +294,8 @@ static int espi_xec_configure(struct device *dev, struct espi_cfg *cfg) return 0; } -static bool espi_xec_channel_ready(struct device *dev, enum espi_channel ch) +static bool espi_xec_channel_ready(const struct device *dev, + enum espi_channel ch) { bool sts; @@ -319,7 +320,7 @@ static bool espi_xec_channel_ready(struct device *dev, enum espi_channel ch) return sts; } -static int espi_xec_read_lpc_request(struct device *dev, +static int espi_xec_read_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -355,7 +356,7 @@ static int espi_xec_read_lpc_request(struct device *dev, return 0; } -static int espi_xec_write_lpc_request(struct device *dev, +static int espi_xec_write_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -410,7 +411,7 @@ static int espi_xec_write_lpc_request(struct device *dev, return 0; } -static int espi_xec_send_vwire(struct device *dev, +static int espi_xec_send_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t level) { struct xec_signal signal_info = vw_tbl[signal]; @@ -448,7 +449,7 @@ static int espi_xec_send_vwire(struct device *dev, return 0; } -static int espi_xec_receive_vwire(struct device *dev, +static int espi_xec_receive_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t *level) { struct xec_signal signal_info = vw_tbl[signal]; @@ -473,7 +474,8 @@ static int espi_xec_receive_vwire(struct device *dev, return 0; } -static int espi_xec_send_oob(struct device *dev, struct espi_oob_packet *pckt) +static int espi_xec_send_oob(const struct device *dev, + struct espi_oob_packet *pckt) { int ret; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -519,7 +521,7 @@ static int espi_xec_send_oob(struct device *dev, struct espi_oob_packet *pckt) return 0; } -static int espi_xec_receive_oob(struct device *dev, +static int espi_xec_receive_oob(const struct device *dev, struct espi_oob_packet *pckt) { int ret; @@ -555,7 +557,7 @@ static int espi_xec_receive_oob(struct device *dev, return 0; } -static int espi_xec_flash_read(struct device *dev, +static int espi_xec_flash_read(const struct device *dev, struct espi_flash_packet *pckt) { int ret; @@ -603,8 +605,8 @@ static int espi_xec_flash_read(struct device *dev, return 0; } -static int espi_xec_flash_write(struct device *dev, - struct espi_flash_packet *pckt) +static int espi_xec_flash_write(const struct device *dev, + struct espi_flash_packet *pckt) { int ret; uint32_t err_mask = MCHP_ESPI_FC_STS_IBERR | @@ -654,7 +656,7 @@ static int espi_xec_flash_write(struct device *dev, return 0; } -static int espi_xec_manage_callback(struct device *dev, +static int espi_xec_manage_callback(const struct device *dev, struct espi_callback *callback, bool set) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -663,7 +665,7 @@ static int espi_xec_manage_callback(struct device *dev, } #ifdef CONFIG_ESPI_AUTOMATIC_BOOT_DONE_ACKNOWLEDGE -static void send_slave_bootdone(struct device *dev) +static void send_slave_bootdone(const struct device *dev) { int ret; uint8_t boot_done; @@ -679,7 +681,7 @@ static void send_slave_bootdone(struct device *dev) #endif #ifdef CONFIG_ESPI_OOB_CHANNEL -static void espi_init_oob(struct device *dev) +static void espi_init_oob(const struct device *dev) { struct espi_xec_config *config = (struct espi_xec_config *) (dev->config); @@ -701,7 +703,7 @@ static void espi_init_oob(struct device *dev) #endif #ifdef CONFIG_ESPI_FLASH_CHANNEL -static void espi_init_flash(struct device *dev) +static void espi_init_flash(const struct device *dev) { struct espi_xec_config *config = (struct espi_xec_config *)(dev->config); @@ -715,7 +717,7 @@ static void espi_init_flash(struct device *dev) } #endif -static void espi_bus_init(struct device *dev) +static void espi_bus_init(const struct device *dev) { const struct espi_xec_config *config = dev->config; @@ -724,7 +726,7 @@ static void espi_bus_init(struct device *dev) MCHP_ESPI_VW_EN_GIRQ_VAL | MCHP_ESPI_PC_GIRQ_VAL; } -static void espi_rst_isr(struct device *dev) +static void espi_rst_isr(const struct device *dev) { uint8_t rst_sts; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -758,7 +760,7 @@ static void espi_rst_isr(struct device *dev) * then make its BAR valid. * Refer to microchip eSPI I/O base addresses for default values */ -static void config_sub_devices(struct device *dev) +static void config_sub_devices(const struct device *dev) { #ifdef CONFIG_ESPI_PERIPHERAL_UART /* eSPI logical UART is tied to corresponding physical UART @@ -832,7 +834,8 @@ static void configure_sirq(void) #endif } -static void setup_espi_io_config(struct device *dev, uint16_t host_address) +static void setup_espi_io_config(const struct device *dev, + uint16_t host_address) { ESPI_EIO_BAR_REGS->EC_BAR_IOC = (host_address << 16) | MCHP_ESPI_IO_BAR_HOST_VALID; @@ -846,7 +849,7 @@ static void setup_espi_io_config(struct device *dev, uint16_t host_address) ESPI_CAP_REGS->PC_RDY = 1; } -static void espi_pc_isr(struct device *dev) +static void espi_pc_isr(const struct device *dev) { uint32_t status = ESPI_PC_REGS->PC_STATUS; @@ -859,7 +862,7 @@ static void espi_pc_isr(struct device *dev) } } -static void espi_vwire_chanel_isr(struct device *dev) +static void espi_vwire_chanel_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); const struct espi_xec_config *config = dev->config; @@ -884,7 +887,7 @@ static void espi_vwire_chanel_isr(struct device *dev) } #ifdef CONFIG_ESPI_OOB_CHANNEL -static void espi_oob_down_isr(struct device *dev) +static void espi_oob_down_isr(const struct device *dev) { uint32_t status; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -903,7 +906,7 @@ static void espi_oob_down_isr(struct device *dev) } } -static void espi_oob_up_isr(struct device *dev) +static void espi_oob_up_isr(const struct device *dev) { uint32_t status; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -936,7 +939,7 @@ static void espi_oob_up_isr(struct device *dev) #endif #ifdef CONFIG_ESPI_FLASH_CHANNEL -static void espi_flash_isr(struct device *dev) +static void espi_flash_isr(const struct device *dev) { uint32_t status; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -971,7 +974,7 @@ static void espi_flash_isr(struct device *dev) } #endif -static void vw_pltrst_isr(struct device *dev) +static void vw_pltrst_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); struct espi_event evt = { ESPI_BUS_EVENT_VWIRE_RECEIVED, @@ -993,7 +996,7 @@ static void vw_pltrst_isr(struct device *dev) } /* Send callbacks if enabled and track eSPI host system state */ -static void notify_system_state(struct device *dev, +static void notify_system_state(const struct device *dev, enum espi_vwire_signal signal) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -1010,7 +1013,7 @@ static void notify_system_state(struct device *dev, espi_send_callbacks(&data->callbacks, dev, evt); } -static void notify_host_warning(struct device *dev, +static void notify_host_warning(const struct device *dev, enum espi_vwire_signal signal) { uint8_t status; @@ -1047,42 +1050,42 @@ static void notify_host_warning(struct device *dev, } } -static void vw_slp3_isr(struct device *dev) +static void vw_slp3_isr(const struct device *dev) { notify_system_state(dev, ESPI_VWIRE_SIGNAL_SLP_S3); } -static void vw_slp4_isr(struct device *dev) +static void vw_slp4_isr(const struct device *dev) { notify_system_state(dev, ESPI_VWIRE_SIGNAL_SLP_S4); } -static void vw_slp5_isr(struct device *dev) +static void vw_slp5_isr(const struct device *dev) { notify_system_state(dev, ESPI_VWIRE_SIGNAL_SLP_S5); } -static void vw_host_rst_warn_isr(struct device *dev) +static void vw_host_rst_warn_isr(const struct device *dev) { notify_host_warning(dev, ESPI_VWIRE_SIGNAL_HOST_RST_WARN); } -static void vw_sus_warn_isr(struct device *dev) +static void vw_sus_warn_isr(const struct device *dev) { notify_host_warning(dev, ESPI_VWIRE_SIGNAL_SUS_WARN); } -static void vw_oob_rst_isr(struct device *dev) +static void vw_oob_rst_isr(const struct device *dev) { notify_host_warning(dev, ESPI_VWIRE_SIGNAL_OOB_RST_WARN); } -static void vw_sus_slp_a_isr(struct device *dev) +static void vw_sus_slp_a_isr(const struct device *dev) { notify_system_state(dev, ESPI_VWIRE_SIGNAL_SLP_A); } -static void ibf_isr(struct device *dev) +static void ibf_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, @@ -1093,7 +1096,7 @@ static void ibf_isr(struct device *dev) } #ifdef CONFIG_ESPI_PERIPHERAL_HOST_IO_PVT -static void ibf_pvt_isr(struct device *dev) +static void ibf_pvt_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); struct espi_event evt = { @@ -1106,7 +1109,7 @@ static void ibf_pvt_isr(struct device *dev) } #endif -static void ibf_kbc_isr(struct device *dev) +static void ibf_kbc_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); @@ -1127,7 +1130,7 @@ static void ibf_kbc_isr(struct device *dev) espi_send_callbacks(&data->callbacks, dev, evt); } -static void port80_isr(struct device *dev) +static void port80_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, @@ -1139,7 +1142,7 @@ static void port80_isr(struct device *dev) espi_send_callbacks(&data->callbacks, dev, evt); } -static void port81_isr(struct device *dev) +static void port81_isr(const struct device *dev) { struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); struct espi_event evt = { ESPI_BUS_PERIPHERAL_NOTIFICATION, @@ -1203,7 +1206,7 @@ static uint8_t periph_isr_cnt = sizeof(peripherals_isr) / sizeof(struct espi_isr static void espi_xec_bus_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct espi_xec_config *config = dev->config; uint32_t girq_result; @@ -1224,7 +1227,7 @@ static void espi_xec_bus_isr(void *arg) static void espi_xec_vw_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct espi_xec_config *config = dev->config; uint32_t girq_result; @@ -1245,7 +1248,7 @@ static void espi_xec_vw_isr(void *arg) static void espi_xec_periph_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct espi_xec_config *config = dev->config; uint32_t girq_result; @@ -1264,7 +1267,7 @@ static void espi_xec_periph_isr(void *arg) REG32(MCHP_GIRQ_SRC_ADDR(config->pc_girq_id)) = girq_result; } -static int espi_xec_init(struct device *dev); +static int espi_xec_init(const struct device *dev); static const struct espi_driver_api espi_xec_driver_api = { .config = espi_xec_configure, @@ -1294,7 +1297,7 @@ DEVICE_AND_API_INIT(espi_xec_0, DT_INST_LABEL(0), PRE_KERNEL_2, CONFIG_ESPI_INIT_PRIORITY, &espi_xec_driver_api); -static int espi_xec_init(struct device *dev) +static int espi_xec_init(const struct device *dev) { const struct espi_xec_config *config = dev->config; struct espi_xec_data *data = (struct espi_xec_data *)(dev->data); diff --git a/drivers/espi/espi_utils.h b/drivers/espi/espi_utils.h index be77ddd5a4567d..2ef265cd86af66 100644 --- a/drivers/espi/espi_utils.h +++ b/drivers/espi/espi_utils.h @@ -49,7 +49,7 @@ static int espi_manage_callback(sys_slist_t *callbacks, * @param pins The details on the event that triggered the callback. */ static inline void espi_send_callbacks(sys_slist_t *list, - struct device *device, + const struct device *device, struct espi_event evt) { struct espi_callback *cb, *tmp; diff --git a/drivers/ethernet/eth_e1000.c b/drivers/ethernet/eth_e1000.c index 691ce3ef104a3e..3430d13e70c593 100644 --- a/drivers/ethernet/eth_e1000.c +++ b/drivers/ethernet/eth_e1000.c @@ -79,7 +79,7 @@ static struct net_if *get_iface(struct e1000_dev *ctx, uint16_t vlan_tag) #endif } -static enum ethernet_hw_caps e1000_caps(struct device *dev) +static enum ethernet_hw_caps e1000_caps(const struct device *dev) { return #if IS_ENABLED(CONFIG_NET_VLAN) @@ -108,7 +108,7 @@ static int e1000_tx(struct e1000_dev *dev, void *buf, size_t len) return (dev->tx.sta & TDESC_STA_DD) ? 0 : -EIO; } -static int e1000_send(struct device *device, struct net_pkt *pkt) +static int e1000_send(const struct device *device, struct net_pkt *pkt) { struct e1000_dev *dev = device->data; size_t len = net_pkt_get_len(pkt); @@ -160,7 +160,7 @@ static struct net_pkt *e1000_rx(struct e1000_dev *dev) return pkt; } -static void e1000_isr(struct device *device) +static void e1000_isr(const struct device *device) { struct e1000_dev *dev = device->data; uint32_t icr = ior32(dev, ICR); /* Cleared upon read */ @@ -212,7 +212,7 @@ static void e1000_isr(struct device *device) DEVICE_DECLARE(eth_e1000); -int e1000_probe(struct device *device) +int e1000_probe(const struct device *device) { const pcie_bdf_t bdf = PCIE_BDF(0, 3, 0); struct e1000_dev *dev = device->data; diff --git a/drivers/ethernet/eth_enc28j60.c b/drivers/ethernet/eth_enc28j60.c index 7f02e4cd579814..8801bc3a48b13c 100644 --- a/drivers/ethernet/eth_enc28j60.c +++ b/drivers/ethernet/eth_enc28j60.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #define D10D24S 11 -static int eth_enc28j60_soft_reset(struct device *dev) +static int eth_enc28j60_soft_reset(const struct device *dev) { struct eth_enc28j60_runtime *context = dev->data; uint8_t buf[2] = { ENC28J60_SPI_SC, 0xFF }; @@ -44,7 +44,7 @@ static int eth_enc28j60_soft_reset(struct device *dev) return spi_write(context->spi, &context->spi_cfg, &tx); } -static void eth_enc28j60_set_bank(struct device *dev, uint16_t reg_addr) +static void eth_enc28j60_set_bank(const struct device *dev, uint16_t reg_addr) { struct eth_enc28j60_runtime *context = dev->data; uint8_t buf[2]; @@ -78,7 +78,8 @@ static void eth_enc28j60_set_bank(struct device *dev, uint16_t reg_addr) } } -static void eth_enc28j60_write_reg(struct device *dev, uint16_t reg_addr, +static void eth_enc28j60_write_reg(const struct device *dev, + uint16_t reg_addr, uint8_t value) { struct eth_enc28j60_runtime *context = dev->data; @@ -98,7 +99,7 @@ static void eth_enc28j60_write_reg(struct device *dev, uint16_t reg_addr, spi_write(context->spi, &context->spi_cfg, &tx); } -static void eth_enc28j60_read_reg(struct device *dev, uint16_t reg_addr, +static void eth_enc28j60_read_reg(const struct device *dev, uint16_t reg_addr, uint8_t *value) { struct eth_enc28j60_runtime *context = dev->data; @@ -137,7 +138,8 @@ static void eth_enc28j60_read_reg(struct device *dev, uint16_t reg_addr, } } -static void eth_enc28j60_set_eth_reg(struct device *dev, uint16_t reg_addr, +static void eth_enc28j60_set_eth_reg(const struct device *dev, + uint16_t reg_addr, uint8_t value) { struct eth_enc28j60_runtime *context = dev->data; @@ -158,7 +160,8 @@ static void eth_enc28j60_set_eth_reg(struct device *dev, uint16_t reg_addr, } -static void eth_enc28j60_clear_eth_reg(struct device *dev, uint16_t reg_addr, +static void eth_enc28j60_clear_eth_reg(const struct device *dev, + uint16_t reg_addr, uint8_t value) { struct eth_enc28j60_runtime *context = dev->data; @@ -178,7 +181,8 @@ static void eth_enc28j60_clear_eth_reg(struct device *dev, uint16_t reg_addr, spi_write(context->spi, &context->spi_cfg, &tx); } -static void eth_enc28j60_write_mem(struct device *dev, uint8_t *data_buffer, +static void eth_enc28j60_write_mem(const struct device *dev, + uint8_t *data_buffer, uint16_t buf_len) { struct eth_enc28j60_runtime *context = dev->data; @@ -220,7 +224,8 @@ static void eth_enc28j60_write_mem(struct device *dev, uint8_t *data_buffer, } } -static void eth_enc28j60_read_mem(struct device *dev, uint8_t *data_buffer, +static void eth_enc28j60_read_mem(const struct device *dev, + uint8_t *data_buffer, uint16_t buf_len) { struct eth_enc28j60_runtime *context = dev->data; @@ -271,7 +276,8 @@ static void eth_enc28j60_read_mem(struct device *dev, uint8_t *data_buffer, } } -static void eth_enc28j60_write_phy(struct device *dev, uint16_t reg_addr, +static void eth_enc28j60_write_phy(const struct device *dev, + uint16_t reg_addr, int16_t data) { uint8_t data_mistat; @@ -290,7 +296,7 @@ static void eth_enc28j60_write_phy(struct device *dev, uint16_t reg_addr, } while ((data_mistat & ENC28J60_BIT_MISTAT_BUSY)); } -static void eth_enc28j60_gpio_callback(struct device *dev, +static void eth_enc28j60_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { @@ -300,7 +306,7 @@ static void eth_enc28j60_gpio_callback(struct device *dev, k_sem_give(&context->int_sem); } -static void eth_enc28j60_init_buffers(struct device *dev) +static void eth_enc28j60_init_buffers(const struct device *dev) { uint8_t data_estat; @@ -347,7 +353,7 @@ static void eth_enc28j60_init_buffers(struct device *dev) } while (!(data_estat & ENC28J60_BIT_ESTAT_CLKRDY)); } -static void eth_enc28j60_init_mac(struct device *dev) +static void eth_enc28j60_init_mac(const struct device *dev) { const struct eth_enc28j60_config *config = dev->config; struct eth_enc28j60_runtime *context = dev->data; @@ -397,7 +403,7 @@ static void eth_enc28j60_init_mac(struct device *dev) context->mac_address[0]); } -static void eth_enc28j60_init_phy(struct device *dev) +static void eth_enc28j60_init_phy(const struct device *dev) { const struct eth_enc28j60_config *config = dev->config; @@ -431,7 +437,7 @@ static struct net_if *get_iface(struct eth_enc28j60_runtime *ctx, #endif } -static int eth_enc28j60_tx(struct device *dev, struct net_pkt *pkt) +static int eth_enc28j60_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_enc28j60_runtime *context = dev->data; uint16_t tx_bufaddr = ENC28J60_TXSTART; @@ -504,7 +510,7 @@ static int eth_enc28j60_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static int eth_enc28j60_rx(struct device *dev, uint16_t *vlan_tag) +static int eth_enc28j60_rx(const struct device *dev, uint16_t *vlan_tag) { const struct eth_enc28j60_config *config = dev->config; struct eth_enc28j60_runtime *context = dev->data; @@ -657,7 +663,7 @@ static int eth_enc28j60_rx(struct device *dev, uint16_t *vlan_tag) return 0; } -static void eth_enc28j60_rx_thread(struct device *dev) +static void eth_enc28j60_rx_thread(const struct device *dev) { struct eth_enc28j60_runtime *context = dev->data; uint16_t vlan_tag = NET_VLAN_TAG_UNSPEC; @@ -677,7 +683,7 @@ static void eth_enc28j60_rx_thread(struct device *dev) } } -static enum ethernet_hw_caps eth_enc28j60_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_enc28j60_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -690,7 +696,7 @@ static enum ethernet_hw_caps eth_enc28j60_get_capabilities(struct device *dev) static void eth_enc28j60_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_enc28j60_runtime *context = dev->data; net_if_set_link_addr(iface, context->mac_address, @@ -715,7 +721,7 @@ static const struct ethernet_api api_funcs = { .send = eth_enc28j60_tx, }; -static int eth_enc28j60_init(struct device *dev) +static int eth_enc28j60_init(const struct device *dev) { const struct eth_enc28j60_config *config = dev->config; struct eth_enc28j60_runtime *context = dev->data; diff --git a/drivers/ethernet/eth_enc28j60_priv.h b/drivers/ethernet/eth_enc28j60_priv.h index 03f84f595566af..c5a118ddb186de 100644 --- a/drivers/ethernet/eth_enc28j60_priv.h +++ b/drivers/ethernet/eth_enc28j60_priv.h @@ -233,8 +233,8 @@ struct eth_enc28j60_runtime { CONFIG_ETH_ENC28J60_RX_THREAD_STACK_SIZE); struct k_thread thread; uint8_t mac_address[6]; - struct device *gpio; - struct device *spi; + const struct device *gpio; + const struct device *spi; struct spi_cs_control spi_cs; struct spi_config spi_cfg; struct gpio_callback gpio_cb; diff --git a/drivers/ethernet/eth_enc424j600.c b/drivers/ethernet/eth_enc424j600.c index 773071403940f1..b0c6f3586935a4 100644 --- a/drivers/ethernet/eth_enc424j600.c +++ b/drivers/ethernet/eth_enc424j600.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(ethdrv, CONFIG_ETHERNET_LOG_LEVEL); -static void enc424j600_write_sbc(struct device *dev, uint8_t cmd) +static void enc424j600_write_sbc(const struct device *dev, uint8_t cmd) { struct enc424j600_runtime *context = dev->data; uint8_t buf[2] = { cmd, 0xFF }; @@ -39,7 +39,7 @@ static void enc424j600_write_sbc(struct device *dev, uint8_t cmd) spi_write(context->spi, &context->spi_cfg, &tx); } -static void enc424j600_write_sfru(struct device *dev, uint8_t addr, +static void enc424j600_write_sfru(const struct device *dev, uint8_t addr, uint16_t value) { struct enc424j600_runtime *context = dev->data; @@ -61,7 +61,7 @@ static void enc424j600_write_sfru(struct device *dev, uint8_t addr, spi_write(context->spi, &context->spi_cfg, &tx); } -static void enc424j600_read_sfru(struct device *dev, uint8_t addr, +static void enc424j600_read_sfru(const struct device *dev, uint8_t addr, uint16_t *value) { struct enc424j600_runtime *context = dev->data; @@ -94,7 +94,7 @@ static void enc424j600_read_sfru(struct device *dev, uint8_t addr, } } -static void enc424j600_modify_sfru(struct device *dev, uint8_t opcode, +static void enc424j600_modify_sfru(const struct device *dev, uint8_t opcode, uint16_t addr, uint16_t value) { struct enc424j600_runtime *context = dev->data; @@ -123,7 +123,8 @@ static void enc424j600_modify_sfru(struct device *dev, uint8_t opcode, enc424j600_modify_sfru(dev, ENC424J600_NBC_BFCU, addr, value) -static void enc424j600_write_phy(struct device *dev, uint16_t addr, uint16_t data) +static void enc424j600_write_phy(const struct device *dev, uint16_t addr, + uint16_t data) { uint16_t mistat; @@ -136,7 +137,8 @@ static void enc424j600_write_phy(struct device *dev, uint16_t addr, uint16_t dat } while ((mistat & ENC424J600_MISTAT_BUSY)); } -static void enc424j600_read_phy(struct device *dev, uint16_t addr, uint16_t *data) +static void enc424j600_read_phy(const struct device *dev, uint16_t addr, + uint16_t *data) { uint16_t mistat; @@ -153,7 +155,7 @@ static void enc424j600_read_phy(struct device *dev, uint16_t addr, uint16_t *dat enc424j600_read_sfru(dev, ENC424J600_SFR3_MIRDL, data); } -static void enc424j600_write_mem(struct device *dev, uint8_t opcode, +static void enc424j600_write_mem(const struct device *dev, uint8_t opcode, uint8_t *data_buffer, uint16_t buf_len) { struct enc424j600_runtime *context = dev->data; @@ -179,7 +181,7 @@ static void enc424j600_write_mem(struct device *dev, uint8_t opcode, } } -static void enc424j600_read_mem(struct device *dev, uint8_t opcode, +static void enc424j600_read_mem(const struct device *dev, uint8_t opcode, uint8_t *data_buffer, uint16_t buf_len) { struct enc424j600_runtime *context = dev->data; @@ -213,7 +215,7 @@ static void enc424j600_read_mem(struct device *dev, uint8_t opcode, } } -static void enc424j600_gpio_callback(struct device *dev, +static void enc424j600_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { @@ -223,7 +225,7 @@ static void enc424j600_gpio_callback(struct device *dev, k_sem_give(&context->int_sem); } -static void enc424j600_init_filters(struct device *dev) +static void enc424j600_init_filters(const struct device *dev) { uint16_t tmp; @@ -239,7 +241,7 @@ static void enc424j600_init_filters(struct device *dev) } } -static void enc424j600_init_phy(struct device *dev) +static void enc424j600_init_phy(const struct device *dev) { uint16_t tmp; @@ -261,7 +263,7 @@ static void enc424j600_init_phy(struct device *dev) enc424j600_write_phy(dev, ENC424J600_PSFR_PHCON1, tmp); } -static void enc424j600_setup_mac(struct device *dev) +static void enc424j600_setup_mac(const struct device *dev) { uint16_t tmp; uint16_t macon2; @@ -302,7 +304,7 @@ static void enc424j600_setup_mac(struct device *dev) } } -static int enc424j600_tx(struct device *dev, struct net_pkt *pkt) +static int enc424j600_tx(const struct device *dev, struct net_pkt *pkt) { struct enc424j600_runtime *context = dev->data; uint16_t len = net_pkt_get_len(pkt); @@ -341,7 +343,7 @@ static int enc424j600_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static int enc424j600_rx(struct device *dev) +static int enc424j600_rx(const struct device *dev) { struct enc424j600_runtime *context = dev->data; const struct enc424j600_config *config = dev->config; @@ -439,7 +441,7 @@ static int enc424j600_rx(struct device *dev) return 0; } -static void enc424j600_rx_thread(struct device *dev) +static void enc424j600_rx_thread(const struct device *dev) { struct enc424j600_runtime *context = dev->data; uint16_t eir; @@ -493,7 +495,7 @@ static void enc424j600_rx_thread(struct device *dev) } } -static enum ethernet_hw_caps enc424j600_get_capabilities(struct device *dev) +static enum ethernet_hw_caps enc424j600_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -502,7 +504,7 @@ static enum ethernet_hw_caps enc424j600_get_capabilities(struct device *dev) static void enc424j600_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct enc424j600_runtime *context = dev->data; net_if_set_link_addr(iface, context->mac_address, @@ -515,7 +517,7 @@ static void enc424j600_iface_init(struct net_if *iface) context->iface_initialized = true; } -static int enc424j600_start_device(struct device *dev) +static int enc424j600_start_device(const struct device *dev) { struct enc424j600_runtime *context = dev->data; uint16_t tmp; @@ -545,7 +547,7 @@ static int enc424j600_start_device(struct device *dev) return 0; } -static int enc424j600_stop_device(struct device *dev) +static int enc424j600_stop_device(const struct device *dev) { struct enc424j600_runtime *context = dev->data; uint16_t tmp; @@ -594,7 +596,7 @@ static const struct ethernet_api api_funcs = { .stop = enc424j600_stop_device, }; -static int enc424j600_init(struct device *dev) +static int enc424j600_init(const struct device *dev) { const struct enc424j600_config *config = dev->config; struct enc424j600_runtime *context = dev->data; diff --git a/drivers/ethernet/eth_enc424j600_priv.h b/drivers/ethernet/eth_enc424j600_priv.h index d57dd9c4992afa..b9bc7a9d80745f 100644 --- a/drivers/ethernet/eth_enc424j600_priv.h +++ b/drivers/ethernet/eth_enc424j600_priv.h @@ -294,8 +294,8 @@ struct enc424j600_runtime { struct k_thread thread; uint8_t mac_address[6]; - struct device *gpio; - struct device *spi; + const struct device *gpio; + const struct device *spi; struct spi_cs_control spi_cs; struct spi_config spi_cfg; struct gpio_callback gpio_cb; diff --git a/drivers/ethernet/eth_gecko.c b/drivers/ethernet/eth_gecko.c index eeaaa144477e2a..d864a65a7dd514 100644 --- a/drivers/ethernet/eth_gecko.c +++ b/drivers/ethernet/eth_gecko.c @@ -63,7 +63,7 @@ static void link_configure(ETH_TypeDef *eth, uint32_t flags) eth->NETWORKCTRL |= (ETH_NETWORKCTRL_ENBTX | ETH_NETWORKCTRL_ENBRX); } -static void eth_gecko_setup_mac(struct device *dev) +static void eth_gecko_setup_mac(const struct device *dev) { const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); ETH_TypeDef *eth = cfg->regs; @@ -134,7 +134,7 @@ static void rx_error_handler(ETH_TypeDef *eth) ETH_RX_ENABLE(eth); } -static struct net_pkt *frame_get(struct device *dev) +static struct net_pkt *frame_get(const struct device *dev) { struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); @@ -234,7 +234,7 @@ static struct net_pkt *frame_get(struct device *dev) return rx_frame; } -static void eth_rx(struct device *dev) +static void eth_rx(const struct device *dev) { struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); struct net_pkt *rx_frame; @@ -260,7 +260,7 @@ static void eth_rx(struct device *dev) } } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); @@ -324,7 +324,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) static void rx_thread(void *arg1, void *unused1, void *unused2) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); int res; @@ -369,7 +369,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2) static void eth_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); ETH_TypeDef *eth = cfg->regs; @@ -421,7 +421,7 @@ static void eth_isr(void *arg) eth->IFCR = int_clr; } -static void eth_init_clocks(struct device *dev) +static void eth_init_clocks(const struct device *dev) { __ASSERT_NO_MSG(dev != NULL); @@ -429,7 +429,7 @@ static void eth_init_clocks(struct device *dev) CMU_ClockEnable(cmuClock_ETH, true); } -static void eth_init_pins(struct device *dev) +static void eth_init_pins(const struct device *dev) { const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); ETH_TypeDef *eth = cfg->regs; @@ -461,7 +461,7 @@ static void eth_init_pins(struct device *dev) } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); ETH_TypeDef *eth = cfg->regs; @@ -497,7 +497,7 @@ static void generate_mac(uint8_t mac_addr[6]) static void eth_iface_init(struct net_if *iface) { - struct device *const dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_gecko_dev_data *const dev_data = DEV_DATA(dev); const struct eth_gecko_dev_cfg *const cfg = DEV_CFG(dev); ETH_TypeDef *eth = cfg->regs; @@ -617,7 +617,7 @@ static void eth_iface_init(struct net_if *iface) 0, K_NO_WAIT); } -static enum ethernet_hw_caps eth_gecko_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_gecko_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/ethernet/eth_liteeth.c b/drivers/ethernet/eth_liteeth.c index b7ee2e47dba934..b26a66829fd694 100644 --- a/drivers/ethernet/eth_liteeth.c +++ b/drivers/ethernet/eth_liteeth.c @@ -72,7 +72,7 @@ struct eth_liteeth_config { void (*config_func)(void); }; -static int eth_initialize(struct device *dev) +static int eth_initialize(const struct device *dev) { const struct eth_liteeth_config *config = dev->config; @@ -81,7 +81,7 @@ static int eth_initialize(struct device *dev) return 0; } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { int key; uint16_t len; @@ -113,7 +113,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static void eth_rx(struct device *port) +static void eth_rx(const struct device *port) { struct net_pkt *pkt; struct eth_liteeth_dev_data *context = port->data; @@ -158,7 +158,7 @@ static void eth_rx(struct device *port) irq_unlock(key); } -static void eth_irq_handler(struct device *port) +static void eth_irq_handler(const struct device *port) { /* check sram reader events (tx) */ if (sys_read8(LITEETH_TX_EV_PENDING) & LITEETH_EV_TX) { @@ -190,7 +190,7 @@ static const struct eth_liteeth_config eth_config = { static void eth_iface_init(struct net_if *iface) { - struct device *port = net_if_get_device(iface); + const struct device *port = net_if_get_device(iface); struct eth_liteeth_dev_data *context = port->data; static bool init_done; @@ -231,7 +231,7 @@ static void eth_iface_init(struct net_if *iface) init_done = true; } -static enum ethernet_hw_caps eth_caps(struct device *dev) +static enum ethernet_hw_caps eth_caps(const struct device *dev) { ARG_UNUSED(dev); return ETHERNET_LINK_10BASE_T | ETHERNET_LINK_100BASE_T | diff --git a/drivers/ethernet/eth_mcux.c b/drivers/ethernet/eth_mcux.c index 50a174d4ace612..1abf8b917a40d8 100644 --- a/drivers/ethernet/eth_mcux.c +++ b/drivers/ethernet/eth_mcux.c @@ -70,7 +70,7 @@ enum eth_mcux_phy_state { eth_mcux_phy_state_closing }; -static void eth_mcux_init(struct device *dev); +static void eth_mcux_init(const struct device *dev); static const char * phy_state_name(enum eth_mcux_phy_state state) __attribute__((unused)); @@ -116,11 +116,11 @@ struct eth_context { #ifdef CONFIG_NET_POWER_MANAGEMENT const char *clock_name; clock_ip_name_t clock; - struct device *clock_dev; + const struct device *clock_dev; #endif enet_handle_t enet_handle; #if defined(CONFIG_PTP_CLOCK_MCUX) - struct device *ptp_clock; + const struct device *ptp_clock; enet_ptp_config_t ptp_config; float clk_ratio; #endif @@ -197,7 +197,8 @@ tx_buffer[CONFIG_ETH_MCUX_TX_BUFFERS][ETH_MCUX_BUFFER_SIZE]; static void eth_mcux_phy_enter_reset(struct eth_context *context); void eth_mcux_phy_stop(struct eth_context *context); -static int eth_mcux_device_pm_control(struct device *dev, uint32_t command, +static int eth_mcux_device_pm_control(const struct device *dev, + uint32_t command, void *context, device_pm_cb cb, void *arg) { struct eth_context *eth_ctx = (struct eth_context *)dev->data; @@ -710,7 +711,7 @@ static bool eth_get_ptp_data(struct net_if *iface, struct net_pkt *pkt, } #endif /* CONFIG_PTP_CLOCK_MCUX */ -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_context *context = dev->data; uint16_t total_len = net_pkt_get_len(pkt); @@ -772,7 +773,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static void eth_rx(struct device *iface) +static void eth_rx(const struct device *iface) { struct eth_context *context = iface->data; uint16_t vlan_tag = NET_VLAN_TAG_UNSPEC; @@ -929,7 +930,7 @@ static inline void ts_register_tx_event(struct eth_context *context) static void eth_callback(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *param) { - struct device *iface = param; + const struct device *iface = param; struct eth_context *context = iface->data; switch (event) { @@ -1000,7 +1001,7 @@ static void generate_eth1_unique_mac(uint8_t *mac_addr) } #endif -static void eth_mcux_init(struct device *dev) +static void eth_mcux_init(const struct device *dev) { struct eth_context *context = dev->data; enet_config_t enet_config; @@ -1091,7 +1092,7 @@ static void eth_mcux_init(struct device *dev) eth_mcux_phy_start(context); } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; @@ -1137,7 +1138,7 @@ static void net_if_mcast_cb(struct net_if *iface, const struct in6_addr *addr, bool is_joined) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; struct net_eth_addr mac_addr; @@ -1153,7 +1154,7 @@ static void net_if_mcast_cb(struct net_if *iface, static void eth_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; #if defined(CONFIG_NET_IPV6) @@ -1180,7 +1181,7 @@ static void eth_iface_init(struct net_if *iface) context->config_func(); } -static enum ethernet_hw_caps eth_mcux_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_mcux_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -1197,7 +1198,7 @@ static enum ethernet_hw_caps eth_mcux_get_capabilities(struct device *dev) } #if defined(CONFIG_PTP_CLOCK_MCUX) -static struct device *eth_mcux_get_ptp_clock(struct device *dev) +static const struct device *eth_mcux_get_ptp_clock(const struct device *dev) { struct eth_context *context = dev->data; @@ -1217,7 +1218,7 @@ static const struct ethernet_api api_funcs = { #if defined(CONFIG_PTP_CLOCK_MCUX) static void eth_mcux_ptp_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; struct eth_context *context = dev->data; ENET_Ptp1588TimerIRQHandler(context->base, &context->enet_handle); @@ -1227,7 +1228,7 @@ static void eth_mcux_ptp_isr(void *p) #if DT_INST_IRQ_HAS_NAME(0, common) static void eth_mcux_dispacher_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; struct eth_context *context = dev->data; uint32_t EIR = ENET_GetInterruptStatus(context->base); int irq_lock_key = irq_lock(); @@ -1250,7 +1251,7 @@ static void eth_mcux_dispacher_isr(void *p) #if DT_INST_IRQ_HAS_NAME(0, rx) static void eth_mcux_rx_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; struct eth_context *context = dev->data; ENET_ReceiveIRQHandler(context->base, &context->enet_handle); @@ -1260,7 +1261,7 @@ static void eth_mcux_rx_isr(void *p) #if DT_INST_IRQ_HAS_NAME(0, tx) static void eth_mcux_tx_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; struct eth_context *context = dev->data; ENET_TransmitIRQHandler(context->base, &context->enet_handle); @@ -1270,7 +1271,7 @@ static void eth_mcux_tx_isr(void *p) #if DT_INST_IRQ_HAS_NAME(0, err_misc) static void eth_mcux_error_isr(void *p) { - struct device *dev = p; + const struct device *dev = p; struct eth_context *context = dev->data; uint32_t pending = ENET_GetInterruptStatus(context->base); @@ -1399,7 +1400,8 @@ struct ptp_context { static struct ptp_context ptp_mcux_0_context; -static int ptp_clock_mcux_set(struct device *dev, struct net_ptp_time *tm) +static int ptp_clock_mcux_set(const struct device *dev, + struct net_ptp_time *tm) { struct ptp_context *ptp_context = dev->data; struct eth_context *context = ptp_context->eth_context; @@ -1412,7 +1414,8 @@ static int ptp_clock_mcux_set(struct device *dev, struct net_ptp_time *tm) return 0; } -static int ptp_clock_mcux_get(struct device *dev, struct net_ptp_time *tm) +static int ptp_clock_mcux_get(const struct device *dev, + struct net_ptp_time *tm) { struct ptp_context *ptp_context = dev->data; struct eth_context *context = ptp_context->eth_context; @@ -1425,7 +1428,7 @@ static int ptp_clock_mcux_get(struct device *dev, struct net_ptp_time *tm) return 0; } -static int ptp_clock_mcux_adjust(struct device *dev, int increment) +static int ptp_clock_mcux_adjust(const struct device *dev, int increment) { struct ptp_context *ptp_context = dev->data; struct eth_context *context = ptp_context->eth_context; @@ -1452,7 +1455,7 @@ static int ptp_clock_mcux_adjust(struct device *dev, int increment) return ret; } -static int ptp_clock_mcux_rate_adjust(struct device *dev, float ratio) +static int ptp_clock_mcux_rate_adjust(const struct device *dev, float ratio) { const int hw_inc = NSEC_PER_SEC / CONFIG_ETH_MCUX_PTP_CLOCK_SRC_HZ; struct ptp_context *ptp_context = dev->data; @@ -1510,9 +1513,9 @@ static const struct ptp_clock_driver_api api = { .rate_adjust = ptp_clock_mcux_rate_adjust, }; -static int ptp_mcux_init(struct device *port) +static int ptp_mcux_init(const struct device *port) { - struct device *eth_dev = DEVICE_GET(eth_mcux_0); + const struct device *eth_dev = DEVICE_GET(eth_mcux_0); struct eth_context *context = eth_dev->data; struct ptp_context *ptp_context = port->data; diff --git a/drivers/ethernet/eth_native_posix.c b/drivers/ethernet/eth_native_posix.c index 9f64683986cad7..135bf25b1067f4 100644 --- a/drivers/ethernet/eth_native_posix.c +++ b/drivers/ethernet/eth_native_posix.c @@ -64,7 +64,7 @@ struct eth_context { struct net_stats_eth stats; #endif #if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK) - struct device *ptp_clock; + const struct device *ptp_clock; #endif }; @@ -178,7 +178,7 @@ static void update_gptp(struct net_if *iface, struct net_pkt *pkt, #define update_gptp(iface, pkt, send) #endif /* CONFIG_NET_GPTP */ -static int eth_send(struct device *dev, struct net_pkt *pkt) +static int eth_send(const struct device *dev, struct net_pkt *pkt) { struct eth_context *ctx = dev->data; int count = net_pkt_get_len(pkt); @@ -201,7 +201,7 @@ static int eth_send(struct device *dev, struct net_pkt *pkt) return ret < 0 ? ret : 0; } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { ARG_UNUSED(dev); return 0; @@ -492,7 +492,7 @@ static void eth_iface_init(struct net_if *iface) } static -enum ethernet_hw_caps eth_posix_native_get_capabilities(struct device *dev) +enum ethernet_hw_caps eth_posix_native_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -516,7 +516,7 @@ enum ethernet_hw_caps eth_posix_native_get_capabilities(struct device *dev) } #if defined(CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK) -static struct device *eth_get_ptp_clock(struct device *dev) +static const struct device *eth_get_ptp_clock(const struct device *dev) { struct eth_context *context = dev->data; @@ -525,7 +525,7 @@ static struct device *eth_get_ptp_clock(struct device *dev) #endif #if defined(CONFIG_NET_STATISTICS_ETHERNET) -static struct net_stats_eth *get_stats(struct device *dev) +static struct net_stats_eth *get_stats(const struct device *dev) { struct eth_context *context = dev->data; @@ -533,7 +533,7 @@ static struct net_stats_eth *get_stats(struct device *dev) } #endif -static int set_config(struct device *dev, +static int set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -565,7 +565,7 @@ static int set_config(struct device *dev, } #if defined(CONFIG_NET_VLAN) -static int vlan_setup(struct device *dev, struct net_if *iface, +static int vlan_setup(const struct device *dev, struct net_if *iface, uint16_t tag, bool enable) { if (enable) { @@ -578,7 +578,7 @@ static int vlan_setup(struct device *dev, struct net_if *iface, } #endif /* CONFIG_NET_VLAN */ -static int eth_start_device(struct device *dev) +static int eth_start_device(const struct device *dev) { struct eth_context *context = dev->data; int ret; @@ -592,7 +592,7 @@ static int eth_start_device(struct device *dev) return ret; } -static int eth_stop_device(struct device *dev) +static int eth_stop_device(const struct device *dev) { struct eth_context *context = dev->data; @@ -660,7 +660,7 @@ struct ptp_context { UTIL_LISTIFY(CONFIG_ETH_NATIVE_POSIX_INTERFACE_COUNT, DEFINE_PTP_DEV_DATA, _) -static int ptp_clock_set_native_posix(struct device *clk, +static int ptp_clock_set_native_posix(const struct device *clk, struct net_ptp_time *tm) { ARG_UNUSED(clk); @@ -673,7 +673,7 @@ static int ptp_clock_set_native_posix(struct device *clk, return 0; } -static int ptp_clock_get_native_posix(struct device *clk, +static int ptp_clock_get_native_posix(const struct device *clk, struct net_ptp_time *tm) { ARG_UNUSED(clk); @@ -681,7 +681,7 @@ static int ptp_clock_get_native_posix(struct device *clk, return eth_clock_gettime(tm); } -static int ptp_clock_adjust_native_posix(struct device *clk, +static int ptp_clock_adjust_native_posix(const struct device *clk, int increment) { ARG_UNUSED(clk); @@ -694,7 +694,7 @@ static int ptp_clock_adjust_native_posix(struct device *clk, return 0; } -static int ptp_clock_rate_adjust_native_posix(struct device *clk, +static int ptp_clock_rate_adjust_native_posix(const struct device *clk, float ratio) { ARG_UNUSED(clk); @@ -715,9 +715,9 @@ static const struct ptp_clock_driver_api api = { }; #define PTP_INIT_FUNC(x, _) \ - static int ptp_init_##x(struct device *port) \ + static int ptp_init_##x(const struct device *port) \ { \ - struct device *eth_dev = DEVICE_GET(eth_native_posix_##x); \ + const struct device *eth_dev = DEVICE_GET(eth_native_posix_##x); \ struct eth_context *context = eth_dev->data; \ struct ptp_context *ptp_context = port->data; \ \ diff --git a/drivers/ethernet/eth_sam_gmac.c b/drivers/ethernet/eth_sam_gmac.c index 9bbc3f5208fec6..22ea8e6c34fe0a 100644 --- a/drivers/ethernet/eth_sam_gmac.c +++ b/drivers/ethernet/eth_sam_gmac.c @@ -1350,7 +1350,7 @@ static void eth_rx(struct gmac_queue *queue) uint16_t vlan_tag = NET_VLAN_TAG_UNSPEC; struct net_pkt *rx_frame; #if defined(CONFIG_PTP_CLOCK_SAM_GMAC) - struct device *const dev = net_if_get_device(dev_data->iface); + const struct device *dev = net_if_get_device(dev_data->iface); const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); Gmac *gmac = cfg->regs; struct gptp_hdr *hdr; @@ -1443,7 +1443,7 @@ static int priority2queue(enum net_priority priority) } #endif -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); struct eth_sam_dev_data *const dev_data = DEV_DATA(dev); @@ -1626,7 +1626,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) static void queue0_isr(void *arg) { - struct device *const dev = (struct device *const)arg; + const struct device *dev = (const struct device *)arg; const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); struct eth_sam_dev_data *const dev_data = DEV_DATA(dev); Gmac *gmac = cfg->regs; @@ -1677,7 +1677,7 @@ static void queue0_isr(void *arg) #if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1 static inline void priority_queue_isr(void *arg, unsigned int queue_idx) { - struct device *const dev = (struct device *const)arg; + const struct device *dev = (const struct device *)arg; const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); struct eth_sam_dev_data *const dev_data = DEV_DATA(dev); Gmac *gmac = cfg->regs; @@ -1760,7 +1760,7 @@ static void queue5_isr(void *arg) } #endif -static int eth_initialize(struct device *dev) +static int eth_initialize(const struct device *dev) { const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); @@ -1784,7 +1784,7 @@ static int eth_initialize(struct device *dev) #ifdef CONFIG_ETH_SAM_GMAC_MAC_I2C_EEPROM static void get_mac_addr_from_i2c_eeprom(uint8_t mac_addr[6]) { - struct device *dev; + const struct device *dev; uint32_t iaddr = CONFIG_ETH_SAM_GMAC_MAC_I2C_INT_ADDRESS; dev = device_get_binding(CONFIG_ETH_SAM_GMAC_MAC_I2C_DEV_NAME); @@ -1812,7 +1812,7 @@ static void monitor_work_handler(struct k_work *work) { struct eth_sam_dev_data *const dev_data = CONTAINER_OF(work, struct eth_sam_dev_data, monitor_work); - struct device *const dev = net_if_get_device(dev_data->iface); + const struct device *dev = net_if_get_device(dev_data->iface); const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); bool link_status; uint32_t link_config; @@ -1853,7 +1853,7 @@ static void monitor_work_handler(struct k_work *work) static void eth0_iface_init(struct net_if *iface) { - struct device *const dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_sam_dev_data *const dev_data = DEV_DATA(dev); const struct eth_sam_dev_cfg *const cfg = DEV_CFG(dev); static bool init_done; @@ -1975,7 +1975,7 @@ static void eth0_iface_init(struct net_if *iface) init_done = true; } -static enum ethernet_hw_caps eth_sam_gmac_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_sam_gmac_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -1991,7 +1991,7 @@ static enum ethernet_hw_caps eth_sam_gmac_get_capabilities(struct device *dev) } #if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1 -static int eth_sam_gmac_set_qav_param(struct device *dev, +static int eth_sam_gmac_set_qav_param(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -2033,7 +2033,7 @@ static int eth_sam_gmac_set_qav_param(struct device *dev, } #endif -static int eth_sam_gmac_set_config(struct device *dev, +static int eth_sam_gmac_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -2050,7 +2050,7 @@ static int eth_sam_gmac_set_config(struct device *dev, } #if GMAC_ACTIVE_PRIORITY_QUEUE_NUM >= 1 -static int eth_sam_gmac_get_qav_param(struct device *dev, +static int eth_sam_gmac_get_qav_param(const struct device *dev, enum ethernet_config_type type, struct ethernet_config *config) { @@ -2099,7 +2099,7 @@ static int eth_sam_gmac_get_qav_param(struct device *dev, } #endif -static int eth_sam_gmac_get_config(struct device *dev, +static int eth_sam_gmac_get_config(const struct device *dev, enum ethernet_config_type type, struct ethernet_config *config) { @@ -2119,7 +2119,7 @@ static int eth_sam_gmac_get_config(struct device *dev, } #if defined(CONFIG_PTP_CLOCK_SAM_GMAC) -static struct device *eth_sam_gmac_get_ptp_clock(struct device *dev) +static const struct device *eth_sam_gmac_get_ptp_clock(const struct device *dev) { struct eth_sam_dev_data *const dev_data = DEV_DATA(dev); @@ -2374,12 +2374,12 @@ ETH_NET_DEVICE_INIT(eth0_sam_gmac, DT_INST_LABEL(0), #if defined(CONFIG_PTP_CLOCK_SAM_GMAC) struct ptp_context { - struct device *eth_dev; + const struct device *eth_dev; }; static struct ptp_context ptp_gmac_0_context; -static int ptp_clock_sam_gmac_set(struct device *dev, +static int ptp_clock_sam_gmac_set(const struct device *dev, struct net_ptp_time *tm) { struct ptp_context *ptp_context = dev->data; @@ -2393,7 +2393,7 @@ static int ptp_clock_sam_gmac_set(struct device *dev, return 0; } -static int ptp_clock_sam_gmac_get(struct device *dev, +static int ptp_clock_sam_gmac_get(const struct device *dev, struct net_ptp_time *tm) { struct ptp_context *ptp_context = dev->data; @@ -2406,7 +2406,7 @@ static int ptp_clock_sam_gmac_get(struct device *dev, return 0; } -static int ptp_clock_sam_gmac_adjust(struct device *dev, int increment) +static int ptp_clock_sam_gmac_adjust(const struct device *dev, int increment) { struct ptp_context *ptp_context = dev->data; const struct eth_sam_dev_cfg *const cfg = DEV_CFG(ptp_context->eth_dev); @@ -2425,7 +2425,8 @@ static int ptp_clock_sam_gmac_adjust(struct device *dev, int increment) return 0; } -static int ptp_clock_sam_gmac_rate_adjust(struct device *dev, float ratio) +static int ptp_clock_sam_gmac_rate_adjust(const struct device *dev, + float ratio) { return -ENOTSUP; } @@ -2437,9 +2438,9 @@ static const struct ptp_clock_driver_api ptp_api = { .rate_adjust = ptp_clock_sam_gmac_rate_adjust, }; -static int ptp_gmac_init(struct device *port) +static int ptp_gmac_init(const struct device *port) { - struct device *eth_dev = DEVICE_GET(eth0_sam_gmac); + const struct device *eth_dev = DEVICE_GET(eth0_sam_gmac); struct eth_sam_dev_data *dev_data = eth_dev->data; struct ptp_context *ptp_context = port->data; diff --git a/drivers/ethernet/eth_sam_gmac_priv.h b/drivers/ethernet/eth_sam_gmac_priv.h index 6f476e78bd3b5e..864363c508db2e 100644 --- a/drivers/ethernet/eth_sam_gmac_priv.h +++ b/drivers/ethernet/eth_sam_gmac_priv.h @@ -272,7 +272,7 @@ struct eth_sam_dev_cfg { struct eth_sam_dev_data { struct net_if *iface; #if defined(CONFIG_PTP_CLOCK_SAM_GMAC) - struct device *ptp_clock; + const struct device *ptp_clock; #endif uint8_t mac_addr[6]; struct k_delayed_work monitor_work; diff --git a/drivers/ethernet/eth_smsc911x.c b/drivers/ethernet/eth_smsc911x.c index aeef75b3642370..4855f679e078bd 100644 --- a/drivers/ethernet/eth_smsc911x.c +++ b/drivers/ethernet/eth_smsc911x.c @@ -411,7 +411,7 @@ int smsc_init(void) /* Driver functions */ -static enum ethernet_hw_caps eth_smsc911x_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_smsc911x_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -419,7 +419,7 @@ static enum ethernet_hw_caps eth_smsc911x_get_capabilities(struct device *dev) } #if defined(CONFIG_NET_STATISTICS_ETHERNET) -static struct net_stats_eth *get_stats(struct device *dev) +static struct net_stats_eth *get_stats(const struct device *dev) { struct eth_context *context = dev->data; @@ -429,7 +429,7 @@ static struct net_stats_eth *get_stats(struct device *dev) static void eth_initialize(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; LOG_DBG("eth_initialize"); @@ -471,7 +471,7 @@ static int smsc_write_tx_fifo(const uint8_t *buf, uint32_t len, bool is_last) return 0; } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { uint16_t total_len = net_pkt_get_len(pkt); static uint8_t tx_buf[NET_ETH_MAX_FRAME_SIZE] __aligned(4); @@ -553,7 +553,8 @@ static int smsc_read_rx_fifo(struct net_pkt *pkt, uint32_t len) return 0; } -static struct net_pkt *smsc_recv_pkt(struct device *dev, uint32_t pkt_size) +static struct net_pkt *smsc_recv_pkt(const struct device *dev, + uint32_t pkt_size) { struct eth_context *context = dev->data; struct net_pkt *pkt; @@ -592,7 +593,7 @@ static struct net_pkt *smsc_recv_pkt(struct device *dev, uint32_t pkt_size) return pkt; } -static void eth_smsc911x_isr(struct device *dev) +static void eth_smsc911x_isr(const struct device *dev) { uint32_t int_status = SMSC9220->INT_STS; struct eth_context *context = dev->data; @@ -659,7 +660,7 @@ static void eth_smsc911x_isr(struct device *dev) DEVICE_DECLARE(eth_smsc911x_0); -int eth_init(struct device *dev) +int eth_init(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/ethernet/eth_stellaris.c b/drivers/ethernet/eth_stellaris.c index 09cd96d6487f57..40a63e7cd09f9f 100644 --- a/drivers/ethernet/eth_stellaris.c +++ b/drivers/ethernet/eth_stellaris.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #include "eth_stellaris_priv.h" -static void eth_stellaris_assign_mac(struct device *dev) +static void eth_stellaris_assign_mac(const struct device *dev) { uint8_t mac_addr[6] = DT_INST_PROP(0, local_mac_address); uint32_t value = 0x0; @@ -37,7 +37,7 @@ static void eth_stellaris_assign_mac(struct device *dev) sys_write32(value, REG_MACIA1); } -static void eth_stellaris_flush(struct device *dev) +static void eth_stellaris_flush(const struct device *dev) { struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); @@ -48,7 +48,7 @@ static void eth_stellaris_flush(struct device *dev) } } -static void eth_stellaris_send_byte(struct device *dev, uint8_t byte) +static void eth_stellaris_send_byte(const struct device *dev, uint8_t byte) { struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); @@ -61,7 +61,7 @@ static void eth_stellaris_send_byte(struct device *dev, uint8_t byte) } } -static int eth_stellaris_send(struct device *dev, struct net_pkt *pkt) +static int eth_stellaris_send(const struct device *dev, struct net_pkt *pkt) { struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); struct net_buf *frag; @@ -104,7 +104,7 @@ static int eth_stellaris_send(struct device *dev, struct net_pkt *pkt) static void eth_stellaris_rx_error(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); uint32_t val; eth_stats_update_errors_rx(iface); @@ -118,7 +118,7 @@ static void eth_stellaris_rx_error(struct net_if *iface) sys_write32(val, REG_MACRCTL); } -static struct net_pkt *eth_stellaris_rx_pkt(struct device *dev, +static struct net_pkt *eth_stellaris_rx_pkt(const struct device *dev, struct net_if *iface) { int frame_len, bytes_left; @@ -201,7 +201,7 @@ static struct net_pkt *eth_stellaris_rx_pkt(struct device *dev, return NULL; } -static void eth_stellaris_rx(struct device *dev) +static void eth_stellaris_rx(const struct device *dev) { struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); struct net_if *iface = dev_data->iface; @@ -230,7 +230,7 @@ static void eth_stellaris_rx(struct device *dev) static void eth_stellaris_isr(void *arg) { /* Read the interrupt status */ - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); int isr_val = sys_read32(REG_MACRIS); uint32_t lock; @@ -271,7 +271,7 @@ static void eth_stellaris_isr(void *arg) static void eth_stellaris_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); const struct eth_stellaris_config *dev_conf = DEV_CFG(dev); struct eth_stellaris_runtime *dev_data = DEV_DATA(dev); @@ -291,13 +291,13 @@ static void eth_stellaris_init(struct net_if *iface) } #if defined(CONFIG_NET_STATISTICS_ETHERNET) -static struct net_stats_eth *eth_stellaris_stats(struct device *dev) +static struct net_stats_eth *eth_stellaris_stats(const struct device *dev) { return &(DEV_DATA(dev)->stats); } #endif -static int eth_stellaris_dev_init(struct device *dev) +static int eth_stellaris_dev_init(const struct device *dev) { uint32_t value; @@ -322,7 +322,7 @@ static int eth_stellaris_dev_init(struct device *dev) DEVICE_DECLARE(eth_stellaris); -static void eth_stellaris_irq_config(struct device *dev) +static void eth_stellaris_irq_config(const struct device *dev) { /* Enable Interrupt. */ IRQ_CONNECT(DT_INST_IRQN(0), diff --git a/drivers/ethernet/eth_stellaris_priv.h b/drivers/ethernet/eth_stellaris_priv.h index 7f6534c1d2843d..e2c5874da17d0b 100644 --- a/drivers/ethernet/eth_stellaris_priv.h +++ b/drivers/ethernet/eth_stellaris_priv.h @@ -60,7 +60,7 @@ struct eth_stellaris_runtime { #endif }; -typedef void (*eth_stellaris_config_irq_t)(struct device *dev); +typedef void (*eth_stellaris_config_irq_t)(const struct device *dev); struct eth_stellaris_config { uint32_t mac_base; diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index 0957858f05f012..f49ff5ed2517e8 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -163,7 +163,7 @@ static inline void disable_mcast_filter(ETH_HandleTypeDef *heth) #endif /* CONFIG_SOC_SERIES_STM32H7X) */ } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_stm32_hal_dev_data *dev_data = DEV_DATA(dev); ETH_HandleTypeDef *heth; @@ -272,7 +272,7 @@ static struct net_if *get_iface(struct eth_stm32_hal_dev_data *ctx, #endif } -static struct net_pkt *eth_rx(struct device *dev, uint16_t *vlan_tag) +static struct net_pkt *eth_rx(const struct device *dev, uint16_t *vlan_tag) { struct eth_stm32_hal_dev_data *dev_data; ETH_HandleTypeDef *heth; @@ -404,7 +404,7 @@ static struct net_pkt *eth_rx(struct device *dev, uint16_t *vlan_tag) static void rx_thread(void *arg1, void *unused1, void *unused2) { uint16_t vlan_tag = NET_VLAN_TAG_UNSPEC; - struct device *dev; + const struct device *dev; struct eth_stm32_hal_dev_data *dev_data; struct net_pkt *pkt; int res; @@ -415,7 +415,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2) ARG_UNUSED(unused1); ARG_UNUSED(unused2); - dev = (struct device *)arg1; + dev = (const struct device *)arg1; dev_data = DEV_DATA(dev); __ASSERT_NO_MSG(dev_data != NULL); @@ -467,13 +467,13 @@ static void rx_thread(void *arg1, void *unused1, void *unused2) static void eth_isr(void *arg) { - struct device *dev; + const struct device *dev; struct eth_stm32_hal_dev_data *dev_data; ETH_HandleTypeDef *heth; __ASSERT_NO_MSG(arg != NULL); - dev = (struct device *)arg; + dev = (const struct device *)arg; dev_data = DEV_DATA(dev); __ASSERT_NO_MSG(dev_data != NULL); @@ -505,7 +505,7 @@ static void generate_mac(uint8_t *mac_addr) } #endif -static int eth_initialize(struct device *dev) +static int eth_initialize(const struct device *dev) { struct eth_stm32_hal_dev_data *dev_data; const struct eth_stm32_hal_dev_cfg *cfg; @@ -648,7 +648,7 @@ static int eth_initialize(struct device *dev) static void eth_iface_init(struct net_if *iface) { - struct device *dev; + const struct device *dev; struct eth_stm32_hal_dev_data *dev_data; __ASSERT_NO_MSG(iface != NULL); @@ -681,7 +681,7 @@ static void eth_iface_init(struct net_if *iface) net_if_flag_set(iface, NET_IF_NO_AUTO_START); } -static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -692,7 +692,7 @@ static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(struct device *dev) ; } -static int eth_stm32_hal_set_config(struct device *dev, +static int eth_stm32_hal_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { diff --git a/drivers/ethernet/eth_stm32_hal_priv.h b/drivers/ethernet/eth_stm32_hal_priv.h index fea4b11ce7d5d9..de083367d64903 100644 --- a/drivers/ethernet/eth_stm32_hal_priv.h +++ b/drivers/ethernet/eth_stm32_hal_priv.h @@ -37,7 +37,7 @@ struct eth_stm32_hal_dev_data { uint8_t mac_addr[6]; ETH_HandleTypeDef heth; /* clock device */ - struct device *clock; + const struct device *clock; struct k_mutex tx_mutex; struct k_sem rx_int_sem; K_KERNEL_STACK_MEMBER(rx_thread_stack, diff --git a/drivers/flash/flash_gecko.c b/drivers/flash/flash_gecko.c index 7132761779333d..9ace955b14fb53 100644 --- a/drivers/flash/flash_gecko.c +++ b/drivers/flash/flash_gecko.c @@ -38,7 +38,8 @@ static bool write_range_is_valid(off_t offset, uint32_t size); static bool read_range_is_valid(off_t offset, uint32_t size); static int erase_flash_block(off_t offset, size_t size); -static int flash_gecko_read(struct device *dev, off_t offset, void *data, +static int flash_gecko_read(const struct device *dev, off_t offset, + void *data, size_t size) { if (!read_range_is_valid(offset, size)) { @@ -54,7 +55,7 @@ static int flash_gecko_read(struct device *dev, off_t offset, void *data, return 0; } -static int flash_gecko_write(struct device *dev, off_t offset, +static int flash_gecko_write(const struct device *dev, off_t offset, const void *data, size_t size) { struct flash_gecko_data *const dev_data = DEV_DATA(dev); @@ -83,7 +84,8 @@ static int flash_gecko_write(struct device *dev, off_t offset, return ret; } -static int flash_gecko_erase(struct device *dev, off_t offset, size_t size) +static int flash_gecko_erase(const struct device *dev, off_t offset, + size_t size) { struct flash_gecko_data *const dev_data = DEV_DATA(dev); int ret; @@ -115,7 +117,7 @@ static int flash_gecko_erase(struct device *dev, off_t offset, size_t size) return ret; } -static int flash_gecko_write_protection(struct device *dev, bool enable) +static int flash_gecko_write_protection(const struct device *dev, bool enable) { struct flash_gecko_data *const dev_data = DEV_DATA(dev); @@ -179,7 +181,7 @@ static const struct flash_pages_layout flash_gecko_0_pages_layout = { .pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size), }; -void flash_gecko_page_layout(struct device *dev, +void flash_gecko_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -196,7 +198,7 @@ flash_gecko_get_parameters(const struct device *dev) return &flash_gecko_parameters; } -static int flash_gecko_init(struct device *dev) +static int flash_gecko_init(const struct device *dev) { struct flash_gecko_data *const dev_data = DEV_DATA(dev); diff --git a/drivers/flash/flash_handlers.c b/drivers/flash/flash_handlers.c index 585072329550e5..a5a6c425c2f970 100644 --- a/drivers/flash/flash_handlers.c +++ b/drivers/flash/flash_handlers.c @@ -7,35 +7,37 @@ #include #include -static inline int z_vrfy_flash_read(struct device *dev, off_t offset, +static inline int z_vrfy_flash_read(const struct device *dev, off_t offset, void *data, size_t len) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, read)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(data, len)); - return z_impl_flash_read((struct device *)dev, offset, (void *)data, - len); + return z_impl_flash_read((const struct device *)dev, offset, + (void *)data, + len); } #include -static inline int z_vrfy_flash_write(struct device *dev, off_t offset, - const void *data, size_t len) +static inline int z_vrfy_flash_write(const struct device *dev, off_t offset, + const void *data, size_t len) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write)); Z_OOPS(Z_SYSCALL_MEMORY_READ(data, len)); - return z_impl_flash_write((struct device *)dev, offset, - (const void *)data, len); + return z_impl_flash_write((const struct device *)dev, offset, + (const void *)data, len); } #include -static inline int z_vrfy_flash_write_protection_set(struct device *dev, +static inline int z_vrfy_flash_write_protection_set(const struct device *dev, bool enable) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, write_protection)); - return z_impl_flash_write_protection_set((struct device *)dev, enable); + return z_impl_flash_write_protection_set((const struct device *)dev, + enable); } #include -static inline size_t z_vrfy_flash_get_write_block_size(struct device *dev) +static inline size_t z_vrfy_flash_get_write_block_size(const struct device *dev) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_FLASH)); return z_impl_flash_get_write_block_size(dev); @@ -43,32 +45,34 @@ static inline size_t z_vrfy_flash_get_write_block_size(struct device *dev) #include #ifdef CONFIG_FLASH_PAGE_LAYOUT -static inline int z_vrfy_flash_get_page_info_by_offs(struct device *dev, - off_t offs, - struct flash_pages_info *info) +static inline int z_vrfy_flash_get_page_info_by_offs(const struct device *dev, + off_t offs, + struct flash_pages_info *info) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info))); - return z_impl_flash_get_page_info_by_offs((struct device *)dev, offs, - (struct flash_pages_info *)info); + return z_impl_flash_get_page_info_by_offs((const struct device *)dev, + offs, + (struct flash_pages_info *)info); } #include -static inline int z_vrfy_flash_get_page_info_by_idx(struct device *dev, - uint32_t idx, - struct flash_pages_info *info) +static inline int z_vrfy_flash_get_page_info_by_idx(const struct device *dev, + uint32_t idx, + struct flash_pages_info *info) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(info, sizeof(struct flash_pages_info))); - return z_impl_flash_get_page_info_by_idx((struct device *)dev, idx, - (struct flash_pages_info *)info); + return z_impl_flash_get_page_info_by_idx((const struct device *)dev, + idx, + (struct flash_pages_info *)info); } #include -static inline size_t z_vrfy_flash_get_page_count(struct device *dev) +static inline size_t z_vrfy_flash_get_page_count(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, page_layout)); - return z_impl_flash_get_page_count((struct device *)dev); + return z_impl_flash_get_page_count((const struct device *)dev); } #include @@ -76,7 +80,8 @@ static inline size_t z_vrfy_flash_get_page_count(struct device *dev) #ifdef CONFIG_FLASH_JESD216_API -static inline int z_vrfy_flash_sfdp_read(struct device *dev, off_t offset, +static inline int z_vrfy_flash_sfdp_read(const struct device *dev, + off_t offset, void *data, size_t len) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, sfdp_read)); @@ -85,7 +90,7 @@ static inline int z_vrfy_flash_sfdp_read(struct device *dev, off_t offset, } #include -static inline int z_vrfy_flash_read_jedec_id(struct device *dev, +static inline int z_vrfy_flash_read_jedec_id(const struct device *dev, uint8_t *id) { Z_OOPS(Z_SYSCALL_DRIVER_FLASH(dev, read_jedec_id)); diff --git a/drivers/flash/flash_page_layout.c b/drivers/flash/flash_page_layout.c index c8357f1b9019b5..1809e76db8f185 100644 --- a/drivers/flash/flash_page_layout.c +++ b/drivers/flash/flash_page_layout.c @@ -6,7 +6,7 @@ #include -static int flash_get_page_info(struct device *dev, off_t offs, +static int flash_get_page_info(const struct device *dev, off_t offs, bool use_addr, struct flash_pages_info *info) { const struct flash_driver_api *api = dev->api; @@ -52,19 +52,20 @@ static int flash_get_page_info(struct device *dev, off_t offs, return -EINVAL; /* page of the index doesn't exist */ } -int z_impl_flash_get_page_info_by_offs(struct device *dev, off_t offs, - struct flash_pages_info *info) +int z_impl_flash_get_page_info_by_offs(const struct device *dev, off_t offs, + struct flash_pages_info *info) { return flash_get_page_info(dev, offs, true, info); } -int z_impl_flash_get_page_info_by_idx(struct device *dev, uint32_t page_index, - struct flash_pages_info *info) +int z_impl_flash_get_page_info_by_idx(const struct device *dev, + uint32_t page_index, + struct flash_pages_info *info) { return flash_get_page_info(dev, page_index, false, info); } -size_t z_impl_flash_get_page_count(struct device *dev) +size_t z_impl_flash_get_page_count(const struct device *dev) { const struct flash_driver_api *api = dev->api; const struct flash_pages_layout *layout; @@ -81,7 +82,8 @@ size_t z_impl_flash_get_page_count(struct device *dev) return count; } -void flash_page_foreach(struct device *dev, flash_page_cb cb, void *data) +void flash_page_foreach(const struct device *dev, flash_page_cb cb, + void *data) { const struct flash_driver_api *api = dev->api; const struct flash_pages_layout *layout; diff --git a/drivers/flash/flash_sam.c b/drivers/flash/flash_sam.c index 7651fb80bfd6c2..0ffe89173691c1 100644 --- a/drivers/flash/flash_sam.c +++ b/drivers/flash/flash_sam.c @@ -58,18 +58,19 @@ static const struct flash_parameters flash_sam_parameters = { ((struct flash_sam_dev_data *const)(dev)->data) -static inline void flash_sam_sem_take(struct device *dev) +static inline void flash_sam_sem_take(const struct device *dev) { k_sem_take(&DEV_DATA(dev)->sem, K_FOREVER); } -static inline void flash_sam_sem_give(struct device *dev) +static inline void flash_sam_sem_give(const struct device *dev) { k_sem_give(&DEV_DATA(dev)->sem); } /* Check that the offset is within the flash */ -static bool flash_sam_valid_range(struct device *dev, off_t offset, size_t len) +static bool flash_sam_valid_range(const struct device *dev, off_t offset, + size_t len) { if (offset > CONFIG_FLASH_SIZE * 1024) { return false; @@ -92,7 +93,7 @@ static off_t flash_sam_get_page(off_t offset) * This function checks for errors and waits for the end of the * previous command. */ -static int flash_sam_wait_ready(struct device *dev) +static int flash_sam_wait_ready(const struct device *dev) { Efc *const efc = DEV_CFG(dev)->regs; @@ -130,7 +131,7 @@ static int flash_sam_wait_ready(struct device *dev) } /* This function writes a single page, either fully or partially. */ -static int flash_sam_write_page(struct device *dev, off_t offset, +static int flash_sam_write_page(const struct device *dev, off_t offset, const void *data, size_t len) { Efc *const efc = DEV_CFG(dev)->regs; @@ -156,7 +157,7 @@ static int flash_sam_write_page(struct device *dev, off_t offset, } /* Write data to the flash, page by page */ -static int flash_sam_write(struct device *dev, off_t offset, +static int flash_sam_write(const struct device *dev, off_t offset, const void *data, size_t len) { int rc; @@ -215,7 +216,7 @@ static int flash_sam_write(struct device *dev, off_t offset, } /* Read data from flash */ -static int flash_sam_read(struct device *dev, off_t offset, void *data, +static int flash_sam_read(const struct device *dev, off_t offset, void *data, size_t len) { LOG_DBG("offset = 0x%lx, len = %zu", (long)offset, len); @@ -230,7 +231,7 @@ static int flash_sam_read(struct device *dev, off_t offset, void *data, } /* Erase a single 8KiB block */ -static int flash_sam_erase_block(struct device *dev, off_t offset) +static int flash_sam_erase_block(const struct device *dev, off_t offset) { Efc *const efc = DEV_CFG(dev)->regs; @@ -245,7 +246,7 @@ static int flash_sam_erase_block(struct device *dev, off_t offset) } /* Erase multiple blocks */ -static int flash_sam_erase(struct device *dev, off_t offset, size_t len) +static int flash_sam_erase(const struct device *dev, off_t offset, size_t len) { int rc = 0; off_t i; @@ -294,7 +295,7 @@ static int flash_sam_erase(struct device *dev, off_t offset, size_t len) } /* Enable or disable the write protection */ -static int flash_sam_write_protection(struct device *dev, bool enable) +static int flash_sam_write_protection(const struct device *dev, bool enable) { Efc *const efc = DEV_CFG(dev)->regs; int rc = 0; @@ -326,7 +327,7 @@ static const struct flash_pages_layout flash_sam_pages_layout = { .pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size), }; -void flash_sam_page_layout(struct device *dev, +void flash_sam_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -343,7 +344,7 @@ flash_sam_get_parameters(const struct device *dev) return &flash_sam_parameters; } -static int flash_sam_init(struct device *dev) +static int flash_sam_init(const struct device *dev) { struct flash_sam_dev_data *const data = DEV_DATA(dev); diff --git a/drivers/flash/flash_sam0.c b/drivers/flash/flash_sam0.c index cacc4fb784bd4e..9b00ba2bdd89ee 100644 --- a/drivers/flash/flash_sam0.c +++ b/drivers/flash/flash_sam0.c @@ -70,14 +70,14 @@ static const struct flash_parameters flash_sam0_parameters = { .erase_value = 0xff, }; -static inline void flash_sam0_sem_take(struct device *dev) +static inline void flash_sam0_sem_take(const struct device *dev) { struct flash_sam0_data *ctx = dev->data; k_sem_take(&ctx->sem, K_FOREVER); } -static inline void flash_sam0_sem_give(struct device *dev) +static inline void flash_sam0_sem_give(const struct device *dev) { struct flash_sam0_data *ctx = dev->data; @@ -139,7 +139,7 @@ static int flash_sam0_check_status(off_t offset) return 0; } -static int flash_sam0_write_page(struct device *dev, off_t offset, +static int flash_sam0_write_page(const struct device *dev, off_t offset, const void *data) { const uint32_t *src = data; @@ -178,7 +178,7 @@ static int flash_sam0_write_page(struct device *dev, off_t offset, return 0; } -static int flash_sam0_erase_row(struct device *dev, off_t offset) +static int flash_sam0_erase_row(const struct device *dev, off_t offset) { *FLASH_MEM(offset) = 0U; #ifdef NVMCTRL_CTRLA_CMD_ER @@ -191,7 +191,7 @@ static int flash_sam0_erase_row(struct device *dev, off_t offset) #if CONFIG_SOC_FLASH_SAM0_EMULATE_BYTE_PAGES -static int flash_sam0_commit(struct device *dev) +static int flash_sam0_commit(const struct device *dev) { struct flash_sam0_data *ctx = dev->data; int err; @@ -221,7 +221,7 @@ static int flash_sam0_commit(struct device *dev) return 0; } -static int flash_sam0_write(struct device *dev, off_t offset, +static int flash_sam0_write(const struct device *dev, off_t offset, const void *data, size_t len) { struct flash_sam0_data *ctx = dev->data; @@ -259,7 +259,7 @@ static int flash_sam0_write(struct device *dev, off_t offset, #else /* CONFIG_SOC_FLASH_SAM0_EMULATE_BYTE_PAGES */ -static int flash_sam0_write(struct device *dev, off_t offset, +static int flash_sam0_write(const struct device *dev, off_t offset, const void *data, size_t len) { const uint8_t *pdata = data; @@ -298,7 +298,7 @@ static int flash_sam0_write(struct device *dev, off_t offset, #endif -static int flash_sam0_read(struct device *dev, off_t offset, void *data, +static int flash_sam0_read(const struct device *dev, off_t offset, void *data, size_t len) { int err; @@ -313,7 +313,8 @@ static int flash_sam0_read(struct device *dev, off_t offset, void *data, return 0; } -static int flash_sam0_erase(struct device *dev, off_t offset, size_t size) +static int flash_sam0_erase(const struct device *dev, off_t offset, + size_t size) { int err; @@ -347,7 +348,7 @@ static int flash_sam0_erase(struct device *dev, off_t offset, size_t size) return err; } -static int flash_sam0_write_protection(struct device *dev, bool enable) +static int flash_sam0_write_protection(const struct device *dev, bool enable) { off_t offset; int err; @@ -388,7 +389,7 @@ static int flash_sam0_write_protection(struct device *dev, bool enable) } #if CONFIG_FLASH_PAGE_LAYOUT -void flash_sam0_page_layout(struct device *dev, +void flash_sam0_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -405,7 +406,7 @@ flash_sam0_get_parameters(const struct device *dev) return &flash_sam0_parameters; } -static int flash_sam0_init(struct device *dev) +static int flash_sam0_init(const struct device *dev) { struct flash_sam0_data *ctx = dev->data; diff --git a/drivers/flash/flash_shell.c b/drivers/flash/flash_shell.c index 6838c188f9bd43..cbbea047207d27 100644 --- a/drivers/flash/flash_shell.c +++ b/drivers/flash/flash_shell.c @@ -21,7 +21,8 @@ static uint8_t __aligned(4) test_arr[TEST_ARR_SIZE]; static int parse_helper(const struct shell *shell, size_t *argc, - char **argv[], struct device **flash_dev, uint32_t *addr) + char **argv[], const struct device * *flash_dev, + uint32_t *addr) { char *endptr; @@ -47,7 +48,7 @@ static int parse_helper(const struct shell *shell, size_t *argc, static int cmd_erase(const struct shell *shell, size_t argc, char *argv[]) { - struct device *flash_dev; + const struct device *flash_dev; uint32_t page_addr; int result; uint32_t size; @@ -90,7 +91,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char *argv[]) { uint32_t check_array[BUF_ARRAY_CNT]; uint32_t buf_array[BUF_ARRAY_CNT]; - struct device *flash_dev; + const struct device *flash_dev; uint32_t w_addr; int ret; int j = 0; @@ -135,7 +136,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char *argv[]) static int cmd_read(const struct shell *shell, size_t argc, char *argv[]) { - struct device *flash_dev; + const struct device *flash_dev; uint32_t addr; int todo; int upto; @@ -173,7 +174,7 @@ static int cmd_read(const struct shell *shell, size_t argc, char *argv[]) static int cmd_test(const struct shell *shell, size_t argc, char *argv[]) { - struct device *flash_dev; + const struct device *flash_dev; uint32_t repeat; int result; uint32_t addr; @@ -226,7 +227,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get); static void device_name_get(size_t idx, struct shell_static_entry *entry) { - struct device *dev = shell_device_lookup(idx, NULL); + const struct device *dev = shell_device_lookup(idx, NULL); entry->syntax = (dev != NULL) ? dev->name : NULL; entry->handler = NULL; diff --git a/drivers/flash/flash_simulator.c b/drivers/flash/flash_simulator.c index b466f8a92f8a6b..049ba1a42f1571 100644 --- a/drivers/flash/flash_simulator.c +++ b/drivers/flash/flash_simulator.c @@ -146,7 +146,8 @@ static const struct flash_parameters flash_sim_parameters = { .erase_value = FLASH_SIMULATOR_ERASE_VALUE }; -static int flash_range_is_valid(struct device *dev, off_t offset, size_t len) +static int flash_range_is_valid(const struct device *dev, off_t offset, + size_t len) { ARG_UNUSED(dev); if ((offset + len > FLASH_SIMULATOR_FLASH_SIZE + @@ -158,7 +159,7 @@ static int flash_range_is_valid(struct device *dev, off_t offset, size_t len) return 1; } -static int flash_wp_set(struct device *dev, bool enable) +static int flash_wp_set(const struct device *dev, bool enable) { ARG_UNUSED(dev); write_protection = enable; @@ -171,7 +172,8 @@ static bool flash_wp_is_set(void) return write_protection; } -static int flash_sim_read(struct device *dev, const off_t offset, void *data, +static int flash_sim_read(const struct device *dev, const off_t offset, + void *data, const size_t len) { ARG_UNUSED(dev); @@ -201,7 +203,7 @@ static int flash_sim_read(struct device *dev, const off_t offset, void *data, return 0; } -static int flash_sim_write(struct device *dev, const off_t offset, +static int flash_sim_write(const struct device *dev, const off_t offset, const void *data, const size_t len) { uint8_t buf[FLASH_SIMULATOR_PROG_UNIT]; @@ -286,7 +288,7 @@ static void unit_erase(const uint32_t unit) FLASH_SIMULATOR_ERASE_UNIT); } -static int flash_sim_erase(struct device *dev, const off_t offset, +static int flash_sim_erase(const struct device *dev, const off_t offset, const size_t len) { ARG_UNUSED(dev); @@ -340,7 +342,7 @@ static const struct flash_pages_layout flash_sim_pages_layout = { .pages_size = FLASH_SIMULATOR_ERASE_UNIT, }; -static void flash_sim_page_layout(struct device *dev, +static void flash_sim_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -370,7 +372,7 @@ static const struct flash_driver_api flash_sim_api = { #ifdef CONFIG_ARCH_POSIX -static int flash_mock_init(struct device *dev) +static int flash_mock_init(const struct device *dev) { struct stat f_stat; int rc; @@ -422,7 +424,7 @@ static int flash_mock_init(struct device *dev) #else -static int flash_mock_init(struct device *dev) +static int flash_mock_init(const struct device *dev) { memset(mock_flash, FLASH_SIMULATOR_ERASE_VALUE, ARRAY_SIZE(mock_flash)); return 0; @@ -430,7 +432,7 @@ static int flash_mock_init(struct device *dev) #endif /* CONFIG_ARCH_POSIX */ -static int flash_init(struct device *dev) +static int flash_init(const struct device *dev) { STATS_INIT_AND_REG(flash_sim_stats, STATS_SIZE_32, "flash_sim_stats"); STATS_INIT_AND_REG(flash_sim_thresholds, STATS_SIZE_32, diff --git a/drivers/flash/flash_stm32.c b/drivers/flash/flash_stm32.c index 9bd1fd24ae3c11..a62d72b4a7da63 100644 --- a/drivers/flash/flash_stm32.c +++ b/drivers/flash/flash_stm32.c @@ -76,13 +76,13 @@ static const struct flash_parameters flash_stm32_parameters = { * similarly for flash_stm32_sem_give) to avoid confusion with locking * actual flash pages. */ -static inline void _flash_stm32_sem_take(struct device *dev) +static inline void _flash_stm32_sem_take(const struct device *dev) { k_sem_take(&FLASH_STM32_PRIV(dev)->sem, K_FOREVER); z_stm32_hsem_lock(CFG_HW_FLASH_SEMID, HSEM_LOCK_WAIT_FOREVER); } -static inline void _flash_stm32_sem_give(struct device *dev) +static inline void _flash_stm32_sem_give(const struct device *dev) { z_stm32_hsem_unlock(CFG_HW_FLASH_SEMID); k_sem_give(&FLASH_STM32_PRIV(dev)->sem); @@ -98,7 +98,7 @@ static inline void _flash_stm32_sem_give(struct device *dev) #endif #if !defined(CONFIG_SOC_SERIES_STM32WBX) -static int flash_stm32_check_status(struct device *dev) +static int flash_stm32_check_status(const struct device *dev) { uint32_t const error = #if defined(FLASH_FLAG_PGAERR) @@ -130,7 +130,7 @@ static int flash_stm32_check_status(struct device *dev) } #endif /* CONFIG_SOC_SERIES_STM32WBX */ -int flash_stm32_wait_flash_idle(struct device *dev) +int flash_stm32_wait_flash_idle(const struct device *dev) { int64_t timeout_time = k_uptime_get() + STM32_FLASH_TIMEOUT; int rc; @@ -153,7 +153,7 @@ int flash_stm32_wait_flash_idle(struct device *dev) return 0; } -static void flash_stm32_flush_caches(struct device *dev, +static void flash_stm32_flush_caches(const struct device *dev, off_t offset, size_t len) { #if defined(CONFIG_SOC_SERIES_STM32F0X) || defined(CONFIG_SOC_SERIES_STM32F3X) || \ @@ -182,7 +182,8 @@ static void flash_stm32_flush_caches(struct device *dev, #endif } -static int flash_stm32_read(struct device *dev, off_t offset, void *data, +static int flash_stm32_read(const struct device *dev, off_t offset, + void *data, size_t len) { if (!flash_stm32_valid_range(dev, offset, len, false)) { @@ -202,7 +203,8 @@ static int flash_stm32_read(struct device *dev, off_t offset, void *data, return 0; } -static int flash_stm32_erase(struct device *dev, off_t offset, size_t len) +static int flash_stm32_erase(const struct device *dev, off_t offset, + size_t len) { int rc; @@ -229,7 +231,7 @@ static int flash_stm32_erase(struct device *dev, off_t offset, size_t len) return rc; } -static int flash_stm32_write(struct device *dev, off_t offset, +static int flash_stm32_write(const struct device *dev, off_t offset, const void *data, size_t len) { int rc; @@ -255,7 +257,7 @@ static int flash_stm32_write(struct device *dev, off_t offset, return rc; } -static int flash_stm32_write_protection(struct device *dev, bool enable) +static int flash_stm32_write_protection(const struct device *dev, bool enable) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -342,7 +344,7 @@ static const struct flash_driver_api flash_stm32_api = { #endif }; -static int stm32_flash_init(struct device *dev) +static int stm32_flash_init(const struct device *dev) { #if defined(CONFIG_SOC_SERIES_STM32L4X) || \ defined(CONFIG_SOC_SERIES_STM32F0X) || \ @@ -350,7 +352,7 @@ static int stm32_flash_init(struct device *dev) defined(CONFIG_SOC_SERIES_STM32F3X) || \ defined(CONFIG_SOC_SERIES_STM32G0X) struct flash_stm32_priv *p = FLASH_STM32_PRIV(dev); - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); /* * On STM32F0, Flash interface clock source is always HSI, diff --git a/drivers/flash/flash_stm32.h b/drivers/flash/flash_stm32.h index 32a35cab7db6bc..3bd50ca0cba0fc 100644 --- a/drivers/flash/flash_stm32.h +++ b/drivers/flash/flash_stm32.h @@ -45,7 +45,7 @@ struct flash_stm32_priv { #define FLASH_STM32_REGS(dev) (FLASH_STM32_PRIV(dev)->regs) #ifdef CONFIG_FLASH_PAGE_LAYOUT -static inline bool flash_stm32_range_exists(struct device *dev, +static inline bool flash_stm32_range_exists(const struct device *dev, off_t offset, uint32_t len) { @@ -56,23 +56,24 @@ static inline bool flash_stm32_range_exists(struct device *dev, } #endif /* CONFIG_FLASH_PAGE_LAYOUT */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, uint32_t len, bool write); -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len); -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len); -int flash_stm32_wait_flash_idle(struct device *dev); +int flash_stm32_wait_flash_idle(const struct device *dev); #ifdef CONFIG_SOC_SERIES_STM32WBX -int flash_stm32_check_status(struct device *dev); +int flash_stm32_check_status(const struct device *dev); #endif /* CONFIG_SOC_SERIES_STM32WBX */ #ifdef CONFIG_FLASH_PAGE_LAYOUT -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size); #endif diff --git a/drivers/flash/flash_stm32_v1.c b/drivers/flash/flash_stm32_v1.c index 9b18a19ea16444..e070481cce5a95 100644 --- a/drivers/flash/flash_stm32_v1.c +++ b/drivers/flash/flash_stm32_v1.c @@ -115,7 +115,8 @@ static void erase_page_end(FLASH_TypeDef *regs) } #endif -static int write_value(struct device *dev, off_t offset, flash_prg_t val) +static int write_value(const struct device *dev, off_t offset, + flash_prg_t val) { volatile flash_prg_t *flash = (flash_prg_t *)( offset + CONFIG_FLASH_BASE_ADDRESS); @@ -161,14 +162,16 @@ static int write_value(struct device *dev, off_t offset, flash_prg_t val) /* offset and len must be aligned on 2 for write * positive and not beyond end of flash */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { return (!write || (offset % 2 == 0 && len % 2 == 0U)) && flash_stm32_range_exists(dev, offset, len); } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -200,7 +203,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -217,7 +220,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, return rc; } -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32f4x.c b/drivers/flash/flash_stm32f4x.c index 67b280ed3b3153..772dac2ea4dd2e 100644 --- a/drivers/flash/flash_stm32f4x.c +++ b/drivers/flash/flash_stm32f4x.c @@ -15,7 +15,8 @@ #define STM32F4X_SECTOR_MASK ((uint32_t) 0xFFFFFF07) -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { ARG_UNUSED(write); @@ -34,7 +35,7 @@ bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, return flash_stm32_range_exists(dev, offset, len); } -static int write_byte(struct device *dev, off_t offset, uint8_t val) +static int write_byte(const struct device *dev, off_t offset, uint8_t val) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t tmp; @@ -65,7 +66,7 @@ static int write_byte(struct device *dev, off_t offset, uint8_t val) return rc; } -static int erase_sector(struct device *dev, uint32_t sector) +static int erase_sector(const struct device *dev, uint32_t sector) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t tmp; @@ -105,7 +106,8 @@ static int erase_sector(struct device *dev, uint32_t sector) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { struct flash_pages_info info; @@ -134,7 +136,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -223,7 +225,7 @@ static const struct flash_pages_layout stm32f4_flash_layout[] = { #endif /* FLASH_SECTOR_TOTAL == 5 */ #endif/* !defined(FLASH_SECTOR_TOTAL) */ -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32f7x.c b/drivers/flash/flash_stm32f7x.c index 4095102f026d66..c833ba810796ec 100644 --- a/drivers/flash/flash_stm32f7x.c +++ b/drivers/flash/flash_stm32f7x.c @@ -16,7 +16,8 @@ #define STM32F7X_SECTOR_MASK ((uint32_t) 0xFFFFFF07) -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { ARG_UNUSED(write); @@ -24,7 +25,7 @@ bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, return flash_stm32_range_exists(dev, offset, len); } -static int write_byte(struct device *dev, off_t offset, uint8_t val) +static int write_byte(const struct device *dev, off_t offset, uint8_t val) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); int rc; @@ -56,7 +57,7 @@ static int write_byte(struct device *dev, off_t offset, uint8_t val) return rc; } -static int erase_sector(struct device *dev, uint32_t sector) +static int erase_sector(const struct device *dev, uint32_t sector) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); int rc; @@ -100,7 +101,8 @@ static int erase_sector(struct device *dev, uint32_t sector) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { struct flash_pages_info info; @@ -129,7 +131,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -205,7 +207,7 @@ static const struct flash_pages_layout stm32f7_flash_layout_dual_bank[] = { #error "Unknown flash layout" #endif/* !defined(FLASH_SECTOR_TOTAL) */ -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32g0x.c b/drivers/flash/flash_stm32g0x.c index 485c3839d5131f..1a4ae11110f260 100644 --- a/drivers/flash/flash_stm32g0x.c +++ b/drivers/flash/flash_stm32g0x.c @@ -28,7 +28,8 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); * offset and len must be aligned on 8 for write, * positive and not beyond end of flash */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { return (!write || (offset % 8 == 0 && len % 8 == 0)) && @@ -43,7 +44,7 @@ static unsigned int get_page(off_t offset) return offset >> STM32G0X_PAGE_SHIFT; } -static int write_dword(struct device *dev, off_t offset, uint64_t val) +static int write_dword(const struct device *dev, off_t offset, uint64_t val) { volatile uint32_t *flash = (uint32_t *)(offset + CONFIG_FLASH_BASE_ADDRESS); FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -86,7 +87,7 @@ static int write_dword(struct device *dev, off_t offset, uint64_t val) return rc; } -static int erase_page(struct device *dev, unsigned int page) +static int erase_page(const struct device *dev, unsigned int page) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t tmp; @@ -122,7 +123,8 @@ static int erase_page(struct device *dev, unsigned int page) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { int i, rc = 0; @@ -138,7 +140,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -153,7 +155,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, return rc; } -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32g4x.c b/drivers/flash/flash_stm32g4x.c index 38fb733652d028..a3c4e97353bd60 100644 --- a/drivers/flash/flash_stm32g4x.c +++ b/drivers/flash/flash_stm32g4x.c @@ -24,7 +24,8 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); * offset and len must be aligned on 8 for write, * positive and not beyond end of flash */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { return (!write || (offset % 8 == 0 && len % 8 == 0U)) && @@ -39,7 +40,7 @@ static unsigned int get_page(off_t offset) return offset >> STM32G4X_PAGE_SHIFT; } -static int write_dword(struct device *dev, off_t offset, uint64_t val) +static int write_dword(const struct device *dev, off_t offset, uint64_t val) { volatile uint32_t *flash = (uint32_t *)(offset + CONFIG_FLASH_BASE_ADDRESS); FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -84,7 +85,7 @@ static int write_dword(struct device *dev, off_t offset, uint64_t val) return rc; } -static int erase_page(struct device *dev, unsigned int page) +static int erase_page(const struct device *dev, unsigned int page) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t tmp; @@ -144,7 +145,8 @@ static int erase_page(struct device *dev, unsigned int page) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { int i, rc = 0; @@ -160,7 +162,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -175,7 +177,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, return rc; } -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32l4x.c b/drivers/flash/flash_stm32l4x.c index ffdb4ed97c0232..b7e8e76bc4819d 100644 --- a/drivers/flash/flash_stm32l4x.c +++ b/drivers/flash/flash_stm32l4x.c @@ -28,7 +28,8 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); /* offset and len must be aligned on 8 for write * , positive and not beyond end of flash */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { return (!write || (offset % 8 == 0 && len % 8 == 0U)) && @@ -45,7 +46,7 @@ static unsigned int get_page(off_t offset) return offset >> STM32L4X_PAGE_SHIFT; } -static int write_dword(struct device *dev, off_t offset, uint64_t val) +static int write_dword(const struct device *dev, off_t offset, uint64_t val) { volatile uint32_t *flash = (uint32_t *)(offset + CONFIG_FLASH_BASE_ADDRESS); FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -113,7 +114,7 @@ static int write_dword(struct device *dev, off_t offset, uint64_t val) #define SOC_NV_FLASH_SIZE DT_REG_SIZE(DT_INST(0, soc_nv_flash)) -static int erase_page(struct device *dev, unsigned int page) +static int erase_page(const struct device *dev, unsigned int page) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t tmp; @@ -183,7 +184,8 @@ static int erase_page(struct device *dev, unsigned int page) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { int i, rc = 0; @@ -199,7 +201,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -215,7 +217,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, return rc; } -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/flash_stm32wbx.c b/drivers/flash/flash_stm32wbx.c index f3d68b76fc3921..7640ba49e18824 100644 --- a/drivers/flash/flash_stm32wbx.c +++ b/drivers/flash/flash_stm32wbx.c @@ -24,7 +24,8 @@ LOG_MODULE_REGISTER(LOG_DOMAIN); /* offset and len must be aligned on 8 for write, * positive and not beyond end of flash */ -bool flash_stm32_valid_range(struct device *dev, off_t offset, uint32_t len, +bool flash_stm32_valid_range(const struct device *dev, off_t offset, + uint32_t len, bool write) { return (!write || (offset % 8 == 0 && len % 8 == 0U)) && @@ -39,7 +40,7 @@ static uint32_t get_page(off_t offset) return offset >> STM32WBX_PAGE_SHIFT; } -static int write_dword(struct device *dev, off_t offset, uint64_t val) +static int write_dword(const struct device *dev, off_t offset, uint64_t val) { volatile uint32_t *flash = (uint32_t *)(offset + CONFIG_FLASH_BASE_ADDRESS); FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); @@ -81,7 +82,7 @@ static int write_dword(struct device *dev, off_t offset, uint64_t val) return rc; } -static int erase_page(struct device *dev, uint32_t page) +static int erase_page(const struct device *dev, uint32_t page) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); int rc; @@ -117,7 +118,8 @@ static int erase_page(struct device *dev, uint32_t page) return rc; } -int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, +int flash_stm32_block_erase_loop(const struct device *dev, + unsigned int offset, unsigned int len) { int i, rc = 0; @@ -133,7 +135,7 @@ int flash_stm32_block_erase_loop(struct device *dev, unsigned int offset, return rc; } -int flash_stm32_write_range(struct device *dev, unsigned int offset, +int flash_stm32_write_range(const struct device *dev, unsigned int offset, const void *data, unsigned int len) { int i, rc = 0; @@ -149,7 +151,7 @@ int flash_stm32_write_range(struct device *dev, unsigned int offset, return rc; } -void flash_stm32_page_layout(struct device *dev, +void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -169,7 +171,7 @@ void flash_stm32_page_layout(struct device *dev, *layout_size = 1; } -int flash_stm32_check_status(struct device *dev) +int flash_stm32_check_status(const struct device *dev) { FLASH_TypeDef *regs = FLASH_STM32_REGS(dev); uint32_t error = 0; diff --git a/drivers/flash/nrf_qspi_nor.c b/drivers/flash/nrf_qspi_nor.c index 7f83baa4b021e9..8ccf0c9d649224 100644 --- a/drivers/flash/nrf_qspi_nor.c +++ b/drivers/flash/nrf_qspi_nor.c @@ -237,26 +237,26 @@ static inline int qspi_get_zephyr_ret_code(nrfx_err_t res) } } -static inline struct qspi_nor_data *get_dev_data(struct device *dev) +static inline struct qspi_nor_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline void qspi_lock(struct device *dev) +static inline void qspi_lock(const struct device *dev) { struct qspi_nor_data *dev_data = get_dev_data(dev); k_sem_take(&dev_data->sem, K_FOREVER); } -static inline void qspi_unlock(struct device *dev) +static inline void qspi_unlock(const struct device *dev) { struct qspi_nor_data *dev_data = get_dev_data(dev); k_sem_give(&dev_data->sem); } -static inline void qspi_wait_for_completion(struct device *dev, +static inline void qspi_wait_for_completion(const struct device *dev, nrfx_err_t res) { struct qspi_nor_data *dev_data = get_dev_data(dev); @@ -266,7 +266,7 @@ static inline void qspi_wait_for_completion(struct device *dev, } } -static inline void qspi_complete(struct device *dev) +static inline void qspi_complete(const struct device *dev) { struct qspi_nor_data *dev_data = get_dev_data(dev); @@ -282,7 +282,7 @@ static inline void qspi_complete(struct device *dev) */ static void qspi_handler(nrfx_qspi_evt_t event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; if (event == NRFX_QSPI_EVENT_DONE) { qspi_complete(dev); @@ -291,7 +291,7 @@ static void qspi_handler(nrfx_qspi_evt_t event, void *p_context) /* QSPI send custom command */ -static int qspi_send_cmd(struct device *dev, const struct qspi_cmd *cmd) +static int qspi_send_cmd(const struct device *dev, const struct qspi_cmd *cmd) { /* Check input parameters */ if (!cmd) { @@ -324,7 +324,7 @@ static int qspi_send_cmd(struct device *dev, const struct qspi_cmd *cmd) } /* QSPI erase */ -static int qspi_erase(struct device *dev, uint32_t addr, uint32_t size) +static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size) { /* address must be sector-aligned */ if ((addr % QSPI_SECTOR_SIZE) != 0) { @@ -434,7 +434,7 @@ static inline void qspi_fill_init_struct(nrfx_qspi_config_t *initstruct) } /* Configures QSPI memory for the transfer */ -static int qspi_nrfx_configure(struct device *dev) +static int qspi_nrfx_configure(const struct device *dev) { if (!dev) { return -ENXIO; @@ -484,7 +484,7 @@ static int qspi_nrfx_configure(struct device *dev) * expected JEDEC ID * @return 0 on success, negative errno code otherwise */ -static inline int qspi_nor_read_id(struct device *dev, +static inline int qspi_nor_read_id(const struct device *dev, const struct qspi_nor_config *const flash_id) { uint8_t rx_b[QSPI_NOR_MAX_ID_LEN]; @@ -512,7 +512,8 @@ static inline int qspi_nor_read_id(struct device *dev, return 0; } -static inline nrfx_err_t read_non_aligned(struct device *dev, off_t addr, +static inline nrfx_err_t read_non_aligned(const struct device *dev, + off_t addr, void *dest, size_t size) { uint8_t __aligned(WORD_SIZE) buf[WORD_SIZE * 2]; @@ -582,7 +583,7 @@ static inline nrfx_err_t read_non_aligned(struct device *dev, off_t addr, return res; } -static int qspi_nor_read(struct device *dev, off_t addr, void *dest, +static int qspi_nor_read(const struct device *dev, off_t addr, void *dest, size_t size) { if (!dest) { @@ -617,7 +618,7 @@ static int qspi_nor_read(struct device *dev, off_t addr, void *dest, } /* addr aligned, sptr not null, slen less than 4 */ -static inline nrfx_err_t write_sub_word(struct device *dev, off_t addr, +static inline nrfx_err_t write_sub_word(const struct device *dev, off_t addr, const void *sptr, size_t slen) { uint8_t __aligned(4) buf[4]; @@ -648,7 +649,7 @@ BUILD_ASSERT((CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE % 4) == 0, * * If not enabled return the error the peripheral would have produced. */ -static inline nrfx_err_t write_from_nvmc(struct device *dev, off_t addr, +static inline nrfx_err_t write_from_nvmc(const struct device *dev, off_t addr, const void *sptr, size_t slen) { #if NVMC_WRITE_OK @@ -676,7 +677,8 @@ static inline nrfx_err_t write_from_nvmc(struct device *dev, off_t addr, return res; } -static int qspi_nor_write(struct device *dev, off_t addr, const void *src, +static int qspi_nor_write(const struct device *dev, off_t addr, + const void *src, size_t size) { if (!src) { @@ -727,7 +729,7 @@ static int qspi_nor_write(struct device *dev, off_t addr, const void *src, return qspi_get_zephyr_ret_code(res); } -static int qspi_nor_erase(struct device *dev, off_t addr, size_t size) +static int qspi_nor_erase(const struct device *dev, off_t addr, size_t size) { struct qspi_nor_data *const driver_data = dev->data; const struct qspi_nor_config *params = dev->config; @@ -750,7 +752,7 @@ static int qspi_nor_erase(struct device *dev, off_t addr, size_t size) return ret; } -static int qspi_nor_write_protection_set(struct device *dev, +static int qspi_nor_write_protection_set(const struct device *dev, bool write_protect) { struct qspi_nor_data *const driver_data = dev->data; @@ -776,7 +778,7 @@ static int qspi_nor_write_protection_set(struct device *dev, * @param info The flash info structure * @return 0 on success, negative errno code otherwise */ -static int qspi_nor_configure(struct device *dev) +static int qspi_nor_configure(const struct device *dev) { const struct qspi_nor_config *params = dev->config; @@ -800,7 +802,7 @@ static int qspi_nor_configure(struct device *dev) * @param name The flash name * @return 0 on success, negative errno code otherwise */ -static int qspi_nor_init(struct device *dev) +static int qspi_nor_init(const struct device *dev) { IRQ_CONNECT(DT_IRQN(QSPI_NODE), DT_IRQ(QSPI_NODE, priority), nrfx_isr, nrfx_qspi_irq_handler, 0); @@ -832,7 +834,7 @@ qspi_flash_get_parameters(const struct device *dev) return &qspi_flash_parameters; } -static void qspi_nor_pages_layout(struct device *dev, +static void qspi_nor_pages_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/flash/soc_flash_mcux.c b/drivers/flash/soc_flash_mcux.c index 842124142f778e..31668852af48de 100644 --- a/drivers/flash/soc_flash_mcux.c +++ b/drivers/flash/soc_flash_mcux.c @@ -136,7 +136,8 @@ static const struct flash_parameters flash_mcux_parameters = { * */ -static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) +static int flash_mcux_erase(const struct device *dev, off_t offset, + size_t len) { struct flash_priv *priv = dev->data; uint32_t addr; @@ -169,7 +170,7 @@ static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) * @return 0 on success, * -EIO for erroneous area */ -static int flash_mcux_read(struct device *dev, off_t offset, +static int flash_mcux_read(const struct device *dev, off_t offset, void *data, size_t len) { struct flash_priv *priv = dev->data; @@ -200,7 +201,7 @@ static int flash_mcux_read(struct device *dev, off_t offset, return rc; } -static int flash_mcux_write(struct device *dev, off_t offset, +static int flash_mcux_write(const struct device *dev, off_t offset, const void *data, size_t len) { struct flash_priv *priv = dev->data; @@ -223,7 +224,7 @@ static int flash_mcux_write(struct device *dev, off_t offset, return (rc == kStatus_Success) ? 0 : -EINVAL; } -static int flash_mcux_write_protection(struct device *dev, bool enable) +static int flash_mcux_write_protection(const struct device *dev, bool enable) { struct flash_priv *priv = dev->data; int rc = 0; @@ -244,7 +245,7 @@ static const struct flash_pages_layout dev_layout = { .pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size), }; -static void flash_mcux_pages_layout(struct device *dev, +static void flash_mcux_pages_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -274,7 +275,7 @@ static const struct flash_driver_api flash_mcux_api = { #endif }; -static int flash_mcux_init(struct device *dev) +static int flash_mcux_init(const struct device *dev) { struct flash_priv *priv = dev->data; uint32_t pflash_block_base; diff --git a/drivers/flash/soc_flash_nios2_qspi.c b/drivers/flash/soc_flash_nios2_qspi.c index 07cf0555dc2832..20f6d73c9ff97c 100644 --- a/drivers/flash/soc_flash_nios2_qspi.c +++ b/drivers/flash/soc_flash_nios2_qspi.c @@ -66,7 +66,8 @@ static const struct flash_parameters flash_nios2_qspi_parameters = { .erase_value = 0xff, }; -static int flash_nios2_qspi_erase(struct device *dev, off_t offset, size_t len) +static int flash_nios2_qspi_erase(const struct device *dev, off_t offset, + size_t len) { struct flash_nios2_qspi_config *flash_cfg = dev->data; alt_qspi_controller2_dev *qspi_dev = &flash_cfg->qspi_dev; @@ -160,7 +161,8 @@ static int flash_nios2_qspi_erase(struct device *dev, off_t offset, size_t len) } -static int flash_nios2_qspi_write_block(struct device *dev, int block_offset, +static int flash_nios2_qspi_write_block(const struct device *dev, + int block_offset, int mem_offset, const void *data, size_t len) { @@ -258,7 +260,7 @@ static int flash_nios2_qspi_write_block(struct device *dev, int block_offset, return rc; } -static int flash_nios2_qspi_write(struct device *dev, off_t offset, +static int flash_nios2_qspi_write(const struct device *dev, off_t offset, const void *data, size_t len) { struct flash_nios2_qspi_config *flash_cfg = dev->data; @@ -324,7 +326,7 @@ static int flash_nios2_qspi_write(struct device *dev, off_t offset, return rc; } -static int flash_nios2_qspi_read(struct device *dev, off_t offset, +static int flash_nios2_qspi_read(const struct device *dev, off_t offset, void *data, size_t len) { struct flash_nios2_qspi_config *flash_cfg = dev->data; @@ -391,7 +393,8 @@ static int flash_nios2_qspi_read(struct device *dev, off_t offset, return rc; } -static int flash_nios2_qspi_write_protection(struct device *dev, bool enable) +static int flash_nios2_qspi_write_protection(const struct device *dev, + bool enable) { struct flash_nios2_qspi_config *flash_cfg = dev->data; alt_qspi_controller2_dev *qspi_dev = &flash_cfg->qspi_dev; @@ -474,7 +477,7 @@ static const struct flash_driver_api flash_nios2_qspi_api = { #endif }; -static int flash_nios2_qspi_init(struct device *dev) +static int flash_nios2_qspi_init(const struct device *dev) { struct flash_nios2_qspi_config *flash_cfg = dev->data; diff --git a/drivers/flash/soc_flash_nrf.c b/drivers/flash/soc_flash_nrf.c index 13ee80ad0e13a6..84f2c28c805bbb 100644 --- a/drivers/flash/soc_flash_nrf.c +++ b/drivers/flash/soc_flash_nrf.c @@ -172,7 +172,7 @@ static void nvmc_wait_ready(void) } } -static int flash_nrf_read(struct device *dev, off_t addr, +static int flash_nrf_read(const struct device *dev, off_t addr, void *data, size_t len) { if (is_regular_addr_valid(addr, len)) { @@ -190,7 +190,7 @@ static int flash_nrf_read(struct device *dev, off_t addr, return 0; } -static int flash_nrf_write(struct device *dev, off_t addr, +static int flash_nrf_write(const struct device *dev, off_t addr, const void *data, size_t len) { int ret; @@ -227,7 +227,7 @@ static int flash_nrf_write(struct device *dev, off_t addr, return ret; } -static int flash_nrf_erase(struct device *dev, off_t addr, size_t size) +static int flash_nrf_erase(const struct device *dev, off_t addr, size_t size) { uint32_t pg_size = nrfx_nvmc_flash_page_size_get(); uint32_t n_pages = size / pg_size; @@ -270,7 +270,7 @@ static int flash_nrf_erase(struct device *dev, off_t addr, size_t size) return ret; } -static int flash_nrf_write_protection(struct device *dev, bool enable) +static int flash_nrf_write_protection(const struct device *dev, bool enable) { return 0; } @@ -278,7 +278,7 @@ static int flash_nrf_write_protection(struct device *dev, bool enable) #if defined(CONFIG_FLASH_PAGE_LAYOUT) static struct flash_pages_layout dev_layout; -static void flash_nrf_pages_layout(struct device *dev, +static void flash_nrf_pages_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { @@ -306,7 +306,7 @@ static const struct flash_driver_api flash_nrf_api = { #endif }; -static int nrf_flash_init(struct device *dev) +static int nrf_flash_init(const struct device *dev) { SYNC_INIT(); diff --git a/drivers/flash/soc_flash_rv32m1.c b/drivers/flash/soc_flash_rv32m1.c index e8e31fcdc53394..b8a7730b330bb7 100644 --- a/drivers/flash/soc_flash_rv32m1.c +++ b/drivers/flash/soc_flash_rv32m1.c @@ -42,7 +42,8 @@ static const struct flash_parameters flash_mcux_parameters = { * */ -static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) +static int flash_mcux_erase(const struct device *dev, off_t offset, + size_t len) { struct flash_priv *priv = dev->data; uint32_t addr; @@ -64,7 +65,7 @@ static int flash_mcux_erase(struct device *dev, off_t offset, size_t len) return (rc == kStatus_Success) ? 0 : -EINVAL; } -static int flash_mcux_read(struct device *dev, off_t offset, +static int flash_mcux_read(const struct device *dev, off_t offset, void *data, size_t len) { struct flash_priv *priv = dev->data; @@ -82,7 +83,7 @@ static int flash_mcux_read(struct device *dev, off_t offset, return 0; } -static int flash_mcux_write(struct device *dev, off_t offset, +static int flash_mcux_write(const struct device *dev, off_t offset, const void *data, size_t len) { struct flash_priv *priv = dev->data; @@ -105,7 +106,7 @@ static int flash_mcux_write(struct device *dev, off_t offset, return (rc == kStatus_Success) ? 0 : -EINVAL; } -static int flash_mcux_write_protection(struct device *dev, bool enable) +static int flash_mcux_write_protection(const struct device *dev, bool enable) { struct flash_priv *priv = dev->data; int rc = 0; @@ -126,10 +127,9 @@ static const struct flash_pages_layout dev_layout = { .pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size), }; -static void flash_mcux_pages_layout( - struct device *dev, - const struct flash_pages_layout **layout, - size_t *layout_size) +static void flash_mcux_pages_layout(const struct device *dev, + const struct flash_pages_layout **layout, + size_t *layout_size) { *layout = &dev_layout; *layout_size = 1; @@ -157,7 +157,7 @@ static const struct flash_driver_api flash_mcux_api = { #endif }; -static int flash_mcux_init(struct device *dev) +static int flash_mcux_init(const struct device *dev) { struct flash_priv *priv = dev->data; uint32_t pflash_block_base; diff --git a/drivers/flash/spi_flash_at45.c b/drivers/flash/spi_flash_at45.c index 77cdbf0217945d..3c44d890582c10 100644 --- a/drivers/flash/spi_flash_at45.c +++ b/drivers/flash/spi_flash_at45.c @@ -52,7 +52,7 @@ LOG_MODULE_REGISTER(spi_flash_at45, CONFIG_FLASH_LOG_LEVEL); } struct spi_flash_at45_data { - struct device *spi; + const struct device *spi; struct spi_cs_control spi_cs; struct k_sem lock; #if IS_ENABLED(CONFIG_DEVICE_POWER_MANAGEMENT) @@ -83,27 +83,27 @@ static const struct flash_parameters flash_at45_parameters = { .erase_value = 0xff, }; -static struct spi_flash_at45_data *get_dev_data(struct device *dev) +static struct spi_flash_at45_data *get_dev_data(const struct device *dev) { return dev->data; } -static const struct spi_flash_at45_config *get_dev_config(struct device *dev) +static const struct spi_flash_at45_config *get_dev_config(const struct device *dev) { return dev->config; } -static void acquire(struct device *dev) +static void acquire(const struct device *dev) { k_sem_take(&get_dev_data(dev)->lock, K_FOREVER); } -static void release(struct device *dev) +static void release(const struct device *dev) { k_sem_give(&get_dev_data(dev)->lock); } -static int check_jedec_id(struct device *dev) +static int check_jedec_id(const struct device *dev) { const struct spi_flash_at45_config *cfg = get_dev_config(dev); int err; @@ -154,7 +154,7 @@ static int check_jedec_id(struct device *dev) * - Byte 1 to MSB * of the pointed parameter. */ -static int read_status_register(struct device *dev, uint16_t *status) +static int read_status_register(const struct device *dev, uint16_t *status) { int err; const uint8_t opcode = CMD_READ_STATUS; @@ -189,7 +189,7 @@ static int read_status_register(struct device *dev, uint16_t *status) return 0; } -static int wait_until_ready(struct device *dev) +static int wait_until_ready(const struct device *dev) { int err; uint16_t status; @@ -201,7 +201,7 @@ static int wait_until_ready(struct device *dev) return err; } -static int configure_page_size(struct device *dev) +static int configure_page_size(const struct device *dev) { int err; uint16_t status; @@ -244,7 +244,7 @@ static bool is_valid_request(off_t addr, size_t size, size_t chip_size) return (addr >= 0 && (addr + size) <= chip_size); } -static int spi_flash_at45_read(struct device *dev, off_t offset, +static int spi_flash_at45_read(const struct device *dev, off_t offset, void *data, size_t len) { const struct spi_flash_at45_config *cfg = get_dev_config(dev); @@ -292,7 +292,7 @@ static int spi_flash_at45_read(struct device *dev, off_t offset, return (err != 0) ? -EIO : 0; } -static int perform_write(struct device *dev, off_t offset, +static int perform_write(const struct device *dev, off_t offset, const void *data, size_t len) { int err; @@ -329,7 +329,7 @@ static int perform_write(struct device *dev, off_t offset, return (err != 0) ? -EIO : 0; } -static int spi_flash_at45_write(struct device *dev, off_t offset, +static int spi_flash_at45_write(const struct device *dev, off_t offset, const void *data, size_t len) { const struct spi_flash_at45_config *cfg = get_dev_config(dev); @@ -366,7 +366,7 @@ static int spi_flash_at45_write(struct device *dev, off_t offset, return err; } -static int perform_chip_erase(struct device *dev) +static int perform_chip_erase(const struct device *dev) { int err; uint8_t const chip_erase_cmd[] = CMD_CHIP_ERASE; @@ -398,7 +398,8 @@ static bool is_erase_possible(size_t entity_size, (offset & (entity_size - 1)) == 0); } -static int perform_erase_op(struct device *dev, uint8_t opcode, off_t offset) +static int perform_erase_op(const struct device *dev, uint8_t opcode, + off_t offset) { int err; uint8_t const op_and_addr[] = { @@ -428,7 +429,8 @@ static int perform_erase_op(struct device *dev, uint8_t opcode, off_t offset) return (err != 0) ? -EIO : 0; } -static int spi_flash_at45_erase(struct device *dev, off_t offset, size_t size) +static int spi_flash_at45_erase(const struct device *dev, off_t offset, + size_t size) { const struct spi_flash_at45_config *cfg = get_dev_config(dev); int err = 0; @@ -485,7 +487,8 @@ static int spi_flash_at45_erase(struct device *dev, off_t offset, size_t size) return err; } -static int spi_flash_at45_write_protection(struct device *dev, bool enable) +static int spi_flash_at45_write_protection(const struct device *dev, + bool enable) { ARG_UNUSED(dev); ARG_UNUSED(enable); @@ -503,17 +506,17 @@ static int spi_flash_at45_write_protection(struct device *dev, bool enable) } #if IS_ENABLED(CONFIG_FLASH_PAGE_LAYOUT) -static void spi_flash_at45_pages_layout( - struct device *dev, - const struct flash_pages_layout **layout, - size_t *layout_size) +static void spi_flash_at45_pages_layout(const struct device *dev, + const struct flash_pages_layout **layout, + size_t *layout_size) { *layout = &get_dev_config(dev)->pages_layout; *layout_size = 1; } #endif /* IS_ENABLED(CONFIG_FLASH_PAGE_LAYOUT) */ -static int power_down_op(struct device *dev, uint8_t opcode, uint32_t delay) +static int power_down_op(const struct device *dev, uint8_t opcode, + uint32_t delay) { int err = 0; const struct spi_buf tx_buf[] = { @@ -538,7 +541,7 @@ static int power_down_op(struct device *dev, uint8_t opcode, uint32_t delay) return 0; } -static int spi_flash_at45_init(struct device *dev) +static int spi_flash_at45_init(const struct device *dev) { struct spi_flash_at45_data *dev_data = get_dev_data(dev); const struct spi_flash_at45_config *dev_config = get_dev_config(dev); @@ -584,7 +587,8 @@ static int spi_flash_at45_init(struct device *dev) } #if IS_ENABLED(CONFIG_DEVICE_POWER_MANAGEMENT) -static int spi_flash_at45_pm_control(struct device *dev, uint32_t ctrl_command, +static int spi_flash_at45_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { struct spi_flash_at45_data *dev_data = get_dev_data(dev); diff --git a/drivers/flash/spi_nor.c b/drivers/flash/spi_nor.c index 727d158c801c0e..1d33369d04fa4f 100644 --- a/drivers/flash/spi_nor.c +++ b/drivers/flash/spi_nor.c @@ -101,7 +101,7 @@ struct spi_nor_config { */ struct spi_nor_data { struct k_sem sem; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control cs_ctrl; @@ -153,7 +153,7 @@ static const struct jesd216_erase_type minimal_erase_types[JESD216_NUM_ERASE_TYP * minimal, data for runtime and devicetree. */ static inline const struct jesd216_erase_type * -dev_erase_types(struct device *dev) +dev_erase_types(const struct device *dev) { #ifdef CONFIG_SPI_NOR_SFDP_MINIMAL return minimal_erase_types; @@ -167,7 +167,7 @@ dev_erase_types(struct device *dev) /* Get the size of the flash device. Data for runtime, constant for * minimal and devicetree. */ -static inline uint32_t dev_flash_size(struct device *dev) +static inline uint32_t dev_flash_size(const struct device *dev) { #ifdef CONFIG_SPI_NOR_SFDP_RUNTIME const struct spi_nor_data *data = dev->data; @@ -183,7 +183,7 @@ static inline uint32_t dev_flash_size(struct device *dev) /* Get the flash device page size. Constant for minimal, data for * runtime and devicetree. */ -static inline uint16_t dev_page_size(struct device *dev) +static inline uint16_t dev_page_size(const struct device *dev) { #ifdef CONFIG_SPI_NOR_SFDP_MINIMAL return 256; @@ -396,7 +396,7 @@ static int exit_dpd(const struct device *const dev) * This means taking the lock and, if necessary, waking the device * from deep power-down mode. */ -static void acquire_device(struct device *dev) +static void acquire_device(const struct device *dev) { if (IS_ENABLED(CONFIG_MULTITHREADING)) { struct spi_nor_data *const driver_data = dev->data; @@ -414,7 +414,7 @@ static void acquire_device(struct device *dev) * This means (optionally) putting the device into deep power-down * mode, and releasing the lock. */ -static void release_device(struct device *dev) +static void release_device(const struct device *dev) { if (IS_ENABLED(CONFIG_SPI_NOR_IDLE_IN_DPD)) { enter_dpd(dev); @@ -433,7 +433,7 @@ static void release_device(struct device *dev) * @param dev The device structure * @return 0 on success, negative errno code otherwise */ -static int spi_nor_wait_until_ready(struct device *dev) +static int spi_nor_wait_until_ready(const struct device *dev) { int ret; uint8_t reg; @@ -445,7 +445,7 @@ static int spi_nor_wait_until_ready(struct device *dev) return ret; } -static int spi_nor_read(struct device *dev, off_t addr, void *dest, +static int spi_nor_read(const struct device *dev, off_t addr, void *dest, size_t size) { const size_t flash_size = dev_flash_size(dev); @@ -466,7 +466,8 @@ static int spi_nor_read(struct device *dev, off_t addr, void *dest, return ret; } -static int spi_nor_write(struct device *dev, off_t addr, const void *src, +static int spi_nor_write(const struct device *dev, off_t addr, + const void *src, size_t size) { const size_t flash_size = dev_flash_size(dev); @@ -513,7 +514,7 @@ static int spi_nor_write(struct device *dev, off_t addr, const void *src, return ret; } -static int spi_nor_erase(struct device *dev, off_t addr, size_t size) +static int spi_nor_erase(const struct device *dev, off_t addr, size_t size) { const size_t flash_size = dev_flash_size(dev); int ret = 0; @@ -577,7 +578,8 @@ static int spi_nor_erase(struct device *dev, off_t addr, size_t size) return ret; } -static int spi_nor_write_protection_set(struct device *dev, bool write_protect) +static int spi_nor_write_protection_set(const struct device *dev, + bool write_protect) { int ret; @@ -601,7 +603,7 @@ static int spi_nor_write_protection_set(struct device *dev, bool write_protect) #if defined(CONFIG_FLASH_JESD216_API) -static int spi_nor_sfdp_read(struct device *dev, off_t addr, +static int spi_nor_sfdp_read(const struct device *dev, off_t addr, void *dest, size_t size) { acquire_device(dev); @@ -617,7 +619,7 @@ static int spi_nor_sfdp_read(struct device *dev, off_t addr, #endif /* CONFIG_FLASH_JESD216_API */ -static int spi_nor_read_jedec_id(struct device *dev, +static int spi_nor_read_jedec_id(const struct device *dev, uint8_t *id) { if (id == NULL) { @@ -637,7 +639,7 @@ static int spi_nor_read_jedec_id(struct device *dev, #ifndef CONFIG_SPI_NOR_SFDP_MINIMAL -static int spi_nor_process_bfp(struct device *dev, +static int spi_nor_process_bfp(const struct device *dev, const struct jesd216_param_header *php, const struct jesd216_bfp *bfp) { @@ -672,7 +674,7 @@ static int spi_nor_process_bfp(struct device *dev, return 0; } -static int spi_nor_process_sfdp(struct device *dev) +static int spi_nor_process_sfdp(const struct device *dev) { int rc; @@ -751,7 +753,7 @@ static int spi_nor_process_sfdp(struct device *dev) } #if defined(CONFIG_FLASH_PAGE_LAYOUT) -static int setup_pages_layout(struct device *dev) +static int setup_pages_layout(const struct device *dev) { int rv = 0; @@ -824,7 +826,7 @@ static int setup_pages_layout(struct device *dev) * @param info The flash info structure * @return 0 on success, negative errno code otherwise */ -static int spi_nor_configure(struct device *dev) +static int spi_nor_configure(const struct device *dev) { struct spi_nor_data *data = dev->data; uint8_t jedec_id[SPI_NOR_MAX_ID_LEN]; @@ -916,7 +918,7 @@ static int spi_nor_configure(struct device *dev) * @param name The flash name * @return 0 on success, negative errno code otherwise */ -static int spi_nor_init(struct device *dev) +static int spi_nor_init(const struct device *dev) { if (IS_ENABLED(CONFIG_MULTITHREADING)) { struct spi_nor_data *const driver_data = dev->data; @@ -929,7 +931,7 @@ static int spi_nor_init(struct device *dev) #if defined(CONFIG_FLASH_PAGE_LAYOUT) -static void spi_nor_pages_layout(struct device *dev, +static void spi_nor_pages_layout(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size) { diff --git a/drivers/gpio/gpio_cc13xx_cc26xx.c b/drivers/gpio/gpio_cc13xx_cc26xx.c index 4c03e6f8e44671..d2fc6984c28d97 100644 --- a/drivers/gpio/gpio_cc13xx_cc26xx.c +++ b/drivers/gpio/gpio_cc13xx_cc26xx.c @@ -42,12 +42,12 @@ static const struct gpio_driver_config gpio_cc13xx_cc26xx_cfg_0 = { .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(0), }; -static int gpio_cc13xx_cc26xx_port_set_bits_raw(struct device *port, - uint32_t mask); -static int gpio_cc13xx_cc26xx_port_clear_bits_raw(struct device *port, - uint32_t mask); +static int gpio_cc13xx_cc26xx_port_set_bits_raw(const struct device *port, + uint32_t mask); +static int gpio_cc13xx_cc26xx_port_clear_bits_raw(const struct device *port, + uint32_t mask); -static int gpio_cc13xx_cc26xx_config(struct device *port, +static int gpio_cc13xx_cc26xx_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { @@ -107,7 +107,8 @@ static int gpio_cc13xx_cc26xx_config(struct device *port, return 0; } -static int gpio_cc13xx_cc26xx_port_get_raw(struct device *port, uint32_t *value) +static int gpio_cc13xx_cc26xx_port_get_raw(const struct device *port, + uint32_t *value) { __ASSERT_NO_MSG(value != NULL); @@ -116,8 +117,9 @@ static int gpio_cc13xx_cc26xx_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int gpio_cc13xx_cc26xx_port_set_masked_raw(struct device *port, - uint32_t mask, uint32_t value) +static int gpio_cc13xx_cc26xx_port_set_masked_raw(const struct device *port, + uint32_t mask, + uint32_t value) { GPIO_setMultiDio(mask & value); GPIO_clearMultiDio(mask & ~value); @@ -125,31 +127,34 @@ static int gpio_cc13xx_cc26xx_port_set_masked_raw(struct device *port, return 0; } -static int gpio_cc13xx_cc26xx_port_set_bits_raw(struct device *port, uint32_t mask) +static int gpio_cc13xx_cc26xx_port_set_bits_raw(const struct device *port, + uint32_t mask) { GPIO_setMultiDio(mask); return 0; } -static int gpio_cc13xx_cc26xx_port_clear_bits_raw(struct device *port, - uint32_t mask) +static int gpio_cc13xx_cc26xx_port_clear_bits_raw(const struct device *port, + uint32_t mask) { GPIO_clearMultiDio(mask); return 0; } -static int gpio_cc13xx_cc26xx_port_toggle_bits(struct device *port, uint32_t mask) +static int gpio_cc13xx_cc26xx_port_toggle_bits(const struct device *port, + uint32_t mask) { GPIO_toggleMultiDio(mask); return 0; } -static int gpio_cc13xx_cc26xx_pin_interrupt_configure(struct device *port, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_cc13xx_cc26xx_pin_interrupt_configure(const struct device *port, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { uint32_t config = 0; @@ -177,7 +182,7 @@ static int gpio_cc13xx_cc26xx_pin_interrupt_configure(struct device *port, return 0; } -static int gpio_cc13xx_cc26xx_manage_callback(struct device *port, +static int gpio_cc13xx_cc26xx_manage_callback(const struct device *port, struct gpio_callback *callback, bool set) { @@ -186,7 +191,7 @@ static int gpio_cc13xx_cc26xx_manage_callback(struct device *port, return gpio_manage_callback(&data->callbacks, callback, set); } -static uint32_t gpio_cc13xx_cc26xx_get_pending_int(struct device *dev) +static uint32_t gpio_cc13xx_cc26xx_get_pending_int(const struct device *dev) { return GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK); } @@ -195,7 +200,7 @@ DEVICE_DECLARE(gpio_cc13xx_cc26xx); static void gpio_cc13xx_cc26xx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct gpio_cc13xx_cc26xx_data *data = dev->data; uint32_t status = GPIO_getEventMultiDio(GPIO_DIO_ALL_MASK); @@ -205,7 +210,7 @@ static void gpio_cc13xx_cc26xx_isr(void *arg) gpio_fire_callbacks(&data->callbacks, dev, status); } -static int gpio_cc13xx_cc26xx_init(struct device *dev) +static int gpio_cc13xx_cc26xx_init(const struct device *dev) { #ifdef CONFIG_SYS_POWER_MANAGEMENT /* Set dependency on gpio resource to turn on power domains */ diff --git a/drivers/gpio/gpio_cc32xx.c b/drivers/gpio/gpio_cc32xx.c index 3a22aaa7a2adae..d8bc74f12497f4 100644 --- a/drivers/gpio/gpio_cc32xx.c +++ b/drivers/gpio/gpio_cc32xx.c @@ -64,10 +64,12 @@ struct gpio_cc32xx_data { #define DEV_DATA(dev) \ ((struct gpio_cc32xx_data *)(dev)->data) -static int gpio_cc32xx_port_set_bits_raw(struct device *port, uint32_t mask); -static int gpio_cc32xx_port_clear_bits_raw(struct device *port, uint32_t mask); +static int gpio_cc32xx_port_set_bits_raw(const struct device *port, + uint32_t mask); +static int gpio_cc32xx_port_clear_bits_raw(const struct device *port, + uint32_t mask); -static inline int gpio_cc32xx_config(struct device *port, +static inline int gpio_cc32xx_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { @@ -102,7 +104,8 @@ static inline int gpio_cc32xx_config(struct device *port, return 0; } -static int gpio_cc32xx_port_get_raw(struct device *port, uint32_t *value) +static int gpio_cc32xx_port_get_raw(const struct device *port, + uint32_t *value) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -113,8 +116,9 @@ static int gpio_cc32xx_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int gpio_cc32xx_port_set_masked_raw(struct device *port, uint32_t mask, - uint32_t value) +static int gpio_cc32xx_port_set_masked_raw(const struct device *port, + uint32_t mask, + uint32_t value) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -124,7 +128,8 @@ static int gpio_cc32xx_port_set_masked_raw(struct device *port, uint32_t mask, return 0; } -static int gpio_cc32xx_port_set_bits_raw(struct device *port, uint32_t mask) +static int gpio_cc32xx_port_set_bits_raw(const struct device *port, + uint32_t mask) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -134,7 +139,8 @@ static int gpio_cc32xx_port_set_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_cc32xx_port_clear_bits_raw(struct device *port, uint32_t mask) +static int gpio_cc32xx_port_clear_bits_raw(const struct device *port, + uint32_t mask) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -144,7 +150,8 @@ static int gpio_cc32xx_port_clear_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_cc32xx_port_toggle_bits(struct device *port, uint32_t mask) +static int gpio_cc32xx_port_toggle_bits(const struct device *port, + uint32_t mask) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -158,9 +165,10 @@ static int gpio_cc32xx_port_toggle_bits(struct device *port, uint32_t mask) return 0; } -static int gpio_cc32xx_pin_interrupt_configure(struct device *port, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_cc32xx_pin_interrupt_configure(const struct device *port, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_cc32xx_config *gpio_config = DEV_CFG(port); unsigned long port_base = gpio_config->port_base; @@ -200,8 +208,9 @@ static int gpio_cc32xx_pin_interrupt_configure(struct device *port, return 0; } -static int gpio_cc32xx_manage_callback(struct device *dev, - struct gpio_callback *callback, bool set) +static int gpio_cc32xx_manage_callback(const struct device *dev, + struct gpio_callback *callback, + bool set) { struct gpio_cc32xx_data *data = DEV_DATA(dev); @@ -210,7 +219,7 @@ static int gpio_cc32xx_manage_callback(struct device *dev, static void gpio_cc32xx_port_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct gpio_cc32xx_config *config = DEV_CFG(dev); struct gpio_cc32xx_data *data = DEV_DATA(dev); uint32_t int_status; @@ -237,7 +246,7 @@ static const struct gpio_driver_api api_funcs = { }; #define GPIO_CC32XX_INIT_FUNC(n) \ - static int gpio_cc32xx_a##n##_init(struct device *dev) \ + static int gpio_cc32xx_a##n##_init(const struct device *dev) \ { \ ARG_UNUSED(dev); \ \ diff --git a/drivers/gpio/gpio_cmsdk_ahb.c b/drivers/gpio/gpio_cmsdk_ahb.c index 0576ed08b75f7d..71582dbe3b3d17 100644 --- a/drivers/gpio/gpio_cmsdk_ahb.c +++ b/drivers/gpio/gpio_cmsdk_ahb.c @@ -22,7 +22,7 @@ * @brief GPIO driver for ARM CMSDK AHB GPIO */ -typedef void (*gpio_config_func_t)(struct device *port); +typedef void (*gpio_config_func_t)(const struct device *port); struct gpio_cmsdk_ahb_cfg { /* gpio_driver_config needs to be first */ @@ -44,7 +44,8 @@ struct gpio_cmsdk_ahb_dev_data { sys_slist_t gpio_cb; }; -static int gpio_cmsdk_ahb_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_cmsdk_ahb_port_get_raw(const struct device *dev, + uint32_t *value) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -53,8 +54,9 @@ static int gpio_cmsdk_ahb_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_cmsdk_ahb_port_set_masked_raw(struct device *dev, uint32_t mask, - uint32_t value) +static int gpio_cmsdk_ahb_port_set_masked_raw(const struct device *dev, + uint32_t mask, + uint32_t value) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -63,7 +65,8 @@ static int gpio_cmsdk_ahb_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_cmsdk_ahb_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_cmsdk_ahb_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -72,7 +75,8 @@ static int gpio_cmsdk_ahb_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_cmsdk_ahb_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_cmsdk_ahb_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -81,7 +85,8 @@ static int gpio_cmsdk_ahb_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_cmsdk_ahb_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_cmsdk_ahb_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -90,7 +95,8 @@ static int gpio_cmsdk_ahb_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int cmsdk_ahb_gpio_config(struct device *dev, uint32_t mask, gpio_flags_t flags) +static int cmsdk_ahb_gpio_config(const struct device *dev, uint32_t mask, + gpio_flags_t flags) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -137,16 +143,17 @@ static int cmsdk_ahb_gpio_config(struct device *dev, uint32_t mask, gpio_flags_t * * @return 0 if successful, failed otherwise */ -static int gpio_cmsdk_ahb_config(struct device *dev, +static int gpio_cmsdk_ahb_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { return cmsdk_ahb_gpio_config(dev, BIT(pin), flags); } -static int gpio_cmsdk_ahb_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_cmsdk_ahb_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; @@ -186,7 +193,7 @@ static int gpio_cmsdk_ahb_pin_interrupt_configure(struct device *dev, static void gpio_cmsdk_ahb_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; struct gpio_cmsdk_ahb_dev_data *data = dev->data; uint32_t int_stat; @@ -200,7 +207,7 @@ static void gpio_cmsdk_ahb_isr(void *arg) } -static int gpio_cmsdk_ahb_manage_callback(struct device *dev, +static int gpio_cmsdk_ahb_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { @@ -226,13 +233,13 @@ static const struct gpio_driver_api gpio_cmsdk_ahb_drv_api_funcs = { * @param dev Device struct * @return 0 if successful, failed otherwise. */ -static int gpio_cmsdk_ahb_init(struct device *dev) +static int gpio_cmsdk_ahb_init(const struct device *dev) { const struct gpio_cmsdk_ahb_cfg * const cfg = dev->config; #ifdef CONFIG_CLOCK_CONTROL /* Enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(CONFIG_ARM_CLOCK_CONTROL_DEV_NAME); #ifdef CONFIG_SOC_SERIES_BEETLE diff --git a/drivers/gpio/gpio_dw.c b/drivers/gpio/gpio_dw.c index 51b5190a7dfa9f..925cc374c91f67 100644 --- a/drivers/gpio/gpio_dw.c +++ b/drivers/gpio/gpio_dw.c @@ -32,8 +32,9 @@ #include #endif -static int gpio_dw_port_set_bits_raw(struct device *port, uint32_t mask); -static int gpio_dw_port_clear_bits_raw(struct device *port, uint32_t mask); +static int gpio_dw_port_set_bits_raw(const struct device *port, uint32_t mask); +static int gpio_dw_port_clear_bits_raw(const struct device *port, + uint32_t mask); /* * ARC architecture configure IP through IO auxiliary registers. @@ -84,10 +85,10 @@ static void dw_set_bit(uint32_t base_addr, uint32_t offset, #endif #ifdef CONFIG_GPIO_DW_CLOCK_GATE -static inline void gpio_dw_clock_config(struct device *port) +static inline void gpio_dw_clock_config(const struct device *port) { char *drv = CONFIG_GPIO_DW_CLOCK_GATE_DRV_NAME; - struct device *clk; + const struct device *clk; clk = device_get_binding(drv); if (clk) { @@ -97,7 +98,7 @@ static inline void gpio_dw_clock_config(struct device *port) } } -static inline void gpio_dw_clock_on(struct device *port) +static inline void gpio_dw_clock_on(const struct device *port) { const struct gpio_dw_config *config = port->config; struct gpio_dw_runtime *context = port->data; @@ -105,7 +106,7 @@ static inline void gpio_dw_clock_on(struct device *port) clock_control_on(context->clock, config->clock_data); } -static inline void gpio_dw_clock_off(struct device *port) +static inline void gpio_dw_clock_off(const struct device *port) { const struct gpio_dw_config *config = port->config; struct gpio_dw_runtime *context = port->data; @@ -206,9 +207,10 @@ static inline uint32_t dw_get_dir_port(uint32_t base_addr) return ddr_port; } -static int gpio_dw_pin_interrupt_configure(struct device *port, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_dw_pin_interrupt_configure(const struct device *port, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { struct gpio_dw_runtime *context = port->data; const struct gpio_dw_config *config = port->config; @@ -271,7 +273,7 @@ static int gpio_dw_pin_interrupt_configure(struct device *port, return 0; } -static inline void dw_pin_config(struct device *port, +static inline void dw_pin_config(const struct device *port, uint32_t pin, int flags) { struct gpio_dw_runtime *context = port->data; @@ -303,7 +305,7 @@ static inline void dw_pin_config(struct device *port, } } -static inline int gpio_dw_config(struct device *port, +static inline int gpio_dw_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { @@ -339,7 +341,7 @@ static inline int gpio_dw_config(struct device *port, return 0; } -static int gpio_dw_port_get_raw(struct device *port, uint32_t *value) +static int gpio_dw_port_get_raw(const struct device *port, uint32_t *value) { struct gpio_dw_runtime *context = port->data; uint32_t base_addr = dw_base_to_block_base(context->base_addr); @@ -351,7 +353,7 @@ static int gpio_dw_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int gpio_dw_port_set_masked_raw(struct device *port, +static int gpio_dw_port_set_masked_raw(const struct device *port, uint32_t mask, uint32_t value) { struct gpio_dw_runtime *context = port->data; @@ -367,7 +369,7 @@ static int gpio_dw_port_set_masked_raw(struct device *port, return 0; } -static int gpio_dw_port_set_bits_raw(struct device *port, uint32_t mask) +static int gpio_dw_port_set_bits_raw(const struct device *port, uint32_t mask) { struct gpio_dw_runtime *context = port->data; uint32_t base_addr = dw_base_to_block_base(context->base_addr); @@ -382,7 +384,8 @@ static int gpio_dw_port_set_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_dw_port_clear_bits_raw(struct device *port, uint32_t mask) +static int gpio_dw_port_clear_bits_raw(const struct device *port, + uint32_t mask) { struct gpio_dw_runtime *context = port->data; uint32_t base_addr = dw_base_to_block_base(context->base_addr); @@ -397,7 +400,7 @@ static int gpio_dw_port_clear_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_dw_port_toggle_bits(struct device *port, uint32_t mask) +static int gpio_dw_port_toggle_bits(const struct device *port, uint32_t mask) { struct gpio_dw_runtime *context = port->data; uint32_t base_addr = dw_base_to_block_base(context->base_addr); @@ -412,7 +415,7 @@ static int gpio_dw_port_toggle_bits(struct device *port, uint32_t mask) return 0; } -static inline int gpio_dw_manage_callback(struct device *port, +static inline int gpio_dw_manage_callback(const struct device *port, struct gpio_callback *callback, bool set) { @@ -422,21 +425,22 @@ static inline int gpio_dw_manage_callback(struct device *port, } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static void gpio_dw_set_power_state(struct device *port, uint32_t power_state) +static void gpio_dw_set_power_state(const struct device *port, + uint32_t power_state) { struct gpio_dw_runtime *context = port->data; context->device_power_state = power_state; } -static uint32_t gpio_dw_get_power_state(struct device *port) +static uint32_t gpio_dw_get_power_state(const struct device *port) { struct gpio_dw_runtime *context = port->data; return context->device_power_state; } -static inline int gpio_dw_suspend_port(struct device *port) +static inline int gpio_dw_suspend_port(const struct device *port) { gpio_dw_clock_off(port); gpio_dw_set_power_state(port, DEVICE_PM_SUSPEND_STATE); @@ -444,7 +448,7 @@ static inline int gpio_dw_suspend_port(struct device *port) return 0; } -static inline int gpio_dw_resume_from_suspend_port(struct device *port) +static inline int gpio_dw_resume_from_suspend_port(const struct device *port) { gpio_dw_clock_on(port); gpio_dw_set_power_state(port, DEVICE_PM_ACTIVE_STATE); @@ -455,7 +459,8 @@ static inline int gpio_dw_resume_from_suspend_port(struct device *port) * Implements the driver control management functionality * the *context may include IN data or/and OUT data */ -static int gpio_dw_device_ctrl(struct device *port, uint32_t ctrl_command, +static int gpio_dw_device_ctrl(const struct device *port, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; @@ -484,7 +489,7 @@ static int gpio_dw_device_ctrl(struct device *port, uint32_t ctrl_command, static void gpio_dw_isr(void *arg) { - struct device *port = (struct device *)arg; + const struct device *port = (const struct device *)arg; struct gpio_dw_runtime *context = port->data; uint32_t base_addr = dw_base_to_block_base(context->base_addr); uint32_t int_status; @@ -517,7 +522,7 @@ static const struct gpio_driver_api api_funcs = { .manage_callback = gpio_dw_manage_callback, }; -static int gpio_dw_initialize(struct device *port) +static int gpio_dw_initialize(const struct device *port) { struct gpio_dw_runtime *context = port->data; const struct gpio_dw_config *config = port->config; @@ -547,7 +552,7 @@ static int gpio_dw_initialize(struct device *port) /* Bindings to the plaform */ #ifdef CONFIG_GPIO_DW_0 -static void gpio_config_0_irq(struct device *port); +static void gpio_config_0_irq(const struct device *port); static const struct gpio_dw_config gpio_config_0 = { .common = { @@ -588,7 +593,7 @@ DEVICE_AND_API_INIT(gpio_dw_0, DT_INST_LABEL(0), #else #define INST_0_IRQ_FLAGS 0 #endif -static void gpio_config_0_irq(struct device *port) +static void gpio_config_0_irq(const struct device *port) { #if (DT_INST_IRQN(0) > 0) const struct gpio_dw_config *config = port->config; @@ -600,7 +605,7 @@ static void gpio_config_0_irq(struct device *port) INST_0_IRQ_FLAGS); irq_enable(config->irq_num); #elif defined(CONFIG_GPIO_DW_0_IRQ_SHARED) - struct device *shared_irq_dev; + const struct device *shared_irq_dev; shared_irq_dev = device_get_binding(config->shared_irq_dev_name); __ASSERT(shared_irq_dev != NULL, @@ -616,7 +621,7 @@ static void gpio_config_0_irq(struct device *port) #ifdef CONFIG_GPIO_DW_1 -static void gpio_config_1_irq(struct device *port); +static void gpio_config_1_irq(const struct device *port); static const struct gpio_dw_config gpio_dw_config_1 = { .common = { @@ -658,7 +663,7 @@ DEVICE_AND_API_INIT(gpio_dw_1, DT_INST_LABEL(1), #else #define INST_1_IRQ_FLAGS 0 #endif -static void gpio_config_1_irq(struct device *port) +static void gpio_config_1_irq(const struct device *port) { #if (DT_INST_IRQN(1) > 0) const struct gpio_dw_config *config = port->config; @@ -670,7 +675,7 @@ static void gpio_config_1_irq(struct device *port) INST_1_IRQ_FLAGS); irq_enable(config->irq_num); #elif defined(CONFIG_GPIO_DW_1_IRQ_SHARED) - struct device *shared_irq_dev; + const struct device *shared_irq_dev; shared_irq_dev = device_get_binding(config->shared_irq_dev_name); __ASSERT(shared_irq_dev != NULL, @@ -685,7 +690,7 @@ static void gpio_config_1_irq(struct device *port) #endif /* CONFIG_GPIO_DW_1 */ #ifdef CONFIG_GPIO_DW_2 -static void gpio_config_2_irq(struct device *port); +static void gpio_config_2_irq(const struct device *port); static const struct gpio_dw_config gpio_dw_config_2 = { .common = { @@ -726,7 +731,7 @@ DEVICE_AND_API_INIT(gpio_dw_2, DT_INST_LABEL(2), #else #define INST_2_IRQ_FLAGS 0 #endif -static void gpio_config_2_irq(struct device *port) +static void gpio_config_2_irq(const struct device *port) { #if (DT_INST_IRQN(2) > 0) const struct gpio_dw_config *config = port->config; @@ -738,7 +743,7 @@ static void gpio_config_2_irq(struct device *port) INST_2_IRQ_FLAGS); irq_enable(config->irq_num); #elif defined(CONFIG_GPIO_DW_2_IRQ_SHARED) - struct device *shared_irq_dev; + const struct device *shared_irq_dev; shared_irq_dev = device_get_binding(config->shared_irq_dev_name); __ASSERT(shared_irq_dev != NULL, @@ -753,7 +758,7 @@ static void gpio_config_2_irq(struct device *port) #endif /* CONFIG_GPIO_DW_2 */ #ifdef CONFIG_GPIO_DW_3 -static void gpio_config_3_irq(struct device *port); +static void gpio_config_3_irq(const struct device *port); static const struct gpio_dw_config gpio_dw_config_3 = { .common = { @@ -794,7 +799,7 @@ DEVICE_AND_API_INIT(gpio_dw_3, DT_INST_LABEL(3), #else #define INST_3_IRQ_FLAGS 0 #endif -static void gpio_config_3_irq(struct device *port) +static void gpio_config_3_irq(const struct device *port) { #if (DT_INST_IRQN(3) > 0) const struct gpio_dw_config *config = port->config; @@ -806,7 +811,7 @@ static void gpio_config_3_irq(struct device *port) INST_3_IRQ_FLAGS); irq_enable(config->irq_num); #elif defined(CONFIG_GPIO_DW_3_IRQ_SHARED) - struct device *shared_irq_dev; + const struct device *shared_irq_dev; shared_irq_dev = device_get_binding(config->shared_irq_dev_name); __ASSERT(shared_irq_dev != NULL, diff --git a/drivers/gpio/gpio_dw.h b/drivers/gpio/gpio_dw.h index 5b94ebcc7ae456..d3219f295e9a2b 100644 --- a/drivers/gpio/gpio_dw.h +++ b/drivers/gpio/gpio_dw.h @@ -15,7 +15,7 @@ extern "C" { #endif -typedef void (*gpio_config_irq_t)(struct device *port); +typedef void (*gpio_config_irq_t)(const struct device *port); struct gpio_dw_config { /* gpio_driver_config needs to be first */ @@ -38,7 +38,7 @@ struct gpio_dw_runtime { struct gpio_driver_data common; uint32_t base_addr; #ifdef CONFIG_GPIO_DW_CLOCK_GATE - struct device *clock; + const struct device *clock; #endif sys_slist_t callbacks; #ifdef CONFIG_DEVICE_POWER_MANAGEMENT diff --git a/drivers/gpio/gpio_esp32.c b/drivers/gpio/gpio_esp32.c index d5f76cf8e6592e..65c7c2d44d2c74 100644 --- a/drivers/gpio/gpio_esp32.c +++ b/drivers/gpio/gpio_esp32.c @@ -41,7 +41,7 @@ struct gpio_esp32_data { /* gpio_driver_data needs to be first */ struct gpio_driver_data common; - struct device *pinmux; + const struct device *pinmux; struct { volatile uint32_t *set_reg; @@ -56,7 +56,7 @@ struct gpio_esp32_data { sys_slist_t cb; }; -static int gpio_esp32_config(struct device *dev, +static int gpio_esp32_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { @@ -115,7 +115,7 @@ static int gpio_esp32_config(struct device *dev, return 0; } -static int gpio_esp32_port_get_raw(struct device *port, uint32_t *value) +static int gpio_esp32_port_get_raw(const struct device *port, uint32_t *value) { struct gpio_esp32_data *data = port->data; @@ -124,7 +124,7 @@ static int gpio_esp32_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int gpio_esp32_port_set_masked_raw(struct device *port, +static int gpio_esp32_port_set_masked_raw(const struct device *port, uint32_t mask, uint32_t value) { struct gpio_esp32_data *data = port->data; @@ -138,7 +138,7 @@ static int gpio_esp32_port_set_masked_raw(struct device *port, return 0; } -static int gpio_esp32_port_set_bits_raw(struct device *port, +static int gpio_esp32_port_set_bits_raw(const struct device *port, uint32_t pins) { struct gpio_esp32_data *data = port->data; @@ -147,7 +147,7 @@ static int gpio_esp32_port_set_bits_raw(struct device *port, return 0; } -static int gpio_esp32_port_clear_bits_raw(struct device *port, +static int gpio_esp32_port_clear_bits_raw(const struct device *port, uint32_t pins) { struct gpio_esp32_data *data = port->data; @@ -156,7 +156,7 @@ static int gpio_esp32_port_clear_bits_raw(struct device *port, return 0; } -static int gpio_esp32_port_toggle_bits(struct device *port, +static int gpio_esp32_port_toggle_bits(const struct device *port, uint32_t pins) { struct gpio_esp32_data *data = port->data; @@ -213,7 +213,7 @@ static int convert_int_type(enum gpio_int_mode mode, return -EINVAL; } -static int gpio_esp32_pin_interrupt_configure(struct device *port, +static int gpio_esp32_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -244,7 +244,7 @@ static int gpio_esp32_pin_interrupt_configure(struct device *port, return 0; } -static int gpio_esp32_manage_callback(struct device *dev, +static int gpio_esp32_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { @@ -253,7 +253,7 @@ static int gpio_esp32_manage_callback(struct device *dev, return gpio_manage_callback(&data->cb, callback, set); } -static void gpio_esp32_fire_callbacks(struct device *device) +static void gpio_esp32_fire_callbacks(const struct device *device) { struct gpio_esp32_data *data = device->data; uint32_t irq_status = *data->port.irq_status_reg; @@ -265,7 +265,7 @@ static void gpio_esp32_fire_callbacks(struct device *device) static void gpio_esp32_isr(void *param); -static int gpio_esp32_init(struct device *device) +static int gpio_esp32_init(const struct device *device) { struct gpio_esp32_data *data = device->data; static bool isr_connected; diff --git a/drivers/gpio/gpio_gecko.c b/drivers/gpio/gpio_gecko.c index 52e3ef0d9eb252..7ee86f5244aaf5 100644 --- a/drivers/gpio/gpio_gecko.c +++ b/drivers/gpio/gpio_gecko.c @@ -45,7 +45,7 @@ struct gpio_gecko_common_config { struct gpio_gecko_common_data { /* a list of all ports */ - struct device *ports[NUMBER_OF_PORTS]; + const struct device *ports[NUMBER_OF_PORTS]; size_t count; }; @@ -65,13 +65,13 @@ struct gpio_gecko_data { }; static inline void gpio_gecko_add_port(struct gpio_gecko_common_data *data, - struct device *dev) + const struct device *dev) { __ASSERT(dev, "No port device!"); data->ports[data->count++] = dev; } -static int gpio_gecko_configure(struct device *dev, +static int gpio_gecko_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { @@ -124,7 +124,7 @@ static int gpio_gecko_configure(struct device *dev, return 0; } -static int gpio_gecko_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_gecko_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_gecko_config *config = dev->config; GPIO_Port_TypeDef gpio_index = config->gpio_index; @@ -134,7 +134,8 @@ static int gpio_gecko_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_gecko_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_gecko_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { const struct gpio_gecko_config *config = dev->config; @@ -145,7 +146,8 @@ static int gpio_gecko_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_gecko_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_gecko_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_gecko_config *config = dev->config; GPIO_Port_TypeDef gpio_index = config->gpio_index; @@ -155,7 +157,8 @@ static int gpio_gecko_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_gecko_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_gecko_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_gecko_config *config = dev->config; GPIO_Port_TypeDef gpio_index = config->gpio_index; @@ -165,7 +168,8 @@ static int gpio_gecko_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_gecko_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_gecko_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct gpio_gecko_config *config = dev->config; GPIO_Port_TypeDef gpio_index = config->gpio_index; @@ -175,9 +179,10 @@ static int gpio_gecko_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_gecko_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_gecko_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_gecko_config *config = dev->config; struct gpio_gecko_data *data = dev->data; @@ -218,7 +223,7 @@ static int gpio_gecko_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_gecko_manage_callback(struct device *dev, +static int gpio_gecko_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { struct gpio_gecko_data *data = dev->data; @@ -231,10 +236,10 @@ static int gpio_gecko_manage_callback(struct device *dev, */ static void gpio_gecko_common_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct gpio_gecko_common_data *data = dev->data; uint32_t enabled_int, int_status; - struct device *port_dev; + const struct device *port_dev; struct gpio_gecko_data *port_data; int_status = GPIO->IF; @@ -271,7 +276,7 @@ static const struct gpio_driver_api gpio_gecko_common_driver_api = { .manage_callback = gpio_gecko_manage_callback, }; -static int gpio_gecko_common_init(struct device *dev); +static int gpio_gecko_common_init(const struct device *dev); static const struct gpio_gecko_common_config gpio_gecko_common_config = { }; @@ -284,7 +289,7 @@ DEVICE_AND_API_INIT(gpio_gecko_common, DT_LABEL(DT_INST(0, silabs_gecko_gpio)), POST_KERNEL, CONFIG_GPIO_GECKO_COMMON_INIT_PRIORITY, &gpio_gecko_common_driver_api); -static int gpio_gecko_common_init(struct device *dev) +static int gpio_gecko_common_init(const struct device *dev) { gpio_gecko_common_data.count = 0; IRQ_CONNECT(GPIO_EVEN_IRQn, diff --git a/drivers/gpio/gpio_handlers.c b/drivers/gpio/gpio_handlers.c index a43e9c91cc226f..0a835165e262a9 100644 --- a/drivers/gpio/gpio_handlers.c +++ b/drivers/gpio/gpio_handlers.c @@ -7,71 +7,76 @@ #include #include -static inline int z_vrfy_gpio_config(struct device *port, +static inline int z_vrfy_gpio_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, pin_configure)); - return z_impl_gpio_config((struct device *)port, pin, flags); + return z_impl_gpio_config((const struct device *)port, pin, flags); } #include -static inline int z_vrfy_gpio_port_get_raw(struct device *port, +static inline int z_vrfy_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, port_get_raw)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(value, sizeof(gpio_port_value_t))); - return z_impl_gpio_port_get_raw((struct device *)port, + return z_impl_gpio_port_get_raw((const struct device *)port, (gpio_port_value_t *)value); } #include -static inline int z_vrfy_gpio_port_set_masked_raw(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value) +static inline int z_vrfy_gpio_port_set_masked_raw(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, port_set_masked_raw)); - return z_impl_gpio_port_set_masked_raw((struct device *)port, mask, + return z_impl_gpio_port_set_masked_raw((const struct device *)port, + mask, value); } #include -static inline int z_vrfy_gpio_port_set_bits_raw(struct device *port, +static inline int z_vrfy_gpio_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, port_set_bits_raw)); - return z_impl_gpio_port_set_bits_raw((struct device *)port, pins); + return z_impl_gpio_port_set_bits_raw((const struct device *)port, + pins); } #include -static inline int z_vrfy_gpio_port_clear_bits_raw(struct device *port, +static inline int z_vrfy_gpio_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, port_clear_bits_raw)); - return z_impl_gpio_port_clear_bits_raw((struct device *)port, pins); + return z_impl_gpio_port_clear_bits_raw((const struct device *)port, + pins); } #include -static inline int z_vrfy_gpio_port_toggle_bits(struct device *port, +static inline int z_vrfy_gpio_port_toggle_bits(const struct device *port, gpio_port_pins_t pins) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, port_toggle_bits)); - return z_impl_gpio_port_toggle_bits((struct device *)port, pins); + return z_impl_gpio_port_toggle_bits((const struct device *)port, pins); } #include -static inline int z_vrfy_gpio_pin_interrupt_configure(struct device *port, +static inline int z_vrfy_gpio_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(port, pin_interrupt_configure)); - return z_impl_gpio_pin_interrupt_configure((struct device *)port, pin, + return z_impl_gpio_pin_interrupt_configure((const struct device *)port, + pin, flags); } #include -static inline int z_vrfy_gpio_get_pending_int(struct device *dev) +static inline int z_vrfy_gpio_get_pending_int(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_GPIO(dev, get_pending_int)); - return z_impl_gpio_get_pending_int((struct device *)dev); + return z_impl_gpio_get_pending_int((const struct device *)dev); } #include diff --git a/drivers/gpio/gpio_ht16k33.c b/drivers/gpio/gpio_ht16k33.c index 73df86b9852d2a..5732da7c253d19 100644 --- a/drivers/gpio/gpio_ht16k33.c +++ b/drivers/gpio/gpio_ht16k33.c @@ -35,11 +35,11 @@ struct gpio_ht16k33_cfg { struct gpio_ht16k33_data { /* gpio_driver_data needs to be first */ struct gpio_driver_data common; - struct device *parent; + const struct device *parent; sys_slist_t callbacks; }; -static int gpio_ht16k33_cfg(struct device *dev, +static int gpio_ht16k33_cfg(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { @@ -55,7 +55,7 @@ static int gpio_ht16k33_cfg(struct device *dev, return 0; } -static int gpio_ht16k33_port_get_raw(struct device *port, +static int gpio_ht16k33_port_get_raw(const struct device *port, gpio_port_value_t *value) { ARG_UNUSED(port); @@ -65,7 +65,7 @@ static int gpio_ht16k33_port_get_raw(struct device *port, return -ENOTSUP; } -static int gpio_ht16k33_port_set_masked_raw(struct device *port, +static int gpio_ht16k33_port_set_masked_raw(const struct device *port, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -77,7 +77,7 @@ static int gpio_ht16k33_port_set_masked_raw(struct device *port, return -ENOTSUP; } -static int gpio_ht16k33_port_set_bits_raw(struct device *port, +static int gpio_ht16k33_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) { ARG_UNUSED(port); @@ -87,7 +87,7 @@ static int gpio_ht16k33_port_set_bits_raw(struct device *port, return -ENOTSUP; } -static int gpio_ht16k33_port_clear_bits_raw(struct device *port, +static int gpio_ht16k33_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) { ARG_UNUSED(port); @@ -97,7 +97,7 @@ static int gpio_ht16k33_port_clear_bits_raw(struct device *port, return -ENOTSUP; } -static int gpio_ht16k33_port_toggle_bits(struct device *port, +static int gpio_ht16k33_port_toggle_bits(const struct device *port, gpio_port_pins_t pins) { ARG_UNUSED(port); @@ -107,7 +107,7 @@ static int gpio_ht16k33_port_toggle_bits(struct device *port, return -ENOTSUP; } -static int gpio_ht16k33_pin_interrupt_configure(struct device *port, +static int gpio_ht16k33_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, enum gpio_int_mode int_mode, enum gpio_int_trig int_trig) @@ -121,7 +121,7 @@ static int gpio_ht16k33_pin_interrupt_configure(struct device *port, return 0; } -void ht16k33_process_keyscan_row_data(struct device *dev, +void ht16k33_process_keyscan_row_data(const struct device *dev, uint32_t keys) { struct gpio_ht16k33_data *data = dev->data; @@ -129,7 +129,7 @@ void ht16k33_process_keyscan_row_data(struct device *dev, gpio_fire_callbacks(&data->callbacks, dev, keys); } -static int gpio_ht16k33_manage_callback(struct device *dev, +static int gpio_ht16k33_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { @@ -138,14 +138,14 @@ static int gpio_ht16k33_manage_callback(struct device *dev, return gpio_manage_callback(&data->callbacks, callback, set); } -static uint32_t gpio_ht16k33_get_pending_int(struct device *dev) +static uint32_t gpio_ht16k33_get_pending_int(const struct device *dev) { struct gpio_ht16k33_data *data = dev->data; return ht16k33_get_pending_int(data->parent); } -static int gpio_ht16k33_init(struct device *dev) +static int gpio_ht16k33_init(const struct device *dev) { const struct gpio_ht16k33_cfg *config = dev->config; struct gpio_ht16k33_data *data = dev->data; diff --git a/drivers/gpio/gpio_imx.c b/drivers/gpio/gpio_imx.c index 0eecb95eb00ba1..6c3ecf727cfec6 100644 --- a/drivers/gpio/gpio_imx.c +++ b/drivers/gpio/gpio_imx.c @@ -28,7 +28,7 @@ struct imx_gpio_data { sys_slist_t callbacks; }; -static int imx_gpio_configure(struct device *port, gpio_pin_t pin, +static int imx_gpio_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { const struct imx_gpio_config *config = port->config; @@ -66,7 +66,7 @@ static int imx_gpio_configure(struct device *port, gpio_pin_t pin, return 0; } -static int imx_gpio_port_get_raw(struct device *port, uint32_t *value) +static int imx_gpio_port_get_raw(const struct device *port, uint32_t *value) { const struct imx_gpio_config *config = port->config; GPIO_Type *base = config->base; @@ -76,7 +76,7 @@ static int imx_gpio_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int imx_gpio_port_set_masked_raw(struct device *port, +static int imx_gpio_port_set_masked_raw(const struct device *port, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -89,7 +89,7 @@ static int imx_gpio_port_set_masked_raw(struct device *port, return 0; } -static int imx_gpio_port_set_bits_raw(struct device *port, +static int imx_gpio_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct imx_gpio_config *config = port->config; @@ -100,7 +100,7 @@ static int imx_gpio_port_set_bits_raw(struct device *port, return 0; } -static int imx_gpio_port_clear_bits_raw(struct device *port, +static int imx_gpio_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct imx_gpio_config *config = port->config; @@ -111,7 +111,8 @@ static int imx_gpio_port_clear_bits_raw(struct device *port, return 0; } -static int imx_gpio_port_toggle_bits(struct device *port, gpio_port_pins_t pins) +static int imx_gpio_port_toggle_bits(const struct device *port, + gpio_port_pins_t pins) { const struct imx_gpio_config *config = port->config; GPIO_Type *base = config->base; @@ -121,7 +122,7 @@ static int imx_gpio_port_toggle_bits(struct device *port, gpio_port_pins_t pins) return 0; } -static int imx_gpio_pin_interrupt_configure(struct device *port, +static int imx_gpio_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -174,7 +175,7 @@ static int imx_gpio_pin_interrupt_configure(struct device *port, return 0; } -static int imx_gpio_manage_callback(struct device *port, +static int imx_gpio_manage_callback(const struct device *port, struct gpio_callback *cb, bool set) { struct imx_gpio_data *data = port->data; @@ -184,7 +185,7 @@ static int imx_gpio_manage_callback(struct device *port, static void imx_gpio_port_isr(void *arg) { - struct device *port = (struct device *)arg; + const struct device *port = (const struct device *)arg; const struct imx_gpio_config *config = port->config; struct imx_gpio_data *data = port->data; uint32_t int_status; diff --git a/drivers/gpio/gpio_intel_apl.c b/drivers/gpio/gpio_intel_apl.c index b14408a16fba12..a295c8863a807f 100644 --- a/drivers/gpio/gpio_intel_apl.c +++ b/drivers/gpio/gpio_intel_apl.c @@ -128,7 +128,7 @@ struct gpio_intel_apl_data { sys_slist_t cb; }; -static inline mm_reg_t regs(struct device *dev) +static inline mm_reg_t regs(const struct device *dev) { return DEVICE_MMIO_NAMED_GET(dev, reg_base); } @@ -142,7 +142,7 @@ static inline mm_reg_t regs(struct device *dev) * * @return true if host owns the GPIO pin, false otherwise */ -static bool check_perm(struct device *dev, uint32_t raw_pin) +static bool check_perm(const struct device *dev, uint32_t raw_pin) { struct gpio_intel_apl_data *data = dev->data; uint32_t offset, val; @@ -182,11 +182,11 @@ static bool check_perm(struct device *dev, uint32_t raw_pin) static int nr_isr_devs; -static struct device *isr_devs[GPIO_INTEL_APL_NR_SUBDEVS]; +static const struct device *isr_devs[GPIO_INTEL_APL_NR_SUBDEVS]; static void gpio_intel_apl_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_intel_apl_config *cfg; struct gpio_intel_apl_data *data; struct gpio_callback *cb, *tmp; @@ -217,7 +217,7 @@ static void gpio_intel_apl_isr(void *arg) } } -static int gpio_intel_apl_config(struct device *dev, +static int gpio_intel_apl_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_intel_apl_config *cfg = dev->config; @@ -291,9 +291,10 @@ static int gpio_intel_apl_config(struct device *dev, return 0; } -static int gpio_intel_apl_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_intel_apl_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_intel_apl_config *cfg = dev->config; struct gpio_intel_apl_data *data = dev->data; @@ -382,7 +383,7 @@ static int gpio_intel_apl_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_intel_apl_manage_callback(struct device *dev, +static int gpio_intel_apl_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { @@ -391,7 +392,8 @@ static int gpio_intel_apl_manage_callback(struct device *dev, return gpio_manage_callback(&data->cb, callback, set); } -static int port_get_raw(struct device *dev, uint32_t mask, uint32_t *value, +static int port_get_raw(const struct device *dev, uint32_t mask, + uint32_t *value, bool read_tx) { const struct gpio_intel_apl_config *cfg = dev->config; @@ -431,7 +433,8 @@ static int port_get_raw(struct device *dev, uint32_t mask, uint32_t *value, return 0; } -static int port_set_raw(struct device *dev, uint32_t mask, uint32_t value) +static int port_set_raw(const struct device *dev, uint32_t mask, + uint32_t value) { const struct gpio_intel_apl_config *cfg = dev->config; struct gpio_intel_apl_data *data = dev->data; @@ -467,7 +470,8 @@ static int port_set_raw(struct device *dev, uint32_t mask, uint32_t value) return 0; } -static int gpio_intel_apl_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_intel_apl_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { uint32_t port_val; @@ -481,17 +485,20 @@ static int gpio_intel_apl_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_intel_apl_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_intel_apl_port_set_bits_raw(const struct device *dev, + uint32_t mask) { return gpio_intel_apl_port_set_masked_raw(dev, mask, mask); } -static int gpio_intel_apl_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_intel_apl_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { return gpio_intel_apl_port_set_masked_raw(dev, mask, 0); } -static int gpio_intel_apl_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_intel_apl_port_toggle_bits(const struct device *dev, + uint32_t mask) { uint32_t port_val; @@ -504,7 +511,8 @@ static int gpio_intel_apl_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_intel_apl_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_intel_apl_port_get_raw(const struct device *dev, + uint32_t *value) { return port_get_raw(dev, 0xFFFFFFFF, value, false); } @@ -520,7 +528,7 @@ static const struct gpio_driver_api gpio_intel_apl_api = { .pin_interrupt_configure = gpio_intel_apl_pin_interrupt_configure, }; -int gpio_intel_apl_init(struct device *dev) +int gpio_intel_apl_init(const struct device *dev) { struct gpio_intel_apl_data *data = dev->data; diff --git a/drivers/gpio/gpio_litex.c b/drivers/gpio/gpio_litex.c index 30eefaac10abc5..1dc346b56b90e3 100644 --- a/drivers/gpio/gpio_litex.c +++ b/drivers/gpio/gpio_litex.c @@ -78,7 +78,7 @@ static inline uint32_t get_port(const struct gpio_litex_cfg *config) /* Driver functions */ -static int gpio_litex_init(struct device *dev) +static int gpio_litex_init(const struct device *dev) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -91,7 +91,7 @@ static int gpio_litex_init(struct device *dev) return 0; } -static int gpio_litex_configure(struct device *dev, +static int gpio_litex_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -129,7 +129,8 @@ static int gpio_litex_configure(struct device *dev, return 0; } -static int gpio_litex_port_get_raw(struct device *dev, gpio_port_value_t *value) +static int gpio_litex_port_get_raw(const struct device *dev, + gpio_port_value_t *value) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -137,7 +138,7 @@ static int gpio_litex_port_get_raw(struct device *dev, gpio_port_value_t *value) return 0; } -static int gpio_litex_port_set_masked_raw(struct device *dev, +static int gpio_litex_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -151,7 +152,7 @@ static int gpio_litex_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_litex_port_set_bits_raw(struct device *dev, +static int gpio_litex_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -164,7 +165,7 @@ static int gpio_litex_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_litex_port_clear_bits_raw(struct device *dev, +static int gpio_litex_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -177,7 +178,7 @@ static int gpio_litex_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_litex_port_toggle_bits(struct device *dev, +static int gpio_litex_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_litex_cfg *gpio_config = DEV_GPIO_CFG(dev); @@ -190,10 +191,10 @@ static int gpio_litex_port_toggle_bits(struct device *dev, return 0; } -static int gpio_litex_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, - enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_litex_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { int ret = 0; diff --git a/drivers/gpio/gpio_lmp90xxx.c b/drivers/gpio/gpio_lmp90xxx.c index 62b72cd4a9b2b1..a9c8d648c41c79 100644 --- a/drivers/gpio/gpio_lmp90xxx.c +++ b/drivers/gpio/gpio_lmp90xxx.c @@ -31,10 +31,10 @@ struct gpio_lmp90xxx_config { struct gpio_lmp90xxx_data { /* gpio_driver_data needs to be first */ struct gpio_driver_data common; - struct device *parent; + const struct device *parent; }; -static int gpio_lmp90xxx_config(struct device *dev, +static int gpio_lmp90xxx_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { struct gpio_lmp90xxx_data *data = dev->data; @@ -82,7 +82,7 @@ static int gpio_lmp90xxx_config(struct device *dev, return err; } -static int gpio_lmp90xxx_port_get_raw(struct device *dev, +static int gpio_lmp90xxx_port_get_raw(const struct device *dev, gpio_port_value_t *value) { struct gpio_lmp90xxx_data *data = dev->data; @@ -90,7 +90,7 @@ static int gpio_lmp90xxx_port_get_raw(struct device *dev, return lmp90xxx_gpio_port_get_raw(data->parent, value); } -static int gpio_lmp90xxx_port_set_masked_raw(struct device *dev, +static int gpio_lmp90xxx_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -99,7 +99,7 @@ static int gpio_lmp90xxx_port_set_masked_raw(struct device *dev, return lmp90xxx_gpio_port_set_masked_raw(data->parent, mask, value); } -static int gpio_lmp90xxx_port_set_bits_raw(struct device *dev, +static int gpio_lmp90xxx_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) { struct gpio_lmp90xxx_data *data = dev->data; @@ -107,7 +107,7 @@ static int gpio_lmp90xxx_port_set_bits_raw(struct device *dev, return lmp90xxx_gpio_port_set_bits_raw(data->parent, pins); } -static int gpio_lmp90xxx_port_clear_bits_raw(struct device *dev, +static int gpio_lmp90xxx_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { struct gpio_lmp90xxx_data *data = dev->data; @@ -115,7 +115,7 @@ static int gpio_lmp90xxx_port_clear_bits_raw(struct device *dev, return lmp90xxx_gpio_port_clear_bits_raw(data->parent, pins); } -static int gpio_lmp90xxx_port_toggle_bits(struct device *dev, +static int gpio_lmp90xxx_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { struct gpio_lmp90xxx_data *data = dev->data; @@ -123,7 +123,7 @@ static int gpio_lmp90xxx_port_toggle_bits(struct device *dev, return lmp90xxx_gpio_port_toggle_bits(data->parent, pins); } -static int gpio_lmp90xxx_pin_interrupt_configure(struct device *dev, +static int gpio_lmp90xxx_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -136,7 +136,7 @@ static int gpio_lmp90xxx_pin_interrupt_configure(struct device *dev, return -ENOTSUP; } -static int gpio_lmp90xxx_init(struct device *dev) +static int gpio_lmp90xxx_init(const struct device *dev) { const struct gpio_lmp90xxx_config *config = dev->config; struct gpio_lmp90xxx_data *data = dev->data; diff --git a/drivers/gpio/gpio_lpc11u6x.c b/drivers/gpio/gpio_lpc11u6x.c index 550c0fae5149ae..3b6f2e289a95f0 100644 --- a/drivers/gpio/gpio_lpc11u6x.c +++ b/drivers/gpio/gpio_lpc11u6x.c @@ -103,11 +103,11 @@ struct gpio_lpc11u6x_config { struct gpio_lpc11u6x_data { /* gpio_driver_data needs to be first. */ struct gpio_driver_data common; - struct device *pinmux_dev; + const struct device *pinmux_dev; sys_slist_t cb_list; }; -static int gpio_lpc11u6x_pin_configure(struct device *port, +static int gpio_lpc11u6x_pin_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_lpc11u6x_config *config = DEV_CFG(port); @@ -184,7 +184,7 @@ static int gpio_lpc11u6x_pin_configure(struct device *port, return 0; } -static int gpio_lpc11u6x_port_get_raw(struct device *port, +static int gpio_lpc11u6x_port_get_raw(const struct device *port, gpio_port_value_t *value) { const struct gpio_lpc11u6x_config *config = DEV_CFG(port); @@ -196,7 +196,7 @@ static int gpio_lpc11u6x_port_get_raw(struct device *port, return 0; } -static int gpio_lpc11u6x_port_set_masked_raw(struct device *port, +static int gpio_lpc11u6x_port_set_masked_raw(const struct device *port, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -220,7 +220,7 @@ static int gpio_lpc11u6x_port_set_masked_raw(struct device *port, return 0; } -static int gpio_lpc11u6x_port_set_bits_raw(struct device *port, +static int gpio_lpc11u6x_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct gpio_lpc11u6x_config *config = DEV_CFG(port); @@ -232,7 +232,7 @@ static int gpio_lpc11u6x_port_set_bits_raw(struct device *port, return 0; } -static int gpio_lpc11u6x_port_clear_bits_raw(struct device *port, +static int gpio_lpc11u6x_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct gpio_lpc11u6x_config *config = DEV_CFG(port); @@ -244,7 +244,7 @@ static int gpio_lpc11u6x_port_clear_bits_raw(struct device *port, return 0; } -static int gpio_lpc11u6x_port_toggle_bits(struct device *port, +static int gpio_lpc11u6x_port_toggle_bits(const struct device *port, gpio_port_pins_t pins) { const struct gpio_lpc11u6x_config *config = DEV_CFG(port); @@ -318,7 +318,7 @@ pintsel_detach(const struct gpio_lpc11u6x_shared *shared, uint8_t intpin) return -EINVAL; } -static int gpio_lpc11u6x_pin_interrupt_configure(struct device *port, +static int gpio_lpc11u6x_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -403,7 +403,7 @@ static int gpio_lpc11u6x_pin_interrupt_configure(struct device *port, return 0; } -static int gpio_lpc11u6x_manage_callback(struct device *port, +static int gpio_lpc11u6x_manage_callback(const struct device *port, struct gpio_callback *cb, bool set) { struct gpio_lpc11u6x_data *data = DEV_DATA(port); @@ -411,7 +411,7 @@ static int gpio_lpc11u6x_manage_callback(struct device *port, return gpio_manage_callback(&data->cb_list, cb, set); } -static uint32_t gpio_lpc11u6x_get_pending_int(struct device *dev) +static uint32_t gpio_lpc11u6x_get_pending_int(const struct device *dev) { ARG_UNUSED(dev); @@ -437,7 +437,7 @@ static void gpio_lpc11u6x_isr(void *arg) (uint32_t *) (shared->syscon_base + LPC11U6X_PINTSEL_REGS); uint8_t irq; uint32_t pins[3] = { 0, 0, 0 }; - struct device *port; + const struct device *port; struct gpio_lpc11u6x_data *data; for (irq = 0; irq < shared->nirqs; irq++) { @@ -522,11 +522,11 @@ do { \ irq_enable(DT_INST_IRQ_BY_IDX(0, n, irq)); \ } while (0) -static int gpio_lpc11u6x_init(struct device *dev) +static int gpio_lpc11u6x_init(const struct device *dev) { const struct gpio_lpc11u6x_config *config = DEV_CFG(dev); struct gpio_lpc11u6x_data *data = DEV_DATA(dev); - struct device *clock_dev; + const struct device *clock_dev; int ret; static bool gpio_ready; diff --git a/drivers/gpio/gpio_mchp_xec.c b/drivers/gpio/gpio_mchp_xec.c index b745598342eef5..14907a015bf66e 100644 --- a/drivers/gpio/gpio_mchp_xec.c +++ b/drivers/gpio/gpio_mchp_xec.c @@ -44,7 +44,7 @@ struct gpio_xec_config { uint32_t flags; }; -static int gpio_xec_configure(struct device *dev, +static int gpio_xec_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_xec_config *config = dev->config; @@ -126,9 +126,10 @@ static int gpio_xec_configure(struct device *dev, return 0; } -static int gpio_xec_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_xec_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_xec_config *config = dev->config; __IO uint32_t *current_pcr1; @@ -203,7 +204,8 @@ static int gpio_xec_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_xec_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_xec_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { const struct gpio_xec_config *config = dev->config; @@ -216,7 +218,7 @@ static int gpio_xec_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_xec_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_xec_port_set_bits_raw(const struct device *dev, uint32_t mask) { const struct gpio_xec_config *config = dev->config; @@ -228,7 +230,8 @@ static int gpio_xec_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_xec_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_xec_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_xec_config *config = dev->config; @@ -240,7 +243,7 @@ static int gpio_xec_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_xec_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_xec_port_toggle_bits(const struct device *dev, uint32_t mask) { const struct gpio_xec_config *config = dev->config; @@ -252,7 +255,7 @@ static int gpio_xec_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_xec_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_xec_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_xec_config *config = dev->config; @@ -264,7 +267,7 @@ static int gpio_xec_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_xec_manage_callback(struct device *dev, +static int gpio_xec_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { struct gpio_xec_data *data = dev->data; @@ -276,7 +279,7 @@ static int gpio_xec_manage_callback(struct device *dev, static void gpio_gpio_xec_port_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_xec_config *config = dev->config; struct gpio_xec_data *data = dev->data; uint32_t girq_result; @@ -304,7 +307,7 @@ static const struct gpio_driver_api gpio_xec_driver_api = { }; #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_000_036), okay) -static int gpio_xec_port000_036_init(struct device *dev); +static int gpio_xec_port000_036_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port000_036_config = { .common = { @@ -330,7 +333,7 @@ DEVICE_AND_API_INIT(gpio_xec_port000_036, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port000_036_init(struct device *dev) +static int gpio_xec_port000_036_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_000_036), irq) const struct gpio_xec_config *config = dev->config; @@ -349,7 +352,7 @@ static int gpio_xec_port000_036_init(struct device *dev) #endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_000_036), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_040_076), okay) -static int gpio_xec_port040_076_init(struct device *dev); +static int gpio_xec_port040_076_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port040_076_config = { .common = { @@ -375,7 +378,7 @@ DEVICE_AND_API_INIT(gpio_xec_port040_076, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port040_076_init(struct device *dev) +static int gpio_xec_port040_076_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_040_076), irq) const struct gpio_xec_config *config = dev->config; @@ -394,7 +397,7 @@ static int gpio_xec_port040_076_init(struct device *dev) #endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_040_076), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_100_136), okay) -static int gpio_xec_port100_136_init(struct device *dev); +static int gpio_xec_port100_136_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port100_136_config = { .common = { @@ -420,7 +423,7 @@ DEVICE_AND_API_INIT(gpio_xec_port100_136, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port100_136_init(struct device *dev) +static int gpio_xec_port100_136_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_100_136), irq) const struct gpio_xec_config *config = dev->config; @@ -439,7 +442,7 @@ static int gpio_xec_port100_136_init(struct device *dev) #endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_100_136), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_140_176), okay) -static int gpio_xec_port140_176_init(struct device *dev); +static int gpio_xec_port140_176_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port140_176_config = { .common = { @@ -465,7 +468,7 @@ DEVICE_AND_API_INIT(gpio_xec_port140_176, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port140_176_init(struct device *dev) +static int gpio_xec_port140_176_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_140_176), irq) const struct gpio_xec_config *config = dev->config; @@ -484,7 +487,7 @@ static int gpio_xec_port140_176_init(struct device *dev) #endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_140_176), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_200_236), okay) -static int gpio_xec_port200_236_init(struct device *dev); +static int gpio_xec_port200_236_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port200_236_config = { .common = { @@ -510,7 +513,7 @@ DEVICE_AND_API_INIT(gpio_xec_port200_236, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port200_236_init(struct device *dev) +static int gpio_xec_port200_236_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_200_236), irq) const struct gpio_xec_config *config = dev->config; @@ -529,7 +532,7 @@ static int gpio_xec_port200_236_init(struct device *dev) #endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_200_236), okay) */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_240_276), okay) -static int gpio_xec_port240_276_init(struct device *dev); +static int gpio_xec_port240_276_init(const struct device *dev); static const struct gpio_xec_config gpio_xec_port240_276_config = { .common = { @@ -555,7 +558,7 @@ DEVICE_AND_API_INIT(gpio_xec_port240_276, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_xec_driver_api); -static int gpio_xec_port240_276_init(struct device *dev) +static int gpio_xec_port240_276_init(const struct device *dev) { #if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_240_276), irq) const struct gpio_xec_config *config = dev->config; diff --git a/drivers/gpio/gpio_mcp23s17.c b/drivers/gpio/gpio_mcp23s17.c index d33c67c26016b6..0032455a1da63f 100644 --- a/drivers/gpio/gpio_mcp23s17.c +++ b/drivers/gpio/gpio_mcp23s17.c @@ -37,7 +37,8 @@ LOG_MODULE_REGISTER(gpio_mcp23s17); * * @return 0 if successful, failed otherwise. */ -static int read_port_regs(struct device *dev, uint8_t reg, uint16_t *buf) +static int read_port_regs(const struct device *dev, uint8_t reg, + uint16_t *buf) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -95,7 +96,8 @@ static int read_port_regs(struct device *dev, uint8_t reg, uint16_t *buf) * * @return 0 if successful, failed otherwise. */ -static int write_port_regs(struct device *dev, uint8_t reg, uint16_t value) +static int write_port_regs(const struct device *dev, uint8_t reg, + uint16_t value) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -143,7 +145,7 @@ static int write_port_regs(struct device *dev, uint8_t reg, uint16_t value) * * @return 0 if successful, failed otherwise */ -static int setup_pin_dir(struct device *dev, uint32_t pin, int flags) +static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -181,7 +183,8 @@ static int setup_pin_dir(struct device *dev, uint32_t pin, int flags) * * @return 0 if successful, failed otherwise */ -static int setup_pin_pullupdown(struct device *dev, uint32_t pin, int flags) +static int setup_pin_pullupdown(const struct device *dev, uint32_t pin, + int flags) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -206,7 +209,7 @@ static int setup_pin_pullupdown(struct device *dev, uint32_t pin, int flags) return ret; } -static int mcp23s17_config(struct device *dev, +static int mcp23s17_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { struct mcp23s17_drv_data *const drv_data = @@ -242,7 +245,7 @@ static int mcp23s17_config(struct device *dev, return ret; } -static int mcp23s17_port_get_raw(struct device *dev, uint32_t *value) +static int mcp23s17_port_get_raw(const struct device *dev, uint32_t *value) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -268,7 +271,7 @@ static int mcp23s17_port_get_raw(struct device *dev, uint32_t *value) return ret; } -static int mcp23s17_port_set_masked_raw(struct device *dev, +static int mcp23s17_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value) { struct mcp23s17_drv_data *const drv_data = @@ -296,17 +299,18 @@ static int mcp23s17_port_set_masked_raw(struct device *dev, return ret; } -static int mcp23s17_port_set_bits_raw(struct device *dev, uint32_t mask) +static int mcp23s17_port_set_bits_raw(const struct device *dev, uint32_t mask) { return mcp23s17_port_set_masked_raw(dev, mask, mask); } -static int mcp23s17_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int mcp23s17_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { return mcp23s17_port_set_masked_raw(dev, mask, 0); } -static int mcp23s17_port_toggle_bits(struct device *dev, uint32_t mask) +static int mcp23s17_port_toggle_bits(const struct device *dev, uint32_t mask) { struct mcp23s17_drv_data *const drv_data = (struct mcp23s17_drv_data *const)dev->data; @@ -333,7 +337,7 @@ static int mcp23s17_port_toggle_bits(struct device *dev, uint32_t mask) return ret; } -static int mcp23s17_pin_interrupt_configure(struct device *dev, +static int mcp23s17_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -357,7 +361,7 @@ static const struct gpio_driver_api api_table = { * @param dev Device struct * @return 0 if successful, failed otherwise. */ -static int mcp23s17_init(struct device *dev) +static int mcp23s17_init(const struct device *dev) { const struct mcp23s17_config *const config = dev->config; diff --git a/drivers/gpio/gpio_mcp23s17.h b/drivers/gpio/gpio_mcp23s17.h index b3bc5bd6cc55cb..2827822e691eae 100644 --- a/drivers/gpio/gpio_mcp23s17.h +++ b/drivers/gpio/gpio_mcp23s17.h @@ -64,7 +64,7 @@ struct mcp23s17_drv_data { struct gpio_driver_config data; /** Master SPI device */ - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; struct spi_cs_control mcp23s17_cs_ctrl; diff --git a/drivers/gpio/gpio_mcux.c b/drivers/gpio/gpio_mcux.c index 02f9ec6f3b3304..5d782ef35bd930 100644 --- a/drivers/gpio/gpio_mcux.c +++ b/drivers/gpio/gpio_mcux.c @@ -31,7 +31,7 @@ struct gpio_mcux_data { sys_slist_t callbacks; }; -static int gpio_mcux_configure(struct device *dev, +static int gpio_mcux_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_mcux_config *config = dev->config; @@ -98,7 +98,7 @@ static int gpio_mcux_configure(struct device *dev, return 0; } -static int gpio_mcux_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_mcux_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_mcux_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -108,7 +108,8 @@ static int gpio_mcux_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_mcux_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_mcux_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { const struct gpio_mcux_config *config = dev->config; @@ -119,7 +120,8 @@ static int gpio_mcux_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_mcux_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mcux_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_mcux_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -129,7 +131,8 @@ static int gpio_mcux_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mcux_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mcux_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_mcux_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -139,7 +142,7 @@ static int gpio_mcux_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mcux_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_mcux_port_toggle_bits(const struct device *dev, uint32_t mask) { const struct gpio_mcux_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -149,9 +152,10 @@ static int gpio_mcux_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static uint32_t get_port_pcr_irqc_value_from_flags(struct device *dev, - uint32_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static uint32_t get_port_pcr_irqc_value_from_flags(const struct device *dev, + uint32_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { port_interrupt_t port_interrupt = 0; @@ -182,7 +186,7 @@ static uint32_t get_port_pcr_irqc_value_from_flags(struct device *dev, return PORT_PCR_IRQC(port_interrupt); } -static int gpio_mcux_pin_interrupt_configure(struct device *dev, +static int gpio_mcux_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) { @@ -214,7 +218,7 @@ static int gpio_mcux_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_mcux_manage_callback(struct device *dev, +static int gpio_mcux_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { struct gpio_mcux_data *data = dev->data; @@ -224,7 +228,7 @@ static int gpio_mcux_manage_callback(struct device *dev, static void gpio_mcux_port_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_mcux_config *config = dev->config; struct gpio_mcux_data *data = dev->data; uint32_t int_status; diff --git a/drivers/gpio/gpio_mcux_igpio.c b/drivers/gpio/gpio_mcux_igpio.c index 608fd80bc43180..7af470727aa64e 100644 --- a/drivers/gpio/gpio_mcux_igpio.c +++ b/drivers/gpio/gpio_mcux_igpio.c @@ -28,7 +28,7 @@ struct mcux_igpio_data { sys_slist_t callbacks; }; -static int mcux_igpio_configure(struct device *dev, +static int mcux_igpio_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct mcux_igpio_config *config = dev->config; @@ -59,7 +59,7 @@ static int mcux_igpio_configure(struct device *dev, return 0; } -static int mcux_igpio_port_get_raw(struct device *dev, uint32_t *value) +static int mcux_igpio_port_get_raw(const struct device *dev, uint32_t *value) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -69,8 +69,9 @@ static int mcux_igpio_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int mcux_igpio_port_set_masked_raw(struct device *dev, uint32_t mask, - uint32_t value) +static int mcux_igpio_port_set_masked_raw(const struct device *dev, + uint32_t mask, + uint32_t value) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -80,7 +81,8 @@ static int mcux_igpio_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int mcux_igpio_port_set_bits_raw(struct device *dev, uint32_t mask) +static int mcux_igpio_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -90,7 +92,8 @@ static int mcux_igpio_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int mcux_igpio_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int mcux_igpio_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -100,7 +103,8 @@ static int mcux_igpio_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int mcux_igpio_port_toggle_bits(struct device *dev, uint32_t mask) +static int mcux_igpio_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -110,9 +114,10 @@ static int mcux_igpio_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int mcux_igpio_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int mcux_igpio_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct mcux_igpio_config *config = dev->config; GPIO_Type *base = config->base; @@ -163,8 +168,9 @@ static int mcux_igpio_pin_interrupt_configure(struct device *dev, return 0; } -static int mcux_igpio_manage_callback(struct device *dev, - struct gpio_callback *callback, bool set) +static int mcux_igpio_manage_callback(const struct device *dev, + struct gpio_callback *callback, + bool set) { struct mcux_igpio_data *data = dev->data; @@ -173,7 +179,7 @@ static int mcux_igpio_manage_callback(struct device *dev, static void mcux_igpio_port_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_igpio_config *config = dev->config; struct mcux_igpio_data *data = dev->data; GPIO_Type *base = config->base; diff --git a/drivers/gpio/gpio_mcux_lpc.c b/drivers/gpio/gpio_mcux_lpc.c index efe34ca7ab83b8..65d0a295d85a0e 100644 --- a/drivers/gpio/gpio_mcux_lpc.c +++ b/drivers/gpio/gpio_mcux_lpc.c @@ -60,7 +60,7 @@ struct gpio_mcux_lpc_data { uint32_t isr_list_idx; }; -static int gpio_mcux_lpc_configure(struct device *dev, gpio_pin_t pin, +static int gpio_mcux_lpc_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_mcux_lpc_config *config = dev->config; @@ -122,7 +122,8 @@ static int gpio_mcux_lpc_configure(struct device *dev, gpio_pin_t pin, return 0; } -static int gpio_mcux_lpc_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_mcux_lpc_port_get_raw(const struct device *dev, + uint32_t *value) { const struct gpio_mcux_lpc_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -132,7 +133,8 @@ static int gpio_mcux_lpc_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_mcux_lpc_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_mcux_lpc_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { const struct gpio_mcux_lpc_config *config = dev->config; @@ -148,7 +150,8 @@ static int gpio_mcux_lpc_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_mcux_lpc_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mcux_lpc_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_mcux_lpc_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -158,7 +161,8 @@ static int gpio_mcux_lpc_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mcux_lpc_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mcux_lpc_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_mcux_lpc_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -168,7 +172,8 @@ static int gpio_mcux_lpc_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mcux_lpc_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_mcux_lpc_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct gpio_mcux_lpc_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -180,7 +185,7 @@ static int gpio_mcux_lpc_port_toggle_bits(struct device *dev, uint32_t mask) static void gpio_mcux_lpc_port_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_mcux_lpc_config *config = dev->config; struct gpio_mcux_lpc_data *data = dev->data; uint32_t enabled_int; @@ -249,9 +254,10 @@ static uint32_t attach_pin_to_isr(uint32_t port, uint32_t pin, uint32_t isr_no) static void gpio_mcux_lpc_port_isr(void *arg); -static int gpio_mcux_lpc_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_mcux_lpc_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_mcux_lpc_config *config = dev->config; struct gpio_mcux_lpc_data *data = dev->data; @@ -316,7 +322,7 @@ static int gpio_mcux_lpc_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_mcux_lpc_manage_cb(struct device *port, +static int gpio_mcux_lpc_manage_cb(const struct device *port, struct gpio_callback *callback, bool set) { struct gpio_mcux_lpc_data *data = port->data; @@ -324,7 +330,7 @@ static int gpio_mcux_lpc_manage_cb(struct device *port, return gpio_manage_callback(&data->callbacks, callback, set); } -static int gpio_mcux_lpc_init(struct device *dev) +static int gpio_mcux_lpc_init(const struct device *dev) { const struct gpio_mcux_lpc_config *config = dev->config; struct gpio_mcux_lpc_data *data = dev->data; @@ -355,7 +361,7 @@ static const struct gpio_driver_api gpio_mcux_lpc_driver_api = { static const clock_ip_name_t gpio_clock_names[] = GPIO_CLOCKS; #ifdef CONFIG_GPIO_MCUX_LPC_PORT0 -static int lpc_gpio_0_init(struct device *dev); +static int lpc_gpio_0_init(const struct device *dev); static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port0_config = { .common = { @@ -380,7 +386,7 @@ DEVICE_AND_API_INIT(gpio_mcux_lpc_port0, DT_INST_LABEL(0), CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &gpio_mcux_lpc_driver_api); -static int lpc_gpio_0_init(struct device *dev) +static int lpc_gpio_0_init(const struct device *dev) { #if DT_INST_IRQ_HAS_IDX(0, 0) || \ DT_INST_IRQ_HAS_IDX(0, 1) || \ @@ -429,7 +435,7 @@ static int lpc_gpio_0_init(struct device *dev) #endif /* CONFIG_GPIO_MCUX_LPC_PORT0 */ #ifdef CONFIG_GPIO_MCUX_LPC_PORT1 -static int lpc_gpio_1_init(struct device *dev); +static int lpc_gpio_1_init(const struct device *dev); static const struct gpio_mcux_lpc_config gpio_mcux_lpc_port1_config = { .common = { @@ -454,7 +460,7 @@ DEVICE_AND_API_INIT(gpio_mcux_lpc_port1, DT_INST_LABEL(1), CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &gpio_mcux_lpc_driver_api); -static int lpc_gpio_1_init(struct device *dev) +static int lpc_gpio_1_init(const struct device *dev) { #if DT_INST_IRQ_HAS_IDX(1, 0) || \ DT_INST_IRQ_HAS_IDX(1, 1) || \ diff --git a/drivers/gpio/gpio_mmio32.c b/drivers/gpio/gpio_mmio32.c index bfc0058fd049bd..250f2c4950cade 100644 --- a/drivers/gpio/gpio_mmio32.c +++ b/drivers/gpio/gpio_mmio32.c @@ -29,7 +29,7 @@ #include #include -static int gpio_mmio32_config(struct device *dev, +static int gpio_mmio32_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { struct gpio_mmio32_context *context = dev->data; @@ -62,7 +62,7 @@ static int gpio_mmio32_config(struct device *dev, return 0; } -static int gpio_mmio32_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_mmio32_port_get_raw(const struct device *dev, uint32_t *value) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = context->config; @@ -72,8 +72,9 @@ static int gpio_mmio32_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_mmio32_port_set_masked_raw(struct device *dev, uint32_t mask, - uint32_t value) +static int gpio_mmio32_port_set_masked_raw(const struct device *dev, + uint32_t mask, + uint32_t value) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = context->config; @@ -91,7 +92,8 @@ static int gpio_mmio32_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_mmio32_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mmio32_port_set_bits_raw(const struct device *dev, + uint32_t mask) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = context->config; @@ -108,7 +110,8 @@ static int gpio_mmio32_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mmio32_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_mmio32_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = context->config; @@ -125,7 +128,8 @@ static int gpio_mmio32_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_mmio32_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_mmio32_port_toggle_bits(const struct device *dev, + uint32_t mask) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = context->config; @@ -142,9 +146,10 @@ static int gpio_mmio32_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_mmio32_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_mmio32_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { if (mode != GPIO_INT_MODE_DISABLED) { return -ENOTSUP; @@ -163,7 +168,7 @@ const struct gpio_driver_api gpio_mmio32_api = { .pin_interrupt_configure = gpio_mmio32_pin_interrupt_configure, }; -int gpio_mmio32_init(struct device *dev) +int gpio_mmio32_init(const struct device *dev) { struct gpio_mmio32_context *context = dev->data; const struct gpio_mmio32_config *config = dev->config; diff --git a/drivers/gpio/gpio_npcx.c b/drivers/gpio/gpio_npcx.c index a19e7cad02d634..698129101d6951 100644 --- a/drivers/gpio/gpio_npcx.c +++ b/drivers/gpio/gpio_npcx.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(gpio_npcx, LOG_LEVEL_ERR); /* GPIO module instances declarations */ -static struct device *gpio_devs[]; +static const struct device *gpio_devs[]; static int gpio_devs_count; /* Driver config */ @@ -51,7 +51,7 @@ struct gpio_npcx_data { /* Soc specific GPIO functions */ -struct device *soc_get_gpio_dev(int port) +const struct device *soc_get_gpio_dev(int port) { if (port >= gpio_devs_count) return NULL; @@ -60,7 +60,7 @@ struct device *soc_get_gpio_dev(int port) } /* GPIO api functions */ -static int gpio_npcx_config(struct device *dev, +static int gpio_npcx_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { struct gpio_reg *inst = HAL_INSTANCE(dev); @@ -116,7 +116,8 @@ static int gpio_npcx_config(struct device *dev, return 0; } -static int gpio_npcx_port_get_raw(struct device *dev, gpio_port_value_t *value) +static int gpio_npcx_port_get_raw(const struct device *dev, + gpio_port_value_t *value) { struct gpio_reg *inst = HAL_INSTANCE(dev); @@ -126,7 +127,7 @@ static int gpio_npcx_port_get_raw(struct device *dev, gpio_port_value_t *value) return 0; } -static int gpio_npcx_port_set_masked_raw(struct device *dev, +static int gpio_npcx_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -138,7 +139,7 @@ static int gpio_npcx_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_npcx_port_set_bits_raw(struct device *dev, +static int gpio_npcx_port_set_bits_raw(const struct device *dev, gpio_port_value_t mask) { struct gpio_reg *inst = HAL_INSTANCE(dev); @@ -149,7 +150,7 @@ static int gpio_npcx_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_npcx_port_clear_bits_raw(struct device *dev, +static int gpio_npcx_port_clear_bits_raw(const struct device *dev, gpio_port_value_t mask) { struct gpio_reg *inst = HAL_INSTANCE(dev); @@ -160,7 +161,7 @@ static int gpio_npcx_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_npcx_port_toggle_bits(struct device *dev, +static int gpio_npcx_port_toggle_bits(const struct device *dev, gpio_port_value_t mask) { struct gpio_reg *inst = HAL_INSTANCE(dev); @@ -171,9 +172,10 @@ static int gpio_npcx_port_toggle_bits(struct device *dev, return 0; } -static int gpio_npcx_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_npcx_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_npcx_config *config = DRV_CONFIG(dev); enum miwu_int_mode miwu_mode = NPCX_MIWU_MODE_DISABLED; @@ -217,7 +219,7 @@ static int gpio_npcx_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_npcx_manage_callback(struct device *dev, +static int gpio_npcx_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { const struct gpio_npcx_config *config = DRV_CONFIG(dev); @@ -255,7 +257,7 @@ static const struct gpio_driver_api gpio_npcx_driver = { .manage_callback = gpio_npcx_manage_callback, }; -int gpio_npcx_init(struct device *dev) +int gpio_npcx_init(const struct device *dev) { ARG_UNUSED(dev); @@ -291,7 +293,7 @@ DT_INST_FOREACH_STATUS_OKAY(NPCX_GPIO_DEVICE_INIT) /* GPIO module instances */ #define NPCX_GPIO_DEV(inst) DEVICE_GET(gpio_npcx_##inst), -static struct device *gpio_devs[] = { +static const struct device *gpio_devs[] = { DT_INST_FOREACH_STATUS_OKAY(NPCX_GPIO_DEV) }; diff --git a/drivers/gpio/gpio_nrfx.c b/drivers/gpio/gpio_nrfx.c index cf06585c04f54b..bb9472c12b3d87 100644 --- a/drivers/gpio/gpio_nrfx.c +++ b/drivers/gpio/gpio_nrfx.c @@ -35,12 +35,12 @@ struct gpio_nrfx_cfg { uint8_t port_num; }; -static inline struct gpio_nrfx_data *get_port_data(struct device *port) +static inline struct gpio_nrfx_data *get_port_data(const struct device *port) { return port->data; } -static inline const struct gpio_nrfx_cfg *get_port_cfg(struct device *port) +static inline const struct gpio_nrfx_cfg *get_port_cfg(const struct device *port) { return port->config; } @@ -95,7 +95,7 @@ static inline uint32_t sense_for_pin(const struct gpio_nrfx_data *data, return NRF_GPIO_PIN_SENSE_LOW; } -static int gpiote_pin_int_cfg(struct device *port, uint32_t pin) +static int gpiote_pin_int_cfg(const struct device *port, uint32_t pin) { struct gpio_nrfx_data *data = get_port_data(port); const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); @@ -131,7 +131,7 @@ static int gpiote_pin_int_cfg(struct device *port, uint32_t pin) return res; } -static int gpio_nrfx_config(struct device *port, +static int gpio_nrfx_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; @@ -203,7 +203,7 @@ static int gpio_nrfx_config(struct device *port, return 0; } -static int gpio_nrfx_port_get_raw(struct device *port, uint32_t *value) +static int gpio_nrfx_port_get_raw(const struct device *port, uint32_t *value) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; @@ -212,7 +212,8 @@ static int gpio_nrfx_port_get_raw(struct device *port, uint32_t *value) return 0; } -static int gpio_nrfx_port_set_masked_raw(struct device *port, uint32_t mask, +static int gpio_nrfx_port_set_masked_raw(const struct device *port, + uint32_t mask, uint32_t value) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; @@ -224,7 +225,8 @@ static int gpio_nrfx_port_set_masked_raw(struct device *port, uint32_t mask, return 0; } -static int gpio_nrfx_port_set_bits_raw(struct device *port, uint32_t mask) +static int gpio_nrfx_port_set_bits_raw(const struct device *port, + uint32_t mask) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; @@ -233,7 +235,8 @@ static int gpio_nrfx_port_set_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_nrfx_port_clear_bits_raw(struct device *port, uint32_t mask) +static int gpio_nrfx_port_clear_bits_raw(const struct device *port, + uint32_t mask) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; @@ -242,7 +245,8 @@ static int gpio_nrfx_port_clear_bits_raw(struct device *port, uint32_t mask) return 0; } -static int gpio_nrfx_port_toggle_bits(struct device *port, uint32_t mask) +static int gpio_nrfx_port_toggle_bits(const struct device *port, + uint32_t mask) { NRF_GPIO_Type *reg = get_port_cfg(port)->port; uint32_t value; @@ -253,9 +257,10 @@ static int gpio_nrfx_port_toggle_bits(struct device *port, uint32_t mask) return 0; } -static int gpio_nrfx_pin_interrupt_configure(struct device *port, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_nrfx_pin_interrupt_configure(const struct device *port, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { struct gpio_nrfx_data *data = get_port_data(port); uint32_t abs_pin = NRF_GPIO_PIN_MAP(get_port_cfg(port)->port_num, pin); @@ -279,7 +284,7 @@ static int gpio_nrfx_pin_interrupt_configure(struct device *port, return gpiote_pin_int_cfg(port, pin); } -static int gpio_nrfx_manage_callback(struct device *port, +static int gpio_nrfx_manage_callback(const struct device *port, struct gpio_callback *callback, bool set) { @@ -298,7 +303,7 @@ static const struct gpio_driver_api gpio_nrfx_drv_api_funcs = { .manage_callback = gpio_nrfx_manage_callback, }; -static inline uint32_t get_level_pins(struct device *port) +static inline uint32_t get_level_pins(const struct device *port) { struct gpio_nrfx_data *data = get_port_data(port); @@ -317,7 +322,7 @@ static inline uint32_t get_level_pins(struct device *port) return out; } -static void cfg_level_pins(struct device *port) +static void cfg_level_pins(const struct device *port) { const struct gpio_nrfx_data *data = get_port_data(port); const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); @@ -346,7 +351,7 @@ static void cfg_level_pins(struct device *port) * * @return Bitmask where 1 marks pin as trigger source. */ -static uint32_t check_level_trigger_pins(struct device *port) +static uint32_t check_level_trigger_pins(const struct device *port) { struct gpio_nrfx_data *data = get_port_data(port); const struct gpio_nrfx_cfg *cfg = get_port_cfg(port); @@ -381,7 +386,7 @@ static uint32_t check_level_trigger_pins(struct device *port) return out; } -static inline void fire_callbacks(struct device *port, uint32_t pins) +static inline void fire_callbacks(const struct device *port, uint32_t pins) { struct gpio_nrfx_data *data = get_port_data(port); sys_slist_t *list = &data->callbacks; @@ -458,7 +463,7 @@ static void gpiote_event_handler(void) #define GPIOTE_NODE DT_INST(0, nordic_nrf_gpiote) -static int gpio_nrfx_init(struct device *port) +static int gpio_nrfx_init(const struct device *port) { static bool gpio_initialized; diff --git a/drivers/gpio/gpio_pca95xx.c b/drivers/gpio/gpio_pca95xx.c index 177e7904301f0a..426981a619c4b9 100644 --- a/drivers/gpio/gpio_pca95xx.c +++ b/drivers/gpio/gpio_pca95xx.c @@ -74,7 +74,7 @@ struct gpio_pca95xx_drv_data { struct gpio_driver_data common; /** Master I2C device */ - struct device *i2c_master; + const struct device *i2c_master; struct { uint16_t output; @@ -97,12 +97,13 @@ struct gpio_pca95xx_drv_data { * * @return 0 if successful, failed otherwise. */ -static int read_port_regs(struct device *dev, uint8_t reg, uint16_t *buf) +static int read_port_regs(const struct device *dev, uint8_t reg, + uint16_t *buf) { const struct gpio_pca95xx_config * const config = dev->config; struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; - struct device * const i2c_master = drv_data->i2c_master; + const struct device *i2c_master = drv_data->i2c_master; uint16_t i2c_addr = config->i2c_slave_addr; uint16_t port_data; int ret; @@ -135,13 +136,13 @@ static int read_port_regs(struct device *dev, uint8_t reg, uint16_t *buf) * * @return 0 if successful, failed otherwise. */ -static int write_port_regs(struct device *dev, uint8_t reg, +static int write_port_regs(const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t value) { const struct gpio_pca95xx_config * const config = dev->config; struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; - struct device * const i2c_master = drv_data->i2c_master; + const struct device *i2c_master = drv_data->i2c_master; uint16_t i2c_addr = config->i2c_slave_addr; uint16_t port_data; int ret; @@ -164,7 +165,7 @@ static int write_port_regs(struct device *dev, uint8_t reg, return ret; } -static inline int update_output_regs(struct device *dev, uint16_t value) +static inline int update_output_regs(const struct device *dev, uint16_t value) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -173,7 +174,8 @@ static inline int update_output_regs(struct device *dev, uint16_t value) &drv_data->reg_cache.output, value); } -static inline int update_direction_regs(struct device *dev, uint16_t value) +static inline int update_direction_regs(const struct device *dev, + uint16_t value) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -182,7 +184,8 @@ static inline int update_direction_regs(struct device *dev, uint16_t value) &drv_data->reg_cache.dir, value); } -static inline int update_pul_sel_regs(struct device *dev, uint16_t value) +static inline int update_pul_sel_regs(const struct device *dev, + uint16_t value) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -191,7 +194,7 @@ static inline int update_pul_sel_regs(struct device *dev, uint16_t value) &drv_data->reg_cache.pud_sel, value); } -static inline int update_pul_en_regs(struct device *dev, uint16_t value) +static inline int update_pul_en_regs(const struct device *dev, uint16_t value) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -209,7 +212,7 @@ static inline int update_pul_en_regs(struct device *dev, uint16_t value) * * @return 0 if successful, failed otherwise */ -static int setup_pin_dir(struct device *dev, uint32_t pin, int flags) +static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -248,7 +251,8 @@ static int setup_pin_dir(struct device *dev, uint32_t pin, int flags) * * @return 0 if successful, failed otherwise */ -static int setup_pin_pullupdown(struct device *dev, uint32_t pin, int flags) +static int setup_pin_pullupdown(const struct device *dev, uint32_t pin, + int flags) { const struct gpio_pca95xx_config * const config = dev->config; struct gpio_pca95xx_drv_data * const drv_data = @@ -305,7 +309,7 @@ static int setup_pin_pullupdown(struct device *dev, uint32_t pin, int flags) * * @return 0 if successful, failed otherwise */ -static int gpio_pca95xx_config(struct device *dev, +static int gpio_pca95xx_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { int ret; @@ -355,7 +359,8 @@ static int gpio_pca95xx_config(struct device *dev, return ret; } -static int gpio_pca95xx_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_pca95xx_port_get_raw(const struct device *dev, + uint32_t *value) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -381,7 +386,7 @@ static int gpio_pca95xx_port_get_raw(struct device *dev, uint32_t *value) return ret; } -static int gpio_pca95xx_port_set_masked_raw(struct device *dev, +static int gpio_pca95xx_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value) { struct gpio_pca95xx_drv_data * const drv_data = @@ -406,17 +411,20 @@ static int gpio_pca95xx_port_set_masked_raw(struct device *dev, return ret; } -static int gpio_pca95xx_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_pca95xx_port_set_bits_raw(const struct device *dev, + uint32_t mask) { return gpio_pca95xx_port_set_masked_raw(dev, mask, mask); } -static int gpio_pca95xx_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_pca95xx_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { return gpio_pca95xx_port_set_masked_raw(dev, mask, 0); } -static int gpio_pca95xx_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_pca95xx_port_toggle_bits(const struct device *dev, + uint32_t mask) { struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; @@ -440,7 +448,7 @@ static int gpio_pca95xx_port_toggle_bits(struct device *dev, uint32_t mask) return ret; } -static int gpio_pca95xx_pin_interrupt_configure(struct device *dev, +static int gpio_pca95xx_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -464,12 +472,12 @@ static const struct gpio_driver_api gpio_pca95xx_drv_api_funcs = { * @param dev Device struct * @return 0 if successful, failed otherwise. */ -static int gpio_pca95xx_init(struct device *dev) +static int gpio_pca95xx_init(const struct device *dev) { const struct gpio_pca95xx_config * const config = dev->config; struct gpio_pca95xx_drv_data * const drv_data = (struct gpio_pca95xx_drv_data * const)dev->data; - struct device *i2c_master; + const struct device *i2c_master; /* Find out the device struct of the I2C master */ i2c_master = device_get_binding((char *)config->i2c_master_dev_name); diff --git a/drivers/gpio/gpio_rv32m1.c b/drivers/gpio/gpio_rv32m1.c index a230c7207e44c2..2eb5bb616975d4 100644 --- a/drivers/gpio/gpio_rv32m1.c +++ b/drivers/gpio/gpio_rv32m1.c @@ -26,7 +26,7 @@ struct gpio_rv32m1_config { unsigned int flags; char *clock_controller; clock_control_subsys_t clock_subsys; - int (*irq_config_func)(struct device *dev); + int (*irq_config_func)(const struct device *dev); }; struct gpio_rv32m1_data { @@ -36,9 +36,10 @@ struct gpio_rv32m1_data { sys_slist_t callbacks; }; -static uint32_t get_port_pcr_irqc_value_from_flags(struct device *dev, - uint32_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static uint32_t get_port_pcr_irqc_value_from_flags(const struct device *dev, + uint32_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { port_interrupt_t port_interrupt = 0; @@ -69,7 +70,7 @@ static uint32_t get_port_pcr_irqc_value_from_flags(struct device *dev, return PORT_PCR_IRQC(port_interrupt); } -static int gpio_rv32m1_configure(struct device *dev, +static int gpio_rv32m1_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_rv32m1_config *config = dev->config; @@ -152,7 +153,7 @@ static int gpio_rv32m1_configure(struct device *dev, return 0; } -static int gpio_rv32m1_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_rv32m1_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_rv32m1_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -162,8 +163,9 @@ static int gpio_rv32m1_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_rv32m1_port_set_masked_raw(struct device *dev, uint32_t mask, - uint32_t value) +static int gpio_rv32m1_port_set_masked_raw(const struct device *dev, + uint32_t mask, + uint32_t value) { const struct gpio_rv32m1_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -173,7 +175,8 @@ static int gpio_rv32m1_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_rv32m1_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_rv32m1_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_rv32m1_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -183,7 +186,8 @@ static int gpio_rv32m1_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_rv32m1_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_rv32m1_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_rv32m1_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -193,7 +197,8 @@ static int gpio_rv32m1_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_rv32m1_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_rv32m1_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct gpio_rv32m1_config *config = dev->config; GPIO_Type *gpio_base = config->gpio_base; @@ -203,9 +208,10 @@ static int gpio_rv32m1_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_rv32m1_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_rv32m1_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_rv32m1_config *config = dev->config; PORT_Type *port_base = config->port_base; @@ -229,8 +235,9 @@ static int gpio_rv32m1_pin_interrupt_configure(struct device *dev, } -static int gpio_rv32m1_manage_callback(struct device *dev, - struct gpio_callback *callback, bool set) +static int gpio_rv32m1_manage_callback(const struct device *dev, + struct gpio_callback *callback, + bool set) { struct gpio_rv32m1_data *data = dev->data; @@ -241,7 +248,7 @@ static int gpio_rv32m1_manage_callback(struct device *dev, static void gpio_rv32m1_port_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_rv32m1_config *config = dev->config; struct gpio_rv32m1_data *data = dev->data; uint32_t int_status; @@ -254,10 +261,10 @@ static void gpio_rv32m1_port_isr(void *arg) gpio_fire_callbacks(&data->callbacks, dev, int_status); } -static int gpio_rv32m1_init(struct device *dev) +static int gpio_rv32m1_init(const struct device *dev) { const struct gpio_rv32m1_config *config = dev->config; - struct device *clk; + const struct device *clk; int ret; if (config->clock_controller) { diff --git a/drivers/gpio/gpio_sam.c b/drivers/gpio/gpio_sam.c index ce63eb11469ee1..eee71ea185abd4 100644 --- a/drivers/gpio/gpio_sam.c +++ b/drivers/gpio/gpio_sam.c @@ -15,7 +15,7 @@ #include "gpio_utils.h" -typedef void (*config_func_t)(struct device *dev); +typedef void (*config_func_t)(const struct device *dev); struct gpio_sam_config { /* gpio_driver_config needs to be first */ @@ -38,7 +38,7 @@ struct gpio_sam_runtime { #define GPIO_SAM_ALL_PINS 0xFFFFFFFF -static int gpio_sam_port_configure(struct device *dev, uint32_t mask, +static int gpio_sam_port_configure(const struct device *dev, uint32_t mask, gpio_flags_t flags) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); @@ -145,13 +145,13 @@ static int gpio_sam_port_configure(struct device *dev, uint32_t mask, return 0; } -static int gpio_sam_config(struct device *dev, gpio_pin_t pin, +static int gpio_sam_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { return gpio_sam_port_configure(dev, BIT(pin), flags); } -static int gpio_sam_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_sam_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); Pio * const pio = cfg->regs; @@ -161,7 +161,8 @@ static int gpio_sam_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_sam_port_set_masked_raw(struct device *dev, uint32_t mask, +static int gpio_sam_port_set_masked_raw(const struct device *dev, + uint32_t mask, uint32_t value) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); @@ -172,7 +173,7 @@ static int gpio_sam_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_sam_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_sam_port_set_bits_raw(const struct device *dev, uint32_t mask) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); Pio * const pio = cfg->regs; @@ -183,7 +184,8 @@ static int gpio_sam_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_sam_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_sam_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); Pio * const pio = cfg->regs; @@ -194,7 +196,7 @@ static int gpio_sam_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_sam_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_sam_port_toggle_bits(const struct device *dev, uint32_t mask) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); Pio * const pio = cfg->regs; @@ -205,7 +207,8 @@ static int gpio_sam_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_sam_port_interrupt_configure(struct device *dev, uint32_t mask, +static int gpio_sam_port_interrupt_configure(const struct device *dev, + uint32_t mask, enum gpio_int_mode mode, enum gpio_int_trig trig) { @@ -253,16 +256,17 @@ static int gpio_sam_port_interrupt_configure(struct device *dev, uint32_t mask, return 0; } -static int gpio_sam_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_sam_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { return gpio_sam_port_interrupt_configure(dev, BIT(pin), mode, trig); } static void gpio_sam_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_sam_config * const cfg = DEV_CFG(dev); Pio * const pio = cfg->regs; struct gpio_sam_runtime *context = dev->data; @@ -273,7 +277,7 @@ static void gpio_sam_isr(void *arg) gpio_fire_callbacks(&context->cb, dev, int_stat); } -static int gpio_sam_manage_callback(struct device *port, +static int gpio_sam_manage_callback(const struct device *port, struct gpio_callback *callback, bool set) { @@ -293,7 +297,7 @@ static const struct gpio_driver_api gpio_sam_api = { .manage_callback = gpio_sam_manage_callback, }; -int gpio_sam_init(struct device *dev) +int gpio_sam_init(const struct device *dev) { const struct gpio_sam_config * const cfg = DEV_CFG(dev); diff --git a/drivers/gpio/gpio_sam0.c b/drivers/gpio/gpio_sam0.c index 58144ea4a24205..fbccad1101472d 100644 --- a/drivers/gpio/gpio_sam0.c +++ b/drivers/gpio/gpio_sam0.c @@ -45,14 +45,14 @@ struct gpio_sam0_data { #ifdef CONFIG_SAM0_EIC static void gpio_sam0_isr(uint32_t pins, void *arg) { - struct device *const dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; struct gpio_sam0_data *const data = DEV_DATA(dev); gpio_fire_callbacks(&data->callbacks, dev, pins); } #endif -static int gpio_sam0_config(struct device *dev, gpio_pin_t pin, +static int gpio_sam0_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -107,7 +107,7 @@ static int gpio_sam0_config(struct device *dev, gpio_pin_t pin, return 0; } -static int gpio_sam0_port_get_raw(struct device *dev, +static int gpio_sam0_port_get_raw(const struct device *dev, gpio_port_value_t *value) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -117,7 +117,7 @@ static int gpio_sam0_port_get_raw(struct device *dev, return 0; } -static int gpio_sam0_port_set_masked_raw(struct device *dev, +static int gpio_sam0_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -129,7 +129,7 @@ static int gpio_sam0_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_sam0_port_set_bits_raw(struct device *dev, +static int gpio_sam0_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -139,7 +139,7 @@ static int gpio_sam0_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_sam0_port_clear_bits_raw(struct device *dev, +static int gpio_sam0_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -149,7 +149,7 @@ static int gpio_sam0_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_sam0_port_toggle_bits(struct device *dev, +static int gpio_sam0_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -161,7 +161,7 @@ static int gpio_sam0_port_toggle_bits(struct device *dev, #ifdef CONFIG_SAM0_EIC -static int gpio_sam0_pin_interrupt_configure(struct device *dev, +static int gpio_sam0_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -252,15 +252,15 @@ static int gpio_sam0_pin_interrupt_configure(struct device *dev, } -static int gpio_sam0_manage_callback(struct device *dev, - struct gpio_callback *callback, bool set) +static int gpio_sam0_manage_callback(const struct device *dev, + struct gpio_callback *callback, bool set) { struct gpio_sam0_data *const data = DEV_DATA(dev); return gpio_manage_callback(&data->callbacks, callback, set); } -static uint32_t gpio_sam0_get_pending_int(struct device *dev) +static uint32_t gpio_sam0_get_pending_int(const struct device *dev) { const struct gpio_sam0_config *config = DEV_CFG(dev); @@ -283,7 +283,7 @@ static const struct gpio_driver_api gpio_sam0_api = { #endif }; -static int gpio_sam0_init(struct device *dev) { return 0; } +static int gpio_sam0_init(const struct device *dev) { return 0; } /* Port A */ #if DT_NODE_HAS_STATUS(DT_NODELABEL(porta), okay) diff --git a/drivers/gpio/gpio_shell.c b/drivers/gpio/gpio_shell.c index 05468a2525f200..e0b65768f55f93 100644 --- a/drivers/gpio/gpio_shell.c +++ b/drivers/gpio/gpio_shell.c @@ -50,7 +50,7 @@ static int cmd_gpio_conf(const struct shell *shell, size_t argc, char **argv) { uint8_t index = 0U; int type = GPIO_OUTPUT; - struct device *dev; + const struct device *dev; if (argc == args_no.conf && isdigit((unsigned char)argv[args_indx.index][0]) && @@ -83,7 +83,7 @@ static int cmd_gpio_conf(const struct shell *shell, size_t argc, char **argv) static int cmd_gpio_get(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint8_t index = 0U; int rc; @@ -115,7 +115,7 @@ static int cmd_gpio_get(const struct shell *shell, static int cmd_gpio_set(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint8_t index = 0U; uint8_t value = 0U; diff --git a/drivers/gpio/gpio_sifive.c b/drivers/gpio/gpio_sifive.c index 8c232aca0aefa5..741d2a97e79114 100644 --- a/drivers/gpio/gpio_sifive.c +++ b/drivers/gpio/gpio_sifive.c @@ -114,7 +114,7 @@ static inline int gpio_sifive_plic_to_pin(unsigned int base_irq, int plic_irq) static void gpio_sifive_irq_handler(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct gpio_sifive_data *data = DEV_GPIO_DATA(dev); volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev); @@ -153,7 +153,7 @@ static void gpio_sifive_irq_handler(void *arg) * * @return 0 if successful, failed otherwise */ -static int gpio_sifive_config(struct device *dev, +static int gpio_sifive_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { @@ -193,8 +193,8 @@ static int gpio_sifive_config(struct device *dev, return 0; } -static int gpio_sifive_port_get_raw(struct device *dev, - gpio_port_value_t *value) +static int gpio_sifive_port_get_raw(const struct device *dev, + gpio_port_value_t *value) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); @@ -203,9 +203,9 @@ static int gpio_sifive_port_get_raw(struct device *dev, return 0; } -static int gpio_sifive_port_set_masked_raw(struct device *dev, - gpio_port_pins_t mask, - gpio_port_value_t value) +static int gpio_sifive_port_set_masked_raw(const struct device *dev, + gpio_port_pins_t mask, + gpio_port_value_t value) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); @@ -214,8 +214,8 @@ static int gpio_sifive_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_sifive_port_set_bits_raw(struct device *dev, - gpio_port_pins_t mask) +static int gpio_sifive_port_set_bits_raw(const struct device *dev, + gpio_port_pins_t mask) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); @@ -224,8 +224,8 @@ static int gpio_sifive_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_sifive_port_clear_bits_raw(struct device *dev, - gpio_port_pins_t mask) +static int gpio_sifive_port_clear_bits_raw(const struct device *dev, + gpio_port_pins_t mask) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); @@ -234,8 +234,8 @@ static int gpio_sifive_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_sifive_port_toggle_bits(struct device *dev, - gpio_port_pins_t mask) +static int gpio_sifive_port_toggle_bits(const struct device *dev, + gpio_port_pins_t mask) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); @@ -244,10 +244,10 @@ static int gpio_sifive_port_toggle_bits(struct device *dev, return 0; } -static int gpio_sifive_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, - enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_sifive_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev); @@ -295,9 +295,9 @@ static int gpio_sifive_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_sifive_manage_callback(struct device *dev, - struct gpio_callback *callback, - bool set) +static int gpio_sifive_manage_callback(const struct device *dev, + struct gpio_callback *callback, + bool set) { struct gpio_sifive_data *data = DEV_GPIO_DATA(dev); @@ -324,7 +324,7 @@ static const struct gpio_driver_api gpio_sifive_driver = { * * @return 0 */ -static int gpio_sifive_init(struct device *dev) +static int gpio_sifive_init(const struct device *dev) { volatile struct gpio_sifive_t *gpio = DEV_GPIO(dev); const struct gpio_sifive_config *cfg = DEV_GPIO_CFG(dev); diff --git a/drivers/gpio/gpio_stellaris.c b/drivers/gpio/gpio_stellaris.c index fd5c0a865c9413..2afca28120a4a6 100644 --- a/drivers/gpio/gpio_stellaris.c +++ b/drivers/gpio/gpio_stellaris.c @@ -13,7 +13,7 @@ #include #include "gpio_utils.h" -typedef void (*config_func_t)(struct device *dev); +typedef void (*config_func_t)(const struct device *dev); struct gpio_stellaris_config { /* gpio_driver_config needs to be first */ @@ -59,7 +59,7 @@ enum gpio_regs { static void gpio_stellaris_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct gpio_stellaris_config * const cfg = DEV_CFG(dev); struct gpio_stellaris_runtime *context = DEV_DATA(dev); uint32_t base = cfg->base; @@ -70,7 +70,7 @@ static void gpio_stellaris_isr(void *arg) sys_write32(int_stat, GPIO_REG_ADDR(base, GPIO_ICR_OFFSET)); } -static int gpio_stellaris_configure(struct device *dev, +static int gpio_stellaris_configure(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); @@ -114,7 +114,8 @@ static int gpio_stellaris_configure(struct device *dev, return 0; } -static int gpio_stellaris_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_stellaris_port_get_raw(const struct device *dev, + uint32_t *value) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -124,8 +125,9 @@ static int gpio_stellaris_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_stellaris_port_set_masked_raw(struct device *dev, uint32_t mask, - uint32_t value) +static int gpio_stellaris_port_set_masked_raw(const struct device *dev, + uint32_t mask, + uint32_t value) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -135,7 +137,8 @@ static int gpio_stellaris_port_set_masked_raw(struct device *dev, uint32_t mask, return 0; } -static int gpio_stellaris_port_set_bits_raw(struct device *dev, uint32_t mask) +static int gpio_stellaris_port_set_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -145,7 +148,8 @@ static int gpio_stellaris_port_set_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_stellaris_port_clear_bits_raw(struct device *dev, uint32_t mask) +static int gpio_stellaris_port_clear_bits_raw(const struct device *dev, + uint32_t mask) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -155,7 +159,8 @@ static int gpio_stellaris_port_clear_bits_raw(struct device *dev, uint32_t mask) return 0; } -static int gpio_stellaris_port_toggle_bits(struct device *dev, uint32_t mask) +static int gpio_stellaris_port_toggle_bits(const struct device *dev, + uint32_t mask) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -168,9 +173,10 @@ static int gpio_stellaris_port_toggle_bits(struct device *dev, uint32_t mask) return 0; } -static int gpio_stellaris_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_stellaris_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); uint32_t base = cfg->base; @@ -201,7 +207,7 @@ static int gpio_stellaris_pin_interrupt_configure(struct device *dev, return 0; } -static int gpio_stellaris_init(struct device *dev) +static int gpio_stellaris_init(const struct device *dev) { const struct gpio_stellaris_config *cfg = DEV_CFG(dev); @@ -209,7 +215,7 @@ static int gpio_stellaris_init(struct device *dev) return 0; } -static int gpio_stellaris_manage_callback(struct device *dev, +static int gpio_stellaris_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { diff --git a/drivers/gpio/gpio_stm32.c b/drivers/gpio/gpio_stm32.c index 756ce430520ae7..664a9728d4250e 100644 --- a/drivers/gpio/gpio_stm32.c +++ b/drivers/gpio/gpio_stm32.c @@ -31,7 +31,7 @@ */ static void gpio_stm32_isr(int line, void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct gpio_stm32_data *data = dev->data; gpio_fire_callbacks(&data->cb, dev, BIT(line)); @@ -294,7 +294,7 @@ static int gpio_stm32_enable_int(int port, int pin) defined(CONFIG_SOC_SERIES_STM32L1X) || \ defined(CONFIG_SOC_SERIES_STM32L4X) || \ defined(CONFIG_SOC_SERIES_STM32G4X) - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); struct stm32_pclken pclken = { #ifdef CONFIG_SOC_SERIES_STM32H7X .bus = STM32_CLOCK_BUS_APB4, @@ -313,7 +313,7 @@ static int gpio_stm32_enable_int(int port, int pin) return 0; } -static int gpio_stm32_port_get_raw(struct device *dev, uint32_t *value) +static int gpio_stm32_port_get_raw(const struct device *dev, uint32_t *value) { const struct gpio_stm32_config *cfg = dev->config; GPIO_TypeDef *gpio = (GPIO_TypeDef *)cfg->base; @@ -323,7 +323,7 @@ static int gpio_stm32_port_get_raw(struct device *dev, uint32_t *value) return 0; } -static int gpio_stm32_port_set_masked_raw(struct device *dev, +static int gpio_stm32_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -341,7 +341,7 @@ static int gpio_stm32_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_stm32_port_set_bits_raw(struct device *dev, +static int gpio_stm32_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_stm32_config *cfg = dev->config; @@ -356,7 +356,7 @@ static int gpio_stm32_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_stm32_port_clear_bits_raw(struct device *dev, +static int gpio_stm32_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_stm32_config *cfg = dev->config; @@ -376,7 +376,7 @@ static int gpio_stm32_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_stm32_port_toggle_bits(struct device *dev, +static int gpio_stm32_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { const struct gpio_stm32_config *cfg = dev->config; @@ -396,7 +396,7 @@ static int gpio_stm32_port_toggle_bits(struct device *dev, /** * @brief Configure pin or port */ -static int gpio_stm32_config(struct device *dev, +static int gpio_stm32_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_stm32_config *cfg = dev->config; @@ -425,9 +425,10 @@ static int gpio_stm32_config(struct device *dev, return err; } -static int gpio_stm32_pin_interrupt_configure(struct device *dev, - gpio_pin_t pin, enum gpio_int_mode mode, - enum gpio_int_trig trig) +static int gpio_stm32_pin_interrupt_configure(const struct device *dev, + gpio_pin_t pin, + enum gpio_int_mode mode, + enum gpio_int_trig trig) { const struct gpio_stm32_config *cfg = dev->config; int edge = 0; @@ -476,7 +477,7 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev, return err; } -static int gpio_stm32_manage_callback(struct device *dev, +static int gpio_stm32_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { @@ -506,12 +507,12 @@ static const struct gpio_driver_api gpio_stm32_driver = { * * @return 0 */ -static int gpio_stm32_init(struct device *device) +static int gpio_stm32_init(const struct device *device) { const struct gpio_stm32_config *cfg = device->config; /* enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); if (clock_control_on(clk, @@ -612,7 +613,7 @@ GPIO_DEVICE_INIT_STM32(k, K); #if defined(CONFIG_SOC_SERIES_STM32F1X) -static int gpio_stm32_afio_init(struct device *device) +static int gpio_stm32_afio_init(const struct device *device) { UNUSED(device); diff --git a/drivers/gpio/gpio_sx1509b.c b/drivers/gpio/gpio_sx1509b.c index 87219b7d200955..12ffd253c839c1 100644 --- a/drivers/gpio/gpio_sx1509b.c +++ b/drivers/gpio/gpio_sx1509b.c @@ -60,17 +60,17 @@ struct sx1509b_debounce_state { struct sx1509b_drv_data { /* gpio_driver_data needs to be first */ struct gpio_driver_data common; - struct device *i2c_master; + const struct device *i2c_master; struct sx1509b_pin_state pin_state; struct sx1509b_debounce_state debounce_state; struct k_sem lock; #ifdef CONFIG_GPIO_SX1509B_INTERRUPT - struct device *gpio_int; + const struct device *gpio_int; struct gpio_callback gpio_cb; struct k_work work; struct sx1509b_irq_state irq_state; - struct device *dev; + const struct device *dev; /* user ISR cb */ sys_slist_t cb; #endif /* CONFIG_GPIO_SX1509B_INTERRUPT */ @@ -146,7 +146,8 @@ enum { * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_reg_write_word_be(struct device *dev, uint16_t dev_addr, +static inline int i2c_reg_write_word_be(const struct device *dev, + uint16_t dev_addr, uint8_t reg_addr, uint16_t value) { uint8_t tx_buf[3] = { reg_addr, value >> 8, value & 0xff }; @@ -165,7 +166,8 @@ static inline int i2c_reg_write_word_be(struct device *dev, uint16_t dev_addr, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_reg_write_byte_be(struct device *dev, uint16_t dev_addr, +static inline int i2c_reg_write_byte_be(const struct device *dev, + uint16_t dev_addr, uint8_t reg_addr, uint8_t value) { uint8_t tx_buf[3] = { reg_addr, value }; @@ -176,7 +178,7 @@ static inline int i2c_reg_write_byte_be(struct device *dev, uint16_t dev_addr, #ifdef CONFIG_GPIO_SX1509B_INTERRUPT static int sx1509b_handle_interrupt(void *arg) { - struct device *dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; const struct sx1509b_config *cfg = dev->config; struct sx1509b_drv_data *drv_data = dev->data; int ret = 0; @@ -216,7 +218,8 @@ static void sx1509b_work_handler(struct k_work *work) sx1509b_handle_interrupt(drv_data->dev); } -static void sx1509_int_cb(struct device *dev, struct gpio_callback *gpio_cb, +static void sx1509_int_cb(const struct device *dev, + struct gpio_callback *gpio_cb, uint32_t pins) { struct sx1509b_drv_data *drv_data = CONTAINER_OF(gpio_cb, @@ -228,7 +231,7 @@ static void sx1509_int_cb(struct device *dev, struct gpio_callback *gpio_cb, } #endif -static int sx1509b_config(struct device *dev, +static int sx1509b_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { @@ -367,7 +370,7 @@ static int sx1509b_config(struct device *dev, return rc; } -static int port_get(struct device *dev, +static int port_get(const struct device *dev, gpio_port_value_t *value) { const struct sx1509b_config *cfg = dev->config; @@ -399,7 +402,7 @@ static int port_get(struct device *dev, return rc; } -static int port_write(struct device *dev, +static int port_write(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value, gpio_port_value_t toggle) @@ -430,32 +433,32 @@ static int port_write(struct device *dev, return rc; } -static int port_set_masked(struct device *dev, +static int port_set_masked(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { return port_write(dev, mask, value, 0); } -static int port_set_bits(struct device *dev, +static int port_set_bits(const struct device *dev, gpio_port_pins_t pins) { return port_write(dev, pins, pins, 0); } -static int port_clear_bits(struct device *dev, +static int port_clear_bits(const struct device *dev, gpio_port_pins_t pins) { return port_write(dev, pins, 0, 0); } -static int port_toggle_bits(struct device *dev, +static int port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { return port_write(dev, 0, 0, pins); } -static int pin_interrupt_configure(struct device *dev, +static int pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -530,7 +533,7 @@ static int pin_interrupt_configure(struct device *dev, * @param dev Device struct * @return 0 if successful, failed otherwise. */ -static int sx1509b_init(struct device *dev) +static int sx1509b_init(const struct device *dev) { const struct sx1509b_config *cfg = dev->config; struct sx1509b_drv_data *drv_data = dev->data; @@ -624,7 +627,7 @@ static int sx1509b_init(struct device *dev) } #ifdef CONFIG_GPIO_SX1509B_INTERRUPT -static int gpio_sx1509b_manage_callback(struct device *dev, +static int gpio_sx1509b_manage_callback(const struct device *dev, struct gpio_callback *callback, bool set) { diff --git a/drivers/gpio/gpio_utils.h b/drivers/gpio/gpio_utils.h index 3eea00237ff94c..94cc6b186aac84 100644 --- a/drivers/gpio/gpio_utils.h +++ b/drivers/gpio/gpio_utils.h @@ -59,7 +59,7 @@ static inline int gpio_manage_callback(sys_slist_t *callbacks, * @param pins The actual pin mask that triggered the interrupt */ static inline void gpio_fire_callbacks(sys_slist_t *list, - struct device *port, + const struct device *port, uint32_t pins) { struct gpio_callback *cb, *tmp; diff --git a/drivers/gpio/gpio_xlnx_axi.c b/drivers/gpio/gpio_xlnx_axi.c index cd72cba20ac15b..6ea51815b25238 100644 --- a/drivers/gpio/gpio_xlnx_axi.c +++ b/drivers/gpio/gpio_xlnx_axi.c @@ -47,28 +47,31 @@ struct gpio_xlnx_axi_data { uint32_t tri; }; -static inline uint32_t gpio_xlnx_axi_read_data(struct device *dev) +static inline uint32_t gpio_xlnx_axi_read_data(const struct device *dev) { const struct gpio_xlnx_axi_config *config = dev->config; return sys_read32(config->base + GPIO_DATA_OFFSET); } -static inline void gpio_xlnx_axi_write_data(struct device *dev, uint32_t val) +static inline void gpio_xlnx_axi_write_data(const struct device *dev, + uint32_t val) { const struct gpio_xlnx_axi_config *config = dev->config; sys_write32(val, config->base + GPIO_DATA_OFFSET); } -static inline void gpio_xlnx_axi_write_tri(struct device *dev, uint32_t val) +static inline void gpio_xlnx_axi_write_tri(const struct device *dev, + uint32_t val) { const struct gpio_xlnx_axi_config *config = dev->config; sys_write32(val, config->base + GPIO_TRI_OFFSET); } -static int gpio_xlnx_axi_pin_configure(struct device *dev, gpio_pin_t pin, +static int gpio_xlnx_axi_pin_configure(const struct device *dev, + gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_xlnx_axi_config *config = dev->config; @@ -125,14 +128,14 @@ static int gpio_xlnx_axi_pin_configure(struct device *dev, gpio_pin_t pin, return 0; } -static int gpio_xlnx_axi_port_get_raw(struct device *dev, +static int gpio_xlnx_axi_port_get_raw(const struct device *dev, gpio_port_value_t *value) { *value = gpio_xlnx_axi_read_data(dev); return 0; } -static int gpio_xlnx_axi_port_set_masked_raw(struct device *dev, +static int gpio_xlnx_axi_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value) { @@ -147,7 +150,7 @@ static int gpio_xlnx_axi_port_set_masked_raw(struct device *dev, return 0; } -static int gpio_xlnx_axi_port_set_bits_raw(struct device *dev, +static int gpio_xlnx_axi_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins) { struct gpio_xlnx_axi_data *data = dev->data; @@ -161,7 +164,7 @@ static int gpio_xlnx_axi_port_set_bits_raw(struct device *dev, return 0; } -static int gpio_xlnx_axi_port_clear_bits_raw(struct device *dev, +static int gpio_xlnx_axi_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins) { struct gpio_xlnx_axi_data *data = dev->data; @@ -175,7 +178,7 @@ static int gpio_xlnx_axi_port_clear_bits_raw(struct device *dev, return 0; } -static int gpio_xlnx_axi_port_toggle_bits(struct device *dev, +static int gpio_xlnx_axi_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins) { struct gpio_xlnx_axi_data *data = dev->data; @@ -189,7 +192,7 @@ static int gpio_xlnx_axi_port_toggle_bits(struct device *dev, return 0; } -static int gpio_xlnx_axi_pin_interrupt_configure(struct device *dev, +static int gpio_xlnx_axi_pin_interrupt_configure(const struct device *dev, gpio_pin_t pin, enum gpio_int_mode mode, enum gpio_int_trig trig) @@ -206,7 +209,7 @@ static int gpio_xlnx_axi_pin_interrupt_configure(struct device *dev, return -ENOTSUP; } -static int gpio_xlnx_axi_manage_callback(struct device *dev, +static int gpio_xlnx_axi_manage_callback(const struct device *dev, struct gpio_callback *cb, bool set) { @@ -217,12 +220,12 @@ static int gpio_xlnx_axi_manage_callback(struct device *dev, return -ENOTSUP; } -static uint32_t gpio_xlnx_axi_get_pending_int(struct device *dev) +static uint32_t gpio_xlnx_axi_get_pending_int(const struct device *dev) { return 0; } -static int gpio_xlnx_axi_init(struct device *dev) +static int gpio_xlnx_axi_init(const struct device *dev) { struct gpio_xlnx_axi_data *data = dev->data; diff --git a/drivers/hwinfo/hwinfo_sam.c b/drivers/hwinfo/hwinfo_sam.c index 8e3f95320caea6..fc46c5d2b093c7 100644 --- a/drivers/hwinfo/hwinfo_sam.c +++ b/drivers/hwinfo/hwinfo_sam.c @@ -62,7 +62,7 @@ __ramfunc static void hwinfo_sam_read_device_id(void) } } -static int hwinfo_sam_init(struct device *arg) +static int hwinfo_sam_init(const struct device *arg) { Efc *efc = (Efc *)DT_REG_ADDR(DT_INST(0, atmel_sam_flash_controller)); uint32_t fmr; diff --git a/drivers/i2c/i2c_cc13xx_cc26xx.c b/drivers/i2c/i2c_cc13xx_cc26xx.c index 271ab65ba9701f..66d2f032233b3b 100644 --- a/drivers/i2c/i2c_cc13xx_cc26xx.c +++ b/drivers/i2c/i2c_cc13xx_cc26xx.c @@ -44,18 +44,19 @@ struct i2c_cc13xx_cc26xx_config { uint32_t sda_pin; }; -static inline struct i2c_cc13xx_cc26xx_data *get_dev_data(struct device *dev) +static inline struct i2c_cc13xx_cc26xx_data *get_dev_data(const struct device *dev) { return dev->data; } static inline const struct i2c_cc13xx_cc26xx_config * -get_dev_config(struct device *dev) +get_dev_config(const struct device *dev) { return dev->config; } -static int i2c_cc13xx_cc26xx_transmit(struct device *dev, const uint8_t *buf, +static int i2c_cc13xx_cc26xx_transmit(const struct device *dev, + const uint8_t *buf, uint32_t len, uint16_t addr) { const uint32_t base = get_dev_config(dev)->base; @@ -123,7 +124,8 @@ static int i2c_cc13xx_cc26xx_transmit(struct device *dev, const uint8_t *buf, return -EIO; } -static int i2c_cc13xx_cc26xx_receive(struct device *dev, uint8_t *buf, uint32_t len, +static int i2c_cc13xx_cc26xx_receive(const struct device *dev, uint8_t *buf, + uint32_t len, uint16_t addr) { const uint32_t base = get_dev_config(dev)->base; @@ -195,7 +197,8 @@ static int i2c_cc13xx_cc26xx_receive(struct device *dev, uint8_t *buf, uint32_t return -EIO; } -static int i2c_cc13xx_cc26xx_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_cc13xx_cc26xx_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { int ret = 0; @@ -242,7 +245,8 @@ static int i2c_cc13xx_cc26xx_transfer(struct device *dev, struct i2c_msg *msgs, } #define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) -static int i2c_cc13xx_cc26xx_configure(struct device *dev, uint32_t dev_config) +static int i2c_cc13xx_cc26xx_configure(const struct device *dev, + uint32_t dev_config) { bool fast; @@ -304,7 +308,7 @@ static void i2c_cc13xx_cc26xx_isr(void *arg) static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg) { - struct device *dev = (struct device *)clientArg; + const struct device *dev = (const struct device *)clientArg; int ret = Power_NOTIFYDONE; int16_t res_id; @@ -328,8 +332,8 @@ static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg, #endif #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int i2c_cc13xx_cc26xx_set_power_state(struct device *dev, - uint32_t new_state) +static int i2c_cc13xx_cc26xx_set_power_state(const struct device *dev, + uint32_t new_state) { int ret = 0; @@ -366,8 +370,10 @@ static int i2c_cc13xx_cc26xx_set_power_state(struct device *dev, return ret; } -static int i2c_cc13xx_cc26xx_pm_control(struct device *dev, uint32_t ctrl_command, - void *context, device_pm_cb cb, void *arg) +static int i2c_cc13xx_cc26xx_pm_control(const struct device *dev, + uint32_t ctrl_command, + void *context, device_pm_cb cb, + void *arg) { int ret = 0; @@ -391,7 +397,7 @@ static int i2c_cc13xx_cc26xx_pm_control(struct device *dev, uint32_t ctrl_comman } #endif /* CONFIG_DEVICE_POWER_MANAGEMENT */ -static int i2c_cc13xx_cc26xx_init(struct device *dev) +static int i2c_cc13xx_cc26xx_init(const struct device *dev) { uint32_t cfg; int err; diff --git a/drivers/i2c/i2c_cc32xx.c b/drivers/i2c/i2c_cc32xx.c index 4c582e59f0861d..e1872235e6ed16 100644 --- a/drivers/i2c/i2c_cc32xx.c +++ b/drivers/i2c/i2c_cc32xx.c @@ -82,7 +82,8 @@ struct i2c_cc32xx_data { static void configure_i2c_irq(const struct i2c_cc32xx_config *config); #define I2C_CLK_FREQ(n) DT_PROP(DT_INST_PHANDLE(n, clocks), clock_frequency) -static int i2c_cc32xx_configure(struct device *dev, uint32_t dev_config_raw) +static int i2c_cc32xx_configure(const struct device *dev, + uint32_t dev_config_raw) { uint32_t base = DEV_BASE(dev); uint32_t bitrate_id; @@ -111,7 +112,8 @@ static int i2c_cc32xx_configure(struct device *dev, uint32_t dev_config_raw) return 0; } -static void i2c_cc32xx_prime_transfer(struct device *dev, struct i2c_msg *msg, +static void i2c_cc32xx_prime_transfer(const struct device *dev, + struct i2c_msg *msg, uint16_t addr) { struct i2c_cc32xx_data *data = DEV_DATA(dev); @@ -156,7 +158,7 @@ static void i2c_cc32xx_prime_transfer(struct device *dev, struct i2c_msg *msg, } } -static int i2c_cc32xx_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_cc32xx_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { struct i2c_cc32xx_data *data = DEV_DATA(dev); @@ -261,7 +263,7 @@ static void i2c_cc32xx_isr_handle_read(uint32_t base, static void i2c_cc32xx_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; uint32_t base = DEV_BASE(dev); struct i2c_cc32xx_data *data = DEV_DATA(dev); uint32_t err_status; @@ -322,7 +324,7 @@ static void i2c_cc32xx_isr(void *arg) } } -static int i2c_cc32xx_init(struct device *dev) +static int i2c_cc32xx_init(const struct device *dev) { uint32_t base = DEV_BASE(dev); const struct i2c_cc32xx_config *config = DEV_CFG(dev); diff --git a/drivers/i2c/i2c_dw.c b/drivers/i2c/i2c_dw.c index 945f94e3b7606c..2321bea863bc0b 100644 --- a/drivers/i2c/i2c_dw.c +++ b/drivers/i2c/i2c_dw.c @@ -34,12 +34,12 @@ LOG_MODULE_REGISTER(i2c_dw); #include "i2c-priv.h" -static inline volatile struct i2c_dw_registers *get_regs(struct device *dev) +static inline volatile struct i2c_dw_registers *get_regs(const struct device *dev) { return (volatile struct i2c_dw_registers *)DEVICE_MMIO_GET(dev); } -static inline void i2c_dw_data_ask(struct device *dev) +static inline void i2c_dw_data_ask(const struct device *dev) { struct i2c_dw_dev_config * const dw = dev->data; uint32_t data; @@ -96,7 +96,7 @@ static inline void i2c_dw_data_ask(struct device *dev) } } -static void i2c_dw_data_read(struct device *dev) +static void i2c_dw_data_read(const struct device *dev) { struct i2c_dw_dev_config * const dw = dev->data; @@ -122,7 +122,7 @@ static void i2c_dw_data_read(struct device *dev) } -static int i2c_dw_data_send(struct device *dev) +static int i2c_dw_data_send(const struct device *dev) { struct i2c_dw_dev_config * const dw = dev->data; uint32_t data = 0U; @@ -166,7 +166,7 @@ static int i2c_dw_data_send(struct device *dev) return 0; } -static inline void i2c_dw_transfer_complete(struct device *dev) +static inline void i2c_dw_transfer_complete(const struct device *dev) { struct i2c_dw_dev_config * const dw = dev->data; uint32_t value; @@ -181,7 +181,7 @@ static inline void i2c_dw_transfer_complete(struct device *dev) static void i2c_dw_isr(void *arg) { - struct device *port = (struct device *)arg; + const struct device *port = (const struct device *)arg; struct i2c_dw_dev_config * const dw = port->data; union ic_interrupt_register intr_stat; uint32_t value; @@ -260,7 +260,7 @@ static void i2c_dw_isr(void *arg) } -static int i2c_dw_setup(struct device *dev, uint16_t slave_address) +static int i2c_dw_setup(const struct device *dev, uint16_t slave_address) { struct i2c_dw_dev_config * const dw = dev->data; uint32_t value; @@ -382,7 +382,7 @@ static int i2c_dw_setup(struct device *dev, uint16_t slave_address) return 0; } -static int i2c_dw_transfer(struct device *dev, +static int i2c_dw_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t slave_address) { @@ -494,7 +494,7 @@ static int i2c_dw_transfer(struct device *dev, return ret; } -static int i2c_dw_runtime_configure(struct device *dev, uint32_t config) +static int i2c_dw_runtime_configure(const struct device *dev, uint32_t config) { struct i2c_dw_dev_config * const dw = dev->data; uint32_t value = 0U; @@ -603,7 +603,7 @@ static const struct i2c_driver_api funcs = { .transfer = i2c_dw_transfer, }; -static int i2c_dw_initialize(struct device *dev) +static int i2c_dw_initialize(const struct device *dev) { const struct i2c_dw_rom_config * const rom = dev->config; struct i2c_dw_dev_config * const dw = dev->data; diff --git a/drivers/i2c/i2c_dw.h b/drivers/i2c/i2c_dw.h index fccd2250ff8383..4bf06cb0e93dca 100644 --- a/drivers/i2c/i2c_dw.h +++ b/drivers/i2c/i2c_dw.h @@ -33,7 +33,7 @@ extern "C" { #define I2C_DW_MAGIC_KEY 0x44570140 -typedef void (*i2c_isr_cb_t)(struct device *port); +typedef void (*i2c_isr_cb_t)(const struct device *port); #define IC_ACTIVITY (1 << 0) diff --git a/drivers/i2c/i2c_emul.c b/drivers/i2c/i2c_emul.c index c219c4b5083977..0def4a731bfde9 100644 --- a/drivers/i2c/i2c_emul.c +++ b/drivers/i2c/i2c_emul.c @@ -43,7 +43,7 @@ uint32_t i2c_emul_get_config(const struct device *dev) * @return emulator ro use * @return NULL if not found */ -static struct i2c_emul *i2c_emul_find(struct device *dev, int addr) +static struct i2c_emul *i2c_emul_find(const struct device *dev, int addr) { struct i2c_emul_data *data = dev->data; sys_snode_t *node; @@ -60,7 +60,7 @@ static struct i2c_emul *i2c_emul_find(struct device *dev, int addr) return NULL; } -static int i2c_emul_configure(struct device *dev, uint32_t dev_config) +static int i2c_emul_configure(const struct device *dev, uint32_t dev_config) { struct i2c_emul_data *data = dev->data; @@ -69,7 +69,7 @@ static int i2c_emul_configure(struct device *dev, uint32_t dev_config) return 0; } -static int i2c_emul_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_emul_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { struct i2c_emul *emul; @@ -98,7 +98,7 @@ static int i2c_emul_transfer(struct device *dev, struct i2c_msg *msgs, * * @param dev I2C emulation controller device */ -static int i2c_emul_init(struct device *dev) +static int i2c_emul_init(const struct device *dev) { struct i2c_emul_data *data = dev->data; const struct emul_list_for_bus *list = dev->config; @@ -111,7 +111,7 @@ static int i2c_emul_init(struct device *dev) return rc; } -int i2c_emul_register(struct device *dev, const char *name, +int i2c_emul_register(const struct device *dev, const char *name, struct i2c_emul *emul) { struct i2c_emul_data *data = dev->data; diff --git a/drivers/i2c/i2c_esp32.c b/drivers/i2c/i2c_esp32.c index e1ce07e44c0d5c..67cf2b46876d22 100644 --- a/drivers/i2c/i2c_esp32.c +++ b/drivers/i2c/i2c_esp32.c @@ -62,7 +62,7 @@ struct i2c_esp32_data { struct k_sem fifo_sem; struct k_sem transfer_sem; - struct device *clock_dev; + const struct device *clock_dev; }; typedef void (*irq_connect_cb)(void); @@ -107,7 +107,7 @@ static int i2c_esp32_configure_pins(int pin, int matrix_out, int matrix_in) GPIO_OPEN_DRAIN | GPIO_PULL_UP; const char *device_name = gpio_esp32_get_gpio_for_pin(pin); - struct device *gpio; + const struct device *gpio; int ret; if (!device_name) { @@ -129,7 +129,7 @@ static int i2c_esp32_configure_pins(int pin, int matrix_out, int matrix_in) return 0; } -static int i2c_esp32_configure_speed(struct device *dev, +static int i2c_esp32_configure_speed(const struct device *dev, uint32_t speed) { static const uint32_t speed_to_freq_tbl[] = { @@ -183,7 +183,7 @@ static int i2c_esp32_configure_speed(struct device *dev, return 0; } -static int i2c_esp32_configure(struct device *dev, uint32_t dev_config) +static int i2c_esp32_configure(const struct device *dev, uint32_t dev_config) { const struct i2c_esp32_config *config = dev->config; struct i2c_esp32_data *data = dev->data; @@ -291,7 +291,7 @@ static int i2c_esp32_spin_yield(int *counter) return 0; } -static int i2c_esp32_transmit(struct device *dev) +static int i2c_esp32_transmit(const struct device *dev) { const struct i2c_esp32_config *config = dev->config; struct i2c_esp32_data *data = dev->data; @@ -314,7 +314,7 @@ static int i2c_esp32_transmit(struct device *dev) return 0; } -static int i2c_esp32_wait(struct device *dev, +static int i2c_esp32_wait(const struct device *dev, volatile struct i2c_esp32_cmd *wait_cmd) { const struct i2c_esp32_config *config = dev->config; @@ -341,7 +341,7 @@ static int i2c_esp32_wait(struct device *dev, return 0; } -static int i2c_esp32_transmit_wait(struct device *dev, +static int i2c_esp32_transmit_wait(const struct device *dev, volatile struct i2c_esp32_cmd *wait_cmd) { int ret; @@ -355,7 +355,7 @@ static int i2c_esp32_transmit_wait(struct device *dev, } static volatile struct i2c_esp32_cmd * -i2c_esp32_write_addr(struct device *dev, +i2c_esp32_write_addr(const struct device *dev, volatile struct i2c_esp32_cmd *cmd, struct i2c_msg *msg, uint16_t addr) @@ -386,7 +386,7 @@ i2c_esp32_write_addr(struct device *dev, return cmd; } -static int i2c_esp32_read_msg(struct device *dev, uint16_t addr, +static int i2c_esp32_read_msg(const struct device *dev, uint16_t addr, struct i2c_msg msg) { const struct i2c_esp32_config *config = dev->config; @@ -468,7 +468,7 @@ static int i2c_esp32_read_msg(struct device *dev, uint16_t addr, return 0; } -static int i2c_esp32_write_msg(struct device *dev, uint16_t addr, +static int i2c_esp32_write_msg(const struct device *dev, uint16_t addr, struct i2c_msg msg) { const struct i2c_esp32_config *config = dev->config; @@ -519,7 +519,7 @@ static int i2c_esp32_write_msg(struct device *dev, uint16_t addr, return 0; } -static int i2c_esp32_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_esp32_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { struct i2c_esp32_data *data = dev->data; @@ -555,7 +555,7 @@ static void i2c_esp32_isr(void *arg) I2C_TIME_OUT_INT_ST | I2C_TRANS_COMPLETE_INT_ST | I2C_ARBITRATION_LOST_INT_ST; - struct device *device = arg; + const struct device *device = arg; const struct i2c_esp32_config *config = device->config; if (sys_read32(I2C_INT_STATUS_REG(config->index)) & fifo_give_mask) { @@ -572,7 +572,7 @@ static void i2c_esp32_isr(void *arg) sys_write32(~0, I2C_INT_CLR_REG(config->index)); } -static int i2c_esp32_init(struct device *dev); +static int i2c_esp32_init(const struct device *dev); static const struct i2c_driver_api i2c_esp32_driver_api = { .configure = i2c_esp32_configure, @@ -671,7 +671,7 @@ DEVICE_AND_API_INIT(i2c_esp32_1, DT_INST_LABEL(1), &i2c_esp32_init, &i2c_esp32_driver_api); #endif /* DT_NODE_HAS_STATUS(DT_DRV_INST(1), okay) */ -static int i2c_esp32_init(struct device *dev) +static int i2c_esp32_init(const struct device *dev) { const struct i2c_esp32_config *config = dev->config; struct i2c_esp32_data *data = dev->data; diff --git a/drivers/i2c/i2c_gecko.c b/drivers/i2c/i2c_gecko.c index d06f1ccf110c3f..b08de317adef32 100644 --- a/drivers/i2c/i2c_gecko.c +++ b/drivers/i2c/i2c_gecko.c @@ -46,7 +46,7 @@ struct i2c_gecko_data { uint32_t dev_config; }; -void i2c_gecko_config_pins(struct device *dev, +void i2c_gecko_config_pins(const struct device *dev, const struct soc_gpio_pin *pin_sda, const struct soc_gpio_pin *pin_scl) { @@ -74,7 +74,8 @@ void i2c_gecko_config_pins(struct device *dev, #endif } -static int i2c_gecko_configure(struct device *dev, uint32_t dev_config_raw) +static int i2c_gecko_configure(const struct device *dev, + uint32_t dev_config_raw) { I2C_TypeDef *base = DEV_BASE(dev); struct i2c_gecko_data *data = DEV_DATA(dev); @@ -107,7 +108,7 @@ static int i2c_gecko_configure(struct device *dev, uint32_t dev_config_raw) return 0; } -static int i2c_gecko_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_gecko_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { I2C_TypeDef *base = DEV_BASE(dev); @@ -171,7 +172,7 @@ static int i2c_gecko_transfer(struct device *dev, struct i2c_msg *msgs, return ret; } -static int i2c_gecko_init(struct device *dev) +static int i2c_gecko_init(const struct device *dev) { const struct i2c_gecko_config *config = DEV_CFG(dev); uint32_t bitrate_cfg; diff --git a/drivers/i2c/i2c_gpio.c b/drivers/i2c/i2c_gpio.c index 8bf5ab819de4f3..dccbdc9c6ab8ee 100644 --- a/drivers/i2c/i2c_gpio.c +++ b/drivers/i2c/i2c_gpio.c @@ -51,8 +51,8 @@ struct i2c_gpio_config { /* Driver instance data */ struct i2c_gpio_context { struct i2c_bitbang bitbang; /* Bit-bang library data */ - struct device *scl_gpio; /* GPIO used for I2C SCL line */ - struct device *sda_gpio; /* GPIO used for I2C SDA line */ + const struct device *scl_gpio; /* GPIO used for I2C SCL line */ + const struct device *sda_gpio; /* GPIO used for I2C SDA line */ gpio_pin_t scl_pin; /* Pin on gpio used for SCL line */ gpio_pin_t sda_pin; /* Pin on gpio used for SDA line */ }; @@ -86,14 +86,14 @@ static const struct i2c_bitbang_io io_fns = { .get_sda = &i2c_gpio_get_sda, }; -static int i2c_gpio_configure(struct device *dev, uint32_t dev_config) +static int i2c_gpio_configure(const struct device *dev, uint32_t dev_config) { struct i2c_gpio_context *context = dev->data; return i2c_bitbang_configure(&context->bitbang, dev_config); } -static int i2c_gpio_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_gpio_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t slave_address) { struct i2c_gpio_context *context = dev->data; @@ -102,7 +102,7 @@ static int i2c_gpio_transfer(struct device *dev, struct i2c_msg *msgs, slave_address); } -static int i2c_gpio_recover_bus(struct device *dev) +static int i2c_gpio_recover_bus(const struct device *dev) { struct i2c_gpio_context *context = dev->data; @@ -115,7 +115,7 @@ static struct i2c_driver_api api = { .recover_bus = i2c_gpio_recover_bus, }; -static int i2c_gpio_init(struct device *dev) +static int i2c_gpio_init(const struct device *dev) { struct i2c_gpio_context *context = dev->data; const struct i2c_gpio_config *config = dev->config; diff --git a/drivers/i2c/i2c_handlers.c b/drivers/i2c/i2c_handlers.c index ee161387efc762..02f25d579a252d 100644 --- a/drivers/i2c/i2c_handlers.c +++ b/drivers/i2c/i2c_handlers.c @@ -8,17 +8,18 @@ #include #include -static inline int z_vrfy_i2c_configure(struct device *dev, uint32_t dev_config) +static inline int z_vrfy_i2c_configure(const struct device *dev, + uint32_t dev_config) { Z_OOPS(Z_SYSCALL_DRIVER_I2C(dev, configure)); - return z_impl_i2c_configure((struct device *)dev, dev_config); + return z_impl_i2c_configure((const struct device *)dev, dev_config); } #include -static uint32_t copy_msgs_and_transfer(struct device *dev, - const struct i2c_msg *msgs, - uint8_t num_msgs, - uint16_t addr) +static uint32_t copy_msgs_and_transfer(const struct device *dev, + const struct i2c_msg *msgs, + uint8_t num_msgs, + uint16_t addr) { struct i2c_msg copy[num_msgs]; uint8_t i; @@ -37,9 +38,9 @@ static uint32_t copy_msgs_and_transfer(struct device *dev, return z_impl_i2c_transfer(dev, copy, num_msgs, addr); } -static inline int z_vrfy_i2c_transfer(struct device *dev, - struct i2c_msg *msgs, uint8_t num_msgs, - uint16_t addr) +static inline int z_vrfy_i2c_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, + uint16_t addr) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C)); @@ -54,27 +55,27 @@ static inline int z_vrfy_i2c_transfer(struct device *dev, Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs, sizeof(struct i2c_msg))); - return copy_msgs_and_transfer((struct device *)dev, + return copy_msgs_and_transfer((const struct device *)dev, (struct i2c_msg *)msgs, (uint8_t)num_msgs, (uint16_t)addr); } #include -static inline int z_vrfy_i2c_slave_driver_register(struct device *dev) +static inline int z_vrfy_i2c_slave_driver_register(const struct device *dev) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C)); return z_impl_i2c_slave_driver_register(dev); } #include -static inline int z_vrfy_i2c_slave_driver_unregister(struct device *dev) +static inline int z_vrfy_i2c_slave_driver_unregister(const struct device *dev) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C)); return z_vrfy_i2c_slave_driver_unregister(dev); } #include -static inline int z_vrfy_i2c_recover_bus(struct device *dev) +static inline int z_vrfy_i2c_recover_bus(const struct device *dev) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_I2C)); return z_impl_i2c_recover_bus(dev); diff --git a/drivers/i2c/i2c_imx.c b/drivers/i2c/i2c_imx.c index 4de12ac3d9242c..b64d695dc5e049 100644 --- a/drivers/i2c/i2c_imx.c +++ b/drivers/i2c/i2c_imx.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(i2c_imx); struct i2c_imx_config { I2C_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t bitrate; }; @@ -47,7 +47,8 @@ struct i2c_imx_data { struct k_sem device_sync_sem; }; -static bool i2c_imx_write(struct device *dev, uint8_t *txBuffer, uint8_t txSize) +static bool i2c_imx_write(const struct device *dev, uint8_t *txBuffer, + uint8_t txSize) { I2C_Type *base = DEV_BASE(dev); struct i2c_imx_data *data = DEV_DATA(dev); @@ -80,7 +81,8 @@ static bool i2c_imx_write(struct device *dev, uint8_t *txBuffer, uint8_t txSize) return transfer->ack; } -static void i2c_imx_read(struct device *dev, uint8_t *rxBuffer, uint8_t rxSize) +static void i2c_imx_read(const struct device *dev, uint8_t *rxBuffer, + uint8_t rxSize) { I2C_Type *base = DEV_BASE(dev); struct i2c_imx_data *data = DEV_DATA(dev); @@ -119,7 +121,8 @@ static void i2c_imx_read(struct device *dev, uint8_t *rxBuffer, uint8_t rxSize) } -static int i2c_imx_configure(struct device *dev, uint32_t dev_config_raw) +static int i2c_imx_configure(const struct device *dev, + uint32_t dev_config_raw) { I2C_Type *base = DEV_BASE(dev); struct i2c_imx_data *data = DEV_DATA(dev); @@ -173,7 +176,8 @@ static int i2c_imx_configure(struct device *dev, uint32_t dev_config_raw) return 0; } -static int i2c_imx_send_addr(struct device *dev, uint16_t addr, uint8_t flags) +static int i2c_imx_send_addr(const struct device *dev, uint16_t addr, + uint8_t flags) { uint8_t byte0 = addr << 1; @@ -181,8 +185,8 @@ static int i2c_imx_send_addr(struct device *dev, uint16_t addr, uint8_t flags) return i2c_imx_write(dev, &byte0, 1); } -static int i2c_imx_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int i2c_imx_transfer(const struct device *dev, struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { I2C_Type *base = DEV_BASE(dev); struct i2c_imx_data *data = DEV_DATA(dev); @@ -267,7 +271,7 @@ static int i2c_imx_transfer(struct device *dev, struct i2c_msg *msgs, static void i2c_imx_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; I2C_Type *base = DEV_BASE(dev); struct i2c_imx_data *data = DEV_DATA(dev); struct i2c_master_transfer *transfer = &data->transfer; @@ -332,7 +336,7 @@ static void i2c_imx_isr(void *arg) } } -static int i2c_imx_init(struct device *dev) +static int i2c_imx_init(const struct device *dev) { const struct i2c_imx_config *config = DEV_CFG(dev); struct i2c_imx_data *data = DEV_DATA(dev); diff --git a/drivers/i2c/i2c_litex.c b/drivers/i2c/i2c_litex.c index e856b07578f937..f83c4169116839 100644 --- a/drivers/i2c/i2c_litex.c +++ b/drivers/i2c/i2c_litex.c @@ -81,7 +81,7 @@ static const struct i2c_bitbang_io i2c_litex_bitbang_io = { .get_sda = i2c_litex_bitbang_get_sda, }; -static int i2c_litex_init(struct device *dev) +static int i2c_litex_init(const struct device *dev) { const struct i2c_litex_cfg *config = GET_I2C_CFG(dev); struct i2c_bitbang *bitbang = GET_I2C_BITBANG(dev); @@ -92,15 +92,15 @@ static int i2c_litex_init(struct device *dev) return 0; } -static int i2c_litex_configure(struct device *dev, uint32_t dev_config) +static int i2c_litex_configure(const struct device *dev, uint32_t dev_config) { struct i2c_bitbang *bitbang = GET_I2C_BITBANG(dev); return i2c_bitbang_configure(bitbang, dev_config); } -static int i2c_litex_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int i2c_litex_transfer(const struct device *dev, struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { struct i2c_bitbang *bitbang = GET_I2C_BITBANG(dev); diff --git a/drivers/i2c/i2c_ll_stm32.c b/drivers/i2c/i2c_ll_stm32.c index 9060bbfab03e58..bee7ff1c4aec49 100644 --- a/drivers/i2c/i2c_ll_stm32.c +++ b/drivers/i2c/i2c_ll_stm32.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(i2c_ll_stm32); #include "i2c-priv.h" -int i2c_stm32_runtime_configure(struct device *dev, uint32_t config) +int i2c_stm32_runtime_configure(const struct device *dev, uint32_t config) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -60,7 +60,7 @@ int i2c_stm32_runtime_configure(struct device *dev, uint32_t config) #define OPERATION(msg) (((struct i2c_msg *) msg)->flags & I2C_MSG_RW_MASK) -static int i2c_stm32_transfer(struct device *dev, struct i2c_msg *msg, +static int i2c_stm32_transfer(const struct device *dev, struct i2c_msg *msg, uint8_t num_msgs, uint16_t slave) { struct i2c_stm32_data *data = DEV_DATA(dev); @@ -174,9 +174,9 @@ static const struct i2c_driver_api api_funcs = { #endif }; -static int i2c_stm32_init(struct device *dev) +static int i2c_stm32_init(const struct device *dev) { - struct device *clock = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clock = device_get_binding(STM32_CLOCK_CONTROL_NAME); const struct i2c_stm32_config *cfg = DEV_CFG(dev); uint32_t bitrate_cfg; int ret; @@ -277,7 +277,7 @@ static void i2c_stm32_irq_config_func_##name(struct device *dev) #define STM32_I2C_IRQ_HANDLER_FUNCTION(name) \ .irq_config_func = i2c_stm32_irq_config_func_##name, #define STM32_I2C_IRQ_HANDLER(name) \ -static void i2c_stm32_irq_config_func_##name(struct device *dev) \ +static void i2c_stm32_irq_config_func_##name(const struct device *dev) \ { \ STM32_I2C_IRQ_CONNECT_AND_ENABLE(name); \ } diff --git a/drivers/i2c/i2c_ll_stm32.h b/drivers/i2c/i2c_ll_stm32.h index 0bc05cd1f78985..87967e8fd4fb18 100644 --- a/drivers/i2c/i2c_ll_stm32.h +++ b/drivers/i2c/i2c_ll_stm32.h @@ -9,7 +9,7 @@ #ifndef ZEPHYR_DRIVERS_I2C_I2C_LL_STM32_H_ #define ZEPHYR_DRIVERS_I2C_I2C_LL_STM32_H_ -typedef void (*irq_config_func_t)(struct device *port); +typedef void (*irq_config_func_t)(const struct device *port); #if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2) /** @@ -67,12 +67,14 @@ struct i2c_stm32_data { #endif }; -int32_t stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, uint8_t *flg, - uint16_t sadr); -int32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, uint8_t *flg, - uint16_t sadr); -int32_t stm32_i2c_configure_timing(struct device *dev, uint32_t clk); -int i2c_stm32_runtime_configure(struct device *dev, uint32_t config); +int32_t stm32_i2c_msg_write(const struct device *dev, struct i2c_msg *msg, + uint8_t *flg, + uint16_t sadr); +int32_t stm32_i2c_msg_read(const struct device *dev, struct i2c_msg *msg, + uint8_t *flg, + uint16_t sadr); +int32_t stm32_i2c_configure_timing(const struct device *dev, uint32_t clk); +int i2c_stm32_runtime_configure(const struct device *dev, uint32_t config); void stm32_i2c_event_isr(void *arg); void stm32_i2c_error_isr(void *arg); @@ -81,9 +83,9 @@ void stm32_i2c_combined_isr(void *arg); #endif #ifdef CONFIG_I2C_SLAVE -int i2c_stm32_slave_register(struct device *dev, +int i2c_stm32_slave_register(const struct device *dev, struct i2c_slave_config *config); -int i2c_stm32_slave_unregister(struct device *dev, +int i2c_stm32_slave_unregister(const struct device *dev, struct i2c_slave_config *config); #endif diff --git a/drivers/i2c/i2c_ll_stm32_v1.c b/drivers/i2c/i2c_ll_stm32_v1.c index 1d40f032323d47..8ab4a2c66f0d1e 100644 --- a/drivers/i2c/i2c_ll_stm32_v1.c +++ b/drivers/i2c/i2c_ll_stm32_v1.c @@ -44,7 +44,7 @@ static void stm32_i2c_generate_start_condition(I2C_TypeDef *i2c) #ifdef CONFIG_I2C_STM32_INTERRUPT -static void stm32_i2c_disable_transfer_interrupts(struct device *dev) +static void stm32_i2c_disable_transfer_interrupts(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -56,7 +56,7 @@ static void stm32_i2c_disable_transfer_interrupts(struct device *dev) LL_I2C_DisableIT_ERR(i2c); } -static void stm32_i2c_enable_transfer_interrupts(struct device *dev) +static void stm32_i2c_enable_transfer_interrupts(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -68,7 +68,7 @@ static void stm32_i2c_enable_transfer_interrupts(struct device *dev) #endif /* CONFIG_I2C_STM32_INTERRUPT */ -static void stm32_i2c_reset(struct device *dev) +static void stm32_i2c_reset(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -114,7 +114,7 @@ static void stm32_i2c_reset(struct device *dev) } -static void stm32_i2c_master_finish(struct device *dev) +static void stm32_i2c_master_finish(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -137,7 +137,7 @@ static void stm32_i2c_master_finish(struct device *dev) #endif } -static inline void msg_init(struct device *dev, struct i2c_msg *msg, +static inline void msg_init(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave, uint32_t transfer) { @@ -174,7 +174,8 @@ static inline void msg_init(struct device *dev, struct i2c_msg *msg, } } -static int32_t msg_end(struct device *dev, uint8_t *next_msg_flags, const char *funcname) +static int32_t msg_end(const struct device *dev, uint8_t *next_msg_flags, + const char *funcname) { struct i2c_stm32_data *data = DEV_DATA(dev); @@ -213,14 +214,14 @@ static int32_t msg_end(struct device *dev, uint8_t *next_msg_flags, const char * #ifdef CONFIG_I2C_STM32_INTERRUPT -static void stm32_i2c_master_mode_end(struct device *dev) +static void stm32_i2c_master_mode_end(const struct device *dev) { struct i2c_stm32_data *data = DEV_DATA(dev); k_sem_give(&data->device_sync_sem); } -static inline void handle_sb(struct device *dev) +static inline void handle_sb(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -254,7 +255,7 @@ static inline void handle_sb(struct device *dev) } } -static inline void handle_addr(struct device *dev) +static inline void handle_addr(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -298,7 +299,7 @@ static inline void handle_addr(struct device *dev) LL_I2C_ClearFlag_ADDR(i2c); } -static inline void handle_txe(struct device *dev) +static inline void handle_txe(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -328,7 +329,7 @@ static inline void handle_txe(struct device *dev) } } -static inline void handle_rxne(struct device *dev) +static inline void handle_rxne(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -376,7 +377,7 @@ static inline void handle_rxne(struct device *dev) } } -static inline void handle_btf(struct device *dev) +static inline void handle_btf(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -419,7 +420,7 @@ static inline void handle_btf(struct device *dev) #if defined(CONFIG_I2C_SLAVE) -static void stm32_i2c_slave_event(struct device *dev) +static void stm32_i2c_slave_event(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -470,7 +471,7 @@ static void stm32_i2c_slave_event(struct device *dev) } /* Attach and start I2C as slave */ -int i2c_stm32_slave_register(struct device *dev, +int i2c_stm32_slave_register(const struct device *dev, struct i2c_slave_config *config) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -516,7 +517,7 @@ int i2c_stm32_slave_register(struct device *dev, return 0; } -int i2c_stm32_slave_unregister(struct device *dev, +int i2c_stm32_slave_unregister(const struct device *dev, struct i2c_slave_config *config) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -549,7 +550,7 @@ int i2c_stm32_slave_unregister(struct device *dev, void stm32_i2c_event_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -578,7 +579,7 @@ void stm32_i2c_event_isr(void *arg) void stm32_i2c_error_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -612,8 +613,8 @@ void stm32_i2c_error_isr(void *arg) stm32_i2c_master_mode_end(dev); } -int32_t stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, - uint8_t *next_msg_flags, uint16_t saddr) +int32_t stm32_i2c_msg_write(const struct device *dev, struct i2c_msg *msg, + uint8_t *next_msg_flags, uint16_t saddr) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -634,8 +635,8 @@ int32_t stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, return msg_end(dev, next_msg_flags, __func__); } -int32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, - uint8_t *next_msg_flags, uint16_t saddr) +int32_t stm32_i2c_msg_read(const struct device *dev, struct i2c_msg *msg, + uint8_t *next_msg_flags, uint16_t saddr) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -658,7 +659,7 @@ int32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, #else /* CONFIG_I2C_STM32_INTERRUPT */ -static inline int check_errors(struct device *dev, const char *funcname) +static inline int check_errors(const struct device *dev, const char *funcname) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -708,8 +709,8 @@ static int stm32_i2c_wait_timeout(uint16_t *timeout) } } -int32_t stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, - uint8_t *next_msg_flags, uint16_t saddr) +int32_t stm32_i2c_msg_write(const struct device *dev, struct i2c_msg *msg, + uint8_t *next_msg_flags, uint16_t saddr) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -806,8 +807,8 @@ int32_t stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, return res; } -int32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, - uint8_t *next_msg_flags, uint16_t saddr) +int32_t stm32_i2c_msg_read(const struct device *dev, struct i2c_msg *msg, + uint8_t *next_msg_flags, uint16_t saddr) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -969,7 +970,7 @@ int32_t stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, } #endif /* CONFIG_I2C_STM32_INTERRUPT */ -int32_t stm32_i2c_configure_timing(struct device *dev, uint32_t clock) +int32_t stm32_i2c_configure_timing(const struct device *dev, uint32_t clock) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); diff --git a/drivers/i2c/i2c_ll_stm32_v2.c b/drivers/i2c/i2c_ll_stm32_v2.c index a1d1d96974dd30..8edc5cd323212a 100644 --- a/drivers/i2c/i2c_ll_stm32_v2.c +++ b/drivers/i2c/i2c_ll_stm32_v2.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(i2c_ll_stm32_v2); #include "i2c-priv.h" -static inline void msg_init(struct device *dev, struct i2c_msg *msg, +static inline void msg_init(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave, uint32_t transfer) { @@ -65,7 +65,7 @@ static inline void msg_init(struct device *dev, struct i2c_msg *msg, #ifdef CONFIG_I2C_STM32_INTERRUPT -static void stm32_i2c_disable_transfer_interrupts(struct device *dev) +static void stm32_i2c_disable_transfer_interrupts(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -78,7 +78,7 @@ static void stm32_i2c_disable_transfer_interrupts(struct device *dev) LL_I2C_DisableIT_ERR(i2c); } -static void stm32_i2c_enable_transfer_interrupts(struct device *dev) +static void stm32_i2c_enable_transfer_interrupts(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -89,7 +89,7 @@ static void stm32_i2c_enable_transfer_interrupts(struct device *dev) LL_I2C_EnableIT_ERR(i2c); } -static void stm32_i2c_master_mode_end(struct device *dev) +static void stm32_i2c_master_mode_end(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -109,7 +109,7 @@ static void stm32_i2c_master_mode_end(struct device *dev) } #if defined(CONFIG_I2C_SLAVE) -static void stm32_i2c_slave_event(struct device *dev) +static void stm32_i2c_slave_event(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -174,7 +174,7 @@ static void stm32_i2c_slave_event(struct device *dev) } /* Attach and start I2C as slave */ -int i2c_stm32_slave_register(struct device *dev, +int i2c_stm32_slave_register(const struct device *dev, struct i2c_slave_config *config) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -220,7 +220,7 @@ int i2c_stm32_slave_register(struct device *dev, return 0; } -int i2c_stm32_slave_unregister(struct device *dev, +int i2c_stm32_slave_unregister(const struct device *dev, struct i2c_slave_config *config) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -255,7 +255,7 @@ int i2c_stm32_slave_unregister(struct device *dev, #endif /* defined(CONFIG_I2C_SLAVE) */ -static void stm32_i2c_event(struct device *dev) +static void stm32_i2c_event(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -318,7 +318,7 @@ static void stm32_i2c_event(struct device *dev) stm32_i2c_master_mode_end(dev); } -static int stm32_i2c_error(struct device *dev) +static int stm32_i2c_error(const struct device *dev) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); @@ -352,7 +352,7 @@ static int stm32_i2c_error(struct device *dev) #ifdef CONFIG_I2C_STM32_COMBINED_INTERRUPT void stm32_i2c_combined_isr(void *arg) { - struct device *dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; if (stm32_i2c_error(dev)) { return; @@ -363,20 +363,20 @@ void stm32_i2c_combined_isr(void *arg) void stm32_i2c_event_isr(void *arg) { - struct device *dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; stm32_i2c_event(dev); } void stm32_i2c_error_isr(void *arg) { - struct device *dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; stm32_i2c_error(dev); } #endif -int stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, +int stm32_i2c_msg_write(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -424,7 +424,7 @@ int stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, return -EIO; } -int stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, +int stm32_i2c_msg_read(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -474,7 +474,7 @@ int stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, } #else /* !CONFIG_I2C_STM32_INTERRUPT */ -static inline int check_errors(struct device *dev, const char *funcname) +static inline int check_errors(const struct device *dev, const char *funcname) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -511,7 +511,8 @@ static inline int check_errors(struct device *dev, const char *funcname) return -EIO; } -static inline int msg_done(struct device *dev, unsigned int current_msg_flags) +static inline int msg_done(const struct device *dev, + unsigned int current_msg_flags) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); I2C_TypeDef *i2c = cfg->i2c; @@ -535,7 +536,7 @@ static inline int msg_done(struct device *dev, unsigned int current_msg_flags) return 0; } -int stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, +int stm32_i2c_msg_write(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -565,7 +566,7 @@ int stm32_i2c_msg_write(struct device *dev, struct i2c_msg *msg, return msg_done(dev, msg->flags); } -int stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, +int stm32_i2c_msg_read(const struct device *dev, struct i2c_msg *msg, uint8_t *next_msg_flags, uint16_t slave) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); @@ -592,7 +593,7 @@ int stm32_i2c_msg_read(struct device *dev, struct i2c_msg *msg, } #endif -int stm32_i2c_configure_timing(struct device *dev, uint32_t clock) +int stm32_i2c_configure_timing(const struct device *dev, uint32_t clock) { const struct i2c_stm32_config *cfg = DEV_CFG(dev); struct i2c_stm32_data *data = DEV_DATA(dev); diff --git a/drivers/i2c/i2c_lpc11u6x.c b/drivers/i2c/i2c_lpc11u6x.c index 7bf3d956428c41..7f7fedd8947640 100644 --- a/drivers/i2c/i2c_lpc11u6x.c +++ b/drivers/i2c/i2c_lpc11u6x.c @@ -18,7 +18,7 @@ #define DEV_DATA(dev) ((dev)->data) static void lpc11u6x_i2c_set_bus_speed(const struct lpc11u6x_i2c_config *cfg, - struct device *clk_dev, + const struct device *clk_dev, uint32_t speed) { uint32_t clk, div; @@ -31,11 +31,12 @@ static void lpc11u6x_i2c_set_bus_speed(const struct lpc11u6x_i2c_config *cfg, cfg->base->scll = div - (div / 2); } -static int lpc11u6x_i2c_configure(struct device *dev, uint32_t dev_config) +static int lpc11u6x_i2c_configure(const struct device *dev, + uint32_t dev_config) { const struct lpc11u6x_i2c_config *cfg = DEV_CFG(dev); struct lpc11u6x_i2c_data *data = DEV_DATA(dev); - struct device *clk_dev, *pinmux_dev; + const struct device *clk_dev, *pinmux_dev; uint32_t speed, flags = 0; switch (I2C_SPEED_GET(dev_config)) { @@ -92,7 +93,8 @@ static int lpc11u6x_i2c_configure(struct device *dev, uint32_t dev_config) return -EINVAL; } -static int lpc11u6x_i2c_transfer(struct device *dev, struct i2c_msg *msgs, +static int lpc11u6x_i2c_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { const struct lpc11u6x_i2c_config *cfg = DEV_CFG(dev); @@ -135,7 +137,7 @@ static int lpc11u6x_i2c_transfer(struct device *dev, struct i2c_msg *msgs, return ret; } -static int lpc11u6x_i2c_slave_register(struct device *dev, +static int lpc11u6x_i2c_slave_register(const struct device *dev, struct i2c_slave_config *cfg) { const struct lpc11u6x_i2c_config *dev_cfg = DEV_CFG(dev); @@ -169,7 +171,7 @@ static int lpc11u6x_i2c_slave_register(struct device *dev, } -static int lpc11u6x_i2c_slave_unregister(struct device *dev, +static int lpc11u6x_i2c_slave_unregister(const struct device *dev, struct i2c_slave_config *cfg) { const struct lpc11u6x_i2c_config *dev_cfg = DEV_CFG(dev); @@ -192,8 +194,8 @@ static int lpc11u6x_i2c_slave_unregister(struct device *dev, static void lpc11u6x_i2c_isr(void *arg) { - struct lpc11u6x_i2c_data *data = DEV_DATA((struct device *)arg); - struct lpc11u6x_i2c_regs *i2c = DEV_BASE((struct device *) arg); + struct lpc11u6x_i2c_data *data = DEV_DATA((const struct device *)arg); + struct lpc11u6x_i2c_regs *i2c = DEV_BASE((const struct device *) arg); struct lpc11u6x_i2c_current_transfer *transfer = &data->transfer; uint32_t clear = LPC11U6X_I2C_CONTROL_SI; uint32_t set = 0; @@ -324,11 +326,11 @@ static void lpc11u6x_i2c_isr(void *arg) } -static int lpc11u6x_i2c_init(struct device *dev) +static int lpc11u6x_i2c_init(const struct device *dev) { const struct lpc11u6x_i2c_config *cfg = DEV_CFG(dev); struct lpc11u6x_i2c_data *data = DEV_DATA(dev); - struct device *pinmux_dev, *clk_dev; + const struct device *pinmux_dev, *clk_dev; /* Configure SCL and SDA pins */ pinmux_dev = device_get_binding(cfg->scl_pinmux_drv); diff --git a/drivers/i2c/i2c_lpc11u6x.h b/drivers/i2c/i2c_lpc11u6x.h index 95ddb34bab49da..c8aa41bb2f1f62 100644 --- a/drivers/i2c/i2c_lpc11u6x.h +++ b/drivers/i2c/i2c_lpc11u6x.h @@ -68,7 +68,7 @@ struct lpc11u6x_i2c_config { char *clock_drv; char *scl_pinmux_drv; char *sda_pinmux_drv; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t clkid; uint32_t scl_flags; uint32_t sda_flags; diff --git a/drivers/i2c/i2c_mchp_xec.c b/drivers/i2c/i2c_mchp_xec.c index ec4f199fe2b5af..9f0ccb965992b1 100644 --- a/drivers/i2c/i2c_mchp_xec.c +++ b/drivers/i2c/i2c_mchp_xec.c @@ -146,7 +146,8 @@ static bool check_lines(uint32_t ba) (!(MCHP_I2C_SMB_BB_CTRL(ba) & MCHP_I2C_SMB_BB_DATI_RO))); } -static int i2c_xec_configure(struct device *dev, uint32_t dev_config_raw) +static int i2c_xec_configure(const struct device *dev, + uint32_t dev_config_raw) { const struct i2c_xec_config *config = (const struct i2c_xec_config *const) (dev->config); @@ -225,7 +226,7 @@ static int i2c_xec_configure(struct device *dev, uint32_t dev_config_raw) return 0; } -static int i2c_xec_poll_write(struct device *dev, struct i2c_msg msg, +static int i2c_xec_poll_write(const struct device *dev, struct i2c_msg msg, uint16_t addr) { const struct i2c_xec_config *config = @@ -288,7 +289,7 @@ static int i2c_xec_poll_write(struct device *dev, struct i2c_msg msg, return 0; } -static int i2c_xec_poll_read(struct device *dev, struct i2c_msg msg, +static int i2c_xec_poll_read(const struct device *dev, struct i2c_msg msg, uint16_t addr) { const struct i2c_xec_config *config = @@ -365,7 +366,7 @@ static int i2c_xec_poll_read(struct device *dev, struct i2c_msg msg, return 0; } -static int i2c_xec_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_xec_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { int ret = 0; @@ -386,18 +387,18 @@ static int i2c_xec_transfer(struct device *dev, struct i2c_msg *msgs, } #if defined(CONFIG_I2C_SLAVE) -static int i2c_xec_slave_register(struct device *dev) +static int i2c_xec_slave_register(const struct device *dev) { return -ENOTSUP; } -static int i2c_xec_slave_unregister(struct device *dev) +static int i2c_xec_slave_unregister(const struct device *dev) { return -ENOTSUP; } #endif -static int i2c_xec_init(struct device *dev); +static int i2c_xec_init(const struct device *dev); static const struct i2c_driver_api i2c_xec_driver_api = { .configure = i2c_xec_configure, @@ -408,7 +409,7 @@ static const struct i2c_driver_api i2c_xec_driver_api = { #endif }; -static int i2c_xec_init(struct device *dev) +static int i2c_xec_init(const struct device *dev) { struct i2c_xec_data *data = (struct i2c_xec_data *const) (dev->data); diff --git a/drivers/i2c/i2c_mcux.c b/drivers/i2c/i2c_mcux.c index dad084c73b796d..cbb0c9e51e4eec 100644 --- a/drivers/i2c/i2c_mcux.c +++ b/drivers/i2c/i2c_mcux.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(i2c_mcux); struct i2c_mcux_config { I2C_Type *base; clock_name_t clock_source; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t bitrate; }; @@ -38,7 +38,8 @@ struct i2c_mcux_data { status_t callback_status; }; -static int i2c_mcux_configure(struct device *dev, uint32_t dev_config_raw) +static int i2c_mcux_configure(const struct device *dev, + uint32_t dev_config_raw) { I2C_Type *base = DEV_BASE(dev); const struct i2c_mcux_config *config = DEV_CFG(dev); @@ -76,7 +77,7 @@ static int i2c_mcux_configure(struct device *dev, uint32_t dev_config_raw) static void i2c_mcux_master_transfer_callback(I2C_Type *base, i2c_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct i2c_mcux_data *data = DEV_DATA(dev); ARG_UNUSED(handle); @@ -101,8 +102,8 @@ static uint32_t i2c_mcux_convert_flags(int msg_flags) return flags; } -static int i2c_mcux_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int i2c_mcux_transfer(const struct device *dev, struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { I2C_Type *base = DEV_BASE(dev); struct i2c_mcux_data *data = DEV_DATA(dev); @@ -164,14 +165,14 @@ static int i2c_mcux_transfer(struct device *dev, struct i2c_msg *msgs, static void i2c_mcux_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; I2C_Type *base = DEV_BASE(dev); struct i2c_mcux_data *data = DEV_DATA(dev); I2C_MasterTransferHandleIRQ(base, &data->handle); } -static int i2c_mcux_init(struct device *dev) +static int i2c_mcux_init(const struct device *dev) { I2C_Type *base = DEV_BASE(dev); const struct i2c_mcux_config *config = DEV_CFG(dev); diff --git a/drivers/i2c/i2c_mcux_flexcomm.c b/drivers/i2c/i2c_mcux_flexcomm.c index d8c08dbef219f5..787c6275bc0ba6 100644 --- a/drivers/i2c/i2c_mcux_flexcomm.c +++ b/drivers/i2c/i2c_mcux_flexcomm.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(mcux_flexcomm); struct mcux_flexcomm_config { I2C_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t bitrate; }; @@ -29,7 +29,8 @@ struct mcux_flexcomm_data { status_t callback_status; }; -static int mcux_flexcomm_configure(struct device *dev, uint32_t dev_config_raw) +static int mcux_flexcomm_configure(const struct device *dev, + uint32_t dev_config_raw) { const struct mcux_flexcomm_config *config = dev->config; I2C_Type *base = config->base; @@ -68,7 +69,7 @@ static int mcux_flexcomm_configure(struct device *dev, uint32_t dev_config_raw) static void mcux_flexcomm_master_transfer_callback(I2C_Type *base, i2c_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct mcux_flexcomm_data *data = dev->data; ARG_UNUSED(handle); @@ -93,8 +94,9 @@ static uint32_t mcux_flexcomm_convert_flags(int msg_flags) return flags; } -static int mcux_flexcomm_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int mcux_flexcomm_transfer(const struct device *dev, + struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { const struct mcux_flexcomm_config *config = dev->config; struct mcux_flexcomm_data *data = dev->data; @@ -158,7 +160,7 @@ static int mcux_flexcomm_transfer(struct device *dev, struct i2c_msg *msgs, static void mcux_flexcomm_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_flexcomm_config *config = dev->config; struct mcux_flexcomm_data *data = dev->data; I2C_Type *base = config->base; @@ -166,7 +168,7 @@ static void mcux_flexcomm_isr(void *arg) I2C_MasterTransferHandleIRQ(base, &data->handle); } -static int mcux_flexcomm_init(struct device *dev) +static int mcux_flexcomm_init(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; struct mcux_flexcomm_data *data = dev->data; diff --git a/drivers/i2c/i2c_mcux_lpi2c.c b/drivers/i2c/i2c_mcux_lpi2c.c index 8c98e8fc36d298..53a02b67752fb7 100644 --- a/drivers/i2c/i2c_mcux_lpi2c.c +++ b/drivers/i2c/i2c_mcux_lpi2c.c @@ -21,7 +21,7 @@ struct mcux_lpi2c_config { LPI2C_Type *base; char *clock_name; clock_control_subsys_t clock_subsys; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t bitrate; uint32_t bus_idle_timeout_ns; }; @@ -32,11 +32,12 @@ struct mcux_lpi2c_data { status_t callback_status; }; -static int mcux_lpi2c_configure(struct device *dev, uint32_t dev_config_raw) +static int mcux_lpi2c_configure(const struct device *dev, + uint32_t dev_config_raw) { const struct mcux_lpi2c_config *config = dev->config; LPI2C_Type *base = config->base; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; uint32_t baudrate; @@ -80,7 +81,7 @@ static int mcux_lpi2c_configure(struct device *dev, uint32_t dev_config_raw) static void mcux_lpi2c_master_transfer_callback(LPI2C_Type *base, lpi2c_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct mcux_lpi2c_data *data = dev->data; ARG_UNUSED(handle); @@ -105,8 +106,8 @@ static uint32_t mcux_lpi2c_convert_flags(int msg_flags) return flags; } -static int mcux_lpi2c_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int mcux_lpi2c_transfer(const struct device *dev, struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { const struct mcux_lpi2c_config *config = dev->config; struct mcux_lpi2c_data *data = dev->data; @@ -170,7 +171,7 @@ static int mcux_lpi2c_transfer(struct device *dev, struct i2c_msg *msgs, static void mcux_lpi2c_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_lpi2c_config *config = dev->config; struct mcux_lpi2c_data *data = dev->data; LPI2C_Type *base = config->base; @@ -178,12 +179,12 @@ static void mcux_lpi2c_isr(void *arg) LPI2C_MasterTransferHandleIRQ(base, &data->handle); } -static int mcux_lpi2c_init(struct device *dev) +static int mcux_lpi2c_init(const struct device *dev) { const struct mcux_lpi2c_config *config = dev->config; struct mcux_lpi2c_data *data = dev->data; LPI2C_Type *base = config->base; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq, bitrate_cfg; lpi2c_master_config_t master_config; int error; diff --git a/drivers/i2c/i2c_nios2.c b/drivers/i2c/i2c_nios2.c index 6ea2fe7f9b1129..92dd0c4488c119 100644 --- a/drivers/i2c/i2c_nios2.c +++ b/drivers/i2c/i2c_nios2.c @@ -28,7 +28,7 @@ struct i2c_nios2_config { struct k_sem sem_lock; }; -static int i2c_nios2_configure(struct device *dev, uint32_t dev_config) +static int i2c_nios2_configure(const struct device *dev, uint32_t dev_config) { struct i2c_nios2_config *config = DEV_CFG(dev); int32_t rc = 0; @@ -59,7 +59,7 @@ static int i2c_nios2_configure(struct device *dev, uint32_t dev_config) return rc; } -static int i2c_nios2_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_nios2_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { struct i2c_nios2_config *config = DEV_CFG(dev); @@ -143,14 +143,14 @@ static int i2c_nios2_transfer(struct device *dev, struct i2c_msg *msgs, static void i2c_nios2_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct i2c_nios2_config *config = DEV_CFG(dev); /* Call Altera HAL driver ISR */ alt_handle_irq(&config->i2c_dev, I2C_0_IRQ); } -static int i2c_nios2_init(struct device *dev); +static int i2c_nios2_init(const struct device *dev); static struct i2c_driver_api i2c_nios2_driver_api = { .configure = i2c_nios2_configure, @@ -171,7 +171,7 @@ DEVICE_AND_API_INIT(i2c_nios2_0, DT_INST_LABEL(0), &i2c_nios2_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &i2c_nios2_driver_api); -static int i2c_nios2_init(struct device *dev) +static int i2c_nios2_init(const struct device *dev) { struct i2c_nios2_config *config = DEV_CFG(dev); int rc; diff --git a/drivers/i2c/i2c_nrfx_twi.c b/drivers/i2c/i2c_nrfx_twi.c index f5dc8a56f07409..98257cc614ca65 100644 --- a/drivers/i2c/i2c_nrfx_twi.c +++ b/drivers/i2c/i2c_nrfx_twi.c @@ -29,18 +29,19 @@ struct i2c_nrfx_twi_config { nrfx_twi_config_t config; }; -static inline struct i2c_nrfx_twi_data *get_dev_data(struct device *dev) +static inline struct i2c_nrfx_twi_data *get_dev_data(const struct device *dev) { return dev->data; } static inline -const struct i2c_nrfx_twi_config *get_dev_config(struct device *dev) +const struct i2c_nrfx_twi_config *get_dev_config(const struct device *dev) { return dev->config; } -static int i2c_nrfx_twi_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_nrfx_twi_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { int ret = 0; @@ -143,7 +144,7 @@ static int i2c_nrfx_twi_transfer(struct device *dev, struct i2c_msg *msgs, static void event_handler(nrfx_twi_evt_t const *p_event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; struct i2c_nrfx_twi_data *dev_data = get_dev_data(dev); switch (p_event->type) { @@ -164,7 +165,8 @@ static void event_handler(nrfx_twi_evt_t const *p_event, void *p_context) k_sem_give(&dev_data->completion_sync); } -static int i2c_nrfx_twi_configure(struct device *dev, uint32_t dev_config) +static int i2c_nrfx_twi_configure(const struct device *dev, + uint32_t dev_config) { nrfx_twi_t const *inst = &(get_dev_config(dev)->twi); @@ -193,7 +195,7 @@ static const struct i2c_driver_api i2c_nrfx_twi_driver_api = { .transfer = i2c_nrfx_twi_transfer, }; -static int init_twi(struct device *dev) +static int init_twi(const struct device *dev) { nrfx_err_t result = nrfx_twi_init(&get_dev_config(dev)->twi, &get_dev_config(dev)->config, @@ -211,7 +213,8 @@ static int init_twi(struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int twi_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int twi_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/i2c/i2c_nrfx_twim.c b/drivers/i2c/i2c_nrfx_twim.c index 31013f9a2b55a0..e1a9e6a65bba58 100644 --- a/drivers/i2c/i2c_nrfx_twim.c +++ b/drivers/i2c/i2c_nrfx_twim.c @@ -32,18 +32,19 @@ struct i2c_nrfx_twim_config { nrfx_twim_config_t config; }; -static inline struct i2c_nrfx_twim_data *get_dev_data(struct device *dev) +static inline struct i2c_nrfx_twim_data *get_dev_data(const struct device *dev) { return dev->data; } static inline -const struct i2c_nrfx_twim_config *get_dev_config(struct device *dev) +const struct i2c_nrfx_twim_config *get_dev_config(const struct device *dev) { return dev->config; } -static int i2c_nrfx_twim_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_nrfx_twim_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { int ret = 0; @@ -180,7 +181,7 @@ static int i2c_nrfx_twim_transfer(struct device *dev, struct i2c_msg *msgs, static void event_handler(nrfx_twim_evt_t const *p_event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; struct i2c_nrfx_twim_data *dev_data = get_dev_data(dev); switch (p_event->type) { @@ -201,7 +202,8 @@ static void event_handler(nrfx_twim_evt_t const *p_event, void *p_context) k_sem_give(&dev_data->completion_sync); } -static int i2c_nrfx_twim_configure(struct device *dev, uint32_t dev_config) +static int i2c_nrfx_twim_configure(const struct device *dev, + uint32_t dev_config) { nrfx_twim_t const *inst = &(get_dev_config(dev)->twim); @@ -230,7 +232,7 @@ static const struct i2c_driver_api i2c_nrfx_twim_driver_api = { .transfer = i2c_nrfx_twim_transfer, }; -static int init_twim(struct device *dev) +static int init_twim(const struct device *dev) { nrfx_err_t result = nrfx_twim_init(&get_dev_config(dev)->twim, &get_dev_config(dev)->config, @@ -250,7 +252,8 @@ static int init_twim(struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int twim_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int twim_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/i2c/i2c_rv32m1_lpi2c.c b/drivers/i2c/i2c_rv32m1_lpi2c.c index 1c11284e090315..ed7da0135196bd 100644 --- a/drivers/i2c/i2c_rv32m1_lpi2c.c +++ b/drivers/i2c/i2c_rv32m1_lpi2c.c @@ -25,7 +25,7 @@ struct rv32m1_lpi2c_config { clock_ip_name_t clock_ip_name; uint32_t clock_ip_src; uint32_t bitrate; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct rv32m1_lpi2c_data { @@ -35,10 +35,11 @@ struct rv32m1_lpi2c_data { status_t completion_status; }; -static int rv32m1_lpi2c_configure(struct device *dev, uint32_t dev_config) +static int rv32m1_lpi2c_configure(const struct device *dev, + uint32_t dev_config) { const struct rv32m1_lpi2c_config *config = dev->config; - struct device *clk; + const struct device *clk; uint32_t baudrate; uint32_t clk_freq; int err; @@ -101,7 +102,7 @@ static void rv32m1_lpi2c_master_transfer_callback(LPI2C_Type *base, status_t completionStatus, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct rv32m1_lpi2c_data *data = dev->data; ARG_UNUSED(base); @@ -126,7 +127,8 @@ static uint32_t rv32m1_lpi2c_convert_flags(int msg_flags) return flags; } -static int rv32m1_lpi2c_transfer(struct device *dev, struct i2c_msg *msgs, +static int rv32m1_lpi2c_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { const struct rv32m1_lpi2c_config *config = dev->config; @@ -201,19 +203,19 @@ static int rv32m1_lpi2c_transfer(struct device *dev, struct i2c_msg *msgs, static void rv32m1_lpi2c_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct rv32m1_lpi2c_config *config = dev->config; struct rv32m1_lpi2c_data *data = dev->data; LPI2C_MasterTransferHandleIRQ(config->base, &data->handle); } -static int rv32m1_lpi2c_init(struct device *dev) +static int rv32m1_lpi2c_init(const struct device *dev) { const struct rv32m1_lpi2c_config *config = dev->config; struct rv32m1_lpi2c_data *data = dev->data; lpi2c_master_config_t master_config; - struct device *clk; + const struct device *clk; uint32_t clk_freq, dev_cfg; int err; diff --git a/drivers/i2c/i2c_sam0.c b/drivers/i2c/i2c_sam0.c index 25a31bc57966e1..24d78fc149d114 100644 --- a/drivers/i2c/i2c_sam0.c +++ b/drivers/i2c/i2c_sam0.c @@ -33,7 +33,7 @@ struct i2c_sam0_dev_config { uint32_t pm_apbcmask; uint16_t gclk_clkctrl_id; #endif - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #ifdef CONFIG_I2C_SAM0_DMA_DRIVEN char *dma_dev; @@ -54,7 +54,7 @@ struct i2c_sam0_dev_data { struct i2c_sam0_msg msg; #ifdef CONFIG_I2C_SAM0_DMA_DRIVEN - struct device *dma; + const struct device *dma; #endif }; @@ -79,7 +79,7 @@ static void wait_synchronization(SercomI2cm *regs) #endif } -static bool i2c_sam0_terminate_on_error(struct device *dev) +static bool i2c_sam0_terminate_on_error(const struct device *dev) { struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); @@ -128,7 +128,7 @@ static bool i2c_sam0_terminate_on_error(struct device *dev) static void i2c_sam0_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; @@ -181,10 +181,10 @@ static void i2c_sam0_isr(void *arg) #ifdef CONFIG_I2C_SAM0_DMA_DRIVEN -static void i2c_sam0_dma_write_done(struct device *dma_dev, void *arg, +static void i2c_sam0_dma_write_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { - struct device *dev = arg; + const struct device *dev = arg; struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; @@ -220,7 +220,7 @@ static void i2c_sam0_dma_write_done(struct device *dma_dev, void *arg, i2c->INTENSET.reg = SERCOM_I2CM_INTENSET_MB; } -static bool i2c_sam0_dma_write_start(struct device *dev) +static bool i2c_sam0_dma_write_start(const struct device *dev) { struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); @@ -276,10 +276,10 @@ static bool i2c_sam0_dma_write_start(struct device *dev) return true; } -static void i2c_sam0_dma_read_done(struct device *dma_dev, void *arg, +static void i2c_sam0_dma_read_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { - struct device *dev = arg; + const struct device *dev = arg; struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; @@ -316,7 +316,7 @@ static void i2c_sam0_dma_read_done(struct device *dma_dev, void *arg, i2c->INTENSET.reg = SERCOM_I2CM_INTENSET_SB; } -static bool i2c_sam0_dma_read_start(struct device *dev) +static bool i2c_sam0_dma_read_start(const struct device *dev) { struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); @@ -375,7 +375,7 @@ static bool i2c_sam0_dma_read_start(struct device *dev) #endif -static int i2c_sam0_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_sam0_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { struct i2c_sam0_dev_data *data = DEV_DATA(dev); @@ -507,7 +507,8 @@ static int i2c_sam0_transfer(struct device *dev, struct i2c_msg *msgs, return 0; } -static int i2c_sam0_set_apply_bitrate(struct device *dev, uint32_t config) +static int i2c_sam0_set_apply_bitrate(const struct device *dev, + uint32_t config) { const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; @@ -641,7 +642,7 @@ static int i2c_sam0_set_apply_bitrate(struct device *dev, uint32_t config) return 0; } -static int i2c_sam0_configure(struct device *dev, uint32_t config) +static int i2c_sam0_configure(const struct device *dev, uint32_t config) { const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); SercomI2cm *i2c = cfg->regs; @@ -668,7 +669,7 @@ static int i2c_sam0_configure(struct device *dev, uint32_t config) return 0; } -static int i2c_sam0_initialize(struct device *dev) +static int i2c_sam0_initialize(const struct device *dev) { struct i2c_sam0_dev_data *data = DEV_DATA(dev); const struct i2c_sam0_dev_config *const cfg = DEV_CFG(dev); @@ -757,7 +758,7 @@ static const struct i2c_driver_api i2c_sam0_driver_api = { #if DT_INST_IRQ_HAS_IDX(0, 3) #define I2C_SAM0_IRQ_HANDLER(n) \ -static void i2c_sam0_irq_config_##n(struct device *dev) \ +static void i2c_sam0_irq_config_##n(const struct device *dev) \ { \ SAM0_I2C_IRQ_CONNECT(n, 0); \ SAM0_I2C_IRQ_CONNECT(n, 1); \ @@ -766,7 +767,7 @@ static void i2c_sam0_irq_config_##n(struct device *dev) \ } #else #define I2C_SAM0_IRQ_HANDLER(n) \ -static void i2c_sam0_irq_config_##n(struct device *dev) \ +static void i2c_sam0_irq_config_##n(const struct device *dev) \ { \ SAM0_I2C_IRQ_CONNECT(n, 0); \ } diff --git a/drivers/i2c/i2c_sam_twi.c b/drivers/i2c/i2c_sam_twi.c index 80a6731e39acd8..453bafba1702c3 100644 --- a/drivers/i2c/i2c_sam_twi.c +++ b/drivers/i2c/i2c_sam_twi.c @@ -104,7 +104,7 @@ static int i2c_clk_set(Twi *const twi, uint32_t speed) return 0; } -static int i2c_sam_twi_configure(struct device *dev, uint32_t config) +static int i2c_sam_twi_configure(const struct device *dev, uint32_t config) { const struct i2c_sam_twi_dev_cfg *const dev_cfg = DEV_CFG(dev); Twi *const twi = dev_cfg->regs; @@ -178,7 +178,8 @@ static void read_msg_start(Twi *const twi, struct twi_msg *msg, uint8_t daddr) twi->TWI_IER = TWI_IER_RXRDY | TWI_IER_TXCOMP | TWI_IER_NACK; } -static int i2c_sam_twi_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_sam_twi_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) { const struct i2c_sam_twi_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -236,7 +237,7 @@ static int i2c_sam_twi_transfer(struct device *dev, struct i2c_msg *msgs, static void i2c_sam_twi_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2c_sam_twi_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2c_sam_twi_dev_data *const dev_data = DEV_DATA(dev); Twi *const twi = dev_cfg->regs; @@ -294,7 +295,7 @@ static void i2c_sam_twi_isr(void *arg) k_sem_give(&dev_data->sem); } -static int i2c_sam_twi_initialize(struct device *dev) +static int i2c_sam_twi_initialize(const struct device *dev) { const struct i2c_sam_twi_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2c_sam_twi_dev_data *const dev_data = DEV_DATA(dev); diff --git a/drivers/i2c/i2c_sam_twihs.c b/drivers/i2c/i2c_sam_twihs.c index 038fa4cbf08049..b197c7f3dc61e6 100644 --- a/drivers/i2c/i2c_sam_twihs.c +++ b/drivers/i2c/i2c_sam_twihs.c @@ -104,7 +104,7 @@ static int i2c_clk_set(Twihs *const twihs, uint32_t speed) return 0; } -static int i2c_sam_twihs_configure(struct device *dev, uint32_t config) +static int i2c_sam_twihs_configure(const struct device *dev, uint32_t config) { const struct i2c_sam_twihs_dev_cfg *const dev_cfg = DEV_CFG(dev); Twihs *const twihs = dev_cfg->regs; @@ -180,8 +180,9 @@ static void read_msg_start(Twihs *const twihs, struct twihs_msg *msg, twihs->TWIHS_CR = TWIHS_CR_START | twihs_cr_stop; } -static int i2c_sam_twihs_transfer(struct device *dev, struct i2c_msg *msgs, - uint8_t num_msgs, uint16_t addr) +static int i2c_sam_twihs_transfer(const struct device *dev, + struct i2c_msg *msgs, + uint8_t num_msgs, uint16_t addr) { const struct i2c_sam_twihs_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2c_sam_twihs_dev_data *const dev_data = DEV_DATA(dev); @@ -223,7 +224,7 @@ static int i2c_sam_twihs_transfer(struct device *dev, struct i2c_msg *msgs, static void i2c_sam_twihs_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2c_sam_twihs_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2c_sam_twihs_dev_data *const dev_data = DEV_DATA(dev); Twihs *const twihs = dev_cfg->regs; @@ -281,7 +282,7 @@ static void i2c_sam_twihs_isr(void *arg) k_sem_give(&dev_data->sem); } -static int i2c_sam_twihs_initialize(struct device *dev) +static int i2c_sam_twihs_initialize(const struct device *dev) { const struct i2c_sam_twihs_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2c_sam_twihs_dev_data *const dev_data = DEV_DATA(dev); diff --git a/drivers/i2c/i2c_sbcon.c b/drivers/i2c/i2c_sbcon.c index cc738ae9da4a95..e56c408275ada8 100644 --- a/drivers/i2c/i2c_sbcon.c +++ b/drivers/i2c/i2c_sbcon.c @@ -77,14 +77,14 @@ static const struct i2c_bitbang_io io_fns = { .get_sda = &i2c_sbcon_get_sda, }; -static int i2c_sbcon_configure(struct device *dev, uint32_t dev_config) +static int i2c_sbcon_configure(const struct device *dev, uint32_t dev_config) { struct i2c_sbcon_context *context = dev->data; return i2c_bitbang_configure(&context->bitbang, dev_config); } -static int i2c_sbcon_transfer(struct device *dev, struct i2c_msg *msgs, +static int i2c_sbcon_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t slave_address) { struct i2c_sbcon_context *context = dev->data; @@ -98,7 +98,7 @@ static struct i2c_driver_api api = { .transfer = i2c_sbcon_transfer, }; -static int i2c_sbcon_init(struct device *dev) +static int i2c_sbcon_init(const struct device *dev) { struct i2c_sbcon_context *context = dev->data; const struct i2c_sbcon_config *config = dev->config; diff --git a/drivers/i2c/i2c_shell.c b/drivers/i2c/i2c_shell.c index be2487486326bf..3e368ed8d4bee2 100644 --- a/drivers/i2c/i2c_shell.c +++ b/drivers/i2c/i2c_shell.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(i2c_shell, CONFIG_LOG_DEFAULT_LEVEL); static int cmd_i2c_scan(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint8_t cnt = 0, first = 0x04, last = 0x77; dev = device_get_binding(argv[1]); @@ -70,7 +70,7 @@ static int cmd_i2c_scan(const struct shell *shell, static int cmd_i2c_recover(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; int err; dev = device_get_binding(argv[1]); @@ -92,7 +92,7 @@ static int cmd_i2c_recover(const struct shell *shell, static int cmd_i2c_write(const struct shell *shell, size_t argc, char **argv) { uint8_t buf[MAX_I2C_BYTES]; - struct device *dev; + const struct device *dev; int num_bytes; int reg_addr; int dev_addr; @@ -128,7 +128,7 @@ static int cmd_i2c_write(const struct shell *shell, size_t argc, char **argv) static int cmd_i2c_write_byte(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; int reg_addr; int dev_addr; int out_byte; @@ -155,7 +155,7 @@ static int cmd_i2c_write_byte(const struct shell *shell, static int cmd_i2c_read_byte(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; int reg_addr; int dev_addr; uint8_t out; @@ -184,7 +184,7 @@ static int cmd_i2c_read_byte(const struct shell *shell, static int cmd_i2c_read(const struct shell *shell, size_t argc, char **argv) { uint8_t buf[MAX_I2C_BYTES]; - struct device *dev; + const struct device *dev; int num_bytes; int reg_addr; int dev_addr; @@ -221,7 +221,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get); static void device_name_get(size_t idx, struct shell_static_entry *entry) { - struct device *dev = shell_device_lookup(idx, I2C_DEVICE_PREFIX); + const struct device *dev = shell_device_lookup(idx, I2C_DEVICE_PREFIX); entry->syntax = (dev != NULL) ? dev->name : NULL; entry->handler = NULL; diff --git a/drivers/i2c/i2c_sifive.c b/drivers/i2c/i2c_sifive.c index dc8eed2feec762..dc09387d32ff26 100644 --- a/drivers/i2c/i2c_sifive.c +++ b/drivers/i2c/i2c_sifive.c @@ -67,14 +67,14 @@ struct i2c_sifive_cfg { /* Helper functions */ -static inline bool i2c_sifive_busy(struct device *dev) +static inline bool i2c_sifive_busy(const struct device *dev) { const struct i2c_sifive_cfg *config = dev->config; return IS_SET(config, REG_STATUS, SF_STATUS_TIP); } -static int i2c_sifive_send_addr(struct device *dev, +static int i2c_sifive_send_addr(const struct device *dev, uint16_t addr, uint16_t rw_flag) { @@ -105,7 +105,7 @@ static int i2c_sifive_send_addr(struct device *dev, return 0; } -static int i2c_sifive_write_msg(struct device *dev, +static int i2c_sifive_write_msg(const struct device *dev, struct i2c_msg *msg, uint16_t addr) { @@ -154,7 +154,7 @@ static int i2c_sifive_write_msg(struct device *dev, return 0; } -static int i2c_sifive_read_msg(struct device *dev, +static int i2c_sifive_read_msg(const struct device *dev, struct i2c_msg *msg, uint16_t addr) { @@ -197,7 +197,7 @@ static int i2c_sifive_read_msg(struct device *dev, /* API Functions */ -static int i2c_sifive_configure(struct device *dev, uint32_t dev_config) +static int i2c_sifive_configure(const struct device *dev, uint32_t dev_config) { const struct i2c_sifive_cfg *config = NULL; uint32_t i2c_speed = 0U; @@ -262,7 +262,7 @@ static int i2c_sifive_configure(struct device *dev, uint32_t dev_config) return 0; } -static int i2c_sifive_transfer(struct device *dev, +static int i2c_sifive_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr) @@ -298,7 +298,7 @@ static int i2c_sifive_transfer(struct device *dev, return 0; }; -static int i2c_sifive_init(struct device *dev) +static int i2c_sifive_init(const struct device *dev) { const struct i2c_sifive_cfg *config = dev->config; uint32_t dev_config = 0U; diff --git a/drivers/i2s/i2s_cavs.c b/drivers/i2s/i2s_cavs.c index b433cfebc18cee..d91d840595d2f9 100644 --- a/drivers/i2s/i2s_cavs.c +++ b/drivers/i2s/i2s_cavs.c @@ -151,7 +151,7 @@ struct i2s_cavs_config { /* Device run time data */ struct i2s_cavs_dev_data { struct i2s_config cfg; - struct device *dev_dma; + const struct device *dev_dma; struct stream tx; struct stream rx; }; @@ -166,11 +166,11 @@ I2S_DEVICE_OBJECT_DECLARE(1); I2S_DEVICE_OBJECT_DECLARE(2); I2S_DEVICE_OBJECT_DECLARE(3); -static void i2s_dma_tx_callback(struct device *, void *, uint32_t, int); +static void i2s_dma_tx_callback(const struct device *, void *, uint32_t, int); static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *, - volatile struct i2s_cavs_ssp *const, struct device *); + volatile struct i2s_cavs_ssp *const, const struct device *); static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *, - volatile struct i2s_cavs_ssp *const, struct device *); + volatile struct i2s_cavs_ssp *const, const struct device *); static inline void i2s_purge_stream_buffers(struct stream *strm, struct k_mem_slab *mem_slab) @@ -186,10 +186,10 @@ static inline void i2s_purge_stream_buffers(struct stream *strm, } /* This function is executed in the interrupt context */ -static void i2s_dma_tx_callback(struct device *dma_dev, void *arg, +static void i2s_dma_tx_callback(const struct device *dma_dev, void *arg, uint32_t channel, int status) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); @@ -242,10 +242,10 @@ static void i2s_dma_tx_callback(struct device *dma_dev, void *arg, } } -static void i2s_dma_rx_callback(struct device *dma_dev, void *arg, +static void i2s_dma_rx_callback(const struct device *dma_dev, void *arg, uint32_t channel, int status) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); volatile struct i2s_cavs_ssp *const ssp = dev_cfg->regs; @@ -301,7 +301,7 @@ static void i2s_dma_rx_callback(struct device *dma_dev, void *arg, } } -static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir, +static int i2s_cavs_configure(const struct device *dev, enum i2s_dir dir, struct i2s_config *i2s_cfg) { const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); @@ -566,7 +566,7 @@ static int i2s_cavs_configure(struct device *dev, enum i2s_dir dir, static int i2s_tx_stream_start(struct i2s_cavs_dev_data *dev_data, volatile struct i2s_cavs_ssp *const ssp, - struct device *dev_dma) + const struct device *dev_dma) { int ret = 0; void *buffer; @@ -611,7 +611,8 @@ static int i2s_tx_stream_start(struct i2s_cavs_dev_data *dev_data, } static int i2s_rx_stream_start(struct i2s_cavs_dev_data *dev_data, - volatile struct i2s_cavs_ssp *const ssp, struct device *dev_dma) + volatile struct i2s_cavs_ssp *const ssp, + const struct device *dev_dma) { int ret = 0; void *buffer; @@ -660,7 +661,7 @@ static int i2s_rx_stream_start(struct i2s_cavs_dev_data *dev_data, static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *dev_data, volatile struct i2s_cavs_ssp *const ssp, - struct device *dev_dma) + const struct device *dev_dma) { struct stream *strm = &dev_data->tx; unsigned int key; @@ -683,7 +684,7 @@ static void i2s_tx_stream_disable(struct i2s_cavs_dev_data *dev_data, static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *dev_data, volatile struct i2s_cavs_ssp *const ssp, - struct device *dev_dma) + const struct device *dev_dma) { struct stream *strm = &dev_data->rx; uint32_t data; @@ -706,7 +707,7 @@ static void i2s_rx_stream_disable(struct i2s_cavs_dev_data *dev_data, i2s_purge_stream_buffers(strm, dev_data->cfg.mem_slab); } -static int i2s_cavs_trigger(struct device *dev, enum i2s_dir dir, +static int i2s_cavs_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd) { const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); @@ -768,7 +769,8 @@ static int i2s_cavs_trigger(struct device *dev, enum i2s_dir dir, return ret; } -static int i2s_cavs_read(struct device *dev, void **mem_block, size_t *size) +static int i2s_cavs_read(const struct device *dev, void **mem_block, + size_t *size) { struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); struct stream *strm = &dev_data->rx; @@ -791,7 +793,8 @@ static int i2s_cavs_read(struct device *dev, void **mem_block, size_t *size) return 0; } -static int i2s_cavs_write(struct device *dev, void *mem_block, size_t size) +static int i2s_cavs_write(const struct device *dev, void *mem_block, + size_t size) { struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); struct stream *strm = &dev_data->tx; @@ -818,7 +821,7 @@ static int i2s_cavs_write(struct device *dev, void *mem_block, size_t size) /* clear IRQ sources atm */ static void i2s_cavs_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); volatile struct i2s_cavs_ssp *const ssp = dev_cfg->regs; struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); @@ -840,7 +843,7 @@ static void i2s_cavs_isr(void *arg) } } -static int i2s_cavs_initialize(struct device *dev) +static int i2s_cavs_initialize(const struct device *dev) { const struct i2s_cavs_config *const dev_cfg = DEV_CFG(dev); struct i2s_cavs_dev_data *const dev_data = DEV_DATA(dev); diff --git a/drivers/i2s/i2s_common.c b/drivers/i2s/i2s_common.c index 15dfc117f3bc0a..2319a59194def1 100644 --- a/drivers/i2s/i2s_common.c +++ b/drivers/i2s/i2s_common.c @@ -8,16 +8,16 @@ #include #include -int z_impl_i2s_buf_read(struct device *dev, void *buf, size_t *size) +int z_impl_i2s_buf_read(const struct device *dev, void *buf, size_t *size) { void *mem_block; int ret; - ret = i2s_read((struct device *)dev, &mem_block, size); + ret = i2s_read((const struct device *)dev, &mem_block, size); if (!ret) { struct i2s_config *rx_cfg = - i2s_config_get((struct device *)dev, I2S_DIR_RX); + i2s_config_get((const struct device *)dev, I2S_DIR_RX); memcpy(buf, mem_block, *size); k_mem_slab_free(rx_cfg->mem_slab, &mem_block); @@ -26,13 +26,13 @@ int z_impl_i2s_buf_read(struct device *dev, void *buf, size_t *size) return ret; } -int z_impl_i2s_buf_write(struct device *dev, void *buf, size_t size) +int z_impl_i2s_buf_write(const struct device *dev, void *buf, size_t size) { int ret; struct i2s_config *tx_cfg; void *mem_block; - tx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_TX); + tx_cfg = i2s_config_get((const struct device *)dev, I2S_DIR_TX); if (!tx_cfg) { return -EIO; } @@ -48,7 +48,7 @@ int z_impl_i2s_buf_write(struct device *dev, void *buf, size_t size) memcpy(mem_block, (void *)buf, size); - ret = i2s_write((struct device *)dev, mem_block, size); + ret = i2s_write((const struct device *)dev, mem_block, size); if (ret != 0) { k_mem_slab_free(tx_cfg->mem_slab, &mem_block); } diff --git a/drivers/i2s/i2s_handlers.c b/drivers/i2s/i2s_handlers.c index 13c35e3b7eeb91..27384887f25727 100644 --- a/drivers/i2s/i2s_handlers.c +++ b/drivers/i2s/i2s_handlers.c @@ -9,8 +9,9 @@ #include -static inline int z_vrfy_i2s_configure(struct device *dev, enum i2s_dir dir, - struct i2s_config *cfg_ptr) +static inline int z_vrfy_i2s_configure(const struct device *dev, + enum i2s_dir dir, + struct i2s_config *cfg_ptr) { struct i2s_config config; int ret = -EINVAL; @@ -36,13 +37,13 @@ static inline int z_vrfy_i2s_configure(struct device *dev, enum i2s_dir dir, goto out; } - ret = z_impl_i2s_configure((struct device *)dev, dir, &config); + ret = z_impl_i2s_configure((const struct device *)dev, dir, &config); out: return ret; } #include -static inline int z_vrfy_i2s_buf_read(struct device *dev, +static inline int z_vrfy_i2s_buf_read(const struct device *dev, void *buf, size_t *size) { void *mem_block; @@ -51,7 +52,7 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev, Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, read)); - ret = i2s_read((struct device *)dev, &mem_block, &data_size); + ret = i2s_read((const struct device *)dev, &mem_block, &data_size); if (!ret) { struct i2s_config *rx_cfg; @@ -60,7 +61,8 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev, /* Presumed to be configured otherwise the i2s_read() call * would have failed. */ - rx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_RX); + rx_cfg = i2s_config_get((const struct device *)dev, + I2S_DIR_RX); copy_success = z_user_to_copy((void *)buf, mem_block, data_size); @@ -75,7 +77,7 @@ static inline int z_vrfy_i2s_buf_read(struct device *dev, } #include -static inline int z_vrfy_i2s_buf_write(struct device *dev, +static inline int z_vrfy_i2s_buf_write(const struct device *dev, void *buf, size_t size) { int ret; @@ -83,7 +85,7 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev, void *mem_block; Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, write)); - tx_cfg = i2s_config_get((struct device *)dev, I2S_DIR_TX); + tx_cfg = i2s_config_get((const struct device *)dev, I2S_DIR_TX); if (!tx_cfg) { return -EIO; } @@ -103,7 +105,7 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev, Z_OOPS(ret); } - ret = i2s_write((struct device *)dev, mem_block, size); + ret = i2s_write((const struct device *)dev, mem_block, size); if (ret != 0) { k_mem_slab_free(tx_cfg->mem_slab, &mem_block); } @@ -112,11 +114,12 @@ static inline int z_vrfy_i2s_buf_write(struct device *dev, } #include -static inline int z_vrfy_i2s_trigger(struct device *dev, enum i2s_dir dir, +static inline int z_vrfy_i2s_trigger(const struct device *dev, + enum i2s_dir dir, enum i2s_trigger_cmd cmd) { Z_OOPS(Z_SYSCALL_DRIVER_I2S(dev, trigger)); - return z_impl_i2s_trigger((struct device *)dev, dir, cmd); + return z_impl_i2s_trigger((const struct device *)dev, dir, cmd); } #include diff --git a/drivers/i2s/i2s_litex.c b/drivers/i2s/i2s_litex.c index f6f8637f8e5751..c36e87b48b072c 100644 --- a/drivers/i2s/i2s_litex.c +++ b/drivers/i2s/i2s_litex.c @@ -320,7 +320,7 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size) return 0; } -static int i2s_litex_initialize(struct device *dev) +static int i2s_litex_initialize(const struct device *dev) { struct i2s_litex_cfg *cfg = DEV_CFG(dev); struct i2s_litex_data *const dev_data = DEV_DATA(dev); @@ -333,7 +333,7 @@ static int i2s_litex_initialize(struct device *dev) return 0; } -static int i2s_litex_configure(struct device *dev, enum i2s_dir dir, +static int i2s_litex_configure(const struct device *dev, enum i2s_dir dir, struct i2s_config *i2s_cfg) { struct i2s_litex_data *const dev_data = DEV_DATA(dev); @@ -436,7 +436,8 @@ static int i2s_litex_configure(struct device *dev, enum i2s_dir dir, return 0; } -static int i2s_litex_read(struct device *dev, void **mem_block, size_t *size) +static int i2s_litex_read(const struct device *dev, void **mem_block, + size_t *size) { struct i2s_litex_data *const dev_data = DEV_DATA(dev); int ret; @@ -455,7 +456,8 @@ static int i2s_litex_read(struct device *dev, void **mem_block, size_t *size) return queue_get(&dev_data->rx.mem_block_queue, mem_block, size); } -static int i2s_litex_write(struct device *dev, void *mem_block, size_t size) +static int i2s_litex_write(const struct device *dev, void *mem_block, + size_t size) { struct i2s_litex_data *const dev_data = DEV_DATA(dev); const struct i2s_litex_cfg *cfg = DEV_CFG(dev); @@ -485,7 +487,7 @@ static int i2s_litex_write(struct device *dev, void *mem_block, size_t size) return ret; } -static int i2s_litex_trigger(struct device *dev, enum i2s_dir dir, +static int i2s_litex_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd) { struct i2s_litex_data *const dev_data = DEV_DATA(dev); @@ -543,7 +545,7 @@ static inline void clear_rx_fifo(const struct i2s_litex_cfg *cfg) static void i2s_litex_isr_rx(void *arg) { - struct device *const dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_litex_cfg *cfg = DEV_CFG(dev); struct stream *stream = &DEV_DATA(dev)->rx; int ret; @@ -574,7 +576,7 @@ static void i2s_litex_isr_rx(void *arg) static void i2s_litex_isr_tx(void *arg) { - struct device *const dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_litex_cfg *cfg = DEV_CFG(dev); size_t mem_block_size; struct stream *stream = &DEV_DATA(dev)->tx; diff --git a/drivers/i2s/i2s_litex.h b/drivers/i2s/i2s_litex.h index 4d4b4356b44b43..08d89ab6d5e7fb 100644 --- a/drivers/i2s/i2s_litex.h +++ b/drivers/i2s/i2s_litex.h @@ -104,7 +104,7 @@ struct i2s_litex_cfg { uint32_t base; uint32_t fifo_base; uint16_t fifo_depth; - void (*irq_config)(struct device *dev); + void (*irq_config)(const struct device *dev); }; #endif /* _I2S_LITEI2S__H */ diff --git a/drivers/i2s/i2s_ll_stm32.c b/drivers/i2s/i2s_ll_stm32.c index d30903aaefdc17..d15dde42529edc 100644 --- a/drivers/i2s/i2s_ll_stm32.c +++ b/drivers/i2s/i2s_ll_stm32.c @@ -91,10 +91,10 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size) return 0; } -static int i2s_stm32_enable_clock(struct device *dev) +static int i2s_stm32_enable_clock(const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); - struct device *clk; + const struct device *clk; int ret; clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); @@ -117,7 +117,8 @@ static uint16_t plli2s_ms_count; #define pllr(v) z_pllr(v) #endif -static int i2s_stm32_set_clock(struct device *dev, uint32_t bit_clk_freq) +static int i2s_stm32_set_clock(const struct device *dev, + uint32_t bit_clk_freq) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); uint32_t pll_src = LL_RCC_PLL_GetMainSource(); @@ -177,7 +178,7 @@ static int i2s_stm32_set_clock(struct device *dev, uint32_t bit_clk_freq) return 0; } -static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir, +static int i2s_stm32_configure(const struct device *dev, enum i2s_dir dir, struct i2s_config *i2s_cfg) { const struct i2s_stm32_cfg *const cfg = DEV_CFG(dev); @@ -281,7 +282,7 @@ static int i2s_stm32_configure(struct device *dev, enum i2s_dir dir, return 0; } -static int i2s_stm32_trigger(struct device *dev, enum i2s_dir dir, +static int i2s_stm32_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd) { struct i2s_stm32_data *const dev_data = DEV_DATA(dev); @@ -372,7 +373,8 @@ static int i2s_stm32_trigger(struct device *dev, enum i2s_dir dir, return 0; } -static int i2s_stm32_read(struct device *dev, void **mem_block, size_t *size) +static int i2s_stm32_read(const struct device *dev, void **mem_block, + size_t *size) { struct i2s_stm32_data *const dev_data = DEV_DATA(dev); int ret; @@ -399,7 +401,8 @@ static int i2s_stm32_read(struct device *dev, void **mem_block, size_t *size) return 0; } -static int i2s_stm32_write(struct device *dev, void *mem_block, size_t size) +static int i2s_stm32_write(const struct device *dev, void *mem_block, + size_t size) { struct i2s_stm32_data *const dev_data = DEV_DATA(dev); int ret; @@ -430,10 +433,10 @@ static const struct i2s_driver_api i2s_stm32_driver_api = { }; #define STM32_DMA_NUM_CHANNELS 8 -static struct device *active_dma_rx_channel[STM32_DMA_NUM_CHANNELS]; -static struct device *active_dma_tx_channel[STM32_DMA_NUM_CHANNELS]; +static const struct device *active_dma_rx_channel[STM32_DMA_NUM_CHANNELS]; +static const struct device *active_dma_tx_channel[STM32_DMA_NUM_CHANNELS]; -static int reload_dma(struct device *dev_dma, uint32_t channel, +static int reload_dma(const struct device *dev_dma, uint32_t channel, struct dma_config *dcfg, void *src, void *dst, uint32_t blk_size) { @@ -449,7 +452,7 @@ static int reload_dma(struct device *dev_dma, uint32_t channel, return ret; } -static int start_dma(struct device *dev_dma, uint32_t channel, +static int start_dma(const struct device *dev_dma, uint32_t channel, struct dma_config *dcfg, void *src, bool src_addr_increment, void *dst, bool dst_addr_increment, uint8_t fifo_threshold, @@ -486,16 +489,16 @@ static int start_dma(struct device *dev_dma, uint32_t channel, return ret; } -static struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel); -static struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel); -static void rx_stream_disable(struct stream *stream, struct device *dev); -static void tx_stream_disable(struct stream *stream, struct device *dev); +static const struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel); +static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel); +static void rx_stream_disable(struct stream *stream, const struct device *dev); +static void tx_stream_disable(struct stream *stream, const struct device *dev); /* This function is executed in the interrupt context */ -static void dma_rx_callback(struct device *dma_dev, void *arg, +static void dma_rx_callback(const struct device *dma_dev, void *arg, uint32_t channel, int status) { - struct device *dev = get_dev_from_rx_dma_channel(channel); + const struct device *dev = get_dev_from_rx_dma_channel(channel); const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); struct stream *stream = &dev_data->rx; @@ -559,10 +562,10 @@ static void dma_rx_callback(struct device *dma_dev, void *arg, rx_stream_disable(stream, dev); } -static void dma_tx_callback(struct device *dma_dev, void *arg, +static void dma_tx_callback(const struct device *dma_dev, void *arg, uint32_t channel, int status) { - struct device *dev = get_dev_from_tx_dma_channel(channel); + const struct device *dev = get_dev_from_tx_dma_channel(channel); const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); struct stream *stream = &dev_data->tx; @@ -630,7 +633,7 @@ static uint32_t i2s_stm32_irq_ovr_count; static void i2s_stm32_isr(void *arg) { - struct device *const dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); struct stream *stream = &dev_data->rx; @@ -647,7 +650,7 @@ static void i2s_stm32_isr(void *arg) i2s_stm32_irq_count++; } -static int i2s_stm32_initialize(struct device *dev) +static int i2s_stm32_initialize(const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); @@ -688,7 +691,7 @@ static int i2s_stm32_initialize(struct device *dev) return 0; } -static int rx_stream_start(struct stream *stream, struct device *dev) +static int rx_stream_start(struct stream *stream, const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); @@ -728,7 +731,7 @@ static int rx_stream_start(struct stream *stream, struct device *dev) return 0; } -static int tx_stream_start(struct stream *stream, struct device *dev) +static int tx_stream_start(struct stream *stream, const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); @@ -773,11 +776,11 @@ static int tx_stream_start(struct stream *stream, struct device *dev) return 0; } -static void rx_stream_disable(struct stream *stream, struct device *dev) +static void rx_stream_disable(struct stream *stream, const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); - struct device *dev_dma = dev_data->dev_dma_rx; + const struct device *dev_dma = dev_data->dev_dma_rx; LL_I2S_DisableDMAReq_RX(cfg->i2s); LL_I2S_DisableIT_ERR(cfg->i2s); @@ -793,11 +796,11 @@ static void rx_stream_disable(struct stream *stream, struct device *dev) active_dma_rx_channel[stream->dma_channel] = NULL; } -static void tx_stream_disable(struct stream *stream, struct device *dev) +static void tx_stream_disable(struct stream *stream, const struct device *dev) { const struct i2s_stm32_cfg *cfg = DEV_CFG(dev); struct i2s_stm32_data *const dev_data = DEV_DATA(dev); - struct device *dev_dma = dev_data->dev_dma_tx; + const struct device *dev_dma = dev_data->dev_dma_tx; LL_I2S_DisableDMAReq_TX(cfg->i2s); LL_I2S_DisableIT_ERR(cfg->i2s); @@ -841,12 +844,12 @@ static void tx_queue_drop(struct stream *stream) } } -static struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel) +static const struct device *get_dev_from_rx_dma_channel(uint32_t dma_channel) { return active_dma_rx_channel[dma_channel]; } -static struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel) +static const struct device *get_dev_from_tx_dma_channel(uint32_t dma_channel) { return active_dma_tx_channel[dma_channel]; } diff --git a/drivers/i2s/i2s_ll_stm32.h b/drivers/i2s/i2s_ll_stm32.h index 9245b577ac95df..1a099408c94cfb 100644 --- a/drivers/i2s/i2s_ll_stm32.h +++ b/drivers/i2s/i2s_ll_stm32.h @@ -72,7 +72,7 @@ struct i2s_stm32_cfg { SPI_TypeDef *i2s; struct stm32_pclken pclken; uint32_t i2s_clk_sel; - void (*irq_config)(struct device *dev); + void (*irq_config)(const struct device *dev); }; struct stream { @@ -92,15 +92,15 @@ struct stream { void *mem_block; bool last_block; bool master; - int (*stream_start)(struct stream *, struct device *dev); - void (*stream_disable)(struct stream *, struct device *dev); + int (*stream_start)(struct stream *, const struct device *dev); + void (*stream_disable)(struct stream *, const struct device *dev); void (*queue_drop)(struct stream *); }; /* Device run time data */ struct i2s_stm32_data { - struct device *dev_dma_tx; - struct device *dev_dma_rx; + const struct device *dev_dma_tx; + const struct device *dev_dma_rx; struct stream rx; struct stream tx; }; diff --git a/drivers/i2s/i2s_sam_ssc.c b/drivers/i2s/i2s_sam_ssc.c index 3fa823763c2490..25c933f5008b15 100644 --- a/drivers/i2s/i2s_sam_ssc.c +++ b/drivers/i2s/i2s_sam_ssc.c @@ -81,8 +81,10 @@ struct stream { struct ring_buf mem_block_queue; void *mem_block; bool last_block; - int (*stream_start)(struct stream *, Ssc *const, struct device *); - void (*stream_disable)(struct stream *, Ssc *const, struct device *); + int (*stream_start)(struct stream *, Ssc *const, + const struct device *); + void (*stream_disable)(struct stream *, Ssc *const, + const struct device *); void (*queue_drop)(struct stream *); int (*set_data_format)(const struct i2s_sam_dev_cfg *const, struct i2s_config *); @@ -90,7 +92,7 @@ struct stream { /* Device run time data */ struct i2s_sam_dev_data { - struct device *dev_dma; + const struct device *dev_dma; struct stream rx; struct stream tx; }; @@ -103,11 +105,13 @@ struct i2s_sam_dev_data { #define MODULO_INC(val, max) { val = (++val < max) ? val : 0; } -static struct device *get_dev_from_dma_channel(uint32_t dma_channel); -static void dma_rx_callback(struct device *, void *, uint32_t, int); -static void dma_tx_callback(struct device *, void *, uint32_t, int); -static void rx_stream_disable(struct stream *, Ssc *const, struct device *); -static void tx_stream_disable(struct stream *, Ssc *const, struct device *); +static const struct device *get_dev_from_dma_channel(uint32_t dma_channel); +static void dma_rx_callback(const struct device *, void *, uint32_t, int); +static void dma_tx_callback(const struct device *, void *, uint32_t, int); +static void rx_stream_disable(struct stream *, Ssc *const, + const struct device *); +static void tx_stream_disable(struct stream *, Ssc *const, + const struct device *); /* * Get data from the queue @@ -161,7 +165,7 @@ static int queue_put(struct ring_buf *rb, void *mem_block, size_t size) return 0; } -static int start_dma(struct device *dev_dma, uint32_t channel, +static int start_dma(const struct device *dev_dma, uint32_t channel, struct dma_config *cfg, void *src, void *dst, uint32_t blk_size) { @@ -186,10 +190,10 @@ static int start_dma(struct device *dev_dma, uint32_t channel, } /* This function is executed in the interrupt context */ -static void dma_rx_callback(struct device *dma_dev, void *user_data, +static void dma_rx_callback(const struct device *dma_dev, void *user_data, uint32_t channel, int status) { - struct device *dev = get_dev_from_dma_channel(channel); + const struct device *dev = get_dev_from_dma_channel(channel); const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); Ssc *const ssc = dev_cfg->regs; @@ -246,10 +250,10 @@ static void dma_rx_callback(struct device *dma_dev, void *user_data, } /* This function is executed in the interrupt context */ -static void dma_tx_callback(struct device *dma_dev, void *user_data, +static void dma_tx_callback(const struct device *dma_dev, void *user_data, uint32_t channel, int status) { - struct device *dev = get_dev_from_dma_channel(channel); + const struct device *dev = get_dev_from_dma_channel(channel); const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); Ssc *const ssc = dev_cfg->regs; @@ -511,7 +515,7 @@ static int bit_clock_set(Ssc *const ssc, uint32_t bit_clk_freq) return 0; } -static struct i2s_config *i2s_sam_config_get(struct device *dev, +static struct i2s_config *i2s_sam_config_get(const struct device *dev, enum i2s_dir dir) { struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); @@ -530,7 +534,7 @@ static struct i2s_config *i2s_sam_config_get(struct device *dev, return &stream->cfg; } -static int i2s_sam_configure(struct device *dev, enum i2s_dir dir, +static int i2s_sam_configure(const struct device *dev, enum i2s_dir dir, struct i2s_config *i2s_cfg) { const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -618,7 +622,7 @@ static int i2s_sam_configure(struct device *dev, enum i2s_dir dir, } static int rx_stream_start(struct stream *stream, Ssc *const ssc, - struct device *dev_dma) + const struct device *dev_dma) { int ret; @@ -653,7 +657,7 @@ static int rx_stream_start(struct stream *stream, Ssc *const ssc, } static int tx_stream_start(struct stream *stream, Ssc *const ssc, - struct device *dev_dma) + const struct device *dev_dma) { size_t mem_block_size; int ret; @@ -694,7 +698,7 @@ static int tx_stream_start(struct stream *stream, Ssc *const ssc, } static void rx_stream_disable(struct stream *stream, Ssc *const ssc, - struct device *dev_dma) + const struct device *dev_dma) { ssc->SSC_CR = SSC_CR_RXDIS; ssc->SSC_IDR = SSC_IDR_OVRUN; @@ -706,7 +710,7 @@ static void rx_stream_disable(struct stream *stream, Ssc *const ssc, } static void tx_stream_disable(struct stream *stream, Ssc *const ssc, - struct device *dev_dma) + const struct device *dev_dma) { ssc->SSC_CR = SSC_CR_TXDIS; ssc->SSC_IDR = SSC_IDR_TXEMPTY; @@ -745,7 +749,7 @@ static void tx_queue_drop(struct stream *stream) } } -static int i2s_sam_trigger(struct device *dev, enum i2s_dir dir, +static int i2s_sam_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd) { const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); @@ -833,7 +837,8 @@ static int i2s_sam_trigger(struct device *dev, enum i2s_dir dir, return 0; } -static int i2s_sam_read(struct device *dev, void **mem_block, size_t *size) +static int i2s_sam_read(const struct device *dev, void **mem_block, + size_t *size) { struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); int ret; @@ -860,7 +865,8 @@ static int i2s_sam_read(struct device *dev, void **mem_block, size_t *size) return 0; } -static int i2s_sam_write(struct device *dev, void *mem_block, size_t size) +static int i2s_sam_write(const struct device *dev, void *mem_block, + size_t size) { struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); int ret; @@ -885,7 +891,7 @@ static int i2s_sam_write(struct device *dev, void *mem_block, size_t size) static void i2s_sam_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); Ssc *const ssc = dev_cfg->regs; @@ -910,7 +916,7 @@ static void i2s_sam_isr(void *arg) } } -static int i2s_sam_initialize(struct device *dev) +static int i2s_sam_initialize(const struct device *dev) { const struct i2s_sam_dev_cfg *const dev_cfg = DEV_CFG(dev); struct i2s_sam_dev_data *const dev_data = DEV_DATA(dev); @@ -959,7 +965,7 @@ static const struct i2s_driver_api i2s_sam_driver_api = { DEVICE_DECLARE(i2s0_sam); -static struct device *get_dev_from_dma_channel(uint32_t dma_channel) +static const struct device *get_dev_from_dma_channel(uint32_t dma_channel) { return &DEVICE_NAME_GET(i2s0_sam); } diff --git a/drivers/ieee802154/ieee802154_cc1200.c b/drivers/ieee802154/ieee802154_cc1200.c index d5bbe4ac64db87..2fbf3058a890a9 100644 --- a/drivers/ieee802154/ieee802154_cc1200.c +++ b/drivers/ieee802154/ieee802154_cc1200.c @@ -134,7 +134,7 @@ bool z_cc1200_access_reg(struct cc1200_context *ctx, bool read, uint8_t addr, return (spi_write(ctx->spi, &ctx->spi_cfg, &tx) == 0); } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -177,7 +177,7 @@ static uint8_t get_status(struct cc1200_context *ctx) * GPIO functions * *****************/ -static inline void gpio0_int_handler(struct device *port, +static inline void gpio0_int_handler(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct cc1200_context *cc1200 = @@ -209,7 +209,7 @@ static void enable_gpio0_interrupt(struct cc1200_context *cc1200, bool enable) enable ? GPIO_INT_EDGE_TO_ACTIVE : GPIO_INT_DISABLE); } -static void setup_gpio_callback(struct device *dev) +static void setup_gpio_callback(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -322,7 +322,7 @@ static uint32_t rf_evaluate_freq_setting(struct cc1200_context *ctx, uint32_t ch } static bool -rf_install_settings(struct device *dev, +rf_install_settings(const struct device *dev, const struct cc1200_rf_registers_set *rf_settings) { struct cc1200_context *cc1200 = dev->data; @@ -448,7 +448,7 @@ static inline bool verify_crc(struct cc1200_context *ctx, struct net_pkt *pkt) return true; } -static void cc1200_rx(struct device *dev) +static void cc1200_rx(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; struct net_pkt *pkt; @@ -518,12 +518,12 @@ static void cc1200_rx(struct device *dev) /******************** * Radio device API * *******************/ -static enum ieee802154_hw_caps cc1200_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps cc1200_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_SUB_GHZ; } -static int cc1200_cca(struct device *dev) +static int cc1200_cca(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -541,7 +541,7 @@ static int cc1200_cca(struct device *dev) return -EBUSY; } -static int cc1200_set_channel(struct device *dev, uint16_t channel) +static int cc1200_set_channel(const struct device *dev, uint16_t channel) { struct cc1200_context *cc1200 = dev->data; @@ -566,7 +566,7 @@ static int cc1200_set_channel(struct device *dev, uint16_t channel) return 0; } -static int cc1200_set_txpower(struct device *dev, int16_t dbm) +static int cc1200_set_txpower(const struct device *dev, int16_t dbm) { struct cc1200_context *cc1200 = dev->data; uint8_t pa_power_ramp; @@ -591,7 +591,7 @@ static int cc1200_set_txpower(struct device *dev, int16_t dbm) return 0; } -static int cc1200_tx(struct device *dev, +static int cc1200_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -665,7 +665,7 @@ static int cc1200_tx(struct device *dev, return status ? 0 : -EIO; } -static int cc1200_start(struct device *dev) +static int cc1200_start(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -684,7 +684,7 @@ static int cc1200_start(struct device *dev) return 0; } -static int cc1200_stop(struct device *dev) +static int cc1200_stop(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -698,7 +698,7 @@ static int cc1200_stop(struct device *dev) return 0; } -static uint16_t cc1200_get_channel_count(struct device *dev) +static uint16_t cc1200_get_channel_count(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -709,7 +709,7 @@ static uint16_t cc1200_get_channel_count(struct device *dev) * Initialization * *****************/ -static int power_on_and_setup(struct device *dev) +static int power_on_and_setup(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -734,10 +734,10 @@ static int power_on_and_setup(struct device *dev) return rf_calibrate(cc1200); } -static struct cc1200_gpio_configuration *configure_gpios(struct device *dev) +static struct cc1200_gpio_configuration *configure_gpios(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; - struct device *gpio = device_get_binding(DT_INST_GPIO_LABEL(0, int_gpios)); + const struct device *gpio = device_get_binding(DT_INST_GPIO_LABEL(0, int_gpios)); if (!gpio) { return NULL; @@ -751,7 +751,7 @@ static struct cc1200_gpio_configuration *configure_gpios(struct device *dev) return cc1200->gpios; } -static int configure_spi(struct device *dev) +static int configure_spi(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -787,7 +787,7 @@ static int configure_spi(struct device *dev) return 0; } -static int cc1200_init(struct device *dev) +static int cc1200_init(const struct device *dev) { struct cc1200_context *cc1200 = dev->data; @@ -827,7 +827,7 @@ static int cc1200_init(struct device *dev) static void cc1200_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct cc1200_context *cc1200 = dev->data; uint8_t *mac = get_mac(dev); diff --git a/drivers/ieee802154/ieee802154_cc1200.h b/drivers/ieee802154/ieee802154_cc1200.h index cc4cf50a167534..7bc0d99e9c3aaf 100644 --- a/drivers/ieee802154/ieee802154_cc1200.h +++ b/drivers/ieee802154/ieee802154_cc1200.h @@ -30,7 +30,7 @@ enum cc1200_gpio_index { }; struct cc1200_gpio_configuration { - struct device *dev; + const struct device *dev; uint32_t pin; }; @@ -43,7 +43,7 @@ struct cc1200_context { /**************************/ struct cc1200_gpio_configuration gpios[CC1200_GPIO_IDX_MAX]; struct gpio_callback rx_tx_cb; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; uint8_t mac_addr[8]; /************RF************/ diff --git a/drivers/ieee802154/ieee802154_cc13xx_cc26xx.c b/drivers/ieee802154/ieee802154_cc13xx_cc26xx.c index b0961ad4dff46f..d7968f48edfcf2 100644 --- a/drivers/ieee802154/ieee802154_cc13xx_cc26xx.c +++ b/drivers/ieee802154/ieee802154_cc13xx_cc26xx.c @@ -46,20 +46,20 @@ static uint32_t overrides[] = { static HwiP_Struct RF_hwiCpe0Obj; static inline struct ieee802154_cc13xx_cc26xx_data * -get_dev_data(struct device *dev) +get_dev_data(const struct device *dev) { return dev->data; } static enum ieee802154_hw_caps -ieee802154_cc13xx_cc26xx_get_capabilities(struct device *dev) +ieee802154_cc13xx_cc26xx_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ | IEEE802154_HW_FILTER | IEEE802154_HW_TX_RX_ACK | IEEE802154_HW_CSMA; } -static int ieee802154_cc13xx_cc26xx_cca(struct device *dev) +static int ieee802154_cc13xx_cc26xx_cca(const struct device *dev) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); uint32_t status; @@ -82,7 +82,7 @@ static int ieee802154_cc13xx_cc26xx_cca(struct device *dev) } } -static int ieee802154_cc13xx_cc26xx_set_channel(struct device *dev, +static int ieee802154_cc13xx_cc26xx_set_channel(const struct device *dev, uint16_t channel) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); @@ -116,7 +116,7 @@ static int ieee802154_cc13xx_cc26xx_set_channel(struct device *dev, } static int -ieee802154_cc13xx_cc26xx_filter(struct device *dev, bool set, +ieee802154_cc13xx_cc26xx_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) { @@ -141,7 +141,8 @@ ieee802154_cc13xx_cc26xx_filter(struct device *dev, bool set, return 0; } -static int ieee802154_cc13xx_cc26xx_set_txpower(struct device *dev, int16_t dbm) +static int ieee802154_cc13xx_cc26xx_set_txpower(const struct device *dev, + int16_t dbm) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); uint32_t status; @@ -192,7 +193,7 @@ static int ieee802154_cc13xx_cc26xx_set_txpower(struct device *dev, int16_t dbm) } /* See IEEE 802.15.4 section 6.2.5.1 and TRM section 25.5.4.3 */ -static int ieee802154_cc13xx_cc26xx_tx(struct device *dev, +static int ieee802154_cc13xx_cc26xx_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -272,7 +273,7 @@ static inline uint8_t ieee802154_cc13xx_cc26xx_convert_rssi(int8_t rssi) CC13XX_CC26XX_RSSI_DYNAMIC_RANGE; } -static void ieee802154_cc13xx_cc26xx_rx_done(struct device *dev) +static void ieee802154_cc13xx_cc26xx_rx_done(const struct device *dev) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); struct net_pkt *pkt; @@ -339,14 +340,14 @@ static void ieee802154_cc13xx_cc26xx_rx(void *arg1, void *arg2, void *arg3) } } -static int ieee802154_cc13xx_cc26xx_start(struct device *dev) +static int ieee802154_cc13xx_cc26xx_start(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int ieee802154_cc13xx_cc26xx_stop(struct device *dev) +static int ieee802154_cc13xx_cc26xx_stop(const struct device *dev) { ARG_UNUSED(dev); @@ -356,7 +357,7 @@ static int ieee802154_cc13xx_cc26xx_stop(struct device *dev) } static int -ieee802154_cc13xx_cc26xx_configure(struct device *dev, +ieee802154_cc13xx_cc26xx_configure(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config) { @@ -397,7 +398,7 @@ static void ieee802154_cc13xx_cc26xx_cpe1_isr(void *arg) } } -static void ieee802154_cc13xx_cc26xx_data_init(struct device *dev) +static void ieee802154_cc13xx_cc26xx_data_init(const struct device *dev) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); uint8_t *mac; @@ -441,7 +442,7 @@ static void ieee802154_cc13xx_cc26xx_data_init(struct device *dev) static void ieee802154_cc13xx_cc26xx_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); net_if_set_link_addr(iface, drv_data->mac, sizeof(drv_data->mac), @@ -466,7 +467,7 @@ static struct ieee802154_radio_api ieee802154_cc13xx_cc26xx_radio_api = { .configure = ieee802154_cc13xx_cc26xx_configure, }; -static int ieee802154_cc13xx_cc26xx_init(struct device *dev) +static int ieee802154_cc13xx_cc26xx_init(const struct device *dev) { struct ieee802154_cc13xx_cc26xx_data *drv_data = get_dev_data(dev); bool set_osc_hf; diff --git a/drivers/ieee802154/ieee802154_cc2520.c b/drivers/ieee802154/ieee802154_cc2520.c index 71dda74a10c3b4..a284cac4d3cf3f 100644 --- a/drivers/ieee802154/ieee802154_cc2520.c +++ b/drivers/ieee802154/ieee802154_cc2520.c @@ -67,7 +67,7 @@ static struct spi_cs_control cs_ctrl; * DEBUG * ********/ #if LOG_LEVEL == LOG_LEVEL_DBG -static inline void cc2520_print_gpio_config(struct device *dev) +static inline void cc2520_print_gpio_config(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -277,7 +277,7 @@ static bool verify_osc_stabilization(struct cc2520_context *cc2520) } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -302,7 +302,7 @@ static inline uint8_t *get_mac(struct device *dev) return cc2520->mac_addr; } -static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id) +static int cc2520_set_pan_id(const struct device *dev, uint16_t pan_id) { struct cc2520_context *cc2520 = dev->data; @@ -318,7 +318,8 @@ static int cc2520_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr) +static int cc2520_set_short_addr(const struct device *dev, + uint16_t short_addr) { struct cc2520_context *cc2520 = dev->data; @@ -334,7 +335,8 @@ static int cc2520_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int cc2520_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { struct cc2520_context *cc2520 = dev->data; @@ -353,7 +355,7 @@ static int cc2520_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) /****************** * GPIO functions * *****************/ -static inline void set_reset(struct device *dev, uint32_t value) +static inline void set_reset(const struct device *dev, uint32_t value) { struct cc2520_context *cc2520 = dev->data; @@ -361,7 +363,7 @@ static inline void set_reset(struct device *dev, uint32_t value) cc2520->gpios[CC2520_GPIO_IDX_RESET].pin, value); } -static inline void set_vreg_en(struct device *dev, uint32_t value) +static inline void set_vreg_en(const struct device *dev, uint32_t value) { struct cc2520_context *cc2520 = dev->data; @@ -399,7 +401,7 @@ static inline uint32_t get_cca(struct cc2520_context *cc2520) return pin_value; } -static inline void sfd_int_handler(struct device *port, +static inline void sfd_int_handler(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct cc2520_context *cc2520 = @@ -411,7 +413,7 @@ static inline void sfd_int_handler(struct device *port, } } -static inline void fifop_int_handler(struct device *port, +static inline void fifop_int_handler(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct cc2520_context *cc2520 = @@ -447,7 +449,7 @@ static void enable_sfd_interrupt(struct cc2520_context *cc2520, enable ? GPIO_INT_EDGE_TO_ACTIVE : GPIO_INT_DISABLE); } -static inline void setup_gpio_callbacks(struct device *dev) +static inline void setup_gpio_callbacks(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -607,7 +609,7 @@ static inline bool verify_rxfifo_validity(struct cc2520_context *ctx, static void cc2520_rx(int arg) { - struct device *dev = INT_TO_POINTER(arg); + const struct device *dev = INT_TO_POINTER(arg); struct cc2520_context *cc2520 = dev->data; struct net_pkt *pkt; uint8_t pkt_len; @@ -679,7 +681,7 @@ static void cc2520_rx(int arg) /******************** * Radio device API * *******************/ -static enum ieee802154_hw_caps cc2520_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps cc2520_get_capabilities(const struct device *dev) { /* ToDo: Add support for IEEE802154_HW_PROMISC */ return IEEE802154_HW_FCS | @@ -687,7 +689,7 @@ static enum ieee802154_hw_caps cc2520_get_capabilities(struct device *dev) IEEE802154_HW_FILTER; } -static int cc2520_cca(struct device *dev) +static int cc2520_cca(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -699,7 +701,7 @@ static int cc2520_cca(struct device *dev) return 0; } -static int cc2520_set_channel(struct device *dev, uint16_t channel) +static int cc2520_set_channel(const struct device *dev, uint16_t channel) { struct cc2520_context *cc2520 = dev->data; @@ -720,7 +722,7 @@ static int cc2520_set_channel(struct device *dev, uint16_t channel) return 0; } -static int cc2520_filter(struct device *dev, +static int cc2520_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) @@ -742,7 +744,7 @@ static int cc2520_filter(struct device *dev, return -ENOTSUP; } -static int cc2520_set_txpower(struct device *dev, int16_t dbm) +static int cc2520_set_txpower(const struct device *dev, int16_t dbm) { struct cc2520_context *cc2520 = dev->data; uint8_t pwr; @@ -792,7 +794,7 @@ static int cc2520_set_txpower(struct device *dev, int16_t dbm) return -EIO; } -static int cc2520_tx(struct device *dev, +static int cc2520_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -864,7 +866,7 @@ static int cc2520_tx(struct device *dev, return -EIO; } -static int cc2520_start(struct device *dev) +static int cc2520_start(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -883,7 +885,7 @@ static int cc2520_start(struct device *dev) return 0; } -static int cc2520_stop(struct device *dev) +static int cc2520_stop(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -904,7 +906,7 @@ static int cc2520_stop(struct device *dev) /****************** * Initialization * *****************/ -static int power_on_and_setup(struct device *dev) +static int power_on_and_setup(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -970,10 +972,10 @@ static int power_on_and_setup(struct device *dev) return 0; } -static struct cc2520_gpio_configuration *configure_gpios(struct device *dev) +static struct cc2520_gpio_configuration *configure_gpios(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; - struct device *gpio; + const struct device *gpio; /* VREG_EN */ gpio = device_get_binding(DT_INST_GPIO_LABEL(0, vreg_en_gpios)); @@ -1045,7 +1047,7 @@ static struct cc2520_gpio_configuration *configure_gpios(struct device *dev) } -static inline int configure_spi(struct device *dev) +static inline int configure_spi(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -1081,7 +1083,7 @@ static inline int configure_spi(struct device *dev) return 0; } -static int cc2520_init(struct device *dev) +static int cc2520_init(const struct device *dev) { struct cc2520_context *cc2520 = dev->data; @@ -1122,7 +1124,7 @@ static int cc2520_init(struct device *dev) static void cc2520_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct cc2520_context *cc2520 = dev->data; uint8_t *mac = get_mac(dev); @@ -1425,12 +1427,12 @@ static int cc2520_crypto_uccm(struct cipher_ctx *ctx, return 0; } -static int cc2520_crypto_hw_caps(struct device *dev) +static int cc2520_crypto_hw_caps(const struct device *dev) { return CAP_RAW_KEY | CAP_INPLACE_OPS | CAP_SYNC_OPS; } -static int cc2520_crypto_begin_session(struct device *dev, +static int cc2520_crypto_begin_session(const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, @@ -1459,7 +1461,7 @@ static int cc2520_crypto_begin_session(struct device *dev, return 0; } -static int cc2520_crypto_free_session(struct device *dev, +static int cc2520_crypto_free_session(const struct device *dev, struct cipher_ctx *ctx) { ARG_UNUSED(dev); @@ -1470,7 +1472,7 @@ static int cc2520_crypto_free_session(struct device *dev, return 0; } -static int cc2520_crypto_init(struct device *dev) +static int cc2520_crypto_init(const struct device *dev) { LOG_INF("CC2520 crypto part initialized"); diff --git a/drivers/ieee802154/ieee802154_cc2520.h b/drivers/ieee802154/ieee802154_cc2520.h index fd1c0d02c3bb90..0cdb0cd9380552 100644 --- a/drivers/ieee802154/ieee802154_cc2520.h +++ b/drivers/ieee802154/ieee802154_cc2520.h @@ -25,7 +25,7 @@ enum cc2520_gpio_index { }; struct cc2520_gpio_configuration { - struct device *dev; + const struct device *dev; uint32_t pin; }; @@ -38,7 +38,7 @@ struct cc2520_context { struct cc2520_gpio_configuration gpios[CC2520_GPIO_IDX_MAX]; struct gpio_callback sfd_cb; struct gpio_callback fifop_cb; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; uint8_t mac_addr[8]; /************TX************/ diff --git a/drivers/ieee802154/ieee802154_dw1000.c b/drivers/ieee802154/ieee802154_dw1000.c index 57a7df01f66d05..e2823c466a1103 100644 --- a/drivers/ieee802154/ieee802154_dw1000.c +++ b/drivers/ieee802154/ieee802154_dw1000.c @@ -110,9 +110,9 @@ struct dwt_hi_cfg { struct dwt_context { struct net_if *iface; - struct device *irq_gpio; - struct device *rst_gpio; - struct device *spi; + const struct device *irq_gpio; + const struct device *rst_gpio; + const struct device *spi; struct spi_cs_control spi_cs; struct spi_config *spi_cfg; struct spi_config spi_cfg_slow; @@ -626,7 +626,7 @@ static void dwt_irq_work_handler(struct k_work *item) k_sem_give(&ctx->dev_lock); } -static void dwt_gpio_callback(struct device *dev, +static void dwt_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct dwt_context *ctx = CONTAINER_OF(cb, struct dwt_context, gpio_cb); @@ -635,7 +635,7 @@ static void dwt_gpio_callback(struct device *dev, k_work_submit(&ctx->irq_cb_work); } -static enum ieee802154_hw_caps dwt_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps dwt_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ | /* FIXME: add IEEE802154_HW_UWB_PHY */ @@ -650,7 +650,7 @@ static uint32_t dwt_get_pkt_duration_ns(struct dwt_context *ctx, uint8_t psdu_le return (rf_cfg->t_shr + rf_cfg->t_phr + t_psdu); } -static int dwt_cca(struct device *dev) +static int dwt_cca(const struct device *dev) { struct dwt_context *ctx = dev->data; uint32_t cca_dur = (dwt_get_pkt_duration_ns(ctx, 127) + @@ -683,7 +683,7 @@ static int dwt_cca(struct device *dev) return ctx->cca_busy ? -EBUSY : 0; } -static int dwt_ed(struct device *dev, uint16_t duration, +static int dwt_ed(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb) { /* TODO: see description Sub-Register 0x23:02 – AGC_CTRL1 */ @@ -691,7 +691,7 @@ static int dwt_ed(struct device *dev, uint16_t duration, return -ENOTSUP; } -static int dwt_set_channel(struct device *dev, uint16_t channel) +static int dwt_set_channel(const struct device *dev, uint16_t channel) { struct dwt_context *ctx = dev->data; struct dwt_phy_config *rf_cfg = &ctx->rf_cfg; @@ -713,7 +713,7 @@ static int dwt_set_channel(struct device *dev, uint16_t channel) return 0; } -static int dwt_set_pan_id(struct device *dev, uint16_t pan_id) +static int dwt_set_pan_id(const struct device *dev, uint16_t pan_id) { struct dwt_context *ctx = dev->data; @@ -726,7 +726,7 @@ static int dwt_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int dwt_set_short_addr(struct device *dev, uint16_t short_addr) +static int dwt_set_short_addr(const struct device *dev, uint16_t short_addr) { struct dwt_context *ctx = dev->data; @@ -740,7 +740,8 @@ static int dwt_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int dwt_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int dwt_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { struct dwt_context *ctx = dev->data; @@ -756,7 +757,7 @@ static int dwt_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) return 0; } -static int dwt_filter(struct device *dev, +static int dwt_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) @@ -776,7 +777,7 @@ static int dwt_filter(struct device *dev, return -ENOTSUP; } -static int dwt_set_power(struct device *dev, int16_t dbm) +static int dwt_set_power(const struct device *dev, int16_t dbm) { struct dwt_context *ctx = dev->data; @@ -785,7 +786,7 @@ static int dwt_set_power(struct device *dev, int16_t dbm) return 0; } -static int dwt_tx(struct device *dev, enum ieee802154_tx_mode tx_mode, +static int dwt_tx(const struct device *dev, enum ieee802154_tx_mode tx_mode, struct net_pkt *pkt, struct net_buf *frag) { struct dwt_context *ctx = dev->data; @@ -915,7 +916,8 @@ static void dwt_set_frame_filter(struct dwt_context *ctx, dwt_reg_write_u8(ctx, DWT_SYS_CFG_ID, 0, (uint8_t)sys_cfg_ff); } -static int dwt_configure(struct device *dev, enum ieee802154_config_type type, +static int dwt_configure(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config) { struct dwt_context *ctx = dev->data; @@ -953,7 +955,7 @@ static int dwt_configure(struct device *dev, enum ieee802154_config_type type, /* * Note, the DW_RESET pin should not be driven high externally. */ -static int dwt_hw_reset(struct device *dev) +static int dwt_hw_reset(const struct device *dev) { struct dwt_context *ctx = dev->data; const struct dwt_hi_cfg *hi_cfg = dev->config; @@ -1018,7 +1020,7 @@ static void dwt_set_rx_mode(struct dwt_context *ctx) dwt_reg_write_u32(ctx, DWT_PMSC_ID, DWT_PMSC_CTRL0_OFFSET, pmsc_ctrl0); } -static int dwt_start(struct device *dev) +static int dwt_start(const struct device *dev) { struct dwt_context *ctx = dev->data; uint8_t cswakeup_buf[32] = {0}; @@ -1066,7 +1068,7 @@ static int dwt_start(struct device *dev) return 0; } -static int dwt_stop(struct device *dev) +static int dwt_stop(const struct device *dev) { struct dwt_context *ctx = dev->data; @@ -1487,7 +1489,7 @@ static int dwt_configure_rf_phy(struct dwt_context *ctx) return 0; } -static int dw1000_init(struct device *dev) +static int dw1000_init(const struct device *dev) { struct dwt_context *ctx = dev->data; const struct dwt_hi_cfg *hi_cfg = dev->config; @@ -1619,7 +1621,7 @@ static int dw1000_init(struct device *dev) return 0; } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct dwt_context *dw1000 = dev->data; uint32_t *ptr = (uint32_t *)(dw1000->mac_addr); @@ -1635,7 +1637,7 @@ static inline uint8_t *get_mac(struct device *dev) static void dwt_iface_api_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct dwt_context *dw1000 = dev->data; uint8_t *mac = get_mac(dev); diff --git a/drivers/ieee802154/ieee802154_kw41z.c b/drivers/ieee802154/ieee802154_kw41z.c index 731792d5bcbc30..929b610058c77b 100644 --- a/drivers/ieee802154/ieee802154_kw41z.c +++ b/drivers/ieee802154/ieee802154_kw41z.c @@ -356,7 +356,7 @@ static void kw41z_tmr3_disable(void) ZLL->IRQSTS = irqsts; } -static enum ieee802154_hw_caps kw41z_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps kw41z_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ | @@ -364,7 +364,7 @@ static enum ieee802154_hw_caps kw41z_get_capabilities(struct device *dev) IEEE802154_HW_TX_RX_ACK; } -static int kw41z_cca(struct device *dev) +static int kw41z_cca(const struct device *dev) { struct kw41z_context *kw41z = dev->data; @@ -383,7 +383,7 @@ static int kw41z_cca(struct device *dev) return kw41z->seq_retval; } -static int kw41z_set_channel(struct device *dev, uint16_t channel) +static int kw41z_set_channel(const struct device *dev, uint16_t channel) { if (channel < 11 || channel > 26) { return -EINVAL; @@ -393,7 +393,7 @@ static int kw41z_set_channel(struct device *dev, uint16_t channel) return 0; } -static int kw41z_set_pan_id(struct device *dev, uint16_t pan_id) +static int kw41z_set_pan_id(const struct device *dev, uint16_t pan_id) { ZLL->MACSHORTADDRS0 = (ZLL->MACSHORTADDRS0 & ~ZLL_MACSHORTADDRS0_MACPANID0_MASK) | @@ -401,7 +401,7 @@ static int kw41z_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int kw41z_set_short_addr(struct device *dev, uint16_t short_addr) +static int kw41z_set_short_addr(const struct device *dev, uint16_t short_addr) { ZLL->MACSHORTADDRS0 = (ZLL->MACSHORTADDRS0 & ~ZLL_MACSHORTADDRS0_MACSHORTADDRS0_MASK) | @@ -409,7 +409,8 @@ static int kw41z_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int kw41z_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int kw41z_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { uint32_t val; @@ -422,7 +423,7 @@ static int kw41z_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) return 0; } -static int kw41z_filter(struct device *dev, +static int kw41z_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) @@ -444,7 +445,7 @@ static int kw41z_filter(struct device *dev, return -ENOTSUP; } -static int kw41z_set_txpower(struct device *dev, int16_t dbm) +static int kw41z_set_txpower(const struct device *dev, int16_t dbm) { if (dbm < KW41Z_OUTPUT_POWER_MIN) { LOG_INF("TX-power %d dBm below min of %d dBm, using %d dBm", @@ -465,7 +466,7 @@ static int kw41z_set_txpower(struct device *dev, int16_t dbm) return 0; } -static int kw41z_start(struct device *dev) +static int kw41z_start(const struct device *dev) { irq_enable(Radio_1_IRQn); @@ -475,7 +476,7 @@ static int kw41z_start(struct device *dev) return 0; } -static int kw41z_stop(struct device *dev) +static int kw41z_stop(const struct device *dev) { irq_disable(Radio_1_IRQn); @@ -612,7 +613,7 @@ static void handle_ack(struct kw41z_context *kw41z, uint8_t seq_number) net_pkt_unref(ack_pkt); } -static int kw41z_tx(struct device *dev, enum ieee802154_tx_mode mode, +static int kw41z_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) { struct kw41z_context *kw41z = dev->data; @@ -924,7 +925,7 @@ static void kw41z_isr(int unused) } } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct kw41z_context *kw41z = dev->data; @@ -955,7 +956,7 @@ static inline uint8_t *get_mac(struct device *dev) return kw41z->mac_addr; } -static int kw41z_init(struct device *dev) +static int kw41z_init(const struct device *dev) { struct kw41z_context *kw41z = dev->data; xcvrStatus_t xcvrStatus; @@ -1062,7 +1063,7 @@ static int kw41z_init(struct device *dev) static void kw41z_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct kw41z_context *kw41z = dev->data; uint8_t *mac = get_mac(dev); @@ -1075,7 +1076,8 @@ static void kw41z_iface_init(struct net_if *iface) ieee802154_init(iface); } -static int kw41z_configure(struct device *dev, enum ieee802154_config_type type, +static int kw41z_configure(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config) { return 0; diff --git a/drivers/ieee802154/ieee802154_mcr20a.c b/drivers/ieee802154/ieee802154_mcr20a.c index a09871dbd0b266..93eab70f1bb27d 100644 --- a/drivers/ieee802154/ieee802154_mcr20a.c +++ b/drivers/ieee802154/ieee802154_mcr20a.c @@ -323,7 +323,7 @@ static int mcr20a_timer_set(struct mcr20a_context *mcr20a, return -EIO; } -static int mcr20a_timer_init(struct device *dev, uint8_t tb) +static int mcr20a_timer_init(const struct device *dev, uint8_t tb) { struct mcr20a_context *mcr20a = dev->data; uint8_t buf[3] = {0, 0, 0}; @@ -499,7 +499,7 @@ static inline uint32_t mcr20a_get_rssi(uint32_t lqi) return (a - (b * lqi)) >> 16; } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; uint32_t *ptr = (uint32_t *)(mcr20a->mac_addr); @@ -712,7 +712,7 @@ static inline bool irqsts3_event(struct mcr20a_context *mcr20a, static void mcr20a_thread_main(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct mcr20a_context *mcr20a = dev->data; uint8_t dregs[MCR20A_PHY_CTRL4 + 1]; bool set_new_seq; @@ -785,7 +785,7 @@ static void mcr20a_thread_main(void *arg) } } -static inline void irqb_int_handler(struct device *port, +static inline void irqb_int_handler(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct mcr20a_context *mcr20a = CONTAINER_OF(cb, @@ -814,7 +814,7 @@ static inline void setup_gpio_callbacks(struct mcr20a_context *mcr20a) gpio_add_callback(mcr20a->irq_gpio, &mcr20a->irqb_cb); } -static int mcr20a_set_cca_mode(struct device *dev, uint8_t mode) +static int mcr20a_set_cca_mode(const struct device *dev, uint8_t mode) { struct mcr20a_context *mcr20a = dev->data; uint8_t ctrl4; @@ -831,7 +831,7 @@ static int mcr20a_set_cca_mode(struct device *dev, uint8_t mode) return 0; } -static enum ieee802154_hw_caps mcr20a_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps mcr20a_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ | @@ -840,7 +840,7 @@ static enum ieee802154_hw_caps mcr20a_get_capabilities(struct device *dev) } /* Note: CCA before TX is enabled by default */ -static int mcr20a_cca(struct device *dev) +static int mcr20a_cca(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; int retval; @@ -888,7 +888,7 @@ static int mcr20a_cca(struct device *dev) return -EIO; } -static int mcr20a_set_channel(struct device *dev, uint16_t channel) +static int mcr20a_set_channel(const struct device *dev, uint16_t channel) { struct mcr20a_context *mcr20a = dev->data; uint8_t buf[3]; @@ -943,7 +943,7 @@ static int mcr20a_set_channel(struct device *dev, uint16_t channel) return retval; } -static int mcr20a_set_pan_id(struct device *dev, uint16_t pan_id) +static int mcr20a_set_pan_id(const struct device *dev, uint16_t pan_id) { struct mcr20a_context *mcr20a = dev->data; @@ -962,7 +962,8 @@ static int mcr20a_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int mcr20a_set_short_addr(struct device *dev, uint16_t short_addr) +static int mcr20a_set_short_addr(const struct device *dev, + uint16_t short_addr) { struct mcr20a_context *mcr20a = dev->data; @@ -981,7 +982,8 @@ static int mcr20a_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int mcr20a_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int mcr20a_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { struct mcr20a_context *mcr20a = dev->data; @@ -1001,7 +1003,7 @@ static int mcr20a_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) return 0; } -static int mcr20a_filter(struct device *dev, +static int mcr20a_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) @@ -1023,7 +1025,7 @@ static int mcr20a_filter(struct device *dev, return -ENOTSUP; } -static int mcr20a_set_txpower(struct device *dev, int16_t dbm) +static int mcr20a_set_txpower(const struct device *dev, int16_t dbm) { struct mcr20a_context *mcr20a = dev->data; uint8_t pwr; @@ -1082,7 +1084,7 @@ static inline bool write_txfifo_content(struct mcr20a_context *dev, return (spi_write(dev->spi, &dev->spi_cfg, &tx) == 0); } -static int mcr20a_tx(struct device *dev, +static int mcr20a_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -1145,7 +1147,7 @@ static int mcr20a_tx(struct device *dev, return -EIO; } -static int mcr20a_start(struct device *dev) +static int mcr20a_start(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; uint8_t timeout = 6U; @@ -1203,7 +1205,7 @@ static int mcr20a_start(struct device *dev) return -EIO; } -static int mcr20a_stop(struct device *dev) +static int mcr20a_stop(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; uint8_t power_mode; @@ -1267,7 +1269,7 @@ static int mcr20a_update_overwrites(struct mcr20a_context *dev) return -EIO; } -static int power_on_and_setup(struct device *dev) +static int power_on_and_setup(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; uint8_t timeout = 6U; @@ -1333,7 +1335,7 @@ static int power_on_and_setup(struct device *dev) } -static inline int configure_gpios(struct device *dev) +static inline int configure_gpios(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; @@ -1370,7 +1372,7 @@ static inline int configure_gpios(struct device *dev) return 0; } -static inline int configure_spi(struct device *dev) +static inline int configure_spi(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; @@ -1410,7 +1412,7 @@ static inline int configure_spi(struct device *dev) return 0; } -static int mcr20a_init(struct device *dev) +static int mcr20a_init(const struct device *dev) { struct mcr20a_context *mcr20a = dev->data; @@ -1447,7 +1449,7 @@ static int mcr20a_init(struct device *dev) static void mcr20a_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct mcr20a_context *mcr20a = dev->data; uint8_t *mac = get_mac(dev); diff --git a/drivers/ieee802154/ieee802154_mcr20a.h b/drivers/ieee802154/ieee802154_mcr20a.h index a5993f635a6783..43576186506b6a 100644 --- a/drivers/ieee802154/ieee802154_mcr20a.h +++ b/drivers/ieee802154/ieee802154_mcr20a.h @@ -20,10 +20,10 @@ struct mcr20a_context { struct net_if *iface; /**************************/ - struct device *irq_gpio; - struct device *reset_gpio; + const struct device *irq_gpio; + const struct device *reset_gpio; struct gpio_callback irqb_cb; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control cs_ctrl; diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 98c24b641dabfa..773ee6d7daa4c7 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -43,7 +43,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "nrf_802154.h" struct nrf5_802154_config { - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; static struct nrf5_802154_data nrf5_data; @@ -84,7 +84,7 @@ static void nrf5_get_eui64(uint8_t *mac) static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); struct net_pkt *pkt; struct nrf5_802154_rx_frame *rx_frame; @@ -172,7 +172,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3) /* Radio device API */ -static enum ieee802154_hw_caps nrf5_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps nrf5_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_FILTER | IEEE802154_HW_CSMA | IEEE802154_HW_2_4_GHZ | @@ -180,7 +180,7 @@ static enum ieee802154_hw_caps nrf5_get_capabilities(struct device *dev) IEEE802154_HW_SLEEP_TO_TX; } -static int nrf5_cca(struct device *dev) +static int nrf5_cca(const struct device *dev) { struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); @@ -199,7 +199,7 @@ static int nrf5_cca(struct device *dev) return nrf5_radio->channel_free ? 0 : -EBUSY; } -static int nrf5_set_channel(struct device *dev, uint16_t channel) +static int nrf5_set_channel(const struct device *dev, uint16_t channel) { ARG_UNUSED(dev); @@ -214,7 +214,7 @@ static int nrf5_set_channel(struct device *dev, uint16_t channel) return 0; } -static int nrf5_energy_scan_start(struct device *dev, +static int nrf5_energy_scan_start(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb) { @@ -236,7 +236,7 @@ static int nrf5_energy_scan_start(struct device *dev, return err; } -static int nrf5_set_pan_id(struct device *dev, uint16_t pan_id) +static int nrf5_set_pan_id(const struct device *dev, uint16_t pan_id) { uint8_t pan_id_le[2]; @@ -250,7 +250,7 @@ static int nrf5_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int nrf5_set_short_addr(struct device *dev, uint16_t short_addr) +static int nrf5_set_short_addr(const struct device *dev, uint16_t short_addr) { uint8_t short_addr_le[2]; @@ -264,7 +264,8 @@ static int nrf5_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int nrf5_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int nrf5_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { ARG_UNUSED(dev); @@ -277,7 +278,7 @@ static int nrf5_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) return 0; } -static int nrf5_filter(struct device *dev, bool set, +static int nrf5_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) { @@ -298,7 +299,7 @@ static int nrf5_filter(struct device *dev, bool set, return -ENOTSUP; } -static int nrf5_set_txpower(struct device *dev, int16_t dbm) +static int nrf5_set_txpower(const struct device *dev, int16_t dbm) { ARG_UNUSED(dev); @@ -352,7 +353,7 @@ static int handle_ack(struct nrf5_802154_data *nrf5_radio) return err; } -static void nrf5_tx_started(struct device *dev, +static void nrf5_tx_started(const struct device *dev, struct net_pkt *pkt, struct net_buf *frag) { @@ -364,7 +365,7 @@ static void nrf5_tx_started(struct device *dev, } } -static int nrf5_tx(struct device *dev, +static int nrf5_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -427,7 +428,7 @@ static int nrf5_tx(struct device *dev, return -EIO; } -static int nrf5_start(struct device *dev) +static int nrf5_start(const struct device *dev) { ARG_UNUSED(dev); @@ -442,7 +443,7 @@ static int nrf5_start(struct device *dev) return 0; } -static int nrf5_stop(struct device *dev) +static int nrf5_stop(const struct device *dev) { ARG_UNUSED(dev); @@ -465,7 +466,7 @@ static void nrf5_radio_irq(void *arg) } #endif -static void nrf5_irq_config(struct device *dev) +static void nrf5_irq_config(const struct device *dev) { ARG_UNUSED(dev); @@ -476,7 +477,7 @@ static void nrf5_irq_config(struct device *dev) #endif } -static int nrf5_init(struct device *dev) +static int nrf5_init(const struct device *dev) { const struct nrf5_802154_config *nrf5_radio_cfg = NRF5_802154_CFG(dev); struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); @@ -503,7 +504,7 @@ static int nrf5_init(struct device *dev) static void nrf5_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); nrf5_get_eui64(nrf5_radio->mac); @@ -515,7 +516,8 @@ static void nrf5_iface_init(struct net_if *iface) ieee802154_init(iface); } -static int nrf5_configure(struct device *dev, enum ieee802154_config_type type, +static int nrf5_configure(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config) { ARG_UNUSED(dev); diff --git a/drivers/ieee802154/ieee802154_rf2xx.c b/drivers/ieee802154/ieee802154_rf2xx.c index 29e3891bd12c4e..4a688f6468bf37 100644 --- a/drivers/ieee802154/ieee802154_rf2xx.c +++ b/drivers/ieee802154/ieee802154_rf2xx.c @@ -110,7 +110,7 @@ static const uint8_t phy_tx_pwr_lt[] = { }; /* Radio Transceiver ISR */ -static inline void trx_isr_handler(struct device *port, +static inline void trx_isr_handler(const struct device *port, struct gpio_callback *cb, uint32_t pins) { @@ -124,7 +124,7 @@ static inline void trx_isr_handler(struct device *port, k_sem_give(&ctx->trx_isr_lock); } -static void rf2xx_trx_set_state(struct device *dev, +static void rf2xx_trx_set_state(const struct device *dev, enum rf2xx_trx_state_cmd_t state) { do { @@ -141,7 +141,7 @@ static void rf2xx_trx_set_state(struct device *dev, RF2XX_TRX_PHY_STATUS_MASK)); } -static void rf2xx_trx_set_tx_state(struct device *dev) +static void rf2xx_trx_set_tx_state(const struct device *dev) { uint8_t status; @@ -165,7 +165,7 @@ static void rf2xx_trx_set_tx_state(struct device *dev) rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TX_ARET_ON); } -static void rf2xx_trx_set_rx_state(struct device *dev) +static void rf2xx_trx_set_rx_state(const struct device *dev) { rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_TRX_OFF); rf2xx_iface_reg_read(dev, RF2XX_IRQ_STATUS_REG); @@ -176,7 +176,7 @@ static void rf2xx_trx_set_rx_state(struct device *dev) rf2xx_trx_set_state(dev, RF2XX_TRX_PHY_STATE_CMD_RX_AACK_ON); } -static void rf2xx_trx_rx(struct device *dev) +static void rf2xx_trx_rx(const struct device *dev) { struct rf2xx_context *ctx = dev->data; struct net_pkt *pkt = NULL; @@ -254,7 +254,7 @@ static void rf2xx_trx_rx(struct device *dev) } } -static void rf2xx_process_rx_frame(struct device *dev) +static void rf2xx_process_rx_frame(const struct device *dev) { struct rf2xx_context *ctx = dev->data; @@ -278,7 +278,7 @@ static void rf2xx_process_rx_frame(struct device *dev) } } -static void rf2xx_process_tx_frame(struct device *dev) +static void rf2xx_process_tx_frame(const struct device *dev) { struct rf2xx_context *ctx = dev->data; @@ -288,7 +288,7 @@ static void rf2xx_process_tx_frame(struct device *dev) rf2xx_trx_set_rx_state(dev); } -static void rf2xx_process_trx_end(struct device *dev) +static void rf2xx_process_trx_end(const struct device *dev) { uint8_t trx_status = (rf2xx_iface_reg_read(dev, RF2XX_TRX_STATUS_REG) & RF2XX_TRX_PHY_STATUS_MASK); @@ -302,7 +302,7 @@ static void rf2xx_process_trx_end(struct device *dev) static void rf2xx_thread_main(void *arg) { - struct device *dev = INT_TO_POINTER(arg); + const struct device *dev = INT_TO_POINTER(arg); struct rf2xx_context *ctx = dev->data; uint8_t isr_status; @@ -347,7 +347,7 @@ static void rf2xx_thread_main(void *arg) } } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { const struct rf2xx_config *conf = dev->config; struct rf2xx_context *ctx = dev->data; @@ -369,7 +369,7 @@ static inline uint8_t *get_mac(struct device *dev) return ctx->mac_addr; } -static enum ieee802154_hw_caps rf2xx_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps rf2xx_get_capabilities(const struct device *dev) { ARG_UNUSED(dev); @@ -381,14 +381,14 @@ static enum ieee802154_hw_caps rf2xx_get_capabilities(struct device *dev) IEEE802154_HW_2_4_GHZ; } -static int rf2xx_cca(struct device *dev) +static int rf2xx_cca(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int rf2xx_set_channel(struct device *dev, uint16_t channel) +static int rf2xx_set_channel(const struct device *dev, uint16_t channel) { uint8_t reg; @@ -403,7 +403,7 @@ static int rf2xx_set_channel(struct device *dev, uint16_t channel) return 0; } -static int rf2xx_set_txpower(struct device *dev, int16_t dbm) +static int rf2xx_set_txpower(const struct device *dev, int16_t dbm) { if (dbm < RF2XX_OUTPUT_POWER_MIN) { LOG_INF("TX-power %d dBm below min of %d dBm, using %d dBm", @@ -425,7 +425,7 @@ static int rf2xx_set_txpower(struct device *dev, int16_t dbm) return 0; } -static int rf2xx_set_ieee_addr(struct device *dev, bool set, +static int rf2xx_set_ieee_addr(const struct device *dev, bool set, const uint8_t *ieee_addr) { const uint8_t *ptr_to_reg = ieee_addr; @@ -449,7 +449,7 @@ static int rf2xx_set_ieee_addr(struct device *dev, bool set, return 0; } -static int rf2xx_set_short_addr(struct device *dev, bool set, +static int rf2xx_set_short_addr(const struct device *dev, bool set, uint16_t short_addr) { uint8_t short_addr_le[2] = { 0xFF, 0xFF }; @@ -469,7 +469,8 @@ static int rf2xx_set_short_addr(struct device *dev, bool set, return 0; } -static int rf2xx_set_pan_id(struct device *dev, bool set, uint16_t pan_id) +static int rf2xx_set_pan_id(const struct device *dev, bool set, + uint16_t pan_id) { uint8_t pan_id_le[2] = { 0xFF, 0xFF }; @@ -485,7 +486,7 @@ static int rf2xx_set_pan_id(struct device *dev, bool set, uint16_t pan_id) return 0; } -static int rf2xx_filter(struct device *dev, +static int rf2xx_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) { @@ -526,7 +527,7 @@ static void rf2xx_handle_ack(struct rf2xx_context *ctx, struct net_buf *frag) #define rf2xx_handle_ack(...) #endif -static int rf2xx_tx(struct device *dev, +static int rf2xx_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -583,7 +584,7 @@ static int rf2xx_tx(struct device *dev, return response; } -static int rf2xx_start(struct device *dev) +static int rf2xx_start(const struct device *dev) { const struct rf2xx_config *conf = dev->config; struct rf2xx_context *ctx = dev->data; @@ -597,7 +598,7 @@ static int rf2xx_start(struct device *dev) return 0; } -static int rf2xx_stop(struct device *dev) +static int rf2xx_stop(const struct device *dev) { const struct rf2xx_config *conf = dev->config; struct rf2xx_context *ctx = dev->data; @@ -610,7 +611,8 @@ static int rf2xx_stop(struct device *dev) return 0; } -int rf2xx_configure(struct device *dev, enum ieee802154_config_type type, +int rf2xx_configure(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config) { ARG_UNUSED(dev); @@ -620,7 +622,7 @@ int rf2xx_configure(struct device *dev, enum ieee802154_config_type type, return 0; } -static int power_on_and_setup(struct device *dev) +static int power_on_and_setup(const struct device *dev) { const struct rf2xx_config *conf = dev->config; struct rf2xx_context *ctx = dev->data; @@ -690,7 +692,7 @@ static int power_on_and_setup(struct device *dev) return 0; } -static inline int configure_gpios(struct device *dev) +static inline int configure_gpios(const struct device *dev) { const struct rf2xx_config *conf = dev->config; struct rf2xx_context *ctx = dev->data; @@ -750,7 +752,7 @@ static inline int configure_gpios(struct device *dev) return 0; } -static inline int configure_spi(struct device *dev) +static inline int configure_spi(const struct device *dev) { struct rf2xx_context *ctx = dev->data; const struct rf2xx_config *conf = dev->config; @@ -793,7 +795,7 @@ static inline int configure_spi(struct device *dev) return 0; } -static int rf2xx_init(struct device *dev) +static int rf2xx_init(const struct device *dev) { struct rf2xx_context *ctx = dev->data; const struct rf2xx_config *conf = dev->config; @@ -837,7 +839,7 @@ static int rf2xx_init(struct device *dev) static void rf2xx_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct rf2xx_context *ctx = dev->data; uint8_t *mac = get_mac(dev); diff --git a/drivers/ieee802154/ieee802154_rf2xx.h b/drivers/ieee802154/ieee802154_rf2xx.h index 86d44f281e0e06..1701295dd6107c 100644 --- a/drivers/ieee802154/ieee802154_rf2xx.h +++ b/drivers/ieee802154/ieee802154_rf2xx.h @@ -103,13 +103,13 @@ struct rf2xx_config { struct rf2xx_context { struct net_if *iface; - struct device *irq_gpio; - struct device *reset_gpio; - struct device *slptr_gpio; - struct device *dig2_gpio; - struct device *clkm_gpio; + const struct device *irq_gpio; + const struct device *reset_gpio; + const struct device *slptr_gpio; + const struct device *dig2_gpio; + const struct device *clkm_gpio; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; struct spi_cs_control spi_cs; diff --git a/drivers/ieee802154/ieee802154_rf2xx_iface.c b/drivers/ieee802154/ieee802154_rf2xx_iface.c index c9ff4e107e0aeb..b2634feae8e243 100644 --- a/drivers/ieee802154/ieee802154_rf2xx_iface.c +++ b/drivers/ieee802154/ieee802154_rf2xx_iface.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "ieee802154_rf2xx_regs.h" #include "ieee802154_rf2xx_iface.h" -void rf2xx_iface_phy_rst(struct device *dev) +void rf2xx_iface_phy_rst(const struct device *dev) { const struct rf2xx_config *conf = dev->config; const struct rf2xx_context *ctx = dev->data; @@ -39,7 +39,7 @@ void rf2xx_iface_phy_rst(struct device *dev) k_busy_wait(10); gpio_pin_set(ctx->reset_gpio, conf->reset.pin, 0); } -void rf2xx_iface_phy_tx_start(struct device *dev) +void rf2xx_iface_phy_tx_start(const struct device *dev) { const struct rf2xx_config *conf = dev->config; const struct rf2xx_context *ctx = dev->data; @@ -52,8 +52,8 @@ void rf2xx_iface_phy_tx_start(struct device *dev) gpio_pin_set(ctx->slptr_gpio, conf->slptr.pin, 0); } -uint8_t rf2xx_iface_reg_read(struct device *dev, - uint8_t addr) +uint8_t rf2xx_iface_reg_read(const struct device *dev, + uint8_t addr) { const struct rf2xx_context *ctx = dev->data; uint8_t status; @@ -95,7 +95,7 @@ uint8_t rf2xx_iface_reg_read(struct device *dev, return regval; } -void rf2xx_iface_reg_write(struct device *dev, +void rf2xx_iface_reg_write(const struct device *dev, uint8_t addr, uint8_t data) { @@ -136,10 +136,10 @@ void rf2xx_iface_reg_write(struct device *dev, (addr & ~(RF2XX_RF_CMD_REG_W)), status, data); } -uint8_t rf2xx_iface_bit_read(struct device *dev, - uint8_t addr, - uint8_t mask, - uint8_t pos) +uint8_t rf2xx_iface_bit_read(const struct device *dev, + uint8_t addr, + uint8_t mask, + uint8_t pos) { uint8_t ret; @@ -150,7 +150,7 @@ uint8_t rf2xx_iface_bit_read(struct device *dev, return ret; } -void rf2xx_iface_bit_write(struct device *dev, +void rf2xx_iface_bit_write(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t pos, @@ -166,7 +166,7 @@ void rf2xx_iface_bit_write(struct device *dev, rf2xx_iface_reg_write(dev, reg_addr, new_value); } -void rf2xx_iface_frame_read(struct device *dev, +void rf2xx_iface_frame_read(const struct device *dev, uint8_t *data, uint8_t length) { @@ -198,7 +198,7 @@ void rf2xx_iface_frame_read(struct device *dev, LOG_HEXDUMP_DBG(data + RX2XX_FRAME_HEADER_SIZE, length, "payload"); } -void rf2xx_iface_frame_write(struct device *dev, +void rf2xx_iface_frame_write(const struct device *dev, uint8_t *data, uint8_t length) { @@ -249,7 +249,7 @@ void rf2xx_iface_frame_write(struct device *dev, LOG_HEXDUMP_DBG(data, length, "payload"); } -void rf2xx_iface_sram_read(struct device *dev, +void rf2xx_iface_sram_read(const struct device *dev, uint8_t address, uint8_t *data, uint8_t length) diff --git a/drivers/ieee802154/ieee802154_rf2xx_iface.h b/drivers/ieee802154/ieee802154_rf2xx_iface.h index dfd3a6e8556bbd..0befb663961baf 100644 --- a/drivers/ieee802154/ieee802154_rf2xx_iface.h +++ b/drivers/ieee802154/ieee802154_rf2xx_iface.h @@ -14,14 +14,14 @@ * * @param[in] dev Transceiver device instance */ -void rf2xx_iface_phy_rst(struct device *dev); +void rf2xx_iface_phy_rst(const struct device *dev); /** * @brief Start TX transmition * * @param[in] dev Transceiver device instance */ -void rf2xx_iface_phy_tx_start(struct device *dev); +void rf2xx_iface_phy_tx_start(const struct device *dev); /** * @brief Reads current value from a transceiver register @@ -34,8 +34,8 @@ void rf2xx_iface_phy_tx_start(struct device *dev); * * @return value of the register read */ -uint8_t rf2xx_iface_reg_read(struct device *dev, - uint8_t addr); +uint8_t rf2xx_iface_reg_read(const struct device *dev, + uint8_t addr); /** * @brief Writes data into a transceiver register @@ -47,7 +47,7 @@ uint8_t rf2xx_iface_reg_read(struct device *dev, * @param[in] data Data to be written to trx register * */ -void rf2xx_iface_reg_write(struct device *dev, +void rf2xx_iface_reg_write(const struct device *dev, uint8_t addr, uint8_t data); @@ -61,10 +61,10 @@ void rf2xx_iface_reg_write(struct device *dev, * * @return value of the read bit(s) */ -uint8_t rf2xx_iface_bit_read(struct device *dev, - uint8_t addr, - uint8_t mask, - uint8_t pos); +uint8_t rf2xx_iface_bit_read(const struct device *dev, + uint8_t addr, + uint8_t mask, + uint8_t pos); /** * @brief Subregister write @@ -75,7 +75,7 @@ uint8_t rf2xx_iface_bit_read(struct device *dev, * @param[in] pos Bit position of the subregister * @param[out] new_value Data, which is muxed into the register */ -void rf2xx_iface_bit_write(struct device *dev, +void rf2xx_iface_bit_write(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t pos, @@ -90,7 +90,7 @@ void rf2xx_iface_bit_write(struct device *dev, * @param[out] data Pointer to the location to store frame * @param[in] length Number of bytes to be read from the frame */ -void rf2xx_iface_frame_read(struct device *dev, +void rf2xx_iface_frame_read(const struct device *dev, uint8_t *data, uint8_t length); @@ -103,7 +103,7 @@ void rf2xx_iface_frame_read(struct device *dev, * @param[in] data Pointer to data to be written into frame buffer * @param[in] length Number of bytes to be written into frame buffer */ -void rf2xx_iface_frame_write(struct device *dev, +void rf2xx_iface_frame_write(const struct device *dev, uint8_t *data, uint8_t length); @@ -117,7 +117,7 @@ void rf2xx_iface_frame_write(struct device *dev, * @param[out] data Pointer to the location to store data * @param[in] length Number of bytes to be read from the sram space */ -void rf2xx_iface_sram_read(struct device *dev, +void rf2xx_iface_sram_read(const struct device *dev, uint8_t address, uint8_t *data, uint8_t length); diff --git a/drivers/ieee802154/ieee802154_uart_pipe.c b/drivers/ieee802154/ieee802154_uart_pipe.c index 07a1745bfa1a15..0b44f853acc7ab 100644 --- a/drivers/ieee802154/ieee802154_uart_pipe.c +++ b/drivers/ieee802154/ieee802154_uart_pipe.c @@ -47,7 +47,7 @@ static uint8_t dev_short_addr[SHORT_ADDRESS_SIZE]; /* Device Short Address */ static uint8_t dev_ext_addr[EXTENDED_ADDRESS_SIZE]; /* Device Extended Address */ /** Singleton device used in uart pipe callback */ -static struct device *upipe_dev; +static const struct device *upipe_dev; #if defined(CONFIG_IEEE802154_UPIPE_HW_FILTER) @@ -177,14 +177,14 @@ static uint8_t *upipe_rx(uint8_t *buf, size_t *off) return buf; } -static enum ieee802154_hw_caps upipe_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps upipe_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ | IEEE802154_HW_FILTER; } -static int upipe_cca(struct device *dev) +static int upipe_cca(const struct device *dev) { struct upipe_context *upipe = dev->data; @@ -195,7 +195,7 @@ static int upipe_cca(struct device *dev) return 0; } -static int upipe_set_channel(struct device *dev, uint16_t channel) +static int upipe_set_channel(const struct device *dev, uint16_t channel) { ARG_UNUSED(dev); ARG_UNUSED(channel); @@ -203,7 +203,7 @@ static int upipe_set_channel(struct device *dev, uint16_t channel) return 0; } -static int upipe_set_pan_id(struct device *dev, uint16_t pan_id) +static int upipe_set_pan_id(const struct device *dev, uint16_t pan_id) { uint8_t pan_id_le[2]; @@ -215,7 +215,7 @@ static int upipe_set_pan_id(struct device *dev, uint16_t pan_id) return 0; } -static int upipe_set_short_addr(struct device *dev, uint16_t short_addr) +static int upipe_set_short_addr(const struct device *dev, uint16_t short_addr) { uint8_t short_addr_le[2]; @@ -227,7 +227,8 @@ static int upipe_set_short_addr(struct device *dev, uint16_t short_addr) return 0; } -static int upipe_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) +static int upipe_set_ieee_addr(const struct device *dev, + const uint8_t *ieee_addr) { ARG_UNUSED(dev); @@ -236,7 +237,7 @@ static int upipe_set_ieee_addr(struct device *dev, const uint8_t *ieee_addr) return 0; } -static int upipe_filter(struct device *dev, +static int upipe_filter(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) @@ -258,7 +259,7 @@ static int upipe_filter(struct device *dev, return -ENOTSUP; } -static int upipe_set_txpower(struct device *dev, int16_t dbm) +static int upipe_set_txpower(const struct device *dev, int16_t dbm) { ARG_UNUSED(dev); ARG_UNUSED(dbm); @@ -266,7 +267,7 @@ static int upipe_set_txpower(struct device *dev, int16_t dbm) return 0; } -static int upipe_tx(struct device *dev, +static int upipe_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -300,7 +301,7 @@ static int upipe_tx(struct device *dev, return 0; } -static int upipe_start(struct device *dev) +static int upipe_start(const struct device *dev) { struct upipe_context *upipe = dev->data; @@ -313,7 +314,7 @@ static int upipe_start(struct device *dev) return 0; } -static int upipe_stop(struct device *dev) +static int upipe_stop(const struct device *dev) { struct upipe_context *upipe = dev->data; @@ -326,7 +327,7 @@ static int upipe_stop(struct device *dev) return 0; } -static int upipe_init(struct device *dev) +static int upipe_init(const struct device *dev) { struct upipe_context *upipe = dev->data; @@ -339,7 +340,7 @@ static int upipe_init(struct device *dev) return 0; } -static inline uint8_t *get_mac(struct device *dev) +static inline uint8_t *get_mac(const struct device *dev) { struct upipe_context *upipe = dev->data; @@ -363,7 +364,7 @@ static inline uint8_t *get_mac(struct device *dev) static void upipe_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct upipe_context *upipe = dev->data; uint8_t *mac = get_mac(dev); diff --git a/drivers/interrupt_controller/intc_arcv2_irq_unit.c b/drivers/interrupt_controller/intc_arcv2_irq_unit.c index bc0d1eb8be1a91..3d8a58e1251fd8 100644 --- a/drivers/interrupt_controller/intc_arcv2_irq_unit.c +++ b/drivers/interrupt_controller/intc_arcv2_irq_unit.c @@ -60,7 +60,7 @@ static struct arc_v2_irq_unit_ctx ctx; * * @return 0 for success */ -static int arc_v2_irq_unit_init(struct device *unused) +static int arc_v2_irq_unit_init(const struct device *unused) { ARG_UNUSED(unused); int irq; /* the interrupt index */ @@ -97,7 +97,7 @@ static int arc_v2_irq_unit_init(struct device *unused) * * @return 0 for success */ -static int arc_v2_irq_unit_suspend(struct device *dev) +static int arc_v2_irq_unit_suspend(const struct device *dev) { uint8_t irq; @@ -133,7 +133,7 @@ static int arc_v2_irq_unit_suspend(struct device *dev) * * @return 0 for success */ -static int arc_v2_irq_unit_resume(struct device *dev) +static int arc_v2_irq_unit_resume(const struct device *dev) { uint8_t irq; @@ -176,7 +176,7 @@ static int arc_v2_irq_unit_resume(struct device *dev) * * @return the power state of interrupt unit */ -static int arc_v2_irq_unit_get_state(struct device *dev) +static int arc_v2_irq_unit_get_state(const struct device *dev) { ARG_UNUSED(dev); @@ -191,8 +191,9 @@ static int arc_v2_irq_unit_get_state(struct device *dev) * * @return operation result */ -static int arc_v2_irq_unit_device_ctrl(struct device *device, - uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) +static int arc_v2_irq_unit_device_ctrl(const struct device *device, + uint32_t ctrl_command, void *context, + device_pm_cb cb, void *arg) { int ret = 0; unsigned int key = arch_irq_lock(); diff --git a/drivers/interrupt_controller/intc_cavs.c b/drivers/interrupt_controller/intc_cavs.c index 92f8829f0176af..90f6f1c8e07361 100644 --- a/drivers/interrupt_controller/intc_cavs.c +++ b/drivers/interrupt_controller/intc_cavs.c @@ -50,7 +50,7 @@ static ALWAYS_INLINE void cavs_ictl_dispatch_child_isrs(uint32_t intr_status, static void cavs_ictl_isr(void *arg) { - struct device *port = (struct device *)arg; + const struct device *port = (const struct device *)arg; struct cavs_ictl_runtime *context = port->data; const struct cavs_ictl_config *config = port->config; @@ -62,7 +62,8 @@ static void cavs_ictl_isr(void *arg) config->isr_table_offset); } -static inline void cavs_ictl_irq_enable(struct device *dev, unsigned int irq) +static inline void cavs_ictl_irq_enable(const struct device *dev, + unsigned int irq) { struct cavs_ictl_runtime *context = dev->data; @@ -72,7 +73,8 @@ static inline void cavs_ictl_irq_enable(struct device *dev, unsigned int irq) regs->enable_il = (1 << irq); } -static inline void cavs_ictl_irq_disable(struct device *dev, unsigned int irq) +static inline void cavs_ictl_irq_disable(const struct device *dev, + unsigned int irq) { struct cavs_ictl_runtime *context = dev->data; @@ -82,7 +84,7 @@ static inline void cavs_ictl_irq_disable(struct device *dev, unsigned int irq) regs->disable_il = (1 << irq); } -static inline unsigned int cavs_ictl_irq_get_state(struct device *dev) +static inline unsigned int cavs_ictl_irq_get_state(const struct device *dev) { struct cavs_ictl_runtime *context = dev->data; @@ -100,7 +102,8 @@ static inline unsigned int cavs_ictl_irq_get_state(struct device *dev) return 1; } -static int cavs_ictl_irq_get_line_state(struct device *dev, unsigned int irq) +static int cavs_ictl_irq_get_line_state(const struct device *dev, + unsigned int irq) { struct cavs_ictl_runtime *context = dev->data; diff --git a/drivers/interrupt_controller/intc_cavs.h b/drivers/interrupt_controller/intc_cavs.h index 3f8e62805040e4..fea54ced97a488 100644 --- a/drivers/interrupt_controller/intc_cavs.h +++ b/drivers/interrupt_controller/intc_cavs.h @@ -13,7 +13,7 @@ extern "C" { #endif -typedef void (*cavs_ictl_config_irq_t)(struct device *port); +typedef void (*cavs_ictl_config_irq_t)(const struct device *port); struct cavs_ictl_config { uint32_t irq_num; diff --git a/drivers/interrupt_controller/intc_dw.c b/drivers/interrupt_controller/intc_dw.c index dcdd476b109d69..d41c7763671178 100644 --- a/drivers/interrupt_controller/intc_dw.c +++ b/drivers/interrupt_controller/intc_dw.c @@ -33,7 +33,7 @@ static ALWAYS_INLINE void dw_ictl_dispatch_child_isrs(uint32_t intr_status, } } -static int dw_ictl_initialize(struct device *dev) +static int dw_ictl_initialize(const struct device *dev) { const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = @@ -48,7 +48,7 @@ static int dw_ictl_initialize(struct device *dev) static void dw_ictl_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = (struct dw_ictl_registers *)config->base_addr; @@ -62,7 +62,8 @@ static void dw_ictl_isr(void *arg) } } -static inline void dw_ictl_intr_enable(struct device *dev, unsigned int irq) +static inline void dw_ictl_intr_enable(const struct device *dev, + unsigned int irq) { const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = @@ -75,7 +76,8 @@ static inline void dw_ictl_intr_enable(struct device *dev, unsigned int irq) } } -static inline void dw_ictl_intr_disable(struct device *dev, unsigned int irq) +static inline void dw_ictl_intr_disable(const struct device *dev, + unsigned int irq) { const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = @@ -88,7 +90,7 @@ static inline void dw_ictl_intr_disable(struct device *dev, unsigned int irq) } } -static inline unsigned int dw_ictl_intr_get_state(struct device *dev) +static inline unsigned int dw_ictl_intr_get_state(const struct device *dev) { const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = @@ -106,7 +108,8 @@ static inline unsigned int dw_ictl_intr_get_state(struct device *dev) return 0; } -static int dw_ictl_intr_get_line_state(struct device *dev, unsigned int irq) +static int dw_ictl_intr_get_line_state(const struct device *dev, + unsigned int irq) { const struct dw_ictl_config *config = dev->config; volatile struct dw_ictl_registers * const regs = @@ -125,7 +128,7 @@ static int dw_ictl_intr_get_line_state(struct device *dev, unsigned int irq) return 0; } -static void dw_ictl_config_irq(struct device *dev); +static void dw_ictl_config_irq(const struct device *dev); static const struct dw_ictl_config dw_config = { .base_addr = DT_INST_REG_ADDR(0), @@ -145,7 +148,7 @@ DEVICE_AND_API_INIT(dw_ictl, DT_INST_LABEL(0), dw_ictl_initialize, NULL, &dw_config, PRE_KERNEL_1, CONFIG_DW_ICTL_INIT_PRIORITY, &dw_ictl_apis); -static void dw_ictl_config_irq(struct device *port) +static void dw_ictl_config_irq(const struct device *port) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/interrupt_controller/intc_dw.h b/drivers/interrupt_controller/intc_dw.h index 70c4bb12f0d514..682eae9b11ec9a 100644 --- a/drivers/interrupt_controller/intc_dw.h +++ b/drivers/interrupt_controller/intc_dw.h @@ -13,7 +13,7 @@ extern "C" { #endif -typedef void (*dw_ictl_config_irq_t)(struct device *dev); +typedef void (*dw_ictl_config_irq_t)(const struct device *dev); struct dw_ictl_config { uint32_t base_addr; diff --git a/drivers/interrupt_controller/intc_exti_stm32.c b/drivers/interrupt_controller/intc_exti_stm32.c index 12e74b8e9cca37..9a94453f55c15a 100644 --- a/drivers/interrupt_controller/intc_exti_stm32.c +++ b/drivers/interrupt_controller/intc_exti_stm32.c @@ -224,7 +224,7 @@ void stm32_exti_trigger(int line, int trigger) */ static void __stm32_exti_isr(int min, int max, void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct stm32_exti_data *data = dev->data; int line; @@ -390,12 +390,12 @@ static inline void __stm32_exti_isr_23(void *arg) #endif #endif /* CONFIG_SOC_SERIES_STM32F0X */ -static void __stm32_exti_connect_irqs(struct device *dev); +static void __stm32_exti_connect_irqs(const struct device *dev); /** * @brief initialize EXTI device driver */ -static int stm32_exti_init(struct device *dev) +static int stm32_exti_init(const struct device *dev) { __stm32_exti_connect_irqs(dev); @@ -412,7 +412,7 @@ DEVICE_INIT(exti_stm32, STM32_EXTI_NAME, stm32_exti_init, */ int stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *arg) { - struct device *dev = DEVICE_GET(exti_stm32); + const struct device *dev = DEVICE_GET(exti_stm32); struct stm32_exti_data *data = dev->data; if (data->cb[line].cb) { @@ -427,7 +427,7 @@ int stm32_exti_set_callback(int line, stm32_exti_callback_t cb, void *arg) void stm32_exti_unset_callback(int line) { - struct device *dev = DEVICE_GET(exti_stm32); + const struct device *dev = DEVICE_GET(exti_stm32); struct stm32_exti_data *data = dev->data; data->cb[line].cb = NULL; @@ -437,7 +437,7 @@ void stm32_exti_unset_callback(int line) /** * @brief connect all interrupts */ -static void __stm32_exti_connect_irqs(struct device *dev) +static void __stm32_exti_connect_irqs(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/interrupt_controller/intc_ioapic.c b/drivers/interrupt_controller/intc_ioapic.c index 77e0f4980d01e4..88e6c2009a3e70 100644 --- a/drivers/interrupt_controller/intc_ioapic.c +++ b/drivers/interrupt_controller/intc_ioapic.c @@ -120,7 +120,7 @@ static void IoApicRedUpdateLo(unsigned int irq, uint32_t value, * * @return N/A */ -int ioapic_init(struct device *unused) +int ioapic_init(const struct device *unused) { ARG_UNUSED(unused); @@ -237,7 +237,7 @@ uint32_t restore_flags(unsigned int irq) } -int ioapic_suspend(struct device *port) +int ioapic_suspend(const struct device *port) { int irq; uint32_t rte_lo; @@ -259,7 +259,7 @@ int ioapic_suspend(struct device *port) return 0; } -int ioapic_resume_from_suspend(struct device *port) +int ioapic_resume_from_suspend(const struct device *port) { int irq; uint32_t flags; @@ -293,7 +293,8 @@ int ioapic_resume_from_suspend(struct device *port) * Implements the driver control management functionality * the *context may include IN data or/and OUT data */ -static int ioapic_device_ctrl(struct device *device, uint32_t ctrl_command, +static int ioapic_device_ctrl(const struct device *device, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/interrupt_controller/intc_loapic.c b/drivers/interrupt_controller/intc_loapic.c index d9435cc6777626..ce1bce5cbc54b5 100644 --- a/drivers/interrupt_controller/intc_loapic.c +++ b/drivers/interrupt_controller/intc_loapic.c @@ -186,7 +186,7 @@ void z_loapic_enable(unsigned char cpu_number) * kernel runs through its device initializations, so this is unneeded. */ -static int loapic_init(struct device *unused) +static int loapic_init(const struct device *unused) { ARG_UNUSED(unused); return 0; @@ -333,7 +333,7 @@ int z_irq_controller_isr_vector_get(void) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int loapic_suspend(struct device *port) +static int loapic_suspend(const struct device *port) { volatile uint32_t lvt; /* local vector table entry value */ int loapic_irq; @@ -361,7 +361,7 @@ static int loapic_suspend(struct device *port) return 0; } -int loapic_resume(struct device *port) +int loapic_resume(const struct device *port) { int loapic_irq; @@ -394,7 +394,8 @@ int loapic_resume(struct device *port) * Implements the driver control management functionality * the *context may include IN data or/and OUT data */ -static int loapic_device_ctrl(struct device *port, uint32_t ctrl_command, +static int loapic_device_ctrl(const struct device *port, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/interrupt_controller/intc_miwu.c b/drivers/interrupt_controller/intc_miwu.c index 169a453d35050a..6672e7960a8eaf 100644 --- a/drivers/interrupt_controller/intc_miwu.c +++ b/drivers/interrupt_controller/intc_miwu.c @@ -60,7 +60,7 @@ LOG_MODULE_REGISTER(intc_miwu, LOG_LEVEL_ERR); /* MIWU module instances forward declaration */ -static struct device *miwu_devs[]; +static const struct device *miwu_devs[]; /* Driver config */ struct intc_miwu_config { @@ -257,7 +257,7 @@ void soc_miwu_init_gpio_callback(struct miwu_io_callback *callback, void soc_miwu_init_dev_callback(struct miwu_dev_callback *callback, const struct npcx_wui *dev_wui, miwu_dev_callback_handler_t handler, - struct device *source) + const struct device *source) { /* Initialize WUI and input device settings */ callback->wui.table = dev_wui->table; @@ -326,7 +326,7 @@ int soc_miwu_manage_dev_callback(struct miwu_dev_callback *cb, bool set) /* MIWU init function implementation */ #define NPCX_MIWU_INIT_FUNC_IMPL(inst) \ - static int intc_miwu_init##inst(struct device *dev) \ + static int intc_miwu_init##inst(const struct device *dev) \ { \ int i; \ uint32_t base = DRV_CONFIG(dev)->base; \ @@ -366,7 +366,7 @@ DT_INST_FOREACH_STATUS_OKAY(NPCX_MIWU_INIT) /* MIWU module instances */ #define NPCX_MIWU_DEV(inst) DEVICE_GET(intc_miwu_##inst), -static struct device *miwu_devs[] = { +static const struct device *miwu_devs[] = { DT_INST_FOREACH_STATUS_OKAY(NPCX_MIWU_DEV) }; diff --git a/drivers/interrupt_controller/intc_plic.c b/drivers/interrupt_controller/intc_plic.c index e930f2ef07f0c9..c729e3d3093c61 100644 --- a/drivers/interrupt_controller/intc_plic.c +++ b/drivers/interrupt_controller/intc_plic.c @@ -178,7 +178,7 @@ static void plic_irq_handler(void *arg) * @brief Initialize the Platform Level Interrupt Controller * @return N/A */ -static int plic_init(struct device *dev) +static int plic_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/interrupt_controller/intc_rv32m1_intmux.c b/drivers/interrupt_controller/intc_rv32m1_intmux.c index 8e59c47974b592..8c2a4a0b780624 100644 --- a/drivers/interrupt_controller/intc_rv32m1_intmux.c +++ b/drivers/interrupt_controller/intc_rv32m1_intmux.c @@ -56,7 +56,7 @@ DEVICE_DECLARE(intmux); * API */ -static void rv32m1_intmux_irq_enable(struct device *dev, uint32_t irq) +static void rv32m1_intmux_irq_enable(const struct device *dev, uint32_t irq) { INTMUX_Type *regs = DEV_REGS(dev); uint32_t channel = rv32m1_intmux_channel(irq); @@ -65,7 +65,7 @@ static void rv32m1_intmux_irq_enable(struct device *dev, uint32_t irq) regs->CHANNEL[channel].CHn_IER_31_0 |= BIT(line); } -static void rv32m1_intmux_irq_disable(struct device *dev, uint32_t irq) +static void rv32m1_intmux_irq_disable(const struct device *dev, uint32_t irq) { INTMUX_Type *regs = DEV_REGS(dev); uint32_t channel = rv32m1_intmux_channel(irq); @@ -74,7 +74,7 @@ static void rv32m1_intmux_irq_disable(struct device *dev, uint32_t irq) regs->CHANNEL[channel].CHn_IER_31_0 &= ~BIT(line); } -static uint32_t rv32m1_intmux_get_state(struct device *dev) +static uint32_t rv32m1_intmux_get_state(const struct device *dev) { INTMUX_Type *regs = DEV_REGS(dev); size_t i; @@ -88,7 +88,8 @@ static uint32_t rv32m1_intmux_get_state(struct device *dev) return 0; } -static int rv32m1_intmux_get_line_state(struct device *dev, unsigned int irq) +static int rv32m1_intmux_get_line_state(const struct device *dev, + unsigned int irq) { INTMUX_Type *regs = DEV_REGS(dev); uint32_t channel = rv32m1_intmux_channel(irq); @@ -110,7 +111,7 @@ static int rv32m1_intmux_get_line_state(struct device *dev, unsigned int irq) static void rv32m1_intmux_isr(void *arg) { - struct device *dev = DEVICE_GET(intmux); + const struct device *dev = DEVICE_GET(intmux); INTMUX_Type *regs = DEV_REGS(dev); uint32_t channel = POINTER_TO_UINT(arg); uint32_t line = (regs->CHANNEL[channel].CHn_VEC >> 2); @@ -151,11 +152,11 @@ static const struct rv32m1_intmux_config rv32m1_intmux_cfg = { .isr_base = &_sw_isr_table[CONFIG_2ND_LVL_ISR_TBL_OFFSET], }; -static int rv32m1_intmux_init(struct device *dev) +static int rv32m1_intmux_init(const struct device *dev) { const struct rv32m1_intmux_config *config = DEV_CFG(dev); INTMUX_Type *regs = DEV_REGS(dev); - struct device *clock_dev = device_get_binding(config->clock_name); + const struct device *clock_dev = device_get_binding(config->clock_name); size_t i; if (!clock_dev) { diff --git a/drivers/interrupt_controller/intc_sam0_eic.c b/drivers/interrupt_controller/intc_sam0_eic.c index ca365a59640eb3..e08cfe79bc294a 100644 --- a/drivers/interrupt_controller/intc_sam0_eic.c +++ b/drivers/interrupt_controller/intc_sam0_eic.c @@ -55,7 +55,7 @@ static inline void set_eic_enable(bool on) static void sam0_eic_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct sam0_eic_data *const dev_data = DEV_DATA(dev); uint16_t bits = EIC->INTFLAG.reg; uint32_t line_index; @@ -102,7 +102,7 @@ static void sam0_eic_isr(void *arg) int sam0_eic_acquire(int port, int pin, enum sam0_eic_trigger trigger, bool filter, sam0_eic_callback_t cb, void *data) { - struct device *dev = DEVICE_GET(sam0_eic); + const struct device *dev = DEVICE_GET(sam0_eic); struct sam0_eic_data *dev_data = dev->data; struct sam0_eic_port_data *port_data; struct sam0_eic_line_assignment *line_assignment; @@ -192,7 +192,7 @@ int sam0_eic_acquire(int port, int pin, enum sam0_eic_trigger trigger, static bool sam0_eic_check_ownership(int port, int pin, int line_index) { - struct device *dev = DEVICE_GET(sam0_eic); + const struct device *dev = DEVICE_GET(sam0_eic); struct sam0_eic_data *dev_data = dev->data; struct sam0_eic_line_assignment *line_assignment = &dev_data->lines[line_index]; @@ -211,7 +211,7 @@ static bool sam0_eic_check_ownership(int port, int pin, int line_index) int sam0_eic_release(int port, int pin) { - struct device *dev = DEVICE_GET(sam0_eic); + const struct device *dev = DEVICE_GET(sam0_eic); struct sam0_eic_data *dev_data = dev->data; uint32_t mask; int line_index; @@ -302,7 +302,7 @@ int sam0_eic_disable_interrupt(int port, int pin) uint32_t sam0_eic_interrupt_pending(int port) { - struct device *dev = DEVICE_GET(sam0_eic); + const struct device *dev = DEVICE_GET(sam0_eic); struct sam0_eic_data *dev_data = dev->data; struct sam0_eic_line_assignment *line_assignment; uint32_t set = EIC->INTFLAG.reg; @@ -338,7 +338,7 @@ uint32_t sam0_eic_interrupt_pending(int port) irq_enable(DT_INST_IRQ_BY_IDX(0, n, irq)); \ } while (0) -static int sam0_eic_init(struct device *dev) +static int sam0_eic_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/interrupt_controller/intc_shared_irq.c b/drivers/interrupt_controller/intc_shared_irq.c index addd2eccecb63b..5351b03db664d8 100644 --- a/drivers/interrupt_controller/intc_shared_irq.c +++ b/drivers/interrupt_controller/intc_shared_irq.c @@ -24,8 +24,8 @@ * @param isr_func Pointer to the ISR function for the device. * @param isr_dev Pointer to the device that will service the interrupt. */ -static int isr_register(struct device *dev, isr_t isr_func, - struct device *isr_dev) +static int isr_register(const struct device *dev, isr_t isr_func, + const struct device *isr_dev) { struct shared_irq_runtime *clients = dev->data; const struct shared_irq_config *config = dev->config; @@ -46,7 +46,8 @@ static int isr_register(struct device *dev, isr_t isr_func, * @param dev Pointer to device structure for SHARED_IRQ driver instance. * @param isr_dev Pointer to the device that will service the interrupt. */ -static inline int enable(struct device *dev, struct device *isr_dev) +static inline int enable(const struct device *dev, + const struct device *isr_dev) { struct shared_irq_runtime *clients = dev->data; const struct shared_irq_config *config = dev->config; @@ -78,7 +79,8 @@ static int last_enabled_isr(struct shared_irq_runtime *clients, int count) * @param dev Pointer to device structure for SHARED_IRQ driver instance. * @param isr_dev Pointer to the device that will service the interrupt. */ -static inline int disable(struct device *dev, struct device *isr_dev) +static inline int disable(const struct device *dev, + const struct device *isr_dev) { struct shared_irq_runtime *clients = dev->data; const struct shared_irq_config *config = dev->config; @@ -96,7 +98,7 @@ static inline int disable(struct device *dev, struct device *isr_dev) return -EIO; } -void shared_irq_isr(struct device *dev) +void shared_irq_isr(const struct device *dev) { struct shared_irq_runtime *clients = dev->data; const struct shared_irq_config *config = dev->config; @@ -116,7 +118,7 @@ static const struct shared_irq_driver_api api_funcs = { }; -int shared_irq_initialize(struct device *dev) +int shared_irq_initialize(const struct device *dev) { const struct shared_irq_config *config = dev->config; config->config(); diff --git a/drivers/interrupt_controller/intc_swerv_pic.c b/drivers/interrupt_controller/intc_swerv_pic.c index 87f51db15523af..6fe226d4cddf3f 100644 --- a/drivers/interrupt_controller/intc_swerv_pic.c +++ b/drivers/interrupt_controller/intc_swerv_pic.c @@ -141,7 +141,7 @@ static void swerv_pic_irq_handler(void *arg) swerv_pic_write(SWERV_PIC_meigwclr(irq), 0); } -static int swerv_pic_init(struct device *dev) +static int swerv_pic_init(const struct device *dev) { ARG_UNUSED(dev); int i; diff --git a/drivers/interrupt_controller/intc_vexriscv_litex.c b/drivers/interrupt_controller/intc_vexriscv_litex.c index bce4236510bc3a..599b19cde92669 100644 --- a/drivers/interrupt_controller/intc_vexriscv_litex.c +++ b/drivers/interrupt_controller/intc_vexriscv_litex.c @@ -113,7 +113,7 @@ int arch_irq_is_enabled(unsigned int irq) return vexriscv_litex_irq_getmask() & (1 << irq); } -static int vexriscv_litex_irq_init(struct device *dev) +static int vexriscv_litex_irq_init(const struct device *dev) { ARG_UNUSED(dev); __asm__ volatile ("csrrs x0, mie, %0" diff --git a/drivers/ipm/ipm_cavs_idc.c b/drivers/ipm/ipm_cavs_idc.c index 974c77df77fd97..8a9a82f25ef9d7 100644 --- a/drivers/ipm/ipm_cavs_idc.c +++ b/drivers/ipm/ipm_cavs_idc.c @@ -29,7 +29,7 @@ struct cavs_idc_data { DEVICE_DECLARE(cavs_idc); static struct cavs_idc_data cavs_idc_device_data; -static void cavs_idc_isr(struct device *dev) +static void cavs_idc_isr(const struct device *dev) { struct cavs_idc_data *drv_data = dev->data; @@ -84,7 +84,7 @@ static void cavs_idc_isr(struct device *dev) #endif } -static int cavs_idc_send(struct device *dev, int wait, uint32_t id, +static int cavs_idc_send(const struct device *dev, int wait, uint32_t id, const void *data, int size) { uint32_t curr_cpu_id = arch_curr_cpu()->id; @@ -134,7 +134,7 @@ static int cavs_idc_send(struct device *dev, int wait, uint32_t id, return 0; } -static int cavs_idc_max_data_size_get(struct device *dev) +static int cavs_idc_max_data_size_get(const struct device *dev) { ARG_UNUSED(dev); @@ -149,14 +149,15 @@ static int cavs_idc_max_data_size_get(struct device *dev) return 0; } -static uint32_t cavs_idc_max_id_val_get(struct device *dev) +static uint32_t cavs_idc_max_id_val_get(const struct device *dev) { ARG_UNUSED(dev); return IPM_CAVS_IDC_ID_MASK; } -static void cavs_idc_register_callback(struct device *dev, ipm_callback_t cb, +static void cavs_idc_register_callback(const struct device *dev, + ipm_callback_t cb, void *user_data) { struct cavs_idc_data *drv_data = dev->data; @@ -165,7 +166,7 @@ static void cavs_idc_register_callback(struct device *dev, ipm_callback_t cb, drv_data->user_data = user_data; } -static int cavs_idc_set_enabled(struct device *dev, int enable) +static int cavs_idc_set_enabled(const struct device *dev, int enable) { int i, j; uint32_t mask; @@ -201,7 +202,7 @@ static int cavs_idc_set_enabled(struct device *dev, int enable) return 0; } -static int cavs_idc_init(struct device *dev) +static int cavs_idc_init(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), @@ -227,7 +228,7 @@ DEVICE_AND_API_INIT(IPM_CAVS_IDC_DEV_NAME, &cavs_idc_driver_api); #ifdef CONFIG_SCHED_IPI_SUPPORTED -static int cavs_idc_smp_init(struct device *dev) +static int cavs_idc_smp_init(const struct device *dev) { /* Enable IDC for scheduler IPI */ cavs_idc_set_enabled(dev, 1); diff --git a/drivers/ipm/ipm_handlers.c b/drivers/ipm/ipm_handlers.c index 1261356e9b2886..938ff4db1544f1 100644 --- a/drivers/ipm/ipm_handlers.c +++ b/drivers/ipm/ipm_handlers.c @@ -7,33 +7,34 @@ #include #include -static inline int z_vrfy_ipm_send(struct device *dev, int wait, uint32_t id, - const void *data, int size) +static inline int z_vrfy_ipm_send(const struct device *dev, int wait, + uint32_t id, + const void *data, int size) { Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, send)); Z_OOPS(Z_SYSCALL_MEMORY_READ(data, size)); - return z_impl_ipm_send((struct device *)dev, wait, id, - (const void *)data, size); + return z_impl_ipm_send((const struct device *)dev, wait, id, + (const void *)data, size); } #include -static inline int z_vrfy_ipm_max_data_size_get(struct device *dev) +static inline int z_vrfy_ipm_max_data_size_get(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, max_data_size_get)); - return z_impl_max_data_size_get((struct device *)dev); + return z_impl_max_data_size_get((const struct device *)dev); } #include -static inline uint32_t z_vrfy_ipm_max_id_val_get(struct device *dev) +static inline uint32_t z_vrfy_ipm_max_id_val_get(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, max_id_val_get)); - return z_impl_ipm_max_id_val_get((struct device *)dev); + return z_impl_ipm_max_id_val_get((const struct device *)dev); } #include -static inline int z_vrfy_ipm_set_enabled(struct device *dev, int enable) +static inline int z_vrfy_ipm_set_enabled(const struct device *dev, int enable) { Z_OOPS(Z_SYSCALL_DRIVER_IPM(dev, set_enabled)); - return z_impl_ipm_set_enabled((struct device *)dev, enable); + return z_impl_ipm_set_enabled((const struct device *)dev, enable); } #include diff --git a/drivers/ipm/ipm_imx.c b/drivers/ipm/ipm_imx.c index c4105e6254c74f..cd28bda1ac5f38 100644 --- a/drivers/ipm/ipm_imx.c +++ b/drivers/ipm/ipm_imx.c @@ -23,7 +23,7 @@ struct imx_mu_config { MU_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct imx_mu_data { @@ -33,7 +33,7 @@ struct imx_mu_data { static void imx_mu_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct imx_mu_config *config = dev->config; MU_Type *base = MU(config); struct imx_mu_data *data = dev->data; @@ -87,7 +87,7 @@ static void imx_mu_isr(void *arg) #endif } -static int imx_mu_ipm_send(struct device *dev, int wait, uint32_t id, +static int imx_mu_ipm_send(const struct device *dev, int wait, uint32_t id, const void *data, int size) { const struct imx_mu_config *config = dev->config; @@ -124,21 +124,21 @@ static int imx_mu_ipm_send(struct device *dev, int wait, uint32_t id, return 0; } -static int imx_mu_ipm_max_data_size_get(struct device *dev) +static int imx_mu_ipm_max_data_size_get(const struct device *dev) { ARG_UNUSED(dev); return CONFIG_IPM_IMX_MAX_DATA_SIZE; } -static uint32_t imx_mu_ipm_max_id_val_get(struct device *dev) +static uint32_t imx_mu_ipm_max_id_val_get(const struct device *dev) { ARG_UNUSED(dev); return CONFIG_IPM_IMX_MAX_ID_VAL; } -static void imx_mu_ipm_register_callback(struct device *dev, +static void imx_mu_ipm_register_callback(const struct device *dev, ipm_callback_t cb, void *user_data) { @@ -148,7 +148,7 @@ static void imx_mu_ipm_register_callback(struct device *dev, driver_data->user_data = user_data; } -static int imx_mu_ipm_set_enabled(struct device *dev, int enable) +static int imx_mu_ipm_set_enabled(const struct device *dev, int enable) { const struct imx_mu_config *config = dev->config; MU_Type *base = MU(config); @@ -186,7 +186,7 @@ static int imx_mu_ipm_set_enabled(struct device *dev, int enable) return 0; } -static int imx_mu_init(struct device *dev) +static int imx_mu_init(const struct device *dev) { const struct imx_mu_config *config = dev->config; @@ -206,7 +206,7 @@ static const struct ipm_driver_api imx_mu_driver_api = { /* Config MU */ -static void imx_mu_config_func_b(struct device *dev); +static void imx_mu_config_func_b(const struct device *dev); static const struct imx_mu_config imx_mu_b_config = { .base = (MU_Type *)DT_INST_REG_ADDR(0), @@ -221,7 +221,7 @@ DEVICE_AND_API_INIT(mu_b, DT_INST_LABEL(0), PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &imx_mu_driver_api); -static void imx_mu_config_func_b(struct device *dev) +static void imx_mu_config_func_b(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/ipm/ipm_intel_adsp.c b/drivers/ipm/ipm_intel_adsp.c index cf664102872ac6..775c0b561cdfe8 100644 --- a/drivers/ipm/ipm_intel_adsp.c +++ b/drivers/ipm/ipm_intel_adsp.c @@ -37,7 +37,7 @@ BUILD_ASSERT(IPM_INTEL_ADSP_MAILBOX_OUT_SIZE >= IPM_INTEL_ADSP_MAX_DATA_SIZE); BUILD_ASSERT(IPM_INTEL_ADSP_MAILBOX_IN_SIZE >= IPM_INTEL_ADSP_MAX_DATA_SIZE); struct ipm_adsp_config { - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct ipm_adsp_data { @@ -47,7 +47,7 @@ struct ipm_adsp_data { static void ipm_adsp_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct ipm_adsp_data *data = dev->data; uint32_t dipcctl, dipcie, dipct; @@ -108,7 +108,7 @@ static void ipm_adsp_isr(void *arg) } } -static int ipm_adsp_send(struct device *dev, int wait, uint32_t id, +static int ipm_adsp_send(const struct device *dev, int wait, uint32_t id, const void *data, int size) { LOG_DBG("Send: id %d data %p size %d", id, data, size); @@ -141,7 +141,7 @@ static int ipm_adsp_send(struct device *dev, int wait, uint32_t id, return 0; } -static void ipm_adsp_register_callback(struct device *dev, +static void ipm_adsp_register_callback(const struct device *dev, ipm_callback_t cb, void *user_data) { @@ -151,7 +151,7 @@ static void ipm_adsp_register_callback(struct device *dev, data->user_data = user_data; } -static int ipm_adsp_max_data_size_get(struct device *dev) +static int ipm_adsp_max_data_size_get(const struct device *dev) { ARG_UNUSED(dev); @@ -160,7 +160,7 @@ static int ipm_adsp_max_data_size_get(struct device *dev) return IPM_INTEL_ADSP_MAX_DATA_SIZE; } -static uint32_t ipm_adsp_max_id_val_get(struct device *dev) +static uint32_t ipm_adsp_max_id_val_get(const struct device *dev) { ARG_UNUSED(dev); @@ -169,7 +169,7 @@ static uint32_t ipm_adsp_max_id_val_get(struct device *dev) return IPM_INTEL_ADSP_MAX_ID_VAL; } -static int ipm_adsp_set_enabled(struct device *dev, int enable) +static int ipm_adsp_set_enabled(const struct device *dev, int enable) { LOG_DBG("dev %p", dev); @@ -179,7 +179,7 @@ static int ipm_adsp_set_enabled(struct device *dev, int enable) return 0; } -static int ipm_adsp_init(struct device *dev) +static int ipm_adsp_init(const struct device *dev) { const struct ipm_adsp_config *config = dev->config; @@ -198,7 +198,7 @@ static const struct ipm_driver_api ipm_adsp_driver_api = { .set_enabled = ipm_adsp_set_enabled, }; -static void ipm_adsp_config_func(struct device *dev); +static void ipm_adsp_config_func(const struct device *dev); static const struct ipm_adsp_config ipm_adsp_config = { .irq_config_func = ipm_adsp_config_func, @@ -212,7 +212,7 @@ DEVICE_AND_API_INIT(ipm_adsp, DT_INST_LABEL(0), PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &ipm_adsp_driver_api); -static void ipm_adsp_config_func(struct device *dev) +static void ipm_adsp_config_func(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/ipm/ipm_mcux.c b/drivers/ipm/ipm_mcux.c index 3140e25eb9a234..9d37a62e848612 100644 --- a/drivers/ipm/ipm_mcux.c +++ b/drivers/ipm/ipm_mcux.c @@ -26,7 +26,7 @@ struct mcux_mailbox_config { MAILBOX_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_mailbox_data { @@ -36,7 +36,7 @@ struct mcux_mailbox_data { static void mcux_mailbox_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mcux_mailbox_data *data = dev->data; const struct mcux_mailbox_config *config = dev->config; mailbox_cpu_id_t cpu_id; @@ -64,8 +64,9 @@ static void mcux_mailbox_isr(void *arg) } -static int mcux_mailbox_ipm_send(struct device *d, int wait, uint32_t id, - const void *data, int size) +static int mcux_mailbox_ipm_send(const struct device *d, int wait, + uint32_t id, + const void *data, int size) { const struct mcux_mailbox_config *config = d->config; MAILBOX_Type *base = config->base; @@ -100,7 +101,7 @@ static int mcux_mailbox_ipm_send(struct device *d, int wait, uint32_t id, } -static int mcux_mailbox_ipm_max_data_size_get(struct device *d) +static int mcux_mailbox_ipm_max_data_size_get(const struct device *d) { ARG_UNUSED(d); /* Only a single 32-bit register available */ @@ -108,14 +109,14 @@ static int mcux_mailbox_ipm_max_data_size_get(struct device *d) } -static uint32_t mcux_mailbox_ipm_max_id_val_get(struct device *d) +static uint32_t mcux_mailbox_ipm_max_id_val_get(const struct device *d) { ARG_UNUSED(d); /* Only a single instance of MAILBOX available for this platform */ return MCUX_IPM_MAX_ID_VAL; } -static void mcux_mailbox_ipm_register_callback(struct device *d, +static void mcux_mailbox_ipm_register_callback(const struct device *d, ipm_callback_t cb, void *context) { @@ -126,14 +127,14 @@ static void mcux_mailbox_ipm_register_callback(struct device *d, } -static int mcux_mailbox_ipm_set_enabled(struct device *d, int enable) +static int mcux_mailbox_ipm_set_enabled(const struct device *d, int enable) { /* For now: nothing to be done */ return 0; } -static int mcux_mailbox_init(struct device *dev) +static int mcux_mailbox_init(const struct device *dev) { const struct mcux_mailbox_config *config = dev->config; @@ -153,7 +154,7 @@ static const struct ipm_driver_api mcux_mailbox_driver_api = { /* Config MAILBOX 0 */ -static void mcux_mailbox_config_func_0(struct device *dev); +static void mcux_mailbox_config_func_0(const struct device *dev); static const struct mcux_mailbox_config mcux_mailbox_0_config = { .base = (MAILBOX_Type *)DT_INST_REG_ADDR(0), @@ -169,7 +170,7 @@ DEVICE_AND_API_INIT(mailbox_0, DT_INST_LABEL(0), &mcux_mailbox_driver_api); -static void mcux_mailbox_config_func_0(struct device *dev) +static void mcux_mailbox_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/ipm/ipm_mhu.c b/drivers/ipm/ipm_mhu.c index 4ece426b26e2e4..c9d3aeeecd192c 100644 --- a/drivers/ipm/ipm_mhu.c +++ b/drivers/ipm/ipm_mhu.c @@ -57,7 +57,7 @@ static uint32_t ipm_mhu_get_status(const struct device *d, return IPM_MHU_ERR_NONE; } -static int ipm_mhu_send(struct device *d, int wait, uint32_t cpu_id, +static int ipm_mhu_send(const struct device *d, int wait, uint32_t cpu_id, const void *data, int size) { ARG_UNUSED(wait); @@ -108,14 +108,14 @@ static void ipm_mhu_clear_val(const struct device *d, } } -static uint32_t ipm_mhu_max_id_val_get(struct device *d) +static uint32_t ipm_mhu_max_id_val_get(const struct device *d) { ARG_UNUSED(d); return IPM_MHU_MAX_ID_VAL; } -static int ipm_mhu_init(struct device *d) +static int ipm_mhu_init(const struct device *d) { const struct ipm_mhu_device_config *config = DEV_CFG(d); @@ -126,7 +126,7 @@ static int ipm_mhu_init(struct device *d) static void ipm_mhu_isr(void *arg) { - struct device *d = arg; + const struct device *d = arg; struct ipm_mhu_data *driver_data = DEV_DATA(d); enum ipm_mhu_cpu_id_t cpu_id; uint32_t ipm_mhu_status; @@ -142,21 +142,21 @@ static void ipm_mhu_isr(void *arg) } } -static int ipm_mhu_set_enabled(struct device *d, int enable) +static int ipm_mhu_set_enabled(const struct device *d, int enable) { ARG_UNUSED(d); ARG_UNUSED(enable); return 0; } -static int ipm_mhu_max_data_size_get(struct device *d) +static int ipm_mhu_max_data_size_get(const struct device *d) { ARG_UNUSED(d); return IPM_MHU_MAX_DATA_SIZE; } -static void ipm_mhu_register_cb(struct device *d, +static void ipm_mhu_register_cb(const struct device *d, ipm_callback_t cb, void *user_data) { @@ -174,7 +174,7 @@ static const struct ipm_driver_api ipm_mhu_driver_api = { .set_enabled = ipm_mhu_set_enabled, }; -static void ipm_mhu_irq_config_func_0(struct device *d); +static void ipm_mhu_irq_config_func_0(const struct device *d); static const struct ipm_mhu_device_config ipm_mhu_cfg_0 = { .base = (uint8_t *)DT_INST_REG_ADDR(0), @@ -194,7 +194,7 @@ DEVICE_AND_API_INIT(mhu_0, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &ipm_mhu_driver_api); -static void ipm_mhu_irq_config_func_0(struct device *d) +static void ipm_mhu_irq_config_func_0(const struct device *d) { ARG_UNUSED(d); IRQ_CONNECT(DT_INST_IRQN(0), @@ -205,7 +205,7 @@ static void ipm_mhu_irq_config_func_0(struct device *d) irq_enable(DT_INST_IRQN(0)); } -static void ipm_mhu_irq_config_func_1(struct device *d); +static void ipm_mhu_irq_config_func_1(const struct device *d); static const struct ipm_mhu_device_config ipm_mhu_cfg_1 = { .base = (uint8_t *)DT_INST_REG_ADDR(1), @@ -225,7 +225,7 @@ DEVICE_AND_API_INIT(mhu_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &ipm_mhu_driver_api); -static void ipm_mhu_irq_config_func_1(struct device *d) +static void ipm_mhu_irq_config_func_1(const struct device *d) { ARG_UNUSED(d); IRQ_CONNECT(DT_INST_IRQN(1), diff --git a/drivers/ipm/ipm_mhu.h b/drivers/ipm/ipm_mhu.h index 56340b4851c517..6ebd6b25b3c6fa 100644 --- a/drivers/ipm/ipm_mhu.h +++ b/drivers/ipm/ipm_mhu.h @@ -59,7 +59,7 @@ enum ipm_mhu_cpu_id_t { struct ipm_mhu_device_config { uint8_t *base; - void (*irq_config_func)(struct device *d); + void (*irq_config_func)(const struct device *d); }; /* Device data structure */ diff --git a/drivers/ipm/ipm_nrfx_ipc.c b/drivers/ipm/ipm_nrfx_ipc.c index c0f93cec782fc7..8ffeb320346f97 100644 --- a/drivers/ipm/ipm_nrfx_ipc.c +++ b/drivers/ipm/ipm_nrfx_ipc.c @@ -46,7 +46,7 @@ static void nrfx_ipc_handler(uint32_t event_mask, void *p_context) } } -static int ipm_nrf_send(struct device *dev, int wait, uint32_t id, +static int ipm_nrf_send(const struct device *dev, int wait, uint32_t id, const void *data, int size) { if (id > NRFX_IPC_ID_MAX_VALUE) { @@ -61,21 +61,21 @@ static int ipm_nrf_send(struct device *dev, int wait, uint32_t id, return 0; } -static int ipm_nrf_max_data_size_get(struct device *dev) +static int ipm_nrf_max_data_size_get(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static uint32_t ipm_nrf_max_id_val_get(struct device *dev) +static uint32_t ipm_nrf_max_id_val_get(const struct device *dev) { ARG_UNUSED(dev); return NRFX_IPC_ID_MAX_VALUE; } -static void ipm_nrf_register_callback(struct device *dev, +static void ipm_nrf_register_callback(const struct device *dev, ipm_callback_t cb, void *user_data) { @@ -83,7 +83,7 @@ static void ipm_nrf_register_callback(struct device *dev, nrfx_ipm_data.user_data = user_data; } -static int ipm_nrf_set_enabled(struct device *dev, int enable) +static int ipm_nrf_set_enabled(const struct device *dev, int enable) { /* Enable configured channels */ if (enable) { @@ -96,7 +96,7 @@ static int ipm_nrf_set_enabled(struct device *dev, int enable) return 0; } -static int ipm_nrf_init(struct device *dev) +static int ipm_nrf_init(const struct device *dev) { gipm_init(); return 0; @@ -120,7 +120,7 @@ DEVICE_AND_API_INIT(ipm_nrf, DT_INST_LABEL(0), struct vipm_nrf_data { ipm_callback_t callback[NRFX_IPC_ID_MAX_VALUE]; void *user_data[NRFX_IPC_ID_MAX_VALUE]; - struct device *ipm_device[NRFX_IPC_ID_MAX_VALUE]; + const struct device *ipm_device[NRFX_IPC_ID_MAX_VALUE]; bool ipm_init; }; @@ -144,19 +144,19 @@ static void vipm_dispatcher(uint32_t event_mask, void *p_context) } } -static int vipm_nrf_max_data_size_get(struct device *dev) +static int vipm_nrf_max_data_size_get(const struct device *dev) { return ipm_max_data_size_get(dev); } -static uint32_t vipm_nrf_max_id_val_get(struct device *dev) +static uint32_t vipm_nrf_max_id_val_get(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int vipm_nrf_init(struct device *dev) +static int vipm_nrf_init(const struct device *dev) { if (!nrfx_vipm_data.ipm_init) { gipm_init(); diff --git a/drivers/ipm/ipm_stm32_ipcc.c b/drivers/ipm/ipm_stm32_ipcc.c index 7d0d5c7f77ae39..0556c33d1453c4 100644 --- a/drivers/ipm/ipm_stm32_ipcc.c +++ b/drivers/ipm/ipm_stm32_ipcc.c @@ -88,7 +88,7 @@ LOG_MODULE_REGISTER(ipm_stm32_ipcc, CONFIG_IPM_LOG_LEVEL); #endif struct stm32_ipcc_mailbox_config { - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); IPCC_TypeDef *ipcc; struct stm32_pclken pclken; }; @@ -103,7 +103,7 @@ static struct stm32_ipcc_mbx_data stm32_IPCC_data; static void stm32_ipcc_mailbox_rx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct stm32_ipcc_mbx_data *data = DEV_DATA(dev); const struct stm32_ipcc_mailbox_config *cfg = DEV_CFG(dev); unsigned int value = 0; @@ -132,7 +132,7 @@ static void stm32_ipcc_mailbox_rx_isr(void *arg) static void stm32_ipcc_mailbox_tx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct stm32_ipcc_mbx_data *data = DEV_DATA(dev); const struct stm32_ipcc_mailbox_config *cfg = DEV_CFG(dev); uint32_t mask, i; @@ -152,7 +152,8 @@ static void stm32_ipcc_mailbox_tx_isr(void *arg) } } -static int stm32_ipcc_mailbox_ipm_send(struct device *dev, int wait, uint32_t id, +static int stm32_ipcc_mailbox_ipm_send(const struct device *dev, int wait, + uint32_t id, const void *buff, int size) { struct stm32_ipcc_mbx_data *data = dev->data; @@ -186,7 +187,7 @@ static int stm32_ipcc_mailbox_ipm_send(struct device *dev, int wait, uint32_t id return 0; } -static int stm32_ipcc_mailbox_ipm_max_data_size_get(struct device *dev) +static int stm32_ipcc_mailbox_ipm_max_data_size_get(const struct device *dev) { ARG_UNUSED(dev); @@ -194,14 +195,14 @@ static int stm32_ipcc_mailbox_ipm_max_data_size_get(struct device *dev) return 0; } -static uint32_t stm32_ipcc_mailbox_ipm_max_id_val_get(struct device *d) +static uint32_t stm32_ipcc_mailbox_ipm_max_id_val_get(const struct device *d) { struct stm32_ipcc_mbx_data *data = DEV_DATA(d); return data->num_ch - 1; } -static void stm32_ipcc_mailbox_ipm_register_callback(struct device *d, +static void stm32_ipcc_mailbox_ipm_register_callback(const struct device *d, ipm_callback_t cb, void *user_data) { @@ -211,7 +212,8 @@ static void stm32_ipcc_mailbox_ipm_register_callback(struct device *d, data->user_data = user_data; } -static int stm32_ipcc_mailbox_ipm_set_enabled(struct device *dev, int enable) +static int stm32_ipcc_mailbox_ipm_set_enabled(const struct device *dev, + int enable) { struct stm32_ipcc_mbx_data *data = DEV_DATA(dev); const struct stm32_ipcc_mailbox_config *cfg = DEV_CFG(dev); @@ -238,12 +240,12 @@ static int stm32_ipcc_mailbox_ipm_set_enabled(struct device *dev, int enable) return 0; } -static int stm32_ipcc_mailbox_init(struct device *dev) +static int stm32_ipcc_mailbox_init(const struct device *dev) { struct stm32_ipcc_mbx_data *data = DEV_DATA(dev); const struct stm32_ipcc_mailbox_config *cfg = DEV_CFG(dev); - struct device *clk; + const struct device *clk; uint32_t i; clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); @@ -282,7 +284,7 @@ static const struct ipm_driver_api stm32_ipcc_mailbox_driver_api = { .set_enabled = stm32_ipcc_mailbox_ipm_set_enabled, }; -static void stm32_ipcc_mailbox_config_func(struct device *dev); +static void stm32_ipcc_mailbox_config_func(const struct device *dev); /* Config MAILBOX 0 */ static const struct stm32_ipcc_mailbox_config stm32_ipcc_mailbox_0_config = { @@ -300,7 +302,7 @@ DEVICE_AND_API_INIT(mailbox_0, DT_INST_LABEL(0), POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &stm32_ipcc_mailbox_driver_api); -static void stm32_ipcc_mailbox_config_func(struct device *dev) +static void stm32_ipcc_mailbox_config_func(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, rxo, irq), DT_INST_IRQ_BY_NAME(0, rxo, priority), diff --git a/drivers/kscan/kscan_ft5336.c b/drivers/kscan/kscan_ft5336.c index f363baaeea5cbc..de3b5d5bb77cbd 100644 --- a/drivers/kscan/kscan_ft5336.c +++ b/drivers/kscan/kscan_ft5336.c @@ -60,16 +60,16 @@ struct ft5336_config { /** FT5336 data. */ struct ft5336_data { /** Device pointer. */ - struct device *dev; + const struct device *dev; /** I2C controller device. */ - struct device *i2c; + const struct device *i2c; /** KSCAN Callback. */ kscan_callback_t callback; /** Work queue (for deferred read). */ struct k_work work; #ifdef CONFIG_KSCAN_FT5336_INTERRUPT /** Interrupt GPIO controller. */ - struct device *int_gpio; + const struct device *int_gpio; /** Interrupt GPIO callback. */ struct gpio_callback int_gpio_cb; #else @@ -78,7 +78,7 @@ struct ft5336_data { #endif }; -static int ft5336_process(struct device *dev) +static int ft5336_process(const struct device *dev) { const struct ft5336_config *config = dev->config; struct ft5336_data *data = dev->data; @@ -131,7 +131,8 @@ static void ft5336_work_handler(struct k_work *work) } #ifdef CONFIG_KSCAN_FT5336_INTERRUPT -static void ft5336_isr_handler(struct device *dev, struct gpio_callback *cb, uint32_t pins) +static void ft5336_isr_handler(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) { struct ft5336_data *data = CONTAINER_OF(cb, struct ft5336_data, int_gpio_cb); @@ -146,7 +147,8 @@ static void ft5336_timer_handler(struct k_timer *timer) } #endif -static int ft5336_configure(struct device *dev, kscan_callback_t callback) +static int ft5336_configure(const struct device *dev, + kscan_callback_t callback) { struct ft5336_data *data = dev->data; @@ -160,7 +162,7 @@ static int ft5336_configure(struct device *dev, kscan_callback_t callback) return 0; } -static int ft5336_enable_callback(struct device *dev) +static int ft5336_enable_callback(const struct device *dev) { struct ft5336_data *data = dev->data; @@ -174,7 +176,7 @@ static int ft5336_enable_callback(struct device *dev) return 0; } -static int ft5336_disable_callback(struct device *dev) +static int ft5336_disable_callback(const struct device *dev) { struct ft5336_data *data = dev->data; @@ -187,7 +189,7 @@ static int ft5336_disable_callback(struct device *dev) return 0; } -static int ft5336_init(struct device *dev) +static int ft5336_init(const struct device *dev) { const struct ft5336_config *config = dev->config; struct ft5336_data *data = dev->data; diff --git a/drivers/kscan/kscan_handlers.c b/drivers/kscan/kscan_handlers.c index 2ee6f1525a0dc6..955d8f7f3756e7 100644 --- a/drivers/kscan/kscan_handlers.c +++ b/drivers/kscan/kscan_handlers.c @@ -7,28 +7,28 @@ #include #include -static inline int z_vrfy_kscan_config(struct device *dev, +static inline int z_vrfy_kscan_config(const struct device *dev, kscan_callback_t callback_isr) { Z_OOPS(Z_SYSCALL_DRIVER_KSCAN(dev, config)); Z_OOPS(Z_SYSCALL_VERIFY_MSG(callback_isr == 0, "callback cannot be set from user mode")); - return z_impl_kscan_config((struct device *)dev, callback_isr); + return z_impl_kscan_config((const struct device *)dev, callback_isr); } #include -static inline int z_vrfy_kscan_disable_callback(struct device *dev) +static inline int z_vrfy_kscan_disable_callback(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_KSCAN(dev, disable_callback)); - return z_impl_kscan_disable_callback((struct device *)dev); + return z_impl_kscan_disable_callback((const struct device *)dev); } #include -static int z_vrfy_kscan_enable_callback(struct device *dev) +static int z_vrfy_kscan_enable_callback(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_KSCAN(dev, enable_callback)); - return z_impl_kscan_enable_callback((struct device *)dev); + return z_impl_kscan_enable_callback((const struct device *)dev); } #include diff --git a/drivers/kscan/kscan_mchp_xec.c b/drivers/kscan/kscan_mchp_xec.c index bfbd7bc55a7b7e..3f5de3ee4fa004 100644 --- a/drivers/kscan/kscan_mchp_xec.c +++ b/drivers/kscan/kscan_mchp_xec.c @@ -326,7 +326,7 @@ void polling_task(void *dev, void *dummy2, void *dummy3) } } -static int kscan_xec_configure(struct device *dev, +static int kscan_xec_configure(const struct device *dev, kscan_callback_t callback) { ARG_UNUSED(dev); @@ -342,7 +342,7 @@ static int kscan_xec_configure(struct device *dev, return 0; } -static int kscan_xec_inhibit_interface(struct device *dev) +static int kscan_xec_inhibit_interface(const struct device *dev) { ARG_UNUSED(dev); @@ -351,7 +351,7 @@ static int kscan_xec_inhibit_interface(struct device *dev) return 0; } -static int kscan_xec_enable_interface(struct device *dev) +static int kscan_xec_enable_interface(const struct device *dev) { ARG_UNUSED(dev); @@ -366,7 +366,7 @@ static const struct kscan_driver_api kscan_xec_driver_api = { .enable_callback = kscan_xec_enable_interface, }; -static int kscan_xec_init(struct device *dev); +static int kscan_xec_init(const struct device *dev); DEVICE_AND_API_INIT(kscan_xec, DT_INST_LABEL(0), &kscan_xec_init, @@ -375,7 +375,7 @@ DEVICE_AND_API_INIT(kscan_xec, DT_INST_LABEL(0), &kscan_xec_driver_api); -static int kscan_xec_init(struct device *dev) +static int kscan_xec_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/kscan/kscan_sdl.c b/drivers/kscan/kscan_sdl.c index 8d747c13a680d3..c587ab9ccbbfda 100644 --- a/drivers/kscan/kscan_sdl.c +++ b/drivers/kscan/kscan_sdl.c @@ -18,7 +18,7 @@ struct sdl_data { static int sdl_filter(void *arg, SDL_Event *event) { - struct device *dev = arg; + const struct device *dev = arg; struct sdl_data *data = dev->data; uint32_t row = 0; uint32_t column = 0; @@ -52,7 +52,7 @@ static int sdl_filter(void *arg, SDL_Event *event) return 1; } -static int sdl_configure(struct device *dev, kscan_callback_t callback) +static int sdl_configure(const struct device *dev, kscan_callback_t callback) { struct sdl_data *data = dev->data; @@ -67,7 +67,7 @@ static int sdl_configure(struct device *dev, kscan_callback_t callback) return 0; } -static int sdl_enable_callback(struct device *dev) +static int sdl_enable_callback(const struct device *dev) { struct sdl_data *data = dev->data; @@ -76,7 +76,7 @@ static int sdl_enable_callback(struct device *dev) return 0; } -static int sdl_disable_callback(struct device *dev) +static int sdl_disable_callback(const struct device *dev) { struct sdl_data *data = dev->data; @@ -85,7 +85,7 @@ static int sdl_disable_callback(struct device *dev) return 0; } -static int sdl_init(struct device *dev) +static int sdl_init(const struct device *dev) { LOG_INF("Init '%s' device", dev->name); SDL_AddEventWatch(sdl_filter, dev); diff --git a/drivers/led/ht16k33.c b/drivers/led/ht16k33.c index 3971fb93ab73e6..7066eeabb1ba79 100644 --- a/drivers/led/ht16k33.c +++ b/drivers/led/ht16k33.c @@ -76,13 +76,13 @@ struct ht16k33_cfg { }; struct ht16k33_data { - struct device *i2c; + const struct device *i2c; struct led_data dev_data; /* Shadow buffer for the display data RAM */ uint8_t buffer[HT16K33_DISP_DATA_SIZE]; #ifdef CONFIG_HT16K33_KEYSCAN struct k_mutex lock; - struct device *children[HT16K33_KEYSCAN_ROWS]; + const struct device *children[HT16K33_KEYSCAN_ROWS]; struct gpio_callback irq_cb; struct k_thread irq_thread; struct k_sem irq_sem; @@ -94,7 +94,7 @@ struct ht16k33_data { #endif /* CONFIG_HT16K33_KEYSCAN */ }; -static int ht16k33_led_blink(struct device *dev, uint32_t led, +static int ht16k33_led_blink(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) { /* The HT16K33 blinks all LEDs at the same frequency */ @@ -130,7 +130,7 @@ static int ht16k33_led_blink(struct device *dev, uint32_t led, return 0; } -static int ht16k33_led_set_brightness(struct device *dev, uint32_t led, +static int ht16k33_led_set_brightness(const struct device *dev, uint32_t led, uint8_t value) { ARG_UNUSED(led); @@ -157,7 +157,8 @@ static int ht16k33_led_set_brightness(struct device *dev, uint32_t led, return 0; } -static int ht16k33_led_set_state(struct device *dev, uint32_t led, bool on) +static int ht16k33_led_set_state(const struct device *dev, uint32_t led, + bool on) { const struct ht16k33_cfg *config = dev->config; struct ht16k33_data *data = dev->data; @@ -193,18 +194,18 @@ static int ht16k33_led_set_state(struct device *dev, uint32_t led, bool on) return 0; } -static int ht16k33_led_on(struct device *dev, uint32_t led) +static int ht16k33_led_on(const struct device *dev, uint32_t led) { return ht16k33_led_set_state(dev, led, true); } -static int ht16k33_led_off(struct device *dev, uint32_t led) +static int ht16k33_led_off(const struct device *dev, uint32_t led) { return ht16k33_led_set_state(dev, led, false); } #ifdef CONFIG_HT16K33_KEYSCAN -uint32_t ht16k33_get_pending_int(struct device *dev) +uint32_t ht16k33_get_pending_int(const struct device *dev) { const struct ht16k33_cfg *config = dev->config; struct ht16k33_data *data = dev->data; @@ -223,7 +224,7 @@ uint32_t ht16k33_get_pending_int(struct device *dev) return (flag ? 1 : 0); } -static bool ht16k33_process_keyscan_data(struct device *dev) +static bool ht16k33_process_keyscan_data(const struct device *dev) { const struct ht16k33_cfg *config = dev->config; struct ht16k33_data *data = dev->data; @@ -261,7 +262,7 @@ static bool ht16k33_process_keyscan_data(struct device *dev) return pressed; } -static void ht16k33_irq_thread(struct device *dev) +static void ht16k33_irq_thread(const struct device *dev) { struct ht16k33_data *data = dev->data; bool pressed; @@ -277,7 +278,7 @@ static void ht16k33_irq_thread(struct device *dev) } } -static void ht16k33_irq_callback(struct device *gpiob, +static void ht16k33_irq_callback(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins) { struct ht16k33_data *data; @@ -297,8 +298,8 @@ static void ht16k33_timer_callback(struct k_timer *timer) k_sem_give(&data->irq_sem); } -int ht16k33_register_keyscan_device(struct device *parent, - struct device *child, +int ht16k33_register_keyscan_device(const struct device *parent, + const struct device *child, uint8_t keyscan_idx) { struct ht16k33_data *data = parent->data; @@ -319,7 +320,7 @@ int ht16k33_register_keyscan_device(struct device *parent, } #endif /* CONFIG_HT16K33_KEYSCAN */ -static int ht16k33_init(struct device *dev) +static int ht16k33_init(const struct device *dev) { const struct ht16k33_cfg *config = dev->config; struct ht16k33_data *data = dev->data; @@ -382,7 +383,7 @@ static int ht16k33_init(struct device *dev) /* Configure interrupt */ if (config->irq_enabled) { - struct device *irq_dev; + const struct device *irq_dev; uint8_t keys[HT16K33_KEYSCAN_DATA_SIZE]; irq_dev = device_get_binding(config->irq_dev_name); diff --git a/drivers/led/led_handlers.c b/drivers/led/led_handlers.c index 83f44f785dd90c..27ffa873ff2759 100644 --- a/drivers/led/led_handlers.c +++ b/drivers/led/led_handlers.c @@ -7,16 +7,16 @@ #include #include -static inline int z_vrfy_led_blink(struct device *dev, uint32_t led, - uint32_t delay_on, uint32_t delay_off) +static inline int z_vrfy_led_blink(const struct device *dev, uint32_t led, + uint32_t delay_on, uint32_t delay_off) { Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, blink)); - return z_impl_led_blink((struct device *)dev, led, delay_on, + return z_impl_led_blink((const struct device *)dev, led, delay_on, delay_off); } #include -static inline int z_vrfy_led_get_info(struct device *dev, uint32_t led, +static inline int z_vrfy_led_get_info(const struct device *dev, uint32_t led, const struct led_info **info) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_LED)); @@ -25,16 +25,18 @@ static inline int z_vrfy_led_get_info(struct device *dev, uint32_t led, } #include -static inline int z_vrfy_led_set_brightness(struct device *dev, uint32_t led, - uint8_t value) +static inline int z_vrfy_led_set_brightness(const struct device *dev, + uint32_t led, + uint8_t value) { Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, set_brightness)); - return z_impl_led_set_brightness((struct device *)dev, led, value); + return z_impl_led_set_brightness((const struct device *)dev, led, + value); } #include static inline int -z_vrfy_led_write_channels(struct device *dev, uint32_t start_channel, +z_vrfy_led_write_channels(const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_LED)); @@ -43,7 +45,7 @@ z_vrfy_led_write_channels(struct device *dev, uint32_t start_channel, } #include -static inline int z_vrfy_led_set_channel(struct device *dev, +static inline int z_vrfy_led_set_channel(const struct device *dev, uint32_t channel, uint8_t value) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_LED)); @@ -51,7 +53,7 @@ static inline int z_vrfy_led_set_channel(struct device *dev, } #include -static inline int z_impl_led_set_color(struct device *dev, uint32_t led, +static inline int z_impl_led_set_color(const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) { Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_LED)); @@ -60,16 +62,16 @@ static inline int z_impl_led_set_color(struct device *dev, uint32_t led, } #include -static inline int z_vrfy_led_on(struct device *dev, uint32_t led) +static inline int z_vrfy_led_on(const struct device *dev, uint32_t led) { Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, on)); - return z_impl_led_on((struct device *)dev, led); + return z_impl_led_on((const struct device *)dev, led); } #include -static inline int z_vrfy_led_off(struct device *dev, uint32_t led) +static inline int z_vrfy_led_off(const struct device *dev, uint32_t led) { Z_OOPS(Z_SYSCALL_DRIVER_LED(dev, off)); - return z_impl_led_off((struct device *)dev, led); + return z_impl_led_off((const struct device *)dev, led); } #include diff --git a/drivers/led/led_shell.c b/drivers/led/led_shell.c index ec3fcee342e002..df9fa264828efc 100644 --- a/drivers/led/led_shell.c +++ b/drivers/led/led_shell.c @@ -21,7 +21,7 @@ enum { }; static int parse_common_args(const struct shell *shell, char **argv, - struct device **dev, uint32_t *led) + const struct device * *dev, uint32_t *led) { char *end_ptr; @@ -44,7 +44,7 @@ static int parse_common_args(const struct shell *shell, char **argv, static int cmd_off(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t led; int err; @@ -65,7 +65,7 @@ static int cmd_off(const struct shell *shell, size_t argc, char **argv) static int cmd_on(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t led; int err; @@ -86,7 +86,7 @@ static int cmd_on(const struct shell *shell, size_t argc, char **argv) static int cmd_get_info(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t led; int err; const struct led_info *info; @@ -124,7 +124,7 @@ static int cmd_get_info(const struct shell *shell, size_t argc, char **argv) static int cmd_set_brightness(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t led; int err; char *end_ptr; @@ -160,7 +160,7 @@ static int cmd_set_brightness(const struct shell *shell, static int cmd_set_color(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t led; int err; size_t num_colors; @@ -216,7 +216,7 @@ static int cmd_set_color(const struct shell *shell, size_t argc, char **argv) static int cmd_set_channel(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t channel; int err; char *end_ptr; @@ -253,7 +253,7 @@ static int cmd_set_channel(const struct shell *shell, size_t argc, char **argv) static int cmd_write_channels(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; uint32_t start_channel; int err; size_t num_channels; diff --git a/drivers/led/lp3943.c b/drivers/led/lp3943.c index 117189ae227ea1..7fe0699ad5778f 100644 --- a/drivers/led/lp3943.c +++ b/drivers/led/lp3943.c @@ -52,7 +52,7 @@ enum lp3943_modes { }; struct lp3943_data { - struct device *i2c; + const struct device *i2c; struct led_data dev_data; }; @@ -120,7 +120,7 @@ static int lp3943_set_dim_states(struct lp3943_data *data, uint32_t led, uint8_t return 0; } -static int lp3943_led_blink(struct device *dev, uint32_t led, +static int lp3943_led_blink(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) { struct lp3943_data *data = dev->data; @@ -163,7 +163,7 @@ static int lp3943_led_blink(struct device *dev, uint32_t led, return 0; } -static int lp3943_led_set_brightness(struct device *dev, uint32_t led, +static int lp3943_led_set_brightness(const struct device *dev, uint32_t led, uint8_t value) { struct lp3943_data *data = dev->data; @@ -204,7 +204,7 @@ static int lp3943_led_set_brightness(struct device *dev, uint32_t led, return 0; } -static inline int lp3943_led_on(struct device *dev, uint32_t led) +static inline int lp3943_led_on(const struct device *dev, uint32_t led) { struct lp3943_data *data = dev->data; int ret; @@ -228,7 +228,7 @@ static inline int lp3943_led_on(struct device *dev, uint32_t led) return 0; } -static inline int lp3943_led_off(struct device *dev, uint32_t led) +static inline int lp3943_led_off(const struct device *dev, uint32_t led) { struct lp3943_data *data = dev->data; int ret; @@ -250,7 +250,7 @@ static inline int lp3943_led_off(struct device *dev, uint32_t led) return 0; } -static int lp3943_led_init(struct device *dev) +static int lp3943_led_init(const struct device *dev) { struct lp3943_data *data = dev->data; struct led_data *dev_data = &data->dev_data; diff --git a/drivers/led/lp503x.c b/drivers/led/lp503x.c index 325479e5a4e12d..bc5eea5805eeb1 100644 --- a/drivers/led/lp503x.c +++ b/drivers/led/lp503x.c @@ -72,7 +72,7 @@ struct lp503x_config { }; struct lp503x_data { - struct device *i2c; + const struct device *i2c; uint8_t *chan_buf; }; @@ -89,7 +89,7 @@ lp503x_led_to_info(const struct lp503x_config *config, uint32_t led) return NULL; } -static int lp503x_get_info(struct device *dev, uint32_t led, +static int lp503x_get_info(const struct device *dev, uint32_t led, const struct led_info **info) { const struct lp503x_config *config = DEV_CFG(dev); @@ -104,7 +104,7 @@ static int lp503x_get_info(struct device *dev, uint32_t led, return 0; } -static int lp503x_set_brightness(struct device *dev, +static int lp503x_set_brightness(const struct device *dev, uint32_t led, uint8_t value) { const struct lp503x_config *config = DEV_CFG(dev); @@ -122,17 +122,17 @@ static int lp503x_set_brightness(struct device *dev, return i2c_write(data->i2c, buf, sizeof(buf), config->i2c_addr); } -static int lp503x_on(struct device *dev, uint32_t led) +static int lp503x_on(const struct device *dev, uint32_t led) { return lp503x_set_brightness(dev, led, 100); } -static int lp503x_off(struct device *dev, uint32_t led) +static int lp503x_off(const struct device *dev, uint32_t led) { return lp503x_set_brightness(dev, led, 0); } -static int lp503x_set_color(struct device *dev, uint32_t led, +static int lp503x_set_color(const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) { const struct lp503x_config *config = DEV_CFG(dev); @@ -152,7 +152,8 @@ static int lp503x_set_color(struct device *dev, uint32_t led, return i2c_write(data->i2c, buf, sizeof(buf), config->i2c_addr); } -static int lp503x_write_channels(struct device *dev, uint32_t start_channel, +static int lp503x_write_channels(const struct device *dev, + uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) { const struct lp503x_config *config = DEV_CFG(dev); @@ -174,7 +175,7 @@ static int lp503x_write_channels(struct device *dev, uint32_t start_channel, num_channels + 1, config->i2c_addr); } -static int lp503x_init(struct device *dev) +static int lp503x_init(const struct device *dev) { const struct lp503x_config *config = DEV_CFG(dev); struct lp503x_data *data = DEV_DATA(dev); diff --git a/drivers/led/lp5562.c b/drivers/led/lp5562.c index 0bd50da553aac6..2b20a32f0608fe 100644 --- a/drivers/led/lp5562.c +++ b/drivers/led/lp5562.c @@ -158,7 +158,7 @@ enum lp5562_engine_fade_dirs { }; struct lp5562_data { - struct device *i2c; + const struct device *i2c; struct led_data dev_data; }; @@ -303,7 +303,7 @@ static void lp5562_ms_to_prescale_and_step(struct led_data *data, uint32_t ms, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_set_led_source(struct device *dev, +static int lp5562_set_led_source(const struct device *dev, enum lp5562_led_channels channel, enum lp5562_led_sources source) { @@ -330,7 +330,7 @@ static int lp5562_set_led_source(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_get_led_source(struct device *dev, +static int lp5562_get_led_source(const struct device *dev, enum lp5562_led_channels channel, enum lp5562_led_sources *source) { @@ -358,7 +358,7 @@ static int lp5562_get_led_source(struct device *dev, * @retval true If the engine is currently running. * @retval false If the engine is not running or an error occurred. */ -static bool lp5562_is_engine_executing(struct device *dev, +static bool lp5562_is_engine_executing(const struct device *dev, enum lp5562_led_sources engine) { struct lp5562_data *data = dev->data; @@ -394,7 +394,7 @@ static bool lp5562_is_engine_executing(struct device *dev, * @retval 0 On success. * @retval -ENODEV If all engines are busy. */ -static int lp5562_get_available_engine(struct device *dev, +static int lp5562_get_available_engine(const struct device *dev, enum lp5562_led_sources *engine) { enum lp5562_led_sources src; @@ -423,7 +423,7 @@ static int lp5562_get_available_engine(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_set_engine_reg(struct device *dev, +static int lp5562_set_engine_reg(const struct device *dev, enum lp5562_led_sources engine, uint8_t reg, uint8_t val) { @@ -456,7 +456,7 @@ static int lp5562_set_engine_reg(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_set_engine_op_mode(struct device *dev, +static inline int lp5562_set_engine_op_mode(const struct device *dev, enum lp5562_led_sources engine, enum lp5562_engine_op_modes mode) { @@ -473,9 +473,9 @@ static inline int lp5562_set_engine_op_mode(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_set_engine_exec_state(struct device *dev, - enum lp5562_led_sources engine, - enum lp5562_engine_exec_states state) +static inline int lp5562_set_engine_exec_state(const struct device *dev, + enum lp5562_led_sources engine, + enum lp5562_engine_exec_states state) { int ret; @@ -499,7 +499,7 @@ static inline int lp5562_set_engine_exec_state(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_start_program_exec(struct device *dev, +static inline int lp5562_start_program_exec(const struct device *dev, enum lp5562_led_sources engine) { if (lp5562_set_engine_op_mode(dev, engine, LP5562_OP_MODE_RUN)) { @@ -519,7 +519,7 @@ static inline int lp5562_start_program_exec(struct device *dev, * @retval 0 On success. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_stop_program_exec(struct device *dev, +static inline int lp5562_stop_program_exec(const struct device *dev, enum lp5562_led_sources engine) { if (lp5562_set_engine_op_mode(dev, engine, LP5562_OP_MODE_DISABLED)) { @@ -544,7 +544,7 @@ static inline int lp5562_stop_program_exec(struct device *dev, * engine is passed. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_program_command(struct device *dev, +static int lp5562_program_command(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint8_t command_msb, @@ -593,7 +593,7 @@ static int lp5562_program_command(struct device *dev, * @retval -EINVAL If the passed arguments are invalid or out of range. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_program_set_brightness(struct device *dev, +static int lp5562_program_set_brightness(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint8_t brightness) @@ -630,7 +630,7 @@ static int lp5562_program_set_brightness(struct device *dev, * @retval -EINVAL If the passed arguments are invalid or out of range. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_program_ramp(struct device *dev, +static int lp5562_program_ramp(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint32_t time_per_step, @@ -666,7 +666,7 @@ static int lp5562_program_ramp(struct device *dev, * @retval -EINVAL If the passed arguments are invalid or out of range. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_program_wait(struct device *dev, +static inline int lp5562_program_wait(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index, uint32_t time) @@ -693,7 +693,7 @@ static inline int lp5562_program_wait(struct device *dev, * engine is passed. * @retval -EIO If the underlying I2C call fails. */ -static inline int lp5562_program_go_to_start(struct device *dev, +static inline int lp5562_program_go_to_start(const struct device *dev, enum lp5562_led_sources engine, uint8_t command_index) { @@ -723,7 +723,7 @@ static inline int lp5562_program_go_to_start(struct device *dev, * @retval -EINVAL If the engine ID or brightness is out of range. * @retval -EIO If the underlying I2C call fails. */ -static int lp5562_update_blinking_brightness(struct device *dev, +static int lp5562_update_blinking_brightness(const struct device *dev, enum lp5562_led_sources engine, uint8_t brightness_on) { @@ -754,7 +754,7 @@ static int lp5562_update_blinking_brightness(struct device *dev, return 0; } -static int lp5562_led_blink(struct device *dev, uint32_t led, +static int lp5562_led_blink(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) { struct lp5562_data *data = dev->data; @@ -815,7 +815,8 @@ static int lp5562_led_blink(struct device *dev, uint32_t led, return 0; } -static int lp5562_led_set_brightness(struct device *dev, uint32_t led, uint8_t value) +static int lp5562_led_set_brightness(const struct device *dev, uint32_t led, + uint8_t value) { struct lp5562_data *data = dev->data; struct led_data *dev_data = &data->dev_data; @@ -865,7 +866,7 @@ static int lp5562_led_set_brightness(struct device *dev, uint32_t led, uint8_t v return 0; } -static inline int lp5562_led_on(struct device *dev, uint32_t led) +static inline int lp5562_led_on(const struct device *dev, uint32_t led) { struct lp5562_data *data = dev->data; struct led_data *dev_data = &data->dev_data; @@ -873,7 +874,7 @@ static inline int lp5562_led_on(struct device *dev, uint32_t led) return lp5562_led_set_brightness(dev, led, dev_data->max_brightness); } -static inline int lp5562_led_off(struct device *dev, uint32_t led) +static inline int lp5562_led_off(const struct device *dev, uint32_t led) { struct lp5562_data *data = dev->data; struct led_data *dev_data = &data->dev_data; @@ -896,7 +897,7 @@ static inline int lp5562_led_off(struct device *dev, uint32_t led) return lp5562_led_set_brightness(dev, led, dev_data->min_brightness); } -static int lp5562_led_init(struct device *dev) +static int lp5562_led_init(const struct device *dev) { struct lp5562_data *data = dev->data; struct led_data *dev_data = &data->dev_data; diff --git a/drivers/led/pca9633.c b/drivers/led/pca9633.c index 0c21d7abe7e5f6..16878a692da1d0 100644 --- a/drivers/led/pca9633.c +++ b/drivers/led/pca9633.c @@ -42,11 +42,11 @@ LOG_MODULE_REGISTER(pca9633); #define PCA9633_MASK 0x03 struct pca9633_data { - struct device *i2c; + const struct device *i2c; struct led_data dev_data; }; -static int pca9633_led_blink(struct device *dev, uint32_t led, +static int pca9633_led_blink(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off) { struct pca9633_data *data = dev->data; @@ -109,7 +109,7 @@ static int pca9633_led_blink(struct device *dev, uint32_t led, return 0; } -static int pca9633_led_set_brightness(struct device *dev, uint32_t led, +static int pca9633_led_set_brightness(const struct device *dev, uint32_t led, uint8_t value) { struct pca9633_data *data = dev->data; @@ -142,7 +142,7 @@ static int pca9633_led_set_brightness(struct device *dev, uint32_t led, return 0; } -static inline int pca9633_led_on(struct device *dev, uint32_t led) +static inline int pca9633_led_on(const struct device *dev, uint32_t led) { struct pca9633_data *data = dev->data; @@ -158,7 +158,7 @@ static inline int pca9633_led_on(struct device *dev, uint32_t led) return 0; } -static inline int pca9633_led_off(struct device *dev, uint32_t led) +static inline int pca9633_led_off(const struct device *dev, uint32_t led) { struct pca9633_data *data = dev->data; @@ -174,7 +174,7 @@ static inline int pca9633_led_off(struct device *dev, uint32_t led) return 0; } -static int pca9633_led_init(struct device *dev) +static int pca9633_led_init(const struct device *dev) { struct pca9633_data *data = dev->data; struct led_data *dev_data = &data->dev_data; diff --git a/drivers/led_strip/apa102.c b/drivers/led_strip/apa102.c index 7c6e94904db1d7..9c23c5b8075199 100644 --- a/drivers/led_strip/apa102.c +++ b/drivers/led_strip/apa102.c @@ -13,14 +13,14 @@ #include struct apa102_data { - struct device *spi; + const struct device *spi; struct spi_config cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control cs_ctl; #endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */ }; -static int apa102_update(struct device *dev, void *buf, size_t size) +static int apa102_update(const struct device *dev, void *buf, size_t size) { struct apa102_data *data = dev->data; static const uint8_t zeros[] = {0, 0, 0, 0}; @@ -53,7 +53,7 @@ static int apa102_update(struct device *dev, void *buf, size_t size) return spi_write(data->spi, &data->cfg, &tx); } -static int apa102_update_rgb(struct device *dev, struct led_rgb *pixels, +static int apa102_update_rgb(const struct device *dev, struct led_rgb *pixels, size_t count) { uint8_t *p = (uint8_t *)pixels; @@ -77,14 +77,14 @@ static int apa102_update_rgb(struct device *dev, struct led_rgb *pixels, return apa102_update(dev, pixels, sizeof(struct led_rgb) * count); } -static int apa102_update_channels(struct device *dev, uint8_t *channels, +static int apa102_update_channels(const struct device *dev, uint8_t *channels, size_t num_channels) { /* Not implemented */ return -EINVAL; } -static int apa102_init(struct device *dev) +static int apa102_init(const struct device *dev) { struct apa102_data *data = dev->data; diff --git a/drivers/led_strip/lpd880x.c b/drivers/led_strip/lpd880x.c index 85f474a65f4da5..eb18175c5a138d 100644 --- a/drivers/led_strip/lpd880x.c +++ b/drivers/led_strip/lpd880x.c @@ -36,11 +36,11 @@ LOG_MODULE_REGISTER(lpd880x); SPI_LINES_SINGLE) struct lpd880x_data { - struct device *spi; + const struct device *spi; struct spi_config config; }; -static int lpd880x_update(struct device *dev, void *data, size_t size) +static int lpd880x_update(const struct device *dev, void *data, size_t size) { struct lpd880x_data *drv_data = dev->data; /* @@ -85,7 +85,7 @@ static int lpd880x_update(struct device *dev, void *data, size_t size) return rc; } -static int lpd880x_strip_update_rgb(struct device *dev, +static int lpd880x_strip_update_rgb(const struct device *dev, struct led_rgb *pixels, size_t num_pixels) { @@ -114,7 +114,8 @@ static int lpd880x_strip_update_rgb(struct device *dev, return lpd880x_update(dev, pixels, 3 * num_pixels); } -static int lpd880x_strip_update_channels(struct device *dev, uint8_t *channels, +static int lpd880x_strip_update_channels(const struct device *dev, + uint8_t *channels, size_t num_channels) { size_t i; @@ -126,7 +127,7 @@ static int lpd880x_strip_update_channels(struct device *dev, uint8_t *channels, return lpd880x_update(dev, channels, num_channels); } -static int lpd880x_strip_init(struct device *dev) +static int lpd880x_strip_init(const struct device *dev) { struct lpd880x_data *data = dev->data; struct spi_config *config = &data->config; diff --git a/drivers/led_strip/ws2812_gpio.c b/drivers/led_strip/ws2812_gpio.c index 2fc85fbc5099a9..398720fbce1042 100644 --- a/drivers/led_strip/ws2812_gpio.c +++ b/drivers/led_strip/ws2812_gpio.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(ws2812_gpio); #include struct ws2812_gpio_data { - struct device *gpio; + const struct device *gpio; }; struct ws2812_gpio_cfg { @@ -31,12 +31,12 @@ struct ws2812_gpio_cfg { bool has_white; }; -static struct ws2812_gpio_data *dev_data(struct device *dev) +static struct ws2812_gpio_data *dev_data(const struct device *dev) { return dev->data; } -static const struct ws2812_gpio_cfg *dev_cfg(struct device *dev) +static const struct ws2812_gpio_cfg *dev_cfg(const struct device *dev) { return dev->config; } @@ -98,7 +98,7 @@ static const struct ws2812_gpio_cfg *dev_cfg(struct device *dev) [r] "l" (base), \ [p] "l" (pin)); } while (0) -static int send_buf(struct device *dev, uint8_t *buf, size_t len) +static int send_buf(const struct device *dev, uint8_t *buf, size_t len) { volatile uint32_t *base = (uint32_t *)&NRF_GPIO->OUTSET; const uint32_t val = BIT(dev_cfg(dev)->pin); @@ -153,7 +153,8 @@ static int send_buf(struct device *dev, uint8_t *buf, size_t len) return rc; } -static int ws2812_gpio_update_rgb(struct device *dev, struct led_rgb *pixels, +static int ws2812_gpio_update_rgb(const struct device *dev, + struct led_rgb *pixels, size_t num_pixels) { const struct ws2812_gpio_cfg *config = dev->config; @@ -178,7 +179,8 @@ static int ws2812_gpio_update_rgb(struct device *dev, struct led_rgb *pixels, return send_buf(dev, (uint8_t *)pixels, num_pixels * (has_white ? 4 : 3)); } -static int ws2812_gpio_update_channels(struct device *dev, uint8_t *channels, +static int ws2812_gpio_update_channels(const struct device *dev, + uint8_t *channels, size_t num_channels) { LOG_ERR("update_channels not implemented"); diff --git a/drivers/led_strip/ws2812_spi.c b/drivers/led_strip/ws2812_spi.c index ddd48cf25aaacc..8dafe03c58772b 100644 --- a/drivers/led_strip/ws2812_spi.c +++ b/drivers/led_strip/ws2812_spi.c @@ -45,7 +45,7 @@ LOG_MODULE_REGISTER(ws2812_spi); #define BYTES_PER_PX(has_white) ((has_white) ? 32 : 24) struct ws2812_spi_data { - struct device *spi; + const struct device *spi; }; struct ws2812_spi_cfg { @@ -57,12 +57,12 @@ struct ws2812_spi_cfg { bool has_white; }; -static struct ws2812_spi_data *dev_data(struct device *dev) +static struct ws2812_spi_data *dev_data(const struct device *dev) { return dev->data; } -static const struct ws2812_spi_cfg *dev_cfg(struct device *dev) +static const struct ws2812_spi_cfg *dev_cfg(const struct device *dev) { return dev->config; } @@ -109,7 +109,8 @@ static inline void ws2812_reset_delay(void) k_busy_wait(RESET_DELAY_USEC); } -static int ws2812_strip_update_rgb(struct device *dev, struct led_rgb *pixels, +static int ws2812_strip_update_rgb(const struct device *dev, + struct led_rgb *pixels, size_t num_pixels) { const struct ws2812_spi_cfg *cfg = dev_cfg(dev); @@ -156,7 +157,8 @@ static int ws2812_strip_update_rgb(struct device *dev, struct led_rgb *pixels, return rc; } -static int ws2812_strip_update_channels(struct device *dev, uint8_t *channels, +static int ws2812_strip_update_channels(const struct device *dev, + uint8_t *channels, size_t num_channels) { LOG_ERR("update_channels not implemented"); diff --git a/drivers/lora/shell.c b/drivers/lora/shell.c index 97993122acf745..b660b98ac38efd 100644 --- a/drivers/lora/shell.c +++ b/drivers/lora/shell.c @@ -89,9 +89,9 @@ static int parse_freq(uint32_t *out, const struct shell *shell, const char *arg) return 0; } -static struct device *get_modem(const struct shell *shell) +static const struct device *get_modem(const struct shell *shell) { - struct device *dev; + const struct device *dev; dev = device_get_binding(DEFAULT_RADIO); if (!dev) { @@ -102,10 +102,10 @@ static struct device *get_modem(const struct shell *shell) return dev; } -static struct device *get_configured_modem(const struct shell *shell) +static const struct device *get_configured_modem(const struct shell *shell) { int ret; - struct device *dev; + const struct device *dev; dev = get_modem(shell); if (!dev) { @@ -232,7 +232,7 @@ static int cmd_lora_send(const struct shell *shell, size_t argc, char **argv) { int ret; - struct device *dev; + const struct device *dev; modem_config.tx = true; dev = get_configured_modem(shell); @@ -252,7 +252,7 @@ static int cmd_lora_send(const struct shell *shell, static int cmd_lora_recv(const struct shell *shell, size_t argc, char **argv) { static char buf[0xff]; - struct device *dev; + const struct device *dev; long timeout = 0; int ret; int16_t rssi; @@ -286,7 +286,7 @@ static int cmd_lora_recv(const struct shell *shell, size_t argc, char **argv) static int cmd_lora_test_cw(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; int ret; uint32_t freq; long power, duration; diff --git a/drivers/lora/sx126x.c b/drivers/lora/sx126x.c index b54a79bce3c865..d2e9b14fb8b914 100644 --- a/drivers/lora/sx126x.c +++ b/drivers/lora/sx126x.c @@ -64,16 +64,16 @@ BUILD_ASSERT(DIO2_TX_ENABLE, #define SX126X_CALIBRATION_ALL 0x7f struct sx126x_data { - struct device *reset; - struct device *busy; - struct device *dio1; + const struct device *reset; + const struct device *busy; + const struct device *dio1; struct gpio_callback dio1_irq_callback; struct k_work dio1_irq_work; DioIrqHandler *radio_dio_irq; #if HAVE_GPIO_ANTENNA_ENABLE - struct device *antenna_enable; + const struct device *antenna_enable; #endif - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if HAVE_GPIO_CS struct spi_cs_control spi_cs; @@ -354,7 +354,7 @@ static void sx126x_dio1_irq_work_handler(struct k_work *work) } } -static void sx126x_dio1_irq_callback(struct device *dev, +static void sx126x_dio1_irq_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { if (pins & BIT(GPIO_DIO1_PIN)) { @@ -362,7 +362,7 @@ static void sx126x_dio1_irq_callback(struct device *dev, } } -static int sx126x_lora_init(struct device *dev) +static int sx126x_lora_init(const struct device *dev) { int ret; diff --git a/drivers/lora/sx1276.c b/drivers/lora/sx1276.c index 8cae924e386acc..973c0e54695156 100644 --- a/drivers/lora/sx1276.c +++ b/drivers/lora/sx1276.c @@ -95,30 +95,30 @@ static const struct sx1276_dio sx1276_dios[] = { SX1276_DIO_GPIO_INIT(0) }; #define SX1276_MAX_DIO ARRAY_SIZE(sx1276_dios) static struct sx1276_data { - struct device *reset; + const struct device *reset; #if DT_INST_NODE_HAS_PROP(0, antenna_enable_gpios) - struct device *antenna_enable; + const struct device *antenna_enable; #endif #if DT_INST_NODE_HAS_PROP(0, rfi_enable_gpios) - struct device *rfi_enable; + const struct device *rfi_enable; #endif #if DT_INST_NODE_HAS_PROP(0, rfo_enable_gpios) - struct device *rfo_enable; + const struct device *rfo_enable; #endif #if DT_INST_NODE_HAS_PROP(0, pa_boost_enable_gpios) - struct device *pa_boost_enable; + const struct device *pa_boost_enable; #endif #if DT_INST_NODE_HAS_PROP(0, rfo_enable_gpios) && \ DT_INST_NODE_HAS_PROP(0, pa_boost_enable_gpios) uint8_t tx_power; #endif #if DT_INST_NODE_HAS_PROP(0, tcxo_power_gpios) - struct device *tcxo_power; + const struct device *tcxo_power; bool tcxo_power_enabled; #endif - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; - struct device *dio_dev[SX1276_MAX_DIO]; + const struct device *dio_dev[SX1276_MAX_DIO]; struct k_work dio_work[SX1276_MAX_DIO]; } dev_data; @@ -249,7 +249,7 @@ static void sx1276_dio_work_handle(struct k_work *work) (*DioIrq[dio])(NULL); } -static void sx1276_irq_callback(struct device *dev, +static void sx1276_irq_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { unsigned int i, pin; @@ -472,7 +472,7 @@ static int sx1276_antenna_configure(void) return 0; } -static int sx1276_lora_init(struct device *dev) +static int sx1276_lora_init(const struct device *dev) { #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) static struct spi_cs_control spi_cs; diff --git a/drivers/lora/sx12xx_common.c b/drivers/lora/sx12xx_common.c index 3432e18daf55d1..b62958e81163da 100644 --- a/drivers/lora/sx12xx_common.c +++ b/drivers/lora/sx12xx_common.c @@ -26,7 +26,7 @@ static struct sx12xx_data { int16_t rssi; } dev_data; -int __sx12xx_configure_pin(struct device **dev, const char *controller, +int __sx12xx_configure_pin(const struct device * *dev, const char *controller, gpio_pin_t pin, gpio_flags_t flags) { int err; @@ -65,7 +65,8 @@ static void sx12xx_ev_tx_done(void) Radio.Sleep(); } -int sx12xx_lora_send(struct device *dev, uint8_t *data, uint32_t data_len) +int sx12xx_lora_send(const struct device *dev, uint8_t *data, + uint32_t data_len) { Radio.SetMaxPayloadLength(MODEM_LORA, data_len); @@ -74,7 +75,7 @@ int sx12xx_lora_send(struct device *dev, uint8_t *data, uint32_t data_len) return 0; } -int sx12xx_lora_recv(struct device *dev, uint8_t *data, uint8_t size, +int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr) { int ret; @@ -110,7 +111,8 @@ int sx12xx_lora_recv(struct device *dev, uint8_t *data, uint8_t size, return dev_data.rx_len; } -int sx12xx_lora_config(struct device *dev, struct lora_modem_config *config) +int sx12xx_lora_config(const struct device *dev, + struct lora_modem_config *config) { Radio.SetChannel(config->frequency); @@ -130,14 +132,15 @@ int sx12xx_lora_config(struct device *dev, struct lora_modem_config *config) return 0; } -int sx12xx_lora_test_cw(struct device *dev, uint32_t frequency, int8_t tx_power, +int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency, + int8_t tx_power, uint16_t duration) { Radio.SetTxContinuousWave(frequency, tx_power, duration); return 0; } -int sx12xx_init(struct device *dev) +int sx12xx_init(const struct device *dev) { k_sem_init(&dev_data.data_sem, 0, UINT_MAX); diff --git a/drivers/lora/sx12xx_common.h b/drivers/lora/sx12xx_common.h index a2fc52aeb12098..c66467dfa3df75 100644 --- a/drivers/lora/sx12xx_common.h +++ b/drivers/lora/sx12xx_common.h @@ -13,7 +13,7 @@ #include #include -int __sx12xx_configure_pin(struct device **dev, const char *controller, +int __sx12xx_configure_pin(const struct device * *dev, const char *controller, gpio_pin_t pin, gpio_flags_t flags); #define sx12xx_configure_pin(_name, _flags) \ @@ -25,16 +25,19 @@ int __sx12xx_configure_pin(struct device **dev, const char *controller, _flags)), \ (0)) -int sx12xx_lora_send(struct device *dev, uint8_t *data, uint32_t data_len); +int sx12xx_lora_send(const struct device *dev, uint8_t *data, + uint32_t data_len); -int sx12xx_lora_recv(struct device *dev, uint8_t *data, uint8_t size, +int sx12xx_lora_recv(const struct device *dev, uint8_t *data, uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr); -int sx12xx_lora_config(struct device *dev, struct lora_modem_config *config); +int sx12xx_lora_config(const struct device *dev, + struct lora_modem_config *config); -int sx12xx_lora_test_cw(struct device *dev, uint32_t frequency, int8_t tx_power, +int sx12xx_lora_test_cw(const struct device *dev, uint32_t frequency, + int8_t tx_power, uint16_t duration); -int sx12xx_init(struct device *dev); +int sx12xx_init(const struct device *dev); #endif /* ZEPHYR_DRIVERS_SX12XX_COMMON_H_ */ diff --git a/drivers/modem/gsm_ppp.c b/drivers/modem/gsm_ppp.c index bdb06e514f289f..85f0e7029c2d07 100644 --- a/drivers/modem/gsm_ppp.c +++ b/drivers/modem/gsm_ppp.c @@ -57,9 +57,9 @@ static struct gsm_modem { size_t ppp_recv_buf_len; enum setup_state state; - struct device *ppp_dev; - struct device *at_dev; - struct device *control_dev; + const struct device *ppp_dev; + const struct device *at_dev; + const struct device *control_dev; bool mux_enabled : 1; bool mux_setup_done : 1; @@ -293,7 +293,7 @@ static int gsm_setup_mccmno(struct gsm_modem *gsm) static void set_ppp_carrier_on(struct gsm_modem *gsm) { - struct device *ppp_dev = device_get_binding(CONFIG_NET_PPP_DRV_NAME); + const struct device *ppp_dev = device_get_binding(CONFIG_NET_PPP_DRV_NAME); const struct ppp_api *api; if (!ppp_dev) { @@ -442,7 +442,7 @@ static void mux_setup_next(struct gsm_modem *gsm) (void)k_delayed_work_submit(&gsm->gsm_configure_work, K_MSEC(1)); } -static void mux_attach_cb(struct device *mux, int dlci_address, +static void mux_attach_cb(const struct device *mux, int dlci_address, bool connected, void *user_data) { LOG_DBG("DLCI %d to %s %s", dlci_address, mux->name, @@ -456,7 +456,7 @@ static void mux_attach_cb(struct device *mux, int dlci_address, mux_setup_next(user_data); } -static int mux_attach(struct device *mux, struct device *uart, +static int mux_attach(const struct device *mux, const struct device *uart, int dlci_address, void *user_data) { int ret = uart_mux_attach(mux, uart, dlci_address, mux_attach_cb, @@ -474,7 +474,7 @@ static void mux_setup(struct k_work *work) { struct gsm_modem *gsm = CONTAINER_OF(work, struct gsm_modem, gsm_configure_work); - struct device *uart = device_get_binding(CONFIG_MODEM_GSM_UART_NAME); + const struct device *uart = device_get_binding(CONFIG_MODEM_GSM_UART_NAME); int ret; switch (gsm->state) { @@ -609,7 +609,7 @@ static void gsm_configure(struct k_work *work) gsm_finalize_connection(gsm); } -static int gsm_init(struct device *device) +static int gsm_init(const struct device *device) { struct gsm_modem *gsm = device->data; int r; diff --git a/drivers/modem/hl7800.c b/drivers/modem/hl7800.c index abba81b0829348..2b615d041c4497 100644 --- a/drivers/modem/hl7800.c +++ b/drivers/modem/hl7800.c @@ -444,7 +444,7 @@ struct hl7800_iface_ctx { bool search_no_id_resp; /* GPIO PORT devices */ - struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS]; + const struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS]; struct gpio_callback mdm_vgpio_cb; struct gpio_callback mdm_uart_dsr_cb; struct gpio_callback mdm_gpio6_cb; @@ -3528,7 +3528,8 @@ static void mdm_vgpio_work_cb(struct k_work *item) hl7800_unlock(); } -void mdm_vgpio_callback_isr(struct device *port, struct gpio_callback *cb, +void mdm_vgpio_callback_isr(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { ictx.vgpio_state = (uint32_t)gpio_pin_get(ictx.gpio_port_dev[MDM_VGPIO], @@ -3556,7 +3557,8 @@ void mdm_vgpio_callback_isr(struct device *port, struct gpio_callback *cb, k_work_submit_to_queue(&hl7800_workq, &ictx.mdm_vgpio_work); } -void mdm_uart_dsr_callback_isr(struct device *port, struct gpio_callback *cb, +void mdm_uart_dsr_callback_isr(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { ictx.dsr_state = (uint32_t)gpio_pin_get( @@ -3581,7 +3583,8 @@ static void mark_sockets_for_reconfig(void) } #endif -void mdm_gpio6_callback_isr(struct device *port, struct gpio_callback *cb, +void mdm_gpio6_callback_isr(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { #ifdef CONFIG_MODEM_HL7800_LOW_POWER_MODE @@ -3607,7 +3610,8 @@ void mdm_gpio6_callback_isr(struct device *port, struct gpio_callback *cb, #endif } -void mdm_uart_cts_callback(struct device *port, struct gpio_callback *cb, +void mdm_uart_cts_callback(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { ictx.cts_state = (uint32_t)gpio_pin_get( @@ -4625,7 +4629,7 @@ static struct net_offload offload_funcs = { .put = offload_put, }; -static inline uint8_t *hl7800_get_mac(struct device *dev) +static inline uint8_t *hl7800_get_mac(const struct device *dev) { struct hl7800_iface_ctx *ctx = dev->driver_data; @@ -4696,7 +4700,7 @@ int32_t mdm_hl7800_update_fw(char *file_path) } #endif -static int hl7800_init(struct device *dev) +static int hl7800_init(const struct device *dev) { int i, ret = 0; @@ -4883,7 +4887,7 @@ static int hl7800_init(struct device *dev) static void offload_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct hl7800_iface_ctx *ctx = dev->driver_data; iface->if_dev->offload = &offload_funcs; diff --git a/drivers/modem/modem_context.c b/drivers/modem/modem_context.c index 5ec3b09b2f77d0..676362fc83541f 100644 --- a/drivers/modem/modem_context.c +++ b/drivers/modem/modem_context.c @@ -63,7 +63,7 @@ int modem_context_get_addr_port(const struct sockaddr *addr, uint16_t *port) * * @retval Modem context or NULL. */ -struct modem_context *modem_context_from_iface_dev(struct device *dev) +struct modem_context *modem_context_from_iface_dev(const struct device *dev) { int i; diff --git a/drivers/modem/modem_context.h b/drivers/modem/modem_context.h index 03d20b6d8b34d5..93b09549fae8bd 100644 --- a/drivers/modem/modem_context.h +++ b/drivers/modem/modem_context.h @@ -31,7 +31,7 @@ extern "C" { } struct modem_iface { - struct device *dev; + const struct device *dev; int (*read)(struct modem_iface *iface, uint8_t *buf, size_t size, size_t *bytes_read); @@ -50,7 +50,7 @@ struct modem_cmd_handler { }; struct modem_pin { - struct device *gpio_port_dev; + const struct device *gpio_port_dev; char *dev_name; gpio_pin_t pin; gpio_flags_t init_flags; @@ -117,7 +117,7 @@ struct modem_context *modem_context_from_id(int id); * * @retval Modem context or NULL. */ -struct modem_context *modem_context_from_iface_dev(struct device *dev); +struct modem_context *modem_context_from_iface_dev(const struct device *dev); /** * @brief Registers modem context. diff --git a/drivers/modem/modem_iface_uart.c b/drivers/modem/modem_iface_uart.c index 73054aa58136b5..89ef8d346ee69a 100644 --- a/drivers/modem/modem_iface_uart.c +++ b/drivers/modem/modem_iface_uart.c @@ -47,7 +47,8 @@ static void modem_iface_uart_flush(struct modem_iface *iface) * * @retval None. */ -static void modem_iface_uart_isr(struct device *uart_dev, void *user_data) +static void modem_iface_uart_isr(const struct device *uart_dev, + void *user_data) { struct modem_context *ctx; struct modem_iface_uart_data *data; diff --git a/drivers/modem/modem_receiver.c b/drivers/modem/modem_receiver.c index 863112d5c91707..9f4a54d9400fd9 100644 --- a/drivers/modem/modem_receiver.c +++ b/drivers/modem/modem_receiver.c @@ -33,7 +33,7 @@ static struct mdm_receiver_context *contexts[MAX_MDM_CTX]; * * @retval Receiver context or NULL. */ -static struct mdm_receiver_context *context_from_dev(struct device *dev) +static struct mdm_receiver_context *context_from_dev(const struct device *dev) { int i; @@ -101,7 +101,7 @@ static void mdm_receiver_flush(struct mdm_receiver_context *ctx) * * @retval None. */ -static void mdm_receiver_isr(struct device *uart_dev, void *user_data) +static void mdm_receiver_isr(const struct device *uart_dev, void *user_data) { struct mdm_receiver_context *ctx; int rx, ret; diff --git a/drivers/modem/modem_receiver.h b/drivers/modem/modem_receiver.h index e86b3d2879d9de..f1126d9f1587bc 100644 --- a/drivers/modem/modem_receiver.h +++ b/drivers/modem/modem_receiver.h @@ -22,7 +22,7 @@ extern "C" { #endif struct mdm_receiver_context { - struct device *uart_dev; + const struct device *uart_dev; /* rx data */ struct ring_buf rx_rb; diff --git a/drivers/modem/modem_shell.c b/drivers/modem/modem_shell.c index 0180a1c8868af6..45acbaf9536b59 100644 --- a/drivers/modem/modem_shell.c +++ b/drivers/modem/modem_shell.c @@ -142,7 +142,7 @@ static int cmd_modem_send(const struct shell *shell, size_t argc, } #if defined(CONFIG_GSM_MUX) -static void uart_mux_cb(struct device *uart, struct device *dev, +static void uart_mux_cb(const struct device *uart, const struct device *dev, int dlci_address, void *user_data) { struct modem_shell_user_data *data = user_data; diff --git a/drivers/modem/ublox-sara-r4.c b/drivers/modem/ublox-sara-r4.c index 828b3b3dbfb7be..2e0620d4e16df3 100644 --- a/drivers/modem/ublox-sara-r4.c +++ b/drivers/modem/ublox-sara-r4.c @@ -1663,7 +1663,7 @@ static uint32_t hash32(char *str, int len) return h; } -static inline uint8_t *modem_get_mac(struct device *dev) +static inline uint8_t *modem_get_mac(const struct device *dev) { struct modem_data *data = dev->data; uint32_t hash_value; @@ -1681,7 +1681,7 @@ static inline uint8_t *modem_get_mac(struct device *dev) static void modem_net_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct modem_data *data = dev->data; /* Direct socket offload used instead of net offload: */ @@ -1712,7 +1712,7 @@ static struct modem_cmd unsol_cmds[] = { MODEM_CMD("+CREG: ", on_cmd_socknotifycreg, 1U, ""), }; -static int modem_init(struct device *dev) +static int modem_init(const struct device *dev) { int ret = 0; diff --git a/drivers/modem/wncm14a2a.c b/drivers/modem/wncm14a2a.c index 9a1a7ed75c5caf..fc52b7418df3ad 100644 --- a/drivers/modem/wncm14a2a.c +++ b/drivers/modem/wncm14a2a.c @@ -183,7 +183,7 @@ struct wncm14a2a_iface_ctx { uint8_t mac_addr[6]; /* GPIO PORT devices */ - struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS]; + const struct device *gpio_port_dev[MAX_MDM_CONTROL_PINS]; /* RX specific attributes */ struct mdm_receiver_context mdm_ctx; @@ -1441,7 +1441,7 @@ static void wncm14a2a_modem_reset(void) return; } -static int wncm14a2a_init(struct device *dev) +static int wncm14a2a_init(const struct device *dev) { int i, ret = 0; @@ -1818,7 +1818,7 @@ static struct net_offload offload_funcs = { .put = offload_put, }; -static inline uint8_t *wncm14a2a_get_mac(struct device *dev) +static inline uint8_t *wncm14a2a_get_mac(const struct device *dev) { struct wncm14a2a_iface_ctx *ctx = dev->data; @@ -1833,7 +1833,7 @@ static inline uint8_t *wncm14a2a_get_mac(struct device *dev) static void offload_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct wncm14a2a_iface_ctx *ctx = dev->data; iface->if_dev->offload = &offload_funcs; diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index ef1f94fbbace07..e3946ebaaeb876 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -24,7 +24,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include -int loopback_dev_init(struct device *dev) +int loopback_dev_init(const struct device *dev) { ARG_UNUSED(dev); @@ -38,7 +38,7 @@ static void loopback_init(struct net_if *iface) NET_LINK_DUMMY); } -static int loopback_send(struct device *dev, struct net_pkt *pkt) +static int loopback_send(const struct device *dev, struct net_pkt *pkt) { struct net_pkt *cloned; int res; diff --git a/drivers/net/ppp.c b/drivers/net/ppp.c index 626545518df9fc..6add89fd4c4435 100644 --- a/drivers/net/ppp.c +++ b/drivers/net/ppp.c @@ -50,7 +50,7 @@ enum ppp_driver_state { K_KERNEL_STACK_DEFINE(ppp_workq, PPP_WORKQ_STACK_SIZE); struct ppp_driver_context { - struct device *dev; + const struct device *dev; struct net_if *iface; /* This net_pkt contains pkt that is being read */ @@ -536,7 +536,7 @@ static uint16_t ppp_escape_byte(uint8_t byte, int *offset) return byte; } -static int ppp_send(struct device *dev, struct net_pkt *pkt) +static int ppp_send(const struct device *dev, struct net_pkt *pkt) { struct ppp_driver_context *ppp = dev->data; struct net_buf *buf = pkt->buffer; @@ -682,7 +682,7 @@ static void ppp_isr_cb_work(struct k_work *work) } #endif /* !CONFIG_NET_TEST */ -static int ppp_driver_init(struct device *dev) +static int ppp_driver_init(const struct device *dev) { struct ppp_driver_context *ppp = dev->data; @@ -766,7 +766,7 @@ static void ppp_iface_init(struct net_if *iface) } #if defined(CONFIG_NET_STATISTICS_PPP) -static struct net_stats_ppp *ppp_get_stats(struct device *dev) +static struct net_stats_ppp *ppp_get_stats(const struct device *dev) { struct ppp_driver_context *context = dev->data; @@ -775,7 +775,7 @@ static struct net_stats_ppp *ppp_get_stats(struct device *dev) #endif #if !defined(CONFIG_NET_TEST) -static void ppp_uart_flush(struct device *dev) +static void ppp_uart_flush(const struct device *dev) { uint8_t c; @@ -784,7 +784,7 @@ static void ppp_uart_flush(struct device *dev) } } -static void ppp_uart_isr(struct device *uart, void *user_data) +static void ppp_uart_isr(const struct device *uart, void *user_data) { struct ppp_driver_context *context = user_data; int rx = 0, ret; @@ -809,7 +809,7 @@ static void ppp_uart_isr(struct device *uart, void *user_data) } #endif /* !CONFIG_NET_TEST */ -static int ppp_start(struct device *dev) +static int ppp_start(const struct device *dev) { struct ppp_driver_context *context = dev->data; @@ -827,7 +827,7 @@ static int ppp_start(struct device *dev) * then use our own config. */ #if IS_ENABLED(CONFIG_GSM_MUX) - struct device *mux; + const struct device *mux; mux = uart_mux_find(CONFIG_GSM_MUX_DLCI_PPP); if (mux == NULL) { @@ -869,7 +869,7 @@ static int ppp_start(struct device *dev) return 0; } -static int ppp_stop(struct device *dev) +static int ppp_stop(const struct device *dev) { struct ppp_driver_context *context = dev->data; diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 61f24822a67d82..1e0dbe89cc0f02 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c @@ -106,7 +106,7 @@ static void slip_writeb_esc(unsigned char c) } } -static int slip_send(struct device *dev, struct net_pkt *pkt) +static int slip_send(const struct device *dev, struct net_pkt *pkt) { struct net_buf *buf; uint8_t *ptr; @@ -363,7 +363,7 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off) return buf; } -static int slip_init(struct device *dev) +static int slip_init(const struct device *dev) { struct slip_context *slip = dev->data; @@ -434,7 +434,7 @@ static void slip_iface_init(struct net_if *iface) static struct slip_context slip_context_data; #if defined(CONFIG_SLIP_TAP) -static enum ethernet_hw_caps eth_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_capabilities(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/neural_net/intel_gna.c b/drivers/neural_net/intel_gna.c index 275161a7cfb4e8..7263ce74b611e6 100644 --- a/drivers/neural_net/intel_gna.c +++ b/drivers/neural_net/intel_gna.c @@ -31,8 +31,8 @@ LOG_MODULE_REGISTER(neural_net); ((struct intel_gna_data *const)(dev)->data) #if LOG_LEVEL >= LOG_LEVEL_DBG -static void intel_gna_regs_dump(struct device *dev); -static void intel_gna_config_desc_dump(struct device *dev); +static void intel_gna_regs_dump(const struct device *dev); +static void intel_gna_config_desc_dump(const struct device *dev); #define INTEL_GNA_REGS_DUMP(dev) intel_gna_regs_dump((dev)) #define INTEL_GNA_CONFIG_DESC_DUMP(dev) intel_gna_config_desc_dump((dev)) #else @@ -48,7 +48,7 @@ static struct intel_gna_config_desc __aligned(GNA_PG_SIZE_IN_BYTES) static struct intel_gna_page_table __aligned(GNA_PG_SIZE_IN_BYTES) gna_page_table[GNA_NUM_PG_TABLES_NEEDED]; -static void intel_gna_interrupt_handler(struct device *dev) +static void intel_gna_interrupt_handler(const struct device *dev) { struct intel_gna_data *const gna = DEV_DATA(dev); @@ -165,7 +165,7 @@ static int intel_gna_setup_page_table(void *physical, size_t size, return 0; } -static int intel_gna_initialize(struct device *dev) +static int intel_gna_initialize(const struct device *dev) { struct intel_gna_data *const gna = DEV_DATA(dev); uint32_t page_dir_entry; @@ -219,7 +219,8 @@ static int intel_gna_initialize(struct device *dev) return 0; } -static int intel_gna_configure(struct device *dev, struct gna_config *cfg) +static int intel_gna_configure(const struct device *dev, + struct gna_config *cfg) { const struct intel_gna_config *const dev_cfg = DEV_CFG(dev); struct intel_gna_data *const gna = DEV_DATA(dev); @@ -275,8 +276,9 @@ static int intel_gna_configure(struct device *dev, struct gna_config *cfg) return 0; } -static int intel_gna_register_model(struct device *dev, - struct gna_model_info *model, void **model_handle) +static int intel_gna_register_model(const struct device *dev, + struct gna_model_info *model, + void **model_handle) { struct intel_gna_data *const gna = DEV_DATA(dev); struct intel_gna_model *gna_model; @@ -380,7 +382,8 @@ static int intel_gna_register_model(struct device *dev, return 0; } -static int intel_gna_deregister_model(struct device *dev, void *model_handle) +static int intel_gna_deregister_model(const struct device *dev, + void *model_handle) { struct intel_gna_data *const gna = DEV_DATA(dev); struct intel_gna_model *gna_model; @@ -397,8 +400,9 @@ static int intel_gna_deregister_model(struct device *dev, void *model_handle) return 0; } -static int intel_gna_infer(struct device *dev, struct gna_inference_req *req, - gna_callback callback) +static int intel_gna_infer(const struct device *dev, + struct gna_inference_req *req, + gna_callback callback) { struct intel_gna_data *const gna = DEV_DATA(dev); volatile struct intel_gna_regs *regs = gna->regs; @@ -475,7 +479,7 @@ static int intel_gna_infer(struct device *dev, struct gna_inference_req *req, } #if LOG_LEVEL >= LOG_LEVEL_DBG -static void intel_gna_regs_dump(struct device *dev) +static void intel_gna_regs_dump(const struct device *dev) { struct intel_gna_data *const gna = DEV_DATA(dev); volatile struct intel_gna_regs *regs = gna->regs; @@ -496,7 +500,7 @@ static void intel_gna_regs_dump(struct device *dev) LOG_DBG("gnaversion :%08x", regs->gnaversion); } -static void intel_gna_config_desc_dump(struct device *dev) +static void intel_gna_config_desc_dump(const struct device *dev) { struct intel_gna_data *const gna = DEV_DATA(dev); volatile struct intel_gna_regs *regs = gna->regs; diff --git a/drivers/pcie/endpoint/pcie_ep_bcm_iproc.c b/drivers/pcie/endpoint/pcie_ep_bcm_iproc.c index ec25feb82c6979..e65a041f57d6da 100644 --- a/drivers/pcie/endpoint/pcie_ep_bcm_iproc.c +++ b/drivers/pcie/endpoint/pcie_ep_bcm_iproc.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(iproc_pcie); #define sys_read64(addr) (((uint64_t)(sys_read32(addr + 4)) << 32) | \ sys_read32(addr)) -static int iproc_pcie_conf_read(struct device *dev, uint32_t offset, +static int iproc_pcie_conf_read(const struct device *dev, uint32_t offset, uint32_t *data) { const struct iproc_pcie_ep_config *cfg = dev->config; @@ -35,7 +35,7 @@ static int iproc_pcie_conf_read(struct device *dev, uint32_t offset, return 0; } -static void iproc_pcie_conf_write(struct device *dev, uint32_t offset, +static void iproc_pcie_conf_write(const struct device *dev, uint32_t offset, uint32_t data) { const struct iproc_pcie_ep_config *cfg = dev->config; @@ -47,7 +47,7 @@ static void iproc_pcie_conf_write(struct device *dev, uint32_t offset, pcie_write32(data, &cfg->base->paxb_config_ind_data); } -static int iproc_pcie_map_addr(struct device *dev, uint64_t pcie_addr, +static int iproc_pcie_map_addr(const struct device *dev, uint64_t pcie_addr, uint64_t *mapped_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type) { @@ -117,7 +117,8 @@ static int iproc_pcie_map_addr(struct device *dev, uint64_t pcie_addr, return ret; } -static void iproc_pcie_unmap_addr(struct device *dev, uint64_t mapped_addr) +static void iproc_pcie_unmap_addr(const struct device *dev, + uint64_t mapped_addr) { struct iproc_pcie_ep_ctx *ctx = dev->data; k_spinlock_key_t key; @@ -145,7 +146,8 @@ static void iproc_pcie_unmap_addr(struct device *dev, uint64_t mapped_addr) k_spin_unlock(&ctx->ob_map_lock, key); } -static int iproc_pcie_generate_msi(struct device *dev, const uint32_t msi_num) +static int iproc_pcie_generate_msi(const struct device *dev, + const uint32_t msi_num) { int ret = 0; #ifdef CONFIG_PCIE_EP_BCM_IPROC_V2 @@ -182,7 +184,8 @@ static int iproc_pcie_generate_msi(struct device *dev, const uint32_t msi_num) return ret; } -static int iproc_pcie_generate_msix(struct device *dev, const uint32_t msix_num) +static int iproc_pcie_generate_msix(const struct device *dev, + const uint32_t msix_num) { uint64_t addr; uint32_t data, msix_offset; @@ -211,7 +214,7 @@ static int iproc_pcie_generate_msix(struct device *dev, const uint32_t msix_num) return ret; } -static int iproc_pcie_raise_irq(struct device *dev, +static int iproc_pcie_raise_irq(const struct device *dev, enum pci_ep_irq_type irq_type, uint32_t irq_num) { @@ -240,7 +243,7 @@ static int iproc_pcie_raise_irq(struct device *dev, return ret; } -static int iproc_pcie_register_reset_cb(struct device *dev, +static int iproc_pcie_register_reset_cb(const struct device *dev, enum pcie_reset reset, pcie_ep_reset_callback_t cb, void *arg) { @@ -259,7 +262,7 @@ static int iproc_pcie_register_reset_cb(struct device *dev, #if DT_INST_IRQ_HAS_NAME(0, perst) static void iproc_pcie_perst(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct iproc_pcie_ep_ctx *ctx = dev->data; void *reset_data; uint32_t data; @@ -281,7 +284,7 @@ static void iproc_pcie_perst(void *arg) #if DT_INST_IRQ_HAS_NAME(0, perst_inband) static void iproc_pcie_hot_reset(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct iproc_pcie_ep_ctx *ctx = dev->data; void *reset_data; uint32_t data; @@ -303,7 +306,7 @@ static void iproc_pcie_hot_reset(void *arg) #if DT_INST_IRQ_HAS_NAME(0, flr) static void iproc_pcie_flr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct iproc_pcie_ep_config *cfg = dev->config; struct iproc_pcie_ep_ctx *ctx = dev->data; void *reset_data; @@ -338,7 +341,7 @@ static void iproc_pcie_flr(void *arg) DEVICE_DECLARE(iproc_pcie_ep_0); -static void iproc_pcie_reset_config(struct device *dev) +static void iproc_pcie_reset_config(const struct device *dev) { uint32_t data; const struct iproc_pcie_ep_config *cfg = dev->config; @@ -390,7 +393,7 @@ static void iproc_pcie_reset_config(struct device *dev) } #ifdef CONFIG_PCIE_EP_BCM_IPROC_INIT_CFG -static void iproc_pcie_msix_config(struct device *dev) +static void iproc_pcie_msix_config(const struct device *dev) { /* * Configure capability of generating 16 messages, @@ -402,7 +405,7 @@ static void iproc_pcie_msix_config(struct device *dev) iproc_pcie_conf_write(dev, MSIX_PBA_OFF_BIR, MSIX_PBA_B2_10800); } -static void iproc_pcie_msi_config(struct device *dev) +static void iproc_pcie_msi_config(const struct device *dev) { uint32_t data; @@ -427,7 +430,7 @@ static int iproc_pcie_mode_check(const struct iproc_pcie_ep_config *cfg) return 0; } -static int iproc_pcie_ep_init(struct device *dev) +static int iproc_pcie_ep_init(const struct device *dev) { const struct iproc_pcie_ep_config *cfg = dev->config; struct iproc_pcie_ep_ctx *ctx = dev->data; diff --git a/drivers/pcie/endpoint/pcie_ep_common.c b/drivers/pcie/endpoint/pcie_ep_common.c index 92106e25b67c90..2b0a64e37211ad 100644 --- a/drivers/pcie/endpoint/pcie_ep_common.c +++ b/drivers/pcie/endpoint/pcie_ep_common.c @@ -36,7 +36,7 @@ static int pcie_ep_mapped_copy(uint64_t mapped_addr, uintptr_t local_addr, * Helper API to achieve data transfer with memcpy operation * through PCIe outbound memory */ -int pcie_ep_xfer_data_memcpy(struct device *dev, uint64_t pcie_addr, +int pcie_ep_xfer_data_memcpy(const struct device *dev, uint64_t pcie_addr, uintptr_t *local_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type, enum xfer_direction dir) diff --git a/drivers/peci/peci_handlers.c b/drivers/peci/peci_handlers.c index 062d6070daace5..f7b55e083bdfe0 100644 --- a/drivers/peci/peci_handlers.c +++ b/drivers/peci/peci_handlers.c @@ -8,7 +8,8 @@ #include -static inline int z_vrfy_peci_config(struct device *dev, uint32_t bitrate) +static inline int z_vrfy_peci_config(const struct device *dev, + uint32_t bitrate) { Z_OOPS(Z_SYSCALL_DRIVER_PECI(dev, config)); @@ -16,7 +17,7 @@ static inline int z_vrfy_peci_config(struct device *dev, uint32_t bitrate) } #include -static inline int z_vrfy_peci_enable(struct device *dev) +static inline int z_vrfy_peci_enable(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_PECI(dev, enable)); @@ -24,7 +25,7 @@ static inline int z_vrfy_peci_enable(struct device *dev) } #include -static inline int z_vrfy_peci_disable(struct device *dev) +static inline int z_vrfy_peci_disable(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_PECI(dev, disable)); @@ -32,7 +33,7 @@ static inline int z_vrfy_peci_disable(struct device *dev) } #include -static inline int z_vrfy_peci_transfer(struct device *dev, +static inline int z_vrfy_peci_transfer(const struct device *dev, struct peci_msg *msg) { struct peci_msg msg_copy; diff --git a/drivers/peci/peci_mchp_xec.c b/drivers/peci/peci_mchp_xec.c index 53e07ecb7ee8b4..00ce44ae64f099 100644 --- a/drivers/peci/peci_mchp_xec.c +++ b/drivers/peci/peci_mchp_xec.c @@ -66,7 +66,7 @@ static int check_bus_idle(PECI_Type *base) return 0; } -static int peci_xec_configure(struct device *dev, uint32_t bitrate) +static int peci_xec_configure(const struct device *dev, uint32_t bitrate) { ARG_UNUSED(dev); @@ -88,7 +88,7 @@ static int peci_xec_configure(struct device *dev, uint32_t bitrate) return 0; } -static int peci_xec_disable(struct device *dev) +static int peci_xec_disable(const struct device *dev) { ARG_UNUSED(dev); int ret; @@ -109,7 +109,7 @@ static int peci_xec_disable(struct device *dev) return 0; } -static int peci_xec_enable(struct device *dev) +static int peci_xec_enable(const struct device *dev) { ARG_UNUSED(dev); PECI_Type *base = peci_xec_config.base; @@ -122,7 +122,7 @@ static int peci_xec_enable(struct device *dev) return 0; } -static int peci_xec_write(struct device *dev, struct peci_msg *msg) +static int peci_xec_write(const struct device *dev, struct peci_msg *msg) { ARG_UNUSED(dev); int i; @@ -189,7 +189,7 @@ static int peci_xec_write(struct device *dev, struct peci_msg *msg) return 0; } -static int peci_xec_read(struct device *dev, struct peci_msg *msg) +static int peci_xec_read(const struct device *dev, struct peci_msg *msg) { ARG_UNUSED(dev); int i; @@ -239,7 +239,7 @@ static int peci_xec_read(struct device *dev, struct peci_msg *msg) return 0; } -static int peci_xec_transfer(struct device *dev, struct peci_msg *msg) +static int peci_xec_transfer(const struct device *dev, struct peci_msg *msg) { ARG_UNUSED(dev); int ret; @@ -322,7 +322,7 @@ static const struct peci_driver_api peci_xec_driver_api = { .transfer = peci_xec_transfer, }; -static int peci_xec_init(struct device *dev) +static int peci_xec_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/pinmux/pinmux_cc13xx_cc26xx.c b/drivers/pinmux/pinmux_cc13xx_cc26xx.c index 0e0e5a6414b9a5..3fb26334e0d803 100644 --- a/drivers/pinmux/pinmux_cc13xx_cc26xx.c +++ b/drivers/pinmux/pinmux_cc13xx_cc26xx.c @@ -11,7 +11,8 @@ #include -static int pinmux_cc13xx_cc26xx_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_cc13xx_cc26xx_set(const struct device *dev, uint32_t pin, + uint32_t func) { ARG_UNUSED(dev); @@ -23,7 +24,8 @@ static int pinmux_cc13xx_cc26xx_set(struct device *dev, uint32_t pin, uint32_t f return 0; } -static int pinmux_cc13xx_cc26xx_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_cc13xx_cc26xx_get(const struct device *dev, uint32_t pin, + uint32_t *func) { ARG_UNUSED(dev); @@ -34,7 +36,8 @@ static int pinmux_cc13xx_cc26xx_get(struct device *dev, uint32_t pin, uint32_t * return 0; } -static int pinmux_cc13xx_cc26xx_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_cc13xx_cc26xx_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { ARG_UNUSED(dev); @@ -52,7 +55,8 @@ static int pinmux_cc13xx_cc26xx_pullup(struct device *dev, uint32_t pin, uint8_t return -EINVAL; } -static int pinmux_cc13xx_cc26xx_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_cc13xx_cc26xx_input(const struct device *dev, uint32_t pin, + uint8_t func) { ARG_UNUSED(dev); @@ -70,7 +74,7 @@ static int pinmux_cc13xx_cc26xx_input(struct device *dev, uint32_t pin, uint8_t return -EINVAL; } -static int pinmux_cc13xx_cc26xx_init(struct device *dev) +static int pinmux_cc13xx_cc26xx_init(const struct device *dev) { ARG_UNUSED(dev); return 0; diff --git a/drivers/pinmux/pinmux_esp32.c b/drivers/pinmux/pinmux_esp32.c index 18b83ddc51a146..c7109f410687a9 100644 --- a/drivers/pinmux/pinmux_esp32.c +++ b/drivers/pinmux/pinmux_esp32.c @@ -75,7 +75,7 @@ static int set_reg(uint32_t pin, uint32_t clr_mask, uint32_t set_mask) return 0; } -static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_set(const struct device *dev, uint32_t pin, uint32_t func) { ARG_UNUSED(dev); @@ -91,7 +91,7 @@ static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func) return set_reg(pin, MCU_SEL_M, func<= HSDK_PINMUX_FUNS || pin >= HSDK_PINMUX_SELS) @@ -30,7 +31,8 @@ static int pinmux_hsdk_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_hsdk_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_hsdk_get(const struct device *dev, uint32_t pin, + uint32_t *func) { if (pin >= HSDK_PINMUX_SELS || func == NULL) @@ -41,17 +43,19 @@ static int pinmux_hsdk_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_hsdk_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_hsdk_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_hsdk_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_hsdk_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_hsdk_init(struct device *dev) +static int pinmux_hsdk_init(const struct device *dev) { ARG_UNUSED(dev); return 0; diff --git a/drivers/pinmux/pinmux_intel_s1000.c b/drivers/pinmux/pinmux_intel_s1000.c index 3396f6a8d2f194..52caf91b6deab7 100644 --- a/drivers/pinmux/pinmux_intel_s1000.c +++ b/drivers/pinmux/pinmux_intel_s1000.c @@ -14,7 +14,7 @@ static volatile uint32_t *iomux_ctrl_regs = (volatile uint32_t *)DT_INST_REG_ADD #define PINMUX_CTRL_REG_COUNT (DT_INST_REG_SIZE(0) / 4) -static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_set(const struct device *dev, uint32_t pin, uint32_t func) { uint32_t lsb, msb; uint32_t index; @@ -43,7 +43,7 @@ static int pinmux_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_get(const struct device *dev, uint32_t pin, uint32_t *func) { uint32_t lsb, msb; uint32_t index; @@ -71,12 +71,12 @@ static int pinmux_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_pullup(const struct device *dev, uint32_t pin, uint8_t func) { return -ENOSYS; } -static int pinmux_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_input(const struct device *dev, uint32_t pin, uint8_t func) { return -ENOSYS; } @@ -88,7 +88,7 @@ static struct pinmux_driver_api apis = { .input = pinmux_input }; -static int pinmux_init(struct device *device) +static int pinmux_init(const struct device *device) { ARG_UNUSED(device); return 0; diff --git a/drivers/pinmux/pinmux_lpc11u6x.c b/drivers/pinmux/pinmux_lpc11u6x.c index eb5898468a2d03..acd1839a0459e9 100644 --- a/drivers/pinmux/pinmux_lpc11u6x.c +++ b/drivers/pinmux/pinmux_lpc11u6x.c @@ -32,7 +32,8 @@ struct pinmux_lpc11u6x_config { uint8_t npins; }; -static int pinmux_lpc11u6x_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_lpc11u6x_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_lpc11u6x_config *config = DEV_CFG(dev); volatile uint32_t *base; @@ -54,7 +55,7 @@ static int pinmux_lpc11u6x_set(struct device *dev, uint32_t pin, uint32_t func) } static int -pinmux_lpc11u6x_get(struct device *dev, uint32_t pin, uint32_t *func) +pinmux_lpc11u6x_get(const struct device *dev, uint32_t pin, uint32_t *func) { const struct pinmux_lpc11u6x_config *config = DEV_CFG(dev); volatile uint32_t *base; @@ -76,18 +77,18 @@ pinmux_lpc11u6x_get(struct device *dev, uint32_t pin, uint32_t *func) } static int -pinmux_lpc11u6x_pullup(struct device *dev, uint32_t pin, uint8_t func) +pinmux_lpc11u6x_pullup(const struct device *dev, uint32_t pin, uint8_t func) { return -ENOTSUP; } static int -pinmux_lpc11u6x_input(struct device *dev, uint32_t pin, uint8_t func) +pinmux_lpc11u6x_input(const struct device *dev, uint32_t pin, uint8_t func) { return -ENOTSUP; } -static int pinmux_lpc11u6x_init(struct device *dev) +static int pinmux_lpc11u6x_init(const struct device *dev) { return 0; } diff --git a/drivers/pinmux/pinmux_mchp_xec.c b/drivers/pinmux/pinmux_mchp_xec.c index 90f7a0b014f8c9..1332cfd572095b 100644 --- a/drivers/pinmux/pinmux_mchp_xec.c +++ b/drivers/pinmux/pinmux_mchp_xec.c @@ -23,7 +23,8 @@ struct pinmux_xec_config { uint32_t port_num; }; -static int pinmux_xec_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_xec_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_xec_config *config = dev->config; __IO uint32_t *current_pcr1; @@ -76,7 +77,8 @@ static int pinmux_xec_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_xec_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_xec_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_xec_config *config = dev->config; __IO uint32_t *current_pcr1; @@ -94,17 +96,19 @@ static int pinmux_xec_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_xec_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_xec_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_xec_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_xec_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_xec_init(struct device *dev) +static int pinmux_xec_init(const struct device *dev) { /* Nothing to do. The PCR clock is enabled at reset. */ return 0; diff --git a/drivers/pinmux/pinmux_mcux.c b/drivers/pinmux/pinmux_mcux.c index 3a87bed9569233..b1df4934a1ccf7 100644 --- a/drivers/pinmux/pinmux_mcux.c +++ b/drivers/pinmux/pinmux_mcux.c @@ -15,7 +15,8 @@ struct pinmux_mcux_config { PORT_Type *base; }; -static int pinmux_mcux_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_mcux_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_mcux_config *config = dev->config; PORT_Type *base = config->base; @@ -25,7 +26,8 @@ static int pinmux_mcux_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_mcux_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_mcux_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_mcux_config *config = dev->config; PORT_Type *base = config->base; @@ -35,17 +37,19 @@ static int pinmux_mcux_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_mcux_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_mcux_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_mcux_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_mcux_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_mcux_init(struct device *dev) +static int pinmux_mcux_init(const struct device *dev) { const struct pinmux_mcux_config *config = dev->config; diff --git a/drivers/pinmux/pinmux_mcux_lpc.c b/drivers/pinmux/pinmux_mcux_lpc.c index 150bf71171b4be..3619c806d7a073 100644 --- a/drivers/pinmux/pinmux_mcux_lpc.c +++ b/drivers/pinmux/pinmux_mcux_lpc.c @@ -25,7 +25,8 @@ struct pinmux_mcux_lpc_config { uint32_t port_no; }; -static int pinmux_mcux_lpc_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_mcux_lpc_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_mcux_lpc_config *config = dev->config; #ifdef IOPCTL @@ -40,7 +41,8 @@ static int pinmux_mcux_lpc_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_mcux_lpc_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_mcux_lpc_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_mcux_lpc_config *config = dev->config; #ifdef IOPCTL @@ -55,17 +57,19 @@ static int pinmux_mcux_lpc_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_mcux_lpc_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_mcux_lpc_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_mcux_lpc_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_mcux_lpc_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_mcux_lpc_init(struct device *dev) +static int pinmux_mcux_lpc_init(const struct device *dev) { #ifndef IOPCTL const struct pinmux_mcux_lpc_config *config = dev->config; diff --git a/drivers/pinmux/pinmux_npcx.c b/drivers/pinmux/pinmux_npcx.c index cf0ea9a68a7f33..39fa1c39a8bbee 100644 --- a/drivers/pinmux/pinmux_npcx.c +++ b/drivers/pinmux/pinmux_npcx.c @@ -63,7 +63,7 @@ void soc_pinctrl_mux_configure(const struct npcx_alt *alts_list, } /* Pin-control driver registration */ -static int npcx_pinctrl_init(struct device *dev) +static int npcx_pinctrl_init(const struct device *dev) { struct scfg_reg *inst = HAL_INSTANCE(dev); diff --git a/drivers/pinmux/pinmux_rv32m1.c b/drivers/pinmux/pinmux_rv32m1.c index 69b2a2a08e3ed2..595247938cd436 100644 --- a/drivers/pinmux/pinmux_rv32m1.c +++ b/drivers/pinmux/pinmux_rv32m1.c @@ -19,7 +19,8 @@ struct pinmux_rv32m1_config { PORT_Type *base; }; -static int pinmux_rv32m1_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_rv32m1_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_rv32m1_config *config = dev->config; PORT_Type *base = config->base; @@ -29,7 +30,8 @@ static int pinmux_rv32m1_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_rv32m1_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_rv32m1_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_rv32m1_config *config = dev->config; PORT_Type *base = config->base; @@ -39,17 +41,19 @@ static int pinmux_rv32m1_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_rv32m1_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_rv32m1_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_rv32m1_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_rv32m1_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_rv32m1_init(struct device *dev) +static int pinmux_rv32m1_init(const struct device *dev) { const struct pinmux_rv32m1_config *config = dev->config; diff --git a/drivers/pinmux/pinmux_sam0.c b/drivers/pinmux/pinmux_sam0.c index 96a168e4802d55..7b9d2a76fdf3ad 100644 --- a/drivers/pinmux/pinmux_sam0.c +++ b/drivers/pinmux/pinmux_sam0.c @@ -11,7 +11,8 @@ struct pinmux_sam0_config { PortGroup *regs; }; -static int pinmux_sam0_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_sam0_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_sam0_config *cfg = dev->config; bool odd_pin = pin & 1; @@ -31,7 +32,8 @@ static int pinmux_sam0_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_sam0_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_sam0_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_sam0_config *cfg = dev->config; bool odd_pin = pin & 1; @@ -46,17 +48,19 @@ static int pinmux_sam0_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_sam0_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_sam0_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_sam0_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_sam0_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_sam0_init(struct device *dev) +static int pinmux_sam0_init(const struct device *dev) { /* Nothing to do. The GPIO clock is enabled at reset. */ return 0; diff --git a/drivers/pinmux/pinmux_sifive.c b/drivers/pinmux/pinmux_sifive.c index e605ccc8a6d0e4..5e20fcae14842a 100644 --- a/drivers/pinmux/pinmux_sifive.c +++ b/drivers/pinmux/pinmux_sifive.c @@ -29,7 +29,8 @@ struct pinmux_sifive_regs_t { #define DEV_PINMUX(dev) \ ((struct pinmux_sifive_regs_t *)(DEV_CFG(dev))->base) -static int pinmux_sifive_set(struct device *dev, uint32_t pin, uint32_t func) +static int pinmux_sifive_set(const struct device *dev, uint32_t pin, + uint32_t func) { volatile struct pinmux_sifive_regs_t *pinmux = DEV_PINMUX(dev); @@ -48,7 +49,8 @@ static int pinmux_sifive_set(struct device *dev, uint32_t pin, uint32_t func) return 0; } -static int pinmux_sifive_get(struct device *dev, uint32_t pin, uint32_t *func) +static int pinmux_sifive_get(const struct device *dev, uint32_t pin, + uint32_t *func) { volatile struct pinmux_sifive_regs_t *pinmux = DEV_PINMUX(dev); @@ -62,17 +64,19 @@ static int pinmux_sifive_get(struct device *dev, uint32_t pin, uint32_t *func) return 0; } -static int pinmux_sifive_pullup(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_sifive_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_sifive_input(struct device *dev, uint32_t pin, uint8_t func) +static int pinmux_sifive_input(const struct device *dev, uint32_t pin, + uint8_t func) { return -ENOTSUP; } -static int pinmux_sifive_init(struct device *dev) +static int pinmux_sifive_init(const struct device *dev) { volatile struct pinmux_sifive_regs_t *pinmux = DEV_PINMUX(dev); diff --git a/drivers/pinmux/stm32/pinmux_stm32.c b/drivers/pinmux/stm32/pinmux_stm32.c index 01fd87ffd14f55..39a4a575422c8c 100644 --- a/drivers/pinmux/stm32/pinmux_stm32.c +++ b/drivers/pinmux/stm32/pinmux_stm32.c @@ -84,7 +84,7 @@ static const uint32_t ports_enable[STM32_PORTS_MAX] = { * * @return 0 on success, error otherwise */ -static int enable_port(uint32_t port, struct device *clk) +static int enable_port(uint32_t port, const struct device *clk) { /* enable port clock */ if (!clk) { @@ -126,7 +126,7 @@ static int stm32_pin_configure(int pin, int func, int altf) * @return 0 on success, error otherwise */ int z_pinmux_stm32_set(uint32_t pin, uint32_t func, - struct device *clk) + const struct device *clk) { /* make sure to enable port clock first */ if (enable_port(STM32_PORT(pin), clk)) { @@ -145,7 +145,7 @@ int z_pinmux_stm32_set(uint32_t pin, uint32_t func, void stm32_setup_pins(const struct pin_config *pinconf, size_t pins) { - struct device *clk; + const struct device *clk; int i; clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); diff --git a/drivers/pinmux/stm32/pinmux_stm32.h b/drivers/pinmux/stm32/pinmux_stm32.h index fa5cebcfcbc9d5..6839a2e84b195c 100644 --- a/drivers/pinmux/stm32/pinmux_stm32.h +++ b/drivers/pinmux/stm32/pinmux_stm32.h @@ -78,7 +78,7 @@ clock_control_subsys_t stm32_get_port_clock(int port); * for the port */ int z_pinmux_stm32_set(uint32_t pin, uint32_t func, - struct device *clk); + const struct device *clk); /** * @brief helper for obtaining pin configuration for the board diff --git a/drivers/ps2/ps2_handlers.c b/drivers/ps2/ps2_handlers.c index 4375273460f0b1..dc8502828c7033 100644 --- a/drivers/ps2/ps2_handlers.c +++ b/drivers/ps2/ps2_handlers.c @@ -30,7 +30,7 @@ Z_SYSCALL_HANDLER(ps2_read, dev, value) Z_SYSCALL_HANDLER(ps2_enable_callback) { - return z_impl_ps2_enable_callback((struct device *)dev); + return z_impl_ps2_enable_callback((const struct device *)dev); } Z_SYSCALL_HANDLER(ps2_disable_callback, dev) diff --git a/drivers/ps2/ps2_mchp_xec.c b/drivers/ps2/ps2_mchp_xec.c index c6f5ec0b21ff7a..010d1c9418d580 100644 --- a/drivers/ps2/ps2_mchp_xec.c +++ b/drivers/ps2/ps2_mchp_xec.c @@ -30,7 +30,8 @@ struct ps2_xec_data { struct k_sem tx_lock; }; -static int ps2_xec_configure(struct device *dev, ps2_callback_t callback_isr) +static int ps2_xec_configure(const struct device *dev, + ps2_callback_t callback_isr) { const struct ps2_xec_config *config = dev->config; struct ps2_xec_data *data = dev->data; @@ -67,7 +68,7 @@ static int ps2_xec_configure(struct device *dev, ps2_callback_t callback_isr) } -static int ps2_xec_write(struct device *dev, uint8_t value) +static int ps2_xec_write(const struct device *dev, uint8_t value) { const struct ps2_xec_config *config = dev->config; struct ps2_xec_data *data = dev->data; @@ -116,7 +117,7 @@ static int ps2_xec_write(struct device *dev, uint8_t value) return 0; } -static int ps2_xec_inhibit_interface(struct device *dev) +static int ps2_xec_inhibit_interface(const struct device *dev) { const struct ps2_xec_config *config = dev->config; struct ps2_xec_data *data = dev->data; @@ -135,7 +136,7 @@ static int ps2_xec_inhibit_interface(struct device *dev) return 0; } -static int ps2_xec_enable_interface(struct device *dev) +static int ps2_xec_enable_interface(const struct device *dev) { const struct ps2_xec_config *config = dev->config; struct ps2_xec_data *data = dev->data; @@ -150,7 +151,7 @@ static int ps2_xec_enable_interface(struct device *dev) } static void ps2_xec_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct ps2_xec_config *config = dev->config; struct ps2_xec_data *data = dev->data; PS2_Type *base = config->base; @@ -188,7 +189,7 @@ static const struct ps2_driver_api ps2_xec_driver_api = { }; #ifdef CONFIG_PS2_XEC_0 -static int ps2_xec_init_0(struct device *dev); +static int ps2_xec_init_0(const struct device *dev); static const struct ps2_xec_config ps2_xec_config_0 = { .base = (PS2_Type *) DT_INST_REG_ADDR(0), @@ -206,7 +207,7 @@ DEVICE_AND_API_INIT(ps2_xec_0, DT_INST_LABEL(0), &ps2_xec_driver_api); -static int ps2_xec_init_0(struct device *dev) +static int ps2_xec_init_0(const struct device *dev) { ARG_UNUSED(dev); @@ -225,7 +226,7 @@ static int ps2_xec_init_0(struct device *dev) #endif /* CONFIG_PS2_XEC_0 */ #ifdef CONFIG_PS2_XEC_1 -static int ps2_xec_init_1(struct device *dev); +static int ps2_xec_init_1(const struct device *dev); static const struct ps2_xec_config ps2_xec_config_1 = { .base = (PS2_Type *) DT_INST_REG_ADDR(1), @@ -243,7 +244,7 @@ DEVICE_AND_API_INIT(ps2_xec_1, DT_INST_LABEL(1), POST_KERNEL, CONFIG_PS2_INIT_PRIORITY, &ps2_xec_driver_api); -static int ps2_xec_init_1(struct device *dev) +static int ps2_xec_init_1(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/ptp_clock/ptp_clock.c b/drivers/ptp_clock/ptp_clock.c index 5c81d56be257f3..48578d90b7f816 100644 --- a/drivers/ptp_clock/ptp_clock.c +++ b/drivers/ptp_clock/ptp_clock.c @@ -8,7 +8,7 @@ #include #ifdef CONFIG_USERSPACE -int z_vrfy_ptp_clock_get(struct device *dev, +int z_vrfy_ptp_clock_get(const struct device *dev, struct net_ptp_time *tm) { struct net_ptp_time ptp_time; @@ -17,7 +17,7 @@ int z_vrfy_ptp_clock_get(struct device *dev, Z_OOPS(Z_SYSCALL_DRIVER_PTP_CLOCK(dev, get)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(tm, sizeof(struct net_ptp_time))); - ret = z_impl_ptp_clock_get((struct device *)dev, &ptp_time); + ret = z_impl_ptp_clock_get((const struct device *)dev, &ptp_time); if (ret != 0) { return 0; } diff --git a/drivers/pwm/pwm_dw.c b/drivers/pwm/pwm_dw.c index e6d5d5d06d4779..8645610dd44614 100644 --- a/drivers/pwm/pwm_dw.c +++ b/drivers/pwm/pwm_dw.c @@ -70,7 +70,8 @@ struct pwm_dw_config { * * @return The base address of that particular timer */ -static inline int pwm_dw_timer_base_addr(struct device *dev, uint32_t timer) +static inline int pwm_dw_timer_base_addr(const struct device *dev, + uint32_t timer) { const struct pwm_dw_config * const cfg = (const struct pwm_dw_config *)dev->config; @@ -86,7 +87,8 @@ static inline int pwm_dw_timer_base_addr(struct device *dev, uint32_t timer) * * @return The load count 2 address of that particular timer */ -static inline int pwm_dw_timer_ldcnt2_addr(struct device *dev, uint32_t timer) +static inline int pwm_dw_timer_ldcnt2_addr(const struct device *dev, + uint32_t timer) { const struct pwm_dw_config * const cfg = (const struct pwm_dw_config *)dev->config; @@ -95,7 +97,7 @@ static inline int pwm_dw_timer_ldcnt2_addr(struct device *dev, uint32_t timer) } -static int __set_one_port(struct device *dev, uint32_t pwm, +static int __set_one_port(const struct device *dev, uint32_t pwm, uint32_t on, uint32_t off) { uint32_t reg_addr; @@ -139,7 +141,7 @@ static int __set_one_port(struct device *dev, uint32_t pwm, * * @return 0 */ -static int pwm_dw_pin_set_cycles(struct device *dev, +static int pwm_dw_pin_set_cycles(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -183,7 +185,7 @@ static struct pwm_driver_api pwm_dw_drv_api_funcs = { * @param dev Device struct * @return 0 if successful, failed otherwise. */ -int pwm_dw_init(struct device *dev) +int pwm_dw_init(const struct device *dev) { return 0; } diff --git a/drivers/pwm/pwm_handlers.c b/drivers/pwm/pwm_handlers.c index 609e8150b87af7..2c4ce8bc4497ca 100644 --- a/drivers/pwm/pwm_handlers.c +++ b/drivers/pwm/pwm_handlers.c @@ -7,22 +7,25 @@ #include #include -static inline int z_vrfy_pwm_pin_set_cycles(struct device *dev, uint32_t pwm, +static inline int z_vrfy_pwm_pin_set_cycles(const struct device *dev, + uint32_t pwm, uint32_t period, uint32_t pulse, pwm_flags_t flags) { Z_OOPS(Z_SYSCALL_DRIVER_PWM(dev, pin_set)); - return z_impl_pwm_pin_set_cycles((struct device *)dev, pwm, period, + return z_impl_pwm_pin_set_cycles((const struct device *)dev, pwm, + period, pulse, flags); } #include -static inline int z_vrfy_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, - uint64_t *cycles) +static inline int z_vrfy_pwm_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, + uint64_t *cycles) { Z_OOPS(Z_SYSCALL_DRIVER_PWM(dev, get_cycles_per_sec)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(cycles, sizeof(uint64_t))); - return z_impl_pwm_get_cycles_per_sec((struct device *)dev, - pwm, (uint64_t *)cycles); + return z_impl_pwm_get_cycles_per_sec((const struct device *)dev, + pwm, (uint64_t *)cycles); } #include diff --git a/drivers/pwm/pwm_imx.c b/drivers/pwm/pwm_imx.c index 4917a37d2dfbe1..277105738793fc 100644 --- a/drivers/pwm/pwm_imx.c +++ b/drivers/pwm/pwm_imx.c @@ -40,7 +40,7 @@ static bool imx_pwm_is_enabled(PWM_Type *base) return PWM_PWMCR_REG(base) & PWM_PWMCR_EN_MASK; } -static int imx_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int imx_pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { PWM_Type *base = DEV_BASE(dev); @@ -51,7 +51,7 @@ static int imx_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int imx_pwm_pin_set(struct device *dev, uint32_t pwm, +static int imx_pwm_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -143,7 +143,7 @@ static int imx_pwm_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int imx_pwm_init(struct device *dev) +static int imx_pwm_init(const struct device *dev) { struct imx_pwm_data *data = DEV_DATA(dev); PWM_Type *base = DEV_BASE(dev); diff --git a/drivers/pwm/pwm_led_esp32.c b/drivers/pwm/pwm_led_esp32.c index bb128ad34ba2c2..0e1ade203f249e 100644 --- a/drivers/pwm/pwm_led_esp32.c +++ b/drivers/pwm/pwm_led_esp32.c @@ -213,7 +213,7 @@ static int pwm_led_esp32_channel_set(int pin, bool speed_mode, int channel, const int pin_mode = GPIO_OUTPUT; const char *device_name; - struct device *gpio; + const struct device *gpio; int ret; uint32_t sig_out_idx; @@ -311,7 +311,7 @@ static int pwm_led_esp32_timer_set(int speed_mode, int timer, } /* period_cycles is not used, set frequency on menuconfig instead. */ -static int pwm_led_esp32_pin_set_cycles(struct device *dev, +static int pwm_led_esp32_pin_set_cycles(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -365,7 +365,8 @@ static int pwm_led_esp32_pin_set_cycles(struct device *dev, return ret; } -static int pwm_led_esp32_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int pwm_led_esp32_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, uint64_t *cycles) { const struct pwm_led_esp32_config *config; @@ -394,7 +395,7 @@ static const struct pwm_driver_api pwm_led_esp32_api = { .get_cycles_per_sec = pwm_led_esp32_get_cycles_per_sec, }; -int pwm_led_esp32_init(struct device *dev) +int pwm_led_esp32_init(const struct device *dev) { return 0; } diff --git a/drivers/pwm/pwm_litex.c b/drivers/pwm/pwm_litex.c index d244672dca03b2..b33c05eb770471 100644 --- a/drivers/pwm/pwm_litex.c +++ b/drivers/pwm/pwm_litex.c @@ -40,7 +40,7 @@ static void litex_set_reg(volatile uint32_t *reg, uint32_t reg_size, uint32_t va } } -int pwm_litex_init(struct device *dev) +int pwm_litex_init(const struct device *dev) { const struct pwm_litex_cfg *cfg = GET_PWM_CFG(dev); @@ -48,7 +48,8 @@ int pwm_litex_init(struct device *dev) return 0; } -int pwm_litex_pin_set(struct device *dev, uint32_t pwm, uint32_t period_cycles, +int pwm_litex_pin_set(const struct device *dev, uint32_t pwm, + uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { const struct pwm_litex_cfg *cfg = GET_PWM_CFG(dev); @@ -65,7 +66,8 @@ int pwm_litex_pin_set(struct device *dev, uint32_t pwm, uint32_t period_cycles, return 0; } -int pwm_litex_get_cycles_per_sec(struct device *dev, uint32_t pwm, uint64_t *cycles) +int pwm_litex_get_cycles_per_sec(const struct device *dev, uint32_t pwm, + uint64_t *cycles) { if (pwm >= NUMBER_OF_CHANNELS) { return -EINVAL; diff --git a/drivers/pwm/pwm_mchp_xec.c b/drivers/pwm/pwm_mchp_xec.c index a0ecd41eb84b69..ca1ae1d650b20b 100644 --- a/drivers/pwm/pwm_mchp_xec.c +++ b/drivers/pwm/pwm_mchp_xec.c @@ -233,7 +233,7 @@ static struct xec_params *xec_compare_params(uint32_t target_freq, return params; } -static void xec_compute_and_set_parameters(struct device *dev, +static void xec_compute_and_set_parameters(const struct device *dev, uint32_t target_freq, uint32_t on, uint32_t off) { @@ -306,7 +306,7 @@ static void xec_compute_and_set_parameters(struct device *dev, pwm_regs->CONFIG = reg; } -static int pwm_xec_pin_set(struct device *dev, uint32_t pwm, +static int pwm_xec_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -351,7 +351,7 @@ static int pwm_xec_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int pwm_xec_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int pwm_xec_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { ARG_UNUSED(dev); @@ -370,7 +370,7 @@ static int pwm_xec_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int pwm_xec_init(struct device *dev) +static int pwm_xec_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/pwm/pwm_mcux.c b/drivers/pwm/pwm_mcux.c index ad84d0bd508d83..20ac7445f96ba5 100644 --- a/drivers/pwm/pwm_mcux.c +++ b/drivers/pwm/pwm_mcux.c @@ -31,7 +31,7 @@ struct pwm_mcux_data { pwm_signal_param_t channel[CHANNEL_COUNT]; }; -static int mcux_pwm_pin_set(struct device *dev, uint32_t pwm, +static int mcux_pwm_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -108,7 +108,7 @@ static int mcux_pwm_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int mcux_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int mcux_pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { const struct pwm_mcux_config *config = dev->config; @@ -118,7 +118,7 @@ static int mcux_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int pwm_mcux_init(struct device *dev) +static int pwm_mcux_init(const struct device *dev) { const struct pwm_mcux_config *config = dev->config; struct pwm_mcux_data *data = dev->data; diff --git a/drivers/pwm/pwm_mcux_ftm.c b/drivers/pwm/pwm_mcux_ftm.c index b8703df204d6eb..bae98bdfb4c4de 100644 --- a/drivers/pwm/pwm_mcux_ftm.c +++ b/drivers/pwm/pwm_mcux_ftm.c @@ -35,7 +35,7 @@ struct mcux_ftm_data { ftm_chnl_pwm_config_param_t channel[MAX_CHANNELS]; }; -static int mcux_ftm_pin_set(struct device *dev, uint32_t pwm, +static int mcux_ftm_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -95,7 +95,7 @@ static int mcux_ftm_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int mcux_ftm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int mcux_ftm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { const struct mcux_ftm_config *config = dev->config; @@ -106,12 +106,12 @@ static int mcux_ftm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int mcux_ftm_init(struct device *dev) +static int mcux_ftm_init(const struct device *dev) { const struct mcux_ftm_config *config = dev->config; struct mcux_ftm_data *data = dev->data; ftm_chnl_pwm_config_param_t *channel = data->channel; - struct device *clock_dev; + const struct device *clock_dev; ftm_config_t ftm_config; int i; diff --git a/drivers/pwm/pwm_mcux_tpm.c b/drivers/pwm/pwm_mcux_tpm.c index 3b4728d4040468..933e93c863e91d 100644 --- a/drivers/pwm/pwm_mcux_tpm.c +++ b/drivers/pwm/pwm_mcux_tpm.c @@ -39,7 +39,7 @@ struct mcux_tpm_data { tpm_chnl_pwm_signal_param_t channel[MAX_CHANNELS]; }; -static int mcux_tpm_pin_set(struct device *dev, uint32_t pwm, +static int mcux_tpm_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -116,7 +116,7 @@ static int mcux_tpm_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int mcux_tpm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int mcux_tpm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { const struct mcux_tpm_config *config = dev->config; @@ -127,12 +127,12 @@ static int mcux_tpm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int mcux_tpm_init(struct device *dev) +static int mcux_tpm_init(const struct device *dev) { const struct mcux_tpm_config *config = dev->config; struct mcux_tpm_data *data = dev->data; tpm_chnl_pwm_signal_param_t *channel = data->channel; - struct device *clock_dev; + const struct device *clock_dev; tpm_config_t tpm_config; int i; diff --git a/drivers/pwm/pwm_nrf5_sw.c b/drivers/pwm/pwm_nrf5_sw.c index cc95e361139ddb..4f22484d4a47eb 100644 --- a/drivers/pwm/pwm_nrf5_sw.c +++ b/drivers/pwm/pwm_nrf5_sw.c @@ -88,7 +88,7 @@ static uint8_t pwm_channel_map(struct pwm_data *data, uint8_t map_size, return i; } -static int pwm_nrf5_sw_pin_set(struct device *dev, uint32_t pwm, +static int pwm_nrf5_sw_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -213,7 +213,8 @@ static int pwm_nrf5_sw_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int pwm_nrf5_sw_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int pwm_nrf5_sw_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, uint64_t *cycles) { const struct pwm_config *config; @@ -231,7 +232,7 @@ static const struct pwm_driver_api pwm_nrf5_sw_drv_api_funcs = { .get_cycles_per_sec = pwm_nrf5_sw_get_cycles_per_sec, }; -static int pwm_nrf5_sw_init(struct device *dev) +static int pwm_nrf5_sw_init(const struct device *dev) { const struct pwm_config *config; NRF_TIMER_Type *timer; diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 1ad437cc6f7683..aced00161408ee 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -122,7 +122,7 @@ static bool any_other_channel_is_active(uint8_t channel, return false; } -static int pwm_nrfx_pin_set(struct device *dev, uint32_t pwm, +static int pwm_nrfx_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -248,7 +248,7 @@ static int pwm_nrfx_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int pwm_nrfx_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int pwm_nrfx_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { /* TODO: Since this function might be removed, we will always return @@ -265,7 +265,7 @@ static const struct pwm_driver_api pwm_nrfx_drv_api_funcs = { .get_cycles_per_sec = pwm_nrfx_get_cycles_per_sec, }; -static int pwm_nrfx_init(struct device *dev) +static int pwm_nrfx_init(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; @@ -283,7 +283,7 @@ static int pwm_nrfx_init(struct device *dev) #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static void pwm_nrfx_uninit(struct device *dev) +static void pwm_nrfx_uninit(const struct device *dev) { const struct pwm_nrfx_config *config = dev->config; @@ -292,7 +292,7 @@ static void pwm_nrfx_uninit(struct device *dev) static int pwm_nrfx_set_power_state(uint32_t new_state, uint32_t current_state, - struct device *dev) + const struct device *dev) { int err = 0; @@ -315,7 +315,7 @@ static int pwm_nrfx_set_power_state(uint32_t new_state, return err; } -static int pwm_nrfx_pm_control(struct device *dev, +static int pwm_nrfx_pm_control(const struct device *dev, uint32_t ctrl_command, void *context, uint32_t *current_state) @@ -342,7 +342,7 @@ static int pwm_nrfx_pm_control(struct device *dev, } #define PWM_NRFX_PM_CONTROL(idx) \ - static int pwm_##idx##_nrfx_pm_control(struct device *dev, \ + static int pwm_##idx##_nrfx_pm_control(const struct device *dev, \ uint32_t ctrl_command, \ void *context, \ device_pm_cb cb, \ diff --git a/drivers/pwm/pwm_pca9685.c b/drivers/pwm/pwm_pca9685.c index 47ebc7a74adfeb..0e1436be603a39 100644 --- a/drivers/pwm/pwm_pca9685.c +++ b/drivers/pwm/pwm_pca9685.c @@ -43,11 +43,11 @@ * @param dev Device struct. * @return 1 if I2C master is identified, 0 if not. */ -static inline int has_i2c_master(struct device *dev) +static inline int has_i2c_master(const struct device *dev) { struct pwm_pca9685_drv_data * const drv_data = (struct pwm_pca9685_drv_data * const)dev->data; - struct device * const i2c_master = drv_data->i2c_master; + const struct device *i2c_master = drv_data->i2c_master; if (i2c_master) { return 1; @@ -60,7 +60,7 @@ static inline int has_i2c_master(struct device *dev) * period_count is always taken as 4095. To control the on period send * value to pulse_count */ -static int pwm_pca9685_pin_set_cycles(struct device *dev, uint32_t pwm, +static int pwm_pca9685_pin_set_cycles(const struct device *dev, uint32_t pwm, uint32_t period_count, uint32_t pulse_count, pwm_flags_t flags) { @@ -68,7 +68,7 @@ static int pwm_pca9685_pin_set_cycles(struct device *dev, uint32_t pwm, dev->config; struct pwm_pca9685_drv_data * const drv_data = (struct pwm_pca9685_drv_data * const)dev->data; - struct device * const i2c_master = drv_data->i2c_master; + const struct device *i2c_master = drv_data->i2c_master; uint16_t i2c_addr = config->i2c_slave_addr; uint8_t buf[] = { 0, 0, 0, 0, 0}; @@ -125,13 +125,13 @@ static const struct pwm_driver_api pwm_pca9685_drv_api_funcs = { * @param dev Device struct * @return 0 if successful, failed otherwise. */ -int pwm_pca9685_init(struct device *dev) +int pwm_pca9685_init(const struct device *dev) { const struct pwm_pca9685_config * const config = dev->config; struct pwm_pca9685_drv_data * const drv_data = (struct pwm_pca9685_drv_data * const)dev->data; - struct device *i2c_master; + const struct device *i2c_master; uint8_t buf[] = {0, 0}; int ret; diff --git a/drivers/pwm/pwm_pca9685.h b/drivers/pwm/pwm_pca9685.h index 354009dc10dd96..f8b028846e2503 100644 --- a/drivers/pwm/pwm_pca9685.h +++ b/drivers/pwm/pwm_pca9685.h @@ -24,7 +24,7 @@ extern "C" { * @param dev Device struct * @return 0 if successful, failed otherwise */ -extern int pwm_pca9685_init(struct device *dev); +extern int pwm_pca9685_init(const struct device *dev); /** Configuration data */ struct pwm_pca9685_config { @@ -39,7 +39,7 @@ struct pwm_pca9685_config { /** Runtime driver data */ struct pwm_pca9685_drv_data { /** Master I2C device */ - struct device *i2c_master; + const struct device *i2c_master; }; #ifdef __cplusplus diff --git a/drivers/pwm/pwm_rv32m1_tpm.c b/drivers/pwm/pwm_rv32m1_tpm.c index ad757ea3c22bf9..cf99f2b8c49189 100644 --- a/drivers/pwm/pwm_rv32m1_tpm.c +++ b/drivers/pwm/pwm_rv32m1_tpm.c @@ -38,7 +38,7 @@ struct rv32m1_tpm_data { tpm_chnl_pwm_signal_param_t channel[MAX_CHANNELS]; }; -static int rv32m1_tpm_pin_set(struct device *dev, uint32_t pwm, +static int rv32m1_tpm_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -115,7 +115,8 @@ static int rv32m1_tpm_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int rv32m1_tpm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int rv32m1_tpm_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, uint64_t *cycles) { const struct rv32m1_tpm_config *config = dev->config; @@ -126,12 +127,12 @@ static int rv32m1_tpm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int rv32m1_tpm_init(struct device *dev) +static int rv32m1_tpm_init(const struct device *dev) { const struct rv32m1_tpm_config *config = dev->config; struct rv32m1_tpm_data *data = dev->data; tpm_chnl_pwm_signal_param_t *channel = data->channel; - struct device *clock_dev; + const struct device *clock_dev; tpm_config_t tpm_config; int i; diff --git a/drivers/pwm/pwm_sam.c b/drivers/pwm/pwm_sam.c index 30593b92a85893..1f02d9408f1599 100644 --- a/drivers/pwm/pwm_sam.c +++ b/drivers/pwm/pwm_sam.c @@ -25,7 +25,7 @@ struct sam_pwm_config { #define DEV_CFG(dev) \ ((const struct sam_pwm_config * const)(dev)->config) -static int sam_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int sam_pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { uint8_t prescaler = DEV_CFG(dev)->prescaler; @@ -37,7 +37,7 @@ static int sam_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, return 0; } -static int sam_pwm_pin_set(struct device *dev, uint32_t ch, +static int sam_pwm_pin_set(const struct device *dev, uint32_t ch, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -75,7 +75,7 @@ static int sam_pwm_pin_set(struct device *dev, uint32_t ch, return 0; } -static int sam_pwm_init(struct device *dev) +static int sam_pwm_init(const struct device *dev) { Pwm *const pwm = DEV_CFG(dev)->regs; uint32_t id = DEV_CFG(dev)->id; diff --git a/drivers/pwm/pwm_sam0_tcc.c b/drivers/pwm/pwm_sam0_tcc.c index 35b7e272ec50db..053af0246cfc5d 100644 --- a/drivers/pwm/pwm_sam0_tcc.c +++ b/drivers/pwm/pwm_sam0_tcc.c @@ -43,7 +43,7 @@ static void wait_synchronization(Tcc *regs) } } -static int pwm_sam0_get_cycles_per_sec(struct device *dev, uint32_t ch, +static int pwm_sam0_get_cycles_per_sec(const struct device *dev, uint32_t ch, uint64_t *cycles) { const struct pwm_sam0_config *const cfg = DEV_CFG(dev); @@ -56,7 +56,7 @@ static int pwm_sam0_get_cycles_per_sec(struct device *dev, uint32_t ch, return 0; } -static int pwm_sam0_pin_set(struct device *dev, uint32_t ch, +static int pwm_sam0_pin_set(const struct device *dev, uint32_t ch, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -100,7 +100,7 @@ static int pwm_sam0_pin_set(struct device *dev, uint32_t ch, return 0; } -static int pwm_sam0_init(struct device *dev) +static int pwm_sam0_init(const struct device *dev) { const struct pwm_sam0_config *const cfg = DEV_CFG(dev); Tcc *regs = cfg->regs; diff --git a/drivers/pwm/pwm_shell.c b/drivers/pwm/pwm_shell.c index 8e05306b5e9647..65e65fea582ca5 100644 --- a/drivers/pwm/pwm_shell.c +++ b/drivers/pwm/pwm_shell.c @@ -32,7 +32,7 @@ static const struct args_index args_indx = { static int cmd_cycles(const struct shell *shell, size_t argc, char **argv) { pwm_flags_t flags = 0; - struct device *dev; + const struct device *dev; uint32_t period; uint32_t pulse; uint32_t pwm; @@ -65,7 +65,7 @@ static int cmd_cycles(const struct shell *shell, size_t argc, char **argv) static int cmd_usec(const struct shell *shell, size_t argc, char **argv) { pwm_flags_t flags = 0; - struct device *dev; + const struct device *dev; uint32_t period; uint32_t pulse; uint32_t pwm; @@ -97,7 +97,7 @@ static int cmd_usec(const struct shell *shell, size_t argc, char **argv) static int cmd_nsec(const struct shell *shell, size_t argc, char **argv) { pwm_flags_t flags = 0; - struct device *dev; + const struct device *dev; uint32_t period; uint32_t pulse; uint32_t pwm; diff --git a/drivers/pwm/pwm_sifive.c b/drivers/pwm/pwm_sifive.c index 0951001c712c4d..a75001b24577a3 100644 --- a/drivers/pwm/pwm_sifive.c +++ b/drivers/pwm/pwm_sifive.c @@ -68,7 +68,7 @@ static inline void sys_set_mask(mem_addr_t addr, uint32_t mask, uint32_t value) /* API Functions */ -static int pwm_sifive_init(struct device *dev) +static int pwm_sifive_init(const struct device *dev) { const struct pwm_sifive_cfg *config = dev->config; @@ -95,7 +95,7 @@ static int pwm_sifive_init(struct device *dev) return 0; } -static int pwm_sifive_pin_set(struct device *dev, +static int pwm_sifive_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, @@ -188,7 +188,7 @@ static int pwm_sifive_pin_set(struct device *dev, return 0; } -static int pwm_sifive_get_cycles_per_sec(struct device *dev, +static int pwm_sifive_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles) { diff --git a/drivers/pwm/pwm_stm32.c b/drivers/pwm/pwm_stm32.c index 4b62ba02b7ebf7..5fdbf6840cdefd 100644 --- a/drivers/pwm/pwm_stm32.c +++ b/drivers/pwm/pwm_stm32.c @@ -75,12 +75,12 @@ static void (*const set_timer_compare[TIMER_MAX_CH])(TIM_TypeDef *, #endif }; -static inline struct pwm_stm32_data *to_data(struct device *dev) +static inline struct pwm_stm32_data *to_data(const struct device *dev) { return dev->data; } -static inline const struct pwm_stm32_config *to_config(struct device *dev) +static inline const struct pwm_stm32_config *to_config(const struct device *dev) { return dev->config; } @@ -112,7 +112,7 @@ static uint32_t get_polarity(pwm_flags_t flags) static int get_tim_clk(const struct stm32_pclken *pclken, uint32_t *tim_clk) { int r; - struct device *clk; + const struct device *clk; uint32_t bus_clk, apb_psc; clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); @@ -183,7 +183,7 @@ static int get_tim_clk(const struct stm32_pclken *pclken, uint32_t *tim_clk) return 0; } -static int pwm_stm32_pin_set(struct device *dev, uint32_t pwm, +static int pwm_stm32_pin_set(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags) { @@ -244,7 +244,8 @@ static int pwm_stm32_pin_set(struct device *dev, uint32_t pwm, return 0; } -static int pwm_stm32_get_cycles_per_sec(struct device *dev, uint32_t pwm, +static int pwm_stm32_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, uint64_t *cycles) { struct pwm_stm32_data *data = to_data(dev); @@ -260,13 +261,13 @@ static const struct pwm_driver_api pwm_stm32_driver_api = { .get_cycles_per_sec = pwm_stm32_get_cycles_per_sec, }; -static int pwm_stm32_init(struct device *dev) +static int pwm_stm32_init(const struct device *dev) { struct pwm_stm32_data *data = to_data(dev); const struct pwm_stm32_config *cfg = to_config(dev); int r; - struct device *clk; + const struct device *clk; LL_TIM_InitTypeDef init; /* enable clock and store its speed */ diff --git a/drivers/sensor/adt7420/adt7420.c b/drivers/sensor/adt7420/adt7420.c index b186e874979a88..fc7866ed207989 100644 --- a/drivers/sensor/adt7420/adt7420.c +++ b/drivers/sensor/adt7420/adt7420.c @@ -19,7 +19,8 @@ #include LOG_MODULE_REGISTER(ADT7420, CONFIG_SENSOR_LOG_LEVEL); -static int adt7420_temp_reg_read(struct device *dev, uint8_t reg, int16_t *val) +static int adt7420_temp_reg_read(const struct device *dev, uint8_t reg, + int16_t *val) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; @@ -34,7 +35,8 @@ static int adt7420_temp_reg_read(struct device *dev, uint8_t reg, int16_t *val) return 0; } -static int adt7420_temp_reg_write(struct device *dev, uint8_t reg, int16_t val) +static int adt7420_temp_reg_write(const struct device *dev, uint8_t reg, + int16_t val) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; @@ -43,10 +45,10 @@ static int adt7420_temp_reg_write(struct device *dev, uint8_t reg, int16_t val) return i2c_write(drv_data->i2c, buf, sizeof(buf), cfg->i2c_addr); } -static int adt7420_attr_set(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int adt7420_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; @@ -110,7 +112,8 @@ static int adt7420_attr_set(struct device *dev, return 0; } -static int adt7420_sample_fetch(struct device *dev, enum sensor_channel chan) +static int adt7420_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct adt7420_data *drv_data = dev->data; int16_t value; @@ -127,9 +130,9 @@ static int adt7420_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int adt7420_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static int adt7420_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { struct adt7420_data *drv_data = dev->data; int32_t value; @@ -154,7 +157,7 @@ static const struct sensor_driver_api adt7420_driver_api = { #endif }; -static int adt7420_probe(struct device *dev) +static int adt7420_probe(const struct device *dev) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; @@ -200,7 +203,7 @@ static int adt7420_probe(struct device *dev) return 0; } -static int adt7420_init(struct device *dev) +static int adt7420_init(const struct device *dev) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; diff --git a/drivers/sensor/adt7420/adt7420.h b/drivers/sensor/adt7420/adt7420.h index 7e3b770b64ec5d..2fe806be8275cc 100644 --- a/drivers/sensor/adt7420/adt7420.h +++ b/drivers/sensor/adt7420/adt7420.h @@ -59,16 +59,16 @@ #define ADT7420_TEMP_SCALE 15625 struct adt7420_data { - struct device *i2c; + const struct device *i2c; int16_t sample; #ifdef CONFIG_ADT7420_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t th_handler; struct sensor_trigger th_trigger; - struct device *dev; + const struct device *dev; #if defined(CONFIG_ADT7420_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ADT7420_THREAD_STACK_SIZE); @@ -92,11 +92,11 @@ struct adt7420_dev_config { }; #ifdef CONFIG_ADT7420_TRIGGER -int adt7420_trigger_set(struct device *dev, +int adt7420_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int adt7420_init_interrupt(struct device *dev); +int adt7420_init_interrupt(const struct device *dev); #endif /* CONFIG_ADT7420_TRIGGER */ diff --git a/drivers/sensor/adt7420/adt7420_trigger.c b/drivers/sensor/adt7420/adt7420_trigger.c index 6897901521e7f7..ab6a2a5e4fab0d 100644 --- a/drivers/sensor/adt7420/adt7420_trigger.c +++ b/drivers/sensor/adt7420/adt7420_trigger.c @@ -16,7 +16,7 @@ #include LOG_MODULE_DECLARE(ADT7420, CONFIG_SENSOR_LOG_LEVEL); -static void setup_int(struct device *dev, +static void setup_int(const struct device *dev, bool enable) { struct adt7420_data *drv_data = dev->data; @@ -28,7 +28,7 @@ static void setup_int(struct device *dev, gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, flags); } -static void handle_int(struct device *dev) +static void handle_int(const struct device *dev) { struct adt7420_data *drv_data = dev->data; @@ -41,7 +41,7 @@ static void handle_int(struct device *dev) #endif } -static void process_int(struct device *dev) +static void process_int(const struct device *dev) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; @@ -67,7 +67,7 @@ static void process_int(struct device *dev) } } -static void adt7420_gpio_callback(struct device *dev, +static void adt7420_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct adt7420_data *drv_data = @@ -79,7 +79,7 @@ static void adt7420_gpio_callback(struct device *dev, #if defined(CONFIG_ADT7420_TRIGGER_OWN_THREAD) static void adt7420_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct adt7420_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -100,7 +100,7 @@ static void adt7420_work_cb(struct k_work *work) } #endif -int adt7420_trigger_set(struct device *dev, +int adt7420_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -131,7 +131,7 @@ int adt7420_trigger_set(struct device *dev, return 0; } -int adt7420_init_interrupt(struct device *dev) +int adt7420_init_interrupt(const struct device *dev) { struct adt7420_data *drv_data = dev->data; const struct adt7420_dev_config *cfg = dev->config; diff --git a/drivers/sensor/adxl345/adxl345.c b/drivers/sensor/adxl345/adxl345.c index a897cc0cf5402f..769e59f3d21f4d 100644 --- a/drivers/sensor/adxl345/adxl345.c +++ b/drivers/sensor/adxl345/adxl345.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(ADXL345, CONFIG_SENSOR_LOG_LEVEL); -static int adxl345_read_sample(struct device *dev, +static int adxl345_read_sample(const struct device *dev, struct adxl345_sample *sample) { struct adxl345_dev_data *data = dev->data; @@ -56,7 +56,8 @@ static void adxl345_accel_convert(struct sensor_value *val, int16_t sample) val->val2 = 0; } -static int adxl345_sample_fetch(struct device *dev, enum sensor_channel chan) +static int adxl345_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct adxl345_dev_data *data = dev->data; struct adxl345_sample sample; @@ -87,7 +88,7 @@ static int adxl345_sample_fetch(struct device *dev, enum sensor_channel chan) return samples_count; } -static int adxl345_channel_get(struct device *dev, +static int adxl345_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -128,7 +129,7 @@ static const struct sensor_driver_api adxl345_api_funcs = { .channel_get = adxl345_channel_get, }; -static int adxl345_init(struct device *dev) +static int adxl345_init(const struct device *dev) { int rc; struct adxl345_dev_data *data = dev->data; diff --git a/drivers/sensor/adxl345/adxl345.h b/drivers/sensor/adxl345/adxl345.h index a8df5906fd0b69..822f3f48ac3e03 100644 --- a/drivers/sensor/adxl345/adxl345.h +++ b/drivers/sensor/adxl345/adxl345.h @@ -37,7 +37,7 @@ struct adxl345_dev_data { unsigned int sample_number; - struct device *i2c_master; + const struct device *i2c_master; uint8_t i2c_addr; int16_t bufx[ADXL345_MAX_FIFO_SIZE]; diff --git a/drivers/sensor/adxl362/adxl362.c b/drivers/sensor/adxl362/adxl362.c index a67f13faf9ab76..74c9b829eaad50 100644 --- a/drivers/sensor/adxl362/adxl362.c +++ b/drivers/sensor/adxl362/adxl362.c @@ -58,7 +58,8 @@ static int adxl362_reg_access(struct adxl362_data *ctx, uint8_t cmd, return spi_write(ctx->spi, &ctx->spi_cfg, &tx); } -static inline int adxl362_set_reg(struct device *dev, uint16_t register_value, +static inline int adxl362_set_reg(const struct device *dev, + uint16_t register_value, uint8_t register_address, uint8_t count) { struct adxl362_data *adxl362_data = dev->data; @@ -70,7 +71,7 @@ static inline int adxl362_set_reg(struct device *dev, uint16_t register_value, count); } -int adxl362_reg_write_mask(struct device *dev, uint8_t register_address, +int adxl362_reg_write_mask(const struct device *dev, uint8_t register_address, uint8_t mask, uint8_t data) { int ret; @@ -97,7 +98,7 @@ int adxl362_reg_write_mask(struct device *dev, uint8_t register_address, 1); } -static inline int adxl362_get_reg(struct device *dev, uint8_t *read_buf, +static inline int adxl362_get_reg(const struct device *dev, uint8_t *read_buf, uint8_t register_address, uint8_t count) { struct adxl362_data *adxl362_data = dev->data; @@ -109,9 +110,9 @@ static inline int adxl362_get_reg(struct device *dev, uint8_t *read_buf, } #if defined(CONFIG_ADXL362_TRIGGER) -static int adxl362_interrupt_config(struct device *dev, - uint8_t int1, - uint8_t int2) +static int adxl362_interrupt_config(const struct device *dev, + uint8_t int1, + uint8_t int2) { int ret; struct adxl362_data *adxl362_data = dev->data; @@ -133,12 +134,12 @@ static int adxl362_interrupt_config(struct device *dev, 1); } -int adxl362_get_status(struct device *dev, uint8_t *status) +int adxl362_get_status(const struct device *dev, uint8_t *status) { return adxl362_get_reg(dev, status, ADXL362_REG_STATUS, 1); } -int adxl362_clear_data_ready(struct device *dev) +int adxl362_clear_data_ready(const struct device *dev) { uint8_t buf; /* Reading any data register clears the data ready interrupt */ @@ -146,13 +147,13 @@ int adxl362_clear_data_ready(struct device *dev) } #endif -static int adxl362_software_reset(struct device *dev) +static int adxl362_software_reset(const struct device *dev) { return adxl362_set_reg(dev, ADXL362_RESET_KEY, ADXL362_REG_SOFT_RESET, 1); } -static int adxl362_set_power_mode(struct device *dev, uint8_t mode) +static int adxl362_set_power_mode(const struct device *dev, uint8_t mode) { uint8_t old_power_ctl; uint8_t new_power_ctl; @@ -233,7 +234,7 @@ static int32_t adxl362_range_to_reg_val(uint16_t range) return -EINVAL; } -static int adxl362_set_range(struct device *dev, uint8_t range) +static int adxl362_set_range(const struct device *dev, uint8_t range) { struct adxl362_data *adxl362_data = dev->data; uint8_t old_filter_ctl; @@ -256,7 +257,7 @@ static int adxl362_set_range(struct device *dev, uint8_t range) return 0; } -static int adxl362_set_output_rate(struct device *dev, uint8_t out_rate) +static int adxl362_set_output_rate(const struct device *dev, uint8_t out_rate) { uint8_t old_filter_ctl; uint8_t new_filter_ctl; @@ -270,7 +271,8 @@ static int adxl362_set_output_rate(struct device *dev, uint8_t out_rate) } -static int axl362_acc_config(struct device *dev, enum sensor_channel chan, +static int axl362_acc_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -314,9 +316,10 @@ static int axl362_acc_config(struct device *dev, enum sensor_channel chan, return 0; } -static int adxl362_attr_set_thresh(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int adxl362_attr_set_thresh(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { uint8_t reg; uint16_t threshold = val->val1; @@ -344,8 +347,10 @@ static int adxl362_attr_set_thresh(struct device *dev, enum sensor_channel chan, return ret; } -static int adxl362_attr_set(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, const struct sensor_value *val) +static int adxl362_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { case SENSOR_ATTR_UPPER_THRESH: @@ -370,7 +375,7 @@ static int adxl362_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int adxl362_fifo_setup(struct device *dev, uint8_t mode, +static int adxl362_fifo_setup(const struct device *dev, uint8_t mode, uint16_t water_mark_lvl, uint8_t en_temp_read) { uint8_t write_val; @@ -392,7 +397,7 @@ static int adxl362_fifo_setup(struct device *dev, uint8_t mode, return 0; } -static int adxl362_setup_activity_detection(struct device *dev, +static int adxl362_setup_activity_detection(const struct device *dev, uint8_t ref_or_abs, uint16_t threshold, uint8_t time) @@ -450,7 +455,7 @@ static int adxl362_setup_activity_detection(struct device *dev, return 0; } -static int adxl362_setup_inactivity_detection(struct device *dev, +static int adxl362_setup_inactivity_detection(const struct device *dev, uint8_t ref_or_abs, uint16_t threshold, uint16_t time) @@ -493,7 +498,7 @@ static int adxl362_setup_inactivity_detection(struct device *dev, return 0; } -int adxl362_set_interrupt_mode(struct device *dev, uint8_t mode) +int adxl362_set_interrupt_mode(const struct device *dev, uint8_t mode) { uint8_t old_act_inact_reg; uint8_t new_act_inact_reg; @@ -530,7 +535,8 @@ int adxl362_set_interrupt_mode(struct device *dev, uint8_t mode) return 0; } -static int adxl362_sample_fetch(struct device *dev, enum sensor_channel chan) +static int adxl362_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct adxl362_data *data = dev->data; int16_t buf[4]; @@ -588,7 +594,7 @@ static void adxl362_temp_convert(struct sensor_value *val, int temp) val->val2 = (milli_c % 1000) * 1000; } -static int adxl362_channel_get(struct device *dev, +static int adxl362_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -623,7 +629,7 @@ static const struct sensor_driver_api adxl362_api_funcs = { #endif }; -static int adxl362_chip_init(struct device *dev) +static int adxl362_chip_init(const struct device *dev) { int ret; @@ -719,7 +725,7 @@ static int adxl362_chip_init(struct device *dev) * -1 - an error occurred. * */ -static int adxl362_init(struct device *dev) +static int adxl362_init(const struct device *dev) { const struct adxl362_config *config = dev->config; struct adxl362_data *data = dev->data; diff --git a/drivers/sensor/adxl362/adxl362.h b/drivers/sensor/adxl362/adxl362.h index 56f417781690e9..5d1a69d939fb79 100644 --- a/drivers/sensor/adxl362/adxl362.h +++ b/drivers/sensor/adxl362/adxl362.h @@ -189,7 +189,7 @@ struct adxl362_config { }; struct adxl362_data { - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) struct spi_cs_control adxl362_cs_ctrl; @@ -201,7 +201,7 @@ struct adxl362_data { uint8_t selected_range; #if defined(CONFIG_ADXL362_TRIGGER) - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct k_mutex trigger_mutex; @@ -216,7 +216,7 @@ struct adxl362_data { struct k_thread thread; #elif defined(CONFIG_ADXL362_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_ADXL362_TRIGGER */ }; @@ -246,22 +246,22 @@ struct adxl362_data { #endif #ifdef CONFIG_ADXL362_TRIGGER -int adxl362_reg_write_mask(struct device *dev, +int adxl362_reg_write_mask(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t data); -int adxl362_get_status(struct device *dev, uint8_t *status); +int adxl362_get_status(const struct device *dev, uint8_t *status); -int adxl362_interrupt_activity_enable(struct device *dev); +int adxl362_interrupt_activity_enable(const struct device *dev); -int adxl362_trigger_set(struct device *dev, +int adxl362_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int adxl362_init_interrupt(struct device *dev); +int adxl362_init_interrupt(const struct device *dev); -int adxl362_set_interrupt_mode(struct device *dev, uint8_t mode); +int adxl362_set_interrupt_mode(const struct device *dev, uint8_t mode); -int adxl362_clear_data_ready(struct device *dev); +int adxl362_clear_data_ready(const struct device *dev); #endif /* CONFIG_ADT7420_TRIGGER */ #endif /* ZEPHYR_DRIVERS_SENSOR_ADXL362_ADXL362_H_ */ diff --git a/drivers/sensor/adxl362/adxl362_trigger.c b/drivers/sensor/adxl362/adxl362_trigger.c index 92ec44e0b603c1..a284f2b2b46c51 100644 --- a/drivers/sensor/adxl362/adxl362_trigger.c +++ b/drivers/sensor/adxl362/adxl362_trigger.c @@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(ADXL362, CONFIG_SENSOR_LOG_LEVEL); static void adxl362_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct adxl362_data *drv_data = dev->data; uint8_t status_buf; @@ -44,7 +44,7 @@ static void adxl362_thread_cb(void *arg) k_mutex_unlock(&drv_data->trigger_mutex); } -static void adxl362_gpio_callback(struct device *dev, +static void adxl362_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct adxl362_data *drv_data = @@ -60,7 +60,7 @@ static void adxl362_gpio_callback(struct device *dev, #if defined(CONFIG_ADXL362_TRIGGER_OWN_THREAD) static void adxl362_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct adxl362_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -80,7 +80,7 @@ static void adxl362_work_cb(struct k_work *work) } #endif -int adxl362_trigger_set(struct device *dev, +int adxl362_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -120,7 +120,7 @@ int adxl362_trigger_set(struct device *dev, return adxl362_reg_write_mask(dev, ADXL362_REG_INTMAP1, int_mask, int_en); } -int adxl362_init_interrupt(struct device *dev) +int adxl362_init_interrupt(const struct device *dev) { struct adxl362_data *drv_data = dev->data; const struct adxl362_config *cfg = dev->config; diff --git a/drivers/sensor/adxl372/adxl372.c b/drivers/sensor/adxl372/adxl372.c index f4e1c738c12f1c..032914b7e64689 100644 --- a/drivers/sensor/adxl372/adxl372.c +++ b/drivers/sensor/adxl372/adxl372.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(ADXL372, CONFIG_SENSOR_LOG_LEVEL); -static int adxl372_bus_access(struct device *dev, uint8_t reg, +static int adxl372_bus_access(const struct device *dev, uint8_t reg, void *data, size_t length) { struct adxl372_data *adxl372_data = dev->data; @@ -84,7 +84,7 @@ static int adxl372_bus_access(struct device *dev, uint8_t reg, * @param reg_data - The register data. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_reg_read(struct device *dev, +static int adxl372_reg_read(const struct device *dev, uint8_t reg_addr, uint8_t *reg_data) { @@ -100,7 +100,7 @@ static int adxl372_reg_read(struct device *dev, * @param count - Number of bytes to read. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_reg_read_multiple(struct device *dev, +static int adxl372_reg_read_multiple(const struct device *dev, uint8_t reg_addr, uint8_t *reg_data, uint16_t count) @@ -116,7 +116,7 @@ static int adxl372_reg_read_multiple(struct device *dev, * @param reg_data - The register data. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_reg_write(struct device *dev, +static int adxl372_reg_write(const struct device *dev, uint8_t reg_addr, uint8_t reg_data) { @@ -134,7 +134,7 @@ static int adxl372_reg_write(struct device *dev, * @param data - The register data. * @return 0 in case of success, negative error code otherwise. */ -int adxl372_reg_write_mask(struct device *dev, +int adxl372_reg_write_mask(const struct device *dev, uint8_t reg_addr, uint32_t mask, uint8_t data) @@ -160,8 +160,9 @@ int adxl372_reg_write_mask(struct device *dev, * @param act - The activity config structure. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_activity_threshold(struct device *dev, uint8_t axis_reg_h, - const struct adxl372_activity_threshold *act) +static int adxl372_set_activity_threshold(const struct device *dev, + uint8_t axis_reg_h, + const struct adxl372_activity_threshold *act) { int ret; uint8_t val; @@ -191,9 +192,9 @@ static int adxl372_set_activity_threshold(struct device *dev, uint8_t axis_reg_h * @param act - The activity config structure. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_activity_threshold_xyz(struct device *dev, - uint8_t axis_reg_h, - const struct adxl372_activity_threshold *act) +static int adxl372_set_activity_threshold_xyz(const struct device *dev, + uint8_t axis_reg_h, + const struct adxl372_activity_threshold *act) { int i, ret; @@ -218,7 +219,8 @@ static int adxl372_set_activity_threshold_xyz(struct device *dev, * ADXL372_FULL_BW_MEASUREMENT * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_op_mode(struct device *dev, enum adxl372_op_mode op_mode) +static int adxl372_set_op_mode(const struct device *dev, + enum adxl372_op_mode op_mode) { return adxl372_reg_write_mask(dev, ADXL372_POWER_CTL, ADXL372_POWER_CTL_MODE_MSK, @@ -233,7 +235,7 @@ static int adxl372_set_op_mode(struct device *dev, enum adxl372_op_mode op_mode) * false * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_autosleep(struct device *dev, bool enable) +static int adxl372_set_autosleep(const struct device *dev, bool enable) { return adxl372_reg_write_mask(dev, ADXL372_MEASURE, ADXL372_MEASURE_AUTOSLEEP_MSK, @@ -252,7 +254,8 @@ static int adxl372_set_autosleep(struct device *dev, bool enable) * ADXL372_BW_LPF_DISABLED * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_bandwidth(struct device *dev, enum adxl372_bandwidth bw) +static int adxl372_set_bandwidth(const struct device *dev, + enum adxl372_bandwidth bw) { int ret; uint8_t mask; @@ -285,7 +288,8 @@ static int adxl372_set_bandwidth(struct device *dev, enum adxl372_bandwidth bw) * ADXL372_HPF_DISABLED * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_hpf_corner(struct device *dev, enum adxl372_hpf_corner c) +static int adxl372_set_hpf_corner(const struct device *dev, + enum adxl372_hpf_corner c) { int ret; @@ -316,7 +320,7 @@ static int adxl372_set_hpf_corner(struct device *dev, enum adxl372_hpf_corner c) * ADXL372_LOOPED * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_act_proc_mode(struct device *dev, +static int adxl372_set_act_proc_mode(const struct device *dev, enum adxl372_act_proc_mode mode) { return adxl372_reg_write_mask(dev, ADXL372_MEASURE, @@ -335,7 +339,7 @@ static int adxl372_set_act_proc_mode(struct device *dev, * ADXL372_ODR_6400HZ * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_odr(struct device *dev, enum adxl372_odr odr) +static int adxl372_set_odr(const struct device *dev, enum adxl372_odr odr) { return adxl372_reg_write_mask(dev, ADXL372_TIMING, ADXL372_TIMING_ODR_MSK, @@ -350,8 +354,8 @@ static int adxl372_set_odr(struct device *dev, enum adxl372_odr odr) * ADXL372_INSTANT_ON_HIGH_TH * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_instant_on_th(struct device *dev, - enum adxl372_instant_on_th_mode mode) +static int adxl372_set_instant_on_th(const struct device *dev, + enum adxl372_instant_on_th_mode mode) { return adxl372_reg_write_mask(dev, ADXL372_POWER_CTL, ADXL372_POWER_CTL_INSTANT_ON_TH_MSK, @@ -372,8 +376,8 @@ static int adxl372_set_instant_on_th(struct device *dev, * ADXL372_WUR_24576ms * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_wakeup_rate(struct device *dev, - enum adxl372_wakeup_rate wur) +static int adxl372_set_wakeup_rate(const struct device *dev, + enum adxl372_wakeup_rate wur) { return adxl372_reg_write_mask(dev, ADXL372_TIMING, ADXL372_TIMING_WAKE_UP_RATE_MSK, @@ -386,7 +390,7 @@ static int adxl372_set_wakeup_rate(struct device *dev, * @param time - The value set in this register. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_activity_time(struct device *dev, uint8_t time) +static int adxl372_set_activity_time(const struct device *dev, uint8_t time) { return adxl372_reg_write(dev, ADXL372_TIME_ACT, time); } @@ -398,7 +402,8 @@ static int adxl372_set_activity_time(struct device *dev, uint8_t time) * (eight LSBs) and the TIME_INACT_H register (eight MSBs). * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_inactivity_time(struct device *dev, uint16_t time) +static int adxl372_set_inactivity_time(const struct device *dev, + uint16_t time) { int ret; @@ -418,8 +423,8 @@ static int adxl372_set_inactivity_time(struct device *dev, uint16_t time) * ADXL372_FILTER_SETTLE_16 * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_set_filter_settle(struct device *dev, - enum adxl372_filter_settle mode) +static int adxl372_set_filter_settle(const struct device *dev, + enum adxl372_filter_settle mode) { return adxl372_reg_write_mask(dev, ADXL372_POWER_CTL, ADXL372_POWER_CTL_FIL_SETTLE_MSK, @@ -433,9 +438,9 @@ static int adxl372_set_filter_settle(struct device *dev, * @param int2 - INT2 interrupt pins. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_interrupt_config(struct device *dev, - uint8_t int1, - uint8_t int2) +static int adxl372_interrupt_config(const struct device *dev, + uint8_t int1, + uint8_t int2) { int ret; @@ -457,7 +462,7 @@ static int adxl372_interrupt_config(struct device *dev, * FIFO buffer (0 to 512) * @return 0 in case of success, negative error code otherwise. */ -int adxl372_get_status(struct device *dev, +int adxl372_get_status(const struct device *dev, uint8_t *status1, uint8_t *status2, uint16_t *fifo_entries) @@ -493,7 +498,7 @@ int adxl372_get_status(struct device *dev, * @param dev - The device structure. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_reset(struct device *dev) +static int adxl372_reset(const struct device *dev) { int ret; @@ -531,10 +536,10 @@ static int adxl372_reset(struct device *dev) * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_configure_fifo(struct device *dev, - enum adxl372_fifo_mode mode, - enum adxl372_fifo_format format, - uint16_t fifo_samples) +static int adxl372_configure_fifo(const struct device *dev, + enum adxl372_fifo_mode mode, + enum adxl372_fifo_format format, + uint16_t fifo_samples) { struct adxl372_data *data = dev->data; uint8_t fifo_config; @@ -581,8 +586,8 @@ static int adxl372_configure_fifo(struct device *dev, * where (x, y, z) acceleration data will be stored. * @return 0 in case of success, negative error code otherwise. */ -static int adxl372_get_accel_data(struct device *dev, bool maxpeak, - struct adxl372_xyz_accel_data *accel_data) +static int adxl372_get_accel_data(const struct device *dev, bool maxpeak, + struct adxl372_xyz_accel_data *accel_data) { uint8_t buf[6]; uint8_t status1; @@ -604,9 +609,10 @@ static int adxl372_get_accel_data(struct device *dev, bool maxpeak, return ret; } -static int adxl372_attr_set_odr(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int adxl372_attr_set_odr(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { enum adxl372_odr odr; @@ -633,9 +639,10 @@ static int adxl372_attr_set_odr(struct device *dev, enum sensor_channel chan, return adxl372_set_odr(dev, odr); } -static int adxl372_attr_set_thresh(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int adxl372_attr_set_thresh(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { const struct adxl372_dev_config *cfg = dev->config; struct adxl372_activity_threshold threshold; @@ -674,7 +681,8 @@ static int adxl372_attr_set_thresh(struct device *dev, enum sensor_channel chan, } } -static int adxl372_attr_set(struct device *dev, enum sensor_channel chan, +static int adxl372_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -689,7 +697,8 @@ static int adxl372_attr_set(struct device *dev, enum sensor_channel chan, } } -static int adxl372_sample_fetch(struct device *dev, enum sensor_channel chan) +static int adxl372_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct adxl372_data *data = dev->data; const struct adxl372_dev_config *cfg = dev->config; @@ -710,7 +719,7 @@ static void adxl372_accel_convert(struct sensor_value *val, int16_t value) val->val2 = micro_ms2 % 1000000; } -static int adxl372_channel_get(struct device *dev, +static int adxl372_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -748,7 +757,7 @@ static const struct sensor_driver_api adxl372_api_funcs = { }; -static int adxl372_probe(struct device *dev) +static int adxl372_probe(const struct device *dev) { const struct adxl372_dev_config *cfg = dev->config; uint8_t dev_id, part_id; @@ -875,7 +884,7 @@ static int adxl372_probe(struct device *dev) return adxl372_set_act_proc_mode(dev, cfg->act_proc_mode); } -static int adxl372_init(struct device *dev) +static int adxl372_init(const struct device *dev) { struct adxl372_data *data = dev->data; const struct adxl372_dev_config *cfg = dev->config; diff --git a/drivers/sensor/adxl372/adxl372.h b/drivers/sensor/adxl372/adxl372.h index 0cb5ed1134ca92..fb8fa0bde42f9d 100644 --- a/drivers/sensor/adxl372/adxl372.h +++ b/drivers/sensor/adxl372/adxl372.h @@ -279,7 +279,7 @@ struct adxl372_xyz_accel_data { }; struct adxl372_data { - struct device *bus; + const struct device *bus; #ifdef CONFIG_ADXL372_SPI struct spi_config spi_cfg; #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) @@ -290,14 +290,14 @@ struct adxl372_data { struct adxl372_fifo_config fifo_config; #ifdef CONFIG_ADXL372_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t th_handler; struct sensor_trigger th_trigger; sensor_trigger_handler_t drdy_handler; struct sensor_trigger drdy_trigger; - struct device *dev; + const struct device *dev; #if defined(CONFIG_ADXL372_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ADXL372_THREAD_STACK_SIZE); @@ -355,17 +355,17 @@ struct adxl372_dev_config { }; #ifdef CONFIG_ADXL372_TRIGGER -int adxl372_get_status(struct device *dev, +int adxl372_get_status(const struct device *dev, uint8_t *status1, uint8_t *status2, uint16_t *fifo_entries); -int adxl372_reg_write_mask(struct device *dev, +int adxl372_reg_write_mask(const struct device *dev, uint8_t reg_addr, uint32_t mask, uint8_t data); -int adxl372_trigger_set(struct device *dev, +int adxl372_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int adxl372_init_interrupt(struct device *dev); +int adxl372_init_interrupt(const struct device *dev); #endif /* CONFIG_ADT7420_TRIGGER */ #endif /* ZEPHYR_DRIVERS_SENSOR_ADXL372_ADXL372_H_ */ diff --git a/drivers/sensor/adxl372/adxl372_trigger.c b/drivers/sensor/adxl372/adxl372_trigger.c index cc83e1464bf172..a36e1cb3c0cbe7 100644 --- a/drivers/sensor/adxl372/adxl372_trigger.c +++ b/drivers/sensor/adxl372/adxl372_trigger.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(ADXL372, CONFIG_SENSOR_LOG_LEVEL); static void adxl372_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct adxl372_data *drv_data = dev->data; const struct adxl372_dev_config *cfg = dev->config; uint8_t status1, status2; @@ -51,7 +51,7 @@ static void adxl372_thread_cb(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void adxl372_gpio_callback(struct device *dev, +static void adxl372_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct adxl372_data *drv_data = @@ -71,7 +71,7 @@ static void adxl372_gpio_callback(struct device *dev, #if defined(CONFIG_ADXL372_TRIGGER_OWN_THREAD) static void adxl372_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct adxl372_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -92,7 +92,7 @@ static void adxl372_work_cb(struct k_work *work) } #endif -int adxl372_trigger_set(struct device *dev, +int adxl372_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -138,7 +138,7 @@ int adxl372_trigger_set(struct device *dev, return ret; } -int adxl372_init_interrupt(struct device *dev) +int adxl372_init_interrupt(const struct device *dev) { struct adxl372_data *drv_data = dev->data; const struct adxl372_dev_config *cfg = dev->config; diff --git a/drivers/sensor/ak8975/ak8975.c b/drivers/sensor/ak8975/ak8975.c index ef5ea7ea29c122..195080dbe35782 100644 --- a/drivers/sensor/ak8975/ak8975.c +++ b/drivers/sensor/ak8975/ak8975.c @@ -19,7 +19,8 @@ LOG_MODULE_REGISTER(AK8975, CONFIG_SENSOR_LOG_LEVEL); -static int ak8975_sample_fetch(struct device *dev, enum sensor_channel chan) +static int ak8975_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct ak8975_data *drv_data = dev->data; uint8_t buf[6]; @@ -60,7 +61,7 @@ static void ak8975_convert(struct sensor_value *val, int16_t sample, val->val2 = conv_val % 1000000; } -static int ak8975_channel_get(struct device *dev, +static int ak8975_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -116,7 +117,7 @@ static int ak8975_read_adjustment_data(struct ak8975_data *drv_data) return 0; } -int ak8975_init(struct device *dev) +int ak8975_init(const struct device *dev) { struct ak8975_data *drv_data = dev->data; uint8_t id; diff --git a/drivers/sensor/ak8975/ak8975.h b/drivers/sensor/ak8975/ak8975.h index 0549457448f6dc..733190d2c5785f 100644 --- a/drivers/sensor/ak8975/ak8975.h +++ b/drivers/sensor/ak8975/ak8975.h @@ -40,7 +40,7 @@ struct ak8975_data { - struct device *i2c; + const struct device *i2c; int16_t x_sample; int16_t y_sample; diff --git a/drivers/sensor/amg88xx/amg88xx.c b/drivers/sensor/amg88xx/amg88xx.c index 2638809651e9b1..4e485f37590692 100644 --- a/drivers/sensor/amg88xx/amg88xx.c +++ b/drivers/sensor/amg88xx/amg88xx.c @@ -21,7 +21,8 @@ LOG_MODULE_REGISTER(AMG88XX, CONFIG_SENSOR_LOG_LEVEL); -static int amg88xx_sample_fetch(struct device *dev, enum sensor_channel chan) +static int amg88xx_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct amg88xx_data *drv_data = dev->data; const struct amg88xx_config *config = dev->config; @@ -38,7 +39,7 @@ static int amg88xx_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int amg88xx_channel_get(struct device *dev, +static int amg88xx_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -63,7 +64,7 @@ static int amg88xx_channel_get(struct device *dev, return 0; } -static int amg88xx_init_device(struct device *dev) +static int amg88xx_init_device(const struct device *dev) { struct amg88xx_data *drv_data = dev->data; const struct amg88xx_config *config = dev->config; @@ -103,7 +104,7 @@ static int amg88xx_init_device(struct device *dev) return 0; } -int amg88xx_init(struct device *dev) +int amg88xx_init(const struct device *dev) { struct amg88xx_data *drv_data = dev->data; const struct amg88xx_config *config = dev->config; diff --git a/drivers/sensor/amg88xx/amg88xx.h b/drivers/sensor/amg88xx/amg88xx.h index 497a7b693e9f33..cd7c0e49f1f2d0 100644 --- a/drivers/sensor/amg88xx/amg88xx.h +++ b/drivers/sensor/amg88xx/amg88xx.h @@ -77,11 +77,11 @@ struct amg88xx_config { }; struct amg88xx_data { - struct device *i2c; + const struct device *i2c; int16_t sample[64]; #ifdef CONFIG_AMG88XX_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; @@ -97,23 +97,23 @@ struct amg88xx_data { struct k_thread thread; #elif defined(CONFIG_AMG88XX_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_AMG88XX_TRIGGER */ }; #ifdef CONFIG_AMG88XX_TRIGGER -int amg88xx_attr_set(struct device *dev, +int amg88xx_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int amg88xx_trigger_set(struct device *dev, +int amg88xx_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int amg88xx_init_interrupt(struct device *dev); +int amg88xx_init_interrupt(const struct device *dev); #endif /* CONFIG_AMG88XX_TRIGGER */ #endif diff --git a/drivers/sensor/amg88xx/amg88xx_trigger.c b/drivers/sensor/amg88xx/amg88xx_trigger.c index ffd82db57ad3fb..4a31c157970247 100644 --- a/drivers/sensor/amg88xx/amg88xx_trigger.c +++ b/drivers/sensor/amg88xx/amg88xx_trigger.c @@ -30,7 +30,7 @@ static inline void amg88xx_setup_int(struct amg88xx_data *drv_data, flags); } -int amg88xx_attr_set(struct device *dev, +int amg88xx_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -73,7 +73,7 @@ int amg88xx_attr_set(struct device *dev, return 0; } -static void amg88xx_gpio_callback(struct device *dev, +static void amg88xx_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct amg88xx_data *drv_data = @@ -90,7 +90,7 @@ static void amg88xx_gpio_callback(struct device *dev, static void amg88xx_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct amg88xx_data *drv_data = dev->data; const struct amg88xx_config *config = dev->config; uint8_t status; @@ -114,7 +114,7 @@ static void amg88xx_thread_cb(void *arg) #ifdef CONFIG_AMG88XX_TRIGGER_OWN_THREAD static void amg88xx_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct amg88xx_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -135,7 +135,7 @@ static void amg88xx_work_cb(struct k_work *work) } #endif -int amg88xx_trigger_set(struct device *dev, +int amg88xx_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -167,7 +167,7 @@ int amg88xx_trigger_set(struct device *dev, return 0; } -int amg88xx_init_interrupt(struct device *dev) +int amg88xx_init_interrupt(const struct device *dev) { struct amg88xx_data *drv_data = dev->data; const struct amg88xx_config *config = dev->config; diff --git a/drivers/sensor/ams_iAQcore/iAQcore.c b/drivers/sensor/ams_iAQcore/iAQcore.c index afffd9535ff7d2..d25f22654a867f 100644 --- a/drivers/sensor/ams_iAQcore/iAQcore.c +++ b/drivers/sensor/ams_iAQcore/iAQcore.c @@ -19,7 +19,8 @@ LOG_MODULE_REGISTER(IAQ_CORE, CONFIG_SENSOR_LOG_LEVEL); -static int iaqcore_sample_fetch(struct device *dev, enum sensor_channel chan) +static int iaqcore_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct iaq_core_data *drv_data = dev->data; struct iaq_registers buf; @@ -66,7 +67,7 @@ static int iaqcore_sample_fetch(struct device *dev, enum sensor_channel chan) return -EIO; } -static int iaqcore_channel_get(struct device *dev, +static int iaqcore_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -97,7 +98,7 @@ static const struct sensor_driver_api iaq_core_driver_api = { .channel_get = iaqcore_channel_get, }; -static int iaq_core_init(struct device *dev) +static int iaq_core_init(const struct device *dev) { struct iaq_core_data *drv_data = dev->data; diff --git a/drivers/sensor/ams_iAQcore/iAQcore.h b/drivers/sensor/ams_iAQcore/iAQcore.h index d1fec308c893e4..2f8e6f40205303 100644 --- a/drivers/sensor/ams_iAQcore/iAQcore.h +++ b/drivers/sensor/ams_iAQcore/iAQcore.h @@ -18,7 +18,7 @@ struct iaq_registers { } __packed; struct iaq_core_data { - struct device *i2c; + const struct device *i2c; uint16_t co2; uint16_t voc; uint8_t status; diff --git a/drivers/sensor/apds9960/apds9960.c b/drivers/sensor/apds9960/apds9960.c index e540c14cdb3ea4..85751958e788aa 100644 --- a/drivers/sensor/apds9960/apds9960.c +++ b/drivers/sensor/apds9960/apds9960.c @@ -36,8 +36,8 @@ static void apds9960_handle_cb(struct apds9960_data *drv_data) #endif } -static void apds9960_gpio_callback(struct device *dev, - struct gpio_callback *cb, uint32_t pins) +static void apds9960_gpio_callback(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) { struct apds9960_data *drv_data = CONTAINER_OF(cb, struct apds9960_data, gpio_cb); @@ -45,7 +45,8 @@ static void apds9960_gpio_callback(struct device *dev, apds9960_handle_cb(drv_data); } -static int apds9960_sample_fetch(struct device *dev, enum sensor_channel chan) +static int apds9960_sample_fetch(const struct device *dev, + enum sensor_channel chan) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; @@ -113,7 +114,7 @@ static int apds9960_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int apds9960_channel_get(struct device *dev, +static int apds9960_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -149,7 +150,7 @@ static int apds9960_channel_get(struct device *dev, return 0; } -static int apds9960_proxy_setup(struct device *dev) +static int apds9960_proxy_setup(const struct device *dev) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; @@ -221,7 +222,7 @@ static int apds9960_proxy_setup(struct device *dev) } #ifdef CONFIG_APDS9960_ENABLE_ALS -static int apds9960_ambient_setup(struct device *dev) +static int apds9960_ambient_setup(const struct device *dev) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; @@ -271,7 +272,7 @@ static int apds9960_ambient_setup(struct device *dev) } #endif -static int apds9960_sensor_setup(struct device *dev) +static int apds9960_sensor_setup(const struct device *dev) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; @@ -356,7 +357,7 @@ static int apds9960_sensor_setup(struct device *dev) return 0; } -static int apds9960_init_interrupt(struct device *dev) +static int apds9960_init_interrupt(const struct device *dev) { const struct apds9960_config *config = dev->config; struct apds9960_data *drv_data = dev->data; @@ -407,7 +408,8 @@ static int apds9960_init_interrupt(struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int apds9960_device_ctrl(struct device *dev, uint32_t ctrl_command, +static int apds9960_device_ctrl(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { const struct apds9960_config *config = dev->config; @@ -451,7 +453,7 @@ static int apds9960_device_ctrl(struct device *dev, uint32_t ctrl_command, } #endif -static int apds9960_init(struct device *dev) +static int apds9960_init(const struct device *dev) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; diff --git a/drivers/sensor/apds9960/apds9960.h b/drivers/sensor/apds9960/apds9960.h index e25421d70d0558..f691123b5aa1ee 100644 --- a/drivers/sensor/apds9960/apds9960.h +++ b/drivers/sensor/apds9960/apds9960.h @@ -225,11 +225,11 @@ struct apds9960_config { }; struct apds9960_data { - struct device *i2c; - struct device *gpio; + const struct device *i2c; + const struct device *gpio; struct gpio_callback gpio_cb; struct k_work work; - struct device *dev; + const struct device *dev; uint16_t sample_crgb[4]; uint8_t pdata; uint8_t gpio_pin; @@ -257,12 +257,12 @@ static inline void apds9960_setup_int(struct apds9960_data *drv_data, #ifdef CONFIG_APDS9960_TRIGGER void apds9960_work_cb(struct k_work *work); -int apds9960_attr_set(struct device *dev, +int apds9960_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int apds9960_trigger_set(struct device *dev, +int apds9960_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_APDS9960_TRIGGER */ diff --git a/drivers/sensor/apds9960/apds9960_trigger.c b/drivers/sensor/apds9960/apds9960_trigger.c index 367178055a1f7f..2c9918cabf6061 100644 --- a/drivers/sensor/apds9960/apds9960_trigger.c +++ b/drivers/sensor/apds9960/apds9960_trigger.c @@ -22,7 +22,7 @@ void apds9960_work_cb(struct k_work *work) struct apds9960_data *data = CONTAINER_OF(work, struct apds9960_data, work); - struct device *dev = data->dev; + const struct device *dev = data->dev; if (data->p_th_handler != NULL) { data->p_th_handler(dev, &data->p_th_trigger); @@ -31,7 +31,7 @@ void apds9960_work_cb(struct k_work *work) apds9960_setup_int(data, true); } -int apds9960_attr_set(struct device *dev, +int apds9960_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -65,9 +65,9 @@ int apds9960_attr_set(struct device *dev, return -ENOTSUP; } -int apds9960_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) +int apds9960_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { const struct apds9960_config *config = dev->config; struct apds9960_data *data = dev->data; diff --git a/drivers/sensor/bma280/bma280.c b/drivers/sensor/bma280/bma280.c index 15c09af35d78ec..048f4e65d4f502 100644 --- a/drivers/sensor/bma280/bma280.c +++ b/drivers/sensor/bma280/bma280.c @@ -16,7 +16,8 @@ LOG_MODULE_REGISTER(BMA280, CONFIG_SENSOR_LOG_LEVEL); -static int bma280_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bma280_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bma280_data *drv_data = dev->data; uint8_t buf[6]; @@ -72,7 +73,7 @@ static void bma280_channel_accel_convert(struct sensor_value *val, } } -static int bma280_channel_get(struct device *dev, +static int bma280_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -113,7 +114,7 @@ static const struct sensor_driver_api bma280_driver_api = { .channel_get = bma280_channel_get, }; -int bma280_init(struct device *dev) +int bma280_init(const struct device *dev) { struct bma280_data *drv_data = dev->data; uint8_t id = 0U; diff --git a/drivers/sensor/bma280/bma280.h b/drivers/sensor/bma280/bma280.h index b41aca53f7cdec..e0f0ff0eaff6dc 100644 --- a/drivers/sensor/bma280/bma280.h +++ b/drivers/sensor/bma280/bma280.h @@ -114,15 +114,15 @@ #define BMA280_THREAD_STACKSIZE_UNIT 1024 struct bma280_data { - struct device *i2c; + const struct device *i2c; int16_t x_sample; int16_t y_sample; int16_t z_sample; int8_t temp_sample; #ifdef CONFIG_BMA280_TRIGGER - struct device *dev; - struct device *gpio; + const struct device *dev; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; @@ -143,16 +143,16 @@ struct bma280_data { }; #ifdef CONFIG_BMA280_TRIGGER -int bma280_trigger_set(struct device *dev, +int bma280_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int bma280_attr_set(struct device *dev, +int bma280_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int bma280_init_interrupt(struct device *dev); +int bma280_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_BMA280_BMA280_H_ */ diff --git a/drivers/sensor/bma280/bma280_trigger.c b/drivers/sensor/bma280/bma280_trigger.c index 1bcd38201f0708..96d1733ae50503 100644 --- a/drivers/sensor/bma280/bma280_trigger.c +++ b/drivers/sensor/bma280/bma280_trigger.c @@ -17,7 +17,7 @@ #include LOG_MODULE_DECLARE(BMA280, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_int1(struct device *dev, +static inline void setup_int1(const struct device *dev, bool enable) { struct bma280_data *data = dev->data; @@ -29,7 +29,7 @@ static inline void setup_int1(struct device *dev, : GPIO_INT_DISABLE)); } -int bma280_attr_set(struct device *dev, +int bma280_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -67,7 +67,7 @@ int bma280_attr_set(struct device *dev, return 0; } -static void bma280_gpio_callback(struct device *dev, +static void bma280_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct bma280_data *drv_data = @@ -86,7 +86,7 @@ static void bma280_gpio_callback(struct device *dev, static void bma280_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct bma280_data *drv_data = dev->data; uint8_t status = 0U; int err = 0; @@ -128,7 +128,7 @@ static void bma280_thread_cb(void *arg) #ifdef CONFIG_BMA280_TRIGGER_OWN_THREAD static void bma280_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct bma280_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -150,7 +150,7 @@ static void bma280_work_cb(struct k_work *work) } #endif -int bma280_trigger_set(struct device *dev, +int bma280_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -209,7 +209,7 @@ int bma280_trigger_set(struct device *dev, return 0; } -int bma280_init_interrupt(struct device *dev) +int bma280_init_interrupt(const struct device *dev) { struct bma280_data *drv_data = dev->data; diff --git a/drivers/sensor/bmc150_magn/bmc150_magn.c b/drivers/sensor/bmc150_magn/bmc150_magn.c index 6065c10d10052c..171d056d81f5ad 100644 --- a/drivers/sensor/bmc150_magn/bmc150_magn.c +++ b/drivers/sensor/bmc150_magn/bmc150_magn.c @@ -48,7 +48,7 @@ static const struct bmc150_magn_preset { [HIGH_ACCURACY_PRESET] = {47, 83, 20} }; -static int bmc150_magn_set_power_mode(struct device *dev, +static int bmc150_magn_set_power_mode(const struct device *dev, enum bmc150_magn_power_modes mode, int state) { @@ -88,7 +88,7 @@ static int bmc150_magn_set_power_mode(struct device *dev, return -ENOTSUP; } -static int bmc150_magn_set_odr(struct device *dev, uint8_t val) +static int bmc150_magn_set_odr(const struct device *dev, uint8_t val) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -110,7 +110,7 @@ static int bmc150_magn_set_odr(struct device *dev, uint8_t val) } #if defined(BMC150_MAGN_SET_ATTR) -static int bmc150_magn_read_rep_xy(struct device *dev) +static int bmc150_magn_read_rep_xy(const struct device *dev) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -126,7 +126,7 @@ static int bmc150_magn_read_rep_xy(struct device *dev) return 0; } -static int bmc150_magn_read_rep_z(struct device *dev) +static int bmc150_magn_read_rep_z(const struct device *dev) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -142,7 +142,7 @@ static int bmc150_magn_read_rep_z(struct device *dev) return 0; } -static int bmc150_magn_compute_max_odr(struct device *dev, int rep_xy, +static int bmc150_magn_compute_max_odr(const struct device *dev, int rep_xy, int rep_z, int *max_odr) { struct bmc150_magn_data *data = dev->data; @@ -172,7 +172,7 @@ static int bmc150_magn_compute_max_odr(struct device *dev, int rep_xy, #endif #if defined(BMC150_MAGN_SET_ATTR_REP) -static int bmc150_magn_read_odr(struct device *dev) +static int bmc150_magn_read_odr(const struct device *dev) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -197,7 +197,7 @@ static int bmc150_magn_read_odr(struct device *dev) #endif #if defined(CONFIG_BMC150_MAGN_SAMPLING_REP_XY) -static int bmc150_magn_write_rep_xy(struct device *dev, int val) +static int bmc150_magn_write_rep_xy(const struct device *dev, int val) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -216,7 +216,7 @@ static int bmc150_magn_write_rep_xy(struct device *dev, int val) #endif #if defined(CONFIG_BMC150_MAGN_SAMPLING_REP_Z) -static int bmc150_magn_write_rep_z(struct device *dev, int val) +static int bmc150_magn_write_rep_z(const struct device *dev, int val) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -288,7 +288,7 @@ static int32_t bmc150_magn_compensate_z(struct bmc150_magn_trim_regs *tregs, return val; } -static int bmc150_magn_sample_fetch(struct device *dev, +static int bmc150_magn_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct bmc150_magn_data *data = dev->data; @@ -332,7 +332,7 @@ static void bmc150_magn_convert(struct sensor_value *val, int raw_val) val->val2 = ((int32_t)raw_val * (1000000 / 1600)) % 1000000; } -static int bmc150_magn_channel_get(struct device *dev, +static int bmc150_magn_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -361,7 +361,7 @@ static int bmc150_magn_channel_get(struct device *dev, } #if defined(BMC150_MAGN_SET_ATTR_REP) -static inline int bmc150_magn_attr_set_rep(struct device *dev, +static inline int bmc150_magn_attr_set_rep(const struct device *dev, enum sensor_channel chan, const struct sensor_value *val) { @@ -431,7 +431,7 @@ static inline int bmc150_magn_attr_set_rep(struct device *dev, #endif #if defined(BMC150_MAGN_SET_ATTR) -static int bmc150_magn_attr_set(struct device *dev, +static int bmc150_magn_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -482,7 +482,7 @@ static const struct sensor_driver_api bmc150_magn_api_funcs = { #endif }; -static int bmc150_magn_init_chip(struct device *dev) +static int bmc150_magn_init_chip(const struct device *dev) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -568,7 +568,7 @@ static int bmc150_magn_init_chip(struct device *dev) return -EIO; } -static int bmc150_magn_init(struct device *dev) +static int bmc150_magn_init(const struct device *dev) { const struct bmc150_magn_config * const config = dev->config; diff --git a/drivers/sensor/bmc150_magn/bmc150_magn.h b/drivers/sensor/bmc150_magn/bmc150_magn.h index c0bbce5a1ccbdb..9c4f9b6a7791d8 100644 --- a/drivers/sensor/bmc150_magn/bmc150_magn.h +++ b/drivers/sensor/bmc150_magn/bmc150_magn.h @@ -113,7 +113,7 @@ struct bmc150_magn_trim_regs { } __packed; struct bmc150_magn_data { - struct device *i2c_master; + const struct device *i2c_master; struct k_sem sem; #if defined(CONFIG_BMC150_MAGN_TRIGGER) @@ -123,8 +123,8 @@ struct bmc150_magn_data { #endif #if defined(CONFIG_BMC150_MAGN_TRIGGER_DRDY) - struct device *gpio_drdy; - struct device *dev; + const struct device *gpio_drdy; + const struct device *dev; struct gpio_callback gpio_cb; struct sensor_trigger trigger_drdy; sensor_trigger_handler_t handler_drdy; @@ -168,11 +168,11 @@ enum bmc150_magn_axis { }; #if defined(CONFIG_BMC150_MAGN_TRIGGER) -int bmc150_magn_trigger_set(struct device *dev, +int bmc150_magn_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int bmc150_magn_init_interrupt(struct device *dev); +int bmc150_magn_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_BMC150_MAGN_BMC150_MAGN_H_ */ diff --git a/drivers/sensor/bmc150_magn/bmc150_magn_trigger.c b/drivers/sensor/bmc150_magn/bmc150_magn_trigger.c index 0b17e9821a2930..cb63ed6341d2ea 100644 --- a/drivers/sensor/bmc150_magn/bmc150_magn_trigger.c +++ b/drivers/sensor/bmc150_magn/bmc150_magn_trigger.c @@ -15,7 +15,7 @@ #include LOG_MODULE_DECLARE(BMC150_MAGN, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_drdy(struct device *dev, +static inline void setup_drdy(const struct device *dev, bool enable) { struct bmc150_magn_data *data = dev->data; @@ -30,7 +30,7 @@ static inline void setup_drdy(struct device *dev, } -int bmc150_magn_trigger_set(struct device *dev, +int bmc150_magn_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -68,7 +68,7 @@ int bmc150_magn_trigger_set(struct device *dev, return 0; } -static void bmc150_magn_gpio_drdy_callback(struct device *dev, +static void bmc150_magn_gpio_drdy_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { @@ -84,7 +84,7 @@ static void bmc150_magn_gpio_drdy_callback(struct device *dev, static void bmc150_magn_thread_main(void *arg1, void *arg2, void *arg3) { - struct device *dev = (struct device *) arg1; + const struct device *dev = (const struct device *) arg1; struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; uint8_t reg_val; @@ -107,7 +107,7 @@ static void bmc150_magn_thread_main(void *arg1, void *arg2, void *arg3) } } -static int bmc150_magn_set_drdy_polarity(struct device *dev, int state) +static int bmc150_magn_set_drdy_polarity(const struct device *dev, int state) { struct bmc150_magn_data *data = dev->data; const struct bmc150_magn_config *config = dev->config; @@ -122,7 +122,7 @@ static int bmc150_magn_set_drdy_polarity(struct device *dev, int state) state << BMC150_MAGN_SHIFT_DRDY_DR_POLARITY); } -int bmc150_magn_init_interrupt(struct device *dev) +int bmc150_magn_init_interrupt(const struct device *dev) { const struct bmc150_magn_config * const config = dev->config; diff --git a/drivers/sensor/bme280/bme280.c b/drivers/sensor/bme280/bme280.c index c5aea460ef1270..dada7cdcc4a51f 100644 --- a/drivers/sensor/bme280/bme280.c +++ b/drivers/sensor/bme280/bme280.c @@ -42,7 +42,7 @@ LOG_MODULE_REGISTER(BME280, CONFIG_SENSOR_LOG_LEVEL); */ struct bme280_data { - struct device *bus; + const struct device *bus; #if BME280_BUS_SPI struct spi_cs_control spi_cs; #endif @@ -98,10 +98,10 @@ struct bme280_config { const union bme280_bus_config bus_config; }; -typedef int (*bme280_reg_read_fn)(struct device *bus, +typedef int (*bme280_reg_read_fn)(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t start, uint8_t *buf, int size); -typedef int (*bme280_reg_write_fn)(struct device *bus, +typedef int (*bme280_reg_write_fn)(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t reg, uint8_t val); @@ -110,22 +110,22 @@ struct bme280_reg_io { bme280_reg_write_fn write; }; -static inline struct bme280_data *to_data(struct device *dev) +static inline struct bme280_data *to_data(const struct device *dev) { return dev->data; } -static inline const struct bme280_config *to_config(struct device *dev) +static inline const struct bme280_config *to_config(const struct device *dev) { return dev->config; } -static inline struct device *to_bus(struct device *dev) +static inline const struct device *to_bus(const struct device *dev) { return to_data(dev)->bus; } -static inline const union bme280_bus_config *to_bus_config(struct device *dev) +static inline const union bme280_bus_config *to_bus_config(const struct device *dev) { return &to_config(dev)->bus_config; } @@ -137,7 +137,7 @@ to_spi_config(const union bme280_bus_config *bus_config) return &bus_config->spi_cfg->spi_cfg; } -static int bme280_reg_read_spi(struct device *bus, +static int bme280_reg_read_spi(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t start, uint8_t *buf, int size) { @@ -178,7 +178,7 @@ static int bme280_reg_read_spi(struct device *bus, return 0; } -static int bme280_reg_write_spi(struct device *bus, +static int bme280_reg_write_spi(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t reg, uint8_t val) { @@ -208,7 +208,7 @@ static const struct bme280_reg_io bme280_reg_io_spi = { #endif /* BME280_BUS_SPI */ #if BME280_BUS_I2C -static int bme280_reg_read_i2c(struct device *bus, +static int bme280_reg_read_i2c(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t start, uint8_t *buf, int size) { @@ -216,7 +216,7 @@ static int bme280_reg_read_i2c(struct device *bus, start, buf, size); } -static int bme280_reg_write_i2c(struct device *bus, +static int bme280_reg_write_i2c(const struct device *bus, const union bme280_bus_config *bus_config, uint8_t reg, uint8_t val) { @@ -230,14 +230,15 @@ static const struct bme280_reg_io bme280_reg_io_i2c = { }; #endif /* BME280_BUS_I2C */ -static inline int bme280_reg_read(struct device *dev, +static inline int bme280_reg_read(const struct device *dev, uint8_t start, uint8_t *buf, int size) { return to_config(dev)->reg_io->read(to_bus(dev), to_bus_config(dev), start, buf, size); } -static inline int bme280_reg_write(struct device *dev, uint8_t reg, uint8_t val) +static inline int bme280_reg_write(const struct device *dev, uint8_t reg, + uint8_t val) { return to_config(dev)->reg_io->write(to_bus(dev), to_bus_config(dev), reg, val); @@ -306,7 +307,8 @@ static void bme280_compensate_humidity(struct bme280_data *data, data->comp_humidity = (uint32_t)(h >> 12); } -static int bme280_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bme280_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bme280_data *data = to_data(dev); uint8_t buf[8]; @@ -353,7 +355,7 @@ static int bme280_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int bme280_channel_get(struct device *dev, +static int bme280_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -399,7 +401,7 @@ static const struct sensor_driver_api bme280_api_funcs = { .channel_get = bme280_channel_get, }; -static int bme280_read_compensation(struct device *dev) +static int bme280_read_compensation(const struct device *dev) { struct bme280_data *data = to_data(dev); uint16_t buf[12]; @@ -452,7 +454,7 @@ static int bme280_read_compensation(struct device *dev) return 0; } -static int bme280_chip_init(struct device *dev) +static int bme280_chip_init(const struct device *dev) { struct bme280_data *data = to_data(dev); int err; @@ -505,12 +507,12 @@ static int bme280_chip_init(struct device *dev) } #if BME280_BUS_SPI -static inline int bme280_is_on_spi(struct device *dev) +static inline int bme280_is_on_spi(const struct device *dev) { return to_config(dev)->reg_io == &bme280_reg_io_spi; } -static inline int bme280_spi_init(struct device *dev) +static inline int bme280_spi_init(const struct device *dev) { struct bme280_data *data = to_data(dev); const struct bme280_spi_cfg *spi_cfg = to_bus_config(dev)->spi_cfg; @@ -530,18 +532,18 @@ static inline int bme280_spi_init(struct device *dev) return 0; } #else -static inline int bme280_is_on_spi(struct device *dev) +static inline int bme280_is_on_spi(const struct device *dev) { return 0; } -static inline int bme280_spi_init(struct device *dev) +static inline int bme280_spi_init(const struct device *dev) { return 0; } #endif -int bme280_init(struct device *dev) +int bme280_init(const struct device *dev) { const char *name = dev->name; struct bme280_data *data = to_data(dev); diff --git a/drivers/sensor/bme680/bme680.c b/drivers/sensor/bme680/bme680.c index 382b521687ef2b..4fd349a73fe2de 100644 --- a/drivers/sensor/bme680/bme680.c +++ b/drivers/sensor/bme680/bme680.c @@ -188,7 +188,8 @@ static uint8_t bme680_calc_gas_wait(uint16_t dur) return durval; } -static int bme680_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bme680_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bme680_data *data = dev->data; uint8_t buff[BME680_LEN_FIELD] = { 0 }; @@ -233,7 +234,8 @@ static int bme680_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int bme680_channel_get(struct device *dev, enum sensor_channel chan, +static int bme680_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct bme680_data *data = dev->data; @@ -339,7 +341,7 @@ static int bme680_read_compensation(struct bme680_data *data) return 0; } -static int bme680_chip_init(struct device *dev) +static int bme680_chip_init(const struct device *dev) { struct bme680_data *data = (struct bme680_data *)dev->data; int err; @@ -398,7 +400,7 @@ static int bme680_chip_init(struct device *dev) return 0; } -static int bme680_init(struct device *dev) +static int bme680_init(const struct device *dev) { struct bme680_data *data = dev->data; diff --git a/drivers/sensor/bme680/bme680.h b/drivers/sensor/bme680/bme680.h index 056514dd57b8e9..4a10373992e63e 100644 --- a/drivers/sensor/bme680/bme680.h +++ b/drivers/sensor/bme680/bme680.h @@ -120,7 +120,7 @@ #define BME680_CONCAT_BYTES(msb, lsb) (((uint16_t)msb << 8) | (uint16_t)lsb) struct bme680_data { - struct device *i2c_master; + const struct device *i2c_master; uint16_t i2c_slave_addr; /* Compensation parameters. */ diff --git a/drivers/sensor/bmg160/bmg160.c b/drivers/sensor/bmg160/bmg160.c index a303f822d90ba1..aeac68c5f5a3a0 100644 --- a/drivers/sensor/bmg160/bmg160.c +++ b/drivers/sensor/bmg160/bmg160.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(BMG160, CONFIG_SENSOR_LOG_LEVEL); struct bmg160_device_data bmg160_data; -static inline int bmg160_bus_config(struct device *dev) +static inline int bmg160_bus_config(const struct device *dev) { const struct bmg160_device_config *dev_cfg = dev->config; struct bmg160_device_data *bmg160 = dev->data; @@ -33,7 +33,7 @@ static inline int bmg160_bus_config(struct device *dev) return i2c_configure(bmg160->i2c, i2c_cfg); } -int bmg160_read(struct device *dev, uint8_t reg_addr, uint8_t *data, +int bmg160_read(const struct device *dev, uint8_t reg_addr, uint8_t *data, uint8_t len) { const struct bmg160_device_config *dev_cfg = dev->config; @@ -54,12 +54,14 @@ int bmg160_read(struct device *dev, uint8_t reg_addr, uint8_t *data, return ret; } -int bmg160_read_byte(struct device *dev, uint8_t reg_addr, uint8_t *byte) +int bmg160_read_byte(const struct device *dev, uint8_t reg_addr, + uint8_t *byte) { return bmg160_read(dev, reg_addr, byte, 1); } -static int bmg160_write(struct device *dev, uint8_t reg_addr, uint8_t *data, +static int bmg160_write(const struct device *dev, uint8_t reg_addr, + uint8_t *data, uint8_t len) { const struct bmg160_device_config *dev_cfg = dev->config; @@ -80,12 +82,14 @@ static int bmg160_write(struct device *dev, uint8_t reg_addr, uint8_t *data, return ret; } -int bmg160_write_byte(struct device *dev, uint8_t reg_addr, uint8_t byte) +int bmg160_write_byte(const struct device *dev, uint8_t reg_addr, + uint8_t byte) { return bmg160_write(dev, reg_addr, &byte, 1); } -int bmg160_update_byte(struct device *dev, uint8_t reg_addr, uint8_t mask, +int bmg160_update_byte(const struct device *dev, uint8_t reg_addr, + uint8_t mask, uint8_t value) { const struct bmg160_device_config *dev_cfg = dev->config; @@ -128,7 +132,7 @@ static int bmg160_is_val_valid(int16_t val, const int16_t *val_map, return -1; } -static int bmg160_attr_set(struct device *dev, enum sensor_channel chan, +static int bmg160_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -188,7 +192,8 @@ static int bmg160_attr_set(struct device *dev, enum sensor_channel chan, } } -static int bmg160_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bmg160_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bmg160_device_data *bmg160 = dev->data; union { @@ -229,7 +234,8 @@ static void bmg160_to_fixed_point(struct bmg160_device_data *bmg160, } } -static int bmg160_channel_get(struct device *dev, enum sensor_channel chan, +static int bmg160_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct bmg160_device_data *bmg160 = dev->data; @@ -271,7 +277,7 @@ static const struct sensor_driver_api bmg160_api = { .channel_get = bmg160_channel_get, }; -int bmg160_init(struct device *dev) +int bmg160_init(const struct device *dev) { const struct bmg160_device_config *cfg = dev->config; struct bmg160_device_data *bmg160 = dev->data; diff --git a/drivers/sensor/bmg160/bmg160.h b/drivers/sensor/bmg160/bmg160.h index 32d9948cb17f22..bf3e1afe0ff330 100644 --- a/drivers/sensor/bmg160/bmg160.h +++ b/drivers/sensor/bmg160/bmg160.h @@ -189,9 +189,9 @@ struct bmg160_device_config { }; struct bmg160_device_data { - struct device *i2c; + const struct device *i2c; #ifdef CONFIG_BMG160_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; #endif #ifdef CONFIG_BMG160_TRIGGER_OWN_THREAD @@ -200,7 +200,7 @@ struct bmg160_device_data { struct k_sem sem; #ifdef CONFIG_BMG160_TRIGGER_GLOBAL_THREAD struct k_work work; - struct device *dev; + const struct device *dev; #endif #ifdef CONFIG_BMG160_TRIGGER sensor_trigger_handler_t anymotion_handler; @@ -213,17 +213,20 @@ struct bmg160_device_data { int8_t raw_temp; }; -int bmg160_trigger_init(struct device *dev); -int bmg160_trigger_set(struct device *dev, +int bmg160_trigger_init(const struct device *dev); +int bmg160_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int bmg160_read(struct device *dev, uint8_t reg_addr, uint8_t *data, +int bmg160_read(const struct device *dev, uint8_t reg_addr, uint8_t *data, uint8_t len); -int bmg160_read_byte(struct device *dev, uint8_t reg_addr, uint8_t *byte); -int bmg160_update_byte(struct device *dev, uint8_t reg_addr, uint8_t mask, +int bmg160_read_byte(const struct device *dev, uint8_t reg_addr, + uint8_t *byte); +int bmg160_update_byte(const struct device *dev, uint8_t reg_addr, + uint8_t mask, uint8_t value); -int bmg160_write_byte(struct device *dev, uint8_t reg_addr, uint8_t data); -int bmg160_slope_config(struct device *dev, enum sensor_attribute attr, +int bmg160_write_byte(const struct device *dev, uint8_t reg_addr, + uint8_t data); +int bmg160_slope_config(const struct device *dev, enum sensor_attribute attr, const struct sensor_value *val); #endif /* ZEPHYR_DRIVERS_SENSOR_BMG160_BMG160_H_ */ diff --git a/drivers/sensor/bmg160/bmg160_trigger.c b/drivers/sensor/bmg160/bmg160_trigger.c index 31afeeefd8f1e3..7cb36822703d93 100644 --- a/drivers/sensor/bmg160/bmg160_trigger.c +++ b/drivers/sensor/bmg160/bmg160_trigger.c @@ -18,7 +18,7 @@ extern struct bmg160_device_data bmg160_data; #include LOG_MODULE_DECLARE(BMG160, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_int(struct device *dev, +static inline void setup_int(const struct device *dev, bool enable) { struct bmg160_device_data *data = dev->data; @@ -32,7 +32,8 @@ static inline void setup_int(struct device *dev, : GPIO_INT_DISABLE); } -static void bmg160_gpio_callback(struct device *port, struct gpio_callback *cb, +static void bmg160_gpio_callback(const struct device *port, + struct gpio_callback *cb, uint32_t pin) { struct bmg160_device_data *bmg160 = @@ -48,7 +49,7 @@ static void bmg160_gpio_callback(struct device *port, struct gpio_callback *cb, #endif } -static int bmg160_anymotion_set(struct device *dev, +static int bmg160_anymotion_set(const struct device *dev, sensor_trigger_handler_t handler) { struct bmg160_device_data *bmg160 = dev->data; @@ -70,7 +71,8 @@ static int bmg160_anymotion_set(struct device *dev, return 0; } -static int bmg160_drdy_set(struct device *dev, sensor_trigger_handler_t handler) +static int bmg160_drdy_set(const struct device *dev, + sensor_trigger_handler_t handler) { struct bmg160_device_data *bmg160 = dev->data; @@ -85,7 +87,7 @@ static int bmg160_drdy_set(struct device *dev, sensor_trigger_handler_t handler) return 0; } -int bmg160_slope_config(struct device *dev, enum sensor_attribute attr, +int bmg160_slope_config(const struct device *dev, enum sensor_attribute attr, const struct sensor_value *val) { struct bmg160_device_data *bmg160 = dev->data; @@ -120,7 +122,7 @@ int bmg160_slope_config(struct device *dev, enum sensor_attribute attr, return -ENOTSUP; } -int bmg160_trigger_set(struct device *dev, +int bmg160_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -133,7 +135,7 @@ int bmg160_trigger_set(struct device *dev, return -ENOTSUP; } -static int bmg160_handle_anymotion_int(struct device *dev) +static int bmg160_handle_anymotion_int(const struct device *dev) { struct bmg160_device_data *bmg160 = dev->data; struct sensor_trigger any_trig = { @@ -148,7 +150,7 @@ static int bmg160_handle_anymotion_int(struct device *dev) return 0; } -static int bmg160_handle_dataready_int(struct device *dev) +static int bmg160_handle_dataready_int(const struct device *dev) { struct bmg160_device_data *bmg160 = dev->data; struct sensor_trigger drdy_trig = { @@ -165,7 +167,7 @@ static int bmg160_handle_dataready_int(struct device *dev) static void bmg160_handle_int(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; uint8_t status_int[4]; if (bmg160_read(dev, BMG160_REG_INT_STATUS0, status_int, 4) < 0) { @@ -185,7 +187,7 @@ static struct k_thread bmg160_thread; static void bmg160_thread_main(void *arg1, void *arg2, void *arg3) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct bmg160_device_data *bmg160 = dev->data; while (true) { @@ -206,7 +208,7 @@ static void bmg160_work_cb(struct k_work *work) } #endif -int bmg160_trigger_init(struct device *dev) +int bmg160_trigger_init(const struct device *dev) { const struct bmg160_device_config *cfg = dev->config; struct bmg160_device_data *bmg160 = dev->data; diff --git a/drivers/sensor/bmi160/bmi160.c b/drivers/sensor/bmi160/bmi160.c index 434ecfaca35749..5b8cfbed332f97 100644 --- a/drivers/sensor/bmi160/bmi160.c +++ b/drivers/sensor/bmi160/bmi160.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(BMI160, CONFIG_SENSOR_LOG_LEVEL); struct bmi160_device_data bmi160_data; -static int bmi160_transceive(struct device *dev, uint8_t reg, +static int bmi160_transceive(const struct device *dev, uint8_t reg, bool write, void *data, size_t length) { struct bmi160_device_data *bmi160 = dev->data; @@ -53,17 +53,20 @@ static int bmi160_transceive(struct device *dev, uint8_t reg, return spi_write(bmi160->spi, &bmi160->spi_cfg, &tx); } -int bmi160_read(struct device *dev, uint8_t reg_addr, uint8_t *data, uint8_t len) +int bmi160_read(const struct device *dev, uint8_t reg_addr, uint8_t *data, + uint8_t len) { return bmi160_transceive(dev, reg_addr | BIT(7), false, data, len); } -int bmi160_byte_read(struct device *dev, uint8_t reg_addr, uint8_t *byte) +int bmi160_byte_read(const struct device *dev, uint8_t reg_addr, + uint8_t *byte) { return bmi160_transceive(dev, reg_addr | BIT(7), false, byte, 1); } -static int bmi160_word_read(struct device *dev, uint8_t reg_addr, uint16_t *word) +static int bmi160_word_read(const struct device *dev, uint8_t reg_addr, + uint16_t *word) { if (bmi160_transceive(dev, reg_addr | BIT(7), false, word, 2) != 0) { return -EIO; @@ -74,12 +77,14 @@ static int bmi160_word_read(struct device *dev, uint8_t reg_addr, uint16_t *word return 0; } -int bmi160_byte_write(struct device *dev, uint8_t reg_addr, uint8_t byte) +int bmi160_byte_write(const struct device *dev, uint8_t reg_addr, + uint8_t byte) { return bmi160_transceive(dev, reg_addr & 0x7F, true, &byte, 1); } -int bmi160_word_write(struct device *dev, uint8_t reg_addr, uint16_t word) +int bmi160_word_write(const struct device *dev, uint8_t reg_addr, + uint16_t word) { uint8_t tx_word[2] = { (uint8_t)(word & 0xff), @@ -89,7 +94,7 @@ int bmi160_word_write(struct device *dev, uint8_t reg_addr, uint16_t word) return bmi160_transceive(dev, reg_addr & 0x7F, true, tx_word, 2); } -int bmi160_reg_field_update(struct device *dev, uint8_t reg_addr, +int bmi160_reg_field_update(const struct device *dev, uint8_t reg_addr, uint8_t pos, uint8_t mask, uint8_t val) { uint8_t old_val; @@ -102,7 +107,8 @@ int bmi160_reg_field_update(struct device *dev, uint8_t reg_addr, (old_val & ~mask) | ((val << pos) & mask)); } -static int bmi160_pmu_set(struct device *dev, union bmi160_pmu_status *pmu_sts) +static int bmi160_pmu_set(const struct device *dev, + union bmi160_pmu_status *pmu_sts) { struct { uint8_t cmd; @@ -194,7 +200,7 @@ static int bmi160_freq_to_odr_val(uint16_t freq_int, uint16_t freq_milli) #endif #if defined(CONFIG_BMI160_ACCEL_ODR_RUNTIME) -static int bmi160_acc_odr_set(struct device *dev, uint16_t freq_int, +static int bmi160_acc_odr_set(const struct device *dev, uint16_t freq_int, uint16_t freq_milli) { struct bmi160_device_data *bmi160 = dev->data; @@ -281,7 +287,7 @@ int32_t bmi160_gyr_reg_val_to_range(uint8_t reg_val) BMI160_GYR_RANGE_MAP_SIZE); } -static int bmi160_do_calibration(struct device *dev, uint8_t foc_conf) +static int bmi160_do_calibration(const struct device *dev, uint8_t foc_conf) { if (bmi160_byte_write(dev, BMI160_REG_FOC_CONF, foc_conf) < 0) { return -EIO; @@ -297,7 +303,7 @@ static int bmi160_do_calibration(struct device *dev, uint8_t foc_conf) } #if defined(CONFIG_BMI160_ACCEL_RANGE_RUNTIME) -static int bmi160_acc_range_set(struct device *dev, int32_t range) +static int bmi160_acc_range_set(const struct device *dev, int32_t range) { struct bmi160_device_data *bmi160 = dev->data; int32_t reg_val = bmi160_range_to_reg_val(range, @@ -324,7 +330,8 @@ static int bmi160_acc_range_set(struct device *dev, int32_t range) * 3.9 * 9.80665 * 1000 */ #define BMI160_ACC_OFS_LSB 38246 -static int bmi160_acc_ofs_set(struct device *dev, enum sensor_channel chan, +static int bmi160_acc_ofs_set(const struct device *dev, + enum sensor_channel chan, const struct sensor_value *ofs) { uint8_t reg_addr[] = { @@ -357,7 +364,8 @@ static int bmi160_acc_ofs_set(struct device *dev, enum sensor_channel chan, BIT(BMI160_ACC_OFS_EN_POS), 1); } -static int bmi160_acc_calibrate(struct device *dev, enum sensor_channel chan, +static int bmi160_acc_calibrate(const struct device *dev, + enum sensor_channel chan, const struct sensor_value *xyz_calib_value) { struct bmi160_device_data *bmi160 = dev->data; @@ -408,7 +416,8 @@ static int bmi160_acc_calibrate(struct device *dev, enum sensor_channel chan, BIT(BMI160_ACC_OFS_EN_POS), 1); } -static int bmi160_acc_config(struct device *dev, enum sensor_channel chan, +static int bmi160_acc_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -440,7 +449,7 @@ static int bmi160_acc_config(struct device *dev, enum sensor_channel chan, #endif /* !defined(CONFIG_BMI160_ACCEL_PMU_SUSPEND) */ #if defined(CONFIG_BMI160_GYRO_ODR_RUNTIME) -static int bmi160_gyr_odr_set(struct device *dev, uint16_t freq_int, +static int bmi160_gyr_odr_set(const struct device *dev, uint16_t freq_int, uint16_t freq_milli) { int odr = bmi160_freq_to_odr_val(freq_int, freq_milli); @@ -461,7 +470,7 @@ static int bmi160_gyr_odr_set(struct device *dev, uint16_t freq_int, #endif #if defined(CONFIG_BMI160_GYRO_RANGE_RUNTIME) -static int bmi160_gyr_range_set(struct device *dev, uint16_t range) +static int bmi160_gyr_range_set(const struct device *dev, uint16_t range) { struct bmi160_device_data *bmi160 = dev->data; int32_t reg_val = bmi160_range_to_reg_val(range, @@ -488,7 +497,8 @@ static int bmi160_gyr_range_set(struct device *dev, uint16_t range) * 0.061 * (pi / 180) * 1000000, where pi = 3.141592 */ #define BMI160_GYR_OFS_LSB 1065 -static int bmi160_gyr_ofs_set(struct device *dev, enum sensor_channel chan, +static int bmi160_gyr_ofs_set(const struct device *dev, + enum sensor_channel chan, const struct sensor_value *ofs) { struct { @@ -543,7 +553,8 @@ static int bmi160_gyr_ofs_set(struct device *dev, enum sensor_channel chan, BIT(BMI160_GYR_OFS_EN_POS), 1); } -static int bmi160_gyr_calibrate(struct device *dev, enum sensor_channel chan) +static int bmi160_gyr_calibrate(const struct device *dev, + enum sensor_channel chan) { struct bmi160_device_data *bmi160 = dev->data; @@ -564,7 +575,8 @@ static int bmi160_gyr_calibrate(struct device *dev, enum sensor_channel chan) BIT(BMI160_GYR_OFS_EN_POS), 1); } -static int bmi160_gyr_config(struct device *dev, enum sensor_channel chan, +static int bmi160_gyr_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -592,8 +604,9 @@ static int bmi160_gyr_config(struct device *dev, enum sensor_channel chan, } #endif /* !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND) */ -static int bmi160_attr_set(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, const struct sensor_value *val) +static int bmi160_attr_set(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (chan) { #if !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND) @@ -625,7 +638,8 @@ static int bmi160_attr_set(struct device *dev, enum sensor_channel chan, # define BMI160_SAMPLE_BURST_READ_ADDR BMI160_REG_DATA_GYR_X # define BMI160_DATA_READY_BIT_MASK (1 << 6) #endif -static int bmi160_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bmi160_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bmi160_device_data *bmi160 = dev->data; size_t i; @@ -705,7 +719,7 @@ static void bmi160_channel_convert(enum sensor_channel chan, } #if !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND) -static inline void bmi160_gyr_channel_get(struct device *dev, +static inline void bmi160_gyr_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -717,7 +731,7 @@ static inline void bmi160_gyr_channel_get(struct device *dev, #endif #if !defined(CONFIG_BMI160_ACCEL_PMU_SUSPEND) -static inline void bmi160_acc_channel_get(struct device *dev, +static inline void bmi160_acc_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -728,7 +742,8 @@ static inline void bmi160_acc_channel_get(struct device *dev, } #endif -static int bmi160_temp_channel_get(struct device *dev, struct sensor_value *val) +static int bmi160_temp_channel_get(const struct device *dev, + struct sensor_value *val) { uint16_t temp_raw = 0U; int32_t temp_micro = 0; @@ -751,7 +766,7 @@ static int bmi160_temp_channel_get(struct device *dev, struct sensor_value *val) return 0; } -static int bmi160_channel_get(struct device *dev, +static int bmi160_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -791,7 +806,7 @@ static const struct sensor_driver_api bmi160_api = { .channel_get = bmi160_channel_get, }; -int bmi160_init(struct device *dev) +int bmi160_init(const struct device *dev) { struct bmi160_device_data *bmi160 = dev->data; uint8_t val = 0U; diff --git a/drivers/sensor/bmi160/bmi160.h b/drivers/sensor/bmi160/bmi160.h index c7e79c271164b3..ed1dad17a6d78f 100644 --- a/drivers/sensor/bmi160/bmi160.h +++ b/drivers/sensor/bmi160/bmi160.h @@ -428,10 +428,10 @@ struct bmi160_scale { }; struct bmi160_device_data { - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; #if defined(CONFIG_BMI160_TRIGGER) - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; #endif union bmi160_pmu_status pmu_sts; @@ -444,7 +444,7 @@ struct bmi160_device_data { #ifdef CONFIG_BMI160_TRIGGER_GLOBAL_THREAD struct k_work work; - struct device *dev; + const struct device *dev; #endif #ifdef CONFIG_BMI160_TRIGGER @@ -458,23 +458,28 @@ struct bmi160_device_data { #endif /* CONFIG_BMI160_TRIGGER */ }; -int bmi160_read(struct device *dev, uint8_t reg_addr, +int bmi160_read(const struct device *dev, uint8_t reg_addr, uint8_t *data, uint8_t len); -int bmi160_byte_read(struct device *dev, uint8_t reg_addr, uint8_t *byte); -int bmi160_byte_write(struct device *dev, uint8_t reg_addr, uint8_t byte); -int bmi160_word_write(struct device *dev, uint8_t reg_addr, uint16_t word); -int bmi160_reg_field_update(struct device *dev, uint8_t reg_addr, +int bmi160_byte_read(const struct device *dev, uint8_t reg_addr, + uint8_t *byte); +int bmi160_byte_write(const struct device *dev, uint8_t reg_addr, + uint8_t byte); +int bmi160_word_write(const struct device *dev, uint8_t reg_addr, + uint16_t word); +int bmi160_reg_field_update(const struct device *dev, uint8_t reg_addr, uint8_t pos, uint8_t mask, uint8_t val); -static inline int bmi160_reg_update(struct device *dev, uint8_t reg_addr, +static inline int bmi160_reg_update(const struct device *dev, + uint8_t reg_addr, uint8_t mask, uint8_t val) { return bmi160_reg_field_update(dev, reg_addr, 0, mask, val); } -int bmi160_trigger_mode_init(struct device *dev); -int bmi160_trigger_set(struct device *dev, +int bmi160_trigger_mode_init(const struct device *dev); +int bmi160_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int bmi160_acc_slope_config(struct device *dev, enum sensor_attribute attr, +int bmi160_acc_slope_config(const struct device *dev, + enum sensor_attribute attr, const struct sensor_value *val); int32_t bmi160_acc_reg_val_to_range(uint8_t reg_val); int32_t bmi160_gyr_reg_val_to_range(uint8_t reg_val); diff --git a/drivers/sensor/bmi160/bmi160_trigger.c b/drivers/sensor/bmi160/bmi160_trigger.c index 4abd373f8653ed..82048608db0f66 100644 --- a/drivers/sensor/bmi160/bmi160_trigger.c +++ b/drivers/sensor/bmi160/bmi160_trigger.c @@ -14,7 +14,7 @@ #include LOG_MODULE_DECLARE(BMI160, CONFIG_SENSOR_LOG_LEVEL); -static void bmi160_handle_anymotion(struct device *dev) +static void bmi160_handle_anymotion(const struct device *dev) { struct bmi160_device_data *bmi160 = dev->data; struct sensor_trigger anym_trigger = { @@ -27,7 +27,7 @@ static void bmi160_handle_anymotion(struct device *dev) } } -static void bmi160_handle_drdy(struct device *dev, uint8_t status) +static void bmi160_handle_drdy(const struct device *dev, uint8_t status) { struct bmi160_device_data *bmi160 = dev->data; struct sensor_trigger drdy_trigger = { @@ -51,7 +51,7 @@ static void bmi160_handle_drdy(struct device *dev, uint8_t status) static void bmi160_handle_interrupts(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; union { uint8_t raw[6]; @@ -87,7 +87,7 @@ static void bmi160_thread_main(void *arg1, void *unused1, void *unused2) { ARG_UNUSED(unused1); ARG_UNUSED(unused2); - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct bmi160_device_data *bmi160 = dev->data; while (1) { @@ -109,7 +109,7 @@ static void bmi160_work_handler(struct k_work *work) extern struct bmi160_device_data bmi160_data; -static void bmi160_gpio_callback(struct device *port, +static void bmi160_gpio_callback(const struct device *port, struct gpio_callback *cb, uint32_t pin) { struct bmi160_device_data *bmi160 = @@ -125,7 +125,7 @@ static void bmi160_gpio_callback(struct device *port, #endif } -static int bmi160_trigger_drdy_set(struct device *dev, +static int bmi160_trigger_drdy_set(const struct device *dev, enum sensor_channel chan, sensor_trigger_handler_t handler) { @@ -161,7 +161,7 @@ static int bmi160_trigger_drdy_set(struct device *dev, } #if !defined(CONFIG_BMI160_ACCEL_PMU_SUSPEND) -static int bmi160_trigger_anym_set(struct device *dev, +static int bmi160_trigger_anym_set(const struct device *dev, sensor_trigger_handler_t handler) { struct bmi160_device_data *bmi160 = dev->data; @@ -183,7 +183,7 @@ static int bmi160_trigger_anym_set(struct device *dev, return 0; } -static int bmi160_trigger_set_acc(struct device *dev, +static int bmi160_trigger_set_acc(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -196,7 +196,8 @@ static int bmi160_trigger_set_acc(struct device *dev, return -ENOTSUP; } -int bmi160_acc_slope_config(struct device *dev, enum sensor_attribute attr, +int bmi160_acc_slope_config(const struct device *dev, + enum sensor_attribute attr, const struct sensor_value *val) { uint8_t acc_range_g, reg_val; @@ -241,7 +242,7 @@ int bmi160_acc_slope_config(struct device *dev, enum sensor_attribute attr, #endif #if !defined(CONFIG_BMI160_GYRO_PMU_SUSPEND) -static int bmi160_trigger_set_gyr(struct device *dev, +static int bmi160_trigger_set_gyr(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -253,7 +254,7 @@ static int bmi160_trigger_set_gyr(struct device *dev, } #endif -int bmi160_trigger_set(struct device *dev, +int bmi160_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -270,7 +271,7 @@ int bmi160_trigger_set(struct device *dev, return -ENOTSUP; } -int bmi160_trigger_mode_init(struct device *dev) +int bmi160_trigger_mode_init(const struct device *dev) { struct bmi160_device_data *bmi160 = dev->data; diff --git a/drivers/sensor/bmm150/bmm150.c b/drivers/sensor/bmm150/bmm150.c index 0ade0a086027b1..012fac79f99878 100644 --- a/drivers/sensor/bmm150/bmm150.c +++ b/drivers/sensor/bmm150/bmm150.c @@ -36,7 +36,7 @@ static const struct bmm150_preset { [BMM150_HIGH_ACCURACY_PRESET] = { 47, 83, 20 } }; -static int bmm150_set_power_mode(struct device *dev, +static int bmm150_set_power_mode(const struct device *dev, enum bmm150_power_modes mode, int state) { @@ -77,7 +77,7 @@ static int bmm150_set_power_mode(struct device *dev, } -static int bmm150_set_odr(struct device *dev, uint8_t val) +static int bmm150_set_odr(const struct device *dev, uint8_t val) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -98,7 +98,7 @@ static int bmm150_set_odr(struct device *dev, uint8_t val) } #if defined(BMM150_SET_ATTR) -static int bmm150_read_rep_xy(struct device *dev) +static int bmm150_read_rep_xy(const struct device *dev) { struct bmm150_data *data = dev->driver->data; const struct bmm150_config *config = dev->config; @@ -114,7 +114,7 @@ static int bmm150_read_rep_xy(struct device *dev) return 0; } -static int bmm150_read_rep_z(struct device *dev) +static int bmm150_read_rep_z(const struct device *dev) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -130,7 +130,7 @@ static int bmm150_read_rep_z(struct device *dev) return 0; } -static int bmm150_compute_max_odr(struct device *dev, int rep_xy, +static int bmm150_compute_max_odr(const struct device *dev, int rep_xy, int rep_z, int *max_odr) { struct bmm150_data *data = dev->data; @@ -161,7 +161,7 @@ static int bmm150_compute_max_odr(struct device *dev, int rep_xy, #endif #if defined(BMM150_SET_ATTR_REP) -static int bmm150_read_odr(struct device *dev) +static int bmm150_read_odr(const struct device *dev) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -186,7 +186,7 @@ static int bmm150_read_odr(struct device *dev) #endif #if defined(CONFIG_BMM150_SAMPLING_REP_XY) -static int bmm150_write_rep_xy(struct device *dev, int val) +static int bmm150_write_rep_xy(const struct device *dev, int val) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -205,7 +205,7 @@ static int bmm150_write_rep_xy(struct device *dev, int val) #endif #if defined(CONFIG_BMM150_SAMPLING_REP_Z) -static int bmm150_write_rep_z(struct device *dev, int val) +static int bmm150_write_rep_z(const struct device *dev, int val) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -288,7 +288,8 @@ static int32_t bmm150_compensate_z(struct bmm150_trim_regs *tregs, return val; } -static int bmm150_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bmm150_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bmm150_data *drv_data = dev->data; @@ -338,7 +339,7 @@ static void bmm150_convert(struct sensor_value *val, int raw_val) val->val2 = ((int32_t)raw_val * (1000000 / 1600)) % 1000000; } -static int bmm150_channel_get(struct device *dev, +static int bmm150_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -367,7 +368,7 @@ static int bmm150_channel_get(struct device *dev, } #if defined(BMM150_SET_ATTR_REP) -static inline int bmm150_attr_set_rep(struct device *dev, +static inline int bmm150_attr_set_rep(const struct device *dev, enum sensor_channel chan, const struct sensor_value *val) { @@ -438,7 +439,7 @@ static inline int bmm150_attr_set_rep(struct device *dev, #endif #if defined(BMM150_SET_ATTR) -static int bmm150_attr_set(struct device *dev, +static int bmm150_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -486,7 +487,7 @@ static const struct sensor_driver_api bmm150_api_funcs = { .channel_get = bmm150_channel_get, }; -static int bmm150_init_chip(struct device *dev) +static int bmm150_init_chip(const struct device *dev) { struct bmm150_data *data = dev->data; const struct bmm150_config *config = dev->config; @@ -578,7 +579,7 @@ static int bmm150_init_chip(struct device *dev) return -EIO; } -static int bmm150_init(struct device *dev) +static int bmm150_init(const struct device *dev) { const struct bmm150_config *const config = dev->config; diff --git a/drivers/sensor/bmm150/bmm150.h b/drivers/sensor/bmm150/bmm150.h index 3a5f414bd7e9a8..5c576b478c1966 100644 --- a/drivers/sensor/bmm150/bmm150.h +++ b/drivers/sensor/bmm150/bmm150.h @@ -118,7 +118,7 @@ struct bmm150_trim_regs { } __packed; struct bmm150_data { - struct device *i2c; + const struct device *i2c; struct k_sem sem; struct bmm150_trim_regs tregs; int rep_xy, rep_z, odr, max_odr; diff --git a/drivers/sensor/bq274xx/bq274xx.c b/drivers/sensor/bq274xx/bq274xx.c index 329ff213898cd4..39c2e457a811f6 100644 --- a/drivers/sensor/bq274xx/bq274xx.c +++ b/drivers/sensor/bq274xx/bq274xx.c @@ -132,7 +132,8 @@ static int bq274xx_get_device_type(struct bq274xx_data *bq274xx, uint16_t *val) * * @return -ENOTSUP for unsupported channels */ -static int bq274xx_channel_get(struct device *dev, enum sensor_channel chan, +static int bq274xx_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct bq274xx_data *bq274xx = dev->data; @@ -209,7 +210,8 @@ static int bq274xx_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int bq274xx_sample_fetch(struct device *dev, enum sensor_channel chan) +static int bq274xx_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct bq274xx_data *bq274xx = dev->data; int status = 0; @@ -348,7 +350,7 @@ static int bq274xx_sample_fetch(struct device *dev, enum sensor_channel chan) * * @return 0 for success */ -static int bq274xx_gauge_init(struct device *dev) +static int bq274xx_gauge_init(const struct device *dev) { struct bq274xx_data *bq274xx = dev->data; const struct bq274xx_config *const config = dev->config; diff --git a/drivers/sensor/bq274xx/bq274xx.h b/drivers/sensor/bq274xx/bq274xx.h index 014264840f6d4c..313d00921f27a5 100644 --- a/drivers/sensor/bq274xx/bq274xx.h +++ b/drivers/sensor/bq274xx/bq274xx.h @@ -79,7 +79,7 @@ LOG_MODULE_REGISTER(bq274xx, CONFIG_SENSOR_LOG_LEVEL); #define BQ274XX_DELAY 1000 struct bq274xx_data { - struct device *i2c; + const struct device *i2c; uint16_t voltage; int16_t avg_current; int16_t stdby_current; diff --git a/drivers/sensor/ccs811/ccs811.c b/drivers/sensor/ccs811/ccs811.c index bc900e9bc71670..1f1430818616f3 100644 --- a/drivers/sensor/ccs811/ccs811.c +++ b/drivers/sensor/ccs811/ccs811.c @@ -42,7 +42,7 @@ static void set_wake(struct ccs811_data *drv_data, bool enable) * in bits 8..15. These registers are available in both boot and * application mode. */ -static int fetch_status(struct device *i2c) +static int fetch_status(const struct device *i2c) { uint8_t status; int rv; @@ -74,14 +74,14 @@ static inline uint8_t error_from_status(int status) return status >> 8; } -const struct ccs811_result_type *ccs811_result(struct device *dev) +const struct ccs811_result_type *ccs811_result(const struct device *dev) { struct ccs811_data *drv_data = dev->data; return &drv_data->result; } -int ccs811_configver_fetch(struct device *dev, +int ccs811_configver_fetch(const struct device *dev, struct ccs811_configver_type *ptr) { struct ccs811_data *drv_data = dev->data; @@ -126,7 +126,7 @@ int ccs811_configver_fetch(struct device *dev, return rc; } -int ccs811_baseline_fetch(struct device *dev) +int ccs811_baseline_fetch(const struct device *dev) { const uint8_t cmd = CCS811_REG_BASELINE; struct ccs811_data *drv_data = dev->data; @@ -146,7 +146,7 @@ int ccs811_baseline_fetch(struct device *dev) return rc; } -int ccs811_baseline_update(struct device *dev, +int ccs811_baseline_update(const struct device *dev, uint16_t baseline) { struct ccs811_data *drv_data = dev->data; @@ -161,7 +161,7 @@ int ccs811_baseline_update(struct device *dev, return rc; } -int ccs811_envdata_update(struct device *dev, +int ccs811_envdata_update(const struct device *dev, const struct sensor_value *temperature, const struct sensor_value *humidity) { @@ -229,7 +229,8 @@ int ccs811_envdata_update(struct device *dev, return rc; } -static int ccs811_sample_fetch(struct device *dev, enum sensor_channel chan) +static int ccs811_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct ccs811_data *drv_data = dev->data; struct ccs811_result_type *rp = &drv_data->result; @@ -266,7 +267,7 @@ static int ccs811_sample_fetch(struct device *dev, enum sensor_channel chan) return (status & CCS811_STATUS_DATA_READY) ? 0 : -EAGAIN; } -static int ccs811_channel_get(struct device *dev, +static int ccs811_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -322,7 +323,7 @@ static const struct sensor_driver_api ccs811_driver_api = { .channel_get = ccs811_channel_get, }; -static int switch_to_app_mode(struct device *i2c) +static int switch_to_app_mode(const struct device *i2c) { uint8_t buf; int status; @@ -372,7 +373,7 @@ static int switch_to_app_mode(struct device *i2c) #ifdef CONFIG_CCS811_TRIGGER -int ccs811_mutate_meas_mode(struct device *dev, +int ccs811_mutate_meas_mode(const struct device *dev, uint8_t set, uint8_t clear) { @@ -409,7 +410,7 @@ int ccs811_mutate_meas_mode(struct device *dev, return rc; } -int ccs811_set_thresholds(struct device *dev) +int ccs811_set_thresholds(const struct device *dev) { struct ccs811_data *drv_data = dev->data; const uint8_t buf[5] = { @@ -429,7 +430,7 @@ int ccs811_set_thresholds(struct device *dev) #endif /* CONFIG_CCS811_TRIGGER */ -static int ccs811_init(struct device *dev) +static int ccs811_init(const struct device *dev) { struct ccs811_data *drv_data = dev->data; int ret = 0; diff --git a/drivers/sensor/ccs811/ccs811.h b/drivers/sensor/ccs811/ccs811.h index 6ab98cbafbc507..1f07d79c414ed8 100644 --- a/drivers/sensor/ccs811/ccs811.h +++ b/drivers/sensor/ccs811/ccs811.h @@ -48,11 +48,11 @@ #define CCS811_CO2_MAX_PPM 32767 struct ccs811_data { - struct device *i2c; + const struct device *i2c; #if DT_INST_NODE_HAS_PROP(0, irq_gpios) - struct device *irq_gpio; + const struct device *irq_gpio; #ifdef CONFIG_CCS811_TRIGGER - struct device *dev; + const struct device *dev; /* * DATARDY is configured through SENSOR_CHAN_ALL. @@ -73,10 +73,10 @@ struct ccs811_data { #endif /* CONFIG_CCS811_TRIGGER */ #endif #if DT_INST_NODE_HAS_PROP(0, reset_gpios) - struct device *reset_gpio; + const struct device *reset_gpio; #endif #if DT_INST_NODE_HAS_PROP(0, wake_gpios) - struct device *wake_gpio; + const struct device *wake_gpio; #endif struct ccs811_result_type result; uint8_t mode; @@ -85,22 +85,22 @@ struct ccs811_data { #ifdef CONFIG_CCS811_TRIGGER -int ccs811_mutate_meas_mode(struct device *dev, +int ccs811_mutate_meas_mode(const struct device *dev, uint8_t set, uint8_t clear); -int ccs811_set_thresholds(struct device *dev); +int ccs811_set_thresholds(const struct device *dev); -int ccs811_attr_set(struct device *dev, +int ccs811_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int ccs811_trigger_set(struct device *dev, +int ccs811_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int ccs811_init_interrupt(struct device *dev); +int ccs811_init_interrupt(const struct device *dev); #endif /* CONFIG_CCS811_TRIGGER */ diff --git a/drivers/sensor/ccs811/ccs811_trigger.c b/drivers/sensor/ccs811/ccs811_trigger.c index e815614d365bd4..00c332b25ce270 100644 --- a/drivers/sensor/ccs811/ccs811_trigger.c +++ b/drivers/sensor/ccs811/ccs811_trigger.c @@ -15,7 +15,7 @@ LOG_MODULE_DECLARE(CCS811); #define IRQ_PIN DT_INST_GPIO_PIN(0, irq_gpios) -int ccs811_attr_set(struct device *dev, +int ccs811_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *thr) @@ -45,7 +45,7 @@ int ccs811_attr_set(struct device *dev, return rc; } -static inline void setup_irq(struct device *dev, +static inline void setup_irq(const struct device *dev, bool enable) { struct ccs811_data *data = dev->data; @@ -56,7 +56,7 @@ static inline void setup_irq(struct device *dev, gpio_pin_interrupt_configure(data->irq_gpio, IRQ_PIN, flags); } -static inline void handle_irq(struct device *dev) +static inline void handle_irq(const struct device *dev) { struct ccs811_data *data = dev->data; @@ -69,7 +69,7 @@ static inline void handle_irq(struct device *dev) #endif } -static void process_irq(struct device *dev) +static void process_irq(const struct device *dev) { struct ccs811_data *data = dev->data; @@ -82,7 +82,7 @@ static void process_irq(struct device *dev) } } -static void gpio_callback(struct device *dev, +static void gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { @@ -97,7 +97,7 @@ static void gpio_callback(struct device *dev, #ifdef CONFIG_CCS811_TRIGGER_OWN_THREAD static void irq_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct ccs811_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -118,7 +118,7 @@ static void work_cb(struct k_work *work) #error Unhandled trigger configuration #endif -int ccs811_trigger_set(struct device *dev, +int ccs811_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -168,7 +168,7 @@ int ccs811_trigger_set(struct device *dev, return rc; } -int ccs811_init_interrupt(struct device *dev) +int ccs811_init_interrupt(const struct device *dev) { struct ccs811_data *drv_data = dev->data; diff --git a/drivers/sensor/dht/dht.c b/drivers/sensor/dht/dht.c index 1fbf15ddf4fa5e..da5c31ddf3615e 100644 --- a/drivers/sensor/dht/dht.c +++ b/drivers/sensor/dht/dht.c @@ -28,8 +28,8 @@ LOG_MODULE_REGISTER(DHT, CONFIG_SENSOR_LOG_LEVEL); * @return duration in usec of signal being measured, * -1 if duration exceeds DHT_SIGNAL_MAX_WAIT_DURATION */ -static int8_t dht_measure_signal_duration(struct device *dev, - bool active) +static int8_t dht_measure_signal_duration(const struct device *dev, + bool active) { struct dht_data *drv_data = dev->data; const struct dht_config *cfg = dev->config; @@ -57,7 +57,8 @@ static int8_t dht_measure_signal_duration(struct device *dev, (uint64_t)sys_clock_hw_cycles_per_sec(); } -static int dht_sample_fetch(struct device *dev, enum sensor_channel chan) +static int dht_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct dht_data *drv_data = dev->data; const struct dht_config *cfg = dev->config; @@ -164,7 +165,7 @@ static int dht_sample_fetch(struct device *dev, enum sensor_channel chan) return ret; } -static int dht_channel_get(struct device *dev, +static int dht_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -221,7 +222,7 @@ static const struct sensor_driver_api dht_api = { .channel_get = &dht_channel_get, }; -static int dht_init(struct device *dev) +static int dht_init(const struct device *dev) { int rc = 0; struct dht_data *drv_data = dev->data; diff --git a/drivers/sensor/dht/dht.h b/drivers/sensor/dht/dht.h index 7064afbef5daac..a1ba6728dbcb04 100644 --- a/drivers/sensor/dht/dht.h +++ b/drivers/sensor/dht/dht.h @@ -14,7 +14,7 @@ #define DHT_DATA_BITS_NUM 40 struct dht_data { - struct device *gpio; + const struct device *gpio; uint8_t sample[4]; }; diff --git a/drivers/sensor/dps310/dps310.c b/drivers/sensor/dps310/dps310.c index d64fe34d9d46ab..9edfafdc7cc8c4 100644 --- a/drivers/sensor/dps310/dps310.c +++ b/drivers/sensor/dps310/dps310.c @@ -228,7 +228,7 @@ struct dps310_cal_coeff { }; struct dps310_data { - struct device *i2c_master; + const struct device *i2c_master; struct dps310_cal_coeff comp; /* Temperature Values */ int32_t tmp_val1; @@ -569,7 +569,7 @@ static bool dps310_measure_tmp(struct dps310_data *data, } /* Initialize the sensor and apply the configuration */ -static int dps310_init(struct device *dev) +static int dps310_init(const struct device *dev) { struct dps310_data *data = dev->data; const struct dps310_cfg *config = dev->config; @@ -661,7 +661,8 @@ static int dps310_init(struct device *dev) } /* Do a measurement and fetch the data from the sensor */ -static int dps310_sample_fetch(struct device *dev, enum sensor_channel chan) +static int dps310_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct dps310_data *data = dev->data; const struct dps310_cfg *config = dev->config; @@ -695,7 +696,8 @@ static int dps310_sample_fetch(struct device *dev, enum sensor_channel chan) } /* Get the measurement data */ -static int dps310_channel_get(struct device *dev, enum sensor_channel chan, +static int dps310_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct dps310_data *data = dev->data; diff --git a/drivers/sensor/ens210/ens210.c b/drivers/sensor/ens210/ens210.c index 72b18e1afe9ac5..29c9f95c758657 100644 --- a/drivers/sensor/ens210/ens210.c +++ b/drivers/sensor/ens210/ens210.c @@ -40,7 +40,8 @@ static uint32_t ens210_crc7(uint32_t bitstream) #if defined(CONFIG_ENS210_TEMPERATURE_SINGLE) \ || defined(CONFIG_ENS210_HUMIDITY_SINGLE) -static int ens210_measure(struct device *i2c_dev, enum sensor_channel chan) +static int ens210_measure(const struct device *i2c_dev, + enum sensor_channel chan) { uint8_t buf; int ret; @@ -78,7 +79,8 @@ static int ens210_measure(struct device *i2c_dev, enum sensor_channel chan) } #endif /* Single shot mode */ -static int ens210_sample_fetch(struct device *dev, enum sensor_channel chan) +static int ens210_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct ens210_data *drv_data = dev->data; struct ens210_value_data data[2]; @@ -157,7 +159,7 @@ static int ens210_sample_fetch(struct device *dev, enum sensor_channel chan) return -EIO; } -static int ens210_channel_get(struct device *dev, +static int ens210_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -188,7 +190,7 @@ static int ens210_channel_get(struct device *dev, return 0; } -static int ens210_sys_reset(struct device *i2c_dev) +static int ens210_sys_reset(const struct device *i2c_dev) { const struct ens210_sys_ctrl sys_ctrl = { .low_power = 0, @@ -204,7 +206,7 @@ static int ens210_sys_reset(struct device *i2c_dev) return ret; } -static int ens210_sys_enable(struct device *i2c_dev, uint8_t low_power) +static int ens210_sys_enable(const struct device *i2c_dev, uint8_t low_power) { const struct ens210_sys_ctrl sys_ctrl = { .low_power = low_power, @@ -220,7 +222,7 @@ static int ens210_sys_enable(struct device *i2c_dev, uint8_t low_power) return ret; } -static int ens210_wait_boot(struct device *i2c_dev) +static int ens210_wait_boot(const struct device *i2c_dev) { int cnt; int ret; @@ -263,7 +265,7 @@ static const struct sensor_driver_api en210_driver_api = { .channel_get = ens210_channel_get, }; -static int ens210_init(struct device *dev) +static int ens210_init(const struct device *dev) { struct ens210_data *drv_data = dev->data; const struct ens210_sens_run sense_run = { diff --git a/drivers/sensor/ens210/ens210.h b/drivers/sensor/ens210/ens210.h index 2eabe458b6d8e5..b0e1db4658e616 100644 --- a/drivers/sensor/ens210/ens210.h +++ b/drivers/sensor/ens210/ens210.h @@ -101,7 +101,7 @@ struct ens210_sens_stat { } __packed; struct ens210_data { - struct device *i2c; + const struct device *i2c; struct ens210_value_data temp; struct ens210_value_data humidity; }; diff --git a/drivers/sensor/fxas21002/fxas21002.c b/drivers/sensor/fxas21002/fxas21002.c index 93b5c99ee7833c..820093a45bc44a 100644 --- a/drivers/sensor/fxas21002/fxas21002.c +++ b/drivers/sensor/fxas21002/fxas21002.c @@ -18,7 +18,8 @@ static const uint32_t sample_period[] = { 1250, 2500, 5000, 10000, 20000, 40000, 80000, 80000 }; -static int fxas21002_sample_fetch(struct device *dev, enum sensor_channel chan) +static int fxas21002_sample_fetch(const struct device *dev, + enum sensor_channel chan) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; @@ -70,7 +71,8 @@ static void fxas21002_convert(struct sensor_value *val, int16_t raw, val->val2 = micro_rad % 1000000; } -static int fxas21002_channel_get(struct device *dev, enum sensor_channel chan, +static int fxas21002_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { const struct fxas21002_config *config = dev->config; @@ -130,7 +132,7 @@ static int fxas21002_channel_get(struct device *dev, enum sensor_channel chan, return ret; } -int fxas21002_get_power(struct device *dev, enum fxas21002_power *power) +int fxas21002_get_power(const struct device *dev, enum fxas21002_power *power) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; @@ -148,7 +150,7 @@ int fxas21002_get_power(struct device *dev, enum fxas21002_power *power) return 0; } -int fxas21002_set_power(struct device *dev, enum fxas21002_power power) +int fxas21002_set_power(const struct device *dev, enum fxas21002_power power) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; @@ -184,7 +186,7 @@ uint32_t fxas21002_get_transition_time(enum fxas21002_power start, return transition_time; } -static int fxas21002_init(struct device *dev) +static int fxas21002_init(const struct device *dev) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; diff --git a/drivers/sensor/fxas21002/fxas21002.h b/drivers/sensor/fxas21002/fxas21002.h index 7162b4daf62428..e71741e3337e64 100644 --- a/drivers/sensor/fxas21002/fxas21002.h +++ b/drivers/sensor/fxas21002/fxas21002.h @@ -70,10 +70,10 @@ struct fxas21002_config { }; struct fxas21002_data { - struct device *i2c; + const struct device *i2c; struct k_sem sem; #ifdef CONFIG_FXAS21002_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t drdy_handler; @@ -85,21 +85,21 @@ struct fxas21002_data { #endif #ifdef CONFIG_FXAS21002_TRIGGER_GLOBAL_THREAD struct k_work work; - struct device *dev; + const struct device *dev; #endif int16_t raw[FXAS21002_MAX_NUM_CHANNELS]; }; -int fxas21002_get_power(struct device *dev, enum fxas21002_power *power); -int fxas21002_set_power(struct device *dev, enum fxas21002_power power); +int fxas21002_get_power(const struct device *dev, enum fxas21002_power *power); +int fxas21002_set_power(const struct device *dev, enum fxas21002_power power); uint32_t fxas21002_get_transition_time(enum fxas21002_power start, enum fxas21002_power end, uint8_t dr); #if CONFIG_FXAS21002_TRIGGER -int fxas21002_trigger_init(struct device *dev); -int fxas21002_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler); +int fxas21002_trigger_init(const struct device *dev); +int fxas21002_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); #endif diff --git a/drivers/sensor/fxas21002/fxas21002_trigger.c b/drivers/sensor/fxas21002/fxas21002_trigger.c index d3ab977172946d..10f03e5bd079d2 100644 --- a/drivers/sensor/fxas21002/fxas21002_trigger.c +++ b/drivers/sensor/fxas21002/fxas21002_trigger.c @@ -10,9 +10,9 @@ LOG_MODULE_DECLARE(FXAS21002, CONFIG_SENSOR_LOG_LEVEL); -static void fxas21002_gpio_callback(struct device *dev, - struct gpio_callback *cb, - uint32_t pin_mask) +static void fxas21002_gpio_callback(const struct device *dev, + struct gpio_callback *cb, + uint32_t pin_mask) { struct fxas21002_data *data = CONTAINER_OF(cb, struct fxas21002_data, gpio_cb); @@ -31,7 +31,7 @@ static void fxas21002_gpio_callback(struct device *dev, #endif } -static int fxas21002_handle_drdy_int(struct device *dev) +static int fxas21002_handle_drdy_int(const struct device *dev) { struct fxas21002_data *data = dev->data; @@ -49,7 +49,7 @@ static int fxas21002_handle_drdy_int(struct device *dev) static void fxas21002_handle_int(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; uint8_t int_source; @@ -76,7 +76,7 @@ static void fxas21002_handle_int(void *arg) #ifdef CONFIG_FXAS21002_TRIGGER_OWN_THREAD static void fxas21002_thread_main(void *arg1, void *unused1, void *unused2) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct fxas21002_data *data = dev->data; ARG_UNUSED(unused1); @@ -99,9 +99,9 @@ static void fxas21002_work_handler(struct k_work *work) } #endif -int fxas21002_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) +int fxas21002_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; @@ -169,7 +169,7 @@ int fxas21002_trigger_set(struct device *dev, return ret; } -int fxas21002_trigger_init(struct device *dev) +int fxas21002_trigger_init(const struct device *dev) { const struct fxas21002_config *config = dev->config; struct fxas21002_data *data = dev->data; diff --git a/drivers/sensor/fxos8700/fxos8700.c b/drivers/sensor/fxos8700/fxos8700.c index 112e544c233f89..8a1e28557416b4 100644 --- a/drivers/sensor/fxos8700/fxos8700.c +++ b/drivers/sensor/fxos8700/fxos8700.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(FXOS8700, CONFIG_SENSOR_LOG_LEVEL); -int fxos8700_set_odr(struct device *dev, const struct sensor_value *val) +int fxos8700_set_odr(const struct device *dev, const struct sensor_value *val) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -71,7 +71,7 @@ int fxos8700_set_odr(struct device *dev, const struct sensor_value *val) FXOS8700_CTRLREG1_DR_MASK, (uint8_t)dr); } -static int fxos8700_set_mt_ths(struct device *dev, +static int fxos8700_set_mt_ths(const struct device *dev, const struct sensor_value *val) { #ifdef CONFIG_FXOS8700_MOTION @@ -95,7 +95,7 @@ static int fxos8700_set_mt_ths(struct device *dev, #endif } -static int fxos8700_attr_set(struct device *dev, +static int fxos8700_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -115,7 +115,8 @@ static int fxos8700_attr_set(struct device *dev, return 0; } -static int fxos8700_sample_fetch(struct device *dev, enum sensor_channel chan) +static int fxos8700_sample_fetch(const struct device *dev, + enum sensor_channel chan) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -231,7 +232,8 @@ static void fxos8700_temp_convert(struct sensor_value *val, int8_t raw) } #endif -static int fxos8700_channel_get(struct device *dev, enum sensor_channel chan, +static int fxos8700_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { const struct fxos8700_config *config = dev->config; @@ -339,7 +341,7 @@ static int fxos8700_channel_get(struct device *dev, enum sensor_channel chan, return ret; } -int fxos8700_get_power(struct device *dev, enum fxos8700_power *power) +int fxos8700_get_power(const struct device *dev, enum fxos8700_power *power) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -357,7 +359,7 @@ int fxos8700_get_power(struct device *dev, enum fxos8700_power *power) return 0; } -int fxos8700_set_power(struct device *dev, enum fxos8700_power power) +int fxos8700_set_power(const struct device *dev, enum fxos8700_power power) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -368,12 +370,12 @@ int fxos8700_set_power(struct device *dev, enum fxos8700_power power) power); } -static int fxos8700_init(struct device *dev) +static int fxos8700_init(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; struct sensor_value odr = {.val1 = 6, .val2 = 250000}; - struct device *rst; + const struct device *rst; /* Get the I2C device */ data->i2c = device_get_binding(config->i2c_name); diff --git a/drivers/sensor/fxos8700/fxos8700.h b/drivers/sensor/fxos8700/fxos8700.h index 8ff119147c3435..e884c6fc5f33b1 100644 --- a/drivers/sensor/fxos8700/fxos8700.h +++ b/drivers/sensor/fxos8700/fxos8700.h @@ -161,10 +161,10 @@ struct fxos8700_config { }; struct fxos8700_data { - struct device *i2c; + const struct device *i2c; struct k_sem sem; #ifdef CONFIG_FXOS8700_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t drdy_handler; @@ -186,7 +186,7 @@ struct fxos8700_data { #endif #ifdef CONFIG_FXOS8700_TRIGGER_GLOBAL_THREAD struct k_work work; - struct device *dev; + const struct device *dev; #endif int16_t raw[FXOS8700_MAX_NUM_CHANNELS]; #ifdef CONFIG_FXOS8700_TEMP @@ -195,12 +195,12 @@ struct fxos8700_data { uint8_t whoami; }; -int fxos8700_get_power(struct device *dev, enum fxos8700_power *power); -int fxos8700_set_power(struct device *dev, enum fxos8700_power power); +int fxos8700_get_power(const struct device *dev, enum fxos8700_power *power); +int fxos8700_set_power(const struct device *dev, enum fxos8700_power power); #if CONFIG_FXOS8700_TRIGGER -int fxos8700_trigger_init(struct device *dev); -int fxos8700_trigger_set(struct device *dev, +int fxos8700_trigger_init(const struct device *dev); +int fxos8700_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif diff --git a/drivers/sensor/fxos8700/fxos8700_trigger.c b/drivers/sensor/fxos8700/fxos8700_trigger.c index eb1892f20033cd..8da989c19df360 100644 --- a/drivers/sensor/fxos8700/fxos8700_trigger.c +++ b/drivers/sensor/fxos8700/fxos8700_trigger.c @@ -10,7 +10,7 @@ LOG_MODULE_DECLARE(FXOS8700, CONFIG_SENSOR_LOG_LEVEL); -static void fxos8700_gpio_callback(struct device *dev, +static void fxos8700_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pin_mask) { @@ -31,7 +31,7 @@ static void fxos8700_gpio_callback(struct device *dev, #endif } -static int fxos8700_handle_drdy_int(struct device *dev) +static int fxos8700_handle_drdy_int(const struct device *dev) { struct fxos8700_data *data = dev->data; @@ -48,7 +48,7 @@ static int fxos8700_handle_drdy_int(struct device *dev) } #ifdef CONFIG_FXOS8700_PULSE -static int fxos8700_handle_pulse_int(struct device *dev) +static int fxos8700_handle_pulse_int(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -86,7 +86,7 @@ static int fxos8700_handle_pulse_int(struct device *dev) #endif #ifdef CONFIG_FXOS8700_MOTION -static int fxos8700_handle_motion_int(struct device *dev) +static int fxos8700_handle_motion_int(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -117,7 +117,7 @@ static int fxos8700_handle_motion_int(struct device *dev) #endif #ifdef CONFIG_FXOS8700_MAG_VECM -static int fxos8700_handle_m_vecm_int(struct device *dev) +static int fxos8700_handle_m_vecm_int(const struct device *dev) { struct fxos8700_data *data = dev->driver_data; @@ -136,7 +136,7 @@ static int fxos8700_handle_m_vecm_int(struct device *dev) static void fxos8700_handle_int(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; uint8_t int_source; @@ -191,7 +191,7 @@ static void fxos8700_handle_int(void *arg) #ifdef CONFIG_FXOS8700_TRIGGER_OWN_THREAD static void fxos8700_thread_main(void *arg1, void *unused1, void *unused2) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; struct fxos8700_data *data = dev->data; ARG_UNUSED(unused1); @@ -214,7 +214,7 @@ static void fxos8700_work_handler(struct k_work *work) } #endif -int fxos8700_trigger_set(struct device *dev, +int fxos8700_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -300,7 +300,7 @@ int fxos8700_trigger_set(struct device *dev, } #ifdef CONFIG_FXOS8700_PULSE -static int fxos8700_pulse_init(struct device *dev) +static int fxos8700_pulse_init(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -345,7 +345,7 @@ static int fxos8700_pulse_init(struct device *dev) #endif #ifdef CONFIG_FXOS8700_MOTION -static int fxos8700_motion_init(struct device *dev) +static int fxos8700_motion_init(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; @@ -373,7 +373,7 @@ static int fxos8700_motion_init(struct device *dev) #endif #ifdef CONFIG_FXOS8700_MAG_VECM -static int fxos8700_m_vecm_init(struct device *dev) +static int fxos8700_m_vecm_init(const struct device *dev) { const struct fxos8700_config *config = dev->config_info; struct fxos8700_data *data = dev->driver_data; @@ -410,7 +410,7 @@ static int fxos8700_m_vecm_init(struct device *dev) } #endif -int fxos8700_trigger_init(struct device *dev) +int fxos8700_trigger_init(const struct device *dev) { const struct fxos8700_config *config = dev->config; struct fxos8700_data *data = dev->data; diff --git a/drivers/sensor/grove/light_sensor.c b/drivers/sensor/grove/light_sensor.c index f9ffacfbe819a7..fe1e3439f52065 100644 --- a/drivers/sensor/grove/light_sensor.c +++ b/drivers/sensor/grove/light_sensor.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(grove_light, CONFIG_SENSOR_LOG_LEVEL); struct gls_data { - struct device *adc; + const struct device *adc; struct adc_channel_cfg ch_cfg; uint16_t raw; }; @@ -47,14 +47,15 @@ static struct adc_sequence adc_table = { .options = &options, }; -static int gls_sample_fetch(struct device *dev, enum sensor_channel chan) +static int gls_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct gls_data *drv_data = dev->data; return adc_read(drv_data->adc, &adc_table); } -static int gls_channel_get(struct device *dev, +static int gls_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -81,7 +82,7 @@ static const struct sensor_driver_api gls_api = { .channel_get = &gls_channel_get, }; -static int gls_init(struct device *dev) +static int gls_init(const struct device *dev) { struct gls_data *drv_data = dev->data; const struct gls_config *cfg = dev->config; diff --git a/drivers/sensor/grove/temperature_sensor.c b/drivers/sensor/grove/temperature_sensor.c index 920453817419d7..e281e61861f90d 100644 --- a/drivers/sensor/grove/temperature_sensor.c +++ b/drivers/sensor/grove/temperature_sensor.c @@ -27,7 +27,7 @@ LOG_MODULE_REGISTER(grove_temp, CONFIG_SENSOR_LOG_LEVEL); #endif struct gts_data { - struct device *adc; + const struct device *adc; struct adc_channel_cfg ch_cfg; uint16_t raw; }; @@ -47,14 +47,15 @@ static struct adc_sequence adc_table = { .options = &options, }; -static int gts_sample_fetch(struct device *dev, enum sensor_channel chan) +static int gts_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct gts_data *drv_data = dev->data; return adc_read(drv_data->adc, &adc_table); } -static int gts_channel_get(struct device *dev, +static int gts_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -84,7 +85,7 @@ static const struct sensor_driver_api gts_api = { .channel_get = >s_channel_get, }; -static int gts_init(struct device *dev) +static int gts_init(const struct device *dev) { struct gts_data *drv_data = dev->data; const struct gts_config *cfg = dev->config; diff --git a/drivers/sensor/hmc5883l/hmc5883l.c b/drivers/sensor/hmc5883l/hmc5883l.c index b5cb1f76beddcd..c67c090df4b3b4 100644 --- a/drivers/sensor/hmc5883l/hmc5883l.c +++ b/drivers/sensor/hmc5883l/hmc5883l.c @@ -26,7 +26,7 @@ static void hmc5883l_convert(struct sensor_value *val, int16_t raw_val, val->val2 = (((int64_t)raw_val % divider) * 1000000L) / divider; } -static int hmc5883l_channel_get(struct device *dev, +static int hmc5883l_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -53,7 +53,8 @@ static int hmc5883l_channel_get(struct device *dev, return 0; } -static int hmc5883l_sample_fetch(struct device *dev, enum sensor_channel chan) +static int hmc5883l_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct hmc5883l_data *drv_data = dev->data; int16_t buf[3]; @@ -83,7 +84,7 @@ static const struct sensor_driver_api hmc5883l_driver_api = { .channel_get = hmc5883l_channel_get, }; -int hmc5883l_init(struct device *dev) +int hmc5883l_init(const struct device *dev) { struct hmc5883l_data *drv_data = dev->data; uint8_t chip_cfg[3], id[3], idx; diff --git a/drivers/sensor/hmc5883l/hmc5883l.h b/drivers/sensor/hmc5883l/hmc5883l.h index 09290735a8cc70..ba7b2762d08af2 100644 --- a/drivers/sensor/hmc5883l/hmc5883l.h +++ b/drivers/sensor/hmc5883l/hmc5883l.h @@ -41,14 +41,14 @@ static const uint16_t hmc5883l_gain[] = { }; struct hmc5883l_data { - struct device *i2c; + const struct device *i2c; int16_t x_sample; int16_t y_sample; int16_t z_sample; uint8_t gain_idx; #ifdef CONFIG_HMC5883L_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; @@ -60,18 +60,18 @@ struct hmc5883l_data { struct k_sem gpio_sem; #elif defined(CONFIG_HMC5883L_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_HMC5883L_TRIGGER */ }; #ifdef CONFIG_HMC5883L_TRIGGER -int hmc5883l_trigger_set(struct device *dev, +int hmc5883l_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int hmc5883l_init_interrupt(struct device *dev); +int hmc5883l_init_interrupt(const struct device *dev); #endif #endif /* __SENSOR_HMC5883L__ */ diff --git a/drivers/sensor/hmc5883l/hmc5883l_trigger.c b/drivers/sensor/hmc5883l/hmc5883l_trigger.c index a466a14e80c39d..9f78536360f5f4 100644 --- a/drivers/sensor/hmc5883l/hmc5883l_trigger.c +++ b/drivers/sensor/hmc5883l/hmc5883l_trigger.c @@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(HMC5883L, CONFIG_SENSOR_LOG_LEVEL); -int hmc5883l_trigger_set(struct device *dev, +int hmc5883l_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -43,7 +43,7 @@ int hmc5883l_trigger_set(struct device *dev, return 0; } -static void hmc5883l_gpio_callback(struct device *dev, +static void hmc5883l_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct hmc5883l_data *drv_data = @@ -64,7 +64,7 @@ static void hmc5883l_gpio_callback(struct device *dev, static void hmc5883l_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct hmc5883l_data *drv_data = dev->data; if (drv_data->data_ready_handler != NULL) { @@ -80,7 +80,7 @@ static void hmc5883l_thread_cb(void *arg) #ifdef CONFIG_HMC5883L_TRIGGER_OWN_THREAD static void hmc5883l_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct hmc5883l_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -102,7 +102,7 @@ static void hmc5883l_work_cb(struct k_work *work) } #endif -int hmc5883l_init_interrupt(struct device *dev) +int hmc5883l_init_interrupt(const struct device *dev) { struct hmc5883l_data *drv_data = dev->data; diff --git a/drivers/sensor/hp206c/hp206c.c b/drivers/sensor/hp206c/hp206c.c index 48990df6051d64..657dd0a69373b0 100644 --- a/drivers/sensor/hp206c/hp206c.c +++ b/drivers/sensor/hp206c/hp206c.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(HP206C, CONFIG_SENSOR_LOG_LEVEL); -static inline int hp206c_bus_config(struct device *dev) +static inline int hp206c_bus_config(const struct device *dev) { struct hp206c_device_data *hp206c = dev->data; uint32_t i2c_cfg; @@ -32,7 +32,7 @@ static inline int hp206c_bus_config(struct device *dev) return i2c_configure(hp206c->i2c, i2c_cfg); } -static int hp206c_read(struct device *dev, uint8_t cmd, uint8_t *data, +static int hp206c_read(const struct device *dev, uint8_t cmd, uint8_t *data, uint8_t len) { struct hp206c_device_data *hp206c = dev->data; @@ -47,7 +47,7 @@ static int hp206c_read(struct device *dev, uint8_t cmd, uint8_t *data, return 0; } -static int hp206c_read_reg(struct device *dev, uint8_t reg_addr, +static int hp206c_read_reg(const struct device *dev, uint8_t reg_addr, uint8_t *reg_val) { uint8_t cmd = HP206C_CMD_READ_REG | (reg_addr & HP206C_REG_ADDR_MASK); @@ -55,7 +55,7 @@ static int hp206c_read_reg(struct device *dev, uint8_t reg_addr, return hp206c_read(dev, cmd, reg_val, 1); } -static int hp206c_write(struct device *dev, uint8_t cmd, uint8_t *data, +static int hp206c_write(const struct device *dev, uint8_t cmd, uint8_t *data, uint8_t len) { struct hp206c_device_data *hp206c = dev->data; @@ -70,7 +70,7 @@ static int hp206c_write(struct device *dev, uint8_t cmd, uint8_t *data, return 0; } -static int hp206c_write_reg(struct device *dev, uint8_t reg_addr, +static int hp206c_write_reg(const struct device *dev, uint8_t reg_addr, uint8_t reg_val) { uint8_t cmd = HP206C_CMD_WRITE_REG | (reg_addr & HP206C_REG_ADDR_MASK); @@ -78,7 +78,7 @@ static int hp206c_write_reg(struct device *dev, uint8_t reg_addr, return hp206c_write(dev, cmd, ®_val, 1); } -static int hp206c_cmd_send(struct device *dev, uint8_t cmd) +static int hp206c_cmd_send(const struct device *dev, uint8_t cmd) { struct hp206c_device_data *hp206c = dev->data; @@ -104,7 +104,7 @@ static uint8_t hp206c_adc_time_ms[] = { 5, /* 128 */ }; -static int hp206c_osr_set(struct device *dev, uint16_t osr) +static int hp206c_osr_set(const struct device *dev, uint16_t osr) { struct hp206c_device_data *hp206c = dev->data; uint8_t i; @@ -122,7 +122,7 @@ static int hp206c_osr_set(struct device *dev, uint16_t osr) return 0; } -static int hp206c_altitude_offs_set(struct device *dev, int16_t offs) +static int hp206c_altitude_offs_set(const struct device *dev, int16_t offs) { uint8_t reg_val; @@ -141,7 +141,7 @@ static int hp206c_altitude_offs_set(struct device *dev, int16_t offs) return hp206c_write_reg(dev, HP206C_REG_PARA, HP206C_COMPENSATION_EN); } -static int hp206c_attr_set(struct device *dev, enum sensor_channel chan, +static int hp206c_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -163,7 +163,8 @@ static int hp206c_attr_set(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int hp206c_wait_dev_ready(struct device *dev, uint32_t timeout_ms) +static int hp206c_wait_dev_ready(const struct device *dev, + uint32_t timeout_ms) { struct hp206c_device_data *hp206c = dev->data; uint8_t int_src; @@ -182,7 +183,8 @@ static int hp206c_wait_dev_ready(struct device *dev, uint32_t timeout_ms) return -EBUSY; } -static int hp206c_adc_acquire(struct device *dev, enum sensor_channel chan) +static int hp206c_adc_acquire(const struct device *dev, + enum sensor_channel chan) { struct hp206c_device_data *hp206c = dev->data; @@ -206,7 +208,7 @@ static int32_t hp206c_buf_convert(uint8_t *buf, bool signed_val) return tmp; } -static int hp206c_val_get(struct device *dev, +static int hp206c_val_get(const struct device *dev, uint8_t cmd, struct sensor_value *val) { uint8_t buf[3]; @@ -237,25 +239,25 @@ static int hp206c_val_get(struct device *dev, return 0; } -static inline int hp206c_pressure_get(struct device *dev, +static inline int hp206c_pressure_get(const struct device *dev, struct sensor_value *val) { return hp206c_val_get(dev, HP206C_CMD_READ_P, val); } -static inline int hp206c_altitude_get(struct device *dev, +static inline int hp206c_altitude_get(const struct device *dev, struct sensor_value *val) { return hp206c_val_get(dev, HP206C_CMD_READ_A, val); } -static inline int hp206c_temperature_get(struct device *dev, +static inline int hp206c_temperature_get(const struct device *dev, struct sensor_value *val) { return hp206c_val_get(dev, HP206C_CMD_READ_T, val); } -static int hp206c_channel_get(struct device *dev, +static int hp206c_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -282,7 +284,7 @@ static const struct sensor_driver_api hp206c_api = { .channel_get = hp206c_channel_get, }; -static int hp206c_init(struct device *dev) +static int hp206c_init(const struct device *dev) { struct hp206c_device_data *hp206c = dev->data; diff --git a/drivers/sensor/hp206c/hp206c.h b/drivers/sensor/hp206c/hp206c.h index 62096b888960ce..bcbbf2770ca728 100644 --- a/drivers/sensor/hp206c/hp206c.h +++ b/drivers/sensor/hp206c/hp206c.h @@ -73,7 +73,7 @@ /* end of default settings */ struct hp206c_device_data { - struct device *i2c; + const struct device *i2c; #if CONFIG_SYS_CLOCK_TICKS_PER_SEC < 1000 #error "driver needs millisecond tick granularity" #endif diff --git a/drivers/sensor/hts221/hts221.c b/drivers/sensor/hts221/hts221.c index 7705825adc654c..3e46b5eb51bb5b 100644 --- a/drivers/sensor/hts221/hts221.c +++ b/drivers/sensor/hts221/hts221.c @@ -22,7 +22,7 @@ static const char * const hts221_odr_strings[] = { "1", "7", "12.5" }; -static int hts221_channel_get(struct device *dev, +static int hts221_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -58,7 +58,8 @@ static int hts221_channel_get(struct device *dev, return 0; } -static int hts221_sample_fetch(struct device *dev, enum sensor_channel chan) +static int hts221_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct hts221_data *data = dev->data; const struct hts221_config *cfg = dev->config; @@ -79,7 +80,7 @@ static int hts221_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int hts221_read_conversion_data(struct device *dev) +static int hts221_read_conversion_data(const struct device *dev) { struct hts221_data *data = dev->data; const struct hts221_config *cfg = dev->config; @@ -112,7 +113,7 @@ static const struct sensor_driver_api hts221_driver_api = { .channel_get = hts221_channel_get, }; -int hts221_init(struct device *dev) +int hts221_init(const struct device *dev) { const struct hts221_config *cfg = dev->config; struct hts221_data *data = dev->data; diff --git a/drivers/sensor/hts221/hts221.h b/drivers/sensor/hts221/hts221.h index 663314415f645f..68a7a052abed77 100644 --- a/drivers/sensor/hts221/hts221.h +++ b/drivers/sensor/hts221/hts221.h @@ -29,7 +29,7 @@ #define HTS221_REG_CONVERSION_START 0x30 struct hts221_data { - struct device *i2c; + const struct device *i2c; int16_t rh_sample; int16_t t_sample; @@ -43,8 +43,8 @@ struct hts221_data { int16_t t1_out; #ifdef CONFIG_HTS221_TRIGGER - struct device *dev; - struct device *drdy_dev; + const struct device *dev; + const struct device *drdy_dev; struct gpio_callback drdy_cb; struct sensor_trigger data_ready_trigger; @@ -72,11 +72,11 @@ struct hts221_config { }; #ifdef CONFIG_HTS221_TRIGGER -int hts221_trigger_set(struct device *dev, +int hts221_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int hts221_init_interrupt(struct device *dev); +int hts221_init_interrupt(const struct device *dev); #endif #endif /* __SENSOR_HTS221__ */ diff --git a/drivers/sensor/hts221/hts221_trigger.c b/drivers/sensor/hts221/hts221_trigger.c index 14081a7796477e..e5dae17c19472f 100644 --- a/drivers/sensor/hts221/hts221_trigger.c +++ b/drivers/sensor/hts221/hts221_trigger.c @@ -15,7 +15,7 @@ LOG_MODULE_DECLARE(HTS221, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_drdy(struct device *dev, +static inline void setup_drdy(const struct device *dev, bool enable) { struct hts221_data *data = dev->data; @@ -27,7 +27,7 @@ static inline void setup_drdy(struct device *dev, gpio_pin_interrupt_configure(data->drdy_dev, cfg->drdy_pin, flags); } -static inline void handle_drdy(struct device *dev) +static inline void handle_drdy(const struct device *dev) { struct hts221_data *data = dev->data; @@ -40,7 +40,7 @@ static inline void handle_drdy(struct device *dev) #endif } -static void process_drdy(struct device *dev) +static void process_drdy(const struct device *dev) { struct hts221_data *data = dev->data; @@ -53,7 +53,7 @@ static void process_drdy(struct device *dev) } } -int hts221_trigger_set(struct device *dev, +int hts221_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -83,7 +83,7 @@ int hts221_trigger_set(struct device *dev, return 0; } -static void hts221_drdy_callback(struct device *dev, +static void hts221_drdy_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct hts221_data *data = @@ -97,7 +97,7 @@ static void hts221_drdy_callback(struct device *dev, #ifdef CONFIG_HTS221_TRIGGER_OWN_THREAD static void hts221_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct hts221_data *data = dev->data; ARG_UNUSED(unused); @@ -119,7 +119,7 @@ static void hts221_work_cb(struct k_work *work) } #endif -int hts221_init_interrupt(struct device *dev) +int hts221_init_interrupt(const struct device *dev) { struct hts221_data *data = dev->data; const struct hts221_config *cfg = dev->config; diff --git a/drivers/sensor/iis2dh/iis2dh.c b/drivers/sensor/iis2dh/iis2dh.c index db7f3f5df62642..25b8ef5d76d55f 100644 --- a/drivers/sensor/iis2dh/iis2dh.c +++ b/drivers/sensor/iis2dh/iis2dh.c @@ -71,7 +71,7 @@ static int iis2dh_set_fs_raw(struct iis2dh_data *iis2dh, uint8_t fs) * @dev: Pointer to instance of struct device (I2C or SPI) * @range: Full scale range (2, 4, 8 and 16 G) */ -static int iis2dh_set_range(struct device *dev, uint16_t range) +static int iis2dh_set_range(const struct device *dev, uint16_t range) { int err; struct iis2dh_data *iis2dh = dev->data; @@ -89,7 +89,7 @@ static int iis2dh_set_range(struct device *dev, uint16_t range) * @dev: Pointer to instance of struct device (I2C or SPI) * @odr: Output data rate */ -static int iis2dh_set_odr(struct device *dev, uint16_t odr) +static int iis2dh_set_odr(const struct device *dev, uint16_t odr) { struct iis2dh_data *iis2dh = dev->data; const struct iis2dh_device_config *cfg = dev->config; @@ -113,7 +113,7 @@ static inline void iis2dh_convert(struct sensor_value *val, int raw_val, val->val2 = dval % 1000000LL; } -static inline void iis2dh_channel_get_acc(struct device *dev, +static inline void iis2dh_channel_get_acc(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -142,7 +142,7 @@ static inline void iis2dh_channel_get_acc(struct device *dev, } } -static int iis2dh_channel_get(struct device *dev, +static int iis2dh_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -161,7 +161,7 @@ static int iis2dh_channel_get(struct device *dev, return -ENOTSUP; } -static int iis2dh_config(struct device *dev, enum sensor_channel chan, +static int iis2dh_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -182,7 +182,7 @@ static int iis2dh_config(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int iis2dh_attr_set(struct device *dev, enum sensor_channel chan, +static int iis2dh_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -200,7 +200,8 @@ static int iis2dh_attr_set(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int iis2dh_sample_fetch(struct device *dev, enum sensor_channel chan) +static int iis2dh_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct iis2dh_data *iis2dh = dev->data; union axis3bit16_t buf; @@ -227,7 +228,7 @@ static const struct sensor_driver_api iis2dh_driver_api = { .channel_get = iis2dh_channel_get, }; -static int iis2dh_init_interface(struct device *dev) +static int iis2dh_init_interface(const struct device *dev) { struct iis2dh_data *iis2dh = dev->data; const struct iis2dh_device_config *cfg = dev->config; @@ -249,7 +250,7 @@ static int iis2dh_init_interface(struct device *dev) return 0; } -static int iis2dh_init(struct device *dev) +static int iis2dh_init(const struct device *dev) { struct iis2dh_data *iis2dh = dev->data; const struct iis2dh_device_config *cfg = dev->config; diff --git a/drivers/sensor/iis2dh/iis2dh.h b/drivers/sensor/iis2dh/iis2dh.h index 85a9229ff9dd81..b28b740c5efa33 100644 --- a/drivers/sensor/iis2dh/iis2dh.h +++ b/drivers/sensor/iis2dh/iis2dh.h @@ -58,13 +58,13 @@ struct iis2dh_device_config { /* sensor data */ struct iis2dh_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; uint32_t gain; stmdev_ctx_t *ctx; #ifdef CONFIG_IIS2DH_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t drdy_handler; @@ -74,7 +74,7 @@ struct iis2dh_data { struct k_sem gpio_sem; #elif defined(CONFIG_IIS2DH_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif /* CONFIG_IIS2DH_TRIGGER_GLOBAL_THREAD */ #endif /* CONFIG_IIS2DH_TRIGGER */ #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) @@ -82,12 +82,12 @@ struct iis2dh_data { #endif }; -int iis2dh_i2c_init(struct device *dev); -int iis2dh_spi_init(struct device *dev); +int iis2dh_i2c_init(const struct device *dev); +int iis2dh_spi_init(const struct device *dev); #ifdef CONFIG_IIS2DH_TRIGGER -int iis2dh_init_interrupt(struct device *dev); -int iis2dh_trigger_set(struct device *dev, +int iis2dh_init_interrupt(const struct device *dev); +int iis2dh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_IIS2DH_TRIGGER */ diff --git a/drivers/sensor/iis2dh/iis2dh_i2c.c b/drivers/sensor/iis2dh/iis2dh_i2c.c index c0145fafb932ec..f68556d2e09f52 100644 --- a/drivers/sensor/iis2dh/iis2dh_i2c.c +++ b/drivers/sensor/iis2dh/iis2dh_i2c.c @@ -41,7 +41,7 @@ stmdev_ctx_t iis2dh_i2c_ctx = { .write_reg = (stmdev_write_ptr) iis2dh_i2c_write, }; -int iis2dh_i2c_init(struct device *dev) +int iis2dh_i2c_init(const struct device *dev) { struct iis2dh_data *data = dev->data; diff --git a/drivers/sensor/iis2dh/iis2dh_spi.c b/drivers/sensor/iis2dh/iis2dh_spi.c index 1819a0080c6f1b..450768e6e41243 100644 --- a/drivers/sensor/iis2dh/iis2dh_spi.c +++ b/drivers/sensor/iis2dh/iis2dh_spi.c @@ -97,7 +97,7 @@ stmdev_ctx_t iis2dh_spi_ctx = { .write_reg = (stmdev_write_ptr) iis2dh_spi_write, }; -int iis2dh_spi_init(struct device *dev) +int iis2dh_spi_init(const struct device *dev) { struct iis2dh_data *data = dev->data; diff --git a/drivers/sensor/iis2dh/iis2dh_trigger.c b/drivers/sensor/iis2dh/iis2dh_trigger.c index fd3ecf1f3d7171..f1681bb1e6d792 100644 --- a/drivers/sensor/iis2dh/iis2dh_trigger.c +++ b/drivers/sensor/iis2dh/iis2dh_trigger.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(IIS2DH, CONFIG_SENSOR_LOG_LEVEL); /** * iis2dh_enable_int - enable selected int pin to generate interrupt */ -static int iis2dh_enable_drdy(struct device *dev, +static int iis2dh_enable_drdy(const struct device *dev, enum sensor_trigger_type type, int enable) { struct iis2dh_data *iis2dh = dev->data; @@ -37,7 +37,7 @@ static int iis2dh_enable_drdy(struct device *dev, /** * iis2dh_trigger_set - link external trigger to event data ready */ -int iis2dh_trigger_set(struct device *dev, +int iis2dh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -59,7 +59,7 @@ int iis2dh_trigger_set(struct device *dev, } } -static int iis2dh_handle_drdy_int(struct device *dev) +static int iis2dh_handle_drdy_int(const struct device *dev) { struct iis2dh_data *data = dev->data; @@ -81,7 +81,7 @@ static int iis2dh_handle_drdy_int(struct device *dev) */ static void iis2dh_handle_interrupt(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct iis2dh_data *iis2dh = dev->data; const struct iis2dh_device_config *cfg = dev->config; @@ -91,7 +91,7 @@ static void iis2dh_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void iis2dh_gpio_callback(struct device *dev, +static void iis2dh_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct iis2dh_data *iis2dh = @@ -114,7 +114,7 @@ static void iis2dh_gpio_callback(struct device *dev, #ifdef CONFIG_IIS2DH_TRIGGER_OWN_THREAD static void iis2dh_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct iis2dh_data *iis2dh = dev->data; ARG_UNUSED(unused); @@ -136,7 +136,7 @@ static void iis2dh_work_cb(struct k_work *work) } #endif /* CONFIG_IIS2DH_TRIGGER_GLOBAL_THREAD */ -int iis2dh_init_interrupt(struct device *dev) +int iis2dh_init_interrupt(const struct device *dev) { struct iis2dh_data *iis2dh = dev->data; const struct iis2dh_device_config *cfg = dev->config; diff --git a/drivers/sensor/iis2dlpc/iis2dlpc.c b/drivers/sensor/iis2dlpc/iis2dlpc.c index 0dbff40ce9ad3a..841ec3ba84d721 100644 --- a/drivers/sensor/iis2dlpc/iis2dlpc.c +++ b/drivers/sensor/iis2dlpc/iis2dlpc.c @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(IIS2DLPC, CONFIG_SENSOR_LOG_LEVEL); * @dev: Pointer to instance of struct device (I2C or SPI) * @range: Full scale range (2, 4, 8 and 16 G) */ -static int iis2dlpc_set_range(struct device *dev, uint16_t range) +static int iis2dlpc_set_range(const struct device *dev, uint16_t range) { int err; struct iis2dlpc_data *iis2dlpc = dev->data; @@ -60,7 +60,7 @@ static int iis2dlpc_set_range(struct device *dev, uint16_t range) * @dev: Pointer to instance of struct device (I2C or SPI) * @odr: Output data rate */ -static int iis2dlpc_set_odr(struct device *dev, uint16_t odr) +static int iis2dlpc_set_odr(const struct device *dev, uint16_t odr) { struct iis2dlpc_data *iis2dlpc = dev->data; uint8_t val; @@ -92,7 +92,7 @@ static inline void iis2dlpc_convert(struct sensor_value *val, int raw_val, val->val2 = dval % 1000000LL; } -static inline void iis2dlpc_channel_get_acc(struct device *dev, +static inline void iis2dlpc_channel_get_acc(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -121,7 +121,7 @@ static inline void iis2dlpc_channel_get_acc(struct device *dev, } } -static int iis2dlpc_channel_get(struct device *dev, +static int iis2dlpc_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -140,7 +140,7 @@ static int iis2dlpc_channel_get(struct device *dev, return -ENOTSUP; } -static int iis2dlpc_config(struct device *dev, enum sensor_channel chan, +static int iis2dlpc_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -157,7 +157,8 @@ static int iis2dlpc_config(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int iis2dlpc_attr_set(struct device *dev, enum sensor_channel chan, +static int iis2dlpc_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -175,7 +176,8 @@ static int iis2dlpc_attr_set(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int iis2dlpc_sample_fetch(struct device *dev, enum sensor_channel chan) +static int iis2dlpc_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct iis2dlpc_data *iis2dlpc = dev->data; const struct iis2dlpc_device_config *cfg = dev->config; @@ -211,7 +213,7 @@ static const struct sensor_driver_api iis2dlpc_driver_api = { .channel_get = iis2dlpc_channel_get, }; -static int iis2dlpc_init_interface(struct device *dev) +static int iis2dlpc_init_interface(const struct device *dev) { struct iis2dlpc_data *iis2dlpc = dev->data; const struct iis2dlpc_device_config *cfg = dev->config; @@ -253,7 +255,7 @@ static int iis2dlpc_set_power_mode(struct iis2dlpc_data *iis2dlpc, return iis2dlpc_write_reg(iis2dlpc->ctx, IIS2DLPC_CTRL1, ®val, 1); } -static int iis2dlpc_init(struct device *dev) +static int iis2dlpc_init(const struct device *dev) { struct iis2dlpc_data *iis2dlpc = dev->data; const struct iis2dlpc_device_config *cfg = dev->config; diff --git a/drivers/sensor/iis2dlpc/iis2dlpc.h b/drivers/sensor/iis2dlpc/iis2dlpc.h index 918e11138496e1..394061812bcc78 100644 --- a/drivers/sensor/iis2dlpc/iis2dlpc.h +++ b/drivers/sensor/iis2dlpc/iis2dlpc.h @@ -106,7 +106,7 @@ struct iis2dlpc_device_config { /* sensor data */ struct iis2dlpc_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; /* save sensitivity */ @@ -114,7 +114,7 @@ struct iis2dlpc_data { stmdev_ctx_t *ctx; #ifdef CONFIG_IIS2DLPC_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t drdy_handler; @@ -128,7 +128,7 @@ struct iis2dlpc_data { struct k_sem gpio_sem; #elif defined(CONFIG_IIS2DLPC_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif /* CONFIG_IIS2DLPC_TRIGGER_GLOBAL_THREAD */ #endif /* CONFIG_IIS2DLPC_TRIGGER */ #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) @@ -136,12 +136,12 @@ struct iis2dlpc_data { #endif }; -int iis2dlpc_i2c_init(struct device *dev); -int iis2dlpc_spi_init(struct device *dev); +int iis2dlpc_i2c_init(const struct device *dev); +int iis2dlpc_spi_init(const struct device *dev); #ifdef CONFIG_IIS2DLPC_TRIGGER -int iis2dlpc_init_interrupt(struct device *dev); -int iis2dlpc_trigger_set(struct device *dev, +int iis2dlpc_init_interrupt(const struct device *dev); +int iis2dlpc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_IIS2DLPC_TRIGGER */ diff --git a/drivers/sensor/iis2dlpc/iis2dlpc_i2c.c b/drivers/sensor/iis2dlpc/iis2dlpc_i2c.c index e24abbbdd48ac6..5f75760a3c2d9d 100644 --- a/drivers/sensor/iis2dlpc/iis2dlpc_i2c.c +++ b/drivers/sensor/iis2dlpc/iis2dlpc_i2c.c @@ -41,7 +41,7 @@ stmdev_ctx_t iis2dlpc_i2c_ctx = { .write_reg = (stmdev_write_ptr) iis2dlpc_i2c_write, }; -int iis2dlpc_i2c_init(struct device *dev) +int iis2dlpc_i2c_init(const struct device *dev) { struct iis2dlpc_data *data = dev->data; diff --git a/drivers/sensor/iis2dlpc/iis2dlpc_spi.c b/drivers/sensor/iis2dlpc/iis2dlpc_spi.c index 826b5135572b98..a90265fdaaaf45 100644 --- a/drivers/sensor/iis2dlpc/iis2dlpc_spi.c +++ b/drivers/sensor/iis2dlpc/iis2dlpc_spi.c @@ -97,7 +97,7 @@ stmdev_ctx_t iis2dlpc_spi_ctx = { .write_reg = (stmdev_write_ptr) iis2dlpc_spi_write, }; -int iis2dlpc_spi_init(struct device *dev) +int iis2dlpc_spi_init(const struct device *dev) { struct iis2dlpc_data *data = dev->data; diff --git a/drivers/sensor/iis2dlpc/iis2dlpc_trigger.c b/drivers/sensor/iis2dlpc/iis2dlpc_trigger.c index e0529af5e3a4e0..d562544960447b 100644 --- a/drivers/sensor/iis2dlpc/iis2dlpc_trigger.c +++ b/drivers/sensor/iis2dlpc/iis2dlpc_trigger.c @@ -22,7 +22,7 @@ LOG_MODULE_DECLARE(IIS2DLPC, CONFIG_SENSOR_LOG_LEVEL); /** * iis2dlpc_enable_int - enable selected int pin to generate interrupt */ -static int iis2dlpc_enable_int(struct device *dev, +static int iis2dlpc_enable_int(const struct device *dev, enum sensor_trigger_type type, int enable) { const struct iis2dlpc_device_config *cfg = dev->config; @@ -75,7 +75,7 @@ static int iis2dlpc_enable_int(struct device *dev, /** * iis2dlpc_trigger_set - link external trigger to event data ready */ -int iis2dlpc_trigger_set(struct device *dev, +int iis2dlpc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -105,7 +105,7 @@ int iis2dlpc_trigger_set(struct device *dev, } } -static int iis2dlpc_handle_drdy_int(struct device *dev) +static int iis2dlpc_handle_drdy_int(const struct device *dev) { struct iis2dlpc_data *data = dev->data; @@ -122,7 +122,7 @@ static int iis2dlpc_handle_drdy_int(struct device *dev) } #ifdef CONFIG_IIS2DLPC_PULSE -static int iis2dlpc_handle_single_tap_int(struct device *dev) +static int iis2dlpc_handle_single_tap_int(const struct device *dev) { struct iis2dlpc_data *data = dev->data; sensor_trigger_handler_t handler = data->tap_handler; @@ -139,7 +139,7 @@ static int iis2dlpc_handle_single_tap_int(struct device *dev) return 0; } -static int iis2dlpc_handle_double_tap_int(struct device *dev) +static int iis2dlpc_handle_double_tap_int(const struct device *dev) { struct iis2dlpc_data *data = dev->data; sensor_trigger_handler_t handler = data->double_tap_handler; @@ -163,7 +163,7 @@ static int iis2dlpc_handle_double_tap_int(struct device *dev) */ static void iis2dlpc_handle_interrupt(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct iis2dlpc_data *iis2dlpc = dev->data; const struct iis2dlpc_device_config *cfg = dev->config; iis2dlpc_all_sources_t sources; @@ -186,7 +186,7 @@ static void iis2dlpc_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void iis2dlpc_gpio_callback(struct device *dev, +static void iis2dlpc_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct iis2dlpc_data *iis2dlpc = @@ -209,7 +209,7 @@ static void iis2dlpc_gpio_callback(struct device *dev, #ifdef CONFIG_IIS2DLPC_TRIGGER_OWN_THREAD static void iis2dlpc_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct iis2dlpc_data *iis2dlpc = dev->data; ARG_UNUSED(unused); @@ -231,7 +231,7 @@ static void iis2dlpc_work_cb(struct k_work *work) } #endif /* CONFIG_IIS2DLPC_TRIGGER_GLOBAL_THREAD */ -int iis2dlpc_init_interrupt(struct device *dev) +int iis2dlpc_init_interrupt(const struct device *dev) { struct iis2dlpc_data *iis2dlpc = dev->data; const struct iis2dlpc_device_config *cfg = dev->config; diff --git a/drivers/sensor/iis2mdc/iis2mdc.c b/drivers/sensor/iis2mdc/iis2mdc.c index 37f62114a75f97..238f469154c9eb 100644 --- a/drivers/sensor/iis2mdc/iis2mdc.c +++ b/drivers/sensor/iis2mdc/iis2mdc.c @@ -23,7 +23,8 @@ struct iis2mdc_data iis2mdc_data; LOG_MODULE_REGISTER(IIS2MDC, CONFIG_SENSOR_LOG_LEVEL); #ifdef CONFIG_IIS2MDC_MAG_ODR_RUNTIME -static int iis2mdc_set_odr(struct device *dev, const struct sensor_value *val) +static int iis2mdc_set_odr(const struct device *dev, + const struct sensor_value *val) { struct iis2mdc_data *iis2mdc = dev->data; iis2mdc_odr_t odr; @@ -53,7 +54,8 @@ static int iis2mdc_set_odr(struct device *dev, const struct sensor_value *val) } #endif /* CONFIG_IIS2MDC_MAG_ODR_RUNTIME */ -static int iis2mdc_set_hard_iron(struct device *dev, enum sensor_channel chan, +static int iis2mdc_set_hard_iron(const struct device *dev, + enum sensor_channel chan, const struct sensor_value *val) { struct iis2mdc_data *iis2mdc = dev->data; @@ -68,7 +70,7 @@ static int iis2mdc_set_hard_iron(struct device *dev, enum sensor_channel chan, return iis2mdc_mag_user_offset_set(iis2mdc->ctx, offset.u8bit); } -static void iis2mdc_channel_get_mag(struct device *dev, +static void iis2mdc_channel_get_mag(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -102,7 +104,7 @@ static void iis2mdc_channel_get_mag(struct device *dev, } /* read internal temperature */ -static void iis2mdc_channel_get_temp(struct device *dev, +static void iis2mdc_channel_get_temp(const struct device *dev, struct sensor_value *val) { struct iis2mdc_data *drv_data = dev->data; @@ -111,7 +113,8 @@ static void iis2mdc_channel_get_temp(struct device *dev, val->val2 = (drv_data->temp_sample % 100) * 10000; } -static int iis2mdc_channel_get(struct device *dev, enum sensor_channel chan, +static int iis2mdc_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { switch (chan) { @@ -132,7 +135,7 @@ static int iis2mdc_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int iis2mdc_config(struct device *dev, enum sensor_channel chan, +static int iis2mdc_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -151,7 +154,7 @@ static int iis2mdc_config(struct device *dev, enum sensor_channel chan, return 0; } -static int iis2mdc_attr_set(struct device *dev, +static int iis2mdc_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -171,7 +174,7 @@ static int iis2mdc_attr_set(struct device *dev, return 0; } -static int iis2mdc_sample_fetch_mag(struct device *dev) +static int iis2mdc_sample_fetch_mag(const struct device *dev) { struct iis2mdc_data *iis2mdc = dev->data; union axis3bit16_t raw_mag; @@ -189,7 +192,7 @@ static int iis2mdc_sample_fetch_mag(struct device *dev) return 0; } -static int iis2mdc_sample_fetch_temp(struct device *dev) +static int iis2mdc_sample_fetch_temp(const struct device *dev) { struct iis2mdc_data *iis2mdc = dev->data; union axis1bit16_t raw_temp; @@ -208,7 +211,8 @@ static int iis2mdc_sample_fetch_temp(struct device *dev) return 0; } -static int iis2mdc_sample_fetch(struct device *dev, enum sensor_channel chan) +static int iis2mdc_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_MAGN_X: @@ -240,7 +244,7 @@ static const struct sensor_driver_api iis2mdc_driver_api = { .channel_get = iis2mdc_channel_get, }; -static int iis2mdc_init_interface(struct device *dev) +static int iis2mdc_init_interface(const struct device *dev) { const struct iis2mdc_config *const config = dev->config; struct iis2mdc_data *iis2mdc = dev->data; @@ -286,7 +290,7 @@ static const struct iis2mdc_config iis2mdc_dev_config = { #endif }; -static int iis2mdc_init(struct device *dev) +static int iis2mdc_init(const struct device *dev) { struct iis2mdc_data *iis2mdc = dev->data; uint8_t wai; diff --git a/drivers/sensor/iis2mdc/iis2mdc.h b/drivers/sensor/iis2mdc/iis2mdc.h index 936b1ebdaf2107..bba0e4c6c0680f 100644 --- a/drivers/sensor/iis2mdc/iis2mdc.h +++ b/drivers/sensor/iis2mdc/iis2mdc.h @@ -29,7 +29,7 @@ union axis1bit16_t { struct iis2mdc_config { char *master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_IIS2MDC_TRIGGER const char *drdy_port; gpio_pin_t drdy_pin; @@ -49,7 +49,7 @@ struct iis2mdc_config { /* Sensor data */ struct iis2mdc_data { - struct device *bus; + const struct device *bus; uint16_t i2c_addr; int16_t mag[3]; int32_t temp_sample; @@ -63,11 +63,11 @@ struct iis2mdc_data { #endif #ifdef CONFIG_IIS2MDC_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t handler_drdy; - struct device *dev; + const struct device *dev; #if defined(CONFIG_IIS2MDC_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_IIS2MDC_THREAD_STACK_SIZE); @@ -82,12 +82,12 @@ struct iis2mdc_data { #endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */ }; -int iis2mdc_spi_init(struct device *dev); -int iis2mdc_i2c_init(struct device *dev); +int iis2mdc_spi_init(const struct device *dev); +int iis2mdc_i2c_init(const struct device *dev); #ifdef CONFIG_IIS2MDC_TRIGGER -int iis2mdc_init_interrupt(struct device *dev); -int iis2mdc_trigger_set(struct device *dev, +int iis2mdc_init_interrupt(const struct device *dev); +int iis2mdc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_IIS2MDC_TRIGGER */ diff --git a/drivers/sensor/iis2mdc/iis2mdc_i2c.c b/drivers/sensor/iis2mdc/iis2mdc_i2c.c index 94922fe9f60058..58c67c09c3453e 100644 --- a/drivers/sensor/iis2mdc/iis2mdc_i2c.c +++ b/drivers/sensor/iis2mdc/iis2mdc_i2c.c @@ -21,7 +21,7 @@ #define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL LOG_MODULE_DECLARE(IIS2MDC); -static int iis2mdc_i2c_read(struct device *dev, uint8_t reg_addr, +static int iis2mdc_i2c_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct iis2mdc_data *data = dev->data; @@ -31,7 +31,7 @@ static int iis2mdc_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int iis2mdc_i2c_write(struct device *dev, uint8_t reg_addr, +static int iis2mdc_i2c_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct iis2mdc_data *data = dev->data; @@ -41,7 +41,7 @@ static int iis2mdc_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int iis2mdc_i2c_init(struct device *dev) +int iis2mdc_i2c_init(const struct device *dev) { struct iis2mdc_data *data = dev->data; diff --git a/drivers/sensor/iis2mdc/iis2mdc_spi.c b/drivers/sensor/iis2mdc/iis2mdc_spi.c index 47822d3c345411..f0273500ec242d 100644 --- a/drivers/sensor/iis2mdc/iis2mdc_spi.c +++ b/drivers/sensor/iis2mdc/iis2mdc_spi.c @@ -21,7 +21,7 @@ #define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL LOG_MODULE_DECLARE(IIS2MDC); -static int iis2mdc_spi_read(struct device *dev, uint8_t reg_addr, +static int iis2mdc_spi_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct iis2mdc_data *data = dev->data; @@ -63,7 +63,7 @@ static int iis2mdc_spi_read(struct device *dev, uint8_t reg_addr, return 0; } -static int iis2mdc_spi_write(struct device *dev, uint8_t reg_addr, +static int iis2mdc_spi_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct iis2mdc_data *data = dev->data; @@ -97,7 +97,7 @@ static int iis2mdc_spi_write(struct device *dev, uint8_t reg_addr, return 0; } -int iis2mdc_spi_init(struct device *dev) +int iis2mdc_spi_init(const struct device *dev) { struct iis2mdc_data *data = dev->data; diff --git a/drivers/sensor/iis2mdc/iis2mdc_trigger.c b/drivers/sensor/iis2mdc/iis2mdc_trigger.c index 9aa9c210e6ece4..f35947783bec67 100644 --- a/drivers/sensor/iis2mdc/iis2mdc_trigger.c +++ b/drivers/sensor/iis2mdc/iis2mdc_trigger.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(IIS2MDC, CONFIG_SENSOR_LOG_LEVEL); -static int iis2mdc_enable_int(struct device *dev, int enable) +static int iis2mdc_enable_int(const struct device *dev, int enable) { struct iis2mdc_data *iis2mdc = dev->data; @@ -27,7 +27,7 @@ static int iis2mdc_enable_int(struct device *dev, int enable) } /* link external trigger to event data ready */ -int iis2mdc_trigger_set(struct device *dev, +int iis2mdc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -52,7 +52,7 @@ int iis2mdc_trigger_set(struct device *dev, /* handle the drdy event: read data and call handler if registered any */ static void iis2mdc_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct iis2mdc_data *iis2mdc = dev->data; const struct iis2mdc_config *const config = dev->config; struct sensor_trigger drdy_trigger = { @@ -67,7 +67,7 @@ static void iis2mdc_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void iis2mdc_gpio_callback(struct device *dev, +static void iis2mdc_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct iis2mdc_data *iis2mdc = @@ -88,7 +88,7 @@ static void iis2mdc_gpio_callback(struct device *dev, #ifdef CONFIG_IIS2MDC_TRIGGER_OWN_THREAD static void iis2mdc_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct iis2mdc_data *iis2mdc = dev->data; ARG_UNUSED(unused); @@ -110,7 +110,7 @@ static void iis2mdc_work_cb(struct k_work *work) } #endif -int iis2mdc_init_interrupt(struct device *dev) +int iis2mdc_init_interrupt(const struct device *dev) { struct iis2mdc_data *iis2mdc = dev->data; const struct iis2mdc_config *const config = dev->config; diff --git a/drivers/sensor/iis3dhhc/iis3dhhc.c b/drivers/sensor/iis3dhhc/iis3dhhc.c index ce848e672aba35..b5ade4ffe080b7 100644 --- a/drivers/sensor/iis3dhhc/iis3dhhc.c +++ b/drivers/sensor/iis3dhhc/iis3dhhc.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(IIS3DHHC, CONFIG_SENSOR_LOG_LEVEL); -static int iis3dhhc_sample_fetch(struct device *dev, +static int iis3dhhc_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct iis3dhhc_data *data = dev->data; @@ -48,7 +48,7 @@ static inline void iis3dhhc_convert(struct sensor_value *val, val->val2 = micro_ms2 % 1000000LL; } -static inline void iis3dhhc_channel_get_acc(struct device *dev, +static inline void iis3dhhc_channel_get_acc(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -77,7 +77,7 @@ static inline void iis3dhhc_channel_get_acc(struct device *dev, } } -static int iis3dhhc_channel_get(struct device *dev, +static int iis3dhhc_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -96,8 +96,8 @@ static int iis3dhhc_channel_get(struct device *dev, return -ENOTSUP; } -static int iis3dhhc_odr_set(struct device *dev, - const struct sensor_value *val) +static int iis3dhhc_odr_set(const struct device *dev, + const struct sensor_value *val) { struct iis3dhhc_data *data = dev->data; iis3dhhc_norm_mod_en_t en; @@ -121,9 +121,10 @@ static int iis3dhhc_odr_set(struct device *dev, return 0; } -static int iis3dhhc_attr_set(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int iis3dhhc_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { if (chan != SENSOR_CHAN_ALL) { LOG_WRN("attr_set() not supported on this channel."); @@ -150,7 +151,7 @@ static const struct sensor_driver_api iis3dhhc_api_funcs = { #endif }; -static int iis3dhhc_init_chip(struct device *dev) +static int iis3dhhc_init_chip(const struct device *dev) { struct iis3dhhc_data *data = dev->data; uint8_t chip_id, rst; @@ -189,7 +190,7 @@ static int iis3dhhc_init_chip(struct device *dev) return 0; } -static int iis3dhhc_init(struct device *dev) +static int iis3dhhc_init(const struct device *dev) { const struct iis3dhhc_config * const config = dev->config; struct iis3dhhc_data *data = dev->data; diff --git a/drivers/sensor/iis3dhhc/iis3dhhc.h b/drivers/sensor/iis3dhhc/iis3dhhc.h index b02ffee8f49f16..5398632d15df28 100644 --- a/drivers/sensor/iis3dhhc/iis3dhhc.h +++ b/drivers/sensor/iis3dhhc/iis3dhhc.h @@ -26,7 +26,7 @@ union axis3bit16_t { struct iis3dhhc_config { char *master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_IIS3DHHC_TRIGGER const char *int_port; uint8_t int_pin; @@ -42,7 +42,7 @@ struct iis3dhhc_config { }; struct iis3dhhc_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; stmdev_ctx_t *ctx; @@ -52,12 +52,12 @@ struct iis3dhhc_data { #endif #ifdef CONFIG_IIS3DHHC_TRIGGER - struct device *gpio; + const struct device *gpio; uint32_t pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t handler_drdy; - struct device *dev; + const struct device *dev; #if defined(CONFIG_IIS3DHHC_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_IIS3DHHC_THREAD_STACK_SIZE); @@ -73,14 +73,14 @@ struct iis3dhhc_data { #endif }; -int iis3dhhc_spi_init(struct device *dev); +int iis3dhhc_spi_init(const struct device *dev); #ifdef CONFIG_IIS3DHHC_TRIGGER -int iis3dhhc_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler); +int iis3dhhc_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); -int iis3dhhc_init_interrupt(struct device *dev); +int iis3dhhc_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_IIS3DHHC_IIS3DHHC_H_ */ diff --git a/drivers/sensor/iis3dhhc/iis3dhhc_spi.c b/drivers/sensor/iis3dhhc/iis3dhhc_spi.c index 30c94738fddca2..830110ce628c7f 100644 --- a/drivers/sensor/iis3dhhc/iis3dhhc_spi.c +++ b/drivers/sensor/iis3dhhc/iis3dhhc_spi.c @@ -96,7 +96,7 @@ stmdev_ctx_t iis3dhhc_spi_ctx = { .write_reg = (stmdev_write_ptr) iis3dhhc_spi_write, }; -int iis3dhhc_spi_init(struct device *dev) +int iis3dhhc_spi_init(const struct device *dev) { struct iis3dhhc_data *data = dev->data; diff --git a/drivers/sensor/iis3dhhc/iis3dhhc_trigger.c b/drivers/sensor/iis3dhhc/iis3dhhc_trigger.c index eb87804277d315..49eb9c68b1f953 100644 --- a/drivers/sensor/iis3dhhc/iis3dhhc_trigger.c +++ b/drivers/sensor/iis3dhhc/iis3dhhc_trigger.c @@ -22,7 +22,7 @@ LOG_MODULE_DECLARE(IIS3DHHC, CONFIG_SENSOR_LOG_LEVEL); /** * iis3dhhc_enable_int - enable selected int pin to generate interrupt */ -static int iis3dhhc_enable_int(struct device *dev, int enable) +static int iis3dhhc_enable_int(const struct device *dev, int enable) { struct iis3dhhc_data *iis3dhhc = dev->data; @@ -37,7 +37,7 @@ static int iis3dhhc_enable_int(struct device *dev, int enable) /** * iis3dhhc_trigger_set - link external trigger to event data ready */ -int iis3dhhc_trigger_set(struct device *dev, +int iis3dhhc_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -64,7 +64,7 @@ int iis3dhhc_trigger_set(struct device *dev, */ static void iis3dhhc_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct iis3dhhc_data *iis3dhhc = dev->data; struct sensor_trigger drdy_trigger = { .type = SENSOR_TRIG_DATA_READY, @@ -79,7 +79,7 @@ static void iis3dhhc_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void iis3dhhc_gpio_callback(struct device *dev, +static void iis3dhhc_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct iis3dhhc_data *iis3dhhc = @@ -101,7 +101,7 @@ static void iis3dhhc_gpio_callback(struct device *dev, #ifdef CONFIG_IIS3DHHC_TRIGGER_OWN_THREAD static void iis3dhhc_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct iis3dhhc_data *iis3dhhc = dev->data; ARG_UNUSED(unused); @@ -123,7 +123,7 @@ static void iis3dhhc_work_cb(struct k_work *work) } #endif /* CONFIG_IIS3DHHC_TRIGGER_GLOBAL_THREAD */ -int iis3dhhc_init_interrupt(struct device *dev) +int iis3dhhc_init_interrupt(const struct device *dev) { struct iis3dhhc_data *iis3dhhc = dev->data; const struct iis3dhhc_config *cfg = dev->config; diff --git a/drivers/sensor/isl29035/isl29035.c b/drivers/sensor/isl29035/isl29035.c index 173e97b4b45c5b..bed0213de41956 100644 --- a/drivers/sensor/isl29035/isl29035.c +++ b/drivers/sensor/isl29035/isl29035.c @@ -19,7 +19,8 @@ LOG_MODULE_REGISTER(ISL29035, CONFIG_SENSOR_LOG_LEVEL); -static int isl29035_sample_fetch(struct device *dev, enum sensor_channel chan) +static int isl29035_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct isl29035_driver_data *drv_data = dev->data; uint8_t msb, lsb; @@ -41,7 +42,7 @@ static int isl29035_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int isl29035_channel_get(struct device *dev, +static int isl29035_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -72,7 +73,7 @@ static const struct sensor_driver_api isl29035_api = { .channel_get = &isl29035_channel_get, }; -static int isl29035_init(struct device *dev) +static int isl29035_init(const struct device *dev) { struct isl29035_driver_data *drv_data = dev->data; diff --git a/drivers/sensor/isl29035/isl29035.h b/drivers/sensor/isl29035/isl29035.h index 44fea55962329e..e730ee3bf8d62a 100644 --- a/drivers/sensor/isl29035/isl29035.h +++ b/drivers/sensor/isl29035/isl29035.h @@ -111,11 +111,11 @@ (ISL29035_INT_PRST_IDX << ISL29035_INT_PRST_SHIFT) struct isl29035_driver_data { - struct device *i2c; + const struct device *i2c; uint16_t data_sample; #if CONFIG_ISL29035_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger th_trigger; @@ -127,23 +127,23 @@ struct isl29035_driver_data { struct k_sem gpio_sem; #elif defined(CONFIG_ISL29035_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_ISL29035_TRIGGER */ }; #ifdef CONFIG_ISL29035_TRIGGER -int isl29035_attr_set(struct device *dev, +int isl29035_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int isl29035_trigger_set(struct device *dev, +int isl29035_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int isl29035_init_interrupt(struct device *dev); +int isl29035_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_ISL29035_ISL29035_H_ */ diff --git a/drivers/sensor/isl29035/isl29035_trigger.c b/drivers/sensor/isl29035/isl29035_trigger.c index 21f4e3588f198e..1c53cd3b14538b 100644 --- a/drivers/sensor/isl29035/isl29035_trigger.c +++ b/drivers/sensor/isl29035/isl29035_trigger.c @@ -52,7 +52,7 @@ static uint16_t isl29035_lux_processed_to_raw(struct sensor_value const *val) return raw_val / ISL29035_LUX_RANGE; } -int isl29035_attr_set(struct device *dev, +int isl29035_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -84,7 +84,7 @@ int isl29035_attr_set(struct device *dev, return 0; } -static void isl29035_gpio_callback(struct device *dev, +static void isl29035_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct isl29035_driver_data *drv_data = @@ -95,7 +95,7 @@ static void isl29035_gpio_callback(struct device *dev, handle_int(drv_data); } -static void isl29035_thread_cb(struct device *dev) +static void isl29035_thread_cb(const struct device *dev) { struct isl29035_driver_data *drv_data = dev->data; uint8_t val; @@ -117,7 +117,7 @@ static void isl29035_thread_cb(struct device *dev) #ifdef CONFIG_ISL29035_TRIGGER_OWN_THREAD static void isl29035_thread(int ptr, int unused) { - struct device *dev = INT_TO_POINTER(ptr); + const struct device *dev = INT_TO_POINTER(ptr); struct isl29035_driver_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -139,7 +139,7 @@ static void isl29035_work_cb(struct k_work *work) } #endif -int isl29035_trigger_set(struct device *dev, +int isl29035_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -161,7 +161,7 @@ int isl29035_trigger_set(struct device *dev, return 0; } -int isl29035_init_interrupt(struct device *dev) +int isl29035_init_interrupt(const struct device *dev) { struct isl29035_driver_data *drv_data = dev->data; diff --git a/drivers/sensor/ism330dhcx/ism330dhcx.c b/drivers/sensor/ism330dhcx/ism330dhcx.c index 617a67935664bd..a91271bfd96732 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx.c +++ b/drivers/sensor/ism330dhcx/ism330dhcx.c @@ -88,7 +88,7 @@ static int ism330dhcx_gyro_range_to_fs_val(int32_t range) } #endif -static inline int ism330dhcx_reboot(struct device *dev) +static inline int ism330dhcx_reboot(const struct device *dev) { struct ism330dhcx_data *data = dev->data; @@ -102,7 +102,7 @@ static inline int ism330dhcx_reboot(struct device *dev) return 0; } -static int ism330dhcx_accel_set_fs_raw(struct device *dev, uint8_t fs) +static int ism330dhcx_accel_set_fs_raw(const struct device *dev, uint8_t fs) { struct ism330dhcx_data *data = dev->data; @@ -115,7 +115,7 @@ static int ism330dhcx_accel_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int ism330dhcx_accel_set_odr_raw(struct device *dev, uint8_t odr) +static int ism330dhcx_accel_set_odr_raw(const struct device *dev, uint8_t odr) { struct ism330dhcx_data *data = dev->data; @@ -128,7 +128,7 @@ static int ism330dhcx_accel_set_odr_raw(struct device *dev, uint8_t odr) return 0; } -static int ism330dhcx_gyro_set_fs_raw(struct device *dev, uint8_t fs) +static int ism330dhcx_gyro_set_fs_raw(const struct device *dev, uint8_t fs) { struct ism330dhcx_data *data = dev->data; @@ -139,7 +139,7 @@ static int ism330dhcx_gyro_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int ism330dhcx_gyro_set_odr_raw(struct device *dev, uint8_t odr) +static int ism330dhcx_gyro_set_odr_raw(const struct device *dev, uint8_t odr) { struct ism330dhcx_data *data = dev->data; @@ -151,7 +151,7 @@ static int ism330dhcx_gyro_set_odr_raw(struct device *dev, uint8_t odr) } #ifdef ISM330DHCX_ACCEL_ODR_RUNTIME -static int ism330dhcx_accel_odr_set(struct device *dev, uint16_t freq) +static int ism330dhcx_accel_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -170,7 +170,7 @@ static int ism330dhcx_accel_odr_set(struct device *dev, uint16_t freq) #endif #ifdef ISM330DHCX_ACCEL_FS_RUNTIME -static int ism330dhcx_accel_range_set(struct device *dev, int32_t range) +static int ism330dhcx_accel_range_set(const struct device *dev, int32_t range) { int fs; struct ism330dhcx_data *data = dev->data; @@ -190,7 +190,8 @@ static int ism330dhcx_accel_range_set(struct device *dev, int32_t range) } #endif -static int ism330dhcx_accel_config(struct device *dev, enum sensor_channel chan, +static int ism330dhcx_accel_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -212,7 +213,7 @@ static int ism330dhcx_accel_config(struct device *dev, enum sensor_channel chan, } #ifdef ISM330DHCX_GYRO_ODR_RUNTIME -static int ism330dhcx_gyro_odr_set(struct device *dev, uint16_t freq) +static int ism330dhcx_gyro_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -231,7 +232,7 @@ static int ism330dhcx_gyro_odr_set(struct device *dev, uint16_t freq) #endif #ifdef ISM330DHCX_GYRO_FS_RUNTIME -static int ism330dhcx_gyro_range_set(struct device *dev, int32_t range) +static int ism330dhcx_gyro_range_set(const struct device *dev, int32_t range) { int fs; struct ism330dhcx_data *data = dev->data; @@ -251,7 +252,8 @@ static int ism330dhcx_gyro_range_set(struct device *dev, int32_t range) } #endif -static int ism330dhcx_gyro_config(struct device *dev, enum sensor_channel chan, +static int ism330dhcx_gyro_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -272,7 +274,8 @@ static int ism330dhcx_gyro_config(struct device *dev, enum sensor_channel chan, return 0; } -static int ism330dhcx_attr_set(struct device *dev, enum sensor_channel chan, +static int ism330dhcx_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -295,7 +298,7 @@ static int ism330dhcx_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int ism330dhcx_sample_fetch_accel(struct device *dev) +static int ism330dhcx_sample_fetch_accel(const struct device *dev) { struct ism330dhcx_data *data = dev->data; union axis3bit16_t buf; @@ -312,7 +315,7 @@ static int ism330dhcx_sample_fetch_accel(struct device *dev) return 0; } -static int ism330dhcx_sample_fetch_gyro(struct device *dev) +static int ism330dhcx_sample_fetch_gyro(const struct device *dev) { struct ism330dhcx_data *data = dev->data; union axis3bit16_t buf; @@ -330,7 +333,7 @@ static int ism330dhcx_sample_fetch_gyro(struct device *dev) } #if defined(CONFIG_ISM330DHCX_ENABLE_TEMP) -static int ism330dhcx_sample_fetch_temp(struct device *dev) +static int ism330dhcx_sample_fetch_temp(const struct device *dev) { struct ism330dhcx_data *data = dev->data; union axis1bit16_t buf; @@ -347,7 +350,7 @@ static int ism330dhcx_sample_fetch_temp(struct device *dev) #endif #if defined(CONFIG_ISM330DHCX_SENSORHUB) -static int ism330dhcx_sample_fetch_shub(struct device *dev) +static int ism330dhcx_sample_fetch_shub(const struct device *dev) { if (ism330dhcx_shub_fetch_external_devs(dev) < 0) { LOG_DBG("failed to read ext shub devices"); @@ -358,7 +361,8 @@ static int ism330dhcx_sample_fetch_shub(struct device *dev) } #endif /* CONFIG_ISM330DHCX_SENSORHUB */ -static int ism330dhcx_sample_fetch(struct device *dev, enum sensor_channel chan) +static int ism330dhcx_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -625,7 +629,7 @@ static inline void ism330dhcx_temp_convert(struct sensor_value *val, } #endif -static int ism330dhcx_channel_get(struct device *dev, +static int ism330dhcx_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -685,7 +689,7 @@ static const struct sensor_driver_api ism330dhcx_api_funcs = { .channel_get = ism330dhcx_channel_get, }; -static int ism330dhcx_init_chip(struct device *dev) +static int ism330dhcx_init_chip(const struct device *dev) { struct ism330dhcx_data *ism330dhcx = dev->data; uint8_t chip_id; @@ -803,7 +807,7 @@ static const struct ism330dhcx_config ism330dhcx_config = { #endif /* CONFIG_ISM330DHCX_TRIGGER */ }; -static int ism330dhcx_init(struct device *dev) +static int ism330dhcx_init(const struct device *dev) { const struct ism330dhcx_config * const config = dev->config; struct ism330dhcx_data *data = dev->data; diff --git a/drivers/sensor/ism330dhcx/ism330dhcx.h b/drivers/sensor/ism330dhcx/ism330dhcx.h index 65ecc4972c98ba..8a6c75c50d2415 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx.h +++ b/drivers/sensor/ism330dhcx/ism330dhcx.h @@ -93,7 +93,7 @@ union axis1bit16_t { struct ism330dhcx_config { char *bus_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_ISM330DHCX_TRIGGER const char *int_gpio_port; uint8_t int_gpio_pin; @@ -138,7 +138,7 @@ struct ism330dhcx_tf { #define ISM330DHCX_SHUB_MAX_NUM_SLVS 2 struct ism330dhcx_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; uint32_t acc_gain; int16_t gyro[3]; @@ -172,13 +172,13 @@ struct ism330dhcx_data { uint8_t gyro_fs; #ifdef CONFIG_ISM330DHCX_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t handler_drdy_acc; sensor_trigger_handler_t handler_drdy_gyr; sensor_trigger_handler_t handler_drdy_temp; - struct device *dev; + const struct device *dev; #if defined(CONFIG_ISM330DHCX_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_ISM330DHCX_THREAD_STACK_SIZE); @@ -194,23 +194,23 @@ struct ism330dhcx_data { #endif }; -int ism330dhcx_spi_init(struct device *dev); -int ism330dhcx_i2c_init(struct device *dev); +int ism330dhcx_spi_init(const struct device *dev); +int ism330dhcx_i2c_init(const struct device *dev); #if defined(CONFIG_ISM330DHCX_SENSORHUB) -int ism330dhcx_shub_init(struct device *dev); -int ism330dhcx_shub_fetch_external_devs(struct device *dev); +int ism330dhcx_shub_init(const struct device *dev); +int ism330dhcx_shub_fetch_external_devs(const struct device *dev); int ism330dhcx_shub_get_idx(enum sensor_channel type); -int ism330dhcx_shub_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val); +int ism330dhcx_shub_config(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val); #endif /* CONFIG_ISM330DHCX_SENSORHUB */ #ifdef CONFIG_ISM330DHCX_TRIGGER -int ism330dhcx_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler); +int ism330dhcx_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler); -int ism330dhcx_init_interrupt(struct device *dev); +int ism330dhcx_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_ISM330DHCX_ISM330DHCX_H_ */ diff --git a/drivers/sensor/ism330dhcx/ism330dhcx_i2c.c b/drivers/sensor/ism330dhcx/ism330dhcx_i2c.c index 49b2a9e3e4d96d..0fd4fc41aa0e9c 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx_i2c.c +++ b/drivers/sensor/ism330dhcx/ism330dhcx_i2c.c @@ -20,8 +20,8 @@ LOG_MODULE_DECLARE(ISM330DHCX, CONFIG_SENSOR_LOG_LEVEL); -static int ism330dhcx_i2c_read(struct device *dev, uint8_t reg_addr, - uint8_t *value, uint8_t len) +static int ism330dhcx_i2c_read(const struct device *dev, uint8_t reg_addr, + uint8_t *value, uint8_t len) { struct ism330dhcx_data *data = dev->data; const struct ism330dhcx_config *cfg = dev->config; @@ -30,8 +30,8 @@ static int ism330dhcx_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int ism330dhcx_i2c_write(struct device *dev, uint8_t reg_addr, - uint8_t *value, uint8_t len) +static int ism330dhcx_i2c_write(const struct device *dev, uint8_t reg_addr, + uint8_t *value, uint8_t len) { struct ism330dhcx_data *data = dev->data; const struct ism330dhcx_config *cfg = dev->config; @@ -40,7 +40,7 @@ static int ism330dhcx_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int ism330dhcx_i2c_init(struct device *dev) +int ism330dhcx_i2c_init(const struct device *dev) { struct ism330dhcx_data *data = dev->data; diff --git a/drivers/sensor/ism330dhcx/ism330dhcx_shub.c b/drivers/sensor/ism330dhcx/ism330dhcx_shub.c index 0feb840c6a6ca8..b25129a4baee34 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx_shub.c +++ b/drivers/sensor/ism330dhcx/ism330dhcx_shub.c @@ -680,7 +680,7 @@ int ism330dhcx_shub_get_idx(enum sensor_channel type) return -ENOTSUP; } -int ism330dhcx_shub_fetch_external_devs(struct device *dev) +int ism330dhcx_shub_fetch_external_devs(const struct device *dev) { uint8_t n; struct ism330dhcx_data *data = dev->data; @@ -705,9 +705,9 @@ int ism330dhcx_shub_fetch_external_devs(struct device *dev) return 0; } -int ism330dhcx_shub_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +int ism330dhcx_shub_config(const struct device *dev, enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { struct ism330dhcx_data *data = dev->data; struct ism330dhcx_shub_slist *sp = NULL; @@ -733,7 +733,7 @@ int ism330dhcx_shub_config(struct device *dev, enum sensor_channel chan, return sp->dev_conf(data, sp->ext_i2c_addr, chan, attr, val); } -int ism330dhcx_shub_init(struct device *dev) +int ism330dhcx_shub_init(const struct device *dev) { struct ism330dhcx_data *data = dev->data; uint8_t i, n = 0, regn; diff --git a/drivers/sensor/ism330dhcx/ism330dhcx_spi.c b/drivers/sensor/ism330dhcx/ism330dhcx_spi.c index 3ae3a299d7156c..2162295088ac32 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx_spi.c +++ b/drivers/sensor/ism330dhcx/ism330dhcx_spi.c @@ -20,8 +20,8 @@ LOG_MODULE_DECLARE(ISM330DHCX, CONFIG_SENSOR_LOG_LEVEL); -static int ism330dhcx_spi_read(struct device *dev, uint8_t reg_addr, - uint8_t *value, uint8_t len) +static int ism330dhcx_spi_read(const struct device *dev, uint8_t reg_addr, + uint8_t *value, uint8_t len) { struct ism330dhcx_data *data = dev->data; const struct ism330dhcx_config *cfg = dev->config; @@ -62,8 +62,8 @@ static int ism330dhcx_spi_read(struct device *dev, uint8_t reg_addr, return 0; } -static int ism330dhcx_spi_write(struct device *dev, uint8_t reg_addr, - uint8_t *value, uint8_t len) +static int ism330dhcx_spi_write(const struct device *dev, uint8_t reg_addr, + uint8_t *value, uint8_t len) { struct ism330dhcx_data *data = dev->data; const struct ism330dhcx_config *cfg = dev->config; @@ -96,7 +96,7 @@ static int ism330dhcx_spi_write(struct device *dev, uint8_t reg_addr, return 0; } -int ism330dhcx_spi_init(struct device *dev) +int ism330dhcx_spi_init(const struct device *dev) { struct ism330dhcx_data *data = dev->data; diff --git a/drivers/sensor/ism330dhcx/ism330dhcx_trigger.c b/drivers/sensor/ism330dhcx/ism330dhcx_trigger.c index 50fa9c95fc629d..15af085b6e43fc 100644 --- a/drivers/sensor/ism330dhcx/ism330dhcx_trigger.c +++ b/drivers/sensor/ism330dhcx/ism330dhcx_trigger.c @@ -23,7 +23,7 @@ LOG_MODULE_DECLARE(ISM330DHCX, CONFIG_SENSOR_LOG_LEVEL); /** * ism330dhcx_enable_t_int - TEMP enable selected int pin to generate interrupt */ -static int ism330dhcx_enable_t_int(struct device *dev, int enable) +static int ism330dhcx_enable_t_int(const struct device *dev, int enable) { const struct ism330dhcx_config *cfg = dev->config; struct ism330dhcx_data *ism330dhcx = dev->data; @@ -51,7 +51,7 @@ static int ism330dhcx_enable_t_int(struct device *dev, int enable) /** * ism330dhcx_enable_xl_int - XL enable selected int pin to generate interrupt */ -static int ism330dhcx_enable_xl_int(struct device *dev, int enable) +static int ism330dhcx_enable_xl_int(const struct device *dev, int enable) { const struct ism330dhcx_config *cfg = dev->config; struct ism330dhcx_data *ism330dhcx = dev->data; @@ -87,7 +87,7 @@ static int ism330dhcx_enable_xl_int(struct device *dev, int enable) /** * ism330dhcx_enable_g_int - Gyro enable selected int pin to generate interrupt */ -static int ism330dhcx_enable_g_int(struct device *dev, int enable) +static int ism330dhcx_enable_g_int(const struct device *dev, int enable) { const struct ism330dhcx_config *cfg = dev->config; struct ism330dhcx_data *ism330dhcx = dev->data; @@ -122,9 +122,9 @@ static int ism330dhcx_enable_g_int(struct device *dev, int enable) /** * ism330dhcx_trigger_set - link external trigger to event data ready */ -int ism330dhcx_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) +int ism330dhcx_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { struct ism330dhcx_data *ism330dhcx = dev->data; @@ -163,7 +163,7 @@ int ism330dhcx_trigger_set(struct device *dev, */ static void ism330dhcx_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct ism330dhcx_data *ism330dhcx = dev->data; struct sensor_trigger drdy_trigger = { .type = SENSOR_TRIG_DATA_READY, @@ -204,8 +204,8 @@ static void ism330dhcx_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void ism330dhcx_gpio_callback(struct device *dev, - struct gpio_callback *cb, uint32_t pins) +static void ism330dhcx_gpio_callback(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) { struct ism330dhcx_data *ism330dhcx = CONTAINER_OF(cb, struct ism330dhcx_data, gpio_cb); @@ -226,7 +226,7 @@ static void ism330dhcx_gpio_callback(struct device *dev, #ifdef CONFIG_ISM330DHCX_TRIGGER_OWN_THREAD static void ism330dhcx_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct ism330dhcx_data *ism330dhcx = dev->data; ARG_UNUSED(unused); @@ -248,7 +248,7 @@ static void ism330dhcx_work_cb(struct k_work *work) } #endif /* CONFIG_ISM330DHCX_TRIGGER_GLOBAL_THREAD */ -int ism330dhcx_init_interrupt(struct device *dev) +int ism330dhcx_init_interrupt(const struct device *dev) { struct ism330dhcx_data *ism330dhcx = dev->data; const struct ism330dhcx_config *cfg = dev->config; diff --git a/drivers/sensor/lis2dh/lis2dh.c b/drivers/sensor/lis2dh/lis2dh.c index a0293392752b22..ecdb5fcd070bd4 100644 --- a/drivers/sensor/lis2dh/lis2dh.c +++ b/drivers/sensor/lis2dh/lis2dh.c @@ -52,7 +52,7 @@ static void lis2dh_convert(int16_t raw_val, uint32_t scale, val->val2 = converted_val % 1000000; } -static int lis2dh_channel_get(struct device *dev, +static int lis2dh_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -85,7 +85,8 @@ static int lis2dh_channel_get(struct device *dev, return 0; } -static int lis2dh_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lis2dh_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct lis2dh_data *lis2dh = dev->data; size_t i; @@ -143,7 +144,7 @@ static int lis2dh_freq_to_odr_val(uint16_t freq) return -EINVAL; } -static int lis2dh_acc_odr_set(struct device *dev, uint16_t freq) +static int lis2dh_acc_odr_set(const struct device *dev, uint16_t freq) { int odr; int status; @@ -195,7 +196,7 @@ static int lis2dh_range_to_reg_val(uint16_t range) return -EINVAL; } -static int lis2dh_acc_range_set(struct device *dev, int32_t range) +static int lis2dh_acc_range_set(const struct device *dev, int32_t range) { struct lis2dh_data *lis2dh = dev->data; int fs; @@ -213,9 +214,10 @@ static int lis2dh_acc_range_set(struct device *dev, int32_t range) } #endif -static int lis2dh_acc_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lis2dh_acc_config(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { #ifdef CONFIG_LIS2DH_ACCEL_RANGE_RUNTIME @@ -239,7 +241,7 @@ static int lis2dh_acc_config(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2dh_attr_set(struct device *dev, enum sensor_channel chan, +static int lis2dh_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -266,7 +268,7 @@ static const struct sensor_driver_api lis2dh_driver_api = { .channel_get = lis2dh_channel_get, }; -int lis2dh_init(struct device *dev) +int lis2dh_init(const struct device *dev) { struct lis2dh_data *lis2dh = dev->data; const struct lis2dh_config *cfg = dev->config; diff --git a/drivers/sensor/lis2dh/lis2dh.h b/drivers/sensor/lis2dh/lis2dh.h index 69d2a513576ae0..eaa2a85f064205 100644 --- a/drivers/sensor/lis2dh/lis2dh.h +++ b/drivers/sensor/lis2dh/lis2dh.h @@ -199,7 +199,7 @@ union lis2dh_sample { struct lis2dh_config { char *bus_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) uint16_t i2c_slv_addr; #elif DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) @@ -214,20 +214,20 @@ struct lis2dh_config { }; struct lis2dh_transfer_function { - int (*read_data)(struct device *dev, uint8_t reg_addr, + int (*read_data)(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len); - int (*write_data)(struct device *dev, uint8_t reg_addr, + int (*write_data)(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len); - int (*read_reg)(struct device *dev, uint8_t reg_addr, + int (*read_reg)(const struct device *dev, uint8_t reg_addr, uint8_t *value); - int (*write_reg)(struct device *dev, uint8_t reg_addr, - uint8_t value); - int (*update_reg)(struct device *dev, uint8_t reg_addr, + int (*write_reg)(const struct device *dev, uint8_t reg_addr, + uint8_t value); + int (*update_reg)(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t value); }; struct lis2dh_data { - struct device *bus; + const struct device *bus; const struct lis2dh_transfer_function *hw_tf; union lis2dh_sample sample; @@ -235,8 +235,8 @@ struct lis2dh_data { uint32_t scale; #ifdef CONFIG_LIS2DH_TRIGGER - struct device *gpio_int1; - struct device *gpio_int2; + const struct device *gpio_int1; + const struct device *gpio_int2; struct gpio_callback gpio_int1_cb; struct gpio_callback gpio_int2_cb; @@ -251,7 +251,7 @@ struct lis2dh_data { struct k_sem gpio_sem; #elif defined(CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_LIS2DH_TRIGGER */ @@ -266,18 +266,19 @@ int lis2dh_spi_access(struct lis2dh_data *ctx, uint8_t cmd, #endif #ifdef CONFIG_LIS2DH_TRIGGER -int lis2dh_trigger_set(struct device *dev, +int lis2dh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lis2dh_init_interrupt(struct device *dev); +int lis2dh_init_interrupt(const struct device *dev); -int lis2dh_acc_slope_config(struct device *dev, enum sensor_attribute attr, +int lis2dh_acc_slope_config(const struct device *dev, + enum sensor_attribute attr, const struct sensor_value *val); #endif -int lis2dh_spi_init(struct device *dev); -int lis2dh_i2c_init(struct device *dev); +int lis2dh_spi_init(const struct device *dev); +int lis2dh_i2c_init(const struct device *dev); #endif /* __SENSOR_LIS2DH__ */ diff --git a/drivers/sensor/lis2dh/lis2dh_i2c.c b/drivers/sensor/lis2dh/lis2dh_i2c.c index e5991cc424d488..3b5b906dcbf959 100644 --- a/drivers/sensor/lis2dh/lis2dh_i2c.c +++ b/drivers/sensor/lis2dh/lis2dh_i2c.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(lis2dh, CONFIG_SENSOR_LOG_LEVEL); -static int lis2dh_i2c_read_data(struct device *dev, uint8_t reg_addr, +static int lis2dh_i2c_read_data(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2dh_data *data = dev->data; @@ -31,7 +31,7 @@ static int lis2dh_i2c_read_data(struct device *dev, uint8_t reg_addr, value, len); } -static int lis2dh_i2c_write_data(struct device *dev, uint8_t reg_addr, +static int lis2dh_i2c_write_data(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2dh_data *data = dev->data; @@ -42,7 +42,7 @@ static int lis2dh_i2c_write_data(struct device *dev, uint8_t reg_addr, value, len); } -static int lis2dh_i2c_read_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_i2c_read_reg(const struct device *dev, uint8_t reg_addr, uint8_t *value) { struct lis2dh_data *data = dev->data; @@ -53,7 +53,7 @@ static int lis2dh_i2c_read_reg(struct device *dev, uint8_t reg_addr, reg_addr, value); } -static int lis2dh_i2c_write_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_i2c_write_reg(const struct device *dev, uint8_t reg_addr, uint8_t value) { struct lis2dh_data *data = dev->data; @@ -64,7 +64,7 @@ static int lis2dh_i2c_write_reg(struct device *dev, uint8_t reg_addr, reg_addr, value); } -static int lis2dh_i2c_update_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_i2c_update_reg(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t value) { struct lis2dh_data *data = dev->data; @@ -83,7 +83,7 @@ static const struct lis2dh_transfer_function lis2dh_i2c_transfer_fn = { .update_reg = lis2dh_i2c_update_reg, }; -int lis2dh_i2c_init(struct device *dev) +int lis2dh_i2c_init(const struct device *dev) { struct lis2dh_data *data = dev->data; diff --git a/drivers/sensor/lis2dh/lis2dh_spi.c b/drivers/sensor/lis2dh/lis2dh_spi.c index 46cc1f94e39207..f22214d0bcb665 100644 --- a/drivers/sensor/lis2dh/lis2dh_spi.c +++ b/drivers/sensor/lis2dh/lis2dh_spi.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(lis2dh, CONFIG_SENSOR_LOG_LEVEL); -static int lis2dh_raw_read(struct device *dev, uint8_t reg_addr, +static int lis2dh_raw_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2dh_data *data = dev->data; @@ -64,7 +64,7 @@ static int lis2dh_raw_read(struct device *dev, uint8_t reg_addr, return 0; } -static int lis2dh_raw_write(struct device *dev, uint8_t reg_addr, +static int lis2dh_raw_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2dh_data *data = dev->data; @@ -102,25 +102,25 @@ static int lis2dh_raw_write(struct device *dev, uint8_t reg_addr, return 0; } -static int lis2dh_spi_read_data(struct device *dev, uint8_t reg_addr, +static int lis2dh_spi_read_data(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { return lis2dh_raw_read(dev, reg_addr, value, len); } -static int lis2dh_spi_write_data(struct device *dev, uint8_t reg_addr, +static int lis2dh_spi_write_data(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { return lis2dh_raw_write(dev, reg_addr, value, len); } -static int lis2dh_spi_read_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_spi_read_reg(const struct device *dev, uint8_t reg_addr, uint8_t *value) { return lis2dh_raw_read(dev, reg_addr, value, 1); } -static int lis2dh_spi_write_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_spi_write_reg(const struct device *dev, uint8_t reg_addr, uint8_t value) { uint8_t tmp_val = value; @@ -128,7 +128,7 @@ static int lis2dh_spi_write_reg(struct device *dev, uint8_t reg_addr, return lis2dh_raw_write(dev, reg_addr, &tmp_val, 1); } -static int lis2dh_spi_update_reg(struct device *dev, uint8_t reg_addr, +static int lis2dh_spi_update_reg(const struct device *dev, uint8_t reg_addr, uint8_t mask, uint8_t value) { uint8_t tmp_val; @@ -147,7 +147,7 @@ static const struct lis2dh_transfer_function lis2dh_spi_transfer_fn = { .update_reg = lis2dh_spi_update_reg, }; -int lis2dh_spi_init(struct device *dev) +int lis2dh_spi_init(const struct device *dev) { struct lis2dh_data *data = dev->data; diff --git a/drivers/sensor/lis2dh/lis2dh_trigger.c b/drivers/sensor/lis2dh/lis2dh_trigger.c index 65b38da970ee0e..8e65a165e4e921 100644 --- a/drivers/sensor/lis2dh/lis2dh_trigger.c +++ b/drivers/sensor/lis2dh/lis2dh_trigger.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(lis2dh, CONFIG_SENSOR_LOG_LEVEL); #include "lis2dh.h" -static inline void setup_int1(struct device *dev, +static inline void setup_int1(const struct device *dev, bool enable) { struct lis2dh_data *lis2dh = dev->data; @@ -30,7 +30,8 @@ static inline void setup_int1(struct device *dev, : GPIO_INT_DISABLE); } -static int lis2dh_trigger_drdy_set(struct device *dev, enum sensor_channel chan, +static int lis2dh_trigger_drdy_set(const struct device *dev, + enum sensor_channel chan, sensor_trigger_handler_t handler) { struct lis2dh_data *lis2dh = dev->data; @@ -64,7 +65,7 @@ static int lis2dh_trigger_drdy_set(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2dh_start_trigger_int1(struct device *dev) +static int lis2dh_start_trigger_int1(const struct device *dev) { int status; uint8_t raw[LIS2DH_BUF_SZ]; @@ -109,7 +110,7 @@ static int lis2dh_start_trigger_int1(struct device *dev) #define LIS2DH_ANYM_CFG (LIS2DH_INT_CFG_ZHIE_ZUPE | LIS2DH_INT_CFG_YHIE_YUPE |\ LIS2DH_INT_CFG_XHIE_XUPE) -static inline void setup_int2(struct device *dev, +static inline void setup_int2(const struct device *dev, bool enable) { struct lis2dh_data *lis2dh = dev->data; @@ -121,7 +122,7 @@ static inline void setup_int2(struct device *dev, : GPIO_INT_DISABLE); } -static int lis2dh_trigger_anym_set(struct device *dev, +static int lis2dh_trigger_anym_set(const struct device *dev, sensor_trigger_handler_t handler) { struct lis2dh_data *lis2dh = dev->data; @@ -156,7 +157,7 @@ static int lis2dh_trigger_anym_set(struct device *dev, return 0; } -static int lis2dh_start_trigger_int2(struct device *dev) +static int lis2dh_start_trigger_int2(const struct device *dev) { struct lis2dh_data *lis2dh = dev->data; @@ -167,7 +168,7 @@ static int lis2dh_start_trigger_int2(struct device *dev) } #endif /* DT_INST_PROP_HAS_IDX(0, irq_gpios, 1) */ -int lis2dh_trigger_set(struct device *dev, +int lis2dh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -183,7 +184,8 @@ int lis2dh_trigger_set(struct device *dev, return -ENOTSUP; } -int lis2dh_acc_slope_config(struct device *dev, enum sensor_attribute attr, +int lis2dh_acc_slope_config(const struct device *dev, + enum sensor_attribute attr, const struct sensor_value *val) { struct lis2dh_data *lis2dh = dev->data; @@ -236,7 +238,7 @@ int lis2dh_acc_slope_config(struct device *dev, enum sensor_attribute attr, return status; } -static void lis2dh_gpio_int1_callback(struct device *dev, +static void lis2dh_gpio_int1_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lis2dh_data *lis2dh = @@ -254,7 +256,7 @@ static void lis2dh_gpio_int1_callback(struct device *dev, } #if DT_INST_PROP_HAS_IDX(0, irq_gpios, 1) -static void lis2dh_gpio_int2_callback(struct device *dev, +static void lis2dh_gpio_int2_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lis2dh_data *lis2dh = @@ -274,7 +276,7 @@ static void lis2dh_gpio_int2_callback(struct device *dev, static void lis2dh_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lis2dh_data *lis2dh = dev->data; int status; @@ -346,7 +348,7 @@ static void lis2dh_thread_cb(void *arg) #ifdef CONFIG_LIS2DH_TRIGGER_OWN_THREAD static void lis2dh_thread(void *arg1, void *unused2, void *unused3) { - struct device *dev = arg1; + const struct device *dev = arg1; struct lis2dh_data *lis2dh = dev->data; ARG_UNUSED(unused2); @@ -369,7 +371,7 @@ static void lis2dh_work_cb(struct k_work *work) } #endif -int lis2dh_init_interrupt(struct device *dev) +int lis2dh_init_interrupt(const struct device *dev) { struct lis2dh_data *lis2dh = dev->data; int status; diff --git a/drivers/sensor/lis2ds12/lis2ds12.c b/drivers/sensor/lis2ds12/lis2ds12.c index fb5b86a091e883..90c07c29b50be4 100644 --- a/drivers/sensor/lis2ds12/lis2ds12.c +++ b/drivers/sensor/lis2ds12/lis2ds12.c @@ -57,7 +57,7 @@ static int lis2ds12_freq_to_odr_val(uint16_t freq) return -EINVAL; } -static int lis2ds12_accel_odr_set(struct device *dev, uint16_t freq) +static int lis2ds12_accel_odr_set(const struct device *dev, uint16_t freq) { struct lis2ds12_data *data = dev->data; int odr; @@ -96,7 +96,7 @@ static int lis2ds12_accel_range_to_fs_val(int32_t range) return -EINVAL; } -static int lis2ds12_accel_range_set(struct device *dev, int32_t range) +static int lis2ds12_accel_range_set(const struct device *dev, int32_t range) { int fs; struct lis2ds12_data *data = dev->data; @@ -119,7 +119,8 @@ static int lis2ds12_accel_range_set(struct device *dev, int32_t range) } #endif -static int lis2ds12_accel_config(struct device *dev, enum sensor_channel chan, +static int lis2ds12_accel_config(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -140,7 +141,8 @@ static int lis2ds12_accel_config(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2ds12_attr_set(struct device *dev, enum sensor_channel chan, +static int lis2ds12_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -155,7 +157,7 @@ static int lis2ds12_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2ds12_sample_fetch_accel(struct device *dev) +static int lis2ds12_sample_fetch_accel(const struct device *dev) { struct lis2ds12_data *data = dev->data; uint8_t buf[6]; @@ -173,7 +175,8 @@ static int lis2ds12_sample_fetch_accel(struct device *dev) return 0; } -static int lis2ds12_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lis2ds12_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -236,7 +239,7 @@ static inline int lis2ds12_get_channel(enum sensor_channel chan, return 0; } -static int lis2ds12_channel_get(struct device *dev, +static int lis2ds12_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -254,7 +257,7 @@ static const struct sensor_driver_api lis2ds12_api_funcs = { .channel_get = lis2ds12_channel_get, }; -static int lis2ds12_init(struct device *dev) +static int lis2ds12_init(const struct device *dev) { const struct lis2ds12_config * const config = dev->config; struct lis2ds12_data *data = dev->data; diff --git a/drivers/sensor/lis2ds12/lis2ds12.h b/drivers/sensor/lis2ds12/lis2ds12.h index 5010c5e28b5365..e5c0346fc26282 100644 --- a/drivers/sensor/lis2ds12/lis2ds12.h +++ b/drivers/sensor/lis2ds12/lis2ds12.h @@ -83,7 +83,7 @@ struct lis2ds12_config { char *comm_master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_LIS2DS12_TRIGGER const char *irq_port; gpio_pin_t irq_pin; @@ -107,7 +107,7 @@ struct lis2ds12_transfer_function { }; struct lis2ds12_data { - struct device *comm_master; + const struct device *comm_master; int sample_x; int sample_y; int sample_z; @@ -115,12 +115,12 @@ struct lis2ds12_data { const struct lis2ds12_transfer_function *hw_tf; #ifdef CONFIG_LIS2DS12_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; sensor_trigger_handler_t data_ready_handler; - struct device *dev; + const struct device *dev; #if defined(CONFIG_LIS2DS12_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LIS2DS12_THREAD_STACK_SIZE); @@ -133,15 +133,15 @@ struct lis2ds12_data { #endif /* CONFIG_LIS2DS12_TRIGGER */ }; -int lis2ds12_spi_init(struct device *dev); -int lis2ds12_i2c_init(struct device *dev); +int lis2ds12_spi_init(const struct device *dev); +int lis2ds12_i2c_init(const struct device *dev); #ifdef CONFIG_LIS2DS12_TRIGGER -int lis2ds12_trigger_set(struct device *dev, +int lis2ds12_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lis2ds12_trigger_init(struct device *dev); +int lis2ds12_trigger_init(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_LIS2DS12_LIS2DS12_H_ */ diff --git a/drivers/sensor/lis2ds12/lis2ds12_i2c.c b/drivers/sensor/lis2ds12/lis2ds12_i2c.c index c20f20d526f5af..5709bf900b0d05 100644 --- a/drivers/sensor/lis2ds12/lis2ds12_i2c.c +++ b/drivers/sensor/lis2ds12/lis2ds12_i2c.c @@ -65,7 +65,7 @@ static const struct lis2ds12_transfer_function lis2ds12_i2c_transfer_fn = { .update_reg = lis2ds12_i2c_update_reg, }; -int lis2ds12_i2c_init(struct device *dev) +int lis2ds12_i2c_init(const struct device *dev) { struct lis2ds12_data *data = dev->data; diff --git a/drivers/sensor/lis2ds12/lis2ds12_spi.c b/drivers/sensor/lis2ds12/lis2ds12_spi.c index 5bdfa7d9c2d75a..871d6ec449af6b 100644 --- a/drivers/sensor/lis2ds12/lis2ds12_spi.c +++ b/drivers/sensor/lis2ds12/lis2ds12_spi.c @@ -151,7 +151,7 @@ static const struct lis2ds12_transfer_function lis2ds12_spi_transfer_fn = { .update_reg = lis2ds12_spi_update_reg, }; -int lis2ds12_spi_init(struct device *dev) +int lis2ds12_spi_init(const struct device *dev) { struct lis2ds12_data *data = dev->data; diff --git a/drivers/sensor/lis2ds12/lis2ds12_trigger.c b/drivers/sensor/lis2ds12/lis2ds12_trigger.c index 50a5e82aa59b28..3a476ed2aff51b 100644 --- a/drivers/sensor/lis2ds12/lis2ds12_trigger.c +++ b/drivers/sensor/lis2ds12/lis2ds12_trigger.c @@ -19,8 +19,8 @@ LOG_MODULE_DECLARE(LIS2DS12, CONFIG_SENSOR_LOG_LEVEL); -static void lis2ds12_gpio_callback(struct device *dev, - struct gpio_callback *cb, uint32_t pins) +static void lis2ds12_gpio_callback(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) { struct lis2ds12_data *data = CONTAINER_OF(cb, struct lis2ds12_data, gpio_cb); @@ -38,7 +38,7 @@ static void lis2ds12_gpio_callback(struct device *dev, #endif } -static void lis2ds12_handle_drdy_int(struct device *dev) +static void lis2ds12_handle_drdy_int(const struct device *dev) { struct lis2ds12_data *data = dev->data; @@ -49,7 +49,7 @@ static void lis2ds12_handle_drdy_int(struct device *dev) static void lis2ds12_handle_int(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lis2ds12_data *data = dev->data; const struct lis2ds12_config *cfg = dev->config; uint8_t status; @@ -70,7 +70,7 @@ static void lis2ds12_handle_int(void *arg) #ifdef CONFIG_LIS2DS12_TRIGGER_OWN_THREAD static void lis2ds12_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lis2ds12_data *data = dev->data; ARG_UNUSED(unused); @@ -92,7 +92,7 @@ static void lis2ds12_work_cb(struct k_work *work) } #endif -static int lis2ds12_init_interrupt(struct device *dev) +static int lis2ds12_init_interrupt(const struct device *dev) { struct lis2ds12_data *data = dev->data; @@ -117,7 +117,7 @@ static int lis2ds12_init_interrupt(struct device *dev) return 0; } -int lis2ds12_trigger_init(struct device *dev) +int lis2ds12_trigger_init(const struct device *dev) { struct lis2ds12_data *data = dev->data; const struct lis2ds12_config *cfg = dev->config; @@ -160,9 +160,9 @@ int lis2ds12_trigger_init(struct device *dev) return 0; } -int lis2ds12_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) +int lis2ds12_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { struct lis2ds12_data *data = dev->data; const struct lis2ds12_config *cfg = dev->config; diff --git a/drivers/sensor/lis2dw12/lis2dw12.c b/drivers/sensor/lis2dw12/lis2dw12.c index 279581ea062027..f0920da4dd6cb5 100644 --- a/drivers/sensor/lis2dw12/lis2dw12.c +++ b/drivers/sensor/lis2dw12/lis2dw12.c @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(LIS2DW12, CONFIG_SENSOR_LOG_LEVEL); * @dev: Pointer to instance of struct device (I2C or SPI) * @range: Full scale range (2, 4, 8 and 16 G) */ -static int lis2dw12_set_range(struct device *dev, uint16_t range) +static int lis2dw12_set_range(const struct device *dev, uint16_t range) { int err; struct lis2dw12_data *lis2dw12 = dev->data; @@ -60,7 +60,7 @@ static int lis2dw12_set_range(struct device *dev, uint16_t range) * @dev: Pointer to instance of struct device (I2C or SPI) * @odr: Output data rate */ -static int lis2dw12_set_odr(struct device *dev, uint16_t odr) +static int lis2dw12_set_odr(const struct device *dev, uint16_t odr) { struct lis2dw12_data *lis2dw12 = dev->data; uint8_t val; @@ -92,7 +92,7 @@ static inline void lis2dw12_convert(struct sensor_value *val, int raw_val, val->val2 = dval % 1000000LL; } -static inline void lis2dw12_channel_get_acc(struct device *dev, +static inline void lis2dw12_channel_get_acc(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -121,7 +121,7 @@ static inline void lis2dw12_channel_get_acc(struct device *dev, } } -static int lis2dw12_channel_get(struct device *dev, +static int lis2dw12_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -140,7 +140,7 @@ static int lis2dw12_channel_get(struct device *dev, return -ENOTSUP; } -static int lis2dw12_config(struct device *dev, enum sensor_channel chan, +static int lis2dw12_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -157,7 +157,8 @@ static int lis2dw12_config(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int lis2dw12_attr_set(struct device *dev, enum sensor_channel chan, +static int lis2dw12_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -175,7 +176,8 @@ static int lis2dw12_attr_set(struct device *dev, enum sensor_channel chan, return -ENOTSUP; } -static int lis2dw12_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lis2dw12_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct lis2dw12_data *lis2dw12 = dev->data; const struct lis2dw12_device_config *cfg = dev->config; @@ -211,7 +213,7 @@ static const struct sensor_driver_api lis2dw12_driver_api = { .channel_get = lis2dw12_channel_get, }; -static int lis2dw12_init_interface(struct device *dev) +static int lis2dw12_init_interface(const struct device *dev) { struct lis2dw12_data *lis2dw12 = dev->data; const struct lis2dw12_device_config *cfg = dev->config; @@ -253,7 +255,7 @@ static int lis2dw12_set_power_mode(struct lis2dw12_data *lis2dw12, return lis2dw12_write_reg(lis2dw12->ctx, LIS2DW12_CTRL1, ®val, 1); } -static int lis2dw12_init(struct device *dev) +static int lis2dw12_init(const struct device *dev) { struct lis2dw12_data *lis2dw12 = dev->data; const struct lis2dw12_device_config *cfg = dev->config; diff --git a/drivers/sensor/lis2dw12/lis2dw12.h b/drivers/sensor/lis2dw12/lis2dw12.h index 53a018e9c242fc..e02f7cbbb6040a 100644 --- a/drivers/sensor/lis2dw12/lis2dw12.h +++ b/drivers/sensor/lis2dw12/lis2dw12.h @@ -109,7 +109,7 @@ struct lis2dw12_data; /* sensor data */ struct lis2dw12_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; /* save sensitivity */ @@ -117,7 +117,7 @@ struct lis2dw12_data { stmdev_ctx_t *ctx; #ifdef CONFIG_LIS2DW12_TRIGGER - struct device *gpio; + const struct device *gpio; uint8_t gpio_pin; struct gpio_callback gpio_cb; sensor_trigger_handler_t drdy_handler; @@ -131,7 +131,7 @@ struct lis2dw12_data { struct k_sem gpio_sem; #elif defined(CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif /* CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD */ #endif /* CONFIG_LIS2DW12_TRIGGER */ #if DT_INST_SPI_DEV_HAS_CS_GPIOS(0) @@ -139,12 +139,12 @@ struct lis2dw12_data { #endif }; -int lis2dw12_i2c_init(struct device *dev); -int lis2dw12_spi_init(struct device *dev); +int lis2dw12_i2c_init(const struct device *dev); +int lis2dw12_spi_init(const struct device *dev); #ifdef CONFIG_LIS2DW12_TRIGGER -int lis2dw12_init_interrupt(struct device *dev); -int lis2dw12_trigger_set(struct device *dev, +int lis2dw12_init_interrupt(const struct device *dev); +int lis2dw12_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_LIS2DW12_TRIGGER */ diff --git a/drivers/sensor/lis2dw12/lis2dw12_i2c.c b/drivers/sensor/lis2dw12/lis2dw12_i2c.c index deb51f15064c03..b9587f56378820 100644 --- a/drivers/sensor/lis2dw12/lis2dw12_i2c.c +++ b/drivers/sensor/lis2dw12/lis2dw12_i2c.c @@ -41,7 +41,7 @@ stmdev_ctx_t lis2dw12_i2c_ctx = { .write_reg = (stmdev_write_ptr) lis2dw12_i2c_write, }; -int lis2dw12_i2c_init(struct device *dev) +int lis2dw12_i2c_init(const struct device *dev) { struct lis2dw12_data *data = dev->data; diff --git a/drivers/sensor/lis2dw12/lis2dw12_spi.c b/drivers/sensor/lis2dw12/lis2dw12_spi.c index 13f9681f0aca8e..0b18974d7fadbe 100644 --- a/drivers/sensor/lis2dw12/lis2dw12_spi.c +++ b/drivers/sensor/lis2dw12/lis2dw12_spi.c @@ -97,7 +97,7 @@ stmdev_ctx_t lis2dw12_spi_ctx = { .write_reg = (stmdev_write_ptr) lis2dw12_spi_write, }; -int lis2dw12_spi_init(struct device *dev) +int lis2dw12_spi_init(const struct device *dev) { struct lis2dw12_data *data = dev->data; diff --git a/drivers/sensor/lis2dw12/lis2dw12_trigger.c b/drivers/sensor/lis2dw12/lis2dw12_trigger.c index e8523862b7b14b..663f06bee9ac56 100644 --- a/drivers/sensor/lis2dw12/lis2dw12_trigger.c +++ b/drivers/sensor/lis2dw12/lis2dw12_trigger.c @@ -22,7 +22,7 @@ LOG_MODULE_DECLARE(LIS2DW12, CONFIG_SENSOR_LOG_LEVEL); /** * lis2dw12_enable_int - enable selected int pin to generate interrupt */ -static int lis2dw12_enable_int(struct device *dev, +static int lis2dw12_enable_int(const struct device *dev, enum sensor_trigger_type type, int enable) { const struct lis2dw12_device_config *cfg = dev->config; @@ -75,7 +75,7 @@ static int lis2dw12_enable_int(struct device *dev, /** * lis2dw12_trigger_set - link external trigger to event data ready */ -int lis2dw12_trigger_set(struct device *dev, +int lis2dw12_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -108,7 +108,7 @@ int lis2dw12_trigger_set(struct device *dev, } } -static int lis2dw12_handle_drdy_int(struct device *dev) +static int lis2dw12_handle_drdy_int(const struct device *dev) { struct lis2dw12_data *data = dev->data; @@ -125,7 +125,7 @@ static int lis2dw12_handle_drdy_int(struct device *dev) } #ifdef CONFIG_LIS2DW12_PULSE -static int lis2dw12_handle_single_tap_int(struct device *dev) +static int lis2dw12_handle_single_tap_int(const struct device *dev) { struct lis2dw12_data *data = dev->data; sensor_trigger_handler_t handler = data->tap_handler; @@ -142,7 +142,7 @@ static int lis2dw12_handle_single_tap_int(struct device *dev) return 0; } -static int lis2dw12_handle_double_tap_int(struct device *dev) +static int lis2dw12_handle_double_tap_int(const struct device *dev) { struct lis2dw12_data *data = dev->data; sensor_trigger_handler_t handler = data->double_tap_handler; @@ -166,7 +166,7 @@ static int lis2dw12_handle_double_tap_int(struct device *dev) */ static void lis2dw12_handle_interrupt(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct lis2dw12_data *lis2dw12 = dev->data; const struct lis2dw12_device_config *cfg = dev->config; lis2dw12_all_sources_t sources; @@ -189,7 +189,7 @@ static void lis2dw12_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void lis2dw12_gpio_callback(struct device *dev, +static void lis2dw12_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lis2dw12_data *lis2dw12 = @@ -212,7 +212,7 @@ static void lis2dw12_gpio_callback(struct device *dev, #ifdef CONFIG_LIS2DW12_TRIGGER_OWN_THREAD static void lis2dw12_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lis2dw12_data *lis2dw12 = dev->data; ARG_UNUSED(unused); @@ -234,7 +234,7 @@ static void lis2dw12_work_cb(struct k_work *work) } #endif /* CONFIG_LIS2DW12_TRIGGER_GLOBAL_THREAD */ -int lis2dw12_init_interrupt(struct device *dev) +int lis2dw12_init_interrupt(const struct device *dev) { struct lis2dw12_data *lis2dw12 = dev->data; const struct lis2dw12_device_config *cfg = dev->config; diff --git a/drivers/sensor/lis2mdl/lis2mdl.c b/drivers/sensor/lis2mdl/lis2mdl.c index fd2488fa403700..c97d4f3a04e07e 100644 --- a/drivers/sensor/lis2mdl/lis2mdl.c +++ b/drivers/sensor/lis2mdl/lis2mdl.c @@ -23,7 +23,8 @@ struct lis2mdl_data lis2mdl_data; LOG_MODULE_REGISTER(LIS2MDL, CONFIG_SENSOR_LOG_LEVEL); #ifdef CONFIG_LIS2MDL_MAG_ODR_RUNTIME -static int lis2mdl_set_odr(struct device *dev, const struct sensor_value *val) +static int lis2mdl_set_odr(const struct device *dev, + const struct sensor_value *val) { struct lis2mdl_data *lis2mdl = dev->data; lis2mdl_odr_t odr; @@ -53,7 +54,8 @@ static int lis2mdl_set_odr(struct device *dev, const struct sensor_value *val) } #endif /* CONFIG_LIS2MDL_MAG_ODR_RUNTIME */ -static int lis2mdl_set_hard_iron(struct device *dev, enum sensor_channel chan, +static int lis2mdl_set_hard_iron(const struct device *dev, + enum sensor_channel chan, const struct sensor_value *val) { struct lis2mdl_data *lis2mdl = dev->data; @@ -68,7 +70,7 @@ static int lis2mdl_set_hard_iron(struct device *dev, enum sensor_channel chan, return lis2mdl_mag_user_offset_set(lis2mdl->ctx, offset.u8bit); } -static void lis2mdl_channel_get_mag(struct device *dev, +static void lis2mdl_channel_get_mag(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -102,7 +104,7 @@ static void lis2mdl_channel_get_mag(struct device *dev, } /* read internal temperature */ -static void lis2mdl_channel_get_temp(struct device *dev, +static void lis2mdl_channel_get_temp(const struct device *dev, struct sensor_value *val) { struct lis2mdl_data *drv_data = dev->data; @@ -111,7 +113,8 @@ static void lis2mdl_channel_get_temp(struct device *dev, val->val2 = (drv_data->temp_sample % 100) * 10000; } -static int lis2mdl_channel_get(struct device *dev, enum sensor_channel chan, +static int lis2mdl_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { switch (chan) { @@ -132,7 +135,7 @@ static int lis2mdl_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2mdl_config(struct device *dev, enum sensor_channel chan, +static int lis2mdl_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -151,7 +154,7 @@ static int lis2mdl_config(struct device *dev, enum sensor_channel chan, return 0; } -static int lis2mdl_attr_set(struct device *dev, +static int lis2mdl_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -171,7 +174,7 @@ static int lis2mdl_attr_set(struct device *dev, return 0; } -static int lis2mdl_sample_fetch_mag(struct device *dev) +static int lis2mdl_sample_fetch_mag(const struct device *dev) { struct lis2mdl_data *lis2mdl = dev->data; union axis3bit16_t raw_mag; @@ -189,7 +192,7 @@ static int lis2mdl_sample_fetch_mag(struct device *dev) return 0; } -static int lis2mdl_sample_fetch_temp(struct device *dev) +static int lis2mdl_sample_fetch_temp(const struct device *dev) { struct lis2mdl_data *lis2mdl = dev->data; union axis1bit16_t raw_temp; @@ -208,7 +211,8 @@ static int lis2mdl_sample_fetch_temp(struct device *dev) return 0; } -static int lis2mdl_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lis2mdl_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_MAGN_X: @@ -240,7 +244,7 @@ static const struct sensor_driver_api lis2mdl_driver_api = { .channel_get = lis2mdl_channel_get, }; -static int lis2mdl_init_interface(struct device *dev) +static int lis2mdl_init_interface(const struct device *dev) { const struct lis2mdl_config *const config = dev->config; struct lis2mdl_data *lis2mdl = dev->data; @@ -286,7 +290,7 @@ static const struct lis2mdl_config lis2mdl_dev_config = { #endif }; -static int lis2mdl_init(struct device *dev) +static int lis2mdl_init(const struct device *dev) { struct lis2mdl_data *lis2mdl = dev->data; uint8_t wai; diff --git a/drivers/sensor/lis2mdl/lis2mdl.h b/drivers/sensor/lis2mdl/lis2mdl.h index ed18e972819bfd..8ad18cd21d72f1 100644 --- a/drivers/sensor/lis2mdl/lis2mdl.h +++ b/drivers/sensor/lis2mdl/lis2mdl.h @@ -29,7 +29,7 @@ union axis1bit16_t { struct lis2mdl_config { char *master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_LIS2MDL_TRIGGER char *gpio_name; uint32_t gpio_pin; @@ -49,7 +49,7 @@ struct lis2mdl_config { /* Sensor data */ struct lis2mdl_data { - struct device *bus; + const struct device *bus; uint16_t i2c_addr; int16_t mag[3]; int32_t temp_sample; @@ -63,11 +63,11 @@ struct lis2mdl_data { #endif #ifdef CONFIG_LIS2MDL_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t handler_drdy; - struct device *dev; + const struct device *dev; #if defined(CONFIG_LIS2MDL_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LIS2MDL_THREAD_STACK_SIZE); @@ -82,12 +82,12 @@ struct lis2mdl_data { #endif /* DT_INST_SPI_DEV_HAS_CS_GPIOS(0) */ }; -int lis2mdl_spi_init(struct device *dev); -int lis2mdl_i2c_init(struct device *dev); +int lis2mdl_spi_init(const struct device *dev); +int lis2mdl_i2c_init(const struct device *dev); #ifdef CONFIG_LIS2MDL_TRIGGER -int lis2mdl_init_interrupt(struct device *dev); -int lis2mdl_trigger_set(struct device *dev, +int lis2mdl_init_interrupt(const struct device *dev); +int lis2mdl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #endif /* CONFIG_LIS2MDL_TRIGGER */ diff --git a/drivers/sensor/lis2mdl/lis2mdl_i2c.c b/drivers/sensor/lis2mdl/lis2mdl_i2c.c index 84ce6c0b6bb4ba..737787a81f8cd8 100644 --- a/drivers/sensor/lis2mdl/lis2mdl_i2c.c +++ b/drivers/sensor/lis2mdl/lis2mdl_i2c.c @@ -21,7 +21,7 @@ #define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL LOG_MODULE_DECLARE(LIS2MDL); -static int lis2mdl_i2c_read(struct device *dev, uint8_t reg_addr, +static int lis2mdl_i2c_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct lis2mdl_data *data = dev->data; @@ -31,7 +31,7 @@ static int lis2mdl_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int lis2mdl_i2c_write(struct device *dev, uint8_t reg_addr, +static int lis2mdl_i2c_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct lis2mdl_data *data = dev->data; @@ -41,7 +41,7 @@ static int lis2mdl_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int lis2mdl_i2c_init(struct device *dev) +int lis2mdl_i2c_init(const struct device *dev) { struct lis2mdl_data *data = dev->data; diff --git a/drivers/sensor/lis2mdl/lis2mdl_spi.c b/drivers/sensor/lis2mdl/lis2mdl_spi.c index 69f72835bb6048..8c48672d501525 100644 --- a/drivers/sensor/lis2mdl/lis2mdl_spi.c +++ b/drivers/sensor/lis2mdl/lis2mdl_spi.c @@ -21,7 +21,7 @@ #define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL LOG_MODULE_DECLARE(LIS2MDL); -static int lis2mdl_spi_read(struct device *dev, uint8_t reg_addr, +static int lis2mdl_spi_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2mdl_data *data = dev->data; @@ -63,7 +63,7 @@ static int lis2mdl_spi_read(struct device *dev, uint8_t reg_addr, return 0; } -static int lis2mdl_spi_write(struct device *dev, uint8_t reg_addr, +static int lis2mdl_spi_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lis2mdl_data *data = dev->data; @@ -97,7 +97,7 @@ static int lis2mdl_spi_write(struct device *dev, uint8_t reg_addr, return 0; } -int lis2mdl_spi_init(struct device *dev) +int lis2mdl_spi_init(const struct device *dev) { struct lis2mdl_data *data = dev->data; diff --git a/drivers/sensor/lis2mdl/lis2mdl_trigger.c b/drivers/sensor/lis2mdl/lis2mdl_trigger.c index 07515154c1073e..9d3b19d88249be 100644 --- a/drivers/sensor/lis2mdl/lis2mdl_trigger.c +++ b/drivers/sensor/lis2mdl/lis2mdl_trigger.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(LIS2MDL, CONFIG_SENSOR_LOG_LEVEL); -static int lis2mdl_enable_int(struct device *dev, int enable) +static int lis2mdl_enable_int(const struct device *dev, int enable) { struct lis2mdl_data *lis2mdl = dev->data; @@ -27,7 +27,7 @@ static int lis2mdl_enable_int(struct device *dev, int enable) } /* link external trigger to event data ready */ -int lis2mdl_trigger_set(struct device *dev, +int lis2mdl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -52,7 +52,7 @@ int lis2mdl_trigger_set(struct device *dev, /* handle the drdy event: read data and call handler if registered any */ static void lis2mdl_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lis2mdl_data *lis2mdl = dev->data; const struct lis2mdl_config *const config = dev->config; struct sensor_trigger drdy_trigger = { @@ -67,7 +67,7 @@ static void lis2mdl_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void lis2mdl_gpio_callback(struct device *dev, +static void lis2mdl_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lis2mdl_data *lis2mdl = @@ -88,7 +88,7 @@ static void lis2mdl_gpio_callback(struct device *dev, #ifdef CONFIG_LIS2MDL_TRIGGER_OWN_THREAD static void lis2mdl_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lis2mdl_data *lis2mdl = dev->data; ARG_UNUSED(unused); @@ -110,7 +110,7 @@ static void lis2mdl_work_cb(struct k_work *work) } #endif -int lis2mdl_init_interrupt(struct device *dev) +int lis2mdl_init_interrupt(const struct device *dev) { struct lis2mdl_data *lis2mdl = dev->data; const struct lis2mdl_config *const config = dev->config; diff --git a/drivers/sensor/lis3mdl/lis3mdl.c b/drivers/sensor/lis3mdl/lis3mdl.c index 6412160e69a6a2..9d660cf1820cb8 100644 --- a/drivers/sensor/lis3mdl/lis3mdl.c +++ b/drivers/sensor/lis3mdl/lis3mdl.c @@ -26,7 +26,7 @@ static void lis3mdl_convert(struct sensor_value *val, int16_t raw_val, val->val2 = (((int64_t)raw_val % divider) * 1000000L) / divider; } -static int lis3mdl_channel_get(struct device *dev, +static int lis3mdl_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -58,7 +58,7 @@ static int lis3mdl_channel_get(struct device *dev, return 0; } -int lis3mdl_sample_fetch(struct device *dev, enum sensor_channel chan) +int lis3mdl_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct lis3mdl_data *drv_data = dev->data; int16_t buf[4]; @@ -100,7 +100,7 @@ static const struct sensor_driver_api lis3mdl_driver_api = { .channel_get = lis3mdl_channel_get, }; -int lis3mdl_init(struct device *dev) +int lis3mdl_init(const struct device *dev) { struct lis3mdl_data *drv_data = dev->data; uint8_t chip_cfg[6]; diff --git a/drivers/sensor/lis3mdl/lis3mdl.h b/drivers/sensor/lis3mdl/lis3mdl.h index c326181d567245..70de0bcdade7e6 100644 --- a/drivers/sensor/lis3mdl/lis3mdl.h +++ b/drivers/sensor/lis3mdl/lis3mdl.h @@ -111,14 +111,14 @@ static const uint16_t lis3mdl_magn_gain[] = { }; struct lis3mdl_data { - struct device *i2c; + const struct device *i2c; int16_t x_sample; int16_t y_sample; int16_t z_sample; int16_t temp_sample; #ifdef CONFIG_LIS3MDL_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; @@ -130,20 +130,20 @@ struct lis3mdl_data { struct k_thread thread; #elif defined(CONFIG_LIS3MDL_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_LIS3MDL_TRIGGER */ }; #ifdef CONFIG_LIS3MDL_TRIGGER -int lis3mdl_trigger_set(struct device *dev, +int lis3mdl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lis3mdl_sample_fetch(struct device *dev, enum sensor_channel chan); +int lis3mdl_sample_fetch(const struct device *dev, enum sensor_channel chan); -int lis3mdl_init_interrupt(struct device *dev); +int lis3mdl_init_interrupt(const struct device *dev); #endif #endif /* __SENSOR_LIS3MDL__ */ diff --git a/drivers/sensor/lis3mdl/lis3mdl_trigger.c b/drivers/sensor/lis3mdl/lis3mdl_trigger.c index c48128d7a68e04..22977c3bb27f20 100644 --- a/drivers/sensor/lis3mdl/lis3mdl_trigger.c +++ b/drivers/sensor/lis3mdl/lis3mdl_trigger.c @@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(LIS3MDL, CONFIG_SENSOR_LOG_LEVEL); -int lis3mdl_trigger_set(struct device *dev, +int lis3mdl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -52,7 +52,7 @@ int lis3mdl_trigger_set(struct device *dev, return 0; } -static void lis3mdl_gpio_callback(struct device *dev, +static void lis3mdl_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lis3mdl_data *drv_data = @@ -73,7 +73,7 @@ static void lis3mdl_gpio_callback(struct device *dev, static void lis3mdl_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lis3mdl_data *drv_data = dev->data; if (drv_data->data_ready_handler != NULL) { @@ -89,7 +89,7 @@ static void lis3mdl_thread_cb(void *arg) #ifdef CONFIG_LIS3MDL_TRIGGER_OWN_THREAD static void lis3mdl_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lis3mdl_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -111,7 +111,7 @@ static void lis3mdl_work_cb(struct k_work *work) } #endif -int lis3mdl_init_interrupt(struct device *dev) +int lis3mdl_init_interrupt(const struct device *dev) { struct lis3mdl_data *drv_data = dev->data; diff --git a/drivers/sensor/lps22hb/lps22hb.c b/drivers/sensor/lps22hb/lps22hb.c index 171d50a77f328f..bd1d9f06eea9ef 100644 --- a/drivers/sensor/lps22hb/lps22hb.c +++ b/drivers/sensor/lps22hb/lps22hb.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(LPS22HB, CONFIG_SENSOR_LOG_LEVEL); -static inline int lps22hb_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lps22hb_set_odr_raw(const struct device *dev, uint8_t odr) { struct lps22hb_data *data = dev->data; const struct lps22hb_config *config = dev->config; @@ -31,7 +31,7 @@ static inline int lps22hb_set_odr_raw(struct device *dev, uint8_t odr) odr << LPS22HB_SHIFT_CTRL_REG1_ODR); } -static int lps22hb_sample_fetch(struct device *dev, +static int lps22hb_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct lps22hb_data *data = dev->data; @@ -73,7 +73,7 @@ static inline void lps22hb_temp_convert(struct sensor_value *val, val->val2 = ((int32_t)raw_val % 100) * 10000; } -static int lps22hb_channel_get(struct device *dev, +static int lps22hb_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -95,7 +95,7 @@ static const struct sensor_driver_api lps22hb_api_funcs = { .channel_get = lps22hb_channel_get, }; -static int lps22hb_init_chip(struct device *dev) +static int lps22hb_init_chip(const struct device *dev) { struct lps22hb_data *data = dev->data; const struct lps22hb_config *config = dev->config; @@ -131,7 +131,7 @@ static int lps22hb_init_chip(struct device *dev) return -EIO; } -static int lps22hb_init(struct device *dev) +static int lps22hb_init(const struct device *dev) { const struct lps22hb_config * const config = dev->config; struct lps22hb_data *data = dev->data; diff --git a/drivers/sensor/lps22hb/lps22hb.h b/drivers/sensor/lps22hb/lps22hb.h index 3118ee318a8b79..31ad74d5c97e66 100644 --- a/drivers/sensor/lps22hb/lps22hb.h +++ b/drivers/sensor/lps22hb/lps22hb.h @@ -159,7 +159,7 @@ struct lps22hb_config { }; struct lps22hb_data { - struct device *i2c_master; + const struct device *i2c_master; int32_t sample_press; int16_t sample_temp; }; diff --git a/drivers/sensor/lps22hh/lps22hh.c b/drivers/sensor/lps22hh/lps22hh.c index f1e9cba9c4196d..1fd7a1d92b9773 100644 --- a/drivers/sensor/lps22hh/lps22hh.c +++ b/drivers/sensor/lps22hh/lps22hh.c @@ -22,14 +22,14 @@ LOG_MODULE_REGISTER(LPS22HH, CONFIG_SENSOR_LOG_LEVEL); -static inline int lps22hh_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lps22hh_set_odr_raw(const struct device *dev, uint8_t odr) { struct lps22hh_data *data = dev->data; return lps22hh_data_rate_set(data->ctx, odr); } -static int lps22hh_sample_fetch(struct device *dev, +static int lps22hh_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct lps22hh_data *data = dev->data; @@ -71,7 +71,7 @@ static inline void lps22hh_temp_convert(struct sensor_value *val, val->val2 = ((int32_t)raw_val % 100) * 10000; } -static int lps22hh_channel_get(struct device *dev, +static int lps22hh_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -90,7 +90,7 @@ static int lps22hh_channel_get(struct device *dev, static const uint16_t lps22hh_map[] = {0, 1, 10, 25, 50, 75, 100, 200}; -static int lps22hh_odr_set(struct device *dev, uint16_t freq) +static int lps22hh_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -113,7 +113,8 @@ static int lps22hh_odr_set(struct device *dev, uint16_t freq) return 0; } -static int lps22hh_attr_set(struct device *dev, enum sensor_channel chan, +static int lps22hh_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -142,7 +143,7 @@ static const struct sensor_driver_api lps22hh_api_funcs = { #endif }; -static int lps22hh_init_chip(struct device *dev) +static int lps22hh_init_chip(const struct device *dev) { struct lps22hh_data *data = dev->data; uint8_t chip_id; @@ -170,7 +171,7 @@ static int lps22hh_init_chip(struct device *dev) return 0; } -static int lps22hh_init(struct device *dev) +static int lps22hh_init(const struct device *dev) { const struct lps22hh_config * const config = dev->config; struct lps22hh_data *data = dev->data; diff --git a/drivers/sensor/lps22hh/lps22hh.h b/drivers/sensor/lps22hh/lps22hh.h index 6cacf429920fbc..6d2e61fdf28763 100644 --- a/drivers/sensor/lps22hh/lps22hh.h +++ b/drivers/sensor/lps22hh/lps22hh.h @@ -32,7 +32,7 @@ union axis1bit16_t { struct lps22hh_config { char *master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_LPS22HH_TRIGGER const char *drdy_port; uint8_t drdy_pin; @@ -51,7 +51,7 @@ struct lps22hh_config { }; struct lps22hh_data { - struct device *bus; + const struct device *bus; int32_t sample_press; int16_t sample_temp; @@ -64,13 +64,13 @@ struct lps22hh_data { #endif #ifdef CONFIG_LPS22HH_TRIGGER - struct device *gpio; + const struct device *gpio; uint32_t pin; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; sensor_trigger_handler_t handler_drdy; - struct device *dev; + const struct device *dev; #if defined(CONFIG_LPS22HH_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LPS22HH_THREAD_STACK_SIZE); @@ -86,15 +86,15 @@ struct lps22hh_data { #endif }; -int lps22hh_i2c_init(struct device *dev); -int lps22hh_spi_init(struct device *dev); +int lps22hh_i2c_init(const struct device *dev); +int lps22hh_spi_init(const struct device *dev); #ifdef CONFIG_LPS22HH_TRIGGER -int lps22hh_trigger_set(struct device *dev, +int lps22hh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lps22hh_init_interrupt(struct device *dev); +int lps22hh_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_LPS22HH_LPS22HH_H_ */ diff --git a/drivers/sensor/lps22hh/lps22hh_i2c.c b/drivers/sensor/lps22hh/lps22hh_i2c.c index 3744dc5c602cc4..1d2710038e1563 100644 --- a/drivers/sensor/lps22hh/lps22hh_i2c.c +++ b/drivers/sensor/lps22hh/lps22hh_i2c.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(LPS22HH, CONFIG_SENSOR_LOG_LEVEL); -static int lps22hh_i2c_read(struct device *dev, uint8_t reg_addr, +static int lps22hh_i2c_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct lps22hh_data *data = dev->data; @@ -30,7 +30,7 @@ static int lps22hh_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int lps22hh_i2c_write(struct device *dev, uint8_t reg_addr, +static int lps22hh_i2c_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct lps22hh_data *data = dev->data; @@ -40,7 +40,7 @@ static int lps22hh_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int lps22hh_i2c_init(struct device *dev) +int lps22hh_i2c_init(const struct device *dev) { struct lps22hh_data *data = dev->data; diff --git a/drivers/sensor/lps22hh/lps22hh_spi.c b/drivers/sensor/lps22hh/lps22hh_spi.c index 9dcd05322052d6..c8ec5286e1a105 100644 --- a/drivers/sensor/lps22hh/lps22hh_spi.c +++ b/drivers/sensor/lps22hh/lps22hh_spi.c @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(LPS22HH, CONFIG_SENSOR_LOG_LEVEL); -static int lps22hh_spi_read(struct device *dev, uint8_t reg_addr, +static int lps22hh_spi_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lps22hh_data *data = dev->data; @@ -63,7 +63,7 @@ static int lps22hh_spi_read(struct device *dev, uint8_t reg_addr, return 0; } -static int lps22hh_spi_write(struct device *dev, uint8_t reg_addr, +static int lps22hh_spi_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lps22hh_data *data = dev->data; @@ -97,7 +97,7 @@ static int lps22hh_spi_write(struct device *dev, uint8_t reg_addr, return 0; } -int lps22hh_spi_init(struct device *dev) +int lps22hh_spi_init(const struct device *dev) { struct lps22hh_data *data = dev->data; diff --git a/drivers/sensor/lps22hh/lps22hh_trigger.c b/drivers/sensor/lps22hh/lps22hh_trigger.c index 06625f4352353a..57cfc0aa895e86 100644 --- a/drivers/sensor/lps22hh/lps22hh_trigger.c +++ b/drivers/sensor/lps22hh/lps22hh_trigger.c @@ -22,7 +22,7 @@ LOG_MODULE_DECLARE(LPS22HH, CONFIG_SENSOR_LOG_LEVEL); /** * lps22hh_enable_int - enable selected int pin to generate interrupt */ -static int lps22hh_enable_int(struct device *dev, int enable) +static int lps22hh_enable_int(const struct device *dev, int enable) { struct lps22hh_data *lps22hh = dev->data; lps22hh_reg_t int_route; @@ -38,7 +38,7 @@ static int lps22hh_enable_int(struct device *dev, int enable) /** * lps22hh_trigger_set - link external trigger to event data ready */ -int lps22hh_trigger_set(struct device *dev, +int lps22hh_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -69,7 +69,7 @@ int lps22hh_trigger_set(struct device *dev, */ static void lps22hh_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lps22hh_data *lps22hh = dev->data; const struct lps22hh_config *cfg = dev->config; struct sensor_trigger drdy_trigger = { @@ -84,7 +84,7 @@ static void lps22hh_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void lps22hh_gpio_callback(struct device *dev, +static void lps22hh_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lps22hh_data *lps22hh = @@ -106,7 +106,7 @@ static void lps22hh_gpio_callback(struct device *dev, #ifdef CONFIG_LPS22HH_TRIGGER_OWN_THREAD static void lps22hh_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lps22hh_data *lps22hh = dev->data; ARG_UNUSED(unused); @@ -128,7 +128,7 @@ static void lps22hh_work_cb(struct k_work *work) } #endif /* CONFIG_LPS22HH_TRIGGER_GLOBAL_THREAD */ -int lps22hh_init_interrupt(struct device *dev) +int lps22hh_init_interrupt(const struct device *dev) { struct lps22hh_data *lps22hh = dev->data; const struct lps22hh_config *cfg = dev->config; diff --git a/drivers/sensor/lps25hb/lps25hb.c b/drivers/sensor/lps25hb/lps25hb.c index c8fed57ed77172..d19cf78ed018d9 100644 --- a/drivers/sensor/lps25hb/lps25hb.c +++ b/drivers/sensor/lps25hb/lps25hb.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(LPS25HB, CONFIG_SENSOR_LOG_LEVEL); -static inline int lps25hb_power_ctrl(struct device *dev, uint8_t value) +static inline int lps25hb_power_ctrl(const struct device *dev, uint8_t value) { struct lps25hb_data *data = dev->data; const struct lps25hb_config *config = dev->config; @@ -31,7 +31,7 @@ static inline int lps25hb_power_ctrl(struct device *dev, uint8_t value) value << LPS25HB_SHIFT_CTRL_REG1_PD); } -static inline int lps25hb_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lps25hb_set_odr_raw(const struct device *dev, uint8_t odr) { struct lps25hb_data *data = dev->data; const struct lps25hb_config *config = dev->config; @@ -42,7 +42,7 @@ static inline int lps25hb_set_odr_raw(struct device *dev, uint8_t odr) odr << LPS25HB_SHIFT_CTRL_REG1_ODR); } -static int lps25hb_sample_fetch(struct device *dev, +static int lps25hb_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct lps25hb_data *data = dev->data; @@ -89,7 +89,7 @@ static inline void lps25hb_temp_convert(struct sensor_value *val, val->val2 = uval % 1000000; } -static int lps25hb_channel_get(struct device *dev, +static int lps25hb_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -111,7 +111,7 @@ static const struct sensor_driver_api lps25hb_api_funcs = { .channel_get = lps25hb_channel_get, }; -static int lps25hb_init_chip(struct device *dev) +static int lps25hb_init_chip(const struct device *dev) { struct lps25hb_data *data = dev->data; const struct lps25hb_config *config = dev->config; @@ -160,7 +160,7 @@ static int lps25hb_init_chip(struct device *dev) return -EIO; } -static int lps25hb_init(struct device *dev) +static int lps25hb_init(const struct device *dev) { const struct lps25hb_config * const config = dev->config; struct lps25hb_data *data = dev->data; diff --git a/drivers/sensor/lps25hb/lps25hb.h b/drivers/sensor/lps25hb/lps25hb.h index 997d6d427fcf54..b5ed4cd5163f37 100644 --- a/drivers/sensor/lps25hb/lps25hb.h +++ b/drivers/sensor/lps25hb/lps25hb.h @@ -152,7 +152,7 @@ struct lps25hb_config { }; struct lps25hb_data { - struct device *i2c_master; + const struct device *i2c_master; int32_t sample_press; int16_t sample_temp; diff --git a/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.c b/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.c index 9dc1605571e0ca..ca16068937bfba 100644 --- a/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.c +++ b/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(lsm303dlhc_magn, CONFIG_SENSOR_LOG_LEVEL); #include "lsm303dlhc_magn.h" -static int lsm303dlhc_sample_fetch(struct device *dev, +static int lsm303dlhc_sample_fetch(const struct device *dev, enum sensor_channel chan) { const struct lsm303dlhc_magn_config *config = dev->config; @@ -59,7 +59,7 @@ static void lsm303dlhc_convert(struct sensor_value *val, val->val2 = (1000000 * raw_val / LSM303DLHC_MAGN_LSB_GAUSS) % 1000000; } -static int lsm303dlhc_channel_get(struct device *dev, +static int lsm303dlhc_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -91,7 +91,7 @@ static const struct sensor_driver_api lsm303dlhc_magn_driver_api = { .channel_get = lsm303dlhc_channel_get, }; -static int lsm303dlhc_magn_init(struct device *dev) +static int lsm303dlhc_magn_init(const struct device *dev) { const struct lsm303dlhc_magn_config *config = dev->config; struct lsm303dlhc_magn_data *drv_data = dev->data; diff --git a/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.h b/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.h index 7da1495cbaa82a..7c6732d28ebdd3 100644 --- a/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.h +++ b/drivers/sensor/lsm303dlhc_magn/lsm303dlhc_magn.h @@ -65,7 +65,7 @@ #define LSM303DLHC_SR_REG_M 0x09 struct lsm303dlhc_magn_data { - struct device *i2c; + const struct device *i2c; int16_t magn_x; int16_t magn_y; diff --git a/drivers/sensor/lsm6ds0/lsm6ds0.c b/drivers/sensor/lsm6ds0/lsm6ds0.c index d0c2fcc5fbfccc..ac118dda6558e0 100644 --- a/drivers/sensor/lsm6ds0/lsm6ds0.c +++ b/drivers/sensor/lsm6ds0/lsm6ds0.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(LSM6DS0, CONFIG_SENSOR_LOG_LEVEL); -static inline int lsm6ds0_reboot(struct device *dev) +static inline int lsm6ds0_reboot(const struct device *dev) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -39,7 +39,7 @@ static inline int lsm6ds0_reboot(struct device *dev) return 0; } -static inline int lsm6ds0_accel_axis_ctrl(struct device *dev, int x_en, +static inline int lsm6ds0_accel_axis_ctrl(const struct device *dev, int x_en, int y_en, int z_en) { struct lsm6ds0_data *data = dev->data; @@ -56,7 +56,7 @@ static inline int lsm6ds0_accel_axis_ctrl(struct device *dev, int x_en, state); } -static int lsm6ds0_accel_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6ds0_accel_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -71,7 +71,7 @@ static int lsm6ds0_accel_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6ds0_accel_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6ds0_accel_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -86,7 +86,8 @@ static int lsm6ds0_accel_set_odr_raw(struct device *dev, uint8_t odr) return 0; } -static inline int lsm6ds0_gyro_axis_ctrl(struct device *dev, int x_en, int y_en, +static inline int lsm6ds0_gyro_axis_ctrl(const struct device *dev, int x_en, + int y_en, int z_en) { struct lsm6ds0_data *data = dev->data; @@ -103,7 +104,7 @@ static inline int lsm6ds0_gyro_axis_ctrl(struct device *dev, int x_en, int y_en, state); } -static int lsm6ds0_gyro_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6ds0_gyro_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -118,7 +119,7 @@ static int lsm6ds0_gyro_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6ds0_gyro_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6ds0_gyro_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -133,7 +134,7 @@ static int lsm6ds0_gyro_set_odr_raw(struct device *dev, uint8_t odr) return 0; } -static int lsm6ds0_sample_fetch_accel(struct device *dev) +static int lsm6ds0_sample_fetch_accel(const struct device *dev) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -161,7 +162,7 @@ static int lsm6ds0_sample_fetch_accel(struct device *dev) return 0; } -static int lsm6ds0_sample_fetch_gyro(struct device *dev) +static int lsm6ds0_sample_fetch_gyro(const struct device *dev) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -190,7 +191,7 @@ static int lsm6ds0_sample_fetch_gyro(struct device *dev) } #if defined(CONFIG_LSM6DS0_ENABLE_TEMP) -static int lsm6ds0_sample_fetch_temp(struct device *dev) +static int lsm6ds0_sample_fetch_temp(const struct device *dev) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -209,7 +210,8 @@ static int lsm6ds0_sample_fetch_temp(struct device *dev) } #endif -static int lsm6ds0_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lsm6ds0_sample_fetch(const struct device *dev, + enum sensor_channel chan) { __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ACCEL_XYZ || @@ -368,7 +370,7 @@ static void lsm6ds0_gyro_channel_get_temp(struct sensor_value *val, } #endif -static int lsm6ds0_channel_get(struct device *dev, +static int lsm6ds0_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -404,7 +406,7 @@ static const struct sensor_driver_api lsm6ds0_api_funcs = { .channel_get = lsm6ds0_channel_get, }; -static int lsm6ds0_init_chip(struct device *dev) +static int lsm6ds0_init_chip(const struct device *dev) { struct lsm6ds0_data *data = dev->data; const struct lsm6ds0_config *config = dev->config; @@ -480,7 +482,7 @@ static int lsm6ds0_init_chip(struct device *dev) return 0; } -static int lsm6ds0_init(struct device *dev) +static int lsm6ds0_init(const struct device *dev) { const struct lsm6ds0_config * const config = dev->config; struct lsm6ds0_data *data = dev->data; diff --git a/drivers/sensor/lsm6ds0/lsm6ds0.h b/drivers/sensor/lsm6ds0/lsm6ds0.h index 7bbb1a351a2bfe..7b5e6027955237 100644 --- a/drivers/sensor/lsm6ds0/lsm6ds0.h +++ b/drivers/sensor/lsm6ds0/lsm6ds0.h @@ -465,7 +465,7 @@ struct lsm6ds0_config { }; struct lsm6ds0_data { - struct device *i2c_master; + const struct device *i2c_master; #if defined(CONFIG_LSM6DS0_ACCEL_ENABLE_X_AXIS) int accel_sample_x; diff --git a/drivers/sensor/lsm6dsl/lsm6dsl.c b/drivers/sensor/lsm6dsl/lsm6dsl.c index b08134cfde7ddd..aa6c7cb1b2abe6 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl.c @@ -88,7 +88,7 @@ static int lsm6dsl_gyro_range_to_fs_val(int32_t range) } #endif -static inline int lsm6dsl_reboot(struct device *dev) +static inline int lsm6dsl_reboot(const struct device *dev) { struct lsm6dsl_data *data = dev->data; @@ -104,7 +104,7 @@ static inline int lsm6dsl_reboot(struct device *dev) return 0; } -static int lsm6dsl_accel_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6dsl_accel_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6dsl_data *data = dev->data; @@ -120,7 +120,7 @@ static int lsm6dsl_accel_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6dsl_accel_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6dsl_accel_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6dsl_data *data = dev->data; @@ -136,7 +136,7 @@ static int lsm6dsl_accel_set_odr_raw(struct device *dev, uint8_t odr) return 0; } -static int lsm6dsl_gyro_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6dsl_gyro_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6dsl_data *data = dev->data; @@ -159,7 +159,7 @@ static int lsm6dsl_gyro_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6dsl_gyro_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6dsl_gyro_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6dsl_data *data = dev->data; @@ -174,7 +174,7 @@ static int lsm6dsl_gyro_set_odr_raw(struct device *dev, uint8_t odr) } #ifdef LSM6DSL_ACCEL_ODR_RUNTIME -static int lsm6dsl_accel_odr_set(struct device *dev, uint16_t freq) +static int lsm6dsl_accel_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -193,7 +193,7 @@ static int lsm6dsl_accel_odr_set(struct device *dev, uint16_t freq) #endif #ifdef LSM6DSL_ACCEL_FS_RUNTIME -static int lsm6dsl_accel_range_set(struct device *dev, int32_t range) +static int lsm6dsl_accel_range_set(const struct device *dev, int32_t range) { int fs; struct lsm6dsl_data *data = dev->data; @@ -214,9 +214,10 @@ static int lsm6dsl_accel_range_set(struct device *dev, int32_t range) } #endif -static int lsm6dsl_accel_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dsl_accel_config(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { #ifdef LSM6DSL_ACCEL_FS_RUNTIME @@ -236,7 +237,7 @@ static int lsm6dsl_accel_config(struct device *dev, enum sensor_channel chan, } #ifdef LSM6DSL_GYRO_ODR_RUNTIME -static int lsm6dsl_gyro_odr_set(struct device *dev, uint16_t freq) +static int lsm6dsl_gyro_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -255,7 +256,7 @@ static int lsm6dsl_gyro_odr_set(struct device *dev, uint16_t freq) #endif #ifdef LSM6DSL_GYRO_FS_RUNTIME -static int lsm6dsl_gyro_range_set(struct device *dev, int32_t range) +static int lsm6dsl_gyro_range_set(const struct device *dev, int32_t range) { int fs; struct lsm6dsl_data *data = dev->data; @@ -276,9 +277,10 @@ static int lsm6dsl_gyro_range_set(struct device *dev, int32_t range) } #endif -static int lsm6dsl_gyro_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dsl_gyro_config(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { #ifdef LSM6DSL_GYRO_FS_RUNTIME @@ -297,9 +299,10 @@ static int lsm6dsl_gyro_config(struct device *dev, enum sensor_channel chan, return 0; } -static int lsm6dsl_attr_set(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dsl_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -314,7 +317,7 @@ static int lsm6dsl_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int lsm6dsl_sample_fetch_accel(struct device *dev) +static int lsm6dsl_sample_fetch_accel(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t buf[6]; @@ -335,7 +338,7 @@ static int lsm6dsl_sample_fetch_accel(struct device *dev) return 0; } -static int lsm6dsl_sample_fetch_gyro(struct device *dev) +static int lsm6dsl_sample_fetch_gyro(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t buf[6]; @@ -357,7 +360,7 @@ static int lsm6dsl_sample_fetch_gyro(struct device *dev) } #if defined(CONFIG_LSM6DSL_ENABLE_TEMP) -static int lsm6dsl_sample_fetch_temp(struct device *dev) +static int lsm6dsl_sample_fetch_temp(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t buf[2]; @@ -376,7 +379,7 @@ static int lsm6dsl_sample_fetch_temp(struct device *dev) #endif #if defined(CONFIG_LSM6DSL_EXT0_LIS2MDL) -static int lsm6dsl_sample_fetch_magn(struct device *dev) +static int lsm6dsl_sample_fetch_magn(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t buf[6]; @@ -397,7 +400,7 @@ static int lsm6dsl_sample_fetch_magn(struct device *dev) } #endif #if defined(CONFIG_LSM6DSL_EXT0_LPS22HB) -static int lsm6dsl_sample_fetch_press(struct device *dev) +static int lsm6dsl_sample_fetch_press(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t buf[5]; @@ -417,7 +420,8 @@ static int lsm6dsl_sample_fetch_press(struct device *dev) } #endif -static int lsm6dsl_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lsm6dsl_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -647,7 +651,7 @@ static inline void lps22hb_temp_convert(struct sensor_value *val, } #endif -static int lsm6dsl_channel_get(struct device *dev, +static int lsm6dsl_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -704,7 +708,7 @@ static const struct sensor_driver_api lsm6dsl_api_funcs = { .channel_get = lsm6dsl_channel_get, }; -static int lsm6dsl_init_chip(struct device *dev) +static int lsm6dsl_init_chip(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t chip_id; @@ -777,7 +781,7 @@ static struct lsm6dsl_config lsm6dsl_config = { .comm_master_dev_name = DT_INST_BUS_LABEL(0), }; -static int lsm6dsl_init(struct device *dev) +static int lsm6dsl_init(const struct device *dev) { const struct lsm6dsl_config * const config = dev->config; struct lsm6dsl_data *data = dev->data; diff --git a/drivers/sensor/lsm6dsl/lsm6dsl.h b/drivers/sensor/lsm6dsl/lsm6dsl.h index 4c43a608e9ba7d..d0cb769b4e0868 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl.h +++ b/drivers/sensor/lsm6dsl/lsm6dsl.h @@ -621,7 +621,7 @@ struct lsm6dsl_transfer_function { }; struct lsm6dsl_data { - struct device *comm_master; + const struct device *comm_master; int accel_sample_x; int accel_sample_y; int accel_sample_z; @@ -650,7 +650,7 @@ struct lsm6dsl_data { uint8_t gyro_fs; #ifdef CONFIG_LSM6DSL_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; @@ -662,25 +662,26 @@ struct lsm6dsl_data { struct k_sem gpio_sem; #elif defined(CONFIG_LSM6DSL_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_LSM6DSL_TRIGGER */ }; -int lsm6dsl_spi_init(struct device *dev); -int lsm6dsl_i2c_init(struct device *dev); +int lsm6dsl_spi_init(const struct device *dev); +int lsm6dsl_i2c_init(const struct device *dev); #if defined(CONFIG_LSM6DSL_SENSORHUB) -int lsm6dsl_shub_init_external_chip(struct device *dev); -int lsm6dsl_shub_read_external_chip(struct device *dev, uint8_t *buf, uint8_t len); +int lsm6dsl_shub_init_external_chip(const struct device *dev); +int lsm6dsl_shub_read_external_chip(const struct device *dev, uint8_t *buf, + uint8_t len); #endif #ifdef CONFIG_LSM6DSL_TRIGGER -int lsm6dsl_trigger_set(struct device *dev, +int lsm6dsl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lsm6dsl_init_interrupt(struct device *dev); +int lsm6dsl_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_LSM6DSL_LSM6DSL_H_ */ diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_i2c.c b/drivers/sensor/lsm6dsl/lsm6dsl_i2c.c index ba30656317751c..4c6cfd7f50975e 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_i2c.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_i2c.c @@ -56,7 +56,7 @@ static const struct lsm6dsl_transfer_function lsm6dsl_i2c_transfer_fn = { .update_reg = lsm6dsl_i2c_update_reg, }; -int lsm6dsl_i2c_init(struct device *dev) +int lsm6dsl_i2c_init(const struct device *dev) { struct lsm6dsl_data *data = dev->data; diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c index 5bc07572d9cbc5..25634370997b30 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_shub.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_shub.c @@ -361,7 +361,8 @@ static int lsm6dsl_shub_set_data_channel(struct lsm6dsl_data *data) return 0; } -int lsm6dsl_shub_read_external_chip(struct device *dev, uint8_t *buf, uint8_t len) +int lsm6dsl_shub_read_external_chip(const struct device *dev, uint8_t *buf, + uint8_t len) { struct lsm6dsl_data *data = dev->data; @@ -370,7 +371,7 @@ int lsm6dsl_shub_read_external_chip(struct device *dev, uint8_t *buf, uint8_t le return 0; } -int lsm6dsl_shub_init_external_chip(struct device *dev) +int lsm6dsl_shub_init_external_chip(const struct device *dev) { struct lsm6dsl_data *data = dev->data; uint8_t i; diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_spi.c b/drivers/sensor/lsm6dsl/lsm6dsl_spi.c index a0969dcb8c457e..96eb8b6416238c 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_spi.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_spi.c @@ -142,7 +142,7 @@ static const struct lsm6dsl_transfer_function lsm6dsl_spi_transfer_fn = { .update_reg = lsm6dsl_spi_update_reg, }; -int lsm6dsl_spi_init(struct device *dev) +int lsm6dsl_spi_init(const struct device *dev) { struct lsm6dsl_data *data = dev->data; diff --git a/drivers/sensor/lsm6dsl/lsm6dsl_trigger.c b/drivers/sensor/lsm6dsl/lsm6dsl_trigger.c index a0227efd6825db..09d77d08ef0a32 100644 --- a/drivers/sensor/lsm6dsl/lsm6dsl_trigger.c +++ b/drivers/sensor/lsm6dsl/lsm6dsl_trigger.c @@ -40,7 +40,7 @@ static inline void handle_irq(struct lsm6dsl_data *drv_data) #endif } -int lsm6dsl_trigger_set(struct device *dev, +int lsm6dsl_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -65,7 +65,7 @@ int lsm6dsl_trigger_set(struct device *dev, return 0; } -static void lsm6dsl_gpio_callback(struct device *dev, +static void lsm6dsl_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lsm6dsl_data *drv_data = @@ -78,7 +78,7 @@ static void lsm6dsl_gpio_callback(struct device *dev, static void lsm6dsl_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lsm6dsl_data *drv_data = dev->data; if (drv_data->data_ready_handler != NULL) { @@ -92,7 +92,7 @@ static void lsm6dsl_thread_cb(void *arg) #ifdef CONFIG_LSM6DSL_TRIGGER_OWN_THREAD static void lsm6dsl_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lsm6dsl_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -114,7 +114,7 @@ static void lsm6dsl_work_cb(struct k_work *work) } #endif -int lsm6dsl_init_interrupt(struct device *dev) +int lsm6dsl_init_interrupt(const struct device *dev) { struct lsm6dsl_data *drv_data = dev->data; diff --git a/drivers/sensor/lsm6dso/lsm6dso.c b/drivers/sensor/lsm6dso/lsm6dso.c index de53ffe6f4af60..ae8dba53ce9f7a 100644 --- a/drivers/sensor/lsm6dso/lsm6dso.c +++ b/drivers/sensor/lsm6dso/lsm6dso.c @@ -88,7 +88,7 @@ static int lsm6dso_gyro_range_to_fs_val(int32_t range) } #endif -static inline int lsm6dso_reboot(struct device *dev) +static inline int lsm6dso_reboot(const struct device *dev) { struct lsm6dso_data *data = dev->data; @@ -102,7 +102,7 @@ static inline int lsm6dso_reboot(struct device *dev) return 0; } -static int lsm6dso_accel_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6dso_accel_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6dso_data *data = dev->data; @@ -115,7 +115,7 @@ static int lsm6dso_accel_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6dso_accel_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6dso_accel_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6dso_data *data = dev->data; @@ -128,7 +128,7 @@ static int lsm6dso_accel_set_odr_raw(struct device *dev, uint8_t odr) return 0; } -static int lsm6dso_gyro_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm6dso_gyro_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm6dso_data *data = dev->data; @@ -139,7 +139,7 @@ static int lsm6dso_gyro_set_fs_raw(struct device *dev, uint8_t fs) return 0; } -static int lsm6dso_gyro_set_odr_raw(struct device *dev, uint8_t odr) +static int lsm6dso_gyro_set_odr_raw(const struct device *dev, uint8_t odr) { struct lsm6dso_data *data = dev->data; @@ -151,7 +151,7 @@ static int lsm6dso_gyro_set_odr_raw(struct device *dev, uint8_t odr) } #ifdef LSM6DSO_ACCEL_ODR_RUNTIME -static int lsm6dso_accel_odr_set(struct device *dev, uint16_t freq) +static int lsm6dso_accel_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -170,7 +170,7 @@ static int lsm6dso_accel_odr_set(struct device *dev, uint16_t freq) #endif #ifdef LSM6DSO_ACCEL_FS_RUNTIME -static int lsm6dso_accel_range_set(struct device *dev, int32_t range) +static int lsm6dso_accel_range_set(const struct device *dev, int32_t range) { int fs; struct lsm6dso_data *data = dev->data; @@ -190,9 +190,10 @@ static int lsm6dso_accel_range_set(struct device *dev, int32_t range) } #endif -static int lsm6dso_accel_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dso_accel_config(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { #ifdef LSM6DSO_ACCEL_FS_RUNTIME @@ -212,7 +213,7 @@ static int lsm6dso_accel_config(struct device *dev, enum sensor_channel chan, } #ifdef LSM6DSO_GYRO_ODR_RUNTIME -static int lsm6dso_gyro_odr_set(struct device *dev, uint16_t freq) +static int lsm6dso_gyro_odr_set(const struct device *dev, uint16_t freq) { int odr; @@ -231,7 +232,7 @@ static int lsm6dso_gyro_odr_set(struct device *dev, uint16_t freq) #endif #ifdef LSM6DSO_GYRO_FS_RUNTIME -static int lsm6dso_gyro_range_set(struct device *dev, int32_t range) +static int lsm6dso_gyro_range_set(const struct device *dev, int32_t range) { int fs; struct lsm6dso_data *data = dev->data; @@ -251,9 +252,10 @@ static int lsm6dso_gyro_range_set(struct device *dev, int32_t range) } #endif -static int lsm6dso_gyro_config(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dso_gyro_config(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (attr) { #ifdef LSM6DSO_GYRO_FS_RUNTIME @@ -272,9 +274,10 @@ static int lsm6dso_gyro_config(struct device *dev, enum sensor_channel chan, return 0; } -static int lsm6dso_attr_set(struct device *dev, enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static int lsm6dso_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -295,7 +298,7 @@ static int lsm6dso_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int lsm6dso_sample_fetch_accel(struct device *dev) +static int lsm6dso_sample_fetch_accel(const struct device *dev) { struct lsm6dso_data *data = dev->data; union axis3bit16_t buf; @@ -312,7 +315,7 @@ static int lsm6dso_sample_fetch_accel(struct device *dev) return 0; } -static int lsm6dso_sample_fetch_gyro(struct device *dev) +static int lsm6dso_sample_fetch_gyro(const struct device *dev) { struct lsm6dso_data *data = dev->data; union axis3bit16_t buf; @@ -330,7 +333,7 @@ static int lsm6dso_sample_fetch_gyro(struct device *dev) } #if defined(CONFIG_LSM6DSO_ENABLE_TEMP) -static int lsm6dso_sample_fetch_temp(struct device *dev) +static int lsm6dso_sample_fetch_temp(const struct device *dev) { struct lsm6dso_data *data = dev->data; union axis1bit16_t buf; @@ -347,7 +350,7 @@ static int lsm6dso_sample_fetch_temp(struct device *dev) #endif #if defined(CONFIG_LSM6DSO_SENSORHUB) -static int lsm6dso_sample_fetch_shub(struct device *dev) +static int lsm6dso_sample_fetch_shub(const struct device *dev) { if (lsm6dso_shub_fetch_external_devs(dev) < 0) { LOG_DBG("failed to read ext shub devices"); @@ -358,7 +361,8 @@ static int lsm6dso_sample_fetch_shub(struct device *dev) } #endif /* CONFIG_LSM6DSO_SENSORHUB */ -static int lsm6dso_sample_fetch(struct device *dev, enum sensor_channel chan) +static int lsm6dso_sample_fetch(const struct device *dev, + enum sensor_channel chan) { switch (chan) { case SENSOR_CHAN_ACCEL_XYZ: @@ -625,7 +629,7 @@ static inline void lsm6dso_temp_convert(struct sensor_value *val, } #endif -static int lsm6dso_channel_get(struct device *dev, +static int lsm6dso_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -685,7 +689,7 @@ static const struct sensor_driver_api lsm6dso_api_funcs = { .channel_get = lsm6dso_channel_get, }; -static int lsm6dso_init_chip(struct device *dev) +static int lsm6dso_init_chip(const struct device *dev) { struct lsm6dso_data *lsm6dso = dev->data; uint8_t chip_id; @@ -787,7 +791,7 @@ static const struct lsm6dso_config lsm6dso_config = { #endif /* CONFIG_LSM6DSO_TRIGGER */ }; -static int lsm6dso_init(struct device *dev) +static int lsm6dso_init(const struct device *dev) { const struct lsm6dso_config * const config = dev->config; struct lsm6dso_data *data = dev->data; diff --git a/drivers/sensor/lsm6dso/lsm6dso.h b/drivers/sensor/lsm6dso/lsm6dso.h index c2af808d4f9960..51cdbc39b0e078 100644 --- a/drivers/sensor/lsm6dso/lsm6dso.h +++ b/drivers/sensor/lsm6dso/lsm6dso.h @@ -93,7 +93,7 @@ union axis1bit16_t { struct lsm6dso_config { char *bus_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_LSM6DSO_TRIGGER const char *int_gpio_port; uint8_t int_gpio_pin; @@ -138,7 +138,7 @@ struct lsm6dso_tf { #define LSM6DSO_SHUB_MAX_NUM_SLVS 2 struct lsm6dso_data { - struct device *bus; + const struct device *bus; int16_t acc[3]; uint32_t acc_gain; int16_t gyro[3]; @@ -172,12 +172,12 @@ struct lsm6dso_data { uint8_t gyro_fs; #ifdef CONFIG_LSM6DSO_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; sensor_trigger_handler_t handler_drdy_acc; sensor_trigger_handler_t handler_drdy_gyr; sensor_trigger_handler_t handler_drdy_temp; - struct device *dev; + const struct device *dev; #if defined(CONFIG_LSM6DSO_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LSM6DSO_THREAD_STACK_SIZE); @@ -193,23 +193,23 @@ struct lsm6dso_data { #endif }; -int lsm6dso_spi_init(struct device *dev); -int lsm6dso_i2c_init(struct device *dev); +int lsm6dso_spi_init(const struct device *dev); +int lsm6dso_i2c_init(const struct device *dev); #if defined(CONFIG_LSM6DSO_SENSORHUB) -int lsm6dso_shub_init(struct device *dev); -int lsm6dso_shub_fetch_external_devs(struct device *dev); +int lsm6dso_shub_init(const struct device *dev); +int lsm6dso_shub_fetch_external_devs(const struct device *dev); int lsm6dso_shub_get_idx(enum sensor_channel type); -int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan, +int lsm6dso_shub_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); #endif /* CONFIG_LSM6DSO_SENSORHUB */ #ifdef CONFIG_LSM6DSO_TRIGGER -int lsm6dso_trigger_set(struct device *dev, +int lsm6dso_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lsm6dso_init_interrupt(struct device *dev); +int lsm6dso_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_LSM6DSO_LSM6DSO_H_ */ diff --git a/drivers/sensor/lsm6dso/lsm6dso_i2c.c b/drivers/sensor/lsm6dso/lsm6dso_i2c.c index 893ed5e1d684e9..7ea4939ed59752 100644 --- a/drivers/sensor/lsm6dso/lsm6dso_i2c.c +++ b/drivers/sensor/lsm6dso/lsm6dso_i2c.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL); -static int lsm6dso_i2c_read(struct device *dev, uint8_t reg_addr, +static int lsm6dso_i2c_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lsm6dso_data *data = dev->data; @@ -30,7 +30,7 @@ static int lsm6dso_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int lsm6dso_i2c_write(struct device *dev, uint8_t reg_addr, +static int lsm6dso_i2c_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lsm6dso_data *data = dev->data; @@ -40,7 +40,7 @@ static int lsm6dso_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int lsm6dso_i2c_init(struct device *dev) +int lsm6dso_i2c_init(const struct device *dev) { struct lsm6dso_data *data = dev->data; diff --git a/drivers/sensor/lsm6dso/lsm6dso_shub.c b/drivers/sensor/lsm6dso/lsm6dso_shub.c index db42ef94529a38..faed14cfcf3fdc 100644 --- a/drivers/sensor/lsm6dso/lsm6dso_shub.c +++ b/drivers/sensor/lsm6dso/lsm6dso_shub.c @@ -677,7 +677,7 @@ int lsm6dso_shub_get_idx(enum sensor_channel type) return -ENOTSUP; } -int lsm6dso_shub_fetch_external_devs(struct device *dev) +int lsm6dso_shub_fetch_external_devs(const struct device *dev) { uint8_t n; struct lsm6dso_data *data = dev->data; @@ -701,7 +701,7 @@ int lsm6dso_shub_fetch_external_devs(struct device *dev) return 0; } -int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan, +int lsm6dso_shub_config(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -729,7 +729,7 @@ int lsm6dso_shub_config(struct device *dev, enum sensor_channel chan, return sp->dev_conf(data, sp->ext_i2c_addr, chan, attr, val); } -int lsm6dso_shub_init(struct device *dev) +int lsm6dso_shub_init(const struct device *dev) { struct lsm6dso_data *data = dev->data; uint8_t i, n = 0, regn; diff --git a/drivers/sensor/lsm6dso/lsm6dso_spi.c b/drivers/sensor/lsm6dso/lsm6dso_spi.c index 93d66031c72aed..3f5fcf11c1a9f3 100644 --- a/drivers/sensor/lsm6dso/lsm6dso_spi.c +++ b/drivers/sensor/lsm6dso/lsm6dso_spi.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL); -static int lsm6dso_spi_read(struct device *dev, uint8_t reg_addr, +static int lsm6dso_spi_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lsm6dso_data *data = dev->data; @@ -62,7 +62,7 @@ static int lsm6dso_spi_read(struct device *dev, uint8_t reg_addr, return 0; } -static int lsm6dso_spi_write(struct device *dev, uint8_t reg_addr, +static int lsm6dso_spi_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint8_t len) { struct lsm6dso_data *data = dev->data; @@ -96,7 +96,7 @@ static int lsm6dso_spi_write(struct device *dev, uint8_t reg_addr, return 0; } -int lsm6dso_spi_init(struct device *dev) +int lsm6dso_spi_init(const struct device *dev) { struct lsm6dso_data *data = dev->data; diff --git a/drivers/sensor/lsm6dso/lsm6dso_trigger.c b/drivers/sensor/lsm6dso/lsm6dso_trigger.c index 19b753648e74b9..b5125338ee11cf 100644 --- a/drivers/sensor/lsm6dso/lsm6dso_trigger.c +++ b/drivers/sensor/lsm6dso/lsm6dso_trigger.c @@ -23,7 +23,7 @@ LOG_MODULE_DECLARE(LSM6DSO, CONFIG_SENSOR_LOG_LEVEL); /** * lsm6dso_enable_t_int - TEMP enable selected int pin to generate interrupt */ -static int lsm6dso_enable_t_int(struct device *dev, int enable) +static int lsm6dso_enable_t_int(const struct device *dev, int enable) { const struct lsm6dso_config *cfg = dev->config; struct lsm6dso_data *lsm6dso = dev->data; @@ -51,7 +51,7 @@ static int lsm6dso_enable_t_int(struct device *dev, int enable) /** * lsm6dso_enable_xl_int - XL enable selected int pin to generate interrupt */ -static int lsm6dso_enable_xl_int(struct device *dev, int enable) +static int lsm6dso_enable_xl_int(const struct device *dev, int enable) { const struct lsm6dso_config *cfg = dev->config; struct lsm6dso_data *lsm6dso = dev->data; @@ -87,7 +87,7 @@ static int lsm6dso_enable_xl_int(struct device *dev, int enable) /** * lsm6dso_enable_g_int - Gyro enable selected int pin to generate interrupt */ -static int lsm6dso_enable_g_int(struct device *dev, int enable) +static int lsm6dso_enable_g_int(const struct device *dev, int enable) { const struct lsm6dso_config *cfg = dev->config; struct lsm6dso_data *lsm6dso = dev->data; @@ -122,7 +122,7 @@ static int lsm6dso_enable_g_int(struct device *dev, int enable) /** * lsm6dso_trigger_set - link external trigger to event data ready */ -int lsm6dso_trigger_set(struct device *dev, +int lsm6dso_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -163,7 +163,7 @@ int lsm6dso_trigger_set(struct device *dev, */ static void lsm6dso_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lsm6dso_data *lsm6dso = dev->data; struct sensor_trigger drdy_trigger = { .type = SENSOR_TRIG_DATA_READY, @@ -204,7 +204,7 @@ static void lsm6dso_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void lsm6dso_gpio_callback(struct device *dev, +static void lsm6dso_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lsm6dso_data *lsm6dso = @@ -226,7 +226,7 @@ static void lsm6dso_gpio_callback(struct device *dev, #ifdef CONFIG_LSM6DSO_TRIGGER_OWN_THREAD static void lsm6dso_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct lsm6dso_data *lsm6dso = dev->data; ARG_UNUSED(unused); @@ -248,7 +248,7 @@ static void lsm6dso_work_cb(struct k_work *work) } #endif /* CONFIG_LSM6DSO_TRIGGER_GLOBAL_THREAD */ -int lsm6dso_init_interrupt(struct device *dev) +int lsm6dso_init_interrupt(const struct device *dev) { struct lsm6dso_data *lsm6dso = dev->data; const struct lsm6dso_config *cfg = dev->config; diff --git a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c index da5331b03711bc..33a91e3416285e 100644 --- a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c +++ b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(LSM9DS0_GYRO, CONFIG_SENSOR_LOG_LEVEL); -static inline int lsm9ds0_gyro_power_ctrl(struct device *dev, int power, +static inline int lsm9ds0_gyro_power_ctrl(const struct device *dev, int power, int x_en, int y_en, int z_en) { struct lsm9ds0_gyro_data *data = dev->data; @@ -41,7 +41,7 @@ static inline int lsm9ds0_gyro_power_ctrl(struct device *dev, int power, state); } -static int lsm9ds0_gyro_set_fs_raw(struct device *dev, uint8_t fs) +static int lsm9ds0_gyro_set_fs_raw(const struct device *dev, uint8_t fs) { struct lsm9ds0_gyro_data *data = dev->data; const struct lsm9ds0_gyro_config *config = dev->config; @@ -68,7 +68,7 @@ static const struct { {500, 1}, {2000, 2} }; -static int lsm9ds0_gyro_set_fs(struct device *dev, int fs) +static int lsm9ds0_gyro_set_fs(const struct device *dev, int fs) { int i; @@ -82,7 +82,8 @@ static int lsm9ds0_gyro_set_fs(struct device *dev, int fs) } #endif -static inline int lsm9ds0_gyro_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lsm9ds0_gyro_set_odr_raw(const struct device *dev, + uint8_t odr) { struct lsm9ds0_gyro_data *data = dev->data; const struct lsm9ds0_gyro_config *config = dev->config; @@ -102,7 +103,7 @@ static const struct { {380, 2}, {760, 3} }; -static int lsm9ds0_gyro_set_odr(struct device *dev, int odr) +static int lsm9ds0_gyro_set_odr(const struct device *dev, int odr) { int i; @@ -118,7 +119,7 @@ static int lsm9ds0_gyro_set_odr(struct device *dev, int odr) } #endif -static int lsm9ds0_gyro_sample_fetch(struct device *dev, +static int lsm9ds0_gyro_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct lsm9ds0_gyro_data *data = dev->data; @@ -192,7 +193,7 @@ static inline int lsm9ds0_gyro_get_channel(enum sensor_channel chan, return 0; } -static int lsm9ds0_gyro_channel_get(struct device *dev, +static int lsm9ds0_gyro_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -218,7 +219,7 @@ static int lsm9ds0_gyro_channel_get(struct device *dev, } #if defined(LSM9DS0_GYRO_SET_ATTR) -static int lsm9ds0_gyro_attr_set(struct device *dev, +static int lsm9ds0_gyro_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -259,7 +260,7 @@ static const struct sensor_driver_api lsm9ds0_gyro_api_funcs = { #endif }; -static int lsm9ds0_gyro_init_chip(struct device *dev) +static int lsm9ds0_gyro_init_chip(const struct device *dev) { struct lsm9ds0_gyro_data *data = dev->data; const struct lsm9ds0_gyro_config *config = dev->config; @@ -315,7 +316,7 @@ static int lsm9ds0_gyro_init_chip(struct device *dev) return -EIO; } -static int lsm9ds0_gyro_init(struct device *dev) +static int lsm9ds0_gyro_init(const struct device *dev) { const struct lsm9ds0_gyro_config * const config = dev->config; struct lsm9ds0_gyro_data *data = dev->data; diff --git a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.h b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.h index b4aada92986418..1dd1461044dee8 100644 --- a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.h +++ b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro.h @@ -221,7 +221,7 @@ struct lsm9ds0_gyro_config { }; struct lsm9ds0_gyro_data { - struct device *i2c_master; + const struct device *i2c_master; #if defined(CONFIG_LSM9DS0_GYRO_TRIGGERS) struct k_sem sem; @@ -231,9 +231,9 @@ struct lsm9ds0_gyro_data { K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_LSM9DS0_GYRO_THREAD_STACK_SIZE); struct k_thread thread; - struct device *dev; + const struct device *dev; - struct device *gpio_drdy; + const struct device *gpio_drdy; struct gpio_callback gpio_cb; struct sensor_trigger trigger_drdy; sensor_trigger_handler_t handler_drdy; @@ -247,11 +247,11 @@ struct lsm9ds0_gyro_data { }; #if defined(CONFIG_LSM9DS0_GYRO_TRIGGER_DRDY) -int lsm9ds0_gyro_trigger_set(struct device *dev, +int lsm9ds0_gyro_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int lsm9ds0_gyro_init_interrupt(struct device *dev); +int lsm9ds0_gyro_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_LSM9DS0_GYRO_LSM9DS0_GYRO_H_ */ diff --git a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro_trigger.c b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro_trigger.c index 3f2f92fec39cbf..01c14e2e0029ee 100644 --- a/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro_trigger.c +++ b/drivers/sensor/lsm9ds0_gyro/lsm9ds0_gyro_trigger.c @@ -20,7 +20,7 @@ extern struct lsm9ds0_gyro_data lsm9ds0_gyro_data; LOG_MODULE_DECLARE(LSM9DS0_GYRO, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_drdy(struct device *dev, +static inline void setup_drdy(const struct device *dev, bool enable) { struct lsm9ds0_gyro_data *data = dev->data; @@ -33,7 +33,7 @@ static inline void setup_drdy(struct device *dev, : GPIO_INT_DISABLE); } -int lsm9ds0_gyro_trigger_set(struct device *dev, +int lsm9ds0_gyro_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -70,7 +70,7 @@ int lsm9ds0_gyro_trigger_set(struct device *dev, return -ENOTSUP; } -static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev, +static void lsm9ds0_gyro_gpio_drdy_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct lsm9ds0_gyro_data *data = @@ -83,7 +83,7 @@ static void lsm9ds0_gyro_gpio_drdy_callback(struct device *dev, static void lsm9ds0_gyro_thread_main(void *arg1, void *arg2, void *arg3) { - struct device *dev = (struct device *) arg1; + const struct device *dev = (const struct device *) arg1; struct lsm9ds0_gyro_data *data = dev->data; while (1) { @@ -97,7 +97,7 @@ static void lsm9ds0_gyro_thread_main(void *arg1, void *arg2, void *arg3) } } -int lsm9ds0_gyro_init_interrupt(struct device *dev) +int lsm9ds0_gyro_init_interrupt(const struct device *dev) { const struct lsm9ds0_gyro_config * const config = dev->config; diff --git a/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.c b/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.c index 627531d07386ba..919ee210fc3a36 100644 --- a/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.c +++ b/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(LSM9DS0_MFD, CONFIG_SENSOR_LOG_LEVEL); -static inline int lsm9ds0_mfd_reboot_memory(struct device *dev) +static inline int lsm9ds0_mfd_reboot_memory(const struct device *dev) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -42,7 +42,8 @@ static inline int lsm9ds0_mfd_reboot_memory(struct device *dev) } #if !defined(LSM9DS0_MFD_ACCEL_DISABLED) -static inline int lsm9ds0_mfd_accel_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lsm9ds0_mfd_accel_set_odr_raw(const struct device *dev, + uint8_t odr) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -69,7 +70,7 @@ static const struct { {800, 0}, {1600, 0} }; -static int lsm9ds0_mfd_accel_set_odr(struct device *dev, +static int lsm9ds0_mfd_accel_set_odr(const struct device *dev, const struct sensor_value *val) { uint8_t i; @@ -86,7 +87,8 @@ static int lsm9ds0_mfd_accel_set_odr(struct device *dev, } #endif -static inline int lsm9ds0_mfd_accel_set_fs_raw(struct device *dev, uint8_t fs) +static inline int lsm9ds0_mfd_accel_set_fs_raw(const struct device *dev, + uint8_t fs) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -115,7 +117,7 @@ static const struct { {8}, {16} }; -static int lsm9ds0_mfd_accel_set_fs(struct device *dev, int val) +static int lsm9ds0_mfd_accel_set_fs(const struct device *dev, int val) { uint8_t i; @@ -131,7 +133,8 @@ static int lsm9ds0_mfd_accel_set_fs(struct device *dev, int val) #endif #if !defined(LSM9DS0_MFD_MAGN_DISABLED) -static inline int lsm9ds0_mfd_magn_set_odr_raw(struct device *dev, uint8_t odr) +static inline int lsm9ds0_mfd_magn_set_odr_raw(const struct device *dev, + uint8_t odr) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -154,7 +157,7 @@ static const struct { {50, 0}, {100, 0} }; -static int lsm9ds0_mfd_magn_set_odr(struct device *dev, +static int lsm9ds0_mfd_magn_set_odr(const struct device *dev, const struct sensor_value *val) { uint8_t i; @@ -171,7 +174,8 @@ static int lsm9ds0_mfd_magn_set_odr(struct device *dev, } #endif -static inline int lsm9ds0_mfd_magn_set_fs_raw(struct device *dev, uint8_t fs) +static inline int lsm9ds0_mfd_magn_set_fs_raw(const struct device *dev, + uint8_t fs) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -199,7 +203,7 @@ static const struct { {8}, {12} }; -static int lsm9ds0_mfd_magn_set_fs(struct device *dev, +static int lsm9ds0_mfd_magn_set_fs(const struct device *dev, const struct sensor_value *val) { uint8_t i; @@ -216,7 +220,7 @@ static int lsm9ds0_mfd_magn_set_fs(struct device *dev, #endif #if !defined(LSM9DS0_MFD_ACCEL_DISABLED) -static inline int lsm9ds0_mfd_sample_fetch_accel(struct device *dev) +static inline int lsm9ds0_mfd_sample_fetch_accel(const struct device *dev) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -270,7 +274,7 @@ static inline int lsm9ds0_mfd_sample_fetch_accel(struct device *dev) #endif #if !defined(LSM9DS0_MFD_MAGN_DISABLED) -static inline int lsm9ds0_mfd_sample_fetch_magn(struct device *dev) +static inline int lsm9ds0_mfd_sample_fetch_magn(const struct device *dev) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -318,7 +322,7 @@ static inline int lsm9ds0_mfd_sample_fetch_magn(struct device *dev) #endif #if !defined(LSM9DS0_MFD_TEMP_DISABLED) -static inline int lsm9ds0_mfd_sample_fetch_temp(struct device *dev) +static inline int lsm9ds0_mfd_sample_fetch_temp(const struct device *dev) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -339,7 +343,7 @@ static inline int lsm9ds0_mfd_sample_fetch_temp(struct device *dev) } #endif -static inline int lsm9ds0_mfd_sample_fetch_all(struct device *dev) +static inline int lsm9ds0_mfd_sample_fetch_all(const struct device *dev) { #if !defined(LSM9DS0_MFD_ACCEL_DISABLED) if (lsm9ds0_mfd_sample_fetch_accel(dev) < 0) { @@ -362,7 +366,7 @@ static inline int lsm9ds0_mfd_sample_fetch_all(struct device *dev) return 0; } -static int lsm9ds0_mfd_sample_fetch(struct device *dev, +static int lsm9ds0_mfd_sample_fetch(const struct device *dev, enum sensor_channel chan) { switch (chan) { @@ -426,7 +430,7 @@ static inline int lsm9ds0_mfd_get_accel_channel(enum sensor_channel chan, return 0; } -static inline int lsm9ds0_mfd_get_accel(struct device *dev, +static inline int lsm9ds0_mfd_get_accel(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -512,7 +516,7 @@ static inline int lsm9ds0_mfd_get_magn_channel(enum sensor_channel chan, return 0; } -static inline int lsm9ds0_mfd_get_magn(struct device *dev, +static inline int lsm9ds0_mfd_get_magn(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -549,7 +553,7 @@ static inline int lsm9ds0_mfd_get_magn(struct device *dev, } #endif -static int lsm9ds0_mfd_channel_get(struct device *dev, +static int lsm9ds0_mfd_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -584,7 +588,7 @@ static int lsm9ds0_mfd_channel_get(struct device *dev, } #if defined(LSM9DS0_MFD_ATTR_SET_ACCEL) -static inline int lsm9ds0_mfd_attr_set_accel(struct device *dev, +static inline int lsm9ds0_mfd_attr_set_accel(const struct device *dev, enum sensor_attribute attr, const struct sensor_value *val) { @@ -606,7 +610,7 @@ static inline int lsm9ds0_mfd_attr_set_accel(struct device *dev, #endif #if defined(LSM9DS0_MFD_ATTR_SET_MAGN) -static inline int lsm9ds0_mfd_attr_set_magn(struct device *dev, +static inline int lsm9ds0_mfd_attr_set_magn(const struct device *dev, enum sensor_attribute attr, const struct sensor_value *val) { @@ -628,7 +632,7 @@ static inline int lsm9ds0_mfd_attr_set_magn(struct device *dev, #endif #if defined(LSM9DS0_MFD_ATTR_SET) -static int lsm9ds0_mfd_attr_set(struct device *dev, +static int lsm9ds0_mfd_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -665,7 +669,7 @@ static const struct sensor_driver_api lsm9ds0_mfd_api_funcs = { #endif }; -static int lsm9ds0_mfd_init_chip(struct device *dev) +static int lsm9ds0_mfd_init_chip(const struct device *dev) { struct lsm9ds0_mfd_data *data = dev->data; const struct lsm9ds0_mfd_config *config = dev->config; @@ -767,7 +771,7 @@ static int lsm9ds0_mfd_init_chip(struct device *dev) return 0; } -int lsm9ds0_mfd_init(struct device *dev) +int lsm9ds0_mfd_init(const struct device *dev) { const struct lsm9ds0_mfd_config * const config = dev->config; struct lsm9ds0_mfd_data *data = dev->data; diff --git a/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.h b/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.h index e42bb5293a7387..81290830f1a9fc 100644 --- a/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.h +++ b/drivers/sensor/lsm9ds0_mfd/lsm9ds0_mfd.h @@ -528,7 +528,7 @@ struct lsm9ds0_mfd_config { }; struct lsm9ds0_mfd_data { - struct device *i2c_master; + const struct device *i2c_master; #if !defined(LSM9DS0_MFD_ACCEL_DISABLED) int sample_accel_x, sample_accel_y, sample_accel_z; diff --git a/drivers/sensor/max17055/max17055.c b/drivers/sensor/max17055/max17055.c index a5ac661fb05b20..cfef76f8f6821e 100644 --- a/drivers/sensor/max17055/max17055.c +++ b/drivers/sensor/max17055/max17055.c @@ -75,7 +75,8 @@ static void set_millis(struct sensor_value *val, int val_millis) * @return 0 if successful * @return -ENOTSUP for unsupported channels */ -static int max17055_channel_get(struct device *dev, enum sensor_channel chan, +static int max17055_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *valp) { const struct max17055_config *const config = dev->config; @@ -158,7 +159,8 @@ static int max17055_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int max17055_sample_fetch(struct device *dev, enum sensor_channel chan) +static int max17055_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct max17055_data *priv = dev->data; struct { @@ -197,7 +199,7 @@ static int max17055_sample_fetch(struct device *dev, enum sensor_channel chan) * @return 0 for success * @return -EINVAL if the I2C controller could not be found */ -static int max17055_gauge_init(struct device *dev) +static int max17055_gauge_init(const struct device *dev) { struct max17055_data *priv = dev->data; const struct max17055_config *const config = dev->config; diff --git a/drivers/sensor/max17055/max17055.h b/drivers/sensor/max17055/max17055.h index b0a2e1815227e7..4f3a7a49b5cec0 100644 --- a/drivers/sensor/max17055/max17055.h +++ b/drivers/sensor/max17055/max17055.h @@ -22,7 +22,7 @@ enum { }; struct max17055_data { - struct device *i2c; + const struct device *i2c; /* Current cell voltage in units of 1.25/16mV */ uint16_t voltage; /* Average current in units of 1.5625uV / Rsense */ diff --git a/drivers/sensor/max30101/max30101.c b/drivers/sensor/max30101/max30101.c index 1047ce7b5eea22..1239d1f8e45424 100644 --- a/drivers/sensor/max30101/max30101.c +++ b/drivers/sensor/max30101/max30101.c @@ -12,7 +12,8 @@ LOG_MODULE_REGISTER(MAX30101, CONFIG_SENSOR_LOG_LEVEL); -static int max30101_sample_fetch(struct device *dev, enum sensor_channel chan) +static int max30101_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct max30101_data *data = dev->data; const struct max30101_config *config = dev->config; @@ -44,7 +45,8 @@ static int max30101_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int max30101_channel_get(struct device *dev, enum sensor_channel chan, +static int max30101_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct max30101_data *data = dev->data; @@ -91,7 +93,7 @@ static const struct sensor_driver_api max30101_driver_api = { .channel_get = max30101_channel_get, }; -static int max30101_init(struct device *dev) +static int max30101_init(const struct device *dev) { const struct max30101_config *config = dev->config; struct max30101_data *data = dev->data; diff --git a/drivers/sensor/max30101/max30101.h b/drivers/sensor/max30101/max30101.h index 167c5d0083ecfa..96bed08a2b4211 100644 --- a/drivers/sensor/max30101/max30101.h +++ b/drivers/sensor/max30101/max30101.h @@ -96,7 +96,7 @@ struct max30101_config { }; struct max30101_data { - struct device *i2c; + const struct device *i2c; uint32_t raw[MAX30101_MAX_NUM_CHANNELS]; uint8_t map[MAX30101_MAX_NUM_CHANNELS]; uint8_t num_channels; diff --git a/drivers/sensor/max44009/max44009.c b/drivers/sensor/max44009/max44009.c index 8eda76fb123b28..48bb6558f7bd8e 100644 --- a/drivers/sensor/max44009/max44009.c +++ b/drivers/sensor/max44009/max44009.c @@ -69,7 +69,8 @@ static int max44009_reg_update(struct max44009_data *drv_data, uint8_t reg, return max44009_reg_write(drv_data, reg, new_val); } -static int max44009_attr_set(struct device *dev, enum sensor_channel chan, +static int max44009_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -111,7 +112,8 @@ static int max44009_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int max44009_sample_fetch(struct device *dev, enum sensor_channel chan) +static int max44009_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct max44009_data *drv_data = dev->data; uint8_t val_h, val_l; @@ -136,7 +138,8 @@ static int max44009_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int max44009_channel_get(struct device *dev, enum sensor_channel chan, +static int max44009_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct max44009_data *drv_data = dev->data; @@ -169,7 +172,7 @@ static const struct sensor_driver_api max44009_driver_api = { .channel_get = max44009_channel_get, }; -int max44009_init(struct device *dev) +int max44009_init(const struct device *dev) { struct max44009_data *drv_data = dev->data; diff --git a/drivers/sensor/max44009/max44009.h b/drivers/sensor/max44009/max44009.h index 7ca03e0eb1b7c3..bf2713371d3ef8 100644 --- a/drivers/sensor/max44009/max44009.h +++ b/drivers/sensor/max44009/max44009.h @@ -22,7 +22,7 @@ #define MAX44009_REG_LUX_LOW_BYTE 0x04 struct max44009_data { - struct device *i2c; + const struct device *i2c; uint16_t sample; }; diff --git a/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c b/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c index 2f488a8e728c66..a448d05537c9b9 100644 --- a/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c +++ b/drivers/sensor/mchp_tach_xec/tach_mchp_xec.c @@ -42,7 +42,7 @@ struct tach_xec_data { ((struct tach_xec_data *)dev->data) -int tach_xec_sample_fetch(struct device *dev, enum sensor_channel chan) +int tach_xec_sample_fetch(const struct device *dev, enum sensor_channel chan) { ARG_UNUSED(chan); @@ -76,7 +76,7 @@ int tach_xec_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int tach_xec_channel_get(struct device *dev, +static int tach_xec_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -99,7 +99,7 @@ static int tach_xec_channel_get(struct device *dev, return 0; } -static int tach_xec_init(struct device *dev) +static int tach_xec_init(const struct device *dev) { TACH_Type *tach = TACH_XEC_REG_BASE(dev); diff --git a/drivers/sensor/mcp9808/mcp9808.c b/drivers/sensor/mcp9808/mcp9808.c index 373c3221d684f4..ab88bfabffb56d 100644 --- a/drivers/sensor/mcp9808/mcp9808.c +++ b/drivers/sensor/mcp9808/mcp9808.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(MCP9808, CONFIG_SENSOR_LOG_LEVEL); -int mcp9808_reg_read(struct device *dev, uint8_t reg, uint16_t *val) +int mcp9808_reg_read(const struct device *dev, uint8_t reg, uint16_t *val) { const struct mcp9808_data *data = dev->data; const struct mcp9808_config *cfg = dev->config; @@ -35,7 +35,8 @@ int mcp9808_reg_read(struct device *dev, uint8_t reg, uint16_t *val) return rc; } -static int mcp9808_sample_fetch(struct device *dev, enum sensor_channel chan) +static int mcp9808_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct mcp9808_data *data = dev->data; @@ -44,7 +45,7 @@ static int mcp9808_sample_fetch(struct device *dev, enum sensor_channel chan) return mcp9808_reg_read(dev, MCP9808_REG_TEMP_AMB, &data->reg_val); } -static int mcp9808_channel_get(struct device *dev, +static int mcp9808_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -69,7 +70,7 @@ static const struct sensor_driver_api mcp9808_api_funcs = { #endif /* CONFIG_MCP9808_TRIGGER */ }; -int mcp9808_init(struct device *dev) +int mcp9808_init(const struct device *dev) { struct mcp9808_data *data = dev->data; const struct mcp9808_config *cfg = dev->config; diff --git a/drivers/sensor/mcp9808/mcp9808.h b/drivers/sensor/mcp9808/mcp9808.h index e4cca69e0ee20d..4a6a31bca02e57 100644 --- a/drivers/sensor/mcp9808/mcp9808.h +++ b/drivers/sensor/mcp9808/mcp9808.h @@ -56,15 +56,15 @@ #define MCP9808_TEMP_CRT_BIT BIT(15) struct mcp9808_data { - struct device *i2c_master; + const struct device *i2c_master; uint16_t reg_val; #ifdef CONFIG_MCP9808_TRIGGER - struct device *alert_gpio; + const struct device *alert_gpio; struct gpio_callback alert_cb; - struct device *dev; + const struct device *dev; struct sensor_trigger trig; sensor_trigger_handler_t trigger_handler; @@ -89,16 +89,16 @@ struct mcp9808_config { #endif /* CONFIG_MCP9808_TRIGGER */ }; -int mcp9808_reg_read(struct device *dev, uint8_t reg, uint16_t *val); +int mcp9808_reg_read(const struct device *dev, uint8_t reg, uint16_t *val); #ifdef CONFIG_MCP9808_TRIGGER -int mcp9808_attr_set(struct device *dev, enum sensor_channel chan, +int mcp9808_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int mcp9808_trigger_set(struct device *dev, +int mcp9808_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int mcp9808_setup_interrupt(struct device *dev); +int mcp9808_setup_interrupt(const struct device *dev); #endif /* CONFIG_MCP9808_TRIGGER */ /* Encode a signed temperature in scaled Celsius to the format used in diff --git a/drivers/sensor/mcp9808/mcp9808_trigger.c b/drivers/sensor/mcp9808/mcp9808_trigger.c index 7326627ba81e81..12eabf799f0b2b 100644 --- a/drivers/sensor/mcp9808/mcp9808_trigger.c +++ b/drivers/sensor/mcp9808/mcp9808_trigger.c @@ -14,7 +14,8 @@ LOG_MODULE_DECLARE(MCP9808, CONFIG_SENSOR_LOG_LEVEL); -static int mcp9808_reg_write(struct device *dev, uint8_t reg, uint16_t val) +static int mcp9808_reg_write(const struct device *dev, uint8_t reg, + uint16_t val) { const struct mcp9808_data *data = dev->data; const struct mcp9808_config *cfg = dev->config; @@ -27,7 +28,7 @@ static int mcp9808_reg_write(struct device *dev, uint8_t reg, uint16_t val) return i2c_write(data->i2c_master, buf, sizeof(buf), cfg->i2c_addr); } -int mcp9808_attr_set(struct device *dev, enum sensor_channel chan, +int mcp9808_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -57,7 +58,7 @@ int mcp9808_attr_set(struct device *dev, enum sensor_channel chan, mcp9808_temp_reg_from_signed(temp)); } -static inline void setup_int(struct device *dev, +static inline void setup_int(const struct device *dev, bool enable) { const struct mcp9808_data *data = dev->data; @@ -69,7 +70,7 @@ static inline void setup_int(struct device *dev, gpio_pin_interrupt_configure(data->alert_gpio, cfg->alert_pin, flags); } -static void handle_int(struct device *dev) +static void handle_int(const struct device *dev) { struct mcp9808_data *data = dev->data; @@ -82,7 +83,7 @@ static void handle_int(struct device *dev) #endif } -static void process_int(struct device *dev) +static void process_int(const struct device *dev) { struct mcp9808_data *data = dev->data; @@ -95,7 +96,7 @@ static void process_int(struct device *dev) } } -int mcp9808_trigger_set(struct device *dev, +int mcp9808_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -121,7 +122,8 @@ int mcp9808_trigger_set(struct device *dev, return rv; } -static void alert_cb(struct device *dev, struct gpio_callback *cb, uint32_t pins) +static void alert_cb(const struct device *dev, struct gpio_callback *cb, + uint32_t pins) { struct mcp9808_data *data = CONTAINER_OF(cb, struct mcp9808_data, alert_cb); @@ -135,7 +137,7 @@ static void alert_cb(struct device *dev, struct gpio_callback *cb, uint32_t pins static void mcp9808_thread_main(int arg1, int arg2) { - struct device *dev = INT_TO_POINTER(arg1); + const struct device *dev = INT_TO_POINTER(arg1); struct mcp9808_data *data = dev->data; ARG_UNUSED(arg2); @@ -160,11 +162,11 @@ static void mcp9808_gpio_thread_cb(struct k_work *work) #endif /* CONFIG_MCP9808_TRIGGER_GLOBAL_THREAD */ -int mcp9808_setup_interrupt(struct device *dev) +int mcp9808_setup_interrupt(const struct device *dev) { struct mcp9808_data *data = dev->data; const struct mcp9808_config *cfg = dev->config; - struct device *gpio; + const struct device *gpio; int rc = mcp9808_reg_write(dev, MCP9808_REG_CRITICAL, MCP9808_TEMP_ABS_MASK); if (rc == 0) { diff --git a/drivers/sensor/mpr/mpr.c b/drivers/sensor/mpr/mpr.c index ef9814c9fae91f..104787cd376103 100644 --- a/drivers/sensor/mpr/mpr.c +++ b/drivers/sensor/mpr/mpr.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(MPR, CONFIG_SENSOR_LOG_LEVEL); -static int mpr_init(struct device *dev) +static int mpr_init(const struct device *dev) { struct mpr_data *data = dev->data; const struct mpr_config *cfg = dev->config; @@ -34,7 +34,7 @@ static int mpr_init(struct device *dev) return 0; } -static int mpr_read_reg(struct device *dev) +static int mpr_read_reg(const struct device *dev) { struct mpr_data *data = dev->data; const struct mpr_config *cfg = dev->config; @@ -100,14 +100,15 @@ static inline void mpr_convert_reg(const uint32_t *reg, uint64_t *value) } } -static int mpr_sample_fetch(struct device *dev, enum sensor_channel chan) +static int mpr_sample_fetch(const struct device *dev, + enum sensor_channel chan) { __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_PRESS); return mpr_read_reg(dev); } -static int mpr_channel_get(struct device *dev, +static int mpr_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { diff --git a/drivers/sensor/mpr/mpr.h b/drivers/sensor/mpr/mpr.h index 9b4da876bf886c..f92fe12cf3977e 100644 --- a/drivers/sensor/mpr/mpr.h +++ b/drivers/sensor/mpr/mpr.h @@ -28,7 +28,7 @@ #endif struct mpr_data { - struct device *i2c_master; + const struct device *i2c_master; uint32_t reg_val; }; @@ -38,6 +38,6 @@ struct mpr_config { uint16_t i2c_addr; }; -int mpr_reg_read(struct device *dev, uint8_t reg, uint16_t *val); +int mpr_reg_read(const struct device *dev, uint8_t reg, uint16_t *val); #endif /* ZEPHYR_DRIVERS_SENSOR_MPR_H_ */ diff --git a/drivers/sensor/mpu6050/mpu6050.c b/drivers/sensor/mpu6050/mpu6050.c index 708cd2c06339bc..ad43f165b8fe5a 100644 --- a/drivers/sensor/mpu6050/mpu6050.c +++ b/drivers/sensor/mpu6050/mpu6050.c @@ -55,7 +55,7 @@ static inline void mpu6050_convert_temp(struct sensor_value *val, } } -static int mpu6050_channel_get(struct device *dev, +static int mpu6050_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -109,7 +109,8 @@ static int mpu6050_channel_get(struct device *dev, return 0; } -static int mpu6050_sample_fetch(struct device *dev, enum sensor_channel chan) +static int mpu6050_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct mpu6050_data *drv_data = dev->data; const struct mpu6050_config *cfg = dev->config; @@ -140,7 +141,7 @@ static const struct sensor_driver_api mpu6050_driver_api = { .channel_get = mpu6050_channel_get, }; -int mpu6050_init(struct device *dev) +int mpu6050_init(const struct device *dev) { struct mpu6050_data *drv_data = dev->data; const struct mpu6050_config *cfg = dev->config; diff --git a/drivers/sensor/mpu6050/mpu6050.h b/drivers/sensor/mpu6050/mpu6050.h index 148cdfa93eaad2..59adbf88134a7f 100644 --- a/drivers/sensor/mpu6050/mpu6050.h +++ b/drivers/sensor/mpu6050/mpu6050.h @@ -35,7 +35,7 @@ static const uint16_t mpu6050_gyro_sensitivity_x10[] = { }; struct mpu6050_data { - struct device *i2c; + const struct device *i2c; int16_t accel_x; int16_t accel_y; @@ -50,8 +50,8 @@ struct mpu6050_data { uint16_t gyro_sensitivity_x10; #ifdef CONFIG_MPU6050_TRIGGER - struct device *dev; - struct device *gpio; + const struct device *dev; + const struct device *gpio; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; @@ -79,11 +79,11 @@ struct mpu6050_config { }; #ifdef CONFIG_MPU6050_TRIGGER -int mpu6050_trigger_set(struct device *dev, +int mpu6050_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int mpu6050_init_interrupt(struct device *dev); +int mpu6050_init_interrupt(const struct device *dev); #endif #endif /* __SENSOR_MPU6050__ */ diff --git a/drivers/sensor/mpu6050/mpu6050_trigger.c b/drivers/sensor/mpu6050/mpu6050_trigger.c index 73dba91a248f7a..52ca3df83103a3 100644 --- a/drivers/sensor/mpu6050/mpu6050_trigger.c +++ b/drivers/sensor/mpu6050/mpu6050_trigger.c @@ -14,7 +14,7 @@ LOG_MODULE_DECLARE(MPU6050, CONFIG_SENSOR_LOG_LEVEL); -int mpu6050_trigger_set(struct device *dev, +int mpu6050_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -41,7 +41,7 @@ int mpu6050_trigger_set(struct device *dev, return 0; } -static void mpu6050_gpio_callback(struct device *dev, +static void mpu6050_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mpu6050_data *drv_data = @@ -62,7 +62,7 @@ static void mpu6050_gpio_callback(struct device *dev, static void mpu6050_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mpu6050_data *drv_data = dev->data; const struct mpu6050_config *cfg = dev->config; @@ -79,7 +79,7 @@ static void mpu6050_thread_cb(void *arg) #ifdef CONFIG_MPU6050_TRIGGER_OWN_THREAD static void mpu6050_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct mpu6050_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -101,7 +101,7 @@ static void mpu6050_work_cb(struct k_work *work) } #endif -int mpu6050_init_interrupt(struct device *dev) +int mpu6050_init_interrupt(const struct device *dev) { struct mpu6050_data *drv_data = dev->data; const struct mpu6050_config *cfg = dev->config; diff --git a/drivers/sensor/ms5607/ms5607.c b/drivers/sensor/ms5607/ms5607.c index 42ee65c72a75e6..558c201f71340d 100644 --- a/drivers/sensor/ms5607/ms5607.c +++ b/drivers/sensor/ms5607/ms5607.c @@ -109,7 +109,8 @@ static int ms5607_get_measurement(const struct ms5607_data *data, return 0; } -static int ms5607_sample_fetch(struct device *dev, enum sensor_channel channel) +static int ms5607_sample_fetch(const struct device *dev, + enum sensor_channel channel) { struct ms5607_data *data = dev->data; int err; @@ -137,7 +138,8 @@ static int ms5607_sample_fetch(struct device *dev, enum sensor_channel channel) return 0; } -static int ms5607_channel_get(struct device *dev, enum sensor_channel chan, +static int ms5607_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { const struct ms5607_data *data = dev->data; @@ -158,7 +160,7 @@ static int ms5607_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int ms5607_attr_set(struct device *dev, enum sensor_channel chan, +static int ms5607_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -226,7 +228,7 @@ static const struct ms5607_config ms5607_config = { .ms5607_device_name = DT_INST_BUS_LABEL(0), }; -static int ms5607_init(struct device *dev) +static int ms5607_init(const struct device *dev) { const struct ms5607_config *const config = dev->config; struct ms5607_data *data = dev->data; diff --git a/drivers/sensor/ms5607/ms5607.h b/drivers/sensor/ms5607/ms5607.h index f73b1c3e0b4291..1da8349fef5031 100644 --- a/drivers/sensor/ms5607/ms5607.h +++ b/drivers/sensor/ms5607/ms5607.h @@ -62,7 +62,7 @@ #endif #if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) -int ms5607_spi_init(struct device *dev); +int ms5607_spi_init(const struct device *dev); #else /* I2c Interface not implemented yet */ BUILD_ASSERT(1, "I2c interface not implemented yet"); @@ -73,7 +73,7 @@ struct ms5607_config { }; struct ms5607_data { - struct device *ms5607_device; + const struct device *ms5607_device; const struct ms5607_transfer_function *tf; /* Calibration values */ uint16_t sens_t1; diff --git a/drivers/sensor/ms5607/ms5607_spi.c b/drivers/sensor/ms5607/ms5607_spi.c index 14ea904198ee01..16bc7994fdbfa4 100644 --- a/drivers/sensor/ms5607/ms5607_spi.c +++ b/drivers/sensor/ms5607/ms5607_spi.c @@ -166,7 +166,7 @@ static const struct ms5607_transfer_function ms5607_spi_transfer_function = { .read_adc = ms5607_spi_read_adc, }; -int ms5607_spi_init(struct device *dev) +int ms5607_spi_init(const struct device *dev) { struct ms5607_data *data = dev->data; diff --git a/drivers/sensor/ms5837/ms5837.c b/drivers/sensor/ms5837/ms5837.c index 9b0bdc9e60b6fd..d9317935f20917 100644 --- a/drivers/sensor/ms5837/ms5837.c +++ b/drivers/sensor/ms5837/ms5837.c @@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(MS5837, CONFIG_SENSOR_LOG_LEVEL); -static int ms5837_get_measurement(struct device *i2c_master, +static int ms5837_get_measurement(const struct device *i2c_master, const uint8_t i2c_address, uint32_t *val, uint8_t cmd, const uint8_t delay) { @@ -97,7 +97,8 @@ static void ms5837_compensate(struct ms5837_data *data, (((SENS * adc_pressure) / (1ll << 21)) - OFF) / (1ll << 13); } -static int ms5837_sample_fetch(struct device *dev, enum sensor_channel channel) +static int ms5837_sample_fetch(const struct device *dev, + enum sensor_channel channel) { struct ms5837_data *data = dev->data; const struct ms5837_config *cfg = dev->config; @@ -128,7 +129,8 @@ static int ms5837_sample_fetch(struct device *dev, enum sensor_channel channel) return 0; } -static int ms5837_channel_get(struct device *dev, enum sensor_channel chan, +static int ms5837_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct ms5837_data *data = dev->data; @@ -149,7 +151,7 @@ static int ms5837_channel_get(struct device *dev, enum sensor_channel chan, return 0; } -static int ms5837_attr_set(struct device *dev, enum sensor_channel chan, +static int ms5837_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -228,8 +230,9 @@ static const struct sensor_driver_api ms5837_api_funcs = { .channel_get = ms5837_channel_get, }; -static int ms5837_read_prom(struct device *i2c_master, const uint8_t i2c_address, - const uint8_t cmd, uint16_t *val) +static int ms5837_read_prom(const struct device *i2c_master, + const uint8_t i2c_address, + const uint8_t cmd, uint16_t *val) { int err; @@ -243,7 +246,7 @@ static int ms5837_read_prom(struct device *i2c_master, const uint8_t i2c_address return 0; } -static int ms5837_init(struct device *dev) +static int ms5837_init(const struct device *dev) { struct ms5837_data *data = dev->data; const struct ms5837_config *cfg = dev->config; diff --git a/drivers/sensor/ms5837/ms5837.h b/drivers/sensor/ms5837/ms5837.h index 6febaa834f1e27..4599f5babeb6df 100644 --- a/drivers/sensor/ms5837/ms5837.h +++ b/drivers/sensor/ms5837/ms5837.h @@ -46,7 +46,7 @@ struct ms5837_data { - struct device *i2c_master; + const struct device *i2c_master; /* Calibration values */ uint16_t sens_t1; diff --git a/drivers/sensor/nrf5/temp_nrf5.c b/drivers/sensor/nrf5/temp_nrf5.c index 5b0b6eeb571f59..f755c5742a3a35 100644 --- a/drivers/sensor/nrf5/temp_nrf5.c +++ b/drivers/sensor/nrf5/temp_nrf5.c @@ -37,7 +37,8 @@ static void hfclk_on_callback(struct onoff_manager *mgr, nrf_temp_task_trigger(NRF_TEMP, NRF_TEMP_TASK_START); } -static int temp_nrf5_sample_fetch(struct device *dev, enum sensor_channel chan) +static int temp_nrf5_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct temp_nrf5_data *data = dev->data; struct onoff_client cli; @@ -72,9 +73,9 @@ static int temp_nrf5_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int temp_nrf5_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static int temp_nrf5_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { struct temp_nrf5_data *data = dev->data; int32_t uval; @@ -95,7 +96,7 @@ static int temp_nrf5_channel_get(struct device *dev, static void temp_nrf5_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct temp_nrf5_data *data = dev->data; nrf_temp_event_clear(NRF_TEMP, NRF_TEMP_EVENT_DATARDY); @@ -109,7 +110,7 @@ static const struct sensor_driver_api temp_nrf5_driver_api = { DEVICE_DECLARE(temp_nrf5); -static int temp_nrf5_init(struct device *dev) +static int temp_nrf5_init(const struct device *dev) { struct temp_nrf5_data *data = dev->data; diff --git a/drivers/sensor/nxp_kinetis_temp/temp_kinetis.c b/drivers/sensor/nxp_kinetis_temp/temp_kinetis.c index 64d4a827fb3592..b0aeadc467980d 100644 --- a/drivers/sensor/nxp_kinetis_temp/temp_kinetis.c +++ b/drivers/sensor/nxp_kinetis_temp/temp_kinetis.c @@ -36,11 +36,11 @@ struct temp_kinetis_config { }; struct temp_kinetis_data { - struct device *adc; + const struct device *adc; uint16_t buffer[TEMP_KINETIS_ADC_SAMPLES]; }; -static int temp_kinetis_sample_fetch(struct device *dev, +static int temp_kinetis_sample_fetch(const struct device *dev, enum sensor_channel chan) { const struct temp_kinetis_config *config = dev->config; @@ -84,7 +84,7 @@ static int temp_kinetis_sample_fetch(struct device *dev, return 0; } -static int temp_kinetis_channel_get(struct device *dev, +static int temp_kinetis_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -137,7 +137,7 @@ static const struct sensor_driver_api temp_kinetis_driver_api = { .channel_get = temp_kinetis_channel_get, }; -static int temp_kinetis_init(struct device *dev) +static int temp_kinetis_init(const struct device *dev) { const struct temp_kinetis_config *config = dev->config; struct temp_kinetis_data *data = dev->data; diff --git a/drivers/sensor/opt3001/opt3001.c b/drivers/sensor/opt3001/opt3001.c index 6294e860e3e2c6..7158d6478535ba 100644 --- a/drivers/sensor/opt3001/opt3001.c +++ b/drivers/sensor/opt3001/opt3001.c @@ -61,7 +61,8 @@ static int opt3001_reg_update(struct opt3001_data *drv_data, uint8_t reg, return opt3001_reg_write(drv_data, reg, new_val); } -static int opt3001_sample_fetch(struct device *dev, enum sensor_channel chan) +static int opt3001_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct opt3001_data *drv_data = dev->data; uint16_t value; @@ -79,7 +80,8 @@ static int opt3001_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int opt3001_channel_get(struct device *dev, enum sensor_channel chan, +static int opt3001_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct opt3001_data *drv_data = dev->data; @@ -110,7 +112,7 @@ static const struct sensor_driver_api opt3001_driver_api = { .channel_get = opt3001_channel_get, }; -static int opt3001_chip_init(struct device *dev) +static int opt3001_chip_init(const struct device *dev) { struct opt3001_data *drv_data = dev->data; uint16_t value; @@ -152,7 +154,7 @@ static int opt3001_chip_init(struct device *dev) return 0; } -int opt3001_init(struct device *dev) +int opt3001_init(const struct device *dev) { if (opt3001_chip_init(dev) < 0) { return -EINVAL; diff --git a/drivers/sensor/opt3001/opt3001.h b/drivers/sensor/opt3001/opt3001.h index 1ae22431c9e53c..56cbcafa49d4c0 100644 --- a/drivers/sensor/opt3001/opt3001.h +++ b/drivers/sensor/opt3001/opt3001.h @@ -24,7 +24,7 @@ #define OPT3001_MANTISSA_MASK 0xfff struct opt3001_data { - struct device *i2c; + const struct device *i2c; uint16_t sample; }; diff --git a/drivers/sensor/pms7003/pms7003.c b/drivers/sensor/pms7003/pms7003.c index 98b04ba74aac70..f701cfa319efa3 100644 --- a/drivers/sensor/pms7003/pms7003.c +++ b/drivers/sensor/pms7003/pms7003.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(PMS7003, CONFIG_SENSOR_LOG_LEVEL); #define CFG_PMS7003_SERIAL_TIMEOUT 1000 struct pms7003_data { - struct device *uart_dev; + const struct device *uart_dev; uint16_t pm_1_0; uint16_t pm_2_5; uint16_t pm_10; @@ -43,7 +43,8 @@ struct pms7003_data { * @param timeout the timeout in milliseconds * @return 0 if success; -ETIME if timeout */ -static int uart_wait_for(struct device *dev, uint8_t *data, int len, int timeout) +static int uart_wait_for(const struct device *dev, uint8_t *data, int len, + int timeout) { int matched_size = 0; int64_t timeout_time = k_uptime_get() + K_MSEC(timeout); @@ -80,7 +81,8 @@ static int uart_wait_for(struct device *dev, uint8_t *data, int len, int timeout * @param timeout the timeout in milliseconds * @return 0 if success; -ETIME if timeout */ -static int uart_read_bytes(struct device *dev, uint8_t *data, int len, int timeout) +static int uart_read_bytes(const struct device *dev, uint8_t *data, int len, + int timeout) { int read_size = 0; int64_t timeout_time = k_uptime_get() + K_MSEC(timeout); @@ -102,7 +104,8 @@ static int uart_read_bytes(struct device *dev, uint8_t *data, int len, int timeo return 0; } -static int pms7003_sample_fetch(struct device *dev, enum sensor_channel chan) +static int pms7003_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct pms7003_data *drv_data = dev->data; @@ -139,7 +142,8 @@ static int pms7003_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int pms7003_channel_get(struct device *dev, enum sensor_channel chan, +static int pms7003_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct pms7003_data *drv_data = dev->data; @@ -164,7 +168,7 @@ static const struct sensor_driver_api pms7003_api = { .channel_get = &pms7003_channel_get, }; -static int pms7003_init(struct device *dev) +static int pms7003_init(const struct device *dev) { struct pms7003_data *drv_data = dev->data; diff --git a/drivers/sensor/qdec_nrfx/qdec_nrfx.c b/drivers/sensor/qdec_nrfx/qdec_nrfx.c index cfc4b8ba5ea92b..0518318cbd8b71 100644 --- a/drivers/sensor/qdec_nrfx/qdec_nrfx.c +++ b/drivers/sensor/qdec_nrfx/qdec_nrfx.c @@ -49,7 +49,8 @@ static void accumulate(struct qdec_nrfx_data *data, int16_t acc) irq_unlock(key); } -static int qdec_nrfx_sample_fetch(struct device *dev, enum sensor_channel chan) +static int qdec_nrfx_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct qdec_nrfx_data *data = &qdec_nrfx_data; @@ -71,7 +72,7 @@ static int qdec_nrfx_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int qdec_nrfx_channel_get(struct device *dev, +static int qdec_nrfx_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -105,7 +106,7 @@ static int qdec_nrfx_channel_get(struct device *dev, return 0; } -static int qdec_nrfx_trigger_set(struct device *dev, +static int qdec_nrfx_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -170,7 +171,7 @@ static void qdec_nrfx_gpio_ctrl(bool enable) #endif } -static int qdec_nrfx_init(struct device *dev) +static int qdec_nrfx_init(const struct device *dev) { static const nrfx_qdec_config_t config = { .reportper = NRF_QDEC_REPORTPER_40, @@ -268,7 +269,8 @@ static int qdec_nrfx_pm_set_state(struct qdec_nrfx_data *data, return 0; } -static int qdec_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int qdec_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { struct qdec_nrfx_data *data = &qdec_nrfx_data; diff --git a/drivers/sensor/sensor_handlers.c b/drivers/sensor/sensor_handlers.c index 2b7a93527a50a5..2c601a0ba61795 100644 --- a/drivers/sensor/sensor_handlers.c +++ b/drivers/sensor/sensor_handlers.c @@ -7,52 +7,53 @@ #include #include -static inline int z_vrfy_sensor_attr_set(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static inline int z_vrfy_sensor_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { Z_OOPS(Z_SYSCALL_DRIVER_SENSOR(dev, attr_set)); Z_OOPS(Z_SYSCALL_MEMORY_READ(val, sizeof(struct sensor_value))); - return z_impl_sensor_attr_set((struct device *)dev, chan, attr, - (const struct sensor_value *)val); + return z_impl_sensor_attr_set((const struct device *)dev, chan, attr, + (const struct sensor_value *)val); } #include -static inline int z_vrfy_sensor_attr_get(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - struct sensor_value *val) +static inline int z_vrfy_sensor_attr_get(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + struct sensor_value *val) { Z_OOPS(Z_SYSCALL_DRIVER_SENSOR(dev, attr_get)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(val, sizeof(struct sensor_value))); - return z_impl_sensor_attr_get((struct device *)dev, chan, attr, - (struct sensor_value *)val); + return z_impl_sensor_attr_get((const struct device *)dev, chan, attr, + (struct sensor_value *)val); } #include -static inline int z_vrfy_sensor_sample_fetch(struct device *dev) +static inline int z_vrfy_sensor_sample_fetch(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_SENSOR(dev, sample_fetch)); - return z_impl_sensor_sample_fetch((struct device *)dev); + return z_impl_sensor_sample_fetch((const struct device *)dev); } #include -static inline int z_vrfy_sensor_sample_fetch_chan(struct device *dev, - enum sensor_channel type) +static inline int z_vrfy_sensor_sample_fetch_chan(const struct device *dev, + enum sensor_channel type) { Z_OOPS(Z_SYSCALL_DRIVER_SENSOR(dev, sample_fetch)); - return z_impl_sensor_sample_fetch_chan((struct device *)dev, type); + return z_impl_sensor_sample_fetch_chan((const struct device *)dev, + type); } #include -static inline int z_vrfy_sensor_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static inline int z_vrfy_sensor_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { Z_OOPS(Z_SYSCALL_DRIVER_SENSOR(dev, channel_get)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(val, sizeof(struct sensor_value))); - return z_impl_sensor_channel_get((struct device *)dev, chan, - (struct sensor_value *)val); + return z_impl_sensor_channel_get((const struct device *)dev, chan, + (struct sensor_value *)val); } #include diff --git a/drivers/sensor/sensor_shell.c b/drivers/sensor/sensor_shell.c index d043e977e547ce..d64d4f02f5acf6 100644 --- a/drivers/sensor/sensor_shell.c +++ b/drivers/sensor/sensor_shell.c @@ -64,7 +64,8 @@ const char *sensor_channel_name[SENSOR_CHAN_ALL] = { "gauge_desired_charging_current", }; -static int handle_channel_by_name(const struct shell *shell, struct device *dev, +static int handle_channel_by_name(const struct shell *shell, + const struct device *dev, const char *channel_name) { struct sensor_value value[3]; @@ -118,7 +119,7 @@ static int handle_channel_by_name(const struct shell *shell, struct device *dev, } static int cmd_get_sensor(const struct shell *shell, size_t argc, char *argv[]) { - struct device *dev; + const struct device *dev; int err; dev = device_get_binding(argv[1]); @@ -183,7 +184,7 @@ SHELL_DYNAMIC_CMD_CREATE(dsub_device_name, device_name_get); static void device_name_get(size_t idx, struct shell_static_entry *entry) { - struct device *dev = shell_device_lookup(idx, NULL); + const struct device *dev = shell_device_lookup(idx, NULL); entry->syntax = (dev != NULL) ? dev->name : NULL; entry->handler = NULL; diff --git a/drivers/sensor/shell_battery.c b/drivers/sensor/shell_battery.c index e13240bbf00628..5c1efaff025090 100644 --- a/drivers/sensor/shell_battery.c +++ b/drivers/sensor/shell_battery.c @@ -21,7 +21,7 @@ * @return 0 on success * @return negative error code from sensor API on failure */ -static int get_channels(struct device *dev, ...) +static int get_channels(const struct device *dev, ...) { va_list ptr; int i; @@ -51,7 +51,7 @@ static int cmd_battery(const struct shell *shell, size_t argc, char **argv) struct sensor_value temp, volt, current, i_desired, charge_remain; struct sensor_value charge, v_desired, v_design, cap, nom_cap; struct sensor_value full, empty; - struct device *dev; + const struct device *dev; bool allowed; int err; diff --git a/drivers/sensor/sht3xd/sht3xd.c b/drivers/sensor/sht3xd/sht3xd.c index ea4f4764293438..53d38b2671c3c3 100644 --- a/drivers/sensor/sht3xd/sht3xd.c +++ b/drivers/sensor/sht3xd/sht3xd.c @@ -61,7 +61,7 @@ static uint8_t sht3xd_compute_crc(uint16_t value) return crc; } -int sht3xd_write_command(struct device *dev, uint16_t cmd) +int sht3xd_write_command(const struct device *dev, uint16_t cmd) { uint8_t tx_buf[2] = { cmd >> 8, cmd & 0xFF }; @@ -69,7 +69,7 @@ int sht3xd_write_command(struct device *dev, uint16_t cmd) sht3xd_i2c_address(dev)); } -int sht3xd_write_reg(struct device *dev, uint16_t cmd, uint16_t val) +int sht3xd_write_reg(const struct device *dev, uint16_t cmd, uint16_t val) { uint8_t tx_buf[5]; @@ -83,10 +83,11 @@ int sht3xd_write_reg(struct device *dev, uint16_t cmd, uint16_t val) sht3xd_i2c_address(dev)); } -static int sht3xd_sample_fetch(struct device *dev, enum sensor_channel chan) +static int sht3xd_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct sht3xd_data *data = dev->data; - struct device *i2c = sht3xd_i2c_device(dev); + const struct device *i2c = sht3xd_i2c_device(dev); uint8_t address = sht3xd_i2c_address(dev); uint8_t rx_buf[6]; uint16_t t_sample, rh_sample; @@ -139,7 +140,7 @@ static int sht3xd_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int sht3xd_channel_get(struct device *dev, +static int sht3xd_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -177,11 +178,11 @@ static const struct sensor_driver_api sht3xd_driver_api = { .channel_get = sht3xd_channel_get, }; -static int sht3xd_init(struct device *dev) +static int sht3xd_init(const struct device *dev) { struct sht3xd_data *data = dev->data; const struct sht3xd_config *cfg = dev->config; - struct device *i2c = device_get_binding(cfg->bus_name); + const struct device *i2c = device_get_binding(cfg->bus_name); if (i2c == NULL) { LOG_DBG("Failed to get pointer to %s device!", diff --git a/drivers/sensor/sht3xd/sht3xd.h b/drivers/sensor/sht3xd/sht3xd.h index ab65216f6f0e57..e12919a8d16600 100644 --- a/drivers/sensor/sht3xd/sht3xd.h +++ b/drivers/sensor/sht3xd/sht3xd.h @@ -57,14 +57,14 @@ struct sht3xd_config { }; struct sht3xd_data { - struct device *dev; - struct device *bus; + const struct device *dev; + const struct device *bus; uint16_t t_sample; uint16_t rh_sample; #ifdef CONFIG_SHT3XD_TRIGGER - struct device *alert_gpio; + const struct device *alert_gpio; struct gpio_callback alert_cb; uint16_t t_low; @@ -86,14 +86,14 @@ struct sht3xd_data { #endif /* CONFIG_SHT3XD_TRIGGER */ }; -static inline uint8_t sht3xd_i2c_address(struct device *dev) +static inline uint8_t sht3xd_i2c_address(const struct device *dev) { const struct sht3xd_config *dcp = dev->config; return dcp->base_address; } -static inline struct device *sht3xd_i2c_device(struct device *dev) +static inline const struct device *sht3xd_i2c_device(const struct device *dev) { const struct sht3xd_data *ddp = dev->data; @@ -101,20 +101,20 @@ static inline struct device *sht3xd_i2c_device(struct device *dev) } #ifdef CONFIG_SHT3XD_TRIGGER -int sht3xd_write_command(struct device *dev, uint16_t cmd); +int sht3xd_write_command(const struct device *dev, uint16_t cmd); -int sht3xd_write_reg(struct device *dev, uint16_t cmd, uint16_t val); +int sht3xd_write_reg(const struct device *dev, uint16_t cmd, uint16_t val); -int sht3xd_attr_set(struct device *dev, +int sht3xd_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int sht3xd_trigger_set(struct device *dev, +int sht3xd_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int sht3xd_init_interrupt(struct device *dev); +int sht3xd_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_SHT3XD_SHT3XD_H_ */ diff --git a/drivers/sensor/sht3xd/sht3xd_trigger.c b/drivers/sensor/sht3xd/sht3xd_trigger.c index 277ef024d61cd2..d7bfff86a34d9c 100644 --- a/drivers/sensor/sht3xd/sht3xd_trigger.c +++ b/drivers/sensor/sht3xd/sht3xd_trigger.c @@ -32,7 +32,7 @@ static int sht3xd_rh_processed_to_raw(const struct sensor_value *val) return ((uval * 0xFFFF) / 100) / 1000000; } -int sht3xd_attr_set(struct device *dev, +int sht3xd_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -81,7 +81,7 @@ int sht3xd_attr_set(struct device *dev, return 0; } -static inline void setup_alert(struct device *dev, +static inline void setup_alert(const struct device *dev, bool enable) { struct sht3xd_data *data = (struct sht3xd_data *)dev->data; @@ -94,7 +94,7 @@ static inline void setup_alert(struct device *dev, gpio_pin_interrupt_configure(data->alert_gpio, cfg->alert_pin, flags); } -static inline void handle_alert(struct device *dev) +static inline void handle_alert(const struct device *dev) { setup_alert(dev, false); @@ -109,7 +109,7 @@ static inline void handle_alert(struct device *dev) #endif } -int sht3xd_trigger_set(struct device *dev, +int sht3xd_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -142,7 +142,7 @@ int sht3xd_trigger_set(struct device *dev, return 0; } -static void sht3xd_gpio_callback(struct device *dev, +static void sht3xd_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct sht3xd_data *data = @@ -153,7 +153,7 @@ static void sht3xd_gpio_callback(struct device *dev, static void sht3xd_thread_cb(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct sht3xd_data *data = (struct sht3xd_data *)dev->data; if (data->handler != NULL) { @@ -166,7 +166,7 @@ static void sht3xd_thread_cb(void *arg) #ifdef CONFIG_SHT3XD_TRIGGER_OWN_THREAD static void sht3xd_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct sht3xd_data *data = dev->data; ARG_UNUSED(unused); @@ -188,11 +188,11 @@ static void sht3xd_work_cb(struct k_work *work) } #endif -int sht3xd_init_interrupt(struct device *dev) +int sht3xd_init_interrupt(const struct device *dev) { struct sht3xd_data *data = dev->data; const struct sht3xd_config *cfg = dev->config; - struct device *gpio = device_get_binding(cfg->alert_gpio_name); + const struct device *gpio = device_get_binding(cfg->alert_gpio_name); int rc; /* setup gpio interrupt */ diff --git a/drivers/sensor/si7006/si7006.c b/drivers/sensor/si7006/si7006.c index f605cc62d7d332..695175297aaeb6 100644 --- a/drivers/sensor/si7006/si7006.c +++ b/drivers/sensor/si7006/si7006.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(si7006, CONFIG_SENSOR_LOG_LEVEL); struct si7006_data { - struct device *i2c_dev; + const struct device *i2c_dev; uint16_t temperature; uint16_t humidity; }; @@ -33,7 +33,7 @@ struct si7006_data { * * @return int 0 on success */ -static int si7006_get_humidity(struct device *i2c_dev, +static int si7006_get_humidity(const struct device *i2c_dev, struct si7006_data *si_data) { int retval; @@ -60,7 +60,7 @@ static int si7006_get_humidity(struct device *i2c_dev, * @return int 0 on success */ -static int si7006_get_old_temperature(struct device *i2c_dev, +static int si7006_get_old_temperature(const struct device *i2c_dev, struct si7006_data *si_data) { uint8_t temp[2]; @@ -83,7 +83,8 @@ static int si7006_get_old_temperature(struct device *i2c_dev, * * @return 0 */ -static int si7006_sample_fetch(struct device *dev, enum sensor_channel chan) +static int si7006_sample_fetch(const struct device *dev, + enum sensor_channel chan) { int retval; struct si7006_data *si_data = dev->data; @@ -101,7 +102,8 @@ static int si7006_sample_fetch(struct device *dev, enum sensor_channel chan) * * @return -ENOTSUP for unsupported channels */ -static int si7006_channel_get(struct device *dev, enum sensor_channel chan, +static int si7006_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct si7006_data *si_data = dev->data; @@ -144,7 +146,7 @@ static const struct sensor_driver_api si7006_api = { * @return 0 for success */ -static int si7006_init(struct device *dev) +static int si7006_init(const struct device *dev) { struct si7006_data *drv_data = dev->data; diff --git a/drivers/sensor/si7055/si7055.c b/drivers/sensor/si7055/si7055.c index 1ce8219d674711..6ca16eee29d547 100644 --- a/drivers/sensor/si7055/si7055.c +++ b/drivers/sensor/si7055/si7055.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(si7055, CONFIG_SENSOR_LOG_LEVEL); struct si7055_data { - struct device *i2c_dev; + const struct device *i2c_dev; uint16_t temperature; }; @@ -30,8 +30,8 @@ struct si7055_data { * @return int 0 on success * -EIO for I/O and checksum errors */ -static int si7055_get_temperature(struct device *i2c_dev, - struct si7055_data *si_data) +static int si7055_get_temperature(const struct device *i2c_dev, + struct si7055_data *si_data) { int retval; #if CONFIG_SI7055_ENABLE_CHECKSUM @@ -71,7 +71,8 @@ static int si7055_get_temperature(struct device *i2c_dev, * * @return 0 */ -static int si7055_sample_fetch(struct device *dev, enum sensor_channel chan) +static int si7055_sample_fetch(const struct device *dev, + enum sensor_channel chan) { int retval; struct si7055_data *si_data = dev->data; @@ -86,7 +87,8 @@ static int si7055_sample_fetch(struct device *dev, enum sensor_channel chan) * * @return -ENOTSUP for unsupported channels */ -static int si7055_channel_get(struct device *dev, enum sensor_channel chan, +static int si7055_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct si7055_data *si_data = dev->data; @@ -126,7 +128,7 @@ static const struct sensor_driver_api si7055_api = { * @return 0 for success */ -static int si7055_init(struct device *dev) +static int si7055_init(const struct device *dev) { struct si7055_data *drv_data = dev->data; diff --git a/drivers/sensor/si7060/si7060.c b/drivers/sensor/si7060/si7060.c index 578217eeb2fcf0..c36cf3dfb0c7d1 100644 --- a/drivers/sensor/si7060/si7060.c +++ b/drivers/sensor/si7060/si7060.c @@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(si7060, CONFIG_SENSOR_LOG_LEVEL); struct si7060_data { - struct device *i2c_dev; + const struct device *i2c_dev; uint16_t temperature; }; @@ -40,7 +40,8 @@ static int si7060_reg_write(struct si7060_data *drv_data, uint8_t reg, DT_INST_REG_ADDR(0), reg, val); } -static int si7060_sample_fetch(struct device *dev, enum sensor_channel chan) +static int si7060_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct si7060_data *drv_data = dev->data; @@ -70,7 +71,8 @@ static int si7060_sample_fetch(struct device *dev, enum sensor_channel chan) return retval; } -static int si7060_channel_get(struct device *dev, enum sensor_channel chan, +static int si7060_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct si7060_data *drv_data = dev->data; @@ -94,7 +96,7 @@ static const struct sensor_driver_api si7060_api = { .channel_get = &si7060_channel_get, }; -static int si7060_chip_init(struct device *dev) +static int si7060_chip_init(const struct device *dev) { struct si7060_data *drv_data = dev->data; uint8_t value; @@ -121,7 +123,7 @@ static int si7060_chip_init(struct device *dev) return 0; } -static int si7060_init(struct device *dev) +static int si7060_init(const struct device *dev) { if (si7060_chip_init(dev) < 0) { return -EINVAL; diff --git a/drivers/sensor/sm351lt/sm351lt.c b/drivers/sensor/sm351lt/sm351lt.c index 94f8386453ee80..a19cb9b23b1f61 100644 --- a/drivers/sensor/sm351lt/sm351lt.c +++ b/drivers/sensor/sm351lt/sm351lt.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(SM351LT, CONFIG_SENSOR_LOG_LEVEL); #if CONFIG_SM351LT_TRIGGER -static int sm351lt_trigger_set(struct device *dev, +static int sm351lt_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -48,7 +48,7 @@ static int sm351lt_trigger_set(struct device *dev, return ret; } -static void sm351lt_gpio_callback(struct device *dev, +static void sm351lt_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct sm351lt_data *data = @@ -63,7 +63,7 @@ static void sm351lt_gpio_callback(struct device *dev, static void sm351lt_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct sm351lt_data *data = dev->data; struct sensor_trigger mag_trigger = { @@ -81,7 +81,7 @@ static void sm351lt_thread_cb(void *arg) #if defined(CONFIG_SM351LT_TRIGGER_OWN_THREAD) static void sm351lt_thread(void *arg1, void *unused2, void *unused3) { - struct device *dev = arg1; + const struct device *dev = arg1; struct sm351lt_data *data = dev->data; ARG_UNUSED(unused2); @@ -105,7 +105,7 @@ static void sm351lt_work_cb(struct k_work *work) #endif #endif -static int sm351lt_sample_fetch(struct device *dev, +static int sm351lt_sample_fetch(const struct device *dev, enum sensor_channel chan) { const struct sm351lt_config *config = dev->config; @@ -120,7 +120,7 @@ static int sm351lt_sample_fetch(struct device *dev, return 0; } -static int sm351lt_channel_get(struct device *dev, +static int sm351lt_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -137,7 +137,8 @@ static int sm351lt_channel_get(struct device *dev, } #if CONFIG_SM351LT_TRIGGER -static int sm351lt_attr_set(struct device *dev, enum sensor_channel chan, +static int sm351lt_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -157,7 +158,8 @@ static int sm351lt_attr_set(struct device *dev, enum sensor_channel chan, return 0; } -static int sm351lt_attr_get(struct device *dev, enum sensor_channel chan, +static int sm351lt_attr_get(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val) { @@ -189,7 +191,7 @@ static const struct sensor_driver_api sm351lt_api_funcs = { #endif }; -static int sm351lt_init(struct device *dev) +static int sm351lt_init(const struct device *dev) { const struct sm351lt_config *const config = dev->config; struct sm351lt_data *data = dev->data; diff --git a/drivers/sensor/sm351lt/sm351lt.h b/drivers/sensor/sm351lt/sm351lt.h index 7f78808ce51aaf..9c70ba113728c9 100644 --- a/drivers/sensor/sm351lt/sm351lt.h +++ b/drivers/sensor/sm351lt/sm351lt.h @@ -20,7 +20,7 @@ struct sm351lt_config { }; struct sm351lt_data { - struct device *bus; + const struct device *bus; bool sample_status; #ifdef CONFIG_SM351LT_TRIGGER @@ -35,7 +35,7 @@ struct sm351lt_data { struct k_sem gpio_sem; #elif defined(CONFIG_SM351LT_TRIGGER_GLOBAL_THREAD) struct k_work work; - struct device *dev; + const struct device *dev; #endif #endif /* CONFIG_SM351LT_TRIGGER */ diff --git a/drivers/sensor/stts751/stts751.c b/drivers/sensor/stts751/stts751.c index b49d455cfee3f0..f6037f9e47d8cf 100644 --- a/drivers/sensor/stts751/stts751.c +++ b/drivers/sensor/stts751/stts751.c @@ -22,14 +22,14 @@ LOG_MODULE_REGISTER(STTS751, CONFIG_SENSOR_LOG_LEVEL); -static inline int stts751_set_odr_raw(struct device *dev, uint8_t odr) +static inline int stts751_set_odr_raw(const struct device *dev, uint8_t odr) { struct stts751_data *data = dev->data; return stts751_temp_data_rate_set(data->ctx, odr); } -static int stts751_sample_fetch(struct device *dev, +static int stts751_sample_fetch(const struct device *dev, enum sensor_channel chan) { struct stts751_data *data = dev->data; @@ -54,7 +54,7 @@ static inline void stts751_temp_convert(struct sensor_value *val, val->val2 = ((int32_t)raw_val % 256) * 10000; } -static int stts751_channel_get(struct device *dev, +static int stts751_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -85,7 +85,7 @@ static const struct { {32, 0}, }; -static int stts751_odr_set(struct device *dev, +static int stts751_odr_set(const struct device *dev, const struct sensor_value *val) { int odr; @@ -110,7 +110,8 @@ static int stts751_odr_set(struct device *dev, return 0; } -static int stts751_attr_set(struct device *dev, enum sensor_channel chan, +static int stts751_attr_set(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -139,7 +140,7 @@ static const struct sensor_driver_api stts751_api_funcs = { #endif }; -static int stts751_init_chip(struct device *dev) +static int stts751_init_chip(const struct device *dev) { struct stts751_data *data = dev->data; stts751_id_t chip_id; @@ -167,7 +168,7 @@ static int stts751_init_chip(struct device *dev) return 0; } -static int stts751_init(struct device *dev) +static int stts751_init(const struct device *dev) { const struct stts751_config * const config = dev->config; struct stts751_data *data = dev->data; diff --git a/drivers/sensor/stts751/stts751.h b/drivers/sensor/stts751/stts751.h index 4e1c19a024af35..882aca57993e99 100644 --- a/drivers/sensor/stts751/stts751.h +++ b/drivers/sensor/stts751/stts751.h @@ -26,7 +26,7 @@ union axis1bit16_t { struct stts751_config { char *master_dev_name; - int (*bus_init)(struct device *dev); + int (*bus_init)(const struct device *dev); #ifdef CONFIG_STTS751_TRIGGER const char *event_port; uint8_t event_pin; @@ -38,7 +38,7 @@ struct stts751_config { }; struct stts751_data { - struct device *bus; + const struct device *bus; int16_t sample_temp; stmdev_ctx_t *ctx; @@ -48,13 +48,13 @@ struct stts751_data { #endif #ifdef CONFIG_STTS751_TRIGGER - struct device *gpio; + const struct device *gpio; uint32_t pin; struct gpio_callback gpio_cb; struct sensor_trigger data_ready_trigger; sensor_trigger_handler_t thsld_handler; - struct device *dev; + const struct device *dev; #if defined(CONFIG_STTS751_TRIGGER_OWN_THREAD) K_KERNEL_STACK_MEMBER(thread_stack, CONFIG_STTS751_THREAD_STACK_SIZE); @@ -67,14 +67,14 @@ struct stts751_data { #endif /* CONFIG_STTS751_TRIGGER */ }; -int stts751_i2c_init(struct device *dev); +int stts751_i2c_init(const struct device *dev); #ifdef CONFIG_STTS751_TRIGGER -int stts751_trigger_set(struct device *dev, +int stts751_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int stts751_init_interrupt(struct device *dev); +int stts751_init_interrupt(const struct device *dev); #endif #endif /* ZEPHYR_DRIVERS_SENSOR_STTS751_STTS751_H_ */ diff --git a/drivers/sensor/stts751/stts751_i2c.c b/drivers/sensor/stts751/stts751_i2c.c index 93f4125121d291..40e1bdc9754875 100644 --- a/drivers/sensor/stts751/stts751_i2c.c +++ b/drivers/sensor/stts751/stts751_i2c.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(STTS751, CONFIG_SENSOR_LOG_LEVEL); -static int stts751_i2c_read(struct device *dev, uint8_t reg_addr, +static int stts751_i2c_read(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct stts751_data *data = dev->data; @@ -30,7 +30,7 @@ static int stts751_i2c_read(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -static int stts751_i2c_write(struct device *dev, uint8_t reg_addr, +static int stts751_i2c_write(const struct device *dev, uint8_t reg_addr, uint8_t *value, uint16_t len) { struct stts751_data *data = dev->data; @@ -40,7 +40,7 @@ static int stts751_i2c_write(struct device *dev, uint8_t reg_addr, reg_addr, value, len); } -int stts751_i2c_init(struct device *dev) +int stts751_i2c_init(const struct device *dev) { struct stts751_data *data = dev->data; diff --git a/drivers/sensor/stts751/stts751_trigger.c b/drivers/sensor/stts751/stts751_trigger.c index 39d4bb3a3c5503..0bd22441935a55 100644 --- a/drivers/sensor/stts751/stts751_trigger.c +++ b/drivers/sensor/stts751/stts751_trigger.c @@ -22,7 +22,7 @@ LOG_MODULE_DECLARE(STTS751, CONFIG_SENSOR_LOG_LEVEL); /** * stts751_enable_int - enable selected int pin to generate interrupt */ -static int stts751_enable_int(struct device *dev, int enable) +static int stts751_enable_int(const struct device *dev, int enable) { struct stts751_data *stts751 = dev->data; uint8_t en = (enable) ? 0 : 1; @@ -33,7 +33,7 @@ static int stts751_enable_int(struct device *dev, int enable) /** * stts751_trigger_set - link external trigger to event data ready */ -int stts751_trigger_set(struct device *dev, +int stts751_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -57,7 +57,7 @@ int stts751_trigger_set(struct device *dev, */ static void stts751_handle_interrupt(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct stts751_data *stts751 = dev->data; const struct stts751_config *cfg = dev->config; struct sensor_trigger thsld_trigger = { @@ -76,7 +76,7 @@ static void stts751_handle_interrupt(void *arg) GPIO_INT_EDGE_TO_ACTIVE); } -static void stts751_gpio_callback(struct device *dev, +static void stts751_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct stts751_data *stts751 = @@ -97,7 +97,7 @@ static void stts751_gpio_callback(struct device *dev, #ifdef CONFIG_STTS751_TRIGGER_OWN_THREAD static void stts751_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct stts751_data *stts751 = dev->data; ARG_UNUSED(unused); @@ -119,7 +119,7 @@ static void stts751_work_cb(struct k_work *work) } #endif /* CONFIG_STTS751_TRIGGER_GLOBAL_THREAD */ -int stts751_init_interrupt(struct device *dev) +int stts751_init_interrupt(const struct device *dev) { struct stts751_data *stts751 = dev->data; const struct stts751_config *cfg = dev->config; diff --git a/drivers/sensor/sx9500/sx9500.c b/drivers/sensor/sx9500/sx9500.c index 3f863a1152718a..b9bd2b70258145 100644 --- a/drivers/sensor/sx9500/sx9500.c +++ b/drivers/sensor/sx9500/sx9500.c @@ -45,7 +45,8 @@ static uint8_t sx9500_reg_defaults[] = { 0x00, /* No stuck timeout, no periodic compensation. */ }; -static int sx9500_sample_fetch(struct device *dev, enum sensor_channel chan) +static int sx9500_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct sx9500_data *data = (struct sx9500_data *) dev->data; @@ -55,7 +56,7 @@ static int sx9500_sample_fetch(struct device *dev, enum sensor_channel chan) SX9500_REG_STAT, &data->prox_stat); } -static int sx9500_channel_get(struct device *dev, +static int sx9500_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -78,7 +79,7 @@ static const struct sensor_driver_api sx9500_api_funcs = { #endif }; -static int sx9500_init_chip(struct device *dev) +static int sx9500_init_chip(const struct device *dev) { struct sx9500_data *data = (struct sx9500_data *) dev->data; uint8_t val; @@ -108,7 +109,7 @@ static int sx9500_init_chip(struct device *dev) 1 << CONFIG_SX9500_PROX_CHANNEL); } -int sx9500_init(struct device *dev) +int sx9500_init(const struct device *dev) { struct sx9500_data *data = dev->data; diff --git a/drivers/sensor/sx9500/sx9500.h b/drivers/sensor/sx9500/sx9500.h index 9bc279e95b0694..3f4979c91cf30e 100644 --- a/drivers/sensor/sx9500/sx9500.h +++ b/drivers/sensor/sx9500/sx9500.h @@ -25,7 +25,7 @@ #define SX9500_NEAR_FAR_IRQ ((1 << 5) | (1 << 6)) struct sx9500_data { - struct device *i2c_master; + const struct device *i2c_master; uint16_t i2c_slave_addr; uint8_t prox_stat; @@ -37,7 +37,7 @@ struct sx9500_data { #ifdef CONFIG_SX9500_TRIGGER_GLOBAL_THREAD struct k_work work; - struct device *dev; + const struct device *dev; #endif #ifdef CONFIG_SX9500_TRIGGER @@ -50,12 +50,12 @@ struct sx9500_data { }; #ifdef CONFIG_SX9500_TRIGGER -int sx9500_setup_interrupt(struct device *dev); -int sx9500_trigger_set(struct device *dev, +int sx9500_setup_interrupt(const struct device *dev); +int sx9500_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); #else -static inline int sx9500_setup_interrupt(struct device *dev) +static inline int sx9500_setup_interrupt(const struct device *dev) { return 0; } diff --git a/drivers/sensor/sx9500/sx9500_trigger.c b/drivers/sensor/sx9500/sx9500_trigger.c index 9de1eace7437c3..f8cc6c53e763b6 100644 --- a/drivers/sensor/sx9500/sx9500_trigger.c +++ b/drivers/sensor/sx9500/sx9500_trigger.c @@ -24,7 +24,7 @@ static K_KERNEL_STACK_DEFINE(sx9500_thread_stack, CONFIG_SX9500_THREAD_STACK_SIZ static struct k_thread sx9500_thread; #endif -int sx9500_trigger_set(struct device *dev, +int sx9500_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -64,7 +64,7 @@ int sx9500_trigger_set(struct device *dev, #ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD -static void sx9500_gpio_cb(struct device *port, +static void sx9500_gpio_cb(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct sx9500_data *data = @@ -77,7 +77,7 @@ static void sx9500_gpio_cb(struct device *port, static void sx9500_thread_main(int arg1, int unused) { - struct device *dev = INT_TO_POINTER(arg1); + const struct device *dev = INT_TO_POINTER(arg1); struct sx9500_data *data = dev->data; uint8_t reg_val; @@ -104,7 +104,7 @@ static void sx9500_thread_main(int arg1, int unused) #else /* CONFIG_SX9500_TRIGGER_GLOBAL_THREAD */ -static void sx9500_gpio_cb(struct device *port, +static void sx9500_gpio_cb(const struct device *port, struct gpio_callback *cb, uint32_t pins) { struct sx9500_data *data = @@ -117,7 +117,7 @@ static void sx9500_gpio_cb(struct device *port, static void sx9500_gpio_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct sx9500_data *data = dev->data; uint8_t reg_val; @@ -147,10 +147,10 @@ static void sx9500_work_cb(struct k_work *work) } #endif -int sx9500_setup_interrupt(struct device *dev) +int sx9500_setup_interrupt(const struct device *dev) { struct sx9500_data *data = dev->data; - struct device *gpio; + const struct device *gpio; #ifdef CONFIG_SX9500_TRIGGER_OWN_THREAD k_sem_init(&data->sem, 0, UINT_MAX); diff --git a/drivers/sensor/th02/th02.c b/drivers/sensor/th02/th02.c index 5f11594a53ef7a..383791276a894b 100644 --- a/drivers/sensor/th02/th02.c +++ b/drivers/sensor/th02/th02.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(TH02, CONFIG_SENSOR_LOG_LEVEL); -static uint8_t read8(struct device *dev, uint8_t d) +static uint8_t read8(const struct device *dev, uint8_t d) { uint8_t buf; @@ -29,7 +29,7 @@ static uint8_t read8(struct device *dev, uint8_t d) return buf; } -static int is_ready(struct device *dev) +static int is_ready(const struct device *dev) { uint8_t status; @@ -46,7 +46,7 @@ static int is_ready(struct device *dev) } } -static uint16_t get_humi(struct device *dev) +static uint16_t get_humi(const struct device *dev) { uint16_t humidity = 0U; @@ -65,7 +65,7 @@ static uint16_t get_humi(struct device *dev) return humidity; } -uint16_t get_temp(struct device *dev) +uint16_t get_temp(const struct device *dev) { uint16_t temperature = 0U; @@ -84,7 +84,8 @@ uint16_t get_temp(struct device *dev) return temperature; } -static int th02_sample_fetch(struct device *dev, enum sensor_channel chan) +static int th02_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct th02_data *drv_data = dev->data; @@ -98,7 +99,8 @@ static int th02_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int th02_channel_get(struct device *dev, enum sensor_channel chan, +static int th02_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct th02_data *drv_data = dev->data; @@ -124,7 +126,7 @@ static const struct sensor_driver_api th02_driver_api = { .channel_get = th02_channel_get, }; -static int th02_init(struct device *dev) +static int th02_init(const struct device *dev) { struct th02_data *drv_data = dev->data; diff --git a/drivers/sensor/th02/th02.h b/drivers/sensor/th02/th02.h index 4d6aee568420b1..ccd33bc3d28130 100644 --- a/drivers/sensor/th02/th02.h +++ b/drivers/sensor/th02/th02.h @@ -26,7 +26,7 @@ #define TH02_RD_REG_MODE 0x80 struct th02_data { - struct device *i2c; + const struct device *i2c; uint16_t t_sample; uint16_t rh_sample; }; diff --git a/drivers/sensor/ti_hdc/ti_hdc.c b/drivers/sensor/ti_hdc/ti_hdc.c index 2c4af8bd35f61d..b38785f64c0bcc 100644 --- a/drivers/sensor/ti_hdc/ti_hdc.c +++ b/drivers/sensor/ti_hdc/ti_hdc.c @@ -20,7 +20,7 @@ LOG_MODULE_REGISTER(TI_HDC, CONFIG_SENSOR_LOG_LEVEL); #if DT_INST_NODE_HAS_PROP(0, drdy_gpios) -static void ti_hdc_gpio_callback(struct device *dev, +static void ti_hdc_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct ti_hdc_data *drv_data = @@ -35,7 +35,8 @@ static void ti_hdc_gpio_callback(struct device *dev, } #endif -static int ti_hdc_sample_fetch(struct device *dev, enum sensor_channel chan) +static int ti_hdc_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct ti_hdc_data *drv_data = dev->data; uint8_t buf[4]; @@ -74,7 +75,7 @@ static int ti_hdc_sample_fetch(struct device *dev, enum sensor_channel chan) } -static int ti_hdc_channel_get(struct device *dev, +static int ti_hdc_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -109,7 +110,7 @@ static const struct sensor_driver_api ti_hdc_driver_api = { .channel_get = ti_hdc_channel_get, }; -static uint16_t read16(struct device *dev, uint8_t a, uint8_t d) +static uint16_t read16(const struct device *dev, uint8_t a, uint8_t d) { uint8_t buf[2]; if (i2c_burst_read(dev, a, d, (uint8_t *)buf, 2) < 0) { @@ -118,7 +119,7 @@ static uint16_t read16(struct device *dev, uint8_t a, uint8_t d) return (buf[0] << 8 | buf[1]); } -static int ti_hdc_init(struct device *dev) +static int ti_hdc_init(const struct device *dev) { struct ti_hdc_data *drv_data = dev->data; uint16_t tmp; diff --git a/drivers/sensor/ti_hdc/ti_hdc.h b/drivers/sensor/ti_hdc/ti_hdc.h index 49fcf04dd77d3e..18db3a80b22beb 100644 --- a/drivers/sensor/ti_hdc/ti_hdc.h +++ b/drivers/sensor/ti_hdc/ti_hdc.h @@ -22,12 +22,12 @@ #define HDC_CONVERSION_TIME 13 struct ti_hdc_data { - struct device *i2c; + const struct device *i2c; uint16_t t_sample; uint16_t rh_sample; #if DT_INST_NODE_HAS_PROP(0, drdy_gpios) - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct k_sem data_sem; #endif /* DT_INST_NODE_HAS_PROP(0, drdy_gpios) */ diff --git a/drivers/sensor/tmp007/tmp007.c b/drivers/sensor/tmp007/tmp007.c index 5462d8989598dd..09d03e530d9e85 100644 --- a/drivers/sensor/tmp007/tmp007.c +++ b/drivers/sensor/tmp007/tmp007.c @@ -58,7 +58,8 @@ int tmp007_reg_update(struct tmp007_data *drv_data, uint8_t reg, return tmp007_reg_write(drv_data, reg, new_val); } -static int tmp007_sample_fetch(struct device *dev, enum sensor_channel chan) +static int tmp007_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct tmp007_data *drv_data = dev->data; uint16_t val; @@ -78,7 +79,7 @@ static int tmp007_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int tmp007_channel_get(struct device *dev, +static int tmp007_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -105,7 +106,7 @@ static const struct sensor_driver_api tmp007_driver_api = { .channel_get = tmp007_channel_get, }; -int tmp007_init(struct device *dev) +int tmp007_init(const struct device *dev) { struct tmp007_data *drv_data = dev->data; diff --git a/drivers/sensor/tmp007/tmp007.h b/drivers/sensor/tmp007/tmp007.h index 191eebe9345d70..e3ab60fe1f7dae 100644 --- a/drivers/sensor/tmp007/tmp007.h +++ b/drivers/sensor/tmp007/tmp007.h @@ -34,13 +34,13 @@ #define TMP007_TEMP_TH_SCALE 500000 struct tmp007_data { - struct device *i2c; + const struct device *i2c; int16_t sample; #ifdef CONFIG_TMP007_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; - struct device *dev; + const struct device *dev; sensor_trigger_handler_t drdy_handler; struct sensor_trigger drdy_trigger; @@ -67,16 +67,16 @@ int tmp007_reg_write(struct tmp007_data *drv_data, uint8_t reg, uint16_t val); int tmp007_reg_update(struct tmp007_data *drv_data, uint8_t reg, uint16_t mask, uint16_t val); -int tmp007_attr_set(struct device *dev, +int tmp007_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -int tmp007_trigger_set(struct device *dev, +int tmp007_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); -int tmp007_init_interrupt(struct device *dev); +int tmp007_init_interrupt(const struct device *dev); #endif #endif /* _SENSOR_TMP007_ */ diff --git a/drivers/sensor/tmp007/tmp007_trigger.c b/drivers/sensor/tmp007/tmp007_trigger.c index 213708e1165f01..52c8d0339a0050 100644 --- a/drivers/sensor/tmp007/tmp007_trigger.c +++ b/drivers/sensor/tmp007/tmp007_trigger.c @@ -19,7 +19,7 @@ extern struct tmp007_data tmp007_driver; #include LOG_MODULE_DECLARE(TMP007, CONFIG_SENSOR_LOG_LEVEL); -static inline void setup_int(struct device *dev, +static inline void setup_int(const struct device *dev, bool enable) { struct tmp007_data *data = dev->data; @@ -31,7 +31,7 @@ static inline void setup_int(struct device *dev, : GPIO_INT_DISABLE); } -int tmp007_attr_set(struct device *dev, +int tmp007_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -63,7 +63,7 @@ int tmp007_attr_set(struct device *dev, return 0; } -static void tmp007_gpio_callback(struct device *dev, +static void tmp007_gpio_callback(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct tmp007_data *drv_data = @@ -80,7 +80,7 @@ static void tmp007_gpio_callback(struct device *dev, static void tmp007_thread_cb(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct tmp007_data *drv_data = dev->data; uint16_t status; @@ -104,7 +104,7 @@ static void tmp007_thread_cb(void *arg) #ifdef CONFIG_TMP007_TRIGGER_OWN_THREAD static void tmp007_thread(int dev_ptr, int unused) { - struct device *dev = INT_TO_POINTER(dev_ptr); + const struct device *dev = INT_TO_POINTER(dev_ptr); struct tmp007_data *drv_data = dev->data; ARG_UNUSED(unused); @@ -126,7 +126,7 @@ static void tmp007_work_cb(struct k_work *work) } #endif -int tmp007_trigger_set(struct device *dev, +int tmp007_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -147,7 +147,7 @@ int tmp007_trigger_set(struct device *dev, return 0; } -int tmp007_init_interrupt(struct device *dev) +int tmp007_init_interrupt(const struct device *dev) { struct tmp007_data *drv_data = dev->data; diff --git a/drivers/sensor/tmp112/tmp112.c b/drivers/sensor/tmp112/tmp112.c index 19795984115f5b..3071954e45ee7e 100644 --- a/drivers/sensor/tmp112/tmp112.c +++ b/drivers/sensor/tmp112/tmp112.c @@ -31,7 +31,7 @@ LOG_MODULE_REGISTER(TMP112, CONFIG_SENSOR_LOG_LEVEL); #define TMP112_TEMP_SCALE 62500 struct tmp112_data { - struct device *i2c; + const struct device *i2c; int16_t sample; }; @@ -73,7 +73,7 @@ static int tmp112_reg_update(struct tmp112_data *drv_data, uint8_t reg, return tmp112_reg_write(drv_data, reg, new_val); } -static int tmp112_attr_set(struct device *dev, +static int tmp112_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) @@ -149,7 +149,8 @@ static int tmp112_attr_set(struct device *dev, return 0; } -static int tmp112_sample_fetch(struct device *dev, enum sensor_channel chan) +static int tmp112_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct tmp112_data *drv_data = dev->data; uint16_t val; @@ -169,9 +170,9 @@ static int tmp112_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int tmp112_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static int tmp112_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { struct tmp112_data *drv_data = dev->data; int32_t uval; @@ -193,7 +194,7 @@ static const struct sensor_driver_api tmp112_driver_api = { .channel_get = tmp112_channel_get, }; -int tmp112_init(struct device *dev) +int tmp112_init(const struct device *dev) { struct tmp112_data *drv_data = dev->data; diff --git a/drivers/sensor/tmp116/tmp116.c b/drivers/sensor/tmp116/tmp116.c index c75b0cc259fe49..ebf26542eb5808 100644 --- a/drivers/sensor/tmp116/tmp116.c +++ b/drivers/sensor/tmp116/tmp116.c @@ -20,7 +20,8 @@ #define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL LOG_MODULE_REGISTER(TMP116); -static int tmp116_reg_read(struct device *dev, uint8_t reg, uint16_t *val) +static int tmp116_reg_read(const struct device *dev, uint8_t reg, + uint16_t *val) { struct tmp116_data *drv_data = dev->data; const struct tmp116_dev_config *cfg = dev->config; @@ -43,7 +44,7 @@ static int tmp116_reg_read(struct device *dev, uint8_t reg, uint16_t *val) * @retval 0 On success * @retval -EIO Otherwise */ -static inline int tmp116_device_id_check(struct device *dev) +static inline int tmp116_device_id_check(const struct device *dev) { uint16_t value; @@ -62,7 +63,8 @@ static inline int tmp116_device_id_check(struct device *dev) return 0; } -static int tmp116_sample_fetch(struct device *dev, enum sensor_channel chan) +static int tmp116_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct tmp116_data *drv_data = dev->data; uint16_t value; @@ -88,7 +90,8 @@ static int tmp116_sample_fetch(struct device *dev, enum sensor_channel chan) return 0; } -static int tmp116_channel_get(struct device *dev, enum sensor_channel chan, +static int tmp116_channel_get(const struct device *dev, + enum sensor_channel chan, struct sensor_value *val) { struct tmp116_data *drv_data = dev->data; @@ -114,7 +117,7 @@ static const struct sensor_driver_api tmp116_driver_api = { .channel_get = tmp116_channel_get }; -static int tmp116_init(struct device *dev) +static int tmp116_init(const struct device *dev) { struct tmp116_data *drv_data = dev->data; int rc; diff --git a/drivers/sensor/tmp116/tmp116.h b/drivers/sensor/tmp116/tmp116.h index 5c7202b7e0370d..28baacefa31490 100644 --- a/drivers/sensor/tmp116/tmp116.h +++ b/drivers/sensor/tmp116/tmp116.h @@ -25,7 +25,7 @@ #define TMP117_DEVICE_ID 0x0117 struct tmp116_data { - struct device *i2c; + const struct device *i2c; uint16_t sample; }; diff --git a/drivers/sensor/vl53l0x/vl53l0x.c b/drivers/sensor/vl53l0x/vl53l0x.c index f34dac6a989955..cf47bc5f1516f3 100644 --- a/drivers/sensor/vl53l0x/vl53l0x.c +++ b/drivers/sensor/vl53l0x/vl53l0x.c @@ -40,12 +40,13 @@ LOG_MODULE_REGISTER(VL53L0X, CONFIG_SENSOR_LOG_LEVEL); #define VL53L0X_SETUP_FINAL_RANGE_VCSEL_PERIOD 14 struct vl53l0x_data { - struct device *i2c; + const struct device *i2c; VL53L0X_Dev_t vl53l0x; VL53L0X_RangingMeasurementData_t RangingMeasurementData; }; -static int vl53l0x_sample_fetch(struct device *dev, enum sensor_channel chan) +static int vl53l0x_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct vl53l0x_data *drv_data = dev->data; VL53L0X_Error ret; @@ -65,7 +66,7 @@ static int vl53l0x_sample_fetch(struct device *dev, enum sensor_channel chan) } -static int vl53l0x_channel_get(struct device *dev, +static int vl53l0x_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -95,7 +96,7 @@ static const struct sensor_driver_api vl53l0x_api_funcs = { .channel_get = vl53l0x_channel_get, }; -static int vl53l0x_setup_single_shot(struct device *dev) +static int vl53l0x_setup_single_shot(const struct device *dev) { struct vl53l0x_data *drv_data = dev->data; int ret; @@ -195,7 +196,7 @@ static int vl53l0x_setup_single_shot(struct device *dev) } -static int vl53l0x_init(struct device *dev) +static int vl53l0x_init(const struct device *dev) { struct vl53l0x_data *drv_data = dev->data; VL53L0X_Error ret; @@ -205,7 +206,7 @@ static int vl53l0x_init(struct device *dev) LOG_DBG("enter in %s", __func__); #if DT_INST_NODE_HAS_PROP(0, xshut_gpios) - struct device *gpio; + const struct device *gpio; /* configure and set VL53L0X_XSHUT_Pin */ gpio = device_get_binding(DT_INST_GPIO_LABEL(0, xshut_gpios)); diff --git a/drivers/sensor/vl53l0x/vl53l0x_platform.h b/drivers/sensor/vl53l0x/vl53l0x_platform.h index 50f46436d33527..84e9c6c47f27c7 100644 --- a/drivers/sensor/vl53l0x/vl53l0x_platform.h +++ b/drivers/sensor/vl53l0x/vl53l0x_platform.h @@ -30,7 +30,7 @@ typedef struct { uint8_t I2cDevAddr; /* i2c device address user specific field */ uint8_t comms_type; /* VL53L0X_COMMS_I2C or VL53L0X_COMMS_SPI */ uint16_t comms_speed_khz; /* Comms speed [kHz] */ - struct device *i2c; + const struct device *i2c; } VL53L0X_Dev_t; diff --git a/drivers/sensor/wsen_itds/itds.c b/drivers/sensor/wsen_itds/itds.c index 6bf8821522e93d..65f045288305b2 100644 --- a/drivers/sensor/wsen_itds/itds.c +++ b/drivers/sensor/wsen_itds/itds.c @@ -32,7 +32,8 @@ static const unsigned int itds_sensitivity_scale[][ITDS_ACCL_RANGE_END] = { {244, 488, 976, 1952} }; -static int itds_get_odr_for_index(struct device *dev, enum itds_odr_const idx, +static int itds_get_odr_for_index(const struct device *dev, + enum itds_odr_const idx, uint16_t *freq, uint16_t *mfreq) { struct itds_device_data *ddata = dev->data; @@ -59,7 +60,8 @@ static int itds_get_odr_for_index(struct device *dev, enum itds_odr_const idx, return 0; } -static int itds_accl_odr_set(struct device *dev, uint16_t freq, uint16_t mfreq) +static int itds_accl_odr_set(const struct device *dev, uint16_t freq, + uint16_t mfreq) { struct itds_device_data *ddata = dev->data; const struct itds_device_config *cfg = dev->config; @@ -88,7 +90,7 @@ static int itds_accl_odr_set(struct device *dev, uint16_t freq, uint16_t mfreq) return -EINVAL; } -static int itds_accl_range_set(struct device *dev, int32_t range) +static int itds_accl_range_set(const struct device *dev, int32_t range) { struct itds_device_data *ddata = dev->data; const struct itds_device_config *cfg = dev->config; @@ -119,7 +121,7 @@ static int itds_accl_range_set(struct device *dev, int32_t range) return 0; } -static int itds_attr_set(struct device *dev, enum sensor_channel chan, +static int itds_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val) { @@ -212,7 +214,8 @@ static int itds_fetch_accel(struct itds_device_data *ddata, return 0; } -static int itds_sample_fetch(struct device *dev, enum sensor_channel chan) +static int itds_sample_fetch(const struct device *dev, + enum sensor_channel chan) { struct itds_device_data *ddata = dev->data; const struct itds_device_config *cfg = dev->config; @@ -232,7 +235,7 @@ static int itds_sample_fetch(struct device *dev, enum sensor_channel chan) } } -static inline void itds_accl_channel_get(struct device *dev, +static inline void itds_accl_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -267,7 +270,8 @@ static inline void itds_accl_channel_get(struct device *dev, } } -static int itds_temp_channel_get(struct device *dev, struct sensor_value *val) +static int itds_temp_channel_get(const struct device *dev, + struct sensor_value *val) { int32_t temp_processed; struct itds_device_data *ddata = dev->data; @@ -280,7 +284,7 @@ static int itds_temp_channel_get(struct device *dev, struct sensor_value *val) return 0; } -static int itds_channel_get(struct device *dev, +static int itds_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val) { @@ -303,7 +307,7 @@ static int itds_channel_get(struct device *dev, return 0; } -static int itds_init(struct device *dev) +static int itds_init(const struct device *dev) { struct itds_device_data *ddata = dev->data; const struct itds_device_config *cfg = dev->config; diff --git a/drivers/sensor/wsen_itds/itds.h b/drivers/sensor/wsen_itds/itds.h index 90aa4f2bb925ef..9178dd2a09b2ae 100644 --- a/drivers/sensor/wsen_itds/itds.h +++ b/drivers/sensor/wsen_itds/itds.h @@ -102,9 +102,9 @@ struct itds_device_config { #define ITDS_SAMPLE_SIZE 3 struct itds_device_data { - struct device *i2c; + const struct device *i2c; #ifdef CONFIG_ITDS_TRIGGER - struct device *gpio; + const struct device *gpio; struct gpio_callback gpio_cb; struct k_work work; #endif @@ -112,15 +112,15 @@ struct itds_device_data { int16_t temprature; uint16_t scale; enum operation_mode op_mode; - struct device *dev; + const struct device *dev; #ifdef CONFIG_ITDS_TRIGGER sensor_trigger_handler_t handler_drdy; #endif /* CONFIG_ITDS_TRIGGER */ }; -int itds_trigger_mode_init(struct device *dev); -int itds_trigger_set(struct device *dev, +int itds_trigger_mode_init(const struct device *dev); +int itds_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); diff --git a/drivers/sensor/wsen_itds/itds_trigger.c b/drivers/sensor/wsen_itds/itds_trigger.c index f7ad888c8c7568..b19f435068826d 100644 --- a/drivers/sensor/wsen_itds/itds_trigger.c +++ b/drivers/sensor/wsen_itds/itds_trigger.c @@ -15,7 +15,7 @@ #include "itds.h" LOG_MODULE_DECLARE(ITDS, CONFIG_SENSOR_LOG_LEVEL); -static int itds_trigger_drdy_set(struct device *dev, +static int itds_trigger_drdy_set(const struct device *dev, enum sensor_channel chan, sensor_trigger_handler_t handler) { @@ -38,7 +38,7 @@ static int itds_trigger_drdy_set(struct device *dev, return 0; } -int itds_trigger_set(struct device *dev, +int itds_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -59,7 +59,7 @@ static void itds_work_handler(struct k_work *work) { struct itds_device_data *ddata = CONTAINER_OF(work, struct itds_device_data, work); - struct device *dev = (struct device *)ddata->dev; + const struct device *dev = (const struct device *)ddata->dev; const struct itds_device_config *cfg = dev->config; uint8_t status; struct sensor_trigger drdy_trigger = { @@ -79,7 +79,7 @@ static void itds_work_handler(struct k_work *work) } } -static void itds_gpio_callback(struct device *port, +static void itds_gpio_callback(const struct device *port, struct gpio_callback *cb, uint32_t pin) { struct itds_device_data *ddata = @@ -91,7 +91,7 @@ static void itds_gpio_callback(struct device *port, k_work_submit(&ddata->work); } -int itds_trigger_mode_init(struct device *dev) +int itds_trigger_mode_init(const struct device *dev) { struct itds_device_data *ddata = dev->data; const struct itds_device_config *cfg = dev->config; diff --git a/drivers/serial/leuart_gecko.c b/drivers/serial/leuart_gecko.c index e77a0645b24b5e..c85a6c3709b49d 100644 --- a/drivers/serial/leuart_gecko.c +++ b/drivers/serial/leuart_gecko.c @@ -30,7 +30,7 @@ struct leuart_gecko_config { CMU_Clock_TypeDef clock; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif struct soc_gpio_pin pin_rx; struct soc_gpio_pin pin_tx; @@ -49,7 +49,7 @@ struct leuart_gecko_data { #endif }; -static int leuart_gecko_poll_in(struct device *dev, unsigned char *c) +static int leuart_gecko_poll_in(const struct device *dev, unsigned char *c) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t flags = LEUART_StatusGet(base); @@ -62,7 +62,7 @@ static int leuart_gecko_poll_in(struct device *dev, unsigned char *c) return -1; } -static void leuart_gecko_poll_out(struct device *dev, unsigned char c) +static void leuart_gecko_poll_out(const struct device *dev, unsigned char c) { LEUART_TypeDef *base = DEV_BASE(dev); @@ -72,7 +72,7 @@ static void leuart_gecko_poll_out(struct device *dev, unsigned char c) LEUART_Tx(base, c); } -static int leuart_gecko_err_check(struct device *dev) +static int leuart_gecko_err_check(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t flags = LEUART_IntGet(base); @@ -98,8 +98,9 @@ static int leuart_gecko_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int leuart_gecko_fifo_fill(struct device *dev, const uint8_t *tx_data, - int len) +static int leuart_gecko_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int len) { LEUART_TypeDef *base = DEV_BASE(dev); uint8_t num_tx = 0U; @@ -113,8 +114,8 @@ static int leuart_gecko_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int leuart_gecko_fifo_read(struct device *dev, uint8_t *rx_data, - const int len) +static int leuart_gecko_fifo_read(const struct device *dev, uint8_t *rx_data, + const int len) { LEUART_TypeDef *base = DEV_BASE(dev); uint8_t num_rx = 0U; @@ -128,7 +129,7 @@ static int leuart_gecko_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void leuart_gecko_irq_tx_enable(struct device *dev) +static void leuart_gecko_irq_tx_enable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t mask = LEUART_IEN_TXBL | LEUART_IEN_TXC; @@ -136,7 +137,7 @@ static void leuart_gecko_irq_tx_enable(struct device *dev) LEUART_IntEnable(base, mask); } -static void leuart_gecko_irq_tx_disable(struct device *dev) +static void leuart_gecko_irq_tx_disable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t mask = LEUART_IEN_TXBL | LEUART_IEN_TXC; @@ -144,7 +145,7 @@ static void leuart_gecko_irq_tx_disable(struct device *dev) LEUART_IntDisable(base, mask); } -static int leuart_gecko_irq_tx_complete(struct device *dev) +static int leuart_gecko_irq_tx_complete(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t flags = LEUART_IntGet(base); @@ -152,7 +153,7 @@ static int leuart_gecko_irq_tx_complete(struct device *dev) return (flags & LEUART_IF_TXC) != 0U; } -static int leuart_gecko_irq_tx_ready(struct device *dev) +static int leuart_gecko_irq_tx_ready(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t flags = LEUART_IntGet(base); @@ -160,7 +161,7 @@ static int leuart_gecko_irq_tx_ready(struct device *dev) return (flags & LEUART_IF_TXBL) != 0U; } -static void leuart_gecko_irq_rx_enable(struct device *dev) +static void leuart_gecko_irq_rx_enable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t mask = LEUART_IEN_RXDATAV; @@ -168,7 +169,7 @@ static void leuart_gecko_irq_rx_enable(struct device *dev) LEUART_IntEnable(base, mask); } -static void leuart_gecko_irq_rx_disable(struct device *dev) +static void leuart_gecko_irq_rx_disable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t mask = LEUART_IEN_RXDATAV; @@ -176,7 +177,7 @@ static void leuart_gecko_irq_rx_disable(struct device *dev) LEUART_IntDisable(base, mask); } -static int leuart_gecko_irq_rx_full(struct device *dev) +static int leuart_gecko_irq_rx_full(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t flags = LEUART_IntGet(base); @@ -184,7 +185,7 @@ static int leuart_gecko_irq_rx_full(struct device *dev) return (flags & LEUART_IF_RXDATAV) != 0U; } -static int leuart_gecko_irq_rx_ready(struct device *dev) +static int leuart_gecko_irq_rx_ready(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); uint32_t mask = LEUART_IEN_RXDATAV; @@ -193,7 +194,7 @@ static int leuart_gecko_irq_rx_ready(struct device *dev) && leuart_gecko_irq_rx_full(dev); } -static void leuart_gecko_irq_err_enable(struct device *dev) +static void leuart_gecko_irq_err_enable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); @@ -202,7 +203,7 @@ static void leuart_gecko_irq_err_enable(struct device *dev) LEUART_IF_FERR); } -static void leuart_gecko_irq_err_disable(struct device *dev) +static void leuart_gecko_irq_err_disable(const struct device *dev) { LEUART_TypeDef *base = DEV_BASE(dev); @@ -211,17 +212,17 @@ static void leuart_gecko_irq_err_disable(struct device *dev) LEUART_IF_FERR); } -static int leuart_gecko_irq_is_pending(struct device *dev) +static int leuart_gecko_irq_is_pending(const struct device *dev) { return leuart_gecko_irq_tx_ready(dev) || leuart_gecko_irq_rx_ready(dev); } -static int leuart_gecko_irq_update(struct device *dev) +static int leuart_gecko_irq_update(const struct device *dev) { return 1; } -static void leuart_gecko_irq_callback_set(struct device *dev, +static void leuart_gecko_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -233,7 +234,7 @@ static void leuart_gecko_irq_callback_set(struct device *dev, static void leuart_gecko_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct leuart_gecko_data *data = dev->data; if (data->callback) { @@ -242,7 +243,7 @@ static void leuart_gecko_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static void leuart_gecko_init_pins(struct device *dev) +static void leuart_gecko_init_pins(const struct device *dev) { const struct leuart_gecko_config *config = DEV_CFG(dev); LEUART_TypeDef *base = DEV_BASE(dev); @@ -261,7 +262,7 @@ static void leuart_gecko_init_pins(struct device *dev) #endif } -static int leuart_gecko_init(struct device *dev) +static int leuart_gecko_init(const struct device *dev) { const struct leuart_gecko_config *config = DEV_CFG(dev); LEUART_TypeDef *base = DEV_BASE(dev); @@ -325,7 +326,7 @@ static const struct uart_driver_api leuart_gecko_driver_api = { DT_INST_PROP_BY_IDX(0, location_tx, 2), gpioModePushPull, 1} #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void leuart_gecko_config_func_0(struct device *dev); +static void leuart_gecko_config_func_0(const struct device *dev); #endif static const struct leuart_gecko_config leuart_gecko_0_config = { @@ -358,7 +359,7 @@ DEVICE_AND_API_INIT(leuart_0, DT_INST_LABEL(0), &leuart_gecko_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void leuart_gecko_config_func_0(struct device *dev) +static void leuart_gecko_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), @@ -378,7 +379,7 @@ static void leuart_gecko_config_func_0(struct device *dev) DT_INST_PROP_BY_IDX(1, location_tx, 2), gpioModePushPull, 1} #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void leuart_gecko_config_func_1(struct device *dev); +static void leuart_gecko_config_func_1(const struct device *dev); #endif static const struct leuart_gecko_config leuart_gecko_1_config = { @@ -411,7 +412,7 @@ DEVICE_AND_API_INIT(leuart_1, DT_INST_LABEL(1), &leuart_gecko_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void leuart_gecko_config_func_1(struct device *dev) +static void leuart_gecko_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(1), DT_INST_IRQ(1, priority), diff --git a/drivers/serial/uart_altera_jtag_hal.c b/drivers/serial/uart_altera_jtag_hal.c index 38d4b6dae625c4..8dbb0d6672bbfa 100644 --- a/drivers/serial/uart_altera_jtag_hal.c +++ b/drivers/serial/uart_altera_jtag_hal.c @@ -24,7 +24,7 @@ extern int altera_avalon_jtag_uart_read(altera_avalon_jtag_uart_state *sp, extern int altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state *sp, const char *ptr, int count, int flags); -static void uart_altera_jtag_poll_out(struct device *dev, +static void uart_altera_jtag_poll_out(const struct device *dev, unsigned char c) { const struct uart_device_config *config; @@ -36,7 +36,7 @@ static void uart_altera_jtag_poll_out(struct device *dev, altera_avalon_jtag_uart_write(&ustate, &c, 1, 0); } -static int uart_altera_jtag_init(struct device *dev) +static int uart_altera_jtag_init(const struct device *dev) { /* * Work around to clear interrupt enable bits diff --git a/drivers/serial/uart_cc13xx_cc26xx.c b/drivers/serial/uart_cc13xx_cc26xx.c index 0d52e0a9be3ec3..09fee5cef14d93 100644 --- a/drivers/serial/uart_cc13xx_cc26xx.c +++ b/drivers/serial/uart_cc13xx_cc26xx.c @@ -40,17 +40,18 @@ struct uart_cc13xx_cc26xx_data { #endif }; -static inline struct uart_cc13xx_cc26xx_data *get_dev_data(struct device *dev) +static inline struct uart_cc13xx_cc26xx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct uart_device_config *get_dev_conf(struct device *dev) +static inline const struct uart_device_config *get_dev_conf(const struct device *dev) { return dev->config; } -static int uart_cc13xx_cc26xx_poll_in(struct device *dev, unsigned char *c) +static int uart_cc13xx_cc26xx_poll_in(const struct device *dev, + unsigned char *c) { if (!UARTCharsAvail(get_dev_conf(dev)->regs)) { return -1; @@ -61,7 +62,8 @@ static int uart_cc13xx_cc26xx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_cc13xx_cc26xx_poll_out(struct device *dev, unsigned char c) +static void uart_cc13xx_cc26xx_poll_out(const struct device *dev, + unsigned char c) { UARTCharPut(get_dev_conf(dev)->regs, c); /* @@ -72,7 +74,7 @@ static void uart_cc13xx_cc26xx_poll_out(struct device *dev, unsigned char c) } } -static int uart_cc13xx_cc26xx_err_check(struct device *dev) +static int uart_cc13xx_cc26xx_err_check(const struct device *dev) { uint32_t flags = UARTRxErrorGet(get_dev_conf(dev)->regs); @@ -86,7 +88,7 @@ static int uart_cc13xx_cc26xx_err_check(struct device *dev) return error; } -static int uart_cc13xx_cc26xx_configure(struct device *dev, +static int uart_cc13xx_cc26xx_configure(const struct device *dev, const struct uart_config *cfg) { uint32_t line_ctrl = 0; @@ -184,7 +186,7 @@ static int uart_cc13xx_cc26xx_configure(struct device *dev, return 0; } -static int uart_cc13xx_cc26xx_config_get(struct device *dev, +static int uart_cc13xx_cc26xx_config_get(const struct device *dev, struct uart_config *cfg) { *cfg = get_dev_data(dev)->uart_config; @@ -193,7 +195,8 @@ static int uart_cc13xx_cc26xx_config_get(struct device *dev, #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_cc13xx_cc26xx_fifo_fill(struct device *dev, const uint8_t *buf, +static int uart_cc13xx_cc26xx_fifo_fill(const struct device *dev, + const uint8_t *buf, int len) { int n = 0; @@ -208,7 +211,8 @@ static int uart_cc13xx_cc26xx_fifo_fill(struct device *dev, const uint8_t *buf, return n; } -static int uart_cc13xx_cc26xx_fifo_read(struct device *dev, uint8_t *buf, +static int uart_cc13xx_cc26xx_fifo_read(const struct device *dev, + uint8_t *buf, const int len) { int c, n; @@ -225,7 +229,7 @@ static int uart_cc13xx_cc26xx_fifo_read(struct device *dev, uint8_t *buf, return n; } -static void uart_cc13xx_cc26xx_irq_tx_enable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_tx_enable(const struct device *dev) { #if defined(CONFIG_SYS_POWER_MANAGEMENT) && \ defined(CONFIG_SYS_POWER_SLEEP_STATES) @@ -248,7 +252,7 @@ static void uart_cc13xx_cc26xx_irq_tx_enable(struct device *dev) UARTIntEnable(get_dev_conf(dev)->regs, UART_INT_TX); } -static void uart_cc13xx_cc26xx_irq_tx_disable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_tx_disable(const struct device *dev) { UARTIntDisable(get_dev_conf(dev)->regs, UART_INT_TX); @@ -261,12 +265,12 @@ static void uart_cc13xx_cc26xx_irq_tx_disable(struct device *dev) #endif } -static int uart_cc13xx_cc26xx_irq_tx_ready(struct device *dev) +static int uart_cc13xx_cc26xx_irq_tx_ready(const struct device *dev) { return UARTSpaceAvail(get_dev_conf(dev)->regs) ? 1 : 0; } -static void uart_cc13xx_cc26xx_irq_rx_enable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_rx_enable(const struct device *dev) { #if defined(CONFIG_SYS_POWER_MANAGEMENT) && \ defined(CONFIG_SYS_POWER_SLEEP_STATES) @@ -284,7 +288,7 @@ static void uart_cc13xx_cc26xx_irq_rx_enable(struct device *dev) UARTIntEnable(get_dev_conf(dev)->regs, UART_INT_RX); } -static void uart_cc13xx_cc26xx_irq_rx_disable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_rx_disable(const struct device *dev) { #if defined(CONFIG_SYS_POWER_MANAGEMENT) && \ defined(CONFIG_SYS_POWER_SLEEP_STATES) @@ -297,45 +301,46 @@ static void uart_cc13xx_cc26xx_irq_rx_disable(struct device *dev) UARTIntDisable(get_dev_conf(dev)->regs, UART_INT_RX); } -static int uart_cc13xx_cc26xx_irq_tx_complete(struct device *dev) +static int uart_cc13xx_cc26xx_irq_tx_complete(const struct device *dev) { return UARTBusy(get_dev_conf(dev)->regs) ? 0 : 1; } -static int uart_cc13xx_cc26xx_irq_rx_ready(struct device *dev) +static int uart_cc13xx_cc26xx_irq_rx_ready(const struct device *dev) { return UARTCharsAvail(get_dev_conf(dev)->regs) ? 1 : 0; } -static void uart_cc13xx_cc26xx_irq_err_enable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_err_enable(const struct device *dev) { return UARTIntEnable(get_dev_conf(dev)->regs, UART_INT_OE | UART_INT_BE | UART_INT_PE | UART_INT_FE); } -static void uart_cc13xx_cc26xx_irq_err_disable(struct device *dev) +static void uart_cc13xx_cc26xx_irq_err_disable(const struct device *dev) { return UARTIntDisable(get_dev_conf(dev)->regs, UART_INT_OE | UART_INT_BE | UART_INT_PE | UART_INT_FE); } -static int uart_cc13xx_cc26xx_irq_is_pending(struct device *dev) +static int uart_cc13xx_cc26xx_irq_is_pending(const struct device *dev) { uint32_t status = UARTIntStatus(get_dev_conf(dev)->regs, true); return status & (UART_INT_TX | UART_INT_RX) ? 1 : 0; } -static int uart_cc13xx_cc26xx_irq_update(struct device *dev) +static int uart_cc13xx_cc26xx_irq_update(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void uart_cc13xx_cc26xx_irq_callback_set( - struct device *dev, uart_irq_callback_user_data_t cb, void *user_data) +static void uart_cc13xx_cc26xx_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *user_data) { struct uart_cc13xx_cc26xx_data *data = get_dev_data(dev); @@ -345,7 +350,7 @@ static void uart_cc13xx_cc26xx_irq_callback_set( static void uart_cc13xx_cc26xx_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct uart_cc13xx_cc26xx_data *data = get_dev_data(dev); if (data->callback) { @@ -367,7 +372,7 @@ static void uart_cc13xx_cc26xx_isr(void *arg) static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg) { - struct device *dev = (struct device *)clientArg; + const struct device *dev = (const struct device *)clientArg; int ret = Power_NOTIFYDONE; int16_t res_id; @@ -397,8 +402,8 @@ static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg, #endif #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int uart_cc13xx_cc26xx_set_power_state(struct device *dev, - uint32_t new_state) +static int uart_cc13xx_cc26xx_set_power_state(const struct device *dev, + uint32_t new_state) { int ret = 0; @@ -442,8 +447,10 @@ static int uart_cc13xx_cc26xx_set_power_state(struct device *dev, return ret; } -static int uart_cc13xx_cc26xx_pm_control(struct device *dev, uint32_t ctrl_command, - void *context, device_pm_cb cb, void *arg) +static int uart_cc13xx_cc26xx_pm_control(const struct device *dev, + uint32_t ctrl_command, + void *context, device_pm_cb cb, + void *arg) { int ret = 0; @@ -596,7 +603,7 @@ static const struct uart_driver_api uart_cc13xx_cc26xx_driver_api = { #endif #define UART_CC13XX_CC26XX_INIT_FUNC(n) \ - static int uart_cc13xx_cc26xx_init_##n(struct device *dev) \ + static int uart_cc13xx_cc26xx_init_##n(const struct device *dev) \ { \ int ret; \ \ diff --git a/drivers/serial/uart_cc32xx.c b/drivers/serial/uart_cc32xx.c index 89e4f7fb0718c5..79ca7d6e144b2d 100644 --- a/drivers/serial/uart_cc32xx.c +++ b/drivers/serial/uart_cc32xx.c @@ -56,7 +56,7 @@ static struct uart_cc32xx_dev_data_t uart_cc32xx_dev_data_0 = { * Keeping with this assumption, this driver leaves the FIFOs disabled, * and at depth 1. */ -static int uart_cc32xx_init(struct device *dev) +static int uart_cc32xx_init(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -92,7 +92,7 @@ static int uart_cc32xx_init(struct device *dev) return 0; } -static int uart_cc32xx_poll_in(struct device *dev, unsigned char *c) +static int uart_cc32xx_poll_in(const struct device *dev, unsigned char *c) { const struct uart_device_config *config = DEV_CFG(dev); @@ -104,14 +104,14 @@ static int uart_cc32xx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_cc32xx_poll_out(struct device *dev, unsigned char c) +static void uart_cc32xx_poll_out(const struct device *dev, unsigned char c) { const struct uart_device_config *config = DEV_CFG(dev); MAP_UARTCharPut((unsigned long)config->base, c); } -static int uart_cc32xx_err_check(struct device *dev) +static int uart_cc32xx_err_check(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned long cc32xx_errs = 0L; @@ -133,7 +133,8 @@ static int uart_cc32xx_err_check(struct device *dev) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_cc32xx_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_cc32xx_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { const struct uart_device_config *config = DEV_CFG(dev); @@ -152,7 +153,7 @@ static int uart_cc32xx_fifo_fill(struct device *dev, const uint8_t *tx_data, return (int)num_tx; } -static int uart_cc32xx_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_cc32xx_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { const struct uart_device_config *config = DEV_CFG(dev); @@ -169,21 +170,21 @@ static int uart_cc32xx_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void uart_cc32xx_irq_tx_enable(struct device *dev) +static void uart_cc32xx_irq_tx_enable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); MAP_UARTIntEnable((unsigned long)config->base, UART_INT_TX); } -static void uart_cc32xx_irq_tx_disable(struct device *dev) +static void uart_cc32xx_irq_tx_disable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); MAP_UARTIntDisable((unsigned long)config->base, UART_INT_TX); } -static int uart_cc32xx_irq_tx_ready(struct device *dev) +static int uart_cc32xx_irq_tx_ready(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -193,7 +194,7 @@ static int uart_cc32xx_irq_tx_ready(struct device *dev) return (int_status & UART_INT_TX); } -static void uart_cc32xx_irq_rx_enable(struct device *dev) +static void uart_cc32xx_irq_rx_enable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -201,21 +202,21 @@ static void uart_cc32xx_irq_rx_enable(struct device *dev) MAP_UARTIntEnable((unsigned long)config->base, UART_INT_RX); } -static void uart_cc32xx_irq_rx_disable(struct device *dev) +static void uart_cc32xx_irq_rx_disable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); MAP_UARTIntDisable((unsigned long)config->base, UART_INT_RX); } -static int uart_cc32xx_irq_tx_complete(struct device *dev) +static int uart_cc32xx_irq_tx_complete(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); return (!MAP_UARTBusy((unsigned long)config->base)); } -static int uart_cc32xx_irq_rx_ready(struct device *dev) +static int uart_cc32xx_irq_rx_ready(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -225,17 +226,17 @@ static int uart_cc32xx_irq_rx_ready(struct device *dev) return (int_status & UART_INT_RX); } -static void uart_cc32xx_irq_err_enable(struct device *dev) +static void uart_cc32xx_irq_err_enable(const struct device *dev) { /* Not yet used in zephyr */ } -static void uart_cc32xx_irq_err_disable(struct device *dev) +static void uart_cc32xx_irq_err_disable(const struct device *dev) { /* Not yet used in zephyr */ } -static int uart_cc32xx_irq_is_pending(struct device *dev) +static int uart_cc32xx_irq_is_pending(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -245,12 +246,12 @@ static int uart_cc32xx_irq_is_pending(struct device *dev) return (int_status & (UART_INT_TX | UART_INT_RX)); } -static int uart_cc32xx_irq_update(struct device *dev) +static int uart_cc32xx_irq_update(const struct device *dev) { return 1; } -static void uart_cc32xx_irq_callback_set(struct device *dev, +static void uart_cc32xx_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -274,7 +275,7 @@ static void uart_cc32xx_irq_callback_set(struct device *dev, */ static void uart_cc32xx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct uart_device_config *config = DEV_CFG(dev); struct uart_cc32xx_dev_data_t * const dev_data = DEV_DATA(dev); diff --git a/drivers/serial/uart_cmsdk_apb.c b/drivers/serial/uart_cmsdk_apb.c index 16ccd0f3d04a6c..4bfba1c62124fd 100644 --- a/drivers/serial/uart_cmsdk_apb.c +++ b/drivers/serial/uart_cmsdk_apb.c @@ -95,7 +95,7 @@ static void uart_cmsdk_apb_isr(void *arg); * * @return N/A */ -static void baudrate_set(struct device *dev) +static void baudrate_set(const struct device *dev) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); const struct uart_device_config * const dev_cfg = DEV_CFG(dev); @@ -121,7 +121,7 @@ static void baudrate_set(struct device *dev) * * @return 0 */ -static int uart_cmsdk_apb_init(struct device *dev) +static int uart_cmsdk_apb_init(const struct device *dev) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -130,7 +130,7 @@ static int uart_cmsdk_apb_init(struct device *dev) #ifdef CONFIG_CLOCK_CONTROL /* Enable clock for subsystem */ - struct device *clk = + const struct device *clk = device_get_binding(CONFIG_ARM_CLOCK_CONTROL_DEV_NAME); struct uart_cmsdk_apb_dev_data * const data = DEV_DATA(dev); @@ -164,7 +164,7 @@ static int uart_cmsdk_apb_init(struct device *dev) * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_cmsdk_apb_poll_in(struct device *dev, unsigned char *c) +static int uart_cmsdk_apb_poll_in(const struct device *dev, unsigned char *c) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); @@ -188,7 +188,7 @@ static int uart_cmsdk_apb_poll_in(struct device *dev, unsigned char *c) * @param dev UART device struct * @param c Character to send */ -static void uart_cmsdk_apb_poll_out(struct device *dev, +static void uart_cmsdk_apb_poll_out(const struct device *dev, unsigned char c) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); @@ -212,7 +212,7 @@ static void uart_cmsdk_apb_poll_out(struct device *dev, * * @return the number of characters that have been read */ -static int uart_cmsdk_apb_fifo_fill(struct device *dev, +static int uart_cmsdk_apb_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); @@ -235,7 +235,7 @@ static int uart_cmsdk_apb_fifo_fill(struct device *dev, * * @return the number of characters that have been read */ -static int uart_cmsdk_apb_fifo_read(struct device *dev, +static int uart_cmsdk_apb_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); @@ -256,7 +256,7 @@ static int uart_cmsdk_apb_fifo_read(struct device *dev, * * @return N/A */ -static void uart_cmsdk_apb_irq_tx_enable(struct device *dev) +static void uart_cmsdk_apb_irq_tx_enable(const struct device *dev) { unsigned int key; @@ -279,7 +279,7 @@ static void uart_cmsdk_apb_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_tx_disable(struct device *dev) +static void uart_cmsdk_apb_irq_tx_disable(const struct device *dev) { UART_STRUCT(dev)->ctrl &= ~UART_TX_IN_EN; } @@ -291,7 +291,7 @@ static void uart_cmsdk_apb_irq_tx_disable(struct device *dev) * * @return 1 if an interrupt is ready, 0 otherwise */ -static int uart_cmsdk_apb_irq_tx_ready(struct device *dev) +static int uart_cmsdk_apb_irq_tx_ready(const struct device *dev) { return !(UART_STRUCT(dev)->state & UART_TX_BF); } @@ -303,7 +303,7 @@ static int uart_cmsdk_apb_irq_tx_ready(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_rx_enable(struct device *dev) +static void uart_cmsdk_apb_irq_rx_enable(const struct device *dev) { UART_STRUCT(dev)->ctrl |= UART_RX_IN_EN; } @@ -315,7 +315,7 @@ static void uart_cmsdk_apb_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_rx_disable(struct device *dev) +static void uart_cmsdk_apb_irq_rx_disable(const struct device *dev) { UART_STRUCT(dev)->ctrl &= ~UART_RX_IN_EN; } @@ -327,7 +327,7 @@ static void uart_cmsdk_apb_irq_rx_disable(struct device *dev) * * @return 1 if an interrupt is ready, 0 otherwise */ -static int uart_cmsdk_apb_irq_tx_complete(struct device *dev) +static int uart_cmsdk_apb_irq_tx_complete(const struct device *dev) { return uart_cmsdk_apb_irq_tx_ready(dev); } @@ -339,7 +339,7 @@ static int uart_cmsdk_apb_irq_tx_complete(struct device *dev) * * @return 1 if an interrupt is ready, 0 otherwise */ -static int uart_cmsdk_apb_irq_rx_ready(struct device *dev) +static int uart_cmsdk_apb_irq_rx_ready(const struct device *dev) { return UART_STRUCT(dev)->state & UART_RX_BF; } @@ -351,7 +351,7 @@ static int uart_cmsdk_apb_irq_rx_ready(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_err_enable(struct device *dev) +static void uart_cmsdk_apb_irq_err_enable(const struct device *dev) { ARG_UNUSED(dev); } @@ -363,7 +363,7 @@ static void uart_cmsdk_apb_irq_err_enable(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_err_disable(struct device *dev) +static void uart_cmsdk_apb_irq_err_disable(const struct device *dev) { ARG_UNUSED(dev); } @@ -375,7 +375,7 @@ static void uart_cmsdk_apb_irq_err_disable(struct device *dev) * * @return 1 if Tx or Rx interrupt is pending, 0 otherwise */ -static int uart_cmsdk_apb_irq_is_pending(struct device *dev) +static int uart_cmsdk_apb_irq_is_pending(const struct device *dev) { /* Return true if rx buffer full or tx buffer empty */ return (UART_STRUCT(dev)->state & (UART_RX_BF | UART_TX_BF)) @@ -389,7 +389,7 @@ static int uart_cmsdk_apb_irq_is_pending(struct device *dev) * * @return always 1 */ -static int uart_cmsdk_apb_irq_update(struct device *dev) +static int uart_cmsdk_apb_irq_update(const struct device *dev) { return 1; } @@ -402,7 +402,7 @@ static int uart_cmsdk_apb_irq_update(struct device *dev) * * @return N/A */ -static void uart_cmsdk_apb_irq_callback_set(struct device *dev, +static void uart_cmsdk_apb_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -421,7 +421,7 @@ static void uart_cmsdk_apb_irq_callback_set(struct device *dev, */ void uart_cmsdk_apb_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; volatile struct uart_cmsdk_apb *uart = UART_STRUCT(dev); struct uart_cmsdk_apb_dev_data *data = DEV_DATA(dev); @@ -461,7 +461,7 @@ static const struct uart_driver_api uart_cmsdk_apb_driver_api = { #if DT_NODE_HAS_STATUS(DT_DRV_INST(0), okay) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_cmsdk_apb_irq_config_func_0(struct device *dev); +static void uart_cmsdk_apb_irq_config_func_0(const struct device *dev); #endif static const struct uart_device_config uart_cmsdk_apb_dev_cfg_0 = { @@ -492,7 +492,7 @@ DEVICE_AND_API_INIT(uart_cmsdk_apb_0, #ifdef CONFIG_UART_INTERRUPT_DRIVEN #if DT_INST_IRQ_HAS_CELL(0, irq) -static void uart_cmsdk_apb_irq_config_func_0(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), @@ -502,7 +502,7 @@ static void uart_cmsdk_apb_irq_config_func_0(struct device *dev) irq_enable(DT_INST_IRQN(0)); } #else -static void uart_cmsdk_apb_irq_config_func_0(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(0, tx, irq), DT_INST_IRQ_BY_NAME(0, tx, priority), @@ -526,7 +526,7 @@ static void uart_cmsdk_apb_irq_config_func_0(struct device *dev) #if DT_NODE_HAS_STATUS(DT_DRV_INST(1), okay) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_cmsdk_apb_irq_config_func_1(struct device *dev); +static void uart_cmsdk_apb_irq_config_func_1(const struct device *dev); #endif static const struct uart_device_config uart_cmsdk_apb_dev_cfg_1 = { @@ -557,7 +557,7 @@ DEVICE_AND_API_INIT(uart_cmsdk_apb_1, #ifdef CONFIG_UART_INTERRUPT_DRIVEN #if DT_INST_IRQ_HAS_CELL(1, irq) -static void uart_cmsdk_apb_irq_config_func_1(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(1), DT_INST_IRQ(1, priority), @@ -567,7 +567,7 @@ static void uart_cmsdk_apb_irq_config_func_1(struct device *dev) irq_enable(DT_INST_IRQN(1)); } #else -static void uart_cmsdk_apb_irq_config_func_1(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(1, tx, irq), DT_INST_IRQ_BY_NAME(1, tx, priority), @@ -591,7 +591,7 @@ static void uart_cmsdk_apb_irq_config_func_1(struct device *dev) #if DT_NODE_HAS_STATUS(DT_DRV_INST(2), okay) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_cmsdk_apb_irq_config_func_2(struct device *dev); +static void uart_cmsdk_apb_irq_config_func_2(const struct device *dev); #endif static const struct uart_device_config uart_cmsdk_apb_dev_cfg_2 = { @@ -622,7 +622,7 @@ DEVICE_AND_API_INIT(uart_cmsdk_apb_2, #ifdef CONFIG_UART_INTERRUPT_DRIVEN #ifdef CMSDK_APB_UART_2_IRQ -static void uart_cmsdk_apb_irq_config_func_2(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_2(const struct device *dev) { IRQ_CONNECT(CMSDK_APB_UART_2_IRQ, DT_INST_IRQ_BY_NAME(2, priority, irq), @@ -632,7 +632,7 @@ static void uart_cmsdk_apb_irq_config_func_2(struct device *dev) irq_enable(CMSDK_APB_UART_2_IRQ); } #else -static void uart_cmsdk_apb_irq_config_func_2(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_2(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(2, tx, irq), DT_INST_IRQ_BY_NAME(2, tx, priority), @@ -656,7 +656,7 @@ static void uart_cmsdk_apb_irq_config_func_2(struct device *dev) #if DT_NODE_HAS_STATUS(DT_DRV_INST(3), okay) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_cmsdk_apb_irq_config_func_3(struct device *dev); +static void uart_cmsdk_apb_irq_config_func_3(const struct device *dev); #endif static const struct uart_device_config uart_cmsdk_apb_dev_cfg_3 = { @@ -687,7 +687,7 @@ DEVICE_AND_API_INIT(uart_cmsdk_apb_3, #ifdef CONFIG_UART_INTERRUPT_DRIVEN #ifdef CMSDK_APB_UART_3_IRQ -static void uart_cmsdk_apb_irq_config_func_3(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_3(const struct device *dev) { IRQ_CONNECT(CMSDK_APB_UART_3_IRQ, DT_INST_IRQ_BY_NAME(3, priority, irq), @@ -697,7 +697,7 @@ static void uart_cmsdk_apb_irq_config_func_3(struct device *dev) irq_enable(CMSDK_APB_UART_3_IRQ); } #else -static void uart_cmsdk_apb_irq_config_func_3(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_3(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(3, tx, irq), DT_INST_IRQ_BY_NAME(3, tx, priority), @@ -721,7 +721,7 @@ static void uart_cmsdk_apb_irq_config_func_3(struct device *dev) #if DT_NODE_HAS_STATUS(DT_DRV_INST(4), okay) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_cmsdk_apb_irq_config_func_4(struct device *dev); +static void uart_cmsdk_apb_irq_config_func_4(const struct device *dev); #endif static const struct uart_device_config uart_cmsdk_apb_dev_cfg_4 = { @@ -752,7 +752,7 @@ DEVICE_AND_API_INIT(uart_cmsdk_apb_4, #ifdef CONFIG_UART_INTERRUPT_DRIVEN #ifdef CMSDK_APB_UART_4_IRQ -static void uart_cmsdk_apb_irq_config_func_4(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_4(const struct device *dev) { IRQ_CONNECT(CMSDK_APB_UART_4_IRQ, DT_INST_IRQ_BY_NAME(4, priority, irq), @@ -762,7 +762,7 @@ static void uart_cmsdk_apb_irq_config_func_4(struct device *dev) irq_enable(CMSDK_APB_UART_4_IRQ); } #else -static void uart_cmsdk_apb_irq_config_func_4(struct device *dev) +static void uart_cmsdk_apb_irq_config_func_4(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQ_BY_NAME(4, tx, irq), DT_INST_IRQ_BY_NAME(4, tx, priority), diff --git a/drivers/serial/uart_esp32.c b/drivers/serial/uart_esp32.c index 06ace97c48b541..d6a33a97b33e7b 100644 --- a/drivers/serial/uart_esp32.c +++ b/drivers/serial/uart_esp32.c @@ -90,7 +90,7 @@ struct uart_esp32_config { /* driver data */ struct uart_esp32_data { struct uart_config uart_config; - struct device *clock_dev; + const struct device *clock_dev; #ifdef CONFIG_UART_INTERRUPT_DRIVEN uart_irq_callback_user_data_t irq_cb; void *irq_cb_data; @@ -130,7 +130,7 @@ struct uart_esp32_data { #define DPORT_UART0_CLK_EN DPORT_UART_CLK_EN #define DPORT_UART0_RST DPORT_UART_RST -static int uart_esp32_poll_in(struct device *dev, unsigned char *p_char) +static int uart_esp32_poll_in(const struct device *dev, unsigned char *p_char) { if (UART_RXFIFO_COUNT(DEV_BASE(dev)->status) == 0) { @@ -141,7 +141,7 @@ static int uart_esp32_poll_in(struct device *dev, unsigned char *p_char) return 0; } -static void uart_esp32_poll_out(struct device *dev, +static void uart_esp32_poll_out(const struct device *dev, unsigned char c) { /* Wait for space in FIFO */ @@ -153,7 +153,7 @@ static void uart_esp32_poll_out(struct device *dev, DEV_BASE(dev)->fifo = (uint32_t)c; } -static int uart_esp32_err_check(struct device *dev) +static int uart_esp32_err_check(const struct device *dev) { uint32_t err = UART_GET_PARITY_ERR(DEV_BASE(dev)->int_st) | UART_GET_FRAME_ERR(DEV_BASE(dev)->int_st); @@ -161,7 +161,8 @@ static int uart_esp32_err_check(struct device *dev) return err; } -static int uart_esp32_config_get(struct device *dev, struct uart_config *cfg) +static int uart_esp32_config_get(const struct device *dev, + struct uart_config *cfg) { struct uart_esp32_data *data = DEV_DATA(dev); @@ -186,7 +187,7 @@ static int uart_esp32_config_get(struct device *dev, struct uart_config *cfg) return 0; } -static int uart_esp32_set_baudrate(struct device *dev, int baudrate) +static int uart_esp32_set_baudrate(const struct device *dev, int baudrate) { uint32_t sys_clk_freq = 0; @@ -210,7 +211,7 @@ static int uart_esp32_set_baudrate(struct device *dev, int baudrate) return 1; } -static int uart_esp32_configure_pins(struct device *dev) +static int uart_esp32_configure_pins(const struct device *dev) { const struct uart_esp32_config *const cfg = DEV_CFG(dev); @@ -239,7 +240,7 @@ static int uart_esp32_configure_pins(struct device *dev) return 0; } -static int uart_esp32_configure(struct device *dev, +static int uart_esp32_configure(const struct device *dev, const struct uart_config *cfg) { uint32_t conf0 = UART_TICK_REF_ALWAYS_ON; @@ -313,7 +314,7 @@ static int uart_esp32_configure(struct device *dev, return 0; } -static int uart_esp32_init(struct device *dev) +static int uart_esp32_init(const struct device *dev) { struct uart_esp32_data *data = DEV_DATA(dev); @@ -332,7 +333,7 @@ static int uart_esp32_init(struct device *dev) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_esp32_fifo_fill(struct device *dev, +static int uart_esp32_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { uint8_t num_tx = 0U; @@ -345,7 +346,7 @@ static int uart_esp32_fifo_fill(struct device *dev, return num_tx; } -static int uart_esp32_fifo_read(struct device *dev, +static int uart_esp32_fifo_read(const struct device *dev, uint8_t *rx_data, const int len) { uint8_t num_rx = 0U; @@ -358,63 +359,63 @@ static int uart_esp32_fifo_read(struct device *dev, return num_rx; } -static void uart_esp32_irq_tx_enable(struct device *dev) +static void uart_esp32_irq_tx_enable(const struct device *dev) { DEV_BASE(dev)->int_clr |= UART_TXFIFO_EMPTY_INT_ENA; DEV_BASE(dev)->int_ena |= UART_TXFIFO_EMPTY_INT_ENA; } -static void uart_esp32_irq_tx_disable(struct device *dev) +static void uart_esp32_irq_tx_disable(const struct device *dev) { DEV_BASE(dev)->int_ena &= ~(UART_TXFIFO_EMPTY_INT_ENA); } -static int uart_esp32_irq_tx_ready(struct device *dev) +static int uart_esp32_irq_tx_ready(const struct device *dev) { return (UART_TXFIFO_COUNT(DEV_BASE(dev)->status) < UART_FIFO_LIMIT); } -static void uart_esp32_irq_rx_enable(struct device *dev) +static void uart_esp32_irq_rx_enable(const struct device *dev) { DEV_BASE(dev)->int_clr |= UART_RXFIFO_FULL_INT_ENA; DEV_BASE(dev)->int_ena |= UART_RXFIFO_FULL_INT_ENA; } -static void uart_esp32_irq_rx_disable(struct device *dev) +static void uart_esp32_irq_rx_disable(const struct device *dev) { DEV_BASE(dev)->int_ena &= ~(UART_RXFIFO_FULL_INT_ENA); } -static int uart_esp32_irq_tx_complete(struct device *dev) +static int uart_esp32_irq_tx_complete(const struct device *dev) { /* check if TX FIFO is empty */ return (UART_TXFIFO_COUNT(DEV_BASE(dev)->status) == 0 ? 1 : 0); } -static int uart_esp32_irq_rx_ready(struct device *dev) +static int uart_esp32_irq_rx_ready(const struct device *dev) { return (UART_RXFIFO_COUNT(DEV_BASE(dev)->status) > 0); } -static void uart_esp32_irq_err_enable(struct device *dev) +static void uart_esp32_irq_err_enable(const struct device *dev) { /* enable framing, parity */ DEV_BASE(dev)->int_ena |= UART_FRM_ERR_INT_ENA | UART_PARITY_ERR_INT_ENA; } -static void uart_esp32_irq_err_disable(struct device *dev) +static void uart_esp32_irq_err_disable(const struct device *dev) { DEV_BASE(dev)->int_ena &= ~(UART_FRM_ERR_INT_ENA); DEV_BASE(dev)->int_ena &= ~(UART_PARITY_ERR_INT_ENA); } -static int uart_esp32_irq_is_pending(struct device *dev) +static int uart_esp32_irq_is_pending(const struct device *dev) { return uart_esp32_irq_rx_ready(dev) || uart_esp32_irq_tx_ready(dev); } -static int uart_esp32_irq_update(struct device *dev) +static int uart_esp32_irq_update(const struct device *dev) { DEV_BASE(dev)->int_clr |= UART_RXFIFO_FULL_INT_ENA; DEV_BASE(dev)->int_clr |= UART_TXFIFO_EMPTY_INT_ENA; @@ -422,7 +423,7 @@ static int uart_esp32_irq_update(struct device *dev) return 1; } -static void uart_esp32_irq_callback_set(struct device *dev, +static void uart_esp32_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -432,7 +433,7 @@ static void uart_esp32_irq_callback_set(struct device *dev, void uart_esp32_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_esp32_data *data = DEV_DATA(dev); /* Verify if the callback has been registered */ @@ -476,7 +477,7 @@ static const struct uart_driver_api uart_esp32_api = { .irq_config_func = uart_esp32_irq_config_func_##idx, #define ESP32_UART_IRQ_HANDLER(idx) \ - static void uart_esp32_irq_config_func_##idx(struct device *dev) \ + static void uart_esp32_irq_config_func_##idx(const struct device *dev) \ { \ esp32_rom_intr_matrix_set(0, ETS_UART##idx##_INTR_SOURCE, \ INST_##idx##_ESPRESSIF_ESP32_UART_IRQ_0); \ diff --git a/drivers/serial/uart_handlers.c b/drivers/serial/uart_handlers.c index b8d0c8d374ed99..61b2052495ff5e 100644 --- a/drivers/serial/uart_handlers.c +++ b/drivers/serial/uart_handlers.c @@ -8,14 +8,14 @@ #include #define UART_SIMPLE(op_) \ - static inline int z_vrfy_uart_##op_(struct device *dev) \ + static inline int z_vrfy_uart_##op_(const struct device *dev) \ { \ Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, op_)); \ return z_impl_uart_ ## op_(dev); \ } #define UART_SIMPLE_VOID(op_) \ - static inline void z_vrfy_uart_##op_(struct device *dev) \ + static inline void z_vrfy_uart_##op_(const struct device *dev) \ { \ Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, op_)); \ z_impl_uart_ ## op_(dev); \ @@ -24,7 +24,7 @@ UART_SIMPLE(err_check) #include -static inline int z_vrfy_uart_poll_in(struct device *dev, +static inline int z_vrfy_uart_poll_in(const struct device *dev, unsigned char *p_char) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_in)); @@ -33,16 +33,16 @@ static inline int z_vrfy_uart_poll_in(struct device *dev, } #include -static inline void z_vrfy_uart_poll_out(struct device *dev, +static inline void z_vrfy_uart_poll_out(const struct device *dev, unsigned char out_char) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, poll_out)); - z_impl_uart_poll_out((struct device *)dev, out_char); + z_impl_uart_poll_out((const struct device *)dev, out_char); } #include -static inline int z_vrfy_uart_config_get(struct device *dev, - struct uart_config *cfg) +static inline int z_vrfy_uart_config_get(const struct device *dev, + struct uart_config *cfg) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, config_get)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(cfg, sizeof(struct uart_config))); @@ -51,8 +51,8 @@ static inline int z_vrfy_uart_config_get(struct device *dev, } #include -static inline int z_vrfy_uart_configure(struct device *dev, - const struct uart_config *cfg) +static inline int z_vrfy_uart_configure(const struct device *dev, + const struct uart_config *cfg) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, config_get)); Z_OOPS(Z_SYSCALL_MEMORY_READ(cfg, sizeof(struct uart_config))); @@ -68,7 +68,7 @@ static inline int z_vrfy_uart_configure(struct device *dev, * rx_buf_rsp() excluded as it's designed to be called from ISR callbacks */ -static inline int z_vrfy_uart_tx(struct device *dev, const uint8_t *buf, +static inline int z_vrfy_uart_tx(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, tx)); @@ -80,7 +80,8 @@ static inline int z_vrfy_uart_tx(struct device *dev, const uint8_t *buf, UART_SIMPLE(tx_abort); #include -static inline int z_vrfy_uart_rx_enable(struct device *dev, uint8_t *buf, +static inline int z_vrfy_uart_rx_enable(const struct device *dev, + uint8_t *buf, size_t len, int32_t timeout) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, rx_enable)); @@ -113,30 +114,32 @@ UART_SIMPLE(irq_update) #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ #ifdef CONFIG_UART_LINE_CTRL -static inline int z_vrfy_uart_line_ctrl_set(struct device *dev, +static inline int z_vrfy_uart_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, line_ctrl_set)); - return z_impl_uart_line_ctrl_set((struct device *)dev, ctrl, val); + return z_impl_uart_line_ctrl_set((const struct device *)dev, ctrl, + val); } #include -static inline int z_vrfy_uart_line_ctrl_get(struct device *dev, +static inline int z_vrfy_uart_line_ctrl_get(const struct device *dev, uint32_t ctrl, uint32_t *val) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, line_ctrl_get)); Z_OOPS(Z_SYSCALL_MEMORY_WRITE(val, sizeof(uint32_t))); - return z_impl_uart_line_ctrl_get((struct device *)dev, ctrl, - (uint32_t *)val); + return z_impl_uart_line_ctrl_get((const struct device *)dev, ctrl, + (uint32_t *)val); } #include #endif /* CONFIG_UART_LINE_CTRL */ #ifdef CONFIG_UART_DRV_CMD -static inline int z_vrfy_uart_drv_cmd(struct device *dev, uint32_t cmd, uint32_t p) +static inline int z_vrfy_uart_drv_cmd(const struct device *dev, uint32_t cmd, + uint32_t p) { Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, drv_cmd)); - return z_impl_uart_drv_cmd((struct device *)dev, cmd, p); + return z_impl_uart_drv_cmd((const struct device *)dev, cmd, p); } #include #endif /* CONFIG_UART_DRV_CMD */ diff --git a/drivers/serial/uart_imx.c b/drivers/serial/uart_imx.c index 59df2b9e59ea86..03a10881d6a7bd 100644 --- a/drivers/serial/uart_imx.c +++ b/drivers/serial/uart_imx.c @@ -31,7 +31,7 @@ struct imx_uart_config { uint32_t baud_rate; uint8_t modem_mode; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -52,7 +52,7 @@ struct imx_uart_data { * * @return 0 */ -static int uart_imx_init(struct device *dev) +static int uart_imx_init(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); const struct imx_uart_config *config = dev->config; @@ -95,7 +95,7 @@ static int uart_imx_init(struct device *dev) return 0; } -static void uart_imx_poll_out(struct device *dev, unsigned char c) +static void uart_imx_poll_out(const struct device *dev, unsigned char c) { UART_Type *uart = UART_STRUCT(dev); @@ -104,7 +104,7 @@ static void uart_imx_poll_out(struct device *dev, unsigned char c) UART_Putchar(uart, c); } -static int uart_imx_poll_in(struct device *dev, unsigned char *c) +static int uart_imx_poll_in(const struct device *dev, unsigned char *c) { UART_Type *uart = UART_STRUCT(dev); @@ -121,7 +121,8 @@ static int uart_imx_poll_in(struct device *dev, unsigned char *c) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_imx_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_imx_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { UART_Type *uart = UART_STRUCT(dev); @@ -137,7 +138,7 @@ static int uart_imx_fifo_fill(struct device *dev, const uint8_t *tx_data, return (int)num_tx; } -static int uart_imx_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_imx_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { UART_Type *uart = UART_STRUCT(dev); @@ -156,49 +157,49 @@ static int uart_imx_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void uart_imx_irq_tx_enable(struct device *dev) +static void uart_imx_irq_tx_enable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); UART_SetIntCmd(uart, uartIntTxReady, true); } -static void uart_imx_irq_tx_disable(struct device *dev) +static void uart_imx_irq_tx_disable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); UART_SetIntCmd(uart, uartIntTxReady, false); } -static int uart_imx_irq_tx_ready(struct device *dev) +static int uart_imx_irq_tx_ready(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); return UART_GetStatusFlag(uart, uartStatusTxReady); } -static void uart_imx_irq_rx_enable(struct device *dev) +static void uart_imx_irq_rx_enable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); UART_SetIntCmd(uart, uartIntRxReady, true); } -static void uart_imx_irq_rx_disable(struct device *dev) +static void uart_imx_irq_rx_disable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); UART_SetIntCmd(uart, uartIntRxReady, false); } -static int uart_imx_irq_rx_ready(struct device *dev) +static int uart_imx_irq_rx_ready(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); return UART_GetStatusFlag(uart, uartStatusRxReady); } -static void uart_imx_irq_err_enable(struct device *dev) +static void uart_imx_irq_err_enable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); @@ -206,7 +207,7 @@ static void uart_imx_irq_err_enable(struct device *dev) UART_SetIntCmd(uart, uartIntFrameError, true); } -static void uart_imx_irq_err_disable(struct device *dev) +static void uart_imx_irq_err_disable(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); @@ -214,7 +215,7 @@ static void uart_imx_irq_err_disable(struct device *dev) UART_SetIntCmd(uart, uartIntFrameError, false); } -static int uart_imx_irq_is_pending(struct device *dev) +static int uart_imx_irq_is_pending(const struct device *dev) { UART_Type *uart = UART_STRUCT(dev); @@ -222,14 +223,14 @@ static int uart_imx_irq_is_pending(struct device *dev) UART_GetStatusFlag(uart, uartStatusTxReady); } -static int uart_imx_irq_update(struct device *dev) +static int uart_imx_irq_update(const struct device *dev) { return 1; } -static void uart_imx_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void uart_imx_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct imx_uart_data *data = dev->data; @@ -251,7 +252,7 @@ static void uart_imx_irq_callback_set(struct device *dev, */ void uart_imx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct imx_uart_data *data = dev->data; if (data->callback) { @@ -292,7 +293,7 @@ static const struct uart_driver_api uart_imx_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define UART_IMX_CONFIG_FUNC(n) \ - static void irq_config_func_##n(struct device *dev) \ + static void irq_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/serial/uart_liteuart.c b/drivers/serial/uart_liteuart.c index 0c43522bc22377..63b84553666409 100644 --- a/drivers/serial/uart_liteuart.c +++ b/drivers/serial/uart_liteuart.c @@ -53,7 +53,7 @@ struct uart_liteuart_data { * @param dev UART device struct * @param c Character to send */ -static void uart_liteuart_poll_out(struct device *dev, unsigned char c) +static void uart_liteuart_poll_out(const struct device *dev, unsigned char c) { /* wait for space */ while (sys_read8(UART_TXFULL)) { @@ -70,7 +70,7 @@ static void uart_liteuart_poll_out(struct device *dev, unsigned char c) * * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_liteuart_poll_in(struct device *dev, unsigned char *c) +static int uart_liteuart_poll_in(const struct device *dev, unsigned char *c) { if (!sys_read8(UART_RXEMPTY)) { *c = sys_read8(UART_RXTX); @@ -93,7 +93,7 @@ static int uart_liteuart_poll_in(struct device *dev, unsigned char *c) * * @return N/A */ -static void uart_liteuart_irq_tx_enable(struct device *dev) +static void uart_liteuart_irq_tx_enable(const struct device *dev) { uint8_t enable = sys_read8(UART_EV_ENABLE); @@ -107,7 +107,7 @@ static void uart_liteuart_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_liteuart_irq_tx_disable(struct device *dev) +static void uart_liteuart_irq_tx_disable(const struct device *dev) { uint8_t enable = sys_read8(UART_EV_ENABLE); @@ -121,7 +121,7 @@ static void uart_liteuart_irq_tx_disable(struct device *dev) * * @return N/A */ -static void uart_liteuart_irq_rx_enable(struct device *dev) +static void uart_liteuart_irq_rx_enable(const struct device *dev) { uint8_t enable = sys_read8(UART_EV_ENABLE); @@ -135,7 +135,7 @@ static void uart_liteuart_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_liteuart_irq_rx_disable(struct device *dev) +static void uart_liteuart_irq_rx_disable(const struct device *dev) { uint8_t enable = sys_read8(UART_EV_ENABLE); @@ -149,7 +149,7 @@ static void uart_liteuart_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ has been raised, 0 otherwise */ -static int uart_liteuart_irq_tx_ready(struct device *dev) +static int uart_liteuart_irq_tx_ready(const struct device *dev) { uint8_t val = sys_read8(UART_TXFULL); @@ -163,7 +163,7 @@ static int uart_liteuart_irq_tx_ready(struct device *dev) * * @return 1 if an IRQ has been raised, 0 otherwise */ -static int uart_liteuart_irq_rx_ready(struct device *dev) +static int uart_liteuart_irq_rx_ready(const struct device *dev) { uint8_t pending; @@ -185,8 +185,8 @@ static int uart_liteuart_irq_rx_ready(struct device *dev) * * @return Number of bytes sent */ -static int uart_liteuart_fifo_fill(struct device *dev, - const uint8_t *tx_data, int size) +static int uart_liteuart_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { int i; @@ -206,8 +206,8 @@ static int uart_liteuart_fifo_fill(struct device *dev, * * @return Number of bytes read */ -static int uart_liteuart_fifo_read(struct device *dev, - uint8_t *rx_data, const int size) +static int uart_liteuart_fifo_read(const struct device *dev, + uint8_t *rx_data, const int size) { int i; @@ -223,7 +223,7 @@ static int uart_liteuart_fifo_read(struct device *dev, return i; } -static void uart_liteuart_irq_err(struct device *dev) +static void uart_liteuart_irq_err(const struct device *dev) { ARG_UNUSED(dev); } @@ -235,7 +235,7 @@ static void uart_liteuart_irq_err(struct device *dev) * * @return 1 if an IRQ is pending, 0 otherwise */ -static int uart_liteuart_irq_is_pending(struct device *dev) +static int uart_liteuart_irq_is_pending(const struct device *dev) { uint8_t pending; @@ -248,7 +248,7 @@ static int uart_liteuart_irq_is_pending(struct device *dev) } } -static int uart_liteuart_irq_update(struct device *dev) +static int uart_liteuart_irq_update(const struct device *dev) { return 1; } @@ -261,9 +261,9 @@ static int uart_liteuart_irq_update(struct device *dev) * * @return N/A */ -static void uart_liteuart_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void uart_liteuart_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct uart_liteuart_data *data; @@ -274,7 +274,7 @@ static void uart_liteuart_irq_callback_set(struct device *dev, static void liteuart_uart_irq_handler(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct uart_liteuart_data *data = DEV_DATA(dev); int key = irq_lock(); @@ -311,7 +311,7 @@ static const struct uart_driver_api uart_liteuart_driver_api = { }; static struct uart_liteuart_data uart_liteuart_data_0; -static int uart_liteuart_init(struct device *dev); +static int uart_liteuart_init(const struct device *dev); static const struct uart_liteuart_device_config uart_liteuart_dev_cfg_0 = { .port = UART_BASE_ADDR, @@ -324,7 +324,7 @@ DEVICE_AND_API_INIT(uart_liteuart_0, DT_INST_LABEL(0), PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, (void *)&uart_liteuart_driver_api); -static int uart_liteuart_init(struct device *dev) +static int uart_liteuart_init(const struct device *dev) { sys_write8(UART_EV_TX | UART_EV_RX, UART_EV_PENDING); diff --git a/drivers/serial/uart_lpc11u6x.c b/drivers/serial/uart_lpc11u6x.c index f399e24d945799..9ca755f9c6a1d1 100644 --- a/drivers/serial/uart_lpc11u6x.c +++ b/drivers/serial/uart_lpc11u6x.c @@ -17,7 +17,7 @@ #define DEV_DATA(dev) ((dev)->data) #if DT_NODE_HAS_STATUS(DT_NODELABEL(uart0), okay) -static int lpc11u6x_uart0_poll_in(struct device *dev, unsigned char *c) +static int lpc11u6x_uart0_poll_in(const struct device *dev, unsigned char *c) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -29,7 +29,7 @@ static int lpc11u6x_uart0_poll_in(struct device *dev, unsigned char *c) return 0; } -static void lpc11u6x_uart0_poll_out(struct device *dev, unsigned char c) +static void lpc11u6x_uart0_poll_out(const struct device *dev, unsigned char c) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -38,7 +38,7 @@ static void lpc11u6x_uart0_poll_out(struct device *dev, unsigned char c) cfg->uart0->thr = c; } -static int lpc11u6x_uart0_err_check(struct device *dev) +static int lpc11u6x_uart0_err_check(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); uint32_t lsr; @@ -77,9 +77,9 @@ static void lpc11u6x_uart0_write_fdr(struct lpc11u6x_uart0_regs *uart0, uart0->fdr = (div & 0xF) | ((mul & 0xF) << 4); } -static void lpc11u6x_uart0_config_baudrate(struct device *clk_drv, - const struct lpc11u6x_uart0_config *cfg, - uint32_t baudrate) +static void lpc11u6x_uart0_config_baudrate(const struct device *clk_drv, + const struct lpc11u6x_uart0_config *cfg, + uint32_t baudrate) { uint32_t div = 1, mul, dl; uint32_t pclk; @@ -100,12 +100,12 @@ static void lpc11u6x_uart0_config_baudrate(struct device *clk_drv, lpc11u6x_uart0_write_fdr(cfg->uart0, div, mul); } -static int lpc11u6x_uart0_configure(struct device *dev, +static int lpc11u6x_uart0_configure(const struct device *dev, const struct uart_config *cfg) { const struct lpc11u6x_uart0_config *dev_cfg = DEV_CFG(dev); struct lpc11u6x_uart0_data *data = DEV_DATA(dev); - struct device *clk_dev; + const struct device *clk_dev; uint32_t flags = 0; /* Check that the baudrate is a multiple of 9600 */ @@ -186,7 +186,7 @@ static int lpc11u6x_uart0_configure(struct device *dev, return 0; } -static int lpc11u6x_uart0_config_get(struct device *dev, +static int lpc11u6x_uart0_config_get(const struct device *dev, struct uart_config *cfg) { struct lpc11u6x_uart0_data *data = DEV_DATA(dev); @@ -201,7 +201,8 @@ static int lpc11u6x_uart0_config_get(struct device *dev, } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int lpc11u6x_uart0_fifo_fill(struct device *dev, const uint8_t *data, +static int lpc11u6x_uart0_fifo_fill(const struct device *dev, + const uint8_t *data, const int size) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -214,7 +215,7 @@ static int lpc11u6x_uart0_fifo_fill(struct device *dev, const uint8_t *data, return nr_sent; } -static int lpc11u6x_uart0_fifo_read(struct device *dev, uint8_t *data, +static int lpc11u6x_uart0_fifo_read(const struct device *dev, uint8_t *data, const int size) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -227,7 +228,7 @@ static int lpc11u6x_uart0_fifo_read(struct device *dev, uint8_t *data, return nr_rx; } -static void lpc11u6x_uart0_irq_tx_enable(struct device *dev) +static void lpc11u6x_uart0_irq_tx_enable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -240,7 +241,7 @@ static void lpc11u6x_uart0_irq_tx_enable(struct device *dev) NVIC_SetPendingIRQ(DT_INST_IRQN(0)); } -static void lpc11u6x_uart0_irq_tx_disable(struct device *dev) +static void lpc11u6x_uart0_irq_tx_disable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -248,14 +249,14 @@ static void lpc11u6x_uart0_irq_tx_disable(struct device *dev) ~LPC11U6X_UART0_IER_THREINTEN; } -static int lpc11u6x_uart0_irq_tx_complete(struct device *dev) +static int lpc11u6x_uart0_irq_tx_complete(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); return (cfg->uart0->lsr & LPC11U6X_UART0_LSR_TEMT) != 0; } -static int lpc11u6x_uart0_irq_tx_ready(struct device *dev) +static int lpc11u6x_uart0_irq_tx_ready(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -263,7 +264,7 @@ static int lpc11u6x_uart0_irq_tx_ready(struct device *dev) (cfg->uart0->ier & LPC11U6X_UART0_IER_THREINTEN); } -static void lpc11u6x_uart0_irq_rx_enable(struct device *dev) +static void lpc11u6x_uart0_irq_rx_enable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -271,7 +272,7 @@ static void lpc11u6x_uart0_irq_rx_enable(struct device *dev) LPC11U6X_UART0_IER_RBRINTEN; } -static void lpc11u6x_uart0_irq_rx_disable(struct device *dev) +static void lpc11u6x_uart0_irq_rx_disable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -279,7 +280,7 @@ static void lpc11u6x_uart0_irq_rx_disable(struct device *dev) ~LPC11U6X_UART0_IER_RBRINTEN; } -static int lpc11u6x_uart0_irq_rx_ready(struct device *dev) +static int lpc11u6x_uart0_irq_rx_ready(const struct device *dev) { struct lpc11u6x_uart0_data *data = DEV_DATA(dev); @@ -289,7 +290,7 @@ static int lpc11u6x_uart0_irq_rx_ready(struct device *dev) LPC11U6X_UART0_IIR_INTID_CTI); } -static void lpc11u6x_uart0_irq_err_enable(struct device *dev) +static void lpc11u6x_uart0_irq_err_enable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -297,7 +298,7 @@ static void lpc11u6x_uart0_irq_err_enable(struct device *dev) LPC11U6X_UART0_IER_RLSINTEN; } -static void lpc11u6x_uart0_irq_err_disable(struct device *dev) +static void lpc11u6x_uart0_irq_err_disable(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); @@ -305,14 +306,14 @@ static void lpc11u6x_uart0_irq_err_disable(struct device *dev) ~LPC11U6X_UART0_IER_RLSINTEN; } -static int lpc11u6x_uart0_irq_is_pending(struct device *dev) +static int lpc11u6x_uart0_irq_is_pending(const struct device *dev) { struct lpc11u6x_uart0_data *data = DEV_DATA(dev); return !(data->cached_iir & LPC11U6X_UART0_IIR_STATUS); } -static int lpc11u6x_uart0_irq_update(struct device *dev) +static int lpc11u6x_uart0_irq_update(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); struct lpc11u6x_uart0_data *data = DEV_DATA(dev); @@ -321,7 +322,7 @@ static int lpc11u6x_uart0_irq_update(struct device *dev) return 1; } -static void lpc11u6x_uart0_irq_callback_set(struct device *dev, +static void lpc11u6x_uart0_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data) { @@ -333,7 +334,7 @@ static void lpc11u6x_uart0_irq_callback_set(struct device *dev, static void lpc11u6x_uart0_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct lpc11u6x_uart0_data *data = DEV_DATA(dev); if (data->cb) { @@ -342,11 +343,11 @@ static void lpc11u6x_uart0_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int lpc11u6x_uart0_init(struct device *dev) +static int lpc11u6x_uart0_init(const struct device *dev) { const struct lpc11u6x_uart0_config *cfg = DEV_CFG(dev); struct lpc11u6x_uart0_data *data = DEV_DATA(dev); - struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv; + const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv; /* Configure RX and TX pin via the pinmux driver */ rx_pinmux_drv = device_get_binding(cfg->rx_pinmux_drv_name); @@ -390,7 +391,7 @@ static int lpc11u6x_uart0_init(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void lpc11u6x_uart0_isr_config(struct device *dev); +static void lpc11u6x_uart0_isr_config(const struct device *dev); #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ static const struct lpc11u6x_uart0_config uart0_config = { @@ -445,7 +446,7 @@ DEVICE_AND_API_INIT(lpc11u6x_uart0, DT_LABEL(DT_NODELABEL(uart0)), &uart0_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void lpc11u6x_uart0_isr_config(struct device *dev) +static void lpc11u6x_uart0_isr_config(const struct device *dev) { IRQ_CONNECT(DT_IRQN(DT_NODELABEL(uart0)), DT_IRQ(DT_NODELABEL(uart0), priority), @@ -462,7 +463,7 @@ static void lpc11u6x_uart0_isr_config(struct device *dev) DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay) || \ DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay) -static int lpc11u6x_uartx_poll_in(struct device *dev, unsigned char *c) +static int lpc11u6x_uartx_poll_in(const struct device *dev, unsigned char *c) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -473,7 +474,7 @@ static int lpc11u6x_uartx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void lpc11u6x_uartx_poll_out(struct device *dev, unsigned char c) +static void lpc11u6x_uartx_poll_out(const struct device *dev, unsigned char c) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -482,7 +483,7 @@ static void lpc11u6x_uartx_poll_out(struct device *dev, unsigned char c) cfg->base->tx_dat = c; } -static int lpc11u6x_uartx_err_check(struct device *dev) +static int lpc11u6x_uartx_err_check(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); int ret = 0; @@ -501,7 +502,7 @@ static int lpc11u6x_uartx_err_check(struct device *dev) } static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg, - struct device *clk_drv, + const struct device *clk_drv, uint32_t baudrate) { uint32_t clk_rate; @@ -517,12 +518,12 @@ static void lpc11u6x_uartx_config_baud(const struct lpc11u6x_uartx_config *cfg, cfg->base->brg = div & LPC11U6X_UARTX_BRG_MASK; } -static int lpc11u6x_uartx_configure(struct device *dev, +static int lpc11u6x_uartx_configure(const struct device *dev, const struct uart_config *cfg) { const struct lpc11u6x_uartx_config *dev_cfg = DEV_CFG(dev); struct lpc11u6x_uartx_data *data = DEV_DATA(dev); - struct device *clk_dev; + const struct device *clk_dev; uint32_t flags = 0; /* We only support baudrates that are multiple of 9600 */ @@ -608,7 +609,7 @@ static int lpc11u6x_uartx_configure(struct device *dev, return 0; } -static int lpc11u6x_uartx_config_get(struct device *dev, +static int lpc11u6x_uartx_config_get(const struct device *dev, struct uart_config *cfg) { const struct lpc11u6x_uartx_data *data = DEV_DATA(dev); @@ -623,7 +624,8 @@ static int lpc11u6x_uartx_config_get(struct device *dev, } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int lpc11u6x_uartx_fifo_fill(struct device *dev, const uint8_t *data, +static int lpc11u6x_uartx_fifo_fill(const struct device *dev, + const uint8_t *data, int size) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -636,7 +638,8 @@ static int lpc11u6x_uartx_fifo_fill(struct device *dev, const uint8_t *data, return tx_size; } -static int lpc11u6x_uartx_fifo_read(struct device *dev, uint8_t *data, int size) +static int lpc11u6x_uartx_fifo_read(const struct device *dev, uint8_t *data, + int size) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); int rx_size = 0; @@ -648,7 +651,7 @@ static int lpc11u6x_uartx_fifo_read(struct device *dev, uint8_t *data, int size) return rx_size; } -static void lpc11u6x_uartx_irq_tx_enable(struct device *dev) +static void lpc11u6x_uartx_irq_tx_enable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -657,14 +660,14 @@ static void lpc11u6x_uartx_irq_tx_enable(struct device *dev) LPC11U6X_UARTX_INT_EN_SET_TXRDYEN; } -static void lpc11u6x_uartx_irq_tx_disable(struct device *dev) +static void lpc11u6x_uartx_irq_tx_disable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); cfg->base->int_en_clr = LPC11U6X_UARTX_INT_EN_CLR_TXRDYCLR; } -static int lpc11u6x_uartx_irq_tx_ready(struct device *dev) +static int lpc11u6x_uartx_irq_tx_ready(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -672,14 +675,14 @@ static int lpc11u6x_uartx_irq_tx_ready(struct device *dev) (cfg->base->int_en_set & LPC11U6X_UARTX_INT_EN_SET_TXRDYEN); } -static int lpc11u6x_uartx_irq_tx_complete(struct device *dev) +static int lpc11u6x_uartx_irq_tx_complete(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); return (cfg->base->stat & LPC11U6X_UARTX_STAT_TXIDLE) != 0; } -static void lpc11u6x_uartx_irq_rx_enable(struct device *dev) +static void lpc11u6x_uartx_irq_rx_enable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -688,14 +691,14 @@ static void lpc11u6x_uartx_irq_rx_enable(struct device *dev) LPC11U6X_UARTX_INT_EN_SET_RXRDYEN; } -static void lpc11u6x_uartx_irq_rx_disable(struct device *dev) +static void lpc11u6x_uartx_irq_rx_disable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); cfg->base->int_en_clr = LPC11U6X_UARTX_INT_EN_CLR_RXRDYCLR; } -static int lpc11u6x_uartx_irq_rx_ready(struct device *dev) +static int lpc11u6x_uartx_irq_rx_ready(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -703,7 +706,7 @@ static int lpc11u6x_uartx_irq_rx_ready(struct device *dev) (cfg->base->int_en_set & LPC11U6X_UARTX_INT_EN_SET_RXRDYEN); } -static void lpc11u6x_uartx_irq_err_enable(struct device *dev) +static void lpc11u6x_uartx_irq_err_enable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -714,7 +717,7 @@ static void lpc11u6x_uartx_irq_err_enable(struct device *dev) LPC11U6X_UARTX_INT_EN_SET_PARITYERREN); } -static void lpc11u6x_uartx_irq_err_disable(struct device *dev) +static void lpc11u6x_uartx_irq_err_disable(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -723,7 +726,7 @@ static void lpc11u6x_uartx_irq_err_disable(struct device *dev) LPC11U6X_UARTX_INT_EN_CLR_PARITYERRCLR; } -static int lpc11u6x_uartx_irq_is_pending(struct device *dev) +static int lpc11u6x_uartx_irq_is_pending(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); @@ -743,12 +746,12 @@ static int lpc11u6x_uartx_irq_is_pending(struct device *dev) return 0; } -static int lpc11u6x_uartx_irq_update(struct device *dev) +static int lpc11u6x_uartx_irq_update(const struct device *dev) { return 1; } -static void lpc11u6x_uartx_irq_callback_set(struct device *dev, +static void lpc11u6x_uartx_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data) { @@ -758,7 +761,7 @@ static void lpc11u6x_uartx_irq_callback_set(struct device *dev, data->cb_data = user_data; } -static void lpc11u6x_uartx_isr(struct device *dev) +static void lpc11u6x_uartx_isr(const struct device *dev) { struct lpc11u6x_uartx_data *data = DEV_DATA(dev); @@ -780,11 +783,11 @@ static void lpc11u6x_uartx_shared_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int lpc11u6x_uartx_init(struct device *dev) +static int lpc11u6x_uartx_init(const struct device *dev) { const struct lpc11u6x_uartx_config *cfg = DEV_CFG(dev); struct lpc11u6x_uartx_data *data = DEV_DATA(dev); - struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv; + const struct device *clk_drv, *rx_pinmux_drv, *tx_pinmux_drv; /* Configure RX and TX pin via the pinmux driver */ rx_pinmux_drv = device_get_binding(cfg->rx_pinmux_drv_name); @@ -930,7 +933,7 @@ struct lpc11u6x_uartx_shared_irq lpc11u6x_uartx_shared_irq_info_1 = { }, }; -static void lpc11u6x_uartx_isr_config_1(struct device *dev) +static void lpc11u6x_uartx_isr_config_1(const struct device *dev) { #if DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) IRQ_CONNECT(DT_IRQN(DT_NODELABEL(uart1)), @@ -971,7 +974,7 @@ struct lpc11u6x_uartx_shared_irq lpc11u6x_uartx_shared_irq_info_2 = { }, }; -static void lpc11u6x_uartx_isr_config_2(struct device *dev) +static void lpc11u6x_uartx_isr_config_2(const struct device *dev) { #if DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) IRQ_CONNECT(DT_IRQN(DT_NODELABEL(uart2)), diff --git a/drivers/serial/uart_lpc11u6x.h b/drivers/serial/uart_lpc11u6x.h index be6699249a5910..17779ab2af9284 100644 --- a/drivers/serial/uart_lpc11u6x.h +++ b/drivers/serial/uart_lpc11u6x.h @@ -136,7 +136,7 @@ struct lpc11u6x_uart0_config { uint8_t tx_pin; uint8_t tx_func; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; @@ -198,13 +198,13 @@ struct lpc11u6x_uartx_data { * notified when said IRQ is raied */ struct lpc11u6x_uartx_shared_irq { - struct device *devices[LPC11U6X_UARTX_DEVICE_PER_IRQ]; + const struct device *devices[LPC11U6X_UARTX_DEVICE_PER_IRQ]; }; #if CONFIG_UART_INTERRUPT_DRIVEN && \ (DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay) || \ DT_NODE_HAS_STATUS(DT_NODELABEL(uart4), okay)) -static void lpc11u6x_uartx_isr_config_1(struct device *dev); +static void lpc11u6x_uartx_isr_config_1(const struct device *dev); #endif /* CONFIG_UART_INTERRUPT_DRIVEN && * (DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) || * DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)) @@ -213,7 +213,7 @@ static void lpc11u6x_uartx_isr_config_1(struct device *dev); #if CONFIG_UART_INTERRUPT_DRIVEN && \ (DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) || \ DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)) -static void lpc11u6x_uartx_isr_config_2(struct device *dev); +static void lpc11u6x_uartx_isr_config_2(const struct device *dev); #endif /* CONFIG_UART_INTERRUPT_DRIVEN && * (DT_NODE_HAS_STATUS(DT_NODELABEL(uart2), okay) || * DT_NODE_HAS_STATUS(DT_NODELABEL(uart3), okay)) diff --git a/drivers/serial/uart_mcux.c b/drivers/serial/uart_mcux.c index 6223cd8edbdf0a..2f56ad5dcf0132 100644 --- a/drivers/serial/uart_mcux.c +++ b/drivers/serial/uart_mcux.c @@ -19,7 +19,7 @@ struct uart_mcux_config { char *clock_name; clock_control_subsys_t clock_subsys; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -31,13 +31,13 @@ struct uart_mcux_data { #endif }; -static int uart_mcux_configure(struct device *dev, +static int uart_mcux_configure(const struct device *dev, const struct uart_config *cfg) { const struct uart_mcux_config *config = dev->config; struct uart_mcux_data *data = dev->data; uart_config_t uart_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; status_t retval; @@ -108,7 +108,8 @@ FSL_FEATURE_UART_HAS_STOP_BIT_CONFIG_SUPPORT return 0; } -static int uart_mcux_config_get(struct device *dev, struct uart_config *cfg) +static int uart_mcux_config_get(const struct device *dev, + struct uart_config *cfg) { struct uart_mcux_data *data = dev->data; @@ -117,7 +118,7 @@ static int uart_mcux_config_get(struct device *dev, struct uart_config *cfg) return 0; } -static int uart_mcux_poll_in(struct device *dev, unsigned char *c) +static int uart_mcux_poll_in(const struct device *dev, unsigned char *c) { const struct uart_mcux_config *config = dev->config; uint32_t flags = UART_GetStatusFlags(config->base); @@ -131,7 +132,7 @@ static int uart_mcux_poll_in(struct device *dev, unsigned char *c) return ret; } -static void uart_mcux_poll_out(struct device *dev, unsigned char c) +static void uart_mcux_poll_out(const struct device *dev, unsigned char c) { const struct uart_mcux_config *config = dev->config; @@ -141,7 +142,7 @@ static void uart_mcux_poll_out(struct device *dev, unsigned char c) UART_WriteByte(config->base, c); } -static int uart_mcux_err_check(struct device *dev) +static int uart_mcux_err_check(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t flags = UART_GetStatusFlags(config->base); @@ -167,7 +168,8 @@ static int uart_mcux_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_mcux_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_mcux_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { const struct uart_mcux_config *config = dev->config; @@ -182,7 +184,7 @@ static int uart_mcux_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int uart_mcux_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_mcux_fifo_read(const struct device *dev, uint8_t *rx_data, const int len) { const struct uart_mcux_config *config = dev->config; @@ -197,7 +199,7 @@ static int uart_mcux_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void uart_mcux_irq_tx_enable(struct device *dev) +static void uart_mcux_irq_tx_enable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_TxDataRegEmptyInterruptEnable; @@ -205,7 +207,7 @@ static void uart_mcux_irq_tx_enable(struct device *dev) UART_EnableInterrupts(config->base, mask); } -static void uart_mcux_irq_tx_disable(struct device *dev) +static void uart_mcux_irq_tx_disable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_TxDataRegEmptyInterruptEnable; @@ -213,7 +215,7 @@ static void uart_mcux_irq_tx_disable(struct device *dev) UART_DisableInterrupts(config->base, mask); } -static int uart_mcux_irq_tx_complete(struct device *dev) +static int uart_mcux_irq_tx_complete(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t flags = UART_GetStatusFlags(config->base); @@ -221,7 +223,7 @@ static int uart_mcux_irq_tx_complete(struct device *dev) return (flags & kUART_TransmissionCompleteFlag) != 0U; } -static int uart_mcux_irq_tx_ready(struct device *dev) +static int uart_mcux_irq_tx_ready(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_TxDataRegEmptyInterruptEnable; @@ -231,7 +233,7 @@ static int uart_mcux_irq_tx_ready(struct device *dev) && (flags & kUART_TxDataRegEmptyFlag); } -static void uart_mcux_irq_rx_enable(struct device *dev) +static void uart_mcux_irq_rx_enable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_RxDataRegFullInterruptEnable; @@ -239,7 +241,7 @@ static void uart_mcux_irq_rx_enable(struct device *dev) UART_EnableInterrupts(config->base, mask); } -static void uart_mcux_irq_rx_disable(struct device *dev) +static void uart_mcux_irq_rx_disable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_RxDataRegFullInterruptEnable; @@ -247,7 +249,7 @@ static void uart_mcux_irq_rx_disable(struct device *dev) UART_DisableInterrupts(config->base, mask); } -static int uart_mcux_irq_rx_full(struct device *dev) +static int uart_mcux_irq_rx_full(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t flags = UART_GetStatusFlags(config->base); @@ -255,7 +257,7 @@ static int uart_mcux_irq_rx_full(struct device *dev) return (flags & kUART_RxDataRegFullFlag) != 0U; } -static int uart_mcux_irq_rx_ready(struct device *dev) +static int uart_mcux_irq_rx_ready(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_RxDataRegFullInterruptEnable; @@ -264,7 +266,7 @@ static int uart_mcux_irq_rx_ready(struct device *dev) && uart_mcux_irq_rx_full(dev); } -static void uart_mcux_irq_err_enable(struct device *dev) +static void uart_mcux_irq_err_enable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_NoiseErrorInterruptEnable | @@ -274,7 +276,7 @@ static void uart_mcux_irq_err_enable(struct device *dev) UART_EnableInterrupts(config->base, mask); } -static void uart_mcux_irq_err_disable(struct device *dev) +static void uart_mcux_irq_err_disable(const struct device *dev) { const struct uart_mcux_config *config = dev->config; uint32_t mask = kUART_NoiseErrorInterruptEnable | @@ -284,17 +286,17 @@ static void uart_mcux_irq_err_disable(struct device *dev) UART_DisableInterrupts(config->base, mask); } -static int uart_mcux_irq_is_pending(struct device *dev) +static int uart_mcux_irq_is_pending(const struct device *dev) { return uart_mcux_irq_tx_ready(dev) || uart_mcux_irq_rx_ready(dev); } -static int uart_mcux_irq_update(struct device *dev) +static int uart_mcux_irq_update(const struct device *dev) { return 1; } -static void uart_mcux_irq_callback_set(struct device *dev, +static void uart_mcux_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -306,7 +308,7 @@ static void uart_mcux_irq_callback_set(struct device *dev, static void uart_mcux_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_mcux_data *data = dev->data; if (data->callback) { @@ -315,7 +317,7 @@ static void uart_mcux_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int uart_mcux_init(struct device *dev) +static int uart_mcux_init(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_mcux_config *config = dev->config; @@ -369,7 +371,7 @@ static const struct uart_mcux_config uart_mcux_##n##_config = { \ #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define UART_MCUX_CONFIG_FUNC(n) \ - static void uart_mcux_config_func_##n(struct device *dev) \ + static void uart_mcux_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQ_BY_NAME(n, status, irq), \ DT_INST_IRQ_BY_NAME(n, status, priority), \ diff --git a/drivers/serial/uart_mcux_flexcomm.c b/drivers/serial/uart_mcux_flexcomm.c index 480a71ff62becc..345b931dec6b14 100644 --- a/drivers/serial/uart_mcux_flexcomm.c +++ b/drivers/serial/uart_mcux_flexcomm.c @@ -27,7 +27,7 @@ struct mcux_flexcomm_config { uint32_t clock_source; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -38,7 +38,7 @@ struct mcux_flexcomm_data { #endif }; -static int mcux_flexcomm_poll_in(struct device *dev, unsigned char *c) +static int mcux_flexcomm_poll_in(const struct device *dev, unsigned char *c) { const struct mcux_flexcomm_config *config = dev->config; uint32_t flags = USART_GetStatusFlags(config->base); @@ -52,7 +52,7 @@ static int mcux_flexcomm_poll_in(struct device *dev, unsigned char *c) return ret; } -static void mcux_flexcomm_poll_out(struct device *dev, +static void mcux_flexcomm_poll_out(const struct device *dev, unsigned char c) { const struct mcux_flexcomm_config *config = dev->config; @@ -64,7 +64,7 @@ static void mcux_flexcomm_poll_out(struct device *dev, USART_WriteByte(config->base, c); } -static int mcux_flexcomm_err_check(struct device *dev) +static int mcux_flexcomm_err_check(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t flags = USART_GetStatusFlags(config->base); @@ -91,8 +91,9 @@ static int mcux_flexcomm_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int mcux_flexcomm_fifo_fill(struct device *dev, const uint8_t *tx_data, - int len) +static int mcux_flexcomm_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int len) { const struct mcux_flexcomm_config *config = dev->config; uint8_t num_tx = 0U; @@ -107,8 +108,8 @@ static int mcux_flexcomm_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int mcux_flexcomm_fifo_read(struct device *dev, uint8_t *rx_data, - const int len) +static int mcux_flexcomm_fifo_read(const struct device *dev, uint8_t *rx_data, + const int len) { const struct mcux_flexcomm_config *config = dev->config; uint8_t num_rx = 0U; @@ -123,7 +124,7 @@ static int mcux_flexcomm_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void mcux_flexcomm_irq_tx_enable(struct device *dev) +static void mcux_flexcomm_irq_tx_enable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_TxLevelInterruptEnable; @@ -131,7 +132,7 @@ static void mcux_flexcomm_irq_tx_enable(struct device *dev) USART_EnableInterrupts(config->base, mask); } -static void mcux_flexcomm_irq_tx_disable(struct device *dev) +static void mcux_flexcomm_irq_tx_disable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_TxLevelInterruptEnable; @@ -139,14 +140,14 @@ static void mcux_flexcomm_irq_tx_disable(struct device *dev) USART_DisableInterrupts(config->base, mask); } -static int mcux_flexcomm_irq_tx_complete(struct device *dev) +static int mcux_flexcomm_irq_tx_complete(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; return (config->base->STAT & USART_STAT_TXIDLE_MASK) != 0; } -static int mcux_flexcomm_irq_tx_ready(struct device *dev) +static int mcux_flexcomm_irq_tx_ready(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_TxLevelInterruptEnable; @@ -156,7 +157,7 @@ static int mcux_flexcomm_irq_tx_ready(struct device *dev) && (flags & kUSART_TxFifoEmptyFlag); } -static void mcux_flexcomm_irq_rx_enable(struct device *dev) +static void mcux_flexcomm_irq_rx_enable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_RxLevelInterruptEnable; @@ -164,7 +165,7 @@ static void mcux_flexcomm_irq_rx_enable(struct device *dev) USART_EnableInterrupts(config->base, mask); } -static void mcux_flexcomm_irq_rx_disable(struct device *dev) +static void mcux_flexcomm_irq_rx_disable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_RxLevelInterruptEnable; @@ -172,7 +173,7 @@ static void mcux_flexcomm_irq_rx_disable(struct device *dev) USART_DisableInterrupts(config->base, mask); } -static int mcux_flexcomm_irq_rx_full(struct device *dev) +static int mcux_flexcomm_irq_rx_full(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t flags = USART_GetStatusFlags(config->base); @@ -180,7 +181,7 @@ static int mcux_flexcomm_irq_rx_full(struct device *dev) return (flags & kUSART_RxFifoNotEmptyFlag) != 0U; } -static int mcux_flexcomm_irq_rx_ready(struct device *dev) +static int mcux_flexcomm_irq_rx_ready(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kUSART_RxLevelInterruptEnable; @@ -189,7 +190,7 @@ static int mcux_flexcomm_irq_rx_ready(struct device *dev) && mcux_flexcomm_irq_rx_full(dev); } -static void mcux_flexcomm_irq_err_enable(struct device *dev) +static void mcux_flexcomm_irq_err_enable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kStatus_USART_NoiseError | @@ -199,7 +200,7 @@ static void mcux_flexcomm_irq_err_enable(struct device *dev) USART_EnableInterrupts(config->base, mask); } -static void mcux_flexcomm_irq_err_disable(struct device *dev) +static void mcux_flexcomm_irq_err_disable(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; uint32_t mask = kStatus_USART_NoiseError | @@ -209,20 +210,20 @@ static void mcux_flexcomm_irq_err_disable(struct device *dev) USART_DisableInterrupts(config->base, mask); } -static int mcux_flexcomm_irq_is_pending(struct device *dev) +static int mcux_flexcomm_irq_is_pending(const struct device *dev) { return (mcux_flexcomm_irq_tx_ready(dev) || mcux_flexcomm_irq_rx_ready(dev)); } -static int mcux_flexcomm_irq_update(struct device *dev) +static int mcux_flexcomm_irq_update(const struct device *dev) { return 1; } -static void mcux_flexcomm_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void mcux_flexcomm_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct mcux_flexcomm_data *data = dev->data; @@ -232,7 +233,7 @@ static void mcux_flexcomm_irq_callback_set(struct device *dev, static void mcux_flexcomm_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mcux_flexcomm_data *data = dev->data; if (data->callback) { @@ -242,7 +243,7 @@ static void mcux_flexcomm_isr(void *arg) #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int mcux_flexcomm_init(struct device *dev) +static int mcux_flexcomm_init(const struct device *dev) { const struct mcux_flexcomm_config *config = dev->config; usart_config_t usart_config; @@ -289,7 +290,7 @@ static const struct uart_driver_api mcux_flexcomm_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define UART_MCUX_FLEXCOMM_CONFIG_FUNC(n) \ - static void mcux_flexcomm_config_func_##n(struct device *dev) \ + static void mcux_flexcomm_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/serial/uart_mcux_iuart.c b/drivers/serial/uart_mcux_iuart.c index 01fa5773fe2589..24c3b405a3a2d1 100644 --- a/drivers/serial/uart_mcux_iuart.c +++ b/drivers/serial/uart_mcux_iuart.c @@ -19,7 +19,7 @@ struct mcux_iuart_config { clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -33,7 +33,7 @@ struct mcux_iuart_data { #define DEV_CFG(dev) \ ((const struct mcux_iuart_config * const)(dev)->config) -static int mcux_iuart_poll_in(struct device *dev, unsigned char *c) +static int mcux_iuart_poll_in(const struct device *dev, unsigned char *c) { const struct mcux_iuart_config *config = DEV_CFG(dev); int ret = -1; @@ -46,7 +46,7 @@ static int mcux_iuart_poll_in(struct device *dev, unsigned char *c) return ret; } -static void mcux_iuart_poll_out(struct device *dev, unsigned char c) +static void mcux_iuart_poll_out(const struct device *dev, unsigned char c) { const struct mcux_iuart_config *config = DEV_CFG(dev); @@ -56,7 +56,7 @@ static void mcux_iuart_poll_out(struct device *dev, unsigned char c) UART_WriteByte(config->base, c); } -static int mcux_iuart_err_check(struct device *dev) +static int mcux_iuart_err_check(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); int err = 0; @@ -80,8 +80,9 @@ static int mcux_iuart_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int mcux_iuart_fifo_fill(struct device *dev, const uint8_t *tx_data, - int len) +static int mcux_iuart_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int len) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint8_t num_tx = 0U; @@ -95,8 +96,8 @@ static int mcux_iuart_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int mcux_iuart_fifo_read(struct device *dev, uint8_t *rx_data, - const int len) +static int mcux_iuart_fifo_read(const struct device *dev, uint8_t *rx_data, + const int len) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint8_t num_rx = 0U; @@ -110,28 +111,28 @@ static int mcux_iuart_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void mcux_iuart_irq_tx_enable(struct device *dev) +static void mcux_iuart_irq_tx_enable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); UART_EnableInterrupts(config->base, kUART_TxEmptyEnable); } -static void mcux_iuart_irq_tx_disable(struct device *dev) +static void mcux_iuart_irq_tx_disable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); UART_DisableInterrupts(config->base, kUART_TxEmptyEnable); } -static int mcux_iuart_irq_tx_complete(struct device *dev) +static int mcux_iuart_irq_tx_complete(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); return (UART_GetStatusFlag(config->base, kUART_TxEmptyFlag)) != 0U; } -static int mcux_iuart_irq_tx_ready(struct device *dev) +static int mcux_iuart_irq_tx_ready(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_TxEmptyEnable; @@ -140,7 +141,7 @@ static int mcux_iuart_irq_tx_ready(struct device *dev) && mcux_iuart_irq_tx_complete(dev); } -static void mcux_iuart_irq_rx_enable(struct device *dev) +static void mcux_iuart_irq_rx_enable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_RxDataReadyEnable; @@ -148,7 +149,7 @@ static void mcux_iuart_irq_rx_enable(struct device *dev) UART_EnableInterrupts(config->base, mask); } -static void mcux_iuart_irq_rx_disable(struct device *dev) +static void mcux_iuart_irq_rx_disable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_RxDataReadyEnable; @@ -156,14 +157,14 @@ static void mcux_iuart_irq_rx_disable(struct device *dev) UART_DisableInterrupts(config->base, mask); } -static int mcux_iuart_irq_rx_full(struct device *dev) +static int mcux_iuart_irq_rx_full(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); return (UART_GetStatusFlag(config->base, kUART_RxDataReadyFlag)) != 0U; } -static int mcux_iuart_irq_rx_ready(struct device *dev) +static int mcux_iuart_irq_rx_ready(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_RxDataReadyEnable; @@ -172,7 +173,7 @@ static int mcux_iuart_irq_rx_ready(struct device *dev) && mcux_iuart_irq_rx_full(dev); } -static void mcux_iuart_irq_err_enable(struct device *dev) +static void mcux_iuart_irq_err_enable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_RxOverrunEnable | kUART_ParityErrorEnable | @@ -181,7 +182,7 @@ static void mcux_iuart_irq_err_enable(struct device *dev) UART_EnableInterrupts(config->base, mask); } -static void mcux_iuart_irq_err_disable(struct device *dev) +static void mcux_iuart_irq_err_disable(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uint32_t mask = kUART_RxOverrunEnable | kUART_ParityErrorEnable | @@ -190,19 +191,19 @@ static void mcux_iuart_irq_err_disable(struct device *dev) UART_DisableInterrupts(config->base, mask); } -static int mcux_iuart_irq_is_pending(struct device *dev) +static int mcux_iuart_irq_is_pending(const struct device *dev) { return mcux_iuart_irq_tx_ready(dev) || mcux_iuart_irq_rx_ready(dev); } -static int mcux_iuart_irq_update(struct device *dev) +static int mcux_iuart_irq_update(const struct device *dev) { return 1; } -static void mcux_iuart_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void mcux_iuart_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct mcux_iuart_data *data = dev->data; @@ -212,7 +213,7 @@ static void mcux_iuart_irq_callback_set(struct device *dev, static void mcux_iuart_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mcux_iuart_data *data = dev->data; if (data->callback) { @@ -221,11 +222,11 @@ static void mcux_iuart_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int mcux_iuart_init(struct device *dev) +static int mcux_iuart_init(const struct device *dev) { const struct mcux_iuart_config *config = DEV_CFG(dev); uart_config_t uart_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; clock_dev = device_get_binding(config->clock_name); diff --git a/drivers/serial/uart_mcux_lpsci.c b/drivers/serial/uart_mcux_lpsci.c index de053cf18107c5..2b450411308dc0 100644 --- a/drivers/serial/uart_mcux_lpsci.c +++ b/drivers/serial/uart_mcux_lpsci.c @@ -19,7 +19,7 @@ struct mcux_lpsci_config { clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -30,7 +30,7 @@ struct mcux_lpsci_data { #endif }; -static int mcux_lpsci_poll_in(struct device *dev, unsigned char *c) +static int mcux_lpsci_poll_in(const struct device *dev, unsigned char *c) { const struct mcux_lpsci_config *config = dev->config; uint32_t flags = LPSCI_GetStatusFlags(config->base); @@ -44,7 +44,7 @@ static int mcux_lpsci_poll_in(struct device *dev, unsigned char *c) return ret; } -static void mcux_lpsci_poll_out(struct device *dev, unsigned char c) +static void mcux_lpsci_poll_out(const struct device *dev, unsigned char c) { const struct mcux_lpsci_config *config = dev->config; @@ -55,7 +55,7 @@ static void mcux_lpsci_poll_out(struct device *dev, unsigned char c) LPSCI_WriteByte(config->base, c); } -static int mcux_lpsci_err_check(struct device *dev) +static int mcux_lpsci_err_check(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t flags = LPSCI_GetStatusFlags(config->base); @@ -81,7 +81,8 @@ static int mcux_lpsci_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int mcux_lpsci_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int mcux_lpsci_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { const struct mcux_lpsci_config *config = dev->config; @@ -97,7 +98,7 @@ static int mcux_lpsci_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int mcux_lpsci_fifo_read(struct device *dev, uint8_t *rx_data, +static int mcux_lpsci_fifo_read(const struct device *dev, uint8_t *rx_data, const int len) { const struct mcux_lpsci_config *config = dev->config; @@ -113,7 +114,7 @@ static int mcux_lpsci_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void mcux_lpsci_irq_tx_enable(struct device *dev) +static void mcux_lpsci_irq_tx_enable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_TxDataRegEmptyInterruptEnable; @@ -121,7 +122,7 @@ static void mcux_lpsci_irq_tx_enable(struct device *dev) LPSCI_EnableInterrupts(config->base, mask); } -static void mcux_lpsci_irq_tx_disable(struct device *dev) +static void mcux_lpsci_irq_tx_disable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_TxDataRegEmptyInterruptEnable; @@ -129,7 +130,7 @@ static void mcux_lpsci_irq_tx_disable(struct device *dev) LPSCI_DisableInterrupts(config->base, mask); } -static int mcux_lpsci_irq_tx_complete(struct device *dev) +static int mcux_lpsci_irq_tx_complete(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t flags = LPSCI_GetStatusFlags(config->base); @@ -137,7 +138,7 @@ static int mcux_lpsci_irq_tx_complete(struct device *dev) return (flags & kLPSCI_TransmissionCompleteFlag) != 0U; } -static int mcux_lpsci_irq_tx_ready(struct device *dev) +static int mcux_lpsci_irq_tx_ready(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_TxDataRegEmptyInterruptEnable; @@ -147,7 +148,7 @@ static int mcux_lpsci_irq_tx_ready(struct device *dev) && (flags & kLPSCI_TxDataRegEmptyFlag); } -static void mcux_lpsci_irq_rx_enable(struct device *dev) +static void mcux_lpsci_irq_rx_enable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_RxDataRegFullInterruptEnable; @@ -155,7 +156,7 @@ static void mcux_lpsci_irq_rx_enable(struct device *dev) LPSCI_EnableInterrupts(config->base, mask); } -static void mcux_lpsci_irq_rx_disable(struct device *dev) +static void mcux_lpsci_irq_rx_disable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_RxDataRegFullInterruptEnable; @@ -163,7 +164,7 @@ static void mcux_lpsci_irq_rx_disable(struct device *dev) LPSCI_DisableInterrupts(config->base, mask); } -static int mcux_lpsci_irq_rx_full(struct device *dev) +static int mcux_lpsci_irq_rx_full(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t flags = LPSCI_GetStatusFlags(config->base); @@ -171,7 +172,7 @@ static int mcux_lpsci_irq_rx_full(struct device *dev) return (flags & kLPSCI_RxDataRegFullFlag) != 0U; } -static int mcux_lpsci_irq_rx_ready(struct device *dev) +static int mcux_lpsci_irq_rx_ready(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_RxDataRegFullInterruptEnable; @@ -180,7 +181,7 @@ static int mcux_lpsci_irq_rx_ready(struct device *dev) && mcux_lpsci_irq_rx_full(dev); } -static void mcux_lpsci_irq_err_enable(struct device *dev) +static void mcux_lpsci_irq_err_enable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_NoiseErrorInterruptEnable | @@ -190,7 +191,7 @@ static void mcux_lpsci_irq_err_enable(struct device *dev) LPSCI_EnableInterrupts(config->base, mask); } -static void mcux_lpsci_irq_err_disable(struct device *dev) +static void mcux_lpsci_irq_err_disable(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; uint32_t mask = kLPSCI_NoiseErrorInterruptEnable | @@ -200,20 +201,20 @@ static void mcux_lpsci_irq_err_disable(struct device *dev) LPSCI_DisableInterrupts(config->base, mask); } -static int mcux_lpsci_irq_is_pending(struct device *dev) +static int mcux_lpsci_irq_is_pending(const struct device *dev) { return (mcux_lpsci_irq_tx_ready(dev) || mcux_lpsci_irq_rx_ready(dev)); } -static int mcux_lpsci_irq_update(struct device *dev) +static int mcux_lpsci_irq_update(const struct device *dev) { return 1; } -static void mcux_lpsci_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void mcux_lpsci_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct mcux_lpsci_data *data = dev->data; @@ -223,7 +224,7 @@ static void mcux_lpsci_irq_callback_set(struct device *dev, static void mcux_lpsci_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mcux_lpsci_data *data = dev->data; if (data->callback) { @@ -232,11 +233,11 @@ static void mcux_lpsci_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int mcux_lpsci_init(struct device *dev) +static int mcux_lpsci_init(const struct device *dev) { const struct mcux_lpsci_config *config = dev->config; lpsci_config_t uart_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; clock_dev = device_get_binding(config->clock_name); @@ -287,7 +288,7 @@ static const struct uart_driver_api mcux_lpsci_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define MCUX_LPSCI_CONFIG_FUNC(n) \ - static void mcux_lpsci_config_func_##n(struct device *dev) \ + static void mcux_lpsci_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/serial/uart_mcux_lpuart.c b/drivers/serial/uart_mcux_lpuart.c index 21c48f63731dc1..9dc8df0976a1bf 100644 --- a/drivers/serial/uart_mcux_lpuart.c +++ b/drivers/serial/uart_mcux_lpuart.c @@ -19,7 +19,7 @@ struct mcux_lpuart_config { clock_control_subsys_t clock_subsys; uint32_t baud_rate; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -30,7 +30,7 @@ struct mcux_lpuart_data { #endif }; -static int mcux_lpuart_poll_in(struct device *dev, unsigned char *c) +static int mcux_lpuart_poll_in(const struct device *dev, unsigned char *c) { const struct mcux_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -44,7 +44,7 @@ static int mcux_lpuart_poll_in(struct device *dev, unsigned char *c) return ret; } -static void mcux_lpuart_poll_out(struct device *dev, unsigned char c) +static void mcux_lpuart_poll_out(const struct device *dev, unsigned char c) { const struct mcux_lpuart_config *config = dev->config; @@ -55,7 +55,7 @@ static void mcux_lpuart_poll_out(struct device *dev, unsigned char c) LPUART_WriteByte(config->base, c); } -static int mcux_lpuart_err_check(struct device *dev) +static int mcux_lpuart_err_check(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -81,8 +81,9 @@ static int mcux_lpuart_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int mcux_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data, - int len) +static int mcux_lpuart_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int len) { const struct mcux_lpuart_config *config = dev->config; uint8_t num_tx = 0U; @@ -97,8 +98,8 @@ static int mcux_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int mcux_lpuart_fifo_read(struct device *dev, uint8_t *rx_data, - const int len) +static int mcux_lpuart_fifo_read(const struct device *dev, uint8_t *rx_data, + const int len) { const struct mcux_lpuart_config *config = dev->config; uint8_t num_rx = 0U; @@ -113,7 +114,7 @@ static int mcux_lpuart_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void mcux_lpuart_irq_tx_enable(struct device *dev) +static void mcux_lpuart_irq_tx_enable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -121,7 +122,7 @@ static void mcux_lpuart_irq_tx_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void mcux_lpuart_irq_tx_disable(struct device *dev) +static void mcux_lpuart_irq_tx_disable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -129,7 +130,7 @@ static void mcux_lpuart_irq_tx_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int mcux_lpuart_irq_tx_complete(struct device *dev) +static int mcux_lpuart_irq_tx_complete(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -137,7 +138,7 @@ static int mcux_lpuart_irq_tx_complete(struct device *dev) return (flags & kLPUART_TransmissionCompleteFlag) != 0U; } -static int mcux_lpuart_irq_tx_ready(struct device *dev) +static int mcux_lpuart_irq_tx_ready(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -147,7 +148,7 @@ static int mcux_lpuart_irq_tx_ready(struct device *dev) && (flags & kLPUART_TxDataRegEmptyFlag); } -static void mcux_lpuart_irq_rx_enable(struct device *dev) +static void mcux_lpuart_irq_rx_enable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -155,7 +156,7 @@ static void mcux_lpuart_irq_rx_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void mcux_lpuart_irq_rx_disable(struct device *dev) +static void mcux_lpuart_irq_rx_disable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -163,7 +164,7 @@ static void mcux_lpuart_irq_rx_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int mcux_lpuart_irq_rx_full(struct device *dev) +static int mcux_lpuart_irq_rx_full(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -171,7 +172,7 @@ static int mcux_lpuart_irq_rx_full(struct device *dev) return (flags & kLPUART_RxDataRegFullFlag) != 0U; } -static int mcux_lpuart_irq_rx_ready(struct device *dev) +static int mcux_lpuart_irq_rx_ready(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -180,7 +181,7 @@ static int mcux_lpuart_irq_rx_ready(struct device *dev) && mcux_lpuart_irq_rx_full(dev); } -static void mcux_lpuart_irq_err_enable(struct device *dev) +static void mcux_lpuart_irq_err_enable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_NoiseErrorInterruptEnable | @@ -190,7 +191,7 @@ static void mcux_lpuart_irq_err_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void mcux_lpuart_irq_err_disable(struct device *dev) +static void mcux_lpuart_irq_err_disable(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; uint32_t mask = kLPUART_NoiseErrorInterruptEnable | @@ -200,20 +201,20 @@ static void mcux_lpuart_irq_err_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int mcux_lpuart_irq_is_pending(struct device *dev) +static int mcux_lpuart_irq_is_pending(const struct device *dev) { return (mcux_lpuart_irq_tx_ready(dev) || mcux_lpuart_irq_rx_ready(dev)); } -static int mcux_lpuart_irq_update(struct device *dev) +static int mcux_lpuart_irq_update(const struct device *dev) { return 1; } -static void mcux_lpuart_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void mcux_lpuart_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct mcux_lpuart_data *data = dev->data; @@ -223,7 +224,7 @@ static void mcux_lpuart_irq_callback_set(struct device *dev, static void mcux_lpuart_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct mcux_lpuart_data *data = dev->data; if (data->callback) { @@ -232,11 +233,11 @@ static void mcux_lpuart_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int mcux_lpuart_init(struct device *dev) +static int mcux_lpuart_init(const struct device *dev) { const struct mcux_lpuart_config *config = dev->config; lpuart_config_t uart_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; clock_dev = device_get_binding(config->clock_name); diff --git a/drivers/serial/uart_miv.c b/drivers/serial/uart_miv.c index e82d22723998af..98f4c13a71d772 100644 --- a/drivers/serial/uart_miv.c +++ b/drivers/serial/uart_miv.c @@ -124,7 +124,7 @@ struct uart_miv_regs_t { }; #ifdef CONFIG_UART_INTERRUPT_DRIVEN -typedef void (*irq_cfg_func_t)(struct device *dev); +typedef void (*irq_cfg_func_t)(const struct device *dev); #endif struct uart_miv_device_config { @@ -152,7 +152,7 @@ struct uart_miv_data { #define DEV_DATA(dev) \ ((struct uart_miv_data * const)(dev)->data) -static void uart_miv_poll_out(struct device *dev, +static void uart_miv_poll_out(const struct device *dev, unsigned char c) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); @@ -163,7 +163,7 @@ static void uart_miv_poll_out(struct device *dev, uart->tx = c; } -static int uart_miv_poll_in(struct device *dev, unsigned char *c) +static int uart_miv_poll_in(const struct device *dev, unsigned char *c) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); @@ -175,7 +175,7 @@ static int uart_miv_poll_in(struct device *dev, unsigned char *c) return -1; } -static int uart_miv_err_check(struct device *dev) +static int uart_miv_err_check(const struct device *dev) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); uint32_t flags = uart->status; @@ -199,7 +199,7 @@ static int uart_miv_err_check(struct device *dev) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_miv_fifo_fill(struct device *dev, +static int uart_miv_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size) { @@ -213,7 +213,7 @@ static int uart_miv_fifo_fill(struct device *dev, return i; } -static int uart_miv_fifo_read(struct device *dev, +static int uart_miv_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { @@ -231,72 +231,72 @@ static int uart_miv_fifo_read(struct device *dev, return i; } -static void uart_miv_irq_tx_enable(struct device *dev) +static void uart_miv_irq_tx_enable(const struct device *dev) { ARG_UNUSED(dev); } -static void uart_miv_irq_tx_disable(struct device *dev) +static void uart_miv_irq_tx_disable(const struct device *dev) { ARG_UNUSED(dev); } -static int uart_miv_irq_tx_ready(struct device *dev) +static int uart_miv_irq_tx_ready(const struct device *dev) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); return !(uart->status & STATUS_TXRDY_MASK); } -static int uart_miv_irq_tx_complete(struct device *dev) +static int uart_miv_irq_tx_complete(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void uart_miv_irq_rx_enable(struct device *dev) +static void uart_miv_irq_rx_enable(const struct device *dev) { ARG_UNUSED(dev); } -static void uart_miv_irq_rx_disable(struct device *dev) +static void uart_miv_irq_rx_disable(const struct device *dev) { ARG_UNUSED(dev); } -static int uart_miv_irq_rx_ready(struct device *dev) +static int uart_miv_irq_rx_ready(const struct device *dev) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); return !!(uart->status & STATUS_RXFULL_MASK); } -static void uart_miv_irq_err_enable(struct device *dev) +static void uart_miv_irq_err_enable(const struct device *dev) { ARG_UNUSED(dev); } -static void uart_miv_irq_err_disable(struct device *dev) +static void uart_miv_irq_err_disable(const struct device *dev) { ARG_UNUSED(dev); } -static int uart_miv_irq_is_pending(struct device *dev) +static int uart_miv_irq_is_pending(const struct device *dev) { volatile struct uart_miv_regs_t *uart = DEV_UART(dev); return !!(uart->status & STATUS_RXFULL_MASK); } -static int uart_miv_irq_update(struct device *dev) +static int uart_miv_irq_update(const struct device *dev) { return 1; } static void uart_miv_irq_handler(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct uart_miv_data *data = DEV_DATA(dev); if (data->callback) { @@ -312,7 +312,7 @@ static void uart_miv_irq_handler(void *arg) */ void uart_miv_rx_thread(void *arg1, void *arg2, void *arg3) { - struct device *dev = (struct device *)arg1; + const struct device *dev = (const struct device *)arg1; volatile struct uart_miv_regs_t *uart = DEV_UART(dev); const struct uart_miv_device_config *const cfg = DEV_CFG(dev); /* Make it go to sleep for a period no longer than @@ -328,7 +328,7 @@ void uart_miv_rx_thread(void *arg1, void *arg2, void *arg3) } } -static void uart_miv_irq_callback_set(struct device *dev, +static void uart_miv_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -340,7 +340,7 @@ static void uart_miv_irq_callback_set(struct device *dev, #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int uart_miv_init(struct device *dev) +static int uart_miv_init(const struct device *dev) { const struct uart_miv_device_config *const cfg = DEV_CFG(dev); volatile struct uart_miv_regs_t *uart = DEV_UART(dev); @@ -390,7 +390,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1, static struct uart_miv_data uart_miv_data_0; #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_miv_irq_cfg_func_0(struct device *dev); +static void uart_miv_irq_cfg_func_0(const struct device *dev); #endif static const struct uart_miv_device_config uart_miv_dev_cfg_0 = { @@ -409,7 +409,7 @@ DEVICE_AND_API_INIT(uart_miv_0, DT_INST_LABEL(0), (void *)&uart_miv_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_miv_irq_cfg_func_0(struct device *dev) +static void uart_miv_irq_cfg_func_0(const struct device *dev) { /* Create a thread which will poll for data - replacement for IRQ */ k_thread_create(&rx_thread, rx_stack, 500, diff --git a/drivers/serial/uart_msp432p4xx.c b/drivers/serial/uart_msp432p4xx.c index aee79e92ae9edc..d5b929ed1be3a1 100644 --- a/drivers/serial/uart_msp432p4xx.c +++ b/drivers/serial/uart_msp432p4xx.c @@ -117,7 +117,7 @@ static int baudrate_set(eUSCI_UART_Config *config, uint32_t baudrate) return 0; } -static int uart_msp432p4xx_init(struct device *dev) +static int uart_msp432p4xx_init(const struct device *dev) { int err; const struct uart_device_config *config = DEV_CFG(dev); @@ -156,7 +156,7 @@ static int uart_msp432p4xx_init(struct device *dev) return 0; } -static int uart_msp432p4xx_poll_in(struct device *dev, unsigned char *c) +static int uart_msp432p4xx_poll_in(const struct device *dev, unsigned char *c) { const struct uart_device_config *config = DEV_CFG(dev); @@ -165,7 +165,7 @@ static int uart_msp432p4xx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_msp432p4xx_poll_out(struct device *dev, +static void uart_msp432p4xx_poll_out(const struct device *dev, unsigned char c) { const struct uart_device_config *config = DEV_CFG(dev); @@ -174,7 +174,7 @@ static void uart_msp432p4xx_poll_out(struct device *dev, } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_msp432p4xx_fifo_fill(struct device *dev, +static int uart_msp432p4xx_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size) { const struct uart_device_config *config = DEV_CFG(dev); @@ -194,7 +194,8 @@ static int uart_msp432p4xx_fifo_fill(struct device *dev, return (int)num_tx; } -static int uart_msp432p4xx_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_msp432p4xx_fifo_read(const struct device *dev, + uint8_t *rx_data, const int size) { const struct uart_device_config *config = DEV_CFG(dev); @@ -211,7 +212,7 @@ static int uart_msp432p4xx_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void uart_msp432p4xx_irq_tx_enable(struct device *dev) +static void uart_msp432p4xx_irq_tx_enable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -219,7 +220,7 @@ static void uart_msp432p4xx_irq_tx_enable(struct device *dev) EUSCI_A_UART_TRANSMIT_INTERRUPT); } -static void uart_msp432p4xx_irq_tx_disable(struct device *dev) +static void uart_msp432p4xx_irq_tx_disable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -227,7 +228,7 @@ static void uart_msp432p4xx_irq_tx_disable(struct device *dev) EUSCI_A_UART_TRANSMIT_INTERRUPT); } -static int uart_msp432p4xx_irq_tx_ready(struct device *dev) +static int uart_msp432p4xx_irq_tx_ready(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -238,7 +239,7 @@ static int uart_msp432p4xx_irq_tx_ready(struct device *dev) return (int_status & EUSCI_A_IE_TXIE); } -static void uart_msp432p4xx_irq_rx_enable(struct device *dev) +static void uart_msp432p4xx_irq_rx_enable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -246,7 +247,7 @@ static void uart_msp432p4xx_irq_rx_enable(struct device *dev) EUSCI_A_UART_RECEIVE_INTERRUPT); } -static void uart_msp432p4xx_irq_rx_disable(struct device *dev) +static void uart_msp432p4xx_irq_rx_disable(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -254,7 +255,7 @@ static void uart_msp432p4xx_irq_rx_disable(struct device *dev) EUSCI_A_UART_RECEIVE_INTERRUPT); } -static int uart_msp432p4xx_irq_tx_complete(struct device *dev) +static int uart_msp432p4xx_irq_tx_complete(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); @@ -262,7 +263,7 @@ static int uart_msp432p4xx_irq_tx_complete(struct device *dev) EUSCI_A_UART_TRANSMIT_COMPLETE_INTERRUPT_FLAG); } -static int uart_msp432p4xx_irq_rx_ready(struct device *dev) +static int uart_msp432p4xx_irq_rx_ready(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -273,17 +274,17 @@ static int uart_msp432p4xx_irq_rx_ready(struct device *dev) return (int_status & EUSCI_A_IE_RXIE); } -static void uart_msp432p4xx_irq_err_enable(struct device *dev) +static void uart_msp432p4xx_irq_err_enable(const struct device *dev) { /* Not yet used in zephyr */ } -static void uart_msp432p4xx_irq_err_disable(struct device *dev) +static void uart_msp432p4xx_irq_err_disable(const struct device *dev) { /* Not yet used in zephyr */ } -static int uart_msp432p4xx_irq_is_pending(struct device *dev) +static int uart_msp432p4xx_irq_is_pending(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); unsigned int int_status; @@ -294,14 +295,14 @@ static int uart_msp432p4xx_irq_is_pending(struct device *dev) return (int_status & (EUSCI_A_IE_TXIE | EUSCI_A_IE_RXIE)); } -static int uart_msp432p4xx_irq_update(struct device *dev) +static int uart_msp432p4xx_irq_update(const struct device *dev) { return 1; } -static void uart_msp432p4xx_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void uart_msp432p4xx_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct uart_msp432p4xx_dev_data_t * const dev_data = DEV_DATA(dev); @@ -320,7 +321,7 @@ static void uart_msp432p4xx_irq_callback_set(struct device *dev, */ static void uart_msp432p4xx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct uart_device_config *config = DEV_CFG(dev); struct uart_msp432p4xx_dev_data_t * const dev_data = DEV_DATA(dev); unsigned int int_status; diff --git a/drivers/serial/uart_native_posix.c b/drivers/serial/uart_native_posix.c index be91880de2edc8..1cf3f384a33f61 100644 --- a/drivers/serial/uart_native_posix.c +++ b/drivers/serial/uart_native_posix.c @@ -38,9 +38,11 @@ * emulator to it, if set so from command line. */ -static int np_uart_stdin_poll_in(struct device *dev, unsigned char *p_char); -static int np_uart_tty_poll_in(struct device *dev, unsigned char *p_char); -static void np_uart_poll_out(struct device *dev, +static int np_uart_stdin_poll_in(const struct device *dev, + unsigned char *p_char); +static int np_uart_tty_poll_in(const struct device *dev, + unsigned char *p_char); +static void np_uart_poll_out(const struct device *dev, unsigned char out_char); static bool auto_attach; @@ -196,7 +198,7 @@ static int open_tty(struct native_uart_status *driver_data, * * @return 0 (if it fails catastrophically, the execution is terminated) */ -static int np_uart_0_init(struct device *dev) +static int np_uart_0_init(const struct device *dev) { struct native_uart_status *d; @@ -233,7 +235,7 @@ static int np_uart_0_init(struct device *dev) * Initialize the 2nd UART port. * This port will be always attached to its own new pseudoterminal. */ -static int np_uart_1_init(struct device *dev) +static int np_uart_1_init(const struct device *dev) { struct native_uart_status *d; int tty_fn; @@ -255,7 +257,7 @@ static int np_uart_1_init(struct device *dev) * @param dev UART device struct * @param out_char Character to send. */ -static void np_uart_poll_out(struct device *dev, +static void np_uart_poll_out(const struct device *dev, unsigned char out_char) { int ret; @@ -278,7 +280,8 @@ static void np_uart_poll_out(struct device *dev, * @retval 0 If a character arrived and was stored in p_char * @retval -1 If no character was available to read */ -static int np_uart_stdin_poll_in(struct device *dev, unsigned char *p_char) +static int np_uart_stdin_poll_in(const struct device *dev, + unsigned char *p_char) { static bool disconnected; @@ -326,7 +329,8 @@ static int np_uart_stdin_poll_in(struct device *dev, unsigned char *p_char) * @retval 0 If a character arrived and was stored in p_char * @retval -1 If no character was available to read */ -static int np_uart_tty_poll_in(struct device *dev, unsigned char *p_char) +static int np_uart_tty_poll_in(const struct device *dev, + unsigned char *p_char) { int n = -1; int in_f = ((struct native_uart_status *)dev->data)->in_fd; diff --git a/drivers/serial/uart_npcx.c b/drivers/serial/uart_npcx.c index d937cefd81d0f1..b0c4e717f9cf9f 100644 --- a/drivers/serial/uart_npcx.c +++ b/drivers/serial/uart_npcx.c @@ -51,7 +51,7 @@ struct uart_npcx_data { /* UART local functions */ #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_npcx_tx_fifo_ready(struct device *dev) +static int uart_npcx_tx_fifo_ready(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -59,7 +59,7 @@ static int uart_npcx_tx_fifo_ready(struct device *dev) return !(GET_FIELD(inst->UFTSTS, NPCX_UFTSTS_TEMPTY_LVL) == 0); } -static int uart_npcx_rx_fifo_available(struct device *dev) +static int uart_npcx_rx_fifo_available(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -67,7 +67,7 @@ static int uart_npcx_rx_fifo_available(struct device *dev) return IS_BIT_SET(inst->UFRSTS, NPCX_UFRSTS_RFIFO_NEMPTY_STS); } -static void uart_npcx_dis_all_tx_interrupts(struct device *dev) +static void uart_npcx_dis_all_tx_interrupts(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -77,7 +77,7 @@ static void uart_npcx_dis_all_tx_interrupts(struct device *dev) BIT(NPCX_UFTCTL_NXMIPEN)); } -static void uart_npcx_clear_rx_fifo(struct device *dev) +static void uart_npcx_clear_rx_fifo(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); uint8_t scratch; @@ -89,7 +89,7 @@ static void uart_npcx_clear_rx_fifo(struct device *dev) #endif /* UART api functions */ -static int uart_npcx_poll_in(struct device *dev, unsigned char *c) +static int uart_npcx_poll_in(const struct device *dev, unsigned char *c) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -101,7 +101,7 @@ static int uart_npcx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_npcx_poll_out(struct device *dev, unsigned char c) +static void uart_npcx_poll_out(const struct device *dev, unsigned char c) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -112,7 +112,7 @@ static void uart_npcx_poll_out(struct device *dev, unsigned char c) inst->UTBUF = c; } -static int uart_npcx_err_check(struct device *dev) +static int uart_npcx_err_check(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); uint32_t err = 0U; @@ -131,7 +131,8 @@ static int uart_npcx_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_npcx_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_npcx_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -146,7 +147,7 @@ static int uart_npcx_fifo_fill(struct device *dev, const uint8_t *tx_data, return tx_bytes; } -static int uart_npcx_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_npcx_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -161,21 +162,21 @@ static int uart_npcx_fifo_read(struct device *dev, uint8_t *rx_data, return rx_bytes; } -static void uart_npcx_irq_tx_enable(struct device *dev) +static void uart_npcx_irq_tx_enable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UFTCTL |= BIT(NPCX_UFTCTL_TEMPTY_EN); } -static void uart_npcx_irq_tx_disable(struct device *dev) +static void uart_npcx_irq_tx_disable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UFTCTL &= ~(BIT(NPCX_UFTCTL_TEMPTY_EN)); } -static int uart_npcx_irq_tx_ready(struct device *dev) +static int uart_npcx_irq_tx_ready(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -184,7 +185,7 @@ static int uart_npcx_irq_tx_ready(struct device *dev) uart_npcx_tx_fifo_ready(dev)); } -static int uart_npcx_irq_tx_complete(struct device *dev) +static int uart_npcx_irq_tx_complete(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -192,21 +193,21 @@ static int uart_npcx_irq_tx_complete(struct device *dev) return IS_BIT_SET(inst->UFTSTS, NPCX_UFTSTS_NXMIP); } -static void uart_npcx_irq_rx_enable(struct device *dev) +static void uart_npcx_irq_rx_enable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UFRCTL |= BIT(NPCX_UFRCTL_RNEMPTY_EN); } -static void uart_npcx_irq_rx_disable(struct device *dev) +static void uart_npcx_irq_rx_disable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UFRCTL &= ~(BIT(NPCX_UFRCTL_RNEMPTY_EN)); } -static int uart_npcx_irq_rx_ready(struct device *dev) +static int uart_npcx_irq_rx_ready(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); @@ -215,34 +216,34 @@ static int uart_npcx_irq_rx_ready(struct device *dev) uart_npcx_rx_fifo_available(dev)); } -static void uart_npcx_irq_err_enable(struct device *dev) +static void uart_npcx_irq_err_enable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UICTRL |= BIT(NPCX_UICTRL_EEI); } -static void uart_npcx_irq_err_disable(struct device *dev) +static void uart_npcx_irq_err_disable(const struct device *dev) { struct uart_reg *inst = HAL_INSTANCE(dev); inst->UICTRL &= ~(BIT(NPCX_UICTRL_EEI)); } -static int uart_npcx_irq_is_pending(struct device *dev) +static int uart_npcx_irq_is_pending(const struct device *dev) { return (uart_npcx_irq_tx_ready(dev) || uart_npcx_irq_rx_ready(dev)); } -static int uart_npcx_irq_update(struct device *dev) +static int uart_npcx_irq_update(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void uart_npcx_irq_callback_set(struct device *dev, +static void uart_npcx_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -254,7 +255,7 @@ static void uart_npcx_irq_callback_set(struct device *dev, static void uart_npcx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_npcx_data *data = DRV_DATA(dev); if (data->user_cb) { @@ -286,12 +287,12 @@ static const struct uart_driver_api uart_npcx_driver_api = { #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; -static int uart_npcx_init(struct device *dev) +static int uart_npcx_init(const struct device *dev) { const struct uart_npcx_config *config = DRV_CONFIG(dev); const struct uart_npcx_data *data = DRV_DATA(dev); struct uart_reg *inst = HAL_INSTANCE(dev); - struct device *clk_dev = device_get_binding(NPCX_CLOCK_CONTROL_NAME); + const struct device *clk_dev = device_get_binding(NPCX_CLOCK_CONTROL_NAME); uint32_t uart_rate; /* Turn on device clock first */ @@ -363,7 +364,7 @@ static int uart_npcx_init(struct device *dev) #define NPCX_UART_IRQ_CONFIG_FUNC_INIT(inst) \ .irq_config_func = uart_npcx_irq_config_##inst, #define NPCX_UART_IRQ_CONFIG_FUNC(inst) \ - static void uart_npcx_irq_config_##inst(struct device *dev) \ + static void uart_npcx_irq_config_##inst(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(inst), \ DT_INST_IRQ(inst, priority), \ diff --git a/drivers/serial/uart_nrfx_uart.c b/drivers/serial/uart_nrfx_uart.c index b74c0d96457372..5d1c980ab23b7f 100644 --- a/drivers/serial/uart_nrfx_uart.c +++ b/drivers/serial/uart_nrfx_uart.c @@ -59,7 +59,7 @@ struct uart_nrfx_data { struct uart_config uart_config; }; -static inline struct uart_nrfx_data *get_dev_data(struct device *dev) +static inline struct uart_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } @@ -135,7 +135,7 @@ static void event_txdrdy_clear(void) * @return N/A */ -static int baudrate_set(struct device *dev, uint32_t baudrate) +static int baudrate_set(const struct device *dev, uint32_t baudrate) { nrf_uart_baudrate_t nrf_baudrate; /* calculated baudrate divisor */ @@ -220,7 +220,7 @@ static int baudrate_set(struct device *dev, uint32_t baudrate) * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_nrfx_poll_in(struct device *dev, unsigned char *c) +static int uart_nrfx_poll_in(const struct device *dev, unsigned char *c) { if (!nrf_uart_event_check(uart0_addr, NRF_UART_EVENT_RXDRDY)) { return -1; @@ -245,7 +245,7 @@ static void uart_nrfx_isr(void *arg); * @param dev UART device struct * @param c Character to send */ -static void uart_nrfx_poll_out(struct device *dev, unsigned char c) +static void uart_nrfx_poll_out(const struct device *dev, unsigned char c) { atomic_t *lock; #ifdef CONFIG_UART_0_ASYNC @@ -309,13 +309,13 @@ static void uart_nrfx_poll_out(struct device *dev, unsigned char c) } /** Console I/O function */ -static int uart_nrfx_err_check(struct device *dev) +static int uart_nrfx_err_check(const struct device *dev) { /* register bitfields maps to the defines in uart.h */ return nrf_uart_errorsrc_get_and_clear(uart0_addr); } -static int uart_nrfx_configure(struct device *dev, +static int uart_nrfx_configure(const struct device *dev, const struct uart_config *cfg) { nrf_uart_config_t uart_cfg; @@ -387,7 +387,8 @@ static int uart_nrfx_configure(struct device *dev, return 0; } -static int uart_nrfx_config_get(struct device *dev, struct uart_config *cfg) +static int uart_nrfx_config_get(const struct device *dev, + struct uart_config *cfg) { *cfg = get_dev_data(dev)->uart_config; return 0; @@ -396,14 +397,15 @@ static int uart_nrfx_config_get(struct device *dev, struct uart_config *cfg) #ifdef CONFIG_UART_0_ASYNC -static void user_callback(struct device *dev, struct uart_event *event) +static void user_callback(const struct device *dev, struct uart_event *event) { if (uart0_cb.callback) { uart0_cb.callback(dev, event, uart0_cb.user_data); } } -static int uart_nrfx_callback_set(struct device *dev, uart_callback_t callback, +static int uart_nrfx_callback_set(const struct device *dev, + uart_callback_t callback, void *user_data) { uart0_cb.callback = callback; @@ -412,7 +414,8 @@ static int uart_nrfx_callback_set(struct device *dev, uart_callback_t callback, return 0; } -static int uart_nrfx_tx(struct device *dev, const uint8_t *buf, size_t len, +static int uart_nrfx_tx(const struct device *dev, const uint8_t *buf, + size_t len, int32_t timeout) { if (atomic_cas((atomic_t *) &uart0_cb.tx_buffer_length, @@ -436,7 +439,7 @@ static int uart_nrfx_tx(struct device *dev, const uint8_t *buf, size_t len, return 0; } -static int uart_nrfx_tx_abort(struct device *dev) +static int uart_nrfx_tx_abort(const struct device *dev) { if (uart0_cb.tx_buffer_length == 0) { return -EINVAL; @@ -462,7 +465,8 @@ static int uart_nrfx_tx_abort(struct device *dev) return 0; } -static int uart_nrfx_rx_enable(struct device *dev, uint8_t *buf, size_t len, +static int uart_nrfx_rx_enable(const struct device *dev, uint8_t *buf, + size_t len, int32_t timeout) { if (!RX_PIN_USED) { @@ -492,7 +496,8 @@ static int uart_nrfx_rx_enable(struct device *dev, uint8_t *buf, size_t len, return 0; } -static int uart_nrfx_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) +static int uart_nrfx_rx_buf_rsp(const struct device *dev, uint8_t *buf, + size_t len) { int err; int key = irq_lock(); @@ -512,7 +517,7 @@ static int uart_nrfx_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) return err; } -static int uart_nrfx_rx_disable(struct device *dev) +static int uart_nrfx_rx_disable(const struct device *dev) { if (uart0_cb.rx_buffer_length == 0) { return -EFAULT; @@ -527,7 +532,7 @@ static int uart_nrfx_rx_disable(struct device *dev) return 0; } -static void rx_rdy_evt(struct device *dev) +static void rx_rdy_evt(const struct device *dev) { struct uart_event event; size_t rx_cnt = uart0_cb.rx_counter; @@ -542,7 +547,7 @@ static void rx_rdy_evt(struct device *dev) user_callback(dev, &event); } -static void buf_released_evt(struct device *dev) +static void buf_released_evt(const struct device *dev) { struct uart_event event = { .type = UART_RX_BUF_RELEASED, @@ -551,7 +556,7 @@ static void buf_released_evt(struct device *dev) user_callback(dev, &event); } -static void rx_disabled_evt(struct device *dev) +static void rx_disabled_evt(const struct device *dev) { struct uart_event event = { .type = UART_RX_DISABLED @@ -572,7 +577,7 @@ static void rx_reset_state(void) uart0_cb.rx_secondary_buffer_length = 0; } -static void rx_isr(struct device *dev) +static void rx_isr(const struct device *dev) { struct uart_event event; @@ -628,7 +633,7 @@ static void rx_isr(struct device *dev) } } -static void tx_isr(struct device *dev) +static void tx_isr(const struct device *dev) { uart0_cb.tx_counter++; if (uart0_cb.tx_counter < uart0_cb.tx_buffer_length && @@ -674,7 +679,7 @@ static void tx_isr(struct device *dev) : mask & NRF_UART_ERROR_BREAK_MASK ? UART_BREAK \ : 0) -static void error_isr(struct device *dev) +static void error_isr(const struct device *dev) { if (uart0_cb.rx_timeout != SYS_FOREVER_MS) { k_delayed_work_cancel(&uart0_cb.rx_timeout_work); @@ -705,7 +710,7 @@ static void error_isr(struct device *dev) * it is used as a sign that peripheral has finished its operation and is * disabled. */ -static void rxto_isr(struct device *dev) +static void rxto_isr(const struct device *dev) { nrf_uart_event_clear(uart0_addr, NRF_UART_EVENT_RXTO); @@ -726,7 +731,7 @@ static void rxto_isr(struct device *dev) void uart_nrfx_isr(void *arg) { - struct device *uart = (struct device *) arg; + const struct device *uart = (const struct device *) arg; if (nrf_uart_int_enable_check(uart0_addr, NRF_UART_INT_MASK_ERROR) && nrf_uart_event_check(uart0_addr, NRF_UART_EVENT_ERROR)) { @@ -778,7 +783,7 @@ static void tx_timeout(struct k_work *work) #ifdef CONFIG_UART_0_INTERRUPT_DRIVEN /** Interrupt driven FIFO fill function */ -static int uart_nrfx_fifo_fill(struct device *dev, +static int uart_nrfx_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { @@ -798,7 +803,7 @@ static int uart_nrfx_fifo_fill(struct device *dev, } /** Interrupt driven FIFO read function */ -static int uart_nrfx_fifo_read(struct device *dev, +static int uart_nrfx_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { @@ -817,7 +822,7 @@ static int uart_nrfx_fifo_read(struct device *dev, } /** Interrupt driven transfer enabling function */ -static void uart_nrfx_irq_tx_enable(struct device *dev) +static void uart_nrfx_irq_tx_enable(const struct device *dev) { uint32_t key; @@ -848,26 +853,26 @@ static void uart_nrfx_irq_tx_enable(struct device *dev) } /** Interrupt driven transfer disabling function */ -static void uart_nrfx_irq_tx_disable(struct device *dev) +static void uart_nrfx_irq_tx_disable(const struct device *dev) { /* Disable TX interrupt in uart_nrfx_isr() when transmission is done. */ disable_tx_irq = true; } /** Interrupt driven receiver enabling function */ -static void uart_nrfx_irq_rx_enable(struct device *dev) +static void uart_nrfx_irq_rx_enable(const struct device *dev) { nrf_uart_int_enable(uart0_addr, NRF_UART_INT_MASK_RXDRDY); } /** Interrupt driven receiver disabling function */ -static void uart_nrfx_irq_rx_disable(struct device *dev) +static void uart_nrfx_irq_rx_disable(const struct device *dev) { nrf_uart_int_disable(uart0_addr, NRF_UART_INT_MASK_RXDRDY); } /** Interrupt driven transfer empty function */ -static int uart_nrfx_irq_tx_ready_complete(struct device *dev) +static int uart_nrfx_irq_tx_ready_complete(const struct device *dev) { /* Signal TX readiness only when the TX interrupt is enabled and there * is no pending request to disable it. Note that this function may get @@ -881,25 +886,25 @@ static int uart_nrfx_irq_tx_ready_complete(struct device *dev) } /** Interrupt driven receiver ready function */ -static int uart_nrfx_irq_rx_ready(struct device *dev) +static int uart_nrfx_irq_rx_ready(const struct device *dev) { return nrf_uart_event_check(uart0_addr, NRF_UART_EVENT_RXDRDY); } /** Interrupt driven error enabling function */ -static void uart_nrfx_irq_err_enable(struct device *dev) +static void uart_nrfx_irq_err_enable(const struct device *dev) { nrf_uart_int_enable(uart0_addr, NRF_UART_INT_MASK_ERROR); } /** Interrupt driven error disabling function */ -static void uart_nrfx_irq_err_disable(struct device *dev) +static void uart_nrfx_irq_err_disable(const struct device *dev) { nrf_uart_int_disable(uart0_addr, NRF_UART_INT_MASK_ERROR); } /** Interrupt driven pending status function */ -static int uart_nrfx_irq_is_pending(struct device *dev) +static int uart_nrfx_irq_is_pending(const struct device *dev) { return ((nrf_uart_int_enable_check(uart0_addr, NRF_UART_INT_MASK_TXDRDY) && @@ -911,13 +916,13 @@ static int uart_nrfx_irq_is_pending(struct device *dev) } /** Interrupt driven interrupt update function */ -static int uart_nrfx_irq_update(struct device *dev) +static int uart_nrfx_irq_update(const struct device *dev) { return 1; } /** Set the callback function */ -static void uart_nrfx_irq_callback_set(struct device *dev, +static void uart_nrfx_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -937,7 +942,7 @@ static void uart_nrfx_irq_callback_set(struct device *dev, */ static void uart_nrfx_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; if (disable_tx_irq && nrf_uart_event_check(uart0_addr, NRF_UART_EVENT_TXDRDY)) { @@ -978,7 +983,7 @@ static void uart_nrfx_isr(void *arg) * * @return 0 on success */ -static int uart_nrfx_init(struct device *dev) +static int uart_nrfx_init(const struct device *dev) { int err; @@ -1091,7 +1096,7 @@ static const struct uart_driver_api uart_nrfx_uart_driver_api = { #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static void uart_nrfx_pins_enable(struct device *dev, bool enable) +static void uart_nrfx_pins_enable(const struct device *dev, bool enable) { if (!IS_ENABLED(CONFIG_UART_0_GPIO_MANAGEMENT)) { return; @@ -1133,7 +1138,8 @@ static void uart_nrfx_pins_enable(struct device *dev, bool enable) } } -static void uart_nrfx_set_power_state(struct device *dev, uint32_t new_state) +static void uart_nrfx_set_power_state(const struct device *dev, + uint32_t new_state) { if (new_state == DEVICE_PM_ACTIVE_STATE) { uart_nrfx_pins_enable(dev, true); @@ -1151,7 +1157,8 @@ static void uart_nrfx_set_power_state(struct device *dev, uint32_t new_state) } } -static int uart_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int uart_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { static uint32_t current_state = DEVICE_PM_ACTIVE_STATE; diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 9eb1feea1bc6eb..f1a68210738945 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -139,17 +139,17 @@ struct uarte_init_config { uint32_t pselrts; /* PSEL.RTS register value */ }; -static inline struct uarte_nrfx_data *get_dev_data(struct device *dev) +static inline struct uarte_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct uarte_nrfx_config *get_dev_config(struct device *dev) +static inline const struct uarte_nrfx_config *get_dev_config(const struct device *dev) { return dev->config; } -static inline NRF_UARTE_Type *get_uarte_instance(struct device *dev) +static inline NRF_UARTE_Type *get_uarte_instance(const struct device *dev) { const struct uarte_nrfx_config *config = get_dev_config(dev); @@ -168,7 +168,7 @@ static inline NRF_UARTE_Type *get_uarte_instance(struct device *dev) */ static void uarte_nrfx_isr_int(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uarte_nrfx_data *data = get_dev_data(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -206,7 +206,7 @@ static void uarte_nrfx_isr_int(void *arg) * * @return 0 on success or error code */ -static int baudrate_set(struct device *dev, uint32_t baudrate) +static int baudrate_set(const struct device *dev, uint32_t baudrate) { nrf_uarte_baudrate_t nrf_baudrate; /* calculated baudrate divisor */ NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -283,7 +283,7 @@ static int baudrate_set(struct device *dev, uint32_t baudrate) return 0; } -static int uarte_nrfx_configure(struct device *dev, +static int uarte_nrfx_configure(const struct device *dev, const struct uart_config *cfg) { nrf_uarte_config_t uarte_cfg; @@ -355,14 +355,15 @@ static int uarte_nrfx_configure(struct device *dev, return 0; } -static int uarte_nrfx_config_get(struct device *dev, struct uart_config *cfg) +static int uarte_nrfx_config_get(const struct device *dev, + struct uart_config *cfg) { *cfg = get_dev_data(dev)->uart_config; return 0; } -static int uarte_nrfx_err_check(struct device *dev) +static int uarte_nrfx_err_check(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); /* register bitfields maps to the defines in uart.h */ @@ -384,7 +385,7 @@ static void timer_handler(nrf_timer_event_t event_type, void *p_context) { } static void rx_timeout(struct k_timer *timer); static void tx_timeout(struct k_timer *timer); -static int uarte_nrfx_rx_counting_init(struct device *dev) +static int uarte_nrfx_rx_counting_init(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); const struct uarte_nrfx_config *cfg = get_dev_config(dev); @@ -451,7 +452,7 @@ static int uarte_nrfx_rx_counting_init(struct device *dev) return 0; } -static int uarte_nrfx_init(struct device *dev) +static int uarte_nrfx_init(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -491,7 +492,8 @@ static int uarte_nrfx_init(struct device *dev) return 0; } -static int uarte_nrfx_tx(struct device *dev, const uint8_t *buf, size_t len, +static int uarte_nrfx_tx(const struct device *dev, const uint8_t *buf, + size_t len, int32_t timeout) { struct uarte_nrfx_data *data = get_dev_data(dev); @@ -524,7 +526,7 @@ static int uarte_nrfx_tx(struct device *dev, const uint8_t *buf, size_t len, return 0; } -static int uarte_nrfx_tx_abort(struct device *dev) +static int uarte_nrfx_tx_abort(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -538,7 +540,8 @@ static int uarte_nrfx_tx_abort(struct device *dev) return 0; } -static int uarte_nrfx_rx_enable(struct device *dev, uint8_t *buf, size_t len, +static int uarte_nrfx_rx_enable(const struct device *dev, uint8_t *buf, + size_t len, int32_t timeout) { struct uarte_nrfx_data *data = get_dev_data(dev); @@ -569,7 +572,8 @@ static int uarte_nrfx_rx_enable(struct device *dev, uint8_t *buf, size_t len, return 0; } -static int uarte_nrfx_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) +static int uarte_nrfx_rx_buf_rsp(const struct device *dev, uint8_t *buf, + size_t len) { struct uarte_nrfx_data *data = get_dev_data(dev); int err; @@ -593,8 +597,9 @@ static int uarte_nrfx_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) return err; } -static int uarte_nrfx_callback_set(struct device *dev, uart_callback_t callback, - void *user_data) +static int uarte_nrfx_callback_set(const struct device *dev, + uart_callback_t callback, + void *user_data) { struct uarte_nrfx_data *data = get_dev_data(dev); @@ -604,7 +609,7 @@ static int uarte_nrfx_callback_set(struct device *dev, uart_callback_t callback, return 0; } -static int uarte_nrfx_rx_disable(struct device *dev) +static int uarte_nrfx_rx_disable(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -627,11 +632,11 @@ static int uarte_nrfx_rx_disable(struct device *dev) static void tx_timeout(struct k_timer *timer) { - struct device *dev = k_timer_user_data_get(timer); + const struct device *dev = k_timer_user_data_get(timer); (void) uarte_nrfx_tx_abort(dev); } -static void user_callback(struct device *dev, struct uart_event *evt) +static void user_callback(const struct device *dev, struct uart_event *evt) { struct uarte_nrfx_data *data = get_dev_data(dev); @@ -650,7 +655,7 @@ static void user_callback(struct device *dev, struct uart_event *evt) */ static void rx_timeout(struct k_timer *timer) { - struct device *dev = k_timer_user_data_get(timer); + const struct device *dev = k_timer_user_data_get(timer); struct uarte_nrfx_data *data = get_dev_data(dev); const struct uarte_nrfx_config *cfg = get_dev_config(dev); uint32_t read; @@ -735,7 +740,7 @@ static void rx_timeout(struct k_timer *timer) : (mask) & NRF_UARTE_ERROR_BREAK_MASK ? UART_BREAK \ : 0) -static void error_isr(struct device *dev) +static void error_isr(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); uint32_t err = nrf_uarte_errorsrc_get_and_clear(uarte); @@ -747,7 +752,7 @@ static void error_isr(struct device *dev) (void) uarte_nrfx_rx_disable(dev); } -static void rxstarted_isr(struct device *dev) +static void rxstarted_isr(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); struct uart_event evt = { @@ -762,7 +767,7 @@ static void rxstarted_isr(struct device *dev) } } -static void endrx_isr(struct device *dev) +static void endrx_isr(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -880,7 +885,7 @@ static void endrx_isr(struct device *dev) * the events UART_RX_BUF_RELEASED and UART_RX_DISABLED are reported * from endrx_isr. */ -static void rxto_isr(struct device *dev) +static void rxto_isr(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); struct uart_event evt = { @@ -907,7 +912,7 @@ static void rxto_isr(struct device *dev) nrf_uarte_task_trigger(get_uarte_instance(dev), NRF_UARTE_TASK_FLUSHRX); } -static void txstopped_isr(struct device *dev) +static void txstopped_isr(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); @@ -934,7 +939,7 @@ static void txstopped_isr(struct device *dev) user_callback(dev, &evt); } -static void endtx_isr(struct device *dev) +static void endtx_isr(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -945,7 +950,7 @@ static void endtx_isr(struct device *dev) k_timer_stop(&data->async->tx_timeout_timer); } -static void uarte_nrfx_isr_async(struct device *dev) +static void uarte_nrfx_isr_async(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1001,7 +1006,7 @@ static void uarte_nrfx_isr_async(struct device *dev) * * @return 0 if a character arrived, -1 if the input buffer is empty. */ -static int uarte_nrfx_poll_in(struct device *dev, unsigned char *c) +static int uarte_nrfx_poll_in(const struct device *dev, unsigned char *c) { const struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1032,7 +1037,7 @@ static int uarte_nrfx_poll_in(struct device *dev, unsigned char *c) * @param dev UARTE device struct * @param c Character to send */ -static void uarte_nrfx_poll_out(struct device *dev, unsigned char c) +static void uarte_nrfx_poll_out(const struct device *dev, unsigned char c) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1099,7 +1104,7 @@ static void uarte_nrfx_poll_out(struct device *dev, unsigned char c) } #ifdef UARTE_INTERRUPT_DRIVEN /** Interrupt driven FIFO fill function */ -static int uarte_nrfx_fifo_fill(struct device *dev, +static int uarte_nrfx_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { @@ -1129,7 +1134,7 @@ static int uarte_nrfx_fifo_fill(struct device *dev, } /** Interrupt driven FIFO read function */ -static int uarte_nrfx_fifo_read(struct device *dev, +static int uarte_nrfx_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { @@ -1151,7 +1156,7 @@ static int uarte_nrfx_fifo_read(struct device *dev, } /** Interrupt driven transfer enabling function */ -static void uarte_nrfx_irq_tx_enable(struct device *dev) +static void uarte_nrfx_irq_tx_enable(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1161,7 +1166,7 @@ static void uarte_nrfx_irq_tx_enable(struct device *dev) } /** Interrupt driven transfer disabling function */ -static void uarte_nrfx_irq_tx_disable(struct device *dev) +static void uarte_nrfx_irq_tx_disable(const struct device *dev) { struct uarte_nrfx_data *data = get_dev_data(dev); /* TX IRQ will be disabled after current transmission is finished */ @@ -1169,7 +1174,7 @@ static void uarte_nrfx_irq_tx_disable(struct device *dev) } /** Interrupt driven transfer ready function */ -static int uarte_nrfx_irq_tx_ready_complete(struct device *dev) +static int uarte_nrfx_irq_tx_ready_complete(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1184,7 +1189,7 @@ static int uarte_nrfx_irq_tx_ready_complete(struct device *dev) nrf_uarte_int_enable_check(uarte, NRF_UARTE_INT_ENDTX_MASK); } -static int uarte_nrfx_irq_rx_ready(struct device *dev) +static int uarte_nrfx_irq_rx_ready(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1192,7 +1197,7 @@ static int uarte_nrfx_irq_rx_ready(struct device *dev) } /** Interrupt driven receiver enabling function */ -static void uarte_nrfx_irq_rx_enable(struct device *dev) +static void uarte_nrfx_irq_rx_enable(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1200,7 +1205,7 @@ static void uarte_nrfx_irq_rx_enable(struct device *dev) } /** Interrupt driven receiver disabling function */ -static void uarte_nrfx_irq_rx_disable(struct device *dev) +static void uarte_nrfx_irq_rx_disable(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1208,7 +1213,7 @@ static void uarte_nrfx_irq_rx_disable(struct device *dev) } /** Interrupt driven error enabling function */ -static void uarte_nrfx_irq_err_enable(struct device *dev) +static void uarte_nrfx_irq_err_enable(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1216,7 +1221,7 @@ static void uarte_nrfx_irq_err_enable(struct device *dev) } /** Interrupt driven error disabling function */ -static void uarte_nrfx_irq_err_disable(struct device *dev) +static void uarte_nrfx_irq_err_disable(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1224,7 +1229,7 @@ static void uarte_nrfx_irq_err_disable(struct device *dev) } /** Interrupt driven pending status function */ -static int uarte_nrfx_irq_is_pending(struct device *dev) +static int uarte_nrfx_irq_is_pending(const struct device *dev) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); @@ -1238,13 +1243,13 @@ static int uarte_nrfx_irq_is_pending(struct device *dev) } /** Interrupt driven interrupt update function */ -static int uarte_nrfx_irq_update(struct device *dev) +static int uarte_nrfx_irq_update(const struct device *dev) { return 1; } /** Set the callback function */ -static void uarte_nrfx_irq_callback_set(struct device *dev, +static void uarte_nrfx_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -1287,7 +1292,7 @@ static const struct uart_driver_api uart_nrfx_uarte_driver_api = { #endif /* UARTE_INTERRUPT_DRIVEN */ }; -static int uarte_instance_init(struct device *dev, +static int uarte_instance_init(const struct device *dev, const struct uarte_init_config *config, uint8_t interrupts_active) { @@ -1361,7 +1366,7 @@ static int uarte_instance_init(struct device *dev, #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static void uarte_nrfx_pins_enable(struct device *dev, bool enable) +static void uarte_nrfx_pins_enable(const struct device *dev, bool enable) { if (!get_dev_config(dev)->gpio_mgmt) { return; @@ -1405,7 +1410,8 @@ static void uarte_nrfx_pins_enable(struct device *dev, bool enable) } } -static void uarte_nrfx_set_power_state(struct device *dev, uint32_t new_state) +static void uarte_nrfx_set_power_state(const struct device *dev, + uint32_t new_state) { NRF_UARTE_Type *uarte = get_uarte_instance(dev); struct uarte_nrfx_data *data = get_dev_data(dev); @@ -1464,7 +1470,8 @@ static void uarte_nrfx_set_power_state(struct device *dev, uint32_t new_state) } } -static int uarte_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int uarte_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { struct uarte_nrfx_data *data = get_dev_data(dev); diff --git a/drivers/serial/uart_ns16550.c b/drivers/serial/uart_ns16550.c index 797fac97ded1dd..7d80e1c37412fa 100644 --- a/drivers/serial/uart_ns16550.c +++ b/drivers/serial/uart_ns16550.c @@ -296,7 +296,7 @@ struct uart_ns16550_dev_data_t { static const struct uart_driver_api uart_ns16550_driver_api; -static inline uintptr_t get_port(struct device *dev) +static inline uintptr_t get_port(const struct device *dev) { #ifndef UART_NS16550_ACCESS_IOPORT return DEVICE_MMIO_GET(dev); @@ -305,7 +305,7 @@ static inline uintptr_t get_port(struct device *dev) #endif } -static void set_baud_rate(struct device *dev, uint32_t baud_rate) +static void set_baud_rate(const struct device *dev, uint32_t baud_rate) { const struct uart_ns16550_device_config * const dev_cfg = DEV_CFG(dev); struct uart_ns16550_dev_data_t * const dev_data = DEV_DATA(dev); @@ -333,8 +333,8 @@ static void set_baud_rate(struct device *dev, uint32_t baud_rate) } } -static int uart_ns16550_configure(struct device *dev, - const struct uart_config *cfg) +static int uart_ns16550_configure(const struct device *dev, + const struct uart_config *cfg) { struct uart_ns16550_dev_data_t * const dev_data = DEV_DATA(dev); const struct uart_ns16550_device_config * const dev_cfg = DEV_CFG(dev); @@ -475,7 +475,8 @@ static int uart_ns16550_configure(struct device *dev, return ret; }; -static int uart_ns16550_config_get(struct device *dev, struct uart_config *cfg) +static int uart_ns16550_config_get(const struct device *dev, + struct uart_config *cfg) { struct uart_ns16550_dev_data_t *data = DEV_DATA(dev); @@ -497,7 +498,7 @@ static int uart_ns16550_config_get(struct device *dev, struct uart_config *cfg) * * @return 0 if successful, failed otherwise */ -static int uart_ns16550_init(struct device *dev) +static int uart_ns16550_init(const struct device *dev) { int ret; @@ -521,7 +522,7 @@ static int uart_ns16550_init(struct device *dev) * * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_ns16550_poll_in(struct device *dev, unsigned char *c) +static int uart_ns16550_poll_in(const struct device *dev, unsigned char *c) { int ret = -1; k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -549,7 +550,7 @@ static int uart_ns16550_poll_in(struct device *dev, unsigned char *c) * @param dev UART device struct * @param c Character to send */ -static void uart_ns16550_poll_out(struct device *dev, +static void uart_ns16550_poll_out(const struct device *dev, unsigned char c) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -570,7 +571,7 @@ static void uart_ns16550_poll_out(struct device *dev, * @return one of UART_ERROR_OVERRUN, UART_ERROR_PARITY, UART_ERROR_FRAMING, * UART_BREAK if an error was detected, 0 otherwise. */ -static int uart_ns16550_err_check(struct device *dev) +static int uart_ns16550_err_check(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); int check = (INBYTE(LSR(dev)) & LSR_EOB_MASK); @@ -591,7 +592,8 @@ static int uart_ns16550_err_check(struct device *dev) * * @return Number of bytes sent */ -static int uart_ns16550_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_ns16550_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { int i; @@ -615,7 +617,7 @@ static int uart_ns16550_fifo_fill(struct device *dev, const uint8_t *tx_data, * * @return Number of bytes read */ -static int uart_ns16550_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_ns16550_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { int i; @@ -637,7 +639,7 @@ static int uart_ns16550_fifo_read(struct device *dev, uint8_t *rx_data, * * @return N/A */ -static void uart_ns16550_irq_tx_enable(struct device *dev) +static void uart_ns16550_irq_tx_enable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -653,7 +655,7 @@ static void uart_ns16550_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_ns16550_irq_tx_disable(struct device *dev) +static void uart_ns16550_irq_tx_disable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -669,7 +671,7 @@ static void uart_ns16550_irq_tx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_ns16550_irq_tx_ready(struct device *dev) +static int uart_ns16550_irq_tx_ready(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -687,7 +689,7 @@ static int uart_ns16550_irq_tx_ready(struct device *dev) * * @return 1 if nothing remains to be transmitted, 0 otherwise */ -static int uart_ns16550_irq_tx_complete(struct device *dev) +static int uart_ns16550_irq_tx_complete(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -706,7 +708,7 @@ static int uart_ns16550_irq_tx_complete(struct device *dev) * * @return N/A */ -static void uart_ns16550_irq_rx_enable(struct device *dev) +static void uart_ns16550_irq_rx_enable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -722,7 +724,7 @@ static void uart_ns16550_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_ns16550_irq_rx_disable(struct device *dev) +static void uart_ns16550_irq_rx_disable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -738,7 +740,7 @@ static void uart_ns16550_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_ns16550_irq_rx_ready(struct device *dev) +static int uart_ns16550_irq_rx_ready(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -756,7 +758,7 @@ static int uart_ns16550_irq_rx_ready(struct device *dev) * * @return N/A */ -static void uart_ns16550_irq_err_enable(struct device *dev) +static void uart_ns16550_irq_err_enable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -772,7 +774,7 @@ static void uart_ns16550_irq_err_enable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static void uart_ns16550_irq_err_disable(struct device *dev) +static void uart_ns16550_irq_err_disable(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -788,7 +790,7 @@ static void uart_ns16550_irq_err_disable(struct device *dev) * * @return 1 if an IRQ is pending, 0 otherwise */ -static int uart_ns16550_irq_is_pending(struct device *dev) +static int uart_ns16550_irq_is_pending(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -806,7 +808,7 @@ static int uart_ns16550_irq_is_pending(struct device *dev) * * @return Always 1 */ -static int uart_ns16550_irq_update(struct device *dev) +static int uart_ns16550_irq_update(const struct device *dev) { k_spinlock_key_t key = k_spin_lock(&DEV_DATA(dev)->lock); @@ -825,7 +827,7 @@ static int uart_ns16550_irq_update(struct device *dev) * * @return N/A */ -static void uart_ns16550_irq_callback_set(struct device *dev, +static void uart_ns16550_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -849,7 +851,7 @@ static void uart_ns16550_irq_callback_set(struct device *dev, */ static void uart_ns16550_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_ns16550_dev_data_t * const dev_data = DEV_DATA(dev); if (dev_data->cb) { @@ -871,7 +873,7 @@ static void uart_ns16550_isr(void *arg) * * @return 0 if successful, failed otherwise */ -static int uart_ns16550_line_ctrl_set(struct device *dev, +static int uart_ns16550_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val) { uint32_t mdc, chg; @@ -919,7 +921,8 @@ static int uart_ns16550_line_ctrl_set(struct device *dev, * * @return 0 if successful, failed otherwise */ -static int uart_ns16550_drv_cmd(struct device *dev, uint32_t cmd, uint32_t p) +static int uart_ns16550_drv_cmd(const struct device *dev, uint32_t cmd, + uint32_t p) { #ifdef UART_NS16550_DLF_ENABLED if (cmd == CMD_SET_DLF) { diff --git a/drivers/serial/uart_nuvoton.c b/drivers/serial/uart_nuvoton.c index d7b0ce97b2123d..0c3f14caf0b29d 100644 --- a/drivers/serial/uart_nuvoton.c +++ b/drivers/serial/uart_nuvoton.c @@ -28,11 +28,11 @@ struct uart_numicro_config { }; struct uart_numicro_data { - struct device *clock; + const struct device *clock; struct uart_config ucfg; }; -static int uart_numicro_poll_in(struct device *dev, unsigned char *c) +static int uart_numicro_poll_in(const struct device *dev, unsigned char *c) { uint32_t count; @@ -44,12 +44,12 @@ static int uart_numicro_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_numicro_poll_out(struct device *dev, unsigned char c) +static void uart_numicro_poll_out(const struct device *dev, unsigned char c) { UART_Write(UART_STRUCT(dev), &c, 1); } -static int uart_numicro_err_check(struct device *dev) +static int uart_numicro_err_check(const struct device *dev) { return 0; } @@ -101,7 +101,7 @@ static inline uint32_t uart_numicro_convert_parity(enum uart_config_parity parit } } -static int uart_numicro_configure(struct device *dev, +static int uart_numicro_configure(const struct device *dev, const struct uart_config *cfg) { struct uart_numicro_data *ddata = DRV_DATA(dev); @@ -136,7 +136,8 @@ static int uart_numicro_configure(struct device *dev, return 0; } -static int uart_numicro_config_get(struct device *dev, struct uart_config *cfg) +static int uart_numicro_config_get(const struct device *dev, + struct uart_config *cfg) { struct uart_numicro_data *ddata = DRV_DATA(dev); @@ -145,7 +146,7 @@ static int uart_numicro_config_get(struct device *dev, struct uart_config *cfg) return 0; } -static int uart_numicro_init(struct device *dev) +static int uart_numicro_init(const struct device *dev) { const struct uart_numicro_config *config = DEV_CFG(dev); struct uart_numicro_data *ddata = DRV_DATA(dev); diff --git a/drivers/serial/uart_pl011.c b/drivers/serial/uart_pl011.c index 827ae9d22d9216..be259fd5da8f83 100644 --- a/drivers/serial/uart_pl011.c +++ b/drivers/serial/uart_pl011.c @@ -147,27 +147,27 @@ struct pl011_data { #define PL011_REGS(dev) \ ((volatile struct pl011_regs *)(DEV_CFG(dev))->base) -static void pl011_enable(struct device *dev) +static void pl011_enable(const struct device *dev) { PL011_REGS(dev)->cr |= PL011_CR_UARTEN; } -static void pl011_disable(struct device *dev) +static void pl011_disable(const struct device *dev) { PL011_REGS(dev)->cr &= ~PL011_CR_UARTEN; } -static void pl011_enable_fifo(struct device *dev) +static void pl011_enable_fifo(const struct device *dev) { PL011_REGS(dev)->lcr_h |= PL011_LCRH_FEN; } -static void pl011_disable_fifo(struct device *dev) +static void pl011_disable_fifo(const struct device *dev) { PL011_REGS(dev)->lcr_h &= ~PL011_LCRH_FEN; } -static int pl011_set_baudrate(struct device *dev, +static int pl011_set_baudrate(const struct device *dev, uint32_t clk, uint32_t baudrate) { /* Avoiding float calculations, bauddiv is left shifted by 6 */ @@ -197,7 +197,7 @@ static int pl011_set_baudrate(struct device *dev, return 0; } -static bool pl011_is_readable(struct device *dev) +static bool pl011_is_readable(const struct device *dev) { if ((PL011_REGS(dev)->cr & PL011_CR_UARTEN) && (PL011_REGS(dev)->cr & PL011_CR_RXE) && @@ -208,7 +208,7 @@ static bool pl011_is_readable(struct device *dev) return false; } -static int pl011_poll_in(struct device *dev, unsigned char *c) +static int pl011_poll_in(const struct device *dev, unsigned char *c) { if (!pl011_is_readable(dev)) { return -1; @@ -220,7 +220,7 @@ static int pl011_poll_in(struct device *dev, unsigned char *c) return PL011_REGS(dev)->rsr & PL011_RSR_ERROR_MASK; } -static void pl011_poll_out(struct device *dev, +static void pl011_poll_out(const struct device *dev, unsigned char c) { /* Wait for space in FIFO */ @@ -233,7 +233,7 @@ static void pl011_poll_out(struct device *dev, } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int pl011_fifo_fill(struct device *dev, +static int pl011_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { uint8_t num_tx = 0U; @@ -245,7 +245,7 @@ static int pl011_fifo_fill(struct device *dev, return num_tx; } -static int pl011_fifo_read(struct device *dev, +static int pl011_fifo_read(const struct device *dev, uint8_t *rx_data, const int len) { uint8_t num_rx = 0U; @@ -258,70 +258,70 @@ static int pl011_fifo_read(struct device *dev, return num_rx; } -static void pl011_irq_tx_enable(struct device *dev) +static void pl011_irq_tx_enable(const struct device *dev) { PL011_REGS(dev)->imsc |= PL011_IMSC_TXIM; } -static void pl011_irq_tx_disable(struct device *dev) +static void pl011_irq_tx_disable(const struct device *dev) { PL011_REGS(dev)->imsc &= ~PL011_IMSC_TXIM; } -static int pl011_irq_tx_complete(struct device *dev) +static int pl011_irq_tx_complete(const struct device *dev) { /* check for TX FIFO empty */ return PL011_REGS(dev)->fr & PL011_FR_TXFE; } -static int pl011_irq_tx_ready(struct device *dev) +static int pl011_irq_tx_ready(const struct device *dev) { return ((PL011_REGS(dev)->cr & PL011_CR_TXE) && (PL011_REGS(dev)->imsc & PL011_IMSC_TXIM) && pl011_irq_tx_complete(dev)); } -static void pl011_irq_rx_enable(struct device *dev) +static void pl011_irq_rx_enable(const struct device *dev) { PL011_REGS(dev)->imsc |= PL011_IMSC_RXIM | PL011_IMSC_RTIM; } -static void pl011_irq_rx_disable(struct device *dev) +static void pl011_irq_rx_disable(const struct device *dev) { PL011_REGS(dev)->imsc &= ~(PL011_IMSC_RXIM | PL011_IMSC_RTIM); } -static int pl011_irq_rx_ready(struct device *dev) +static int pl011_irq_rx_ready(const struct device *dev) { return ((PL011_REGS(dev)->cr & PL011_CR_RXE) && (PL011_REGS(dev)->imsc & PL011_IMSC_RXIM) && (!(PL011_REGS(dev)->fr & PL011_FR_RXFE))); } -static void pl011_irq_err_enable(struct device *dev) +static void pl011_irq_err_enable(const struct device *dev) { /* enable framing, parity, break, and overrun */ PL011_REGS(dev)->imsc |= PL011_IMSC_ERROR_MASK; } -static void pl011_irq_err_disable(struct device *dev) +static void pl011_irq_err_disable(const struct device *dev) { PL011_REGS(dev)->imsc &= ~PL011_IMSC_ERROR_MASK; } -static int pl011_irq_is_pending(struct device *dev) +static int pl011_irq_is_pending(const struct device *dev) { return pl011_irq_rx_ready(dev) || pl011_irq_tx_ready(dev); } -static int pl011_irq_update(struct device *dev) +static int pl011_irq_update(const struct device *dev) { return 1; } -static void pl011_irq_callback_set(struct device *dev, +static void pl011_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -351,7 +351,7 @@ static const struct uart_driver_api pl011_driver_api = { #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; -static int pl011_init(struct device *dev) +static int pl011_init(const struct device *dev) { int ret; uint32_t lcrh; @@ -397,7 +397,7 @@ static int pl011_init(struct device *dev) #ifdef CONFIG_UART_INTERRUPT_DRIVEN void pl011_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct pl011_data *data = DEV_DATA(dev); /* Verify if the callback has been registered */ @@ -411,7 +411,7 @@ void pl011_isr(void *arg) #ifdef CONFIG_UART_PL011_PORT0 #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void pl011_irq_config_func_0(struct device *dev); +static void pl011_irq_config_func_0(const struct device *dev); #endif static struct uart_device_config pl011_cfg_port_0 = { @@ -435,7 +435,7 @@ DEVICE_AND_API_INIT(pl011_port_0, &pl011_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void pl011_irq_config_func_0(struct device *dev) +static void pl011_irq_config_func_0(const struct device *dev) { #if DT_NUM_IRQS(DT_INST(0, arm_pl011)) == 1 IRQ_CONNECT(DT_INST_IRQN(0), @@ -474,7 +474,7 @@ static void pl011_irq_config_func_0(struct device *dev) #ifdef CONFIG_UART_PL011_PORT1 #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void pl011_irq_config_func_1(struct device *dev); +static void pl011_irq_config_func_1(const struct device *dev); #endif static struct uart_device_config pl011_cfg_port_1 = { @@ -498,7 +498,7 @@ DEVICE_AND_API_INIT(pl011_port_1, &pl011_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void pl011_irq_config_func_1(struct device *dev) +static void pl011_irq_config_func_1(const struct device *dev) { #if DT_NUM_IRQS(DT_INST(1, arm_pl011)) == 1 IRQ_CONNECT(DT_INST_IRQN(1), diff --git a/drivers/serial/uart_psoc6.c b/drivers/serial/uart_psoc6.c index 8848beaba22683..85d3617d59e56a 100644 --- a/drivers/serial/uart_psoc6.c +++ b/drivers/serial/uart_psoc6.c @@ -92,7 +92,7 @@ static const cy_stc_scb_uart_config_t uartConfig = { * Peforms hardware initialization: debug UART. * */ -static int uart_psoc6_init(struct device *dev) +static int uart_psoc6_init(const struct device *dev) { const struct cypress_psoc6_config *config = dev->config; @@ -123,7 +123,7 @@ static int uart_psoc6_init(struct device *dev) return 0; } -static int uart_psoc6_poll_in(struct device *dev, unsigned char *c) +static int uart_psoc6_poll_in(const struct device *dev, unsigned char *c) { const struct cypress_psoc6_config *config = dev->config; uint32_t rec; @@ -134,7 +134,7 @@ static int uart_psoc6_poll_in(struct device *dev, unsigned char *c) return ((rec == CY_SCB_UART_RX_NO_DATA) ? -1 : 0); } -static void uart_psoc6_poll_out(struct device *dev, unsigned char c) +static void uart_psoc6_poll_out(const struct device *dev, unsigned char c) { const struct cypress_psoc6_config *config = dev->config; diff --git a/drivers/serial/uart_rtt.c b/drivers/serial/uart_rtt.c index 65b9573e444f76..840c7c28533ec0 100644 --- a/drivers/serial/uart_rtt.c +++ b/drivers/serial/uart_rtt.c @@ -15,12 +15,12 @@ struct uart_rtt_config { uint8_t channel; }; -static inline const struct uart_rtt_config *get_dev_config(struct device *dev) +static inline const struct uart_rtt_config *get_dev_config(const struct device *dev) { return dev->config; } -static int uart_rtt_init(struct device *dev) +static int uart_rtt_init(const struct device *dev) { /* * Channel 0 is initialized at compile-time, Kconfig ensures that @@ -49,7 +49,7 @@ static int uart_rtt_init(struct device *dev) * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_rtt_poll_in(struct device *dev, unsigned char *c) +static int uart_rtt_poll_in(const struct device *dev, unsigned char *c) { unsigned int ch = get_dev_config(dev) ? get_dev_config(dev)->channel : 0; @@ -64,7 +64,7 @@ static int uart_rtt_poll_in(struct device *dev, unsigned char *c) * @param dev UART device struct * @param c Character to send */ -static void uart_rtt_poll_out(struct device *dev, unsigned char c) +static void uart_rtt_poll_out(const struct device *dev, unsigned char c) { unsigned int ch = get_dev_config(dev) ? get_dev_config(dev)->channel : 0; diff --git a/drivers/serial/uart_rv32m1_lpuart.c b/drivers/serial/uart_rv32m1_lpuart.c index 72dfa5a0da0c67..d3f2d5cec7dc06 100644 --- a/drivers/serial/uart_rv32m1_lpuart.c +++ b/drivers/serial/uart_rv32m1_lpuart.c @@ -23,7 +23,7 @@ struct rv32m1_lpuart_config { uint32_t baud_rate; uint8_t hw_flow_control; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif }; @@ -34,7 +34,7 @@ struct rv32m1_lpuart_data { #endif }; -static int rv32m1_lpuart_poll_in(struct device *dev, unsigned char *c) +static int rv32m1_lpuart_poll_in(const struct device *dev, unsigned char *c) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -48,7 +48,7 @@ static int rv32m1_lpuart_poll_in(struct device *dev, unsigned char *c) return ret; } -static void rv32m1_lpuart_poll_out(struct device *dev, unsigned char c) +static void rv32m1_lpuart_poll_out(const struct device *dev, unsigned char c) { const struct rv32m1_lpuart_config *config = dev->config; @@ -59,7 +59,7 @@ static void rv32m1_lpuart_poll_out(struct device *dev, unsigned char c) LPUART_WriteByte(config->base, c); } -static int rv32m1_lpuart_err_check(struct device *dev) +static int rv32m1_lpuart_err_check(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -85,8 +85,9 @@ static int rv32m1_lpuart_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int rv32m1_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data, - int len) +static int rv32m1_lpuart_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int len) { const struct rv32m1_lpuart_config *config = dev->config; uint8_t num_tx = 0U; @@ -101,8 +102,8 @@ static int rv32m1_lpuart_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int rv32m1_lpuart_fifo_read(struct device *dev, uint8_t *rx_data, - const int len) +static int rv32m1_lpuart_fifo_read(const struct device *dev, uint8_t *rx_data, + const int len) { const struct rv32m1_lpuart_config *config = dev->config; uint8_t num_rx = 0U; @@ -117,7 +118,7 @@ static int rv32m1_lpuart_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void rv32m1_lpuart_irq_tx_enable(struct device *dev) +static void rv32m1_lpuart_irq_tx_enable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -125,7 +126,7 @@ static void rv32m1_lpuart_irq_tx_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void rv32m1_lpuart_irq_tx_disable(struct device *dev) +static void rv32m1_lpuart_irq_tx_disable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -133,7 +134,7 @@ static void rv32m1_lpuart_irq_tx_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int rv32m1_lpuart_irq_tx_complete(struct device *dev) +static int rv32m1_lpuart_irq_tx_complete(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -141,7 +142,7 @@ static int rv32m1_lpuart_irq_tx_complete(struct device *dev) return (flags & kLPUART_TxDataRegEmptyFlag) != 0U; } -static int rv32m1_lpuart_irq_tx_ready(struct device *dev) +static int rv32m1_lpuart_irq_tx_ready(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_TxDataRegEmptyInterruptEnable; @@ -150,7 +151,7 @@ static int rv32m1_lpuart_irq_tx_ready(struct device *dev) && rv32m1_lpuart_irq_tx_complete(dev); } -static void rv32m1_lpuart_irq_rx_enable(struct device *dev) +static void rv32m1_lpuart_irq_rx_enable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -158,7 +159,7 @@ static void rv32m1_lpuart_irq_rx_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void rv32m1_lpuart_irq_rx_disable(struct device *dev) +static void rv32m1_lpuart_irq_rx_disable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -166,7 +167,7 @@ static void rv32m1_lpuart_irq_rx_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int rv32m1_lpuart_irq_rx_full(struct device *dev) +static int rv32m1_lpuart_irq_rx_full(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t flags = LPUART_GetStatusFlags(config->base); @@ -174,7 +175,7 @@ static int rv32m1_lpuart_irq_rx_full(struct device *dev) return (flags & kLPUART_RxDataRegFullFlag) != 0U; } -static int rv32m1_lpuart_irq_rx_ready(struct device *dev) +static int rv32m1_lpuart_irq_rx_ready(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_RxDataRegFullInterruptEnable; @@ -183,7 +184,7 @@ static int rv32m1_lpuart_irq_rx_ready(struct device *dev) && rv32m1_lpuart_irq_rx_full(dev); } -static void rv32m1_lpuart_irq_err_enable(struct device *dev) +static void rv32m1_lpuart_irq_err_enable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_NoiseErrorInterruptEnable | @@ -193,7 +194,7 @@ static void rv32m1_lpuart_irq_err_enable(struct device *dev) LPUART_EnableInterrupts(config->base, mask); } -static void rv32m1_lpuart_irq_err_disable(struct device *dev) +static void rv32m1_lpuart_irq_err_disable(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; uint32_t mask = kLPUART_NoiseErrorInterruptEnable | @@ -203,20 +204,20 @@ static void rv32m1_lpuart_irq_err_disable(struct device *dev) LPUART_DisableInterrupts(config->base, mask); } -static int rv32m1_lpuart_irq_is_pending(struct device *dev) +static int rv32m1_lpuart_irq_is_pending(const struct device *dev) { return (rv32m1_lpuart_irq_tx_ready(dev) || rv32m1_lpuart_irq_rx_ready(dev)); } -static int rv32m1_lpuart_irq_update(struct device *dev) +static int rv32m1_lpuart_irq_update(const struct device *dev) { return 1; } -static void rv32m1_lpuart_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void rv32m1_lpuart_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct rv32m1_lpuart_data *data = dev->data; @@ -226,7 +227,7 @@ static void rv32m1_lpuart_irq_callback_set(struct device *dev, static void rv32m1_lpuart_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct rv32m1_lpuart_data *data = dev->data; if (data->callback) { @@ -235,11 +236,11 @@ static void rv32m1_lpuart_isr(void *arg) } #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int rv32m1_lpuart_init(struct device *dev) +static int rv32m1_lpuart_init(const struct device *dev) { const struct rv32m1_lpuart_config *config = dev->config; lpuart_config_t uart_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; /* set clock source */ @@ -311,7 +312,7 @@ static const struct uart_driver_api rv32m1_lpuart_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define RV32M1_LPUART_CONFIG_FUNC(n) \ - static void rv32m1_lpuart_config_func_##n(struct device *dev) \ + static void rv32m1_lpuart_config_func_##n(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), 0, rv32m1_lpuart_isr, \ DEVICE_GET(uart_0), 0); \ diff --git a/drivers/serial/uart_sam.c b/drivers/serial/uart_sam.c index 329bed88c3df95..b4820b3606b056 100644 --- a/drivers/serial/uart_sam.c +++ b/drivers/serial/uart_sam.c @@ -53,7 +53,7 @@ static int baudrate_set(Uart *const uart, uint32_t baudrate, uint32_t mck_freq_hz); -static int uart_sam_init(struct device *dev) +static int uart_sam_init(const struct device *dev) { int retval; const struct uart_sam_dev_cfg *const cfg = DEV_CFG(dev); @@ -97,7 +97,7 @@ static int uart_sam_init(struct device *dev) return 0; } -static int uart_sam_poll_in(struct device *dev, unsigned char *c) +static int uart_sam_poll_in(const struct device *dev, unsigned char *c) { Uart *const uart = DEV_CFG(dev)->regs; @@ -111,7 +111,7 @@ static int uart_sam_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_sam_poll_out(struct device *dev, unsigned char c) +static void uart_sam_poll_out(const struct device *dev, unsigned char c) { Uart *const uart = DEV_CFG(dev)->regs; @@ -123,7 +123,7 @@ static void uart_sam_poll_out(struct device *dev, unsigned char c) uart->UART_THR = (uint32_t)c; } -static int uart_sam_err_check(struct device *dev) +static int uart_sam_err_check(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; int errors = 0; @@ -166,7 +166,8 @@ static int baudrate_set(Uart *const uart, uint32_t baudrate, #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_sam_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_sam_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { volatile Uart * const uart = DEV_CFG(dev)->regs; @@ -180,7 +181,7 @@ static int uart_sam_fifo_fill(struct device *dev, const uint8_t *tx_data, return 1; } -static int uart_sam_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_sam_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { volatile Uart * const uart = DEV_CFG(dev)->regs; @@ -200,70 +201,70 @@ static int uart_sam_fifo_read(struct device *dev, uint8_t *rx_data, return bytes_read; } -static void uart_sam_irq_tx_enable(struct device *dev) +static void uart_sam_irq_tx_enable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IER = UART_IER_TXRDY; } -static void uart_sam_irq_tx_disable(struct device *dev) +static void uart_sam_irq_tx_disable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IDR = UART_IDR_TXRDY; } -static int uart_sam_irq_tx_ready(struct device *dev) +static int uart_sam_irq_tx_ready(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; return (uart->UART_SR & UART_SR_TXRDY); } -static void uart_sam_irq_rx_enable(struct device *dev) +static void uart_sam_irq_rx_enable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IER = UART_IER_RXRDY; } -static void uart_sam_irq_rx_disable(struct device *dev) +static void uart_sam_irq_rx_disable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IDR = UART_IDR_RXRDY; } -static int uart_sam_irq_tx_complete(struct device *dev) +static int uart_sam_irq_tx_complete(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; return !(uart->UART_SR & UART_SR_TXRDY); } -static int uart_sam_irq_rx_ready(struct device *dev) +static int uart_sam_irq_rx_ready(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; return (uart->UART_SR & UART_SR_RXRDY); } -static void uart_sam_irq_err_enable(struct device *dev) +static void uart_sam_irq_err_enable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IER = UART_IER_OVRE | UART_IER_FRAME | UART_IER_PARE; } -static void uart_sam_irq_err_disable(struct device *dev) +static void uart_sam_irq_err_disable(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; uart->UART_IDR = UART_IDR_OVRE | UART_IDR_FRAME | UART_IDR_PARE; } -static int uart_sam_irq_is_pending(struct device *dev) +static int uart_sam_irq_is_pending(const struct device *dev) { volatile Uart * const uart = DEV_CFG(dev)->regs; @@ -271,14 +272,14 @@ static int uart_sam_irq_is_pending(struct device *dev) (uart->UART_SR & (UART_SR_TXRDY | UART_SR_RXRDY)); } -static int uart_sam_irq_update(struct device *dev) +static int uart_sam_irq_update(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void uart_sam_irq_callback_set(struct device *dev, +static void uart_sam_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -290,7 +291,7 @@ static void uart_sam_irq_callback_set(struct device *dev, static void uart_sam_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_sam_dev_data *const dev_data = DEV_DATA(dev); if (dev_data->irq_cb) { @@ -335,7 +336,7 @@ static const struct uart_driver_api uart_sam_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define UART_SAM_CONFIG_FUNC(n) \ - static void uart##n##_sam_irq_config_func(struct device *port) \ + static void uart##n##_sam_irq_config_func(const struct device *port) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/serial/uart_sam0.c b/drivers/serial/uart_sam0.c index 0fc3faca64c264..e7249a6e02afeb 100644 --- a/drivers/serial/uart_sam0.c +++ b/drivers/serial/uart_sam0.c @@ -33,7 +33,7 @@ struct uart_sam0_dev_cfg { uint16_t gclk_clkctrl_id; #endif #if CONFIG_UART_INTERRUPT_DRIVEN || CONFIG_UART_ASYNC_API - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif #if CONFIG_UART_ASYNC_API char *dma_dev; @@ -52,9 +52,9 @@ struct uart_sam0_dev_data { void *cb_data; #endif #if CONFIG_UART_ASYNC_API - struct device *dev; + const struct device *dev; const struct uart_sam0_dev_cfg *cfg; - struct device *dma; + const struct device *dma; uart_callback_t async_cb; void *async_cb_data; @@ -120,14 +120,14 @@ static int uart_sam0_set_baudrate(SercomUsart *const usart, uint32_t baudrate, #if CONFIG_UART_ASYNC_API -static void uart_sam0_dma_tx_done(struct device *dma_dev, void *arg, +static void uart_sam0_dma_tx_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { ARG_UNUSED(dma_dev); ARG_UNUSED(id); ARG_UNUSED(error_code); - struct device *dev = arg; + const struct device *dev = arg; struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); k_delayed_work_cancel(&dev_data->tx_timeout_work); @@ -224,14 +224,14 @@ static void uart_sam0_notify_rx_processed(struct uart_sam0_dev_data *dev_data, &evt, dev_data->async_cb_data); } -static void uart_sam0_dma_rx_done(struct device *dma_dev, void *arg, +static void uart_sam0_dma_rx_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { ARG_UNUSED(dma_dev); ARG_UNUSED(id); ARG_UNUSED(error_code); - struct device *dev = arg; + const struct device *dev = arg; struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); const struct uart_sam0_dev_cfg *const cfg = dev_data->cfg; SercomUsart * const regs = cfg->regs; @@ -391,7 +391,7 @@ static void uart_sam0_rx_timeout(struct k_work *work) #endif -static int uart_sam0_configure(struct device *dev, +static int uart_sam0_configure(const struct device *dev, const struct uart_config *new_cfg) { int retval; @@ -490,7 +490,7 @@ static int uart_sam0_configure(struct device *dev, return 0; } -static int uart_sam0_config_get(struct device *dev, +static int uart_sam0_config_get(const struct device *dev, struct uart_config *out_cfg) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); @@ -500,7 +500,7 @@ static int uart_sam0_config_get(struct device *dev, return 0; } -static int uart_sam0_init(struct device *dev) +static int uart_sam0_init(const struct device *dev) { int retval; const struct uart_sam0_dev_cfg *const cfg = DEV_CFG(dev); @@ -634,7 +634,7 @@ static int uart_sam0_init(struct device *dev) return 0; } -static int uart_sam0_poll_in(struct device *dev, unsigned char *c) +static int uart_sam0_poll_in(const struct device *dev, unsigned char *c) { SercomUsart *const usart = DEV_CFG(dev)->regs; @@ -646,7 +646,7 @@ static int uart_sam0_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_sam0_poll_out(struct device *dev, unsigned char c) +static void uart_sam0_poll_out(const struct device *dev, unsigned char c) { SercomUsart *const usart = DEV_CFG(dev)->regs; @@ -661,7 +661,7 @@ static void uart_sam0_poll_out(struct device *dev, unsigned char c) static void uart_sam0_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); #if CONFIG_UART_INTERRUPT_DRIVEN @@ -709,7 +709,8 @@ static void uart_sam0_isr(void *arg) #if CONFIG_UART_INTERRUPT_DRIVEN -static int uart_sam0_fifo_fill(struct device *dev, const uint8_t *tx_data, int len) +static int uart_sam0_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { SercomUsart *regs = DEV_CFG(dev)->regs; @@ -721,49 +722,49 @@ static int uart_sam0_fifo_fill(struct device *dev, const uint8_t *tx_data, int l } } -static void uart_sam0_irq_tx_enable(struct device *dev) +static void uart_sam0_irq_tx_enable(const struct device *dev) { SercomUsart *regs = DEV_CFG(dev)->regs; regs->INTENSET.reg = SERCOM_USART_INTENCLR_DRE; } -static void uart_sam0_irq_tx_disable(struct device *dev) +static void uart_sam0_irq_tx_disable(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; regs->INTENCLR.reg = SERCOM_USART_INTENCLR_DRE; } -static int uart_sam0_irq_tx_ready(struct device *dev) +static int uart_sam0_irq_tx_ready(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; return regs->INTFLAG.bit.DRE != 0; } -static void uart_sam0_irq_rx_enable(struct device *dev) +static void uart_sam0_irq_rx_enable(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; regs->INTENSET.reg = SERCOM_USART_INTENSET_RXC; } -static void uart_sam0_irq_rx_disable(struct device *dev) +static void uart_sam0_irq_rx_disable(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; regs->INTENCLR.reg = SERCOM_USART_INTENCLR_RXC; } -static int uart_sam0_irq_rx_ready(struct device *dev) +static int uart_sam0_irq_rx_ready(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; return regs->INTFLAG.bit.RXC != 0; } -static int uart_sam0_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_sam0_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { SercomUsart *const regs = DEV_CFG(dev)->regs; @@ -781,16 +782,16 @@ static int uart_sam0_fifo_read(struct device *dev, uint8_t *rx_data, return 0; } -static int uart_sam0_irq_is_pending(struct device *dev) +static int uart_sam0_irq_is_pending(const struct device *dev) { SercomUsart *const regs = DEV_CFG(dev)->regs; return (regs->INTENSET.reg & regs->INTFLAG.reg) != 0; } -static int uart_sam0_irq_update(struct device *dev) { return 1; } +static int uart_sam0_irq_update(const struct device *dev) { return 1; } -static void uart_sam0_irq_callback_set(struct device *dev, +static void uart_sam0_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -803,7 +804,8 @@ static void uart_sam0_irq_callback_set(struct device *dev, #ifdef CONFIG_UART_ASYNC_API -static int uart_sam0_callback_set(struct device *dev, uart_callback_t callback, +static int uart_sam0_callback_set(const struct device *dev, + uart_callback_t callback, void *user_data) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); @@ -814,7 +816,8 @@ static int uart_sam0_callback_set(struct device *dev, uart_callback_t callback, return 0; } -static int uart_sam0_tx(struct device *dev, const uint8_t *buf, size_t len, +static int uart_sam0_tx(const struct device *dev, const uint8_t *buf, + size_t len, int32_t timeout) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); @@ -859,7 +862,7 @@ static int uart_sam0_tx(struct device *dev, const uint8_t *buf, size_t len, return retval; } -static int uart_sam0_tx_abort(struct device *dev) +static int uart_sam0_tx_abort(const struct device *dev) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); const struct uart_sam0_dev_cfg *const cfg = DEV_CFG(dev); @@ -873,7 +876,8 @@ static int uart_sam0_tx_abort(struct device *dev) return uart_sam0_tx_halt(dev_data); } -static int uart_sam0_rx_enable(struct device *dev, uint8_t *buf, size_t len, +static int uart_sam0_rx_enable(const struct device *dev, uint8_t *buf, + size_t len, int32_t timeout) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); @@ -928,7 +932,8 @@ static int uart_sam0_rx_enable(struct device *dev, uint8_t *buf, size_t len, return retval; } -static int uart_sam0_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) +static int uart_sam0_rx_buf_rsp(const struct device *dev, uint8_t *buf, + size_t len) { if (len > 0xFFFFU) { return -EINVAL; @@ -959,7 +964,7 @@ static int uart_sam0_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) return retval; } -static int uart_sam0_rx_disable(struct device *dev) +static int uart_sam0_rx_disable(const struct device *dev) { struct uart_sam0_dev_data *const dev_data = DEV_DATA(dev); const struct uart_sam0_dev_cfg *const cfg = DEV_CFG(dev); @@ -1074,7 +1079,7 @@ static const struct uart_driver_api uart_sam0_driver_api = { #if DT_INST_IRQ_HAS_IDX(0, 3) #define UART_SAM0_IRQ_HANDLER(n) \ -static void uart_sam0_irq_config_##n(struct device *dev) \ +static void uart_sam0_irq_config_##n(const struct device *dev) \ { \ SAM0_UART_IRQ_CONNECT(n, 0); \ SAM0_UART_IRQ_CONNECT(n, 1); \ @@ -1083,7 +1088,7 @@ static void uart_sam0_irq_config_##n(struct device *dev) \ } #else #define UART_SAM0_IRQ_HANDLER(n) \ -static void uart_sam0_irq_config_##n(struct device *dev) \ +static void uart_sam0_irq_config_##n(const struct device *dev) \ { \ SAM0_UART_IRQ_CONNECT(n, 0); \ } diff --git a/drivers/serial/uart_sifive.c b/drivers/serial/uart_sifive.c index 6920009e768318..6738c90013668c 100644 --- a/drivers/serial/uart_sifive.c +++ b/drivers/serial/uart_sifive.c @@ -80,7 +80,7 @@ struct uart_sifive_data { * @param dev UART device struct * @param c Character to send */ -static void uart_sifive_poll_out(struct device *dev, +static void uart_sifive_poll_out(const struct device *dev, unsigned char c) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -100,7 +100,7 @@ static void uart_sifive_poll_out(struct device *dev, * * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_sifive_poll_in(struct device *dev, unsigned char *c) +static int uart_sifive_poll_in(const struct device *dev, unsigned char *c) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); uint32_t val = uart->rx; @@ -125,9 +125,9 @@ static int uart_sifive_poll_in(struct device *dev, unsigned char *c) * * @return Number of bytes sent */ -static int uart_sifive_fifo_fill(struct device *dev, - const uint8_t *tx_data, - int size) +static int uart_sifive_fifo_fill(const struct device *dev, + const uint8_t *tx_data, + int size) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); int i; @@ -147,9 +147,9 @@ static int uart_sifive_fifo_fill(struct device *dev, * * @return Number of bytes read */ -static int uart_sifive_fifo_read(struct device *dev, - uint8_t *rx_data, - const int size) +static int uart_sifive_fifo_read(const struct device *dev, + uint8_t *rx_data, + const int size) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); int i; @@ -174,7 +174,7 @@ static int uart_sifive_fifo_read(struct device *dev, * * @return N/A */ -static void uart_sifive_irq_tx_enable(struct device *dev) +static void uart_sifive_irq_tx_enable(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -188,7 +188,7 @@ static void uart_sifive_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_sifive_irq_tx_disable(struct device *dev) +static void uart_sifive_irq_tx_disable(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -202,7 +202,7 @@ static void uart_sifive_irq_tx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_sifive_irq_tx_ready(struct device *dev) +static int uart_sifive_irq_tx_ready(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -216,7 +216,7 @@ static int uart_sifive_irq_tx_ready(struct device *dev) * * @return 1 if nothing remains to be transmitted, 0 otherwise */ -static int uart_sifive_irq_tx_complete(struct device *dev) +static int uart_sifive_irq_tx_complete(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -234,7 +234,7 @@ static int uart_sifive_irq_tx_complete(struct device *dev) * * @return N/A */ -static void uart_sifive_irq_rx_enable(struct device *dev) +static void uart_sifive_irq_rx_enable(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -248,7 +248,7 @@ static void uart_sifive_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_sifive_irq_rx_disable(struct device *dev) +static void uart_sifive_irq_rx_disable(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -262,7 +262,7 @@ static void uart_sifive_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_sifive_irq_rx_ready(struct device *dev) +static int uart_sifive_irq_rx_ready(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); @@ -270,12 +270,12 @@ static int uart_sifive_irq_rx_ready(struct device *dev) } /* No error interrupt for this controller */ -static void uart_sifive_irq_err_enable(struct device *dev) +static void uart_sifive_irq_err_enable(const struct device *dev) { ARG_UNUSED(dev); } -static void uart_sifive_irq_err_disable(struct device *dev) +static void uart_sifive_irq_err_disable(const struct device *dev) { ARG_UNUSED(dev); } @@ -287,14 +287,14 @@ static void uart_sifive_irq_err_disable(struct device *dev) * * @return 1 if an IRQ is pending, 0 otherwise */ -static int uart_sifive_irq_is_pending(struct device *dev) +static int uart_sifive_irq_is_pending(const struct device *dev) { volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); return !!(uart->ip & (IE_RXWM | IE_TXWM)); } -static int uart_sifive_irq_update(struct device *dev) +static int uart_sifive_irq_update(const struct device *dev) { return 1; } @@ -307,9 +307,9 @@ static int uart_sifive_irq_update(struct device *dev) * * @return N/A */ -static void uart_sifive_irq_callback_set(struct device *dev, - uart_irq_callback_user_data_t cb, - void *cb_data) +static void uart_sifive_irq_callback_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *cb_data) { struct uart_sifive_data *data = DEV_DATA(dev); @@ -319,7 +319,7 @@ static void uart_sifive_irq_callback_set(struct device *dev, static void uart_sifive_irq_handler(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct uart_sifive_data *data = DEV_DATA(dev); if (data->callback) @@ -329,7 +329,7 @@ static void uart_sifive_irq_handler(void *arg) #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int uart_sifive_init(struct device *dev) +static int uart_sifive_init(const struct device *dev) { const struct uart_sifive_device_config * const cfg = DEV_CFG(dev); volatile struct uart_sifive_regs_t *uart = DEV_UART(dev); diff --git a/drivers/serial/uart_stellaris.c b/drivers/serial/uart_stellaris.c index 23a5e6cabeb85e..37b14b4ef1b124 100644 --- a/drivers/serial/uart_stellaris.c +++ b/drivers/serial/uart_stellaris.c @@ -159,7 +159,7 @@ static const struct uart_driver_api uart_stellaris_driver_api; * * @return N/A */ -static void baudrate_set(struct device *dev, +static void baudrate_set(const struct device *dev, uint32_t baudrate, uint32_t sys_clk_freq_hz) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -196,7 +196,7 @@ static void baudrate_set(struct device *dev, * * @return N/A */ -static inline void enable(struct device *dev) +static inline void enable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -212,7 +212,7 @@ static inline void enable(struct device *dev) * * @return N/A */ -static inline void disable(struct device *dev) +static inline void disable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -245,7 +245,7 @@ static inline void disable(struct device *dev) * * @return N/A */ -static inline void line_control_defaults_set(struct device *dev) +static inline void line_control_defaults_set(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -262,7 +262,7 @@ static inline void line_control_defaults_set(struct device *dev) * * @return 0 */ -static int uart_stellaris_init(struct device *dev) +static int uart_stellaris_init(const struct device *dev) { disable(dev); baudrate_set(dev, DEV_DATA(dev)->baud_rate, @@ -286,7 +286,7 @@ static int uart_stellaris_init(struct device *dev) * * @return 0 if ready to transmit, 1 otherwise */ -static int poll_tx_ready(struct device *dev) +static int poll_tx_ready(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -302,7 +302,7 @@ static int poll_tx_ready(struct device *dev) * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_stellaris_poll_in(struct device *dev, unsigned char *c) +static int uart_stellaris_poll_in(const struct device *dev, unsigned char *c) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -325,7 +325,7 @@ static int uart_stellaris_poll_in(struct device *dev, unsigned char *c) * @param dev UART device struct * @param c Character to send */ -static void uart_stellaris_poll_out(struct device *dev, +static void uart_stellaris_poll_out(const struct device *dev, unsigned char c) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -348,7 +348,8 @@ static void uart_stellaris_poll_out(struct device *dev, * * @return Number of bytes sent */ -static int uart_stellaris_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_stellaris_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -370,7 +371,8 @@ static int uart_stellaris_fifo_fill(struct device *dev, const uint8_t *tx_data, * * @return Number of bytes read */ -static int uart_stellaris_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_stellaris_fifo_read(const struct device *dev, + uint8_t *rx_data, const int size) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -390,7 +392,7 @@ static int uart_stellaris_fifo_read(struct device *dev, uint8_t *rx_data, * * @return N/A */ -static void uart_stellaris_irq_tx_enable(struct device *dev) +static void uart_stellaris_irq_tx_enable(const struct device *dev) { static uint8_t first_time = 1U; /* used to allow the first transmission */ @@ -444,7 +446,7 @@ static void uart_stellaris_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_tx_disable(struct device *dev) +static void uart_stellaris_irq_tx_disable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -458,7 +460,7 @@ static void uart_stellaris_irq_tx_disable(struct device *dev) * * @return 1 if a Tx IRQ is pending, 0 otherwise */ -static int uart_stellaris_irq_tx_ready(struct device *dev) +static int uart_stellaris_irq_tx_ready(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -472,7 +474,7 @@ static int uart_stellaris_irq_tx_ready(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_rx_enable(struct device *dev) +static void uart_stellaris_irq_rx_enable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -486,7 +488,7 @@ static void uart_stellaris_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_rx_disable(struct device *dev) +static void uart_stellaris_irq_rx_disable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -500,7 +502,7 @@ static void uart_stellaris_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_stellaris_irq_rx_ready(struct device *dev) +static int uart_stellaris_irq_rx_ready(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -514,7 +516,7 @@ static int uart_stellaris_irq_rx_ready(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_err_enable(struct device *dev) +static void uart_stellaris_irq_err_enable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -529,7 +531,7 @@ static void uart_stellaris_irq_err_enable(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_err_disable(struct device *dev) +static void uart_stellaris_irq_err_disable(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -544,7 +546,7 @@ static void uart_stellaris_irq_err_disable(struct device *dev) * * @return 1 if a Tx or Rx IRQ is pending, 0 otherwise */ -static int uart_stellaris_irq_is_pending(struct device *dev) +static int uart_stellaris_irq_is_pending(const struct device *dev) { volatile struct _uart *uart = UART_STRUCT(dev); @@ -559,7 +561,7 @@ static int uart_stellaris_irq_is_pending(struct device *dev) * * @return Always 1 */ -static int uart_stellaris_irq_update(struct device *dev) +static int uart_stellaris_irq_update(const struct device *dev) { return 1; } @@ -572,7 +574,7 @@ static int uart_stellaris_irq_update(struct device *dev) * * @return N/A */ -static void uart_stellaris_irq_callback_set(struct device *dev, +static void uart_stellaris_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -593,7 +595,7 @@ static void uart_stellaris_irq_callback_set(struct device *dev, */ static void uart_stellaris_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_stellaris_dev_data_t * const dev_data = DEV_DATA(dev); if (dev_data->cb) { @@ -631,7 +633,7 @@ static const struct uart_driver_api uart_stellaris_driver_api = { #ifdef CONFIG_UART_STELLARIS_PORT_0 #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_0(struct device *port); +static void irq_config_func_0(const struct device *port); #endif static const struct uart_device_config uart_stellaris_dev_cfg_0 = { @@ -654,7 +656,7 @@ DEVICE_AND_API_INIT(uart_stellaris0, DT_INST_LABEL(0), &uart_stellaris_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_0(struct device *dev) +static void irq_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), @@ -669,7 +671,7 @@ static void irq_config_func_0(struct device *dev) #ifdef CONFIG_UART_STELLARIS_PORT_1 #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_1(struct device *port); +static void irq_config_func_1(const struct device *port); #endif static struct uart_device_config uart_stellaris_dev_cfg_1 = { @@ -692,7 +694,7 @@ DEVICE_AND_API_INIT(uart_stellaris1, DT_INST_LABEL(1), &uart_stellaris_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_1(struct device *dev) +static void irq_config_func_1(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(1), DT_INST_IRQ(1, priority), @@ -707,7 +709,7 @@ static void irq_config_func_1(struct device *dev) #ifdef CONFIG_UART_STELLARIS_PORT_2 #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_2(struct device *port); +static void irq_config_func_2(const struct device *port); #endif static const struct uart_device_config uart_stellaris_dev_cfg_2 = { @@ -730,7 +732,7 @@ DEVICE_AND_API_INIT(uart_stellaris2, DT_INST_LABEL(2), &uart_stellaris_driver_api); #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void irq_config_func_2(struct device *dev) +static void irq_config_func_2(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(2), DT_INST_IRQ(2, priority), diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 3635b70984face..b50ccacd800900 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -42,7 +42,8 @@ LOG_MODULE_REGISTER(uart_stm32); #define TIMEOUT 1000 -static inline void uart_stm32_set_baudrate(struct device *dev, uint32_t baud_rate) +static inline void uart_stm32_set_baudrate(const struct device *dev, + uint32_t baud_rate) { const struct uart_stm32_config *config = DEV_CFG(dev); struct uart_stm32_data *data = DEV_DATA(dev); @@ -85,56 +86,60 @@ static inline void uart_stm32_set_baudrate(struct device *dev, uint32_t baud_rat #endif /* HAS_LPUART_1 */ } -static inline void uart_stm32_set_parity(struct device *dev, uint32_t parity) +static inline void uart_stm32_set_parity(const struct device *dev, + uint32_t parity) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_SetParity(UartInstance, parity); } -static inline uint32_t uart_stm32_get_parity(struct device *dev) +static inline uint32_t uart_stm32_get_parity(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_GetParity(UartInstance); } -static inline void uart_stm32_set_stopbits(struct device *dev, uint32_t stopbits) +static inline void uart_stm32_set_stopbits(const struct device *dev, + uint32_t stopbits) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_SetStopBitsLength(UartInstance, stopbits); } -static inline uint32_t uart_stm32_get_stopbits(struct device *dev) +static inline uint32_t uart_stm32_get_stopbits(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_GetStopBitsLength(UartInstance); } -static inline void uart_stm32_set_databits(struct device *dev, uint32_t databits) +static inline void uart_stm32_set_databits(const struct device *dev, + uint32_t databits) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_SetDataWidth(UartInstance, databits); } -static inline uint32_t uart_stm32_get_databits(struct device *dev) +static inline uint32_t uart_stm32_get_databits(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_GetDataWidth(UartInstance); } -static inline void uart_stm32_set_hwctrl(struct device *dev, uint32_t hwctrl) +static inline void uart_stm32_set_hwctrl(const struct device *dev, + uint32_t hwctrl) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_SetHWFlowCtrl(UartInstance, hwctrl); } -static inline uint32_t uart_stm32_get_hwctrl(struct device *dev) +static inline uint32_t uart_stm32_get_hwctrl(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -277,7 +282,7 @@ static inline enum uart_config_flow_control uart_stm32_ll2cfg_hwctrl(uint32_t fc return UART_CFG_FLOW_CTRL_NONE; } -static int uart_stm32_configure(struct device *dev, +static int uart_stm32_configure(const struct device *dev, const struct uart_config *cfg) { struct uart_stm32_data *data = DEV_DATA(dev); @@ -363,7 +368,8 @@ static int uart_stm32_configure(struct device *dev, return 0; }; -static int uart_stm32_config_get(struct device *dev, struct uart_config *cfg) +static int uart_stm32_config_get(const struct device *dev, + struct uart_config *cfg) { struct uart_stm32_data *data = DEV_DATA(dev); @@ -378,7 +384,7 @@ static int uart_stm32_config_get(struct device *dev, struct uart_config *cfg) return 0; } -static int uart_stm32_poll_in(struct device *dev, unsigned char *c) +static int uart_stm32_poll_in(const struct device *dev, unsigned char *c) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -396,7 +402,7 @@ static int uart_stm32_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_stm32_poll_out(struct device *dev, +static void uart_stm32_poll_out(const struct device *dev, unsigned char c) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -410,7 +416,7 @@ static void uart_stm32_poll_out(struct device *dev, LL_USART_TransmitData8(UartInstance, (uint8_t)c); } -static int uart_stm32_err_check(struct device *dev) +static int uart_stm32_err_check(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); uint32_t err = 0U; @@ -451,10 +457,10 @@ static int uart_stm32_err_check(struct device *dev) return err; } -static inline void __uart_stm32_get_clock(struct device *dev) +static inline void __uart_stm32_get_clock(const struct device *dev) { struct uart_stm32_data *data = DEV_DATA(dev); - struct device *clk = + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); __ASSERT_NO_MSG(clk); @@ -464,7 +470,8 @@ static inline void __uart_stm32_get_clock(struct device *dev) #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static int uart_stm32_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_stm32_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -481,7 +488,7 @@ static int uart_stm32_fifo_fill(struct device *dev, const uint8_t *tx_data, return num_tx; } -static int uart_stm32_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_stm32_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -503,56 +510,56 @@ static int uart_stm32_fifo_read(struct device *dev, uint8_t *rx_data, return num_rx; } -static void uart_stm32_irq_tx_enable(struct device *dev) +static void uart_stm32_irq_tx_enable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_EnableIT_TC(UartInstance); } -static void uart_stm32_irq_tx_disable(struct device *dev) +static void uart_stm32_irq_tx_disable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_DisableIT_TC(UartInstance); } -static int uart_stm32_irq_tx_ready(struct device *dev) +static int uart_stm32_irq_tx_ready(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_IsActiveFlag_TXE(UartInstance); } -static int uart_stm32_irq_tx_complete(struct device *dev) +static int uart_stm32_irq_tx_complete(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_IsActiveFlag_TC(UartInstance); } -static void uart_stm32_irq_rx_enable(struct device *dev) +static void uart_stm32_irq_rx_enable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_EnableIT_RXNE(UartInstance); } -static void uart_stm32_irq_rx_disable(struct device *dev) +static void uart_stm32_irq_rx_disable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); LL_USART_DisableIT_RXNE(UartInstance); } -static int uart_stm32_irq_rx_ready(struct device *dev) +static int uart_stm32_irq_rx_ready(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); return LL_USART_IsActiveFlag_RXNE(UartInstance); } -static void uart_stm32_irq_err_enable(struct device *dev) +static void uart_stm32_irq_err_enable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -568,7 +575,7 @@ static void uart_stm32_irq_err_enable(struct device *dev) LL_USART_EnableIT_PE(UartInstance); } -static void uart_stm32_irq_err_disable(struct device *dev) +static void uart_stm32_irq_err_disable(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -584,7 +591,7 @@ static void uart_stm32_irq_err_disable(struct device *dev) LL_USART_DisableIT_PE(UartInstance); } -static int uart_stm32_irq_is_pending(struct device *dev) +static int uart_stm32_irq_is_pending(const struct device *dev) { USART_TypeDef *UartInstance = UART_STRUCT(dev); @@ -594,12 +601,12 @@ static int uart_stm32_irq_is_pending(struct device *dev) LL_USART_IsEnabledIT_TC(UartInstance))); } -static int uart_stm32_irq_update(struct device *dev) +static int uart_stm32_irq_update(const struct device *dev) { return 1; } -static void uart_stm32_irq_callback_set(struct device *dev, +static void uart_stm32_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -611,7 +618,7 @@ static void uart_stm32_irq_callback_set(struct device *dev, static void uart_stm32_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct uart_stm32_data *data = DEV_DATA(dev); if (data->user_cb) { @@ -655,7 +662,7 @@ static const struct uart_driver_api uart_stm32_driver_api = { * * @return 0 */ -static int uart_stm32_init(struct device *dev) +static int uart_stm32_init(const struct device *dev) { const struct uart_stm32_config *config = DEV_CFG(dev); struct uart_stm32_data *data = DEV_DATA(dev); @@ -737,7 +744,7 @@ static int uart_stm32_init(struct device *dev) #define STM32_UART_IRQ_HANDLER_FUNC(index) \ .irq_config_func = uart_stm32_irq_config_func_##index, #define STM32_UART_IRQ_HANDLER(index) \ -static void uart_stm32_irq_config_func_##index(struct device *dev) \ +static void uart_stm32_irq_config_func_##index(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(index), \ DT_INST_IRQ(index, priority), \ diff --git a/drivers/serial/uart_stm32.h b/drivers/serial/uart_stm32.h index 7167070b12a116..865a423f09b406 100644 --- a/drivers/serial/uart_stm32.h +++ b/drivers/serial/uart_stm32.h @@ -28,7 +28,7 @@ struct uart_stm32_data { /* Baud rate */ uint32_t baud_rate; /* clock device */ - struct device *clock; + const struct device *clock; #ifdef CONFIG_UART_INTERRUPT_DRIVEN uart_irq_callback_user_data_t user_cb; void *user_data; diff --git a/drivers/serial/uart_xlnx_ps.c b/drivers/serial/uart_xlnx_ps.c index b709fa976b431c..29613a4bb1630a 100644 --- a/drivers/serial/uart_xlnx_ps.c +++ b/drivers/serial/uart_xlnx_ps.c @@ -222,7 +222,7 @@ static void xlnx_ps_enable_uart(uint32_t reg_base) * @param dev UART device struct * @param baud_rate The desired baud rate as a decimal value */ -static void set_baudrate(struct device *dev, uint32_t baud_rate) +static void set_baudrate(const struct device *dev, uint32_t baud_rate) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t divisor, generator; @@ -281,7 +281,7 @@ static void set_baudrate(struct device *dev, uint32_t baud_rate) * * @return 0 if successful, failed otherwise */ -static int uart_xlnx_ps_init(struct device *dev) +static int uart_xlnx_ps_init(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_val; @@ -335,7 +335,7 @@ static int uart_xlnx_ps_init(struct device *dev) * * @return 0 if a character arrived, -1 if the input buffer if empty. */ -static int uart_xlnx_ps_poll_in(struct device *dev, unsigned char *c) +static int uart_xlnx_ps_poll_in(const struct device *dev, unsigned char *c) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_val; @@ -366,7 +366,7 @@ static int uart_xlnx_ps_poll_in(struct device *dev, unsigned char *c) * * @return Sent character */ -static void uart_xlnx_ps_poll_out(struct device *dev, unsigned char c) +static void uart_xlnx_ps_poll_out(const struct device *dev, unsigned char c) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_val; @@ -595,8 +595,8 @@ static inline bool uart_xlnx_ps_cfg2ll_hwctrl( * @return 0 if the configuration completed successfully, ENOTSUP * error if an unsupported configuration parameter is detected. */ -static int uart_xlnx_ps_configure(struct device *dev, - const struct uart_config *cfg) +static int uart_xlnx_ps_configure(const struct device *dev, + const struct uart_config *cfg) { struct uart_xlnx_ps_dev_config *dev_cfg = (struct uart_xlnx_ps_dev_config *)DEV_CFG(dev); @@ -800,8 +800,8 @@ static inline enum uart_config_flow_control uart_xlnx_ps_ll2cfg_hwctrl( * * @return always 0. */ -static int uart_xlnx_ps_config_get(struct device *dev, - struct uart_config *cfg) +static int uart_xlnx_ps_config_get(const struct device *dev, + struct uart_config *cfg) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); @@ -836,7 +836,8 @@ static int uart_xlnx_ps_config_get(struct device *dev, * * @return Number of bytes sent */ -static int uart_xlnx_ps_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int uart_xlnx_ps_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); @@ -865,7 +866,7 @@ static int uart_xlnx_ps_fifo_fill(struct device *dev, const uint8_t *tx_data, * * @return Number of bytes read */ -static int uart_xlnx_ps_fifo_read(struct device *dev, uint8_t *rx_data, +static int uart_xlnx_ps_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); @@ -893,7 +894,7 @@ static int uart_xlnx_ps_fifo_read(struct device *dev, uint8_t *rx_data, * * @return N/A */ -static void uart_xlnx_ps_irq_tx_enable(struct device *dev) +static void uart_xlnx_ps_irq_tx_enable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -911,7 +912,7 @@ static void uart_xlnx_ps_irq_tx_enable(struct device *dev) * * @return N/A */ -static void uart_xlnx_ps_irq_tx_disable(struct device *dev) +static void uart_xlnx_ps_irq_tx_disable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -929,7 +930,7 @@ static void uart_xlnx_ps_irq_tx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_xlnx_ps_irq_tx_ready(struct device *dev) +static int uart_xlnx_ps_irq_tx_ready(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -954,7 +955,7 @@ static int uart_xlnx_ps_irq_tx_ready(struct device *dev) * * @return 1 if nothing remains to be transmitted, 0 otherwise */ -static int uart_xlnx_ps_irq_tx_complete(struct device *dev) +static int uart_xlnx_ps_irq_tx_complete(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -976,7 +977,7 @@ static int uart_xlnx_ps_irq_tx_complete(struct device *dev) * * @return N/A */ -static void uart_xlnx_ps_irq_rx_enable(struct device *dev) +static void uart_xlnx_ps_irq_rx_enable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -992,7 +993,7 @@ static void uart_xlnx_ps_irq_rx_enable(struct device *dev) * * @return N/A */ -static void uart_xlnx_ps_irq_rx_disable(struct device *dev) +static void uart_xlnx_ps_irq_rx_disable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -1008,7 +1009,7 @@ static void uart_xlnx_ps_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static int uart_xlnx_ps_irq_rx_ready(struct device *dev) +static int uart_xlnx_ps_irq_rx_ready(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -1031,7 +1032,7 @@ static int uart_xlnx_ps_irq_rx_ready(struct device *dev) * * @return N/A */ -static void uart_xlnx_ps_irq_err_enable(struct device *dev) +static void uart_xlnx_ps_irq_err_enable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -1053,7 +1054,7 @@ static void uart_xlnx_ps_irq_err_enable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise */ -static void uart_xlnx_ps_irq_err_disable(struct device *dev) +static void uart_xlnx_ps_irq_err_disable(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -1075,7 +1076,7 @@ static void uart_xlnx_ps_irq_err_disable(struct device *dev) * * @return 1 if an IRQ is pending, 0 otherwise */ -static int uart_xlnx_ps_irq_is_pending(struct device *dev) +static int uart_xlnx_ps_irq_is_pending(const struct device *dev) { const struct uart_xlnx_ps_dev_config *dev_cfg = DEV_CFG(dev); uint32_t reg_base; @@ -1100,7 +1101,7 @@ static int uart_xlnx_ps_irq_is_pending(struct device *dev) * * @return Always 1 */ -static int uart_xlnx_ps_irq_update(struct device *dev) +static int uart_xlnx_ps_irq_update(const struct device *dev) { (void)dev; return 1; @@ -1114,7 +1115,7 @@ static int uart_xlnx_ps_irq_update(struct device *dev) * * @return N/A */ -static void uart_xlnx_ps_irq_callback_set(struct device *dev, +static void uart_xlnx_ps_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -1135,7 +1136,7 @@ static void uart_xlnx_ps_irq_callback_set(struct device *dev, */ static void uart_xlnx_ps_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; const struct uart_xlnx_ps_dev_data_t *data = DEV_DATA(dev); if (data->user_cb) { diff --git a/drivers/serial/uart_xlnx_uartlite.c b/drivers/serial/uart_xlnx_uartlite.c index c1922dcadc3e58..1187c15189c6ad 100644 --- a/drivers/serial/uart_xlnx_uartlite.c +++ b/drivers/serial/uart_xlnx_uartlite.c @@ -40,14 +40,14 @@ struct xlnx_uartlite_config { mm_reg_t base; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; struct xlnx_uartlite_data { uint32_t errors; #ifdef CONFIG_UART_INTERRUPT_DRIVEN - struct device *dev; + const struct device *dev; struct k_timer timer; uart_irq_callback_user_data_t callback; void *callback_data; @@ -57,7 +57,7 @@ struct xlnx_uartlite_data { #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }; -static inline uint32_t xlnx_uartlite_read_status(struct device *dev) +static inline uint32_t xlnx_uartlite_read_status(const struct device *dev) { const struct xlnx_uartlite_config *config = dev->config; struct xlnx_uartlite_data *data = dev->data; @@ -71,7 +71,7 @@ static inline uint32_t xlnx_uartlite_read_status(struct device *dev) return status | data->errors; } -static inline void xlnx_uartlite_clear_status(struct device *dev) +static inline void xlnx_uartlite_clear_status(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; @@ -79,14 +79,14 @@ static inline void xlnx_uartlite_clear_status(struct device *dev) data->errors = 0; } -static inline unsigned char xlnx_uartlite_read_rx_fifo(struct device *dev) +static inline unsigned char xlnx_uartlite_read_rx_fifo(const struct device *dev) { const struct xlnx_uartlite_config *config = dev->config; return (sys_read32(config->base + RX_FIFO_OFFSET) & BIT_MASK(8)); } -static inline void xlnx_uartlite_write_tx_fifo(struct device *dev, +static inline void xlnx_uartlite_write_tx_fifo(const struct device *dev, unsigned char c) { const struct xlnx_uartlite_config *config = dev->config; @@ -94,7 +94,7 @@ static inline void xlnx_uartlite_write_tx_fifo(struct device *dev, sys_write32((uint32_t)c, config->base + TX_FIFO_OFFSET); } -static int xlnx_uartlite_poll_in(struct device *dev, unsigned char *c) +static int xlnx_uartlite_poll_in(const struct device *dev, unsigned char *c) { if (xlnx_uartlite_read_status(dev) & STAT_REG_RX_FIFO_VALID_DATA) { *c = xlnx_uartlite_read_rx_fifo(dev); @@ -104,7 +104,7 @@ static int xlnx_uartlite_poll_in(struct device *dev, unsigned char *c) return -1; } -static void xlnx_uartlite_poll_out(struct device *dev, unsigned char c) +static void xlnx_uartlite_poll_out(const struct device *dev, unsigned char c) { while (xlnx_uartlite_read_status(dev) & STAT_REG_TX_FIFO_FULL) { } @@ -112,7 +112,7 @@ static void xlnx_uartlite_poll_out(struct device *dev, unsigned char c) xlnx_uartlite_write_tx_fifo(dev, c); } -static int xlnx_uartlite_err_check(struct device *dev) +static int xlnx_uartlite_err_check(const struct device *dev) { uint32_t status = xlnx_uartlite_read_status(dev); int err = 0; @@ -135,14 +135,14 @@ static int xlnx_uartlite_err_check(struct device *dev) } #ifdef CONFIG_UART_INTERRUPT_DRIVEN -static inline void xlnx_uartlite_irq_enable(struct device *dev) +static inline void xlnx_uartlite_irq_enable(const struct device *dev) { const struct xlnx_uartlite_config *config = dev->config; sys_write32(CTRL_REG_ENABLE_INTR, config->base + CTRL_REG_OFFSET); } -static inline void xlnx_uartlite_irq_cond_disable(struct device *dev) +static inline void xlnx_uartlite_irq_cond_disable(const struct device *dev) { const struct xlnx_uartlite_config *config = dev->config; struct xlnx_uartlite_data *data = dev->data; @@ -153,7 +153,8 @@ static inline void xlnx_uartlite_irq_cond_disable(struct device *dev) } } -static int xlnx_uartlite_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int xlnx_uartlite_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int len) { uint32_t status = xlnx_uartlite_read_status(dev); @@ -167,7 +168,7 @@ static int xlnx_uartlite_fifo_fill(struct device *dev, const uint8_t *tx_data, return count; } -static int xlnx_uartlite_fifo_read(struct device *dev, uint8_t *rx_data, +static int xlnx_uartlite_fifo_read(const struct device *dev, uint8_t *rx_data, const int len) { uint32_t status = xlnx_uartlite_read_status(dev); @@ -191,7 +192,7 @@ static void xlnx_uartlite_tx_soft_isr(struct k_timer *timer) } } -static void xlnx_uartlite_irq_tx_enable(struct device *dev) +static void xlnx_uartlite_irq_tx_enable(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; uint32_t status; @@ -210,7 +211,7 @@ static void xlnx_uartlite_irq_tx_enable(struct device *dev) } } -static void xlnx_uartlite_irq_tx_disable(struct device *dev) +static void xlnx_uartlite_irq_tx_disable(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; @@ -218,7 +219,7 @@ static void xlnx_uartlite_irq_tx_disable(struct device *dev) xlnx_uartlite_irq_cond_disable(dev); } -static int xlnx_uartlite_irq_tx_ready(struct device *dev) +static int xlnx_uartlite_irq_tx_ready(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; uint32_t status = xlnx_uartlite_read_status(dev); @@ -227,14 +228,14 @@ static int xlnx_uartlite_irq_tx_ready(struct device *dev) data->tx_irq_enabled); } -static int xlnx_uartlite_irq_tx_complete(struct device *dev) +static int xlnx_uartlite_irq_tx_complete(const struct device *dev) { uint32_t status = xlnx_uartlite_read_status(dev); return (status & STAT_REG_TX_FIFO_EMPTY); } -static void xlnx_uartlite_irq_rx_enable(struct device *dev) +static void xlnx_uartlite_irq_rx_enable(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; @@ -243,7 +244,7 @@ static void xlnx_uartlite_irq_rx_enable(struct device *dev) xlnx_uartlite_irq_enable(dev); } -static void xlnx_uartlite_irq_rx_disable(struct device *dev) +static void xlnx_uartlite_irq_rx_disable(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; @@ -251,7 +252,7 @@ static void xlnx_uartlite_irq_rx_disable(struct device *dev) xlnx_uartlite_irq_cond_disable(dev); } -static int xlnx_uartlite_irq_rx_ready(struct device *dev) +static int xlnx_uartlite_irq_rx_ready(const struct device *dev) { struct xlnx_uartlite_data *data = dev->data; uint32_t status = xlnx_uartlite_read_status(dev); @@ -260,18 +261,18 @@ static int xlnx_uartlite_irq_rx_ready(struct device *dev) data->rx_irq_enabled); } -static int xlnx_uartlite_irq_is_pending(struct device *dev) +static int xlnx_uartlite_irq_is_pending(const struct device *dev) { return (xlnx_uartlite_irq_tx_ready(dev) || xlnx_uartlite_irq_rx_ready(dev)); } -static int xlnx_uartlite_irq_update(struct device *dev) +static int xlnx_uartlite_irq_update(const struct device *dev) { return 1; } -static void xlnx_uartlite_irq_callback_set(struct device *dev, +static void xlnx_uartlite_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data) { @@ -283,7 +284,7 @@ static void xlnx_uartlite_irq_callback_set(struct device *dev, static __unused void xlnx_uartlite_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct xlnx_uartlite_data *data = dev->data; if (data->callback) { @@ -293,7 +294,7 @@ static __unused void xlnx_uartlite_isr(void *arg) #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ -static int xlnx_uartlite_init(struct device *dev) +static int xlnx_uartlite_init(const struct device *dev) { const struct xlnx_uartlite_config *config = dev->config; #ifdef CONFIG_UART_INTERRUPT_DRIVEN diff --git a/drivers/serial/uart_xmc4xxx.c b/drivers/serial/uart_xmc4xxx.c index ca4535e87026e3..8844c85cc980e1 100644 --- a/drivers/serial/uart_xmc4xxx.c +++ b/drivers/serial/uart_xmc4xxx.c @@ -20,7 +20,7 @@ struct uart_xmc4xxx_data { #define DEV_DATA(dev) \ ((struct uart_xmc4xxx_data * const)(dev)->data) -static int uart_xmc4xxx_poll_in(struct device *dev, unsigned char *c) +static int uart_xmc4xxx_poll_in(const struct device *dev, unsigned char *c) { const struct uart_device_config *config = DEV_CFG(dev); @@ -30,14 +30,14 @@ static int uart_xmc4xxx_poll_in(struct device *dev, unsigned char *c) return 0; } -static void uart_xmc4xxx_poll_out(struct device *dev, unsigned char c) +static void uart_xmc4xxx_poll_out(const struct device *dev, unsigned char c) { const struct uart_device_config *config = DEV_CFG(dev); XMC_UART_CH_Transmit((XMC_USIC_CH_t *)config->base, (uint16_t)c); } -static int uart_xmc4xxx_init(struct device *dev) +static int uart_xmc4xxx_init(const struct device *dev) { const struct uart_device_config *config = DEV_CFG(dev); struct uart_xmc4xxx_data *data = DEV_DATA(dev); diff --git a/drivers/serial/usart_sam.c b/drivers/serial/usart_sam.c index 41941f95fa12b0..3ba00164a964a9 100644 --- a/drivers/serial/usart_sam.c +++ b/drivers/serial/usart_sam.c @@ -53,7 +53,7 @@ static int baudrate_set(Usart *const usart, uint32_t baudrate, uint32_t mck_freq_hz); -static int usart_sam_init(struct device *dev) +static int usart_sam_init(const struct device *dev) { int retval; const struct usart_sam_dev_cfg *const cfg = DEV_CFG(dev); @@ -98,7 +98,7 @@ static int usart_sam_init(struct device *dev) return 0; } -static int usart_sam_poll_in(struct device *dev, unsigned char *c) +static int usart_sam_poll_in(const struct device *dev, unsigned char *c) { Usart *const usart = DEV_CFG(dev)->regs; @@ -112,7 +112,7 @@ static int usart_sam_poll_in(struct device *dev, unsigned char *c) return 0; } -static void usart_sam_poll_out(struct device *dev, unsigned char c) +static void usart_sam_poll_out(const struct device *dev, unsigned char c) { Usart *const usart = DEV_CFG(dev)->regs; @@ -124,7 +124,7 @@ static void usart_sam_poll_out(struct device *dev, unsigned char c) usart->US_THR = (uint32_t)c; } -static int usart_sam_err_check(struct device *dev) +static int usart_sam_err_check(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; int errors = 0; @@ -167,7 +167,8 @@ static int baudrate_set(Usart *const usart, uint32_t baudrate, #if CONFIG_UART_INTERRUPT_DRIVEN -static int usart_sam_fifo_fill(struct device *dev, const uint8_t *tx_data, +static int usart_sam_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { volatile Usart * const usart = DEV_CFG(dev)->regs; @@ -181,7 +182,7 @@ static int usart_sam_fifo_fill(struct device *dev, const uint8_t *tx_data, return 1; } -static int usart_sam_fifo_read(struct device *dev, uint8_t *rx_data, +static int usart_sam_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { volatile Usart * const usart = DEV_CFG(dev)->regs; @@ -201,70 +202,70 @@ static int usart_sam_fifo_read(struct device *dev, uint8_t *rx_data, return bytes_read; } -static void usart_sam_irq_tx_enable(struct device *dev) +static void usart_sam_irq_tx_enable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IER = US_IER_TXRDY; } -static void usart_sam_irq_tx_disable(struct device *dev) +static void usart_sam_irq_tx_disable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IDR = US_IDR_TXRDY; } -static int usart_sam_irq_tx_ready(struct device *dev) +static int usart_sam_irq_tx_ready(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; return (usart->US_CSR & US_CSR_TXRDY); } -static void usart_sam_irq_rx_enable(struct device *dev) +static void usart_sam_irq_rx_enable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IER = US_IER_RXRDY; } -static void usart_sam_irq_rx_disable(struct device *dev) +static void usart_sam_irq_rx_disable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IDR = US_IDR_RXRDY; } -static int usart_sam_irq_tx_complete(struct device *dev) +static int usart_sam_irq_tx_complete(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; return !(usart->US_CSR & US_CSR_TXRDY); } -static int usart_sam_irq_rx_ready(struct device *dev) +static int usart_sam_irq_rx_ready(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; return (usart->US_CSR & US_CSR_RXRDY); } -static void usart_sam_irq_err_enable(struct device *dev) +static void usart_sam_irq_err_enable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IER = US_IER_OVRE | US_IER_FRAME | US_IER_PARE; } -static void usart_sam_irq_err_disable(struct device *dev) +static void usart_sam_irq_err_disable(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; usart->US_IDR = US_IDR_OVRE | US_IDR_FRAME | US_IDR_PARE; } -static int usart_sam_irq_is_pending(struct device *dev) +static int usart_sam_irq_is_pending(const struct device *dev) { volatile Usart * const usart = DEV_CFG(dev)->regs; @@ -272,14 +273,14 @@ static int usart_sam_irq_is_pending(struct device *dev) (usart->US_CSR & (US_CSR_TXRDY | US_CSR_RXRDY)); } -static int usart_sam_irq_update(struct device *dev) +static int usart_sam_irq_update(const struct device *dev) { ARG_UNUSED(dev); return 1; } -static void usart_sam_irq_callback_set(struct device *dev, +static void usart_sam_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -291,7 +292,7 @@ static void usart_sam_irq_callback_set(struct device *dev, static void usart_sam_isr(void *arg) { - struct device *dev = arg; + const struct device *dev = arg; struct usart_sam_dev_data *const dev_data = DEV_DATA(dev); if (dev_data->irq_cb) { @@ -336,7 +337,7 @@ static const struct uart_driver_api usart_sam_driver_api = { #ifdef CONFIG_UART_INTERRUPT_DRIVEN #define USART_SAM_CONFIG_FUNC(n) \ - static void usart##n##_sam_irq_config_func(struct device *port) \ + static void usart##n##_sam_irq_config_func(const struct device *port) \ { \ IRQ_CONNECT(DT_INST_IRQN(n), \ DT_INST_IRQ(n, priority), \ diff --git a/drivers/spi/spi_cc13xx_cc26xx.c b/drivers/spi/spi_cc13xx_cc26xx.c index 7185f099c5e0ce..6eef51acbf2b9c 100644 --- a/drivers/spi/spi_cc13xx_cc26xx.c +++ b/drivers/spi/spi_cc13xx_cc26xx.c @@ -39,18 +39,18 @@ struct spi_cc13xx_cc26xx_data { #define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) -static inline struct spi_cc13xx_cc26xx_data *get_dev_data(struct device *dev) +static inline struct spi_cc13xx_cc26xx_data *get_dev_data(const struct device *dev) { return dev->data; } static inline const struct spi_cc13xx_cc26xx_config * -get_dev_config(struct device *dev) +get_dev_config(const struct device *dev) { return dev->config; } -static int spi_cc13xx_cc26xx_configure(struct device *dev, +static int spi_cc13xx_cc26xx_configure(const struct device *dev, const struct spi_config *config) { const struct spi_cc13xx_cc26xx_config *cfg = get_dev_config(dev); @@ -136,7 +136,7 @@ static int spi_cc13xx_cc26xx_configure(struct device *dev, return 0; } -static int spi_cc13xx_cc26xx_transceive(struct device *dev, +static int spi_cc13xx_cc26xx_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -193,7 +193,7 @@ static int spi_cc13xx_cc26xx_transceive(struct device *dev, return err; } -static int spi_cc13xx_cc26xx_release(struct device *dev, +static int spi_cc13xx_cc26xx_release(const struct device *dev, const struct spi_config *config) { struct spi_context *ctx = &get_dev_data(dev)->ctx; @@ -212,8 +212,8 @@ static int spi_cc13xx_cc26xx_release(struct device *dev, } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int spi_cc13xx_cc26xx_set_power_state(struct device *dev, - uint32_t new_state) +static int spi_cc13xx_cc26xx_set_power_state(const struct device *dev, + uint32_t new_state) { int ret = 0; @@ -251,8 +251,10 @@ static int spi_cc13xx_cc26xx_set_power_state(struct device *dev, return ret; } -static int spi_cc13xx_cc26xx_pm_control(struct device *dev, uint32_t ctrl_command, - void *context, device_pm_cb cb, void *arg) +static int spi_cc13xx_cc26xx_pm_control(const struct device *dev, + uint32_t ctrl_command, + void *context, device_pm_cb cb, + void *arg) { int ret = 0; @@ -352,7 +354,7 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = { #endif #define SPI_CC13XX_CC26XX_INIT_FUNC(n) \ - static int spi_cc13xx_cc26xx_init_##n(struct device *dev) \ + static int spi_cc13xx_cc26xx_init_##n(const struct device *dev) \ { \ SPI_CC13XX_CC26XX_INIT_PM_STATE; \ \ diff --git a/drivers/spi/spi_dw.c b/drivers/spi/spi_dw.c index 174aa84f3128c2..50327b59e711f1 100644 --- a/drivers/spi/spi_dw.c +++ b/drivers/spi/spi_dw.c @@ -53,7 +53,7 @@ static inline bool spi_dw_is_slave(struct spi_dw_data *spi) spi_context_is_slave(&spi->ctx)); } -static void completed(struct device *dev, int error) +static void completed(const struct device *dev, int error) { const struct spi_dw_config *info = dev->config; struct spi_dw_data *spi = dev->data; @@ -85,7 +85,7 @@ static void completed(struct device *dev, int error) spi_context_complete(&spi->ctx, error); } -static void push_data(struct device *dev) +static void push_data(const struct device *dev) { const struct spi_dw_config *info = dev->config; struct spi_dw_data *spi = dev->data; @@ -154,7 +154,7 @@ static void push_data(struct device *dev) LOG_DBG("Pushed: %d", DBG_COUNTER_RESULT()); } -static void pull_data(struct device *dev) +static void pull_data(const struct device *dev) { const struct spi_dw_config *info = dev->config; struct spi_dw_data *spi = dev->data; @@ -329,7 +329,7 @@ static void spi_dw_update_txftlr(const struct spi_dw_config *info, write_txftlr(reg_data, info->regs); } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -440,8 +440,8 @@ static int transceive(struct device *dev, return ret; } -static int spi_dw_transceive(struct device *dev, - const struct spi_config *config, +static int spi_dw_transceive(const struct device *dev, + const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) { @@ -451,7 +451,7 @@ static int spi_dw_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_dw_transceive_async(struct device *dev, +static int spi_dw_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -463,7 +463,8 @@ static int spi_dw_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_dw_release(struct device *dev, const struct spi_config *config) +static int spi_dw_release(const struct device *dev, + const struct spi_config *config) { struct spi_dw_data *spi = dev->data; @@ -476,7 +477,7 @@ static int spi_dw_release(struct device *dev, const struct spi_config *config) return 0; } -void spi_dw_isr(struct device *dev) +void spi_dw_isr(const struct device *dev) { const struct spi_dw_config *info = dev->config; uint32_t int_status; @@ -515,7 +516,7 @@ static const struct spi_driver_api dw_spi_api = { .release = spi_dw_release, }; -int spi_dw_init(struct device *dev) +int spi_dw_init(const struct device *dev) { const struct spi_dw_config *info = dev->config; struct spi_dw_data *spi = dev->data; diff --git a/drivers/spi/spi_dw.h b/drivers/spi/spi_dw.h index a381502271feab..f11cf67e7379db 100644 --- a/drivers/spi/spi_dw.h +++ b/drivers/spi/spi_dw.h @@ -34,7 +34,7 @@ struct spi_dw_config { struct spi_dw_data { #ifdef CONFIG_CLOCK_CONTROL - struct device *clock; + const struct device *clock; #endif /* CONFIG_CLOCK_CONTROL */ struct spi_context ctx; uint8_t dfs; /* dfs in bytes: 1,2 or 4 */ @@ -229,7 +229,7 @@ DEFINE_TEST_BIT_OP(sr_busy, DW_SPI_REG_SR, DW_SPI_SR_BUSY_BIT) #ifdef CONFIG_CLOCK_CONTROL -static inline int clock_config(struct device *dev) +static inline int clock_config(const struct device *dev) { const struct spi_dw_config *info = dev->config; struct spi_dw_data *spi = dev->data; @@ -247,7 +247,7 @@ static inline int clock_config(struct device *dev) return 0; } -static inline void clock_on(struct device *dev) +static inline void clock_on(const struct device *dev) { struct spi_dw_data *spi = dev->data; @@ -260,7 +260,7 @@ static inline void clock_on(struct device *dev) extra_clock_on(dev); } -static inline void clock_off(struct device *dev) +static inline void clock_off(const struct device *dev) { struct spi_dw_data *spi = dev->data; diff --git a/drivers/spi/spi_gecko.c b/drivers/spi/spi_gecko.c index 7c27f65b3e8f79..e4874cffba5b88 100644 --- a/drivers/spi/spi_gecko.c +++ b/drivers/spi/spi_gecko.c @@ -50,7 +50,8 @@ struct spi_gecko_config { /* Helper Functions */ -static int spi_config(struct device *dev, const struct spi_config *config, +static int spi_config(const struct device *dev, + const struct spi_config *config, uint16_t *control) { const struct spi_gecko_config *gecko_config = dev->config; @@ -163,8 +164,8 @@ static int spi_gecko_shift_frames(USART_TypeDef *usart, } -static void spi_gecko_xfer(struct device *dev, - const struct spi_config *config) +static void spi_gecko_xfer(const struct device *dev, + const struct spi_config *config) { int ret; struct spi_context *ctx = &DEV_DATA(dev)->ctx; @@ -181,7 +182,7 @@ static void spi_gecko_xfer(struct device *dev, spi_context_complete(ctx, 0); } -static void spi_gecko_init_pins(struct device *dev) +static void spi_gecko_init_pins(const struct device *dev) { const struct spi_gecko_config *config = dev->config; @@ -206,7 +207,7 @@ static void spi_gecko_init_pins(struct device *dev) /* API Functions */ -static int spi_gecko_init(struct device *dev) +static int spi_gecko_init(const struct device *dev) { const struct spi_gecko_config *config = dev->config; USART_InitSync_TypeDef usartInit = USART_INITSYNC_DEFAULT; @@ -242,10 +243,10 @@ static int spi_gecko_init(struct device *dev) return 0; } -static int spi_gecko_transceive(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) +static int spi_gecko_transceive(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs) { uint16_t control = 0; @@ -256,17 +257,17 @@ static int spi_gecko_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_gecko_transceive_async(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs, - struct k_poll_signal *async) +static int spi_gecko_transceive_async(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs, + struct k_poll_signal *async) { return -ENOTSUP; } #endif /* CONFIG_SPI_ASYNC */ -static int spi_gecko_release(struct device *dev, +static int spi_gecko_release(const struct device *dev, const struct spi_config *config) { const struct spi_gecko_config *gecko_config = dev->config; diff --git a/drivers/spi/spi_handlers.c b/drivers/spi/spi_handlers.c index fa84146ab03bce..e44f02988dade5 100644 --- a/drivers/spi/spi_handlers.c +++ b/drivers/spi/spi_handlers.c @@ -52,10 +52,10 @@ static struct spi_buf_set *copy_and_check(struct spi_buf_set *bufs, * count member has been verified and is a value that won't lead to stack * overflow. */ -static uint32_t copy_bufs_and_transceive(struct device *dev, - const struct spi_config *config, - struct spi_buf_set *tx_bufs, - struct spi_buf_set *rx_bufs) +static uint32_t copy_bufs_and_transceive(const struct device *dev, + const struct spi_config *config, + struct spi_buf_set *tx_bufs, + struct spi_buf_set *rx_bufs) { struct spi_buf tx_buf_copy[tx_bufs->count ? tx_bufs->count : 1]; struct spi_buf rx_buf_copy[rx_bufs->count ? rx_bufs->count : 1]; @@ -63,14 +63,14 @@ static uint32_t copy_bufs_and_transceive(struct device *dev, tx_bufs = copy_and_check(tx_bufs, tx_buf_copy, 0); rx_bufs = copy_and_check(rx_bufs, rx_buf_copy, 1); - return z_impl_spi_transceive((struct device *)dev, config, - tx_bufs, rx_bufs); + return z_impl_spi_transceive((const struct device *)dev, config, + tx_bufs, rx_bufs); } -static inline int z_vrfy_spi_transceive(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) +static inline int z_vrfy_spi_transceive(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs) { struct spi_buf_set tx_bufs_copy; struct spi_buf_set rx_bufs_copy; @@ -113,18 +113,18 @@ static inline int z_vrfy_spi_transceive(struct device *dev, } } - return copy_bufs_and_transceive((struct device *)dev, + return copy_bufs_and_transceive((const struct device *)dev, &config_copy, &tx_bufs_copy, &rx_bufs_copy); } #include -static inline int z_vrfy_spi_release(struct device *dev, - const struct spi_config *config) +static inline int z_vrfy_spi_release(const struct device *dev, + const struct spi_config *config) { Z_OOPS(Z_SYSCALL_MEMORY_READ(config, sizeof(*config))); Z_OOPS(Z_SYSCALL_DRIVER_SPI(dev, release)); - return z_impl_spi_release((struct device *)dev, config); + return z_impl_spi_release((const struct device *)dev, config); } #include diff --git a/drivers/spi/spi_litespi.c b/drivers/spi/spi_litespi.c index d812a501a44d0a..28264bc9cf1322 100644 --- a/drivers/spi/spi_litespi.c +++ b/drivers/spi/spi_litespi.c @@ -74,7 +74,8 @@ static int spi_config(const struct spi_config *config, uint16_t *control) return 0; } -static void spi_litespi_send(struct device *dev, uint8_t frame, uint16_t control) +static void spi_litespi_send(const struct device *dev, uint8_t frame, + uint16_t control) { /* Write frame to register */ litex_write8(frame, SPI_MOSI_DATA_REG); @@ -91,8 +92,9 @@ static uint8_t spi_litespi_recv(void) return litex_read8(SPI_MISO_DATA_REG); } -static void spi_litespi_xfer(struct device *dev, - const struct spi_config *config, uint16_t control) +static void spi_litespi_xfer(const struct device *dev, + const struct spi_config *config, + uint16_t control) { struct spi_context *ctx = &SPI_DATA(dev)->ctx; uint32_t send_len = spi_context_longest_current_buf(ctx); @@ -118,15 +120,15 @@ static void spi_litespi_xfer(struct device *dev, /* API Functions */ -static int spi_litespi_init(struct device *dev) +static int spi_litespi_init(const struct device *dev) { return 0; } -static int spi_litespi_transceive(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) +static int spi_litespi_transceive(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs) { uint16_t control = 0; @@ -137,18 +139,18 @@ static int spi_litespi_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_litespi_transceive_async(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs, - struct k_poll_signal *async) +static int spi_litespi_transceive_async(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs, + struct k_poll_signal *async) { return -ENOTSUP; } #endif /* CONFIG_SPI_ASYNC */ -static int spi_litespi_release(struct device *dev, - const struct spi_config *config) +static int spi_litespi_release(const struct device *dev, + const struct spi_config *config) { if (!(litex_read8(SPI_STATUS_REG))) { return -EBUSY; diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 5f72d681dd7042..03334869ebeb9c 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -57,7 +57,7 @@ LOG_MODULE_REGISTER(spi_ll_stm32); uint32_t nop_tx; /* This function is executed in the interrupt context */ -static void dma_callback(struct device *dev, void *arg, +static void dma_callback(const struct device *dev, void *arg, uint32_t channel, int status) { /* arg directly holds the client data */ @@ -85,7 +85,7 @@ static void dma_callback(struct device *dev, void *arg, } } -static int spi_stm32_dma_tx_load(struct device *dev, const uint8_t *buf, +static int spi_stm32_dma_tx_load(const struct device *dev, const uint8_t *buf, size_t len) { const struct spi_stm32_config *cfg = DEV_CFG(dev); @@ -145,7 +145,8 @@ static int spi_stm32_dma_tx_load(struct device *dev, const uint8_t *buf, return dma_start(data->dev_dma_tx, data->dma_tx.channel); } -static int spi_stm32_dma_rx_load(struct device *dev, uint8_t *buf, size_t len) +static int spi_stm32_dma_rx_load(const struct device *dev, uint8_t *buf, + size_t len) { const struct spi_stm32_config *cfg = DEV_CFG(dev); struct spi_stm32_data *data = DEV_DATA(dev); @@ -196,7 +197,7 @@ static int spi_stm32_dma_rx_load(struct device *dev, uint8_t *buf, size_t len) return dma_start(data->dev_dma_rx, data->dma_rx.channel); } -static int spi_dma_move_buffers(struct device *dev) +static int spi_dma_move_buffers(const struct device *dev) { struct spi_stm32_data *data = DEV_DATA(dev); int ret; @@ -410,7 +411,7 @@ static void spi_stm32_complete(struct spi_stm32_data *data, SPI_TypeDef *spi, #ifdef CONFIG_SPI_STM32_INTERRUPT static void spi_stm32_isr(void *arg) { - struct device * const dev = (struct device *) arg; + const struct device *dev = (const struct device *) arg; const struct spi_stm32_config *cfg = dev->config; struct spi_stm32_data *data = dev->data; SPI_TypeDef *spi = cfg->spi; @@ -432,7 +433,7 @@ static void spi_stm32_isr(void *arg) } #endif -static int spi_stm32_configure(struct device *dev, +static int spi_stm32_configure(const struct device *dev, const struct spi_config *config) { const struct spi_stm32_config *cfg = DEV_CFG(dev); @@ -564,7 +565,7 @@ static int spi_stm32_configure(struct device *dev, return 0; } -static int spi_stm32_release(struct device *dev, +static int spi_stm32_release(const struct device *dev, const struct spi_config *config) { struct spi_stm32_data *data = DEV_DATA(dev); @@ -574,7 +575,7 @@ static int spi_stm32_release(struct device *dev, return 0; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -648,11 +649,11 @@ static int transceive(struct device *dev, } #ifdef CONFIG_SPI_STM32_DMA -static int transceive_dma(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs, - bool asynchronous, struct k_poll_signal *signal) +static int transceive_dma(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs, + bool asynchronous, struct k_poll_signal *signal) { const struct spi_stm32_config *cfg = DEV_CFG(dev); struct spi_stm32_data *data = DEV_DATA(dev); @@ -753,7 +754,7 @@ static int transceive_dma(struct device *dev, } #endif /* CONFIG_SPI_STM32_DMA */ -static int spi_stm32_transceive(struct device *dev, +static int spi_stm32_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -771,7 +772,7 @@ static int spi_stm32_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_stm32_transceive_async(struct device *dev, +static int spi_stm32_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -789,7 +790,7 @@ static const struct spi_driver_api api_funcs = { .release = spi_stm32_release, }; -static int spi_stm32_init(struct device *dev) +static int spi_stm32_init(const struct device *dev) { struct spi_stm32_data *data __attribute__((unused)) = dev->data; const struct spi_stm32_config *cfg = dev->config; @@ -835,7 +836,7 @@ static int spi_stm32_init(struct device *dev) #define STM32_SPI_IRQ_HANDLER_FUNC(id) \ .irq_config = spi_stm32_irq_config_func_##id, #define STM32_SPI_IRQ_HANDLER(id) \ -static void spi_stm32_irq_config_func_##id(struct device *dev) \ +static void spi_stm32_irq_config_func_##id(const struct device *dev) \ { \ IRQ_CONNECT(DT_INST_IRQN(id), \ DT_INST_IRQ(id, priority), \ diff --git a/drivers/spi/spi_ll_stm32.h b/drivers/spi/spi_ll_stm32.h index 0af17b4f1c007e..95607af6661bf3 100644 --- a/drivers/spi/spi_ll_stm32.h +++ b/drivers/spi/spi_ll_stm32.h @@ -9,7 +9,7 @@ #include "spi_context.h" -typedef void (*irq_config_func_t)(struct device *port); +typedef void (*irq_config_func_t)(const struct device *port); struct spi_stm32_config { struct stm32_pclken pclken; @@ -35,8 +35,8 @@ struct stream { struct spi_stm32_data { struct spi_context ctx; #ifdef CONFIG_SPI_STM32_DMA - struct device *dev_dma_tx; - struct device *dev_dma_rx; + const struct device *dev_dma_tx; + const struct device *dev_dma_rx; struct stream dma_rx; struct stream dma_tx; size_t dma_segment_len; diff --git a/drivers/spi/spi_mcux_dspi.c b/drivers/spi/spi_mcux_dspi.c index 4d76a69b7da4d7..236210d610a3b9 100644 --- a/drivers/spi/spi_mcux_dspi.c +++ b/drivers/spi/spi_mcux_dspi.c @@ -22,7 +22,7 @@ struct spi_mcux_config { SPI_Type *base; char *clock_name; clock_control_subsys_t clock_subsys; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t pcs_sck_delay; uint32_t sck_pcs_delay; uint32_t transfer_delay; @@ -34,7 +34,7 @@ struct spi_mcux_data { size_t transfer_len; }; -static int spi_mcux_transfer_next_packet(struct device *dev) +static int spi_mcux_transfer_next_packet(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; @@ -105,7 +105,7 @@ static int spi_mcux_transfer_next_packet(struct device *dev) static void spi_mcux_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; SPI_Type *base = config->base; @@ -116,7 +116,7 @@ static void spi_mcux_isr(void *arg) static void spi_mcux_master_transfer_callback(SPI_Type *base, dspi_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct spi_mcux_data *data = dev->data; spi_context_update_tx(&data->ctx, 1, data->transfer_len); @@ -125,14 +125,14 @@ static void spi_mcux_master_transfer_callback(SPI_Type *base, spi_mcux_transfer_next_packet(dev); } -static int spi_mcux_configure(struct device *dev, +static int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cfg) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; SPI_Type *base = config->base; dspi_master_config_t master_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; uint32_t word_size; @@ -204,7 +204,7 @@ static int spi_mcux_configure(struct device *dev, return 0; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -237,7 +237,7 @@ static int transceive(struct device *dev, return ret; } -static int spi_mcux_transceive(struct device *dev, +static int spi_mcux_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -246,7 +246,7 @@ static int spi_mcux_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_mcux_transceive_async(struct device *dev, +static int spi_mcux_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -256,8 +256,8 @@ static int spi_mcux_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_mcux_release(struct device *dev, - const struct spi_config *spi_cfg) +static int spi_mcux_release(const struct device *dev, + const struct spi_config *spi_cfg) { struct spi_mcux_data *data = dev->data; @@ -266,7 +266,7 @@ static int spi_mcux_release(struct device *dev, return 0; } -static int spi_mcux_init(struct device *dev) +static int spi_mcux_init(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; diff --git a/drivers/spi/spi_mcux_flexcomm.c b/drivers/spi/spi_mcux_flexcomm.c index e82ee9033d1b61..19de4b14d83e58 100644 --- a/drivers/spi/spi_mcux_flexcomm.c +++ b/drivers/spi/spi_mcux_flexcomm.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(spi_mcux_flexcomm, CONFIG_SPI_LOG_LEVEL); struct spi_mcux_config { SPI_Type *base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct spi_mcux_data { @@ -30,7 +30,7 @@ struct spi_mcux_data { size_t transfer_len; }; -static void spi_mcux_transfer_next_packet(struct device *dev) +static void spi_mcux_transfer_next_packet(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; @@ -94,7 +94,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev) static void spi_mcux_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; SPI_Type *base = config->base; @@ -105,7 +105,7 @@ static void spi_mcux_isr(void *arg) static void spi_mcux_transfer_callback(SPI_Type *base, spi_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct spi_mcux_data *data = dev->data; spi_context_update_tx(&data->ctx, 1, data->transfer_len); @@ -114,7 +114,7 @@ static void spi_mcux_transfer_callback(SPI_Type *base, spi_mcux_transfer_next_packet(dev); } -static int spi_mcux_configure(struct device *dev, +static int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cfg) { const struct spi_mcux_config *config = dev->config; @@ -220,7 +220,7 @@ static int spi_mcux_configure(struct device *dev, return 0; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -250,7 +250,7 @@ static int transceive(struct device *dev, return ret; } -static int spi_mcux_transceive(struct device *dev, +static int spi_mcux_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -259,7 +259,7 @@ static int spi_mcux_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_mcux_transceive_async(struct device *dev, +static int spi_mcux_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -269,8 +269,8 @@ static int spi_mcux_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_mcux_release(struct device *dev, - const struct spi_config *spi_cfg) +static int spi_mcux_release(const struct device *dev, + const struct spi_config *spi_cfg) { struct spi_mcux_data *data = dev->data; @@ -279,7 +279,7 @@ static int spi_mcux_release(struct device *dev, return 0; } -static int spi_mcux_init(struct device *dev) +static int spi_mcux_init(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; diff --git a/drivers/spi/spi_mcux_lpspi.c b/drivers/spi/spi_mcux_lpspi.c index 664696b93f8937..570df40e92c6c6 100644 --- a/drivers/spi/spi_mcux_lpspi.c +++ b/drivers/spi/spi_mcux_lpspi.c @@ -24,7 +24,7 @@ struct spi_mcux_config { LPSPI_Type *base; char *clock_name; clock_control_subsys_t clock_subsys; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint32_t pcs_sck_delay; uint32_t sck_pcs_delay; uint32_t transfer_delay; @@ -36,7 +36,7 @@ struct spi_mcux_data { size_t transfer_len; }; -static void spi_mcux_transfer_next_packet(struct device *dev) +static void spi_mcux_transfer_next_packet(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; @@ -105,7 +105,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev) static void spi_mcux_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; LPSPI_Type *base = config->base; @@ -116,7 +116,7 @@ static void spi_mcux_isr(void *arg) static void spi_mcux_master_transfer_callback(LPSPI_Type *base, lpspi_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct spi_mcux_data *data = dev->data; spi_context_update_tx(&data->ctx, 1, data->transfer_len); @@ -125,14 +125,14 @@ static void spi_mcux_master_transfer_callback(LPSPI_Type *base, spi_mcux_transfer_next_packet(dev); } -static int spi_mcux_configure(struct device *dev, +static int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cfg) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; LPSPI_Type *base = config->base; lpspi_master_config_t master_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; uint32_t word_size; @@ -203,7 +203,7 @@ static int spi_mcux_configure(struct device *dev, return 0; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -233,7 +233,7 @@ static int transceive(struct device *dev, return ret; } -static int spi_mcux_transceive(struct device *dev, +static int spi_mcux_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -242,7 +242,7 @@ static int spi_mcux_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_mcux_transceive_async(struct device *dev, +static int spi_mcux_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -252,8 +252,8 @@ static int spi_mcux_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_mcux_release(struct device *dev, - const struct spi_config *spi_cfg) +static int spi_mcux_release(const struct device *dev, + const struct spi_config *spi_cfg) { struct spi_mcux_data *data = dev->data; @@ -262,7 +262,7 @@ static int spi_mcux_release(struct device *dev, return 0; } -static int spi_mcux_init(struct device *dev) +static int spi_mcux_init(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; diff --git a/drivers/spi/spi_nrfx_spi.c b/drivers/spi/spi_nrfx_spi.c index 835e82cf40e475..4711a537049743 100644 --- a/drivers/spi/spi_nrfx_spi.c +++ b/drivers/spi/spi_nrfx_spi.c @@ -28,12 +28,12 @@ struct spi_nrfx_config { nrfx_spi_config_t config; }; -static inline struct spi_nrfx_data *get_dev_data(struct device *dev) +static inline struct spi_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct spi_nrfx_config *get_dev_config(struct device *dev) +static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev) { return dev->config; } @@ -85,7 +85,7 @@ static inline nrf_spi_bit_order_t get_nrf_spi_bit_order(uint16_t operation) } } -static int configure(struct device *dev, +static int configure(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_context *ctx = &get_dev_data(dev)->ctx; @@ -135,7 +135,7 @@ static int configure(struct device *dev, return 0; } -static void transfer_next_chunk(struct device *dev) +static void transfer_next_chunk(const struct device *dev) { struct spi_nrfx_data *dev_data = get_dev_data(dev); struct spi_context *ctx = &dev_data->ctx; @@ -169,7 +169,7 @@ static void transfer_next_chunk(struct device *dev) dev_data->busy = false; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -198,7 +198,7 @@ static int transceive(struct device *dev, return error; } -static int spi_nrfx_transceive(struct device *dev, +static int spi_nrfx_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -207,7 +207,7 @@ static int spi_nrfx_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_nrfx_transceive_async(struct device *dev, +static int spi_nrfx_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -217,7 +217,7 @@ static int spi_nrfx_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_nrfx_release(struct device *dev, +static int spi_nrfx_release(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_nrfx_data *dev_data = get_dev_data(dev); @@ -246,7 +246,7 @@ static const struct spi_driver_api spi_nrfx_driver_api = { static void event_handler(const nrfx_spi_evt_t *p_event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; struct spi_nrfx_data *dev_data = get_dev_data(dev); if (p_event->type == NRFX_SPI_EVENT_DONE) { @@ -257,7 +257,7 @@ static void event_handler(const nrfx_spi_evt_t *p_event, void *p_context) } } -static int init_spi(struct device *dev) +static int init_spi(const struct device *dev) { /* This sets only default values of frequency, mode and bit order. * The proper ones are set in configure() when a transfer is started. @@ -281,7 +281,8 @@ static int init_spi(struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int spi_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int spi_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/spi/spi_nrfx_spim.c b/drivers/spi/spi_nrfx_spim.c index 15e88605a6f347..b69dc261d2d23f 100644 --- a/drivers/spi/spi_nrfx_spim.c +++ b/drivers/spi/spi_nrfx_spim.c @@ -33,12 +33,12 @@ struct spi_nrfx_config { nrfx_spim_config_t config; }; -static inline struct spi_nrfx_data *get_dev_data(struct device *dev) +static inline struct spi_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct spi_nrfx_config *get_dev_config(struct device *dev) +static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev) { return dev->config; } @@ -102,7 +102,7 @@ static inline nrf_spim_bit_order_t get_nrf_spim_bit_order(uint16_t operation) } } -static int configure(struct device *dev, +static int configure(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_context *ctx = &get_dev_data(dev)->ctx; @@ -152,7 +152,7 @@ static int configure(struct device *dev, return 0; } -static void transfer_next_chunk(struct device *dev) +static void transfer_next_chunk(const struct device *dev) { struct spi_nrfx_data *dev_data = get_dev_data(dev); const struct spi_nrfx_config *dev_config = get_dev_config(dev); @@ -211,7 +211,7 @@ static void transfer_next_chunk(struct device *dev) dev_data->busy = false; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -240,7 +240,7 @@ static int transceive(struct device *dev, return error; } -static int spi_nrfx_transceive(struct device *dev, +static int spi_nrfx_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -249,7 +249,7 @@ static int spi_nrfx_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_nrfx_transceive_async(struct device *dev, +static int spi_nrfx_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -259,7 +259,7 @@ static int spi_nrfx_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_nrfx_release(struct device *dev, +static int spi_nrfx_release(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_nrfx_data *dev_data = get_dev_data(dev); @@ -288,7 +288,7 @@ static const struct spi_driver_api spi_nrfx_driver_api = { static void event_handler(const nrfx_spim_evt_t *p_event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; struct spi_nrfx_data *dev_data = get_dev_data(dev); if (p_event->type == NRFX_SPIM_EVENT_DONE) { @@ -299,7 +299,7 @@ static void event_handler(const nrfx_spim_evt_t *p_event, void *p_context) } } -static int init_spim(struct device *dev) +static int init_spim(const struct device *dev) { /* This sets only default values of frequency, mode and bit order. * The proper ones are set in configure() when a transfer is started. @@ -323,7 +323,8 @@ static int init_spim(struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int spim_nrfx_pm_control(struct device *dev, uint32_t ctrl_command, +static int spim_nrfx_pm_control(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/spi/spi_nrfx_spis.c b/drivers/spi/spi_nrfx_spis.c index ac9e16f2587e37..9730b756d0f03f 100644 --- a/drivers/spi/spi_nrfx_spis.c +++ b/drivers/spi/spi_nrfx_spis.c @@ -23,12 +23,12 @@ struct spi_nrfx_config { size_t max_buf_len; }; -static inline struct spi_nrfx_data *get_dev_data(struct device *dev) +static inline struct spi_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct spi_nrfx_config *get_dev_config(struct device *dev) +static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev) { return dev->config; } @@ -59,7 +59,7 @@ static inline nrf_spis_bit_order_t get_nrf_spis_bit_order(uint16_t operation) } } -static int configure(struct device *dev, +static int configure(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_context *ctx = &get_dev_data(dev)->ctx; @@ -105,7 +105,7 @@ static int configure(struct device *dev, return 0; } -static void prepare_for_transfer(struct device *dev) +static void prepare_for_transfer(const struct device *dev) { struct spi_nrfx_data *dev_data = get_dev_data(dev); const struct spi_nrfx_config *dev_config = get_dev_config(dev); @@ -141,7 +141,7 @@ static void prepare_for_transfer(struct device *dev) spi_context_complete(ctx, status); } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -177,7 +177,7 @@ static int transceive(struct device *dev, return error; } -static int spi_nrfx_transceive(struct device *dev, +static int spi_nrfx_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -186,7 +186,7 @@ static int spi_nrfx_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_nrfx_transceive_async(struct device *dev, +static int spi_nrfx_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -196,7 +196,7 @@ static int spi_nrfx_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_nrfx_release(struct device *dev, +static int spi_nrfx_release(const struct device *dev, const struct spi_config *spi_cfg) { struct spi_nrfx_data *dev_data = get_dev_data(dev); @@ -221,7 +221,7 @@ static const struct spi_driver_api spi_nrfx_driver_api = { static void event_handler(const nrfx_spis_evt_t *p_event, void *p_context) { - struct device *dev = p_context; + const struct device *dev = p_context; struct spi_nrfx_data *dev_data = get_dev_data(dev); if (p_event->evt_type == NRFX_SPIS_XFER_DONE) { @@ -229,7 +229,8 @@ static void event_handler(const nrfx_spis_evt_t *p_event, void *p_context) } } -static int init_spis(struct device *dev, const nrfx_spis_config_t *config) +static int init_spis(const struct device *dev, + const nrfx_spis_config_t *config) { /* This sets only default values of frequency, mode and bit order. * The proper ones are set in configure() when a transfer is started. diff --git a/drivers/spi/spi_oc_simple.c b/drivers/spi/spi_oc_simple.c index 1e81ec1bf66b5a..eb44c5cd9387f9 100644 --- a/drivers/spi/spi_oc_simple.c +++ b/drivers/spi/spi_oc_simple.c @@ -85,10 +85,10 @@ static int spi_oc_simple_configure(const struct spi_oc_simple_cfg *info, return 0; } -int spi_oc_simple_transceive(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) +int spi_oc_simple_transceive(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs) { const struct spi_oc_simple_cfg *info = dev->config; struct spi_oc_simple_data *spi = SPI_OC_SIMPLE_DATA(dev); @@ -158,17 +158,18 @@ int spi_oc_simple_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_oc_simple_transceive_async(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs, - struct k_poll_signal *async) +static int spi_oc_simple_transceive_async(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs, + struct k_poll_signal *async) { return -ENOTSUP; } #endif /* CONFIG_SPI_ASYNC */ -int spi_oc_simple_release(struct device *dev, const struct spi_config *config) +int spi_oc_simple_release(const struct device *dev, + const struct spi_config *config) { spi_context_unlock_unconditionally(&SPI_OC_SIMPLE_DATA(dev)->ctx); return 0; @@ -182,7 +183,7 @@ static struct spi_driver_api spi_oc_simple_api = { #endif /* CONFIG_SPI_ASYNC */ }; -int spi_oc_simple_init(struct device *dev) +int spi_oc_simple_init(const struct device *dev) { const struct spi_oc_simple_cfg *info = dev->config; diff --git a/drivers/spi/spi_rv32m1_lpspi.c b/drivers/spi/spi_rv32m1_lpspi.c index 681e56e6405ca8..bd92b27e157c04 100644 --- a/drivers/spi/spi_rv32m1_lpspi.c +++ b/drivers/spi/spi_rv32m1_lpspi.c @@ -28,7 +28,7 @@ struct spi_mcux_config { clock_control_subsys_t clock_subsys; clock_ip_name_t clock_ip_name; uint32_t clock_ip_src; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct spi_mcux_data { @@ -37,7 +37,7 @@ struct spi_mcux_data { size_t transfer_len; }; -static void spi_mcux_transfer_next_packet(struct device *dev) +static void spi_mcux_transfer_next_packet(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; @@ -105,7 +105,7 @@ static void spi_mcux_transfer_next_packet(struct device *dev) static void spi_mcux_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; LPSPI_Type *base = config->base; @@ -116,7 +116,7 @@ static void spi_mcux_isr(void *arg) static void spi_mcux_master_transfer_callback(LPSPI_Type *base, lpspi_master_handle_t *handle, status_t status, void *userData) { - struct device *dev = userData; + const struct device *dev = userData; struct spi_mcux_data *data = dev->data; spi_context_update_tx(&data->ctx, 1, data->transfer_len); @@ -125,14 +125,14 @@ static void spi_mcux_master_transfer_callback(LPSPI_Type *base, spi_mcux_transfer_next_packet(dev); } -static int spi_mcux_configure(struct device *dev, +static int spi_mcux_configure(const struct device *dev, const struct spi_config *spi_cfg) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; LPSPI_Type *base = config->base; lpspi_master_config_t master_config; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; uint32_t word_size; @@ -199,7 +199,7 @@ static int spi_mcux_configure(struct device *dev, return 0; } -static int transceive(struct device *dev, +static int transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -229,7 +229,7 @@ static int transceive(struct device *dev, return ret; } -static int spi_mcux_transceive(struct device *dev, +static int spi_mcux_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -238,7 +238,7 @@ static int spi_mcux_transceive(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_mcux_transceive_async(struct device *dev, +static int spi_mcux_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -248,8 +248,8 @@ static int spi_mcux_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_mcux_release(struct device *dev, - const struct spi_config *spi_cfg) +static int spi_mcux_release(const struct device *dev, + const struct spi_config *spi_cfg) { struct spi_mcux_data *data = dev->data; @@ -258,7 +258,7 @@ static int spi_mcux_release(struct device *dev, return 0; } -static int spi_mcux_init(struct device *dev) +static int spi_mcux_init(const struct device *dev) { const struct spi_mcux_config *config = dev->config; struct spi_mcux_data *data = dev->data; diff --git a/drivers/spi/spi_sam.c b/drivers/spi/spi_sam.c index 54f0f0e3c9e614..5821a074974346 100644 --- a/drivers/spi/spi_sam.c +++ b/drivers/spi/spi_sam.c @@ -48,7 +48,7 @@ static int spi_slave_to_mr_pcs(int slave) return pcs[slave]; } -static int spi_sam_configure(struct device *dev, +static int spi_sam_configure(const struct device *dev, const struct spi_config *config) { const struct spi_sam_config *cfg = dev->config; @@ -267,7 +267,7 @@ static void spi_sam_fast_txrx(Spi *regs, } /* Fast path where every overlapping tx and rx buffer is the same length */ -static void spi_sam_fast_transceive(struct device *dev, +static void spi_sam_fast_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -356,7 +356,7 @@ static bool spi_sam_is_regular(const struct spi_buf_set *tx_bufs, return true; } -static int spi_sam_transceive(struct device *dev, +static int spi_sam_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -397,7 +397,7 @@ static int spi_sam_transceive(struct device *dev, return err; } -static int spi_sam_transceive_sync(struct device *dev, +static int spi_sam_transceive_sync(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -406,7 +406,7 @@ static int spi_sam_transceive_sync(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int spi_sam_transceive_async(struct device *dev, +static int spi_sam_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -417,7 +417,7 @@ static int spi_sam_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_sam_release(struct device *dev, +static int spi_sam_release(const struct device *dev, const struct spi_config *config) { struct spi_sam_data *data = dev->data; @@ -427,7 +427,7 @@ static int spi_sam_release(struct device *dev, return 0; } -static int spi_sam_init(struct device *dev) +static int spi_sam_init(const struct device *dev) { const struct spi_sam_config *cfg = dev->config; struct spi_sam_data *data = dev->data; diff --git a/drivers/spi/spi_sam0.c b/drivers/spi/spi_sam0.c index 71cb903c600d2e..7be16c4b19298c 100644 --- a/drivers/spi/spi_sam0.c +++ b/drivers/spi/spi_sam0.c @@ -45,7 +45,7 @@ struct spi_sam0_config { struct spi_sam0_data { struct spi_context ctx; #ifdef CONFIG_SPI_ASYNC - struct device *dma; + const struct device *dma; uint32_t dma_segment_len; #endif }; @@ -65,7 +65,7 @@ static void wait_synchronization(SercomSpi *regs) #endif } -static int spi_sam0_configure(struct device *dev, +static int spi_sam0_configure(const struct device *dev, const struct spi_config *config) { const struct spi_sam0_config *cfg = dev->config; @@ -298,7 +298,7 @@ static void spi_sam0_fast_txrx(SercomSpi *regs, } /* Fast path where every overlapping tx and rx buffer is the same length */ -static void spi_sam0_fast_transceive(struct device *dev, +static void spi_sam0_fast_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -385,7 +385,7 @@ static bool spi_sam0_is_regular(const struct spi_buf_set *tx_bufs, return true; } -static int spi_sam0_transceive(struct device *dev, +static int spi_sam0_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -426,7 +426,7 @@ static int spi_sam0_transceive(struct device *dev, return err; } -static int spi_sam0_transceive_sync(struct device *dev, +static int spi_sam0_transceive_sync(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -436,10 +436,10 @@ static int spi_sam0_transceive_sync(struct device *dev, #ifdef CONFIG_SPI_ASYNC -static void spi_sam0_dma_rx_done(struct device *dma_dev, void *arg, +static void spi_sam0_dma_rx_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code); -static int spi_sam0_dma_rx_load(struct device *dev, uint8_t *buf, +static int spi_sam0_dma_rx_load(const struct device *dev, uint8_t *buf, size_t len) { const struct spi_sam0_config *cfg = dev->config; @@ -481,7 +481,7 @@ static int spi_sam0_dma_rx_load(struct device *dev, uint8_t *buf, return dma_start(data->dma, cfg->rx_dma_channel); } -static int spi_sam0_dma_tx_load(struct device *dev, const uint8_t *buf, +static int spi_sam0_dma_tx_load(const struct device *dev, const uint8_t *buf, size_t len) { const struct spi_sam0_config *cfg = dev->config; @@ -522,7 +522,7 @@ static int spi_sam0_dma_tx_load(struct device *dev, const uint8_t *buf, return dma_start(data->dma, cfg->tx_dma_channel); } -static bool spi_sam0_dma_advance_segment(struct device *dev) +static bool spi_sam0_dma_advance_segment(const struct device *dev) { struct spi_sam0_data *data = dev->data; uint32_t segment_len; @@ -547,7 +547,7 @@ static bool spi_sam0_dma_advance_segment(struct device *dev) return true; } -static int spi_sam0_dma_advance_buffers(struct device *dev) +static int spi_sam0_dma_advance_buffers(const struct device *dev) { struct spi_sam0_data *data = dev->data; int retval; @@ -583,10 +583,10 @@ static int spi_sam0_dma_advance_buffers(struct device *dev) return 0; } -static void spi_sam0_dma_rx_done(struct device *dma_dev, void *arg, +static void spi_sam0_dma_rx_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { - struct device *dev = arg; + const struct device *dev = arg; const struct spi_sam0_config *cfg = dev->config; struct spi_sam0_data *data = dev->data; int retval; @@ -615,7 +615,7 @@ static void spi_sam0_dma_rx_done(struct device *dma_dev, void *arg, } -static int spi_sam0_transceive_async(struct device *dev, +static int spi_sam0_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -668,7 +668,7 @@ static int spi_sam0_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int spi_sam0_release(struct device *dev, +static int spi_sam0_release(const struct device *dev, const struct spi_config *config) { struct spi_sam0_data *data = dev->data; @@ -678,7 +678,7 @@ static int spi_sam0_release(struct device *dev, return 0; } -static int spi_sam0_init(struct device *dev) +static int spi_sam0_init(const struct device *dev) { const struct spi_sam0_config *cfg = dev->config; struct spi_sam0_data *data = dev->data; diff --git a/drivers/spi/spi_sifive.c b/drivers/spi/spi_sifive.c index dab46f469c90cc..43d5c3ba942394 100644 --- a/drivers/spi/spi_sifive.c +++ b/drivers/spi/spi_sifive.c @@ -26,7 +26,8 @@ static inline void sys_set_mask(mem_addr_t addr, uint32_t mask, uint32_t value) sys_write32(temp, addr); } -int spi_config(struct device *dev, uint32_t frequency, uint16_t operation) +int spi_config(const struct device *dev, uint32_t frequency, + uint16_t operation) { uint32_t div; uint32_t fmt_len; @@ -93,7 +94,7 @@ int spi_config(struct device *dev, uint32_t frequency, uint16_t operation) return 0; } -void spi_sifive_send(struct device *dev, uint16_t frame) +void spi_sifive_send(const struct device *dev, uint16_t frame) { while (sys_read32(SPI_REG(dev, REG_TXDATA)) & SF_TXDATA_FULL) { } @@ -101,7 +102,7 @@ void spi_sifive_send(struct device *dev, uint16_t frame) sys_write32((uint32_t) frame, SPI_REG(dev, REG_TXDATA)); } -uint16_t spi_sifive_recv(struct device *dev) +uint16_t spi_sifive_recv(const struct device *dev) { uint32_t val; @@ -111,7 +112,7 @@ uint16_t spi_sifive_recv(struct device *dev) return (uint16_t) val; } -void spi_sifive_xfer(struct device *dev, const bool hw_cs_control) +void spi_sifive_xfer(const struct device *dev, const bool hw_cs_control) { struct spi_context *ctx = &SPI_DATA(dev)->ctx; @@ -148,7 +149,7 @@ void spi_sifive_xfer(struct device *dev, const bool hw_cs_control) /* API Functions */ -int spi_sifive_init(struct device *dev) +int spi_sifive_init(const struct device *dev) { /* Disable SPI Flash mode */ sys_clear_bit(SPI_REG(dev, REG_FCTRL), SF_FCTRL_EN); @@ -158,7 +159,7 @@ int spi_sifive_init(struct device *dev) return 0; } -int spi_sifive_transceive(struct device *dev, +int spi_sifive_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -224,7 +225,8 @@ int spi_sifive_transceive(struct device *dev, return rc; } -int spi_sifive_release(struct device *dev, const struct spi_config *config) +int spi_sifive_release(const struct device *dev, + const struct spi_config *config) { spi_context_unlock_unconditionally(&SPI_DATA(dev)->ctx); return 0; diff --git a/drivers/spi/spi_xec_qmspi.c b/drivers/spi/spi_xec_qmspi.c index 3b9eacd8bc0c0e..54fcad435cf03f 100644 --- a/drivers/spi/spi_xec_qmspi.c +++ b/drivers/spi/spi_xec_qmspi.c @@ -165,7 +165,7 @@ static uint32_t qmspi_config_get_lines(const struct spi_config *config) * Configure QMSPI. * NOTE: QMSPI can control two chip selects. At this time we use CS0# only. */ -static int qmspi_configure(struct device *dev, +static int qmspi_configure(const struct device *dev, const struct spi_config *config) { const struct spi_qmspi_config *cfg = dev->config; @@ -503,7 +503,7 @@ static int qmspi_rx(QMSPI_Type *regs, const struct spi_buf *rx_buf, return 0; } -static int qmspi_transceive(struct device *dev, +static int qmspi_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -570,7 +570,7 @@ static int qmspi_transceive(struct device *dev, return err; } -static int qmspi_transceive_sync(struct device *dev, +static int qmspi_transceive_sync(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -579,7 +579,7 @@ static int qmspi_transceive_sync(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int qmspi_transceive_async(struct device *dev, +static int qmspi_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -589,7 +589,7 @@ static int qmspi_transceive_async(struct device *dev, } #endif -static int qmspi_release(struct device *dev, +static int qmspi_release(const struct device *dev, const struct spi_config *config) { struct spi_qmspi_data *data = dev->data; @@ -614,7 +614,7 @@ static int qmspi_release(struct device *dev, * Initialize SPI context. * QMSPI will be configured and enabled when the transceive API is called. */ -static int qmspi_init(struct device *dev) +static int qmspi_init(const struct device *dev) { const struct spi_qmspi_config *cfg = dev->config; struct spi_qmspi_data *data = dev->data; diff --git a/drivers/spi/spi_xlnx_axi_quadspi.c b/drivers/spi/spi_xlnx_axi_quadspi.c index efabff7bcf4bb2..a328c8d8dea12b 100644 --- a/drivers/spi/spi_xlnx_axi_quadspi.c +++ b/drivers/spi/spi_xlnx_axi_quadspi.c @@ -82,7 +82,7 @@ LOG_MODULE_REGISTER(xlnx_quadspi, CONFIG_SPI_LOG_LEVEL); struct xlnx_quadspi_config { mm_reg_t base; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); uint8_t num_ss_bits; uint8_t num_xfer_bytes; }; @@ -91,14 +91,16 @@ struct xlnx_quadspi_data { struct spi_context ctx; }; -static inline uint32_t xlnx_quadspi_read32(struct device *dev, mm_reg_t offset) +static inline uint32_t xlnx_quadspi_read32(const struct device *dev, + mm_reg_t offset) { const struct xlnx_quadspi_config *config = dev->config; return sys_read32(config->base + offset); } -static inline void xlnx_quadspi_write32(struct device *dev, uint32_t value, +static inline void xlnx_quadspi_write32(const struct device *dev, + uint32_t value, mm_reg_t offset) { const struct xlnx_quadspi_config *config = dev->config; @@ -106,7 +108,7 @@ static inline void xlnx_quadspi_write32(struct device *dev, uint32_t value, sys_write32(value, config->base + offset); } -static void xlnx_quadspi_cs_control(struct device *dev, bool on) +static void xlnx_quadspi_cs_control(const struct device *dev, bool on) { const struct xlnx_quadspi_config *config = dev->config; struct xlnx_quadspi_data *data = dev->data; @@ -130,7 +132,7 @@ static void xlnx_quadspi_cs_control(struct device *dev, bool on) spi_context_cs_control(ctx, on); } -static int xlnx_quadspi_configure(struct device *dev, +static int xlnx_quadspi_configure(const struct device *dev, const struct spi_config *spi_cfg) { const struct xlnx_quadspi_config *config = dev->config; @@ -219,7 +221,7 @@ static int xlnx_quadspi_configure(struct device *dev, return 0; } -static void xlnx_quadspi_start_tx(struct device *dev) +static void xlnx_quadspi_start_tx(const struct device *dev) { const struct xlnx_quadspi_config *config = dev->config; struct xlnx_quadspi_data *data = dev->data; @@ -308,7 +310,7 @@ static void xlnx_quadspi_start_tx(struct device *dev) } } -static int xlnx_quadspi_transceive(struct device *dev, +static int xlnx_quadspi_transceive(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -340,7 +342,7 @@ static int xlnx_quadspi_transceive(struct device *dev, return ret; } -static int xlnx_quadspi_transceive_blocking(struct device *dev, +static int xlnx_quadspi_transceive_blocking(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs) @@ -350,7 +352,7 @@ static int xlnx_quadspi_transceive_blocking(struct device *dev, } #ifdef CONFIG_SPI_ASYNC -static int xlnx_quadspi_transceive_async(struct device *dev, +static int xlnx_quadspi_transceive_async(const struct device *dev, const struct spi_config *spi_cfg, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -361,7 +363,7 @@ static int xlnx_quadspi_transceive_async(struct device *dev, } #endif /* CONFIG_SPI_ASYNC */ -static int xlnx_quadspi_release(struct device *dev, +static int xlnx_quadspi_release(const struct device *dev, const struct spi_config *spi_cfg) { const struct xlnx_quadspi_config *config = dev->config; @@ -383,7 +385,7 @@ static int xlnx_quadspi_release(struct device *dev, static void xlnx_quadspi_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct xlnx_quadspi_config *config = dev->config; struct xlnx_quadspi_data *data = dev->data; struct spi_context *ctx = &data->ctx; @@ -433,7 +435,7 @@ static void xlnx_quadspi_isr(void *arg) } } -static int xlnx_quadspi_init(struct device *dev) +static int xlnx_quadspi_init(const struct device *dev) { const struct xlnx_quadspi_config *config = dev->config; struct xlnx_quadspi_data *data = dev->data; diff --git a/drivers/timer/altera_avalon_timer_hal.c b/drivers/timer/altera_avalon_timer_hal.c index 918acc9118f181..4266402d1cefc3 100644 --- a/drivers/timer/altera_avalon_timer_hal.c +++ b/drivers/timer/altera_avalon_timer_hal.c @@ -41,7 +41,7 @@ static void timer_irq_handler(void *unused) #endif } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/apic_timer.c b/drivers/timer/apic_timer.c index 00d646b6974006..3cdc963b5fde08 100644 --- a/drivers/timer/apic_timer.c +++ b/drivers/timer/apic_timer.c @@ -213,7 +213,7 @@ uint32_t z_timer_cycle_get_32(void) #endif -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { uint32_t val; diff --git a/drivers/timer/arcv2_timer0.c b/drivers/timer/arcv2_timer0.c index aaac69db9ae01a..21d661f96b6824 100644 --- a/drivers/timer/arcv2_timer0.c +++ b/drivers/timer/arcv2_timer0.c @@ -277,7 +277,7 @@ static void timer_int_handler(void *unused) * * @return 0 */ -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/arm_arch_timer.c b/drivers/timer/arm_arch_timer.c index 1b77f7677d903b..b470eb635d1718 100644 --- a/drivers/timer/arm_arch_timer.c +++ b/drivers/timer/arm_arch_timer.c @@ -43,7 +43,7 @@ static void arm_arch_timer_compare_isr(void *arg) z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? delta_ticks : 1); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/cavs_timer.c b/drivers/timer/cavs_timer.c index 849d08fe455f25..14c7172108a74a 100644 --- a/drivers/timer/cavs_timer.c +++ b/drivers/timer/cavs_timer.c @@ -104,7 +104,7 @@ static void compare_isr(void *arg) z_clock_announce(dticks); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { uint64_t curr = count(); diff --git a/drivers/timer/cc13x2_cc26x2_rtc_timer.c b/drivers/timer/cc13x2_cc26x2_rtc_timer.c index 78dbe2517faca1..548d021fad3630 100644 --- a/drivers/timer/cc13x2_cc26x2_rtc_timer.c +++ b/drivers/timer/cc13x2_cc26x2_rtc_timer.c @@ -183,7 +183,7 @@ static void startDevice(void) irq_unlock(key); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/cortex_m_systick.c b/drivers/timer/cortex_m_systick.c index 544ff835171c70..ec046a7ba2491b 100644 --- a/drivers/timer/cortex_m_systick.c +++ b/drivers/timer/cortex_m_systick.c @@ -149,7 +149,7 @@ void z_clock_isr(void *arg) z_arm_int_exit(); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/hpet.c b/drivers/timer/hpet.c index 3d98b177bae67a..a2b4a11d52270c 100644 --- a/drivers/timer/hpet.c +++ b/drivers/timer/hpet.c @@ -116,7 +116,7 @@ static void set_timer0_irq(unsigned int irq) TIMER0_CONF_REG = val; } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { extern int z_clock_hw_cycles_per_sec; uint32_t hz; diff --git a/drivers/timer/litex_timer.c b/drivers/timer/litex_timer.c index e540c1dccb071d..ab896f5595cf45 100644 --- a/drivers/timer/litex_timer.c +++ b/drivers/timer/litex_timer.c @@ -59,7 +59,7 @@ uint32_t z_clock_elapsed(void) return 0; } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); IRQ_CONNECT(TIMER_IRQ, DT_INST_IRQ(0, priority), diff --git a/drivers/timer/loapic_timer.c b/drivers/timer/loapic_timer.c index a4000dc4acbb13..716a8059f07a98 100644 --- a/drivers/timer/loapic_timer.c +++ b/drivers/timer/loapic_timer.c @@ -553,7 +553,7 @@ void z_clock_idle_exit(void) * * @return 0 */ -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); @@ -586,7 +586,7 @@ int z_clock_driver_init(struct device *device) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -static int sys_clock_suspend(struct device *dev) +static int sys_clock_suspend(const struct device *dev) { ARG_UNUSED(dev); @@ -597,7 +597,7 @@ static int sys_clock_suspend(struct device *dev) return 0; } -static int sys_clock_resume(struct device *dev) +static int sys_clock_resume(const struct device *dev) { ARG_UNUSED(dev); @@ -637,7 +637,7 @@ static int sys_clock_resume(struct device *dev) * Implements the driver control management functionality * the *context may include IN data or/and OUT data */ -int z_clock_device_ctrl(struct device *port, uint32_t ctrl_command, +int z_clock_device_ctrl(const struct device *port, uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; diff --git a/drivers/timer/mchp_xec_rtos_timer.c b/drivers/timer/mchp_xec_rtos_timer.c index 6f0cead7608910..b4ae8c2cc31902 100644 --- a/drivers/timer/mchp_xec_rtos_timer.c +++ b/drivers/timer/mchp_xec_rtos_timer.c @@ -324,7 +324,7 @@ void sys_clock_disable(void) TIMER_REGS->CTRL = 0U; } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/native_posix_timer.c b/drivers/timer/native_posix_timer.c index 68fe023f322657..b7131e879b7fa0 100644 --- a/drivers/timer/native_posix_timer.c +++ b/drivers/timer/native_posix_timer.c @@ -52,7 +52,7 @@ static void np_timer_isr(void *arg) * * Enable the hw timer, setting its tick period, and setup its interrupt */ -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c index 8961e8a21e0d6c..de35ccd32911d8 100644 --- a/drivers/timer/nrf_rtc_timer.c +++ b/drivers/timer/nrf_rtc_timer.c @@ -186,7 +186,7 @@ void rtc_nrf_isr(void *arg) z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : (dticks > 0)); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/riscv_machine_timer.c b/drivers/timer/riscv_machine_timer.c index 257d5505132e9d..d895e831226169 100644 --- a/drivers/timer/riscv_machine_timer.c +++ b/drivers/timer/riscv_machine_timer.c @@ -79,7 +79,7 @@ static void timer_isr(void *arg) z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/rv32m1_lptmr_timer.c b/drivers/timer/rv32m1_lptmr_timer.c index 18c712525cad5b..8dd05abf33645e 100644 --- a/drivers/timer/rv32m1_lptmr_timer.c +++ b/drivers/timer/rv32m1_lptmr_timer.c @@ -44,7 +44,7 @@ struct device; /* forward declaration; type is not used. */ static volatile uint32_t cycle_count; -static void lptmr_irq_handler(struct device *unused) +static void lptmr_irq_handler(const struct device *unused) { ARG_UNUSED(unused); @@ -53,7 +53,7 @@ static void lptmr_irq_handler(struct device *unused) z_clock_announce(1); /* Poke the scheduler. */ } -int z_clock_driver_init(struct device *unused) +int z_clock_driver_init(const struct device *unused) { uint32_t csr, psr, sircdiv; /* LPTMR registers */ diff --git a/drivers/timer/sam0_rtc_timer.c b/drivers/timer/sam0_rtc_timer.c index 876ad5bfd03467..f2bd200d1c5bcc 100644 --- a/drivers/timer/sam0_rtc_timer.c +++ b/drivers/timer/sam0_rtc_timer.c @@ -175,7 +175,7 @@ static void rtc_isr(void *arg) #endif /* CONFIG_TICKLESS_KERNEL */ } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/stm32_lptim_timer.c b/drivers/timer/stm32_lptim_timer.c index 907cab89aa0a18..09c727b88203e2 100644 --- a/drivers/timer/stm32_lptim_timer.c +++ b/drivers/timer/stm32_lptim_timer.c @@ -40,7 +40,7 @@ static uint32_t accumulated_lptim_cnt; static struct k_spinlock lock; -static void lptim_irq_handler(struct device *unused) +static void lptim_irq_handler(const struct device *unused) { ARG_UNUSED(unused); @@ -73,7 +73,7 @@ static void lptim_irq_handler(struct device *unused) } } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/timer/sys_clock_init.c b/drivers/timer/sys_clock_init.c index f903919f5d359b..6d39b0901460b6 100644 --- a/drivers/timer/sys_clock_init.c +++ b/drivers/timer/sys_clock_init.c @@ -23,14 +23,15 @@ void __weak z_clock_isr(void *arg) __ASSERT_NO_MSG(false); } -int __weak z_clock_driver_init(struct device *device) +int __weak z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); return 0; } -int __weak z_clock_device_ctrl(struct device *device, uint32_t ctrl_command, +int __weak z_clock_device_ctrl(const struct device *device, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { return -ENOTSUP; diff --git a/drivers/timer/xlnx_psttc_timer.c b/drivers/timer/xlnx_psttc_timer.c index 068ee69fb8227a..bddec645124a94 100644 --- a/drivers/timer/xlnx_psttc_timer.c +++ b/drivers/timer/xlnx_psttc_timer.c @@ -96,7 +96,7 @@ static void ttc_isr(void *arg) z_clock_announce(ticks); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { uint32_t reg_val; diff --git a/drivers/timer/xtensa_sys_timer.c b/drivers/timer/xtensa_sys_timer.c index 72b921a1d8af98..b32bc4c7890e8a 100644 --- a/drivers/timer/xtensa_sys_timer.c +++ b/drivers/timer/xtensa_sys_timer.c @@ -57,7 +57,7 @@ static void ccompare_isr(void *arg) z_clock_announce(IS_ENABLED(CONFIG_TICKLESS_KERNEL) ? dticks : 1); } -int z_clock_driver_init(struct device *device) +int z_clock_driver_init(const struct device *device) { ARG_UNUSED(device); diff --git a/drivers/usb/device/usb_dc_nrfx.c b/drivers/usb/device/usb_dc_nrfx.c index 25a9cb70beb561..5a53d38c8be81a 100644 --- a/drivers/usb/device/usb_dc_nrfx.c +++ b/drivers/usb/device/usb_dc_nrfx.c @@ -1925,7 +1925,7 @@ int usb_dc_wakeup_request(void) return 0; } -static int usb_init(struct device *arg) +static int usb_init(const struct device *arg) { #ifdef CONFIG_SOC_SERIES_NRF53X diff --git a/drivers/usb/device/usb_dc_stm32.c b/drivers/usb/device/usb_dc_stm32.c index 8c64cd354280cc..39edc7a2734ba5 100644 --- a/drivers/usb/device/usb_dc_stm32.c +++ b/drivers/usb/device/usb_dc_stm32.c @@ -220,7 +220,7 @@ void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) static int usb_dc_stm32_clock_enable(void) { - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); struct stm32_pclken pclken = { .bus = USB_CLOCK_BUS, .enr = USB_CLOCK_BITS, @@ -1060,7 +1060,7 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) #if defined(USB) && defined(CONFIG_USB_DC_STM32_DISCONN_ENABLE) void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state) { - struct device *usb_disconnect; + const struct device *usb_disconnect; usb_disconnect = device_get_binding( DT_GPIO_LABEL(DT_INST(0, st_stm32_usb), disconnect_gpios)); diff --git a/drivers/video/mt9m114.c b/drivers/video/mt9m114.c index d4a5df746b3da2..b1a15522d9580d 100644 --- a/drivers/video/mt9m114.c +++ b/drivers/video/mt9m114.c @@ -49,7 +49,7 @@ LOG_MODULE_REGISTER(mt9m114); #define MT9M114_SYS_STATE_LEAVE_STANDBY 0x54 struct mt9m114_data { - struct device *i2c; + const struct device *i2c; struct video_format fmt; uint8_t i2c_addr; }; @@ -101,7 +101,8 @@ static struct mt9m114_reg mt9m114_vga_24mhz_pll[] = { { /* NULL terminated */ } }; -static inline int i2c_burst_read16(struct device *dev, uint16_t dev_addr, +static inline int i2c_burst_read16(const struct device *dev, + uint16_t dev_addr, uint16_t start_addr, uint8_t *buf, uint32_t num_bytes) { uint8_t addr_buffer[2]; @@ -112,7 +113,8 @@ static inline int i2c_burst_read16(struct device *dev, uint16_t dev_addr, buf, num_bytes); } -static inline int i2c_burst_write16(struct device *dev, uint16_t dev_addr, +static inline int i2c_burst_write16(const struct device *dev, + uint16_t dev_addr, uint16_t start_addr, const uint8_t *buf, uint32_t num_bytes) { @@ -132,7 +134,8 @@ static inline int i2c_burst_write16(struct device *dev, uint16_t dev_addr, return i2c_transfer(dev, msg, 2, dev_addr); } -static int mt9m114_write_reg(struct device *dev, uint16_t reg_addr, uint8_t reg_size, +static int mt9m114_write_reg(const struct device *dev, uint16_t reg_addr, + uint8_t reg_size, void *value) { struct mt9m114_data *drv_data = dev->data; @@ -154,7 +157,8 @@ static int mt9m114_write_reg(struct device *dev, uint16_t reg_addr, uint8_t reg_ value, reg_size); } -static int mt9m114_read_reg(struct device *dev, uint16_t reg_addr, uint8_t reg_size, +static int mt9m114_read_reg(const struct device *dev, uint16_t reg_addr, + uint8_t reg_size, void *value) { struct mt9m114_data *drv_data = dev->data; @@ -186,7 +190,8 @@ static int mt9m114_read_reg(struct device *dev, uint16_t reg_addr, uint8_t reg_s return 0; } -static int mt9m114_write_all(struct device *dev, struct mt9m114_reg *reg) +static int mt9m114_write_all(const struct device *dev, + struct mt9m114_reg *reg) { int i = 0; @@ -205,7 +210,7 @@ static int mt9m114_write_all(struct device *dev, struct mt9m114_reg *reg) return 0; } -static int mt9m114_set_state(struct device *dev, uint8_t state) +static int mt9m114_set_state(const struct device *dev, uint8_t state) { uint16_t val; int err; @@ -254,7 +259,8 @@ static int mt9m114_set_state(struct device *dev, uint8_t state) return 0; } -static int mt9m114_set_fmt(struct device *dev, enum video_endpoint_id ep, +static int mt9m114_set_fmt(const struct device *dev, + enum video_endpoint_id ep, struct video_format *fmt) { struct mt9m114_data *drv_data = dev->data; @@ -296,7 +302,8 @@ static int mt9m114_set_fmt(struct device *dev, enum video_endpoint_id ep, return 0; } -static int mt9m114_get_fmt(struct device *dev, enum video_endpoint_id ep, +static int mt9m114_get_fmt(const struct device *dev, + enum video_endpoint_id ep, struct video_format *fmt) { struct mt9m114_data *drv_data = dev->data; @@ -306,12 +313,12 @@ static int mt9m114_get_fmt(struct device *dev, enum video_endpoint_id ep, return 0; } -static int mt9m114_stream_start(struct device *dev) +static int mt9m114_stream_start(const struct device *dev) { return mt9m114_set_state(dev, MT9M114_SYS_STATE_START_STREAMING); } -static int mt9m114_stream_stop(struct device *dev) +static int mt9m114_stream_stop(const struct device *dev) { return mt9m114_set_state(dev, MT9M114_SYS_STATE_ENTER_SUSPEND); } @@ -329,7 +336,8 @@ static const struct video_format_cap fmts[] = { { 0 } }; -static int mt9m114_get_caps(struct device *dev, enum video_endpoint_id ep, +static int mt9m114_get_caps(const struct device *dev, + enum video_endpoint_id ep, struct video_caps *caps) { caps->format_caps = fmts; @@ -344,7 +352,7 @@ static const struct video_driver_api mt9m114_driver_api = { .stream_stop = mt9m114_stream_stop, }; -static int mt9m114_init(struct device *dev) +static int mt9m114_init(const struct device *dev) { struct video_format fmt; uint16_t val; @@ -386,7 +394,7 @@ static int mt9m114_init(struct device *dev) static struct mt9m114_data mt9m114_data_0; -static int mt9m114_init_0(struct device *dev) +static int mt9m114_init_0(const struct device *dev) { struct mt9m114_data *drv_data = dev->data; diff --git a/drivers/video/video_mcux_csi.c b/drivers/video/video_mcux_csi.c index 93c8476f71dbc3..5b0b29949e7b05 100644 --- a/drivers/video/video_mcux_csi.c +++ b/drivers/video/video_mcux_csi.c @@ -22,7 +22,7 @@ struct video_mcux_csi_config { }; struct video_mcux_csi_data { - struct device *sensor_dev; + const struct device *sensor_dev; csi_config_t csi_config; csi_handle_t csi_handle; struct k_fifo fifo_in; @@ -49,7 +49,7 @@ static inline unsigned int video_pix_fmt_bpp(uint32_t pixelformat) static void __frame_done_cb(CSI_Type *base, csi_handle_t *handle, status_t status, void *user_data) { - struct device *dev = user_data; + const struct device *dev = user_data; const struct video_mcux_csi_config *config = dev->config; struct video_mcux_csi_data *data = dev->data; enum video_signal_result result = VIDEO_BUF_DONE; @@ -112,7 +112,8 @@ static void __frame_done_cb(CSI_Type *base, csi_handle_t *handle, return; } -static int video_mcux_csi_set_fmt(struct device *dev, enum video_endpoint_id ep, +static int video_mcux_csi_set_fmt(const struct device *dev, + enum video_endpoint_id ep, struct video_format *fmt) { const struct video_mcux_csi_config *config = dev->config; @@ -152,7 +153,8 @@ static int video_mcux_csi_set_fmt(struct device *dev, enum video_endpoint_id ep, return 0; } -static int video_mcux_csi_get_fmt(struct device *dev, enum video_endpoint_id ep, +static int video_mcux_csi_get_fmt(const struct device *dev, + enum video_endpoint_id ep, struct video_format *fmt) { struct video_mcux_csi_data *data = dev->data; @@ -174,7 +176,7 @@ static int video_mcux_csi_get_fmt(struct device *dev, enum video_endpoint_id ep, return 0; } -static int video_mcux_csi_stream_start(struct device *dev) +static int video_mcux_csi_stream_start(const struct device *dev) { const struct video_mcux_csi_config *config = dev->config; struct video_mcux_csi_data *data = dev->data; @@ -192,7 +194,7 @@ static int video_mcux_csi_stream_start(struct device *dev) return 0; } -static int video_mcux_csi_stream_stop(struct device *dev) +static int video_mcux_csi_stream_stop(const struct device *dev) { const struct video_mcux_csi_config *config = dev->config; struct video_mcux_csi_data *data = dev->data; @@ -211,7 +213,8 @@ static int video_mcux_csi_stream_stop(struct device *dev) } -static int video_mcux_csi_flush(struct device *dev, enum video_endpoint_id ep, +static int video_mcux_csi_flush(const struct device *dev, + enum video_endpoint_id ep, bool cancel) { const struct video_mcux_csi_config *config = dev->config; @@ -245,7 +248,8 @@ static int video_mcux_csi_flush(struct device *dev, enum video_endpoint_id ep, return 0; } -static int video_mcux_csi_enqueue(struct device *dev, enum video_endpoint_id ep, +static int video_mcux_csi_enqueue(const struct device *dev, + enum video_endpoint_id ep, struct video_buffer *vbuf) { const struct video_mcux_csi_config *config = dev->config; @@ -271,7 +275,8 @@ static int video_mcux_csi_enqueue(struct device *dev, enum video_endpoint_id ep, return 0; } -static int video_mcux_csi_dequeue(struct device *dev, enum video_endpoint_id ep, +static int video_mcux_csi_dequeue(const struct device *dev, + enum video_endpoint_id ep, struct video_buffer **vbuf, k_timeout_t timeout) { @@ -289,7 +294,8 @@ static int video_mcux_csi_dequeue(struct device *dev, enum video_endpoint_id ep, return 0; } -static inline int video_mcux_csi_set_ctrl(struct device *dev, unsigned int cid, +static inline int video_mcux_csi_set_ctrl(const struct device *dev, + unsigned int cid, void *value) { struct video_mcux_csi_data *data = dev->data; @@ -303,7 +309,8 @@ static inline int video_mcux_csi_set_ctrl(struct device *dev, unsigned int cid, return ret; } -static inline int video_mcux_csi_get_ctrl(struct device *dev, unsigned int cid, +static inline int video_mcux_csi_get_ctrl(const struct device *dev, + unsigned int cid, void *value) { struct video_mcux_csi_data *data = dev->data; @@ -317,7 +324,7 @@ static inline int video_mcux_csi_get_ctrl(struct device *dev, unsigned int cid, return ret; } -static int video_mcux_csi_get_caps(struct device *dev, +static int video_mcux_csi_get_caps(const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps) { @@ -347,7 +354,7 @@ static void video_mcux_csi_isr(void *p) CSI_DriverIRQHandler(); } -static int video_mcux_csi_init(struct device *dev) +static int video_mcux_csi_init(const struct device *dev) { const struct video_mcux_csi_config *config = dev->config; struct video_mcux_csi_data *data = dev->data; @@ -369,7 +376,7 @@ static int video_mcux_csi_init(struct device *dev) } #ifdef CONFIG_POLL -static int video_mcux_csi_set_signal(struct device *dev, +static int video_mcux_csi_set_signal(const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal) { @@ -409,7 +416,7 @@ static const struct video_mcux_csi_config video_mcux_csi_config_0 = { static struct video_mcux_csi_data video_mcux_csi_data_0; -static int video_mcux_csi_init_0(struct device *dev) +static int video_mcux_csi_init_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), video_mcux_csi_isr, NULL, 0); diff --git a/drivers/video/video_sw_generator.c b/drivers/video/video_sw_generator.c index 976fd2474d317c..6ff3aecadea8e6 100644 --- a/drivers/video/video_sw_generator.c +++ b/drivers/video/video_sw_generator.c @@ -11,7 +11,7 @@ #define VIDEO_PATTERN_FPS 30 struct video_sw_generator_data { - struct device *dev; + const struct device *dev; struct video_format fmt; struct k_fifo fifo_in; struct k_fifo fifo_out; @@ -22,7 +22,7 @@ struct video_sw_generator_data { struct k_poll_signal *signal; }; -static int video_sw_generator_set_fmt(struct device *dev, +static int video_sw_generator_set_fmt(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt) { @@ -37,7 +37,7 @@ static int video_sw_generator_set_fmt(struct device *dev, return 0; } -static int video_sw_generator_get_fmt(struct device *dev, +static int video_sw_generator_get_fmt(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt) { @@ -52,14 +52,14 @@ static int video_sw_generator_get_fmt(struct device *dev, return 0; } -static int video_sw_generator_stream_start(struct device *dev) +static int video_sw_generator_stream_start(const struct device *dev) { struct video_sw_generator_data *data = dev->data; return k_delayed_work_submit(&data->buf_work, K_MSEC(33)); } -static int video_sw_generator_stream_stop(struct device *dev) +static int video_sw_generator_stream_stop(const struct device *dev) { struct video_sw_generator_data *data = dev->data; @@ -123,7 +123,7 @@ static void __buffer_work(struct k_work *work) k_yield(); } -static int video_sw_generator_enqueue(struct device *dev, +static int video_sw_generator_enqueue(const struct device *dev, enum video_endpoint_id ep, struct video_buffer *vbuf) { @@ -138,7 +138,7 @@ static int video_sw_generator_enqueue(struct device *dev, return 0; } -static int video_sw_generator_dequeue(struct device *dev, +static int video_sw_generator_dequeue(const struct device *dev, enum video_endpoint_id ep, struct video_buffer **vbuf, k_timeout_t timeout) @@ -157,7 +157,7 @@ static int video_sw_generator_dequeue(struct device *dev, return 0; } -static int video_sw_generator_flush(struct device *dev, +static int video_sw_generator_flush(const struct device *dev, enum video_endpoint_id ep, bool cancel) { @@ -195,7 +195,7 @@ static const struct video_format_cap fmts[] = { { 0 } }; -static int video_sw_generator_get_caps(struct device *dev, +static int video_sw_generator_get_caps(const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps) { @@ -206,7 +206,7 @@ static int video_sw_generator_get_caps(struct device *dev, } #ifdef CONFIG_POLL -static int video_sw_generator_set_signal(struct device *dev, +static int video_sw_generator_set_signal(const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal) { @@ -222,7 +222,7 @@ static int video_sw_generator_set_signal(struct device *dev, } #endif -static inline int video_sw_generator_set_ctrl(struct device *dev, +static inline int video_sw_generator_set_ctrl(const struct device *dev, unsigned int cid, void *value) { @@ -261,7 +261,7 @@ static struct video_sw_generator_data video_sw_generator_data_0 = { .fmt.pixelformat = VIDEO_PIX_FMT_RGB565, }; -static int video_sw_generator_init(struct device *dev) +static int video_sw_generator_init(const struct device *dev) { struct video_sw_generator_data *data = dev->data; diff --git a/drivers/watchdog/wdt_cmsdk_apb.c b/drivers/watchdog/wdt_cmsdk_apb.c index a0e10633ee395a..6d452dba3b7c04 100644 --- a/drivers/watchdog/wdt_cmsdk_apb.c +++ b/drivers/watchdog/wdt_cmsdk_apb.c @@ -62,15 +62,15 @@ struct wdog_cmsdk_apb { ((volatile struct wdog_cmsdk_apb *)(DT_INST_REG_ADDR(0))) /* Keep reference of the device to pass it to the callback */ -struct device *wdog_r; +const struct device *wdog_r; /* watchdog reload value in sec */ static unsigned int reload_s = CMSDK_APB_WDOG_RELOAD; static uint8_t flags; -static void (*user_cb)(struct device *dev, int channel_id); +static void (*user_cb)(const struct device *dev, int channel_id); -static void wdog_cmsdk_apb_unlock(struct device *dev) +static void wdog_cmsdk_apb_unlock(const struct device *dev) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; @@ -79,7 +79,7 @@ static void wdog_cmsdk_apb_unlock(struct device *dev) wdog->lock = CMSDK_APB_WDOG_UNLOCK_VALUE; } -static int wdog_cmsdk_apb_setup(struct device *dev, uint8_t options) +static int wdog_cmsdk_apb_setup(const struct device *dev, uint8_t options) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; @@ -92,7 +92,7 @@ static int wdog_cmsdk_apb_setup(struct device *dev, uint8_t options) return 0; } -static int wdog_cmsdk_apb_disable(struct device *dev) +static int wdog_cmsdk_apb_disable(const struct device *dev) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; @@ -104,7 +104,7 @@ static int wdog_cmsdk_apb_disable(struct device *dev) return 0; } -static int wdog_cmsdk_apb_install_timeout(struct device *dev, +static int wdog_cmsdk_apb_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *config) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; @@ -124,7 +124,7 @@ static int wdog_cmsdk_apb_install_timeout(struct device *dev, return 0; } -static int wdog_cmsdk_apb_feed(struct device *dev, int channel_id) +static int wdog_cmsdk_apb_feed(const struct device *dev, int channel_id) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; @@ -175,7 +175,7 @@ static void wdog_cmsdk_apb_isr(void) } #endif /* CONFIG_RUNTIME_NMI */ -static int wdog_cmsdk_apb_init(struct device *dev) +static int wdog_cmsdk_apb_init(const struct device *dev) { volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT; diff --git a/drivers/watchdog/wdt_esp32.c b/drivers/watchdog/wdt_esp32.c index a5b05772e9fcb0..7c0b09a20838e5 100644 --- a/drivers/watchdog/wdt_esp32.c +++ b/drivers/watchdog/wdt_esp32.c @@ -68,18 +68,18 @@ struct wdt_esp32_config { * magic value of TIMG_WDT_WKEY_VALUE. The datasheet recommends unsealing, * making modifications, and sealing for every watchdog modification. */ -static inline void wdt_esp32_seal(struct device *dev) +static inline void wdt_esp32_seal(const struct device *dev) { DEV_BASE(dev)->wprotect = 0U; } -static inline void wdt_esp32_unseal(struct device *dev) +static inline void wdt_esp32_unseal(const struct device *dev) { DEV_BASE(dev)->wprotect = TIMG_WDT_WKEY_VALUE; } -static void wdt_esp32_enable(struct device *dev) +static void wdt_esp32_enable(const struct device *dev) { wdt_esp32_unseal(dev); DEV_BASE(dev)->config0 |= BIT(TIMG_WDT_EN_S); @@ -87,7 +87,7 @@ static void wdt_esp32_enable(struct device *dev) } -static int wdt_esp32_disable(struct device *dev) +static int wdt_esp32_disable(const struct device *dev) { wdt_esp32_unseal(dev); DEV_BASE(dev)->config0 &= ~BIT(TIMG_WDT_EN_S); @@ -96,7 +96,7 @@ static int wdt_esp32_disable(struct device *dev) return 0; } -static void adjust_timeout(struct device *dev, uint32_t timeout) +static void adjust_timeout(const struct device *dev, uint32_t timeout) { /* MWDT ticks every 12.5ns. Set the prescaler to 40000, so the * counter for each watchdog stage is decremented every 0.5ms. @@ -106,9 +106,9 @@ static void adjust_timeout(struct device *dev, uint32_t timeout) DEV_BASE(dev)->config3 = timeout; } -static void wdt_esp32_isr(struct device *dev); +static void wdt_esp32_isr(const struct device *dev); -static int wdt_esp32_feed(struct device *dev, int channel_id) +static int wdt_esp32_feed(const struct device *dev, int channel_id) { wdt_esp32_unseal(dev); DEV_BASE(dev)->feed = 0xABAD1DEA; /* Writing any value to WDTFEED will reload it. */ @@ -117,7 +117,7 @@ static int wdt_esp32_feed(struct device *dev, int channel_id) return 0; } -static void set_interrupt_enabled(struct device *dev, bool setting) +static void set_interrupt_enabled(const struct device *dev, bool setting) { *DEV_CFG(dev)->irq_regs.timer_int_clr |= TIMG_WDT_INT_CLR; @@ -130,7 +130,7 @@ static void set_interrupt_enabled(struct device *dev, bool setting) } } -static int wdt_esp32_set_config(struct device *dev, uint8_t options) +static int wdt_esp32_set_config(const struct device *dev, uint8_t options) { struct wdt_esp32_data *data = DEV_DATA(dev); uint32_t v = DEV_BASE(dev)->config0; @@ -177,7 +177,7 @@ static int wdt_esp32_set_config(struct device *dev, uint8_t options) return 0; } -static int wdt_esp32_install_timeout(struct device *dev, +static int wdt_esp32_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { struct wdt_esp32_data *data = DEV_DATA(dev); @@ -200,7 +200,7 @@ static int wdt_esp32_install_timeout(struct device *dev, return 0; } -static int wdt_esp32_init(struct device *dev) +static int wdt_esp32_init(const struct device *dev) { #ifdef CONFIG_WDT_DISABLE_AT_BOOT wdt_esp32_disable(dev); @@ -258,7 +258,7 @@ static const struct wdt_driver_api wdt_api = { PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \ &wdt_api) -static void wdt_esp32_isr(struct device *dev) +static void wdt_esp32_isr(const struct device *dev) { struct wdt_esp32_data *data = DEV_DATA(dev); diff --git a/drivers/watchdog/wdt_gecko.c b/drivers/watchdog/wdt_gecko.c index f480b03643eb14..287c94a6666e5c 100644 --- a/drivers/watchdog/wdt_gecko.c +++ b/drivers/watchdog/wdt_gecko.c @@ -91,7 +91,7 @@ static int wdt_gecko_convert_window(uint32_t window, uint32_t period) return idx; } -static int wdt_gecko_setup(struct device *dev, uint8_t options) +static int wdt_gecko_setup(const struct device *dev, uint8_t options) { const struct wdt_gecko_cfg *config = DEV_CFG(dev); struct wdt_gecko_data *data = DEV_DATA(dev); @@ -128,7 +128,7 @@ static int wdt_gecko_setup(struct device *dev, uint8_t options) return 0; } -static int wdt_gecko_disable(struct device *dev) +static int wdt_gecko_disable(const struct device *dev) { const struct wdt_gecko_cfg *config = DEV_CFG(dev); struct wdt_gecko_data *data = DEV_DATA(dev); @@ -141,7 +141,7 @@ static int wdt_gecko_disable(struct device *dev) return 0; } -static int wdt_gecko_install_timeout(struct device *dev, +static int wdt_gecko_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { struct wdt_gecko_data *data = DEV_DATA(dev); @@ -214,7 +214,7 @@ static int wdt_gecko_install_timeout(struct device *dev, return 0; } -static int wdt_gecko_feed(struct device *dev, int channel_id) +static int wdt_gecko_feed(const struct device *dev, int channel_id) { const struct wdt_gecko_cfg *config = DEV_CFG(dev); WDOG_TypeDef *wdog = config->base; @@ -232,7 +232,7 @@ static int wdt_gecko_feed(struct device *dev, int channel_id) static void wdt_gecko_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct wdt_gecko_cfg *config = DEV_CFG(dev); struct wdt_gecko_data *data = DEV_DATA(dev); WDOG_TypeDef *wdog = config->base; @@ -247,7 +247,7 @@ static void wdt_gecko_isr(void *arg) } } -static int wdt_gecko_init(struct device *dev) +static int wdt_gecko_init(const struct device *dev) { const struct wdt_gecko_cfg *config = DEV_CFG(dev); diff --git a/drivers/watchdog/wdt_handlers.c b/drivers/watchdog/wdt_handlers.c index 646235b6de69cd..37cbb3db9d31e3 100644 --- a/drivers/watchdog/wdt_handlers.c +++ b/drivers/watchdog/wdt_handlers.c @@ -7,7 +7,7 @@ #include #include -static inline int z_vrfy_wdt_setup(struct device *dev, uint8_t options) +static inline int z_vrfy_wdt_setup(const struct device *dev, uint8_t options) { Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, setup)); return z_impl_wdt_setup(dev, options); @@ -15,7 +15,7 @@ static inline int z_vrfy_wdt_setup(struct device *dev, uint8_t options) #include -static inline int z_vrfy_wdt_disable(struct device *dev) +static inline int z_vrfy_wdt_disable(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, disable)); return z_impl_wdt_disable(dev); @@ -23,7 +23,7 @@ static inline int z_vrfy_wdt_disable(struct device *dev) #include -static inline int z_vrfy_wdt_feed(struct device *dev, int channel_id) +static inline int z_vrfy_wdt_feed(const struct device *dev, int channel_id) { Z_OOPS(Z_SYSCALL_DRIVER_WDT(dev, feed)); return z_impl_wdt_feed(dev, channel_id); diff --git a/drivers/watchdog/wdt_iwdg_stm32.c b/drivers/watchdog/wdt_iwdg_stm32.c index 83685ec99ba379..362a02eaf54d08 100644 --- a/drivers/watchdog/wdt_iwdg_stm32.c +++ b/drivers/watchdog/wdt_iwdg_stm32.c @@ -63,7 +63,7 @@ static void iwdg_stm32_convert_timeout(uint32_t timeout, *reload = (uint32_t)(m_timeout / divider) - 1; } -static int iwdg_stm32_setup(struct device *dev, uint8_t options) +static int iwdg_stm32_setup(const struct device *dev, uint8_t options) { IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); @@ -85,7 +85,7 @@ static int iwdg_stm32_setup(struct device *dev, uint8_t options) return 0; } -static int iwdg_stm32_disable(struct device *dev) +static int iwdg_stm32_disable(const struct device *dev) { /* watchdog cannot be stopped once started */ ARG_UNUSED(dev); @@ -93,7 +93,7 @@ static int iwdg_stm32_disable(struct device *dev) return -EPERM; } -static int iwdg_stm32_install_timeout(struct device *dev, +static int iwdg_stm32_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *config) { IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); @@ -134,7 +134,7 @@ static int iwdg_stm32_install_timeout(struct device *dev, return 0; } -static int iwdg_stm32_feed(struct device *dev, int channel_id) +static int iwdg_stm32_feed(const struct device *dev, int channel_id) { IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); @@ -151,7 +151,7 @@ static const struct wdt_driver_api iwdg_stm32_api = { .feed = iwdg_stm32_feed, }; -static int iwdg_stm32_init(struct device *dev) +static int iwdg_stm32_init(const struct device *dev) { #ifndef CONFIG_WDT_DISABLE_AT_BOOT IWDG_TypeDef *iwdg = IWDG_STM32_STRUCT(dev); diff --git a/drivers/watchdog/wdt_mchp_xec.c b/drivers/watchdog/wdt_mchp_xec.c index 67f914298f6697..3a5b1da0e10e7b 100644 --- a/drivers/watchdog/wdt_mchp_xec.c +++ b/drivers/watchdog/wdt_mchp_xec.c @@ -28,7 +28,7 @@ struct wdt_xec_data { DEVICE_DECLARE(wdt_xec); -static int wdt_xec_setup(struct device *dev, uint8_t options) +static int wdt_xec_setup(const struct device *dev, uint8_t options) { WDT_Type *wdt_regs = WDT_XEC_REG_BASE; struct wdt_xec_data *data = dev->data; @@ -60,7 +60,7 @@ static int wdt_xec_setup(struct device *dev, uint8_t options) return 0; } -static int wdt_xec_disable(struct device *dev) +static int wdt_xec_disable(const struct device *dev) { WDT_Type *wdt_regs = WDT_XEC_REG_BASE; struct wdt_xec_data *data = dev->data; @@ -77,7 +77,7 @@ static int wdt_xec_disable(struct device *dev) return 0; } -static int wdt_xec_install_timeout(struct device *dev, +static int wdt_xec_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *config) { WDT_Type *wdt_regs = WDT_XEC_REG_BASE; @@ -121,7 +121,7 @@ static int wdt_xec_install_timeout(struct device *dev, return 0; } -static int wdt_xec_feed(struct device *dev, int channel_id) +static int wdt_xec_feed(const struct device *dev, int channel_id) { WDT_Type *wdt_regs = WDT_XEC_REG_BASE; @@ -139,7 +139,7 @@ static int wdt_xec_feed(struct device *dev, int channel_id) return 0; } -static void wdt_xec_isr(struct device *dev) +static void wdt_xec_isr(const struct device *dev) { WDT_Type *wdt_regs = WDT_XEC_REG_BASE; struct wdt_xec_data *data = dev->data; @@ -161,7 +161,7 @@ static const struct wdt_driver_api wdt_xec_api = { .feed = wdt_xec_feed, }; -static int wdt_xec_init(struct device *dev) +static int wdt_xec_init(const struct device *dev) { if (IS_ENABLED(CONFIG_WDT_DISABLE_AT_BOOT)) { wdt_xec_disable(dev); diff --git a/drivers/watchdog/wdt_mcux_wdog.c b/drivers/watchdog/wdt_mcux_wdog.c index 8e9e465d3305a3..706e26973be03f 100644 --- a/drivers/watchdog/wdt_mcux_wdog.c +++ b/drivers/watchdog/wdt_mcux_wdog.c @@ -21,7 +21,7 @@ struct mcux_wdog_config { WDOG_Type *base; char *clock_name; clock_control_subsys_t clock_subsys; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_wdog_data { @@ -30,7 +30,7 @@ struct mcux_wdog_data { bool timeout_valid; }; -static int mcux_wdog_setup(struct device *dev, uint8_t options) +static int mcux_wdog_setup(const struct device *dev, uint8_t options) { const struct mcux_wdog_config *config = dev->config; struct mcux_wdog_data *data = dev->data; @@ -53,7 +53,7 @@ static int mcux_wdog_setup(struct device *dev, uint8_t options) return 0; } -static int mcux_wdog_disable(struct device *dev) +static int mcux_wdog_disable(const struct device *dev) { const struct mcux_wdog_config *config = dev->config; struct mcux_wdog_data *data = dev->data; @@ -66,12 +66,12 @@ static int mcux_wdog_disable(struct device *dev) return 0; } -static int mcux_wdog_install_timeout(struct device *dev, +static int mcux_wdog_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { const struct mcux_wdog_config *config = dev->config; struct mcux_wdog_data *data = dev->data; - struct device *clock_dev; + const struct device *clock_dev; uint32_t clock_freq; if (data->timeout_valid) { @@ -116,7 +116,7 @@ static int mcux_wdog_install_timeout(struct device *dev, return 0; } -static int mcux_wdog_feed(struct device *dev, int channel_id) +static int mcux_wdog_feed(const struct device *dev, int channel_id) { const struct mcux_wdog_config *config = dev->config; WDOG_Type *base = config->base; @@ -134,7 +134,7 @@ static int mcux_wdog_feed(struct device *dev, int channel_id) static void mcux_wdog_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_wdog_config *config = dev->config; struct mcux_wdog_data *data = dev->data; WDOG_Type *base = config->base; @@ -148,7 +148,7 @@ static void mcux_wdog_isr(void *arg) } } -static int mcux_wdog_init(struct device *dev) +static int mcux_wdog_init(const struct device *dev) { const struct mcux_wdog_config *config = dev->config; @@ -164,7 +164,7 @@ static const struct wdt_driver_api mcux_wdog_api = { .feed = mcux_wdog_feed, }; -static void mcux_wdog_config_func_0(struct device *dev); +static void mcux_wdog_config_func_0(const struct device *dev); static const struct mcux_wdog_config mcux_wdog_config_0 = { .base = (WDOG_Type *) DT_INST_REG_ADDR(0), @@ -182,7 +182,7 @@ DEVICE_AND_API_INIT(mcux_wdog_0, DT_INST_LABEL(0), POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_wdog_api); -static void mcux_wdog_config_func_0(struct device *dev) +static void mcux_wdog_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/watchdog/wdt_mcux_wdog32.c b/drivers/watchdog/wdt_mcux_wdog32.c index 212d3276ee2f1e..74d4982cdcf4c9 100644 --- a/drivers/watchdog/wdt_mcux_wdog32.c +++ b/drivers/watchdog/wdt_mcux_wdog32.c @@ -29,7 +29,7 @@ struct mcux_wdog32_config { #endif /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */ wdog32_clock_source_t clk_source; wdog32_clock_prescaler_t clk_divider; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_wdog32_data { @@ -38,7 +38,7 @@ struct mcux_wdog32_data { bool timeout_valid; }; -static int mcux_wdog32_setup(struct device *dev, uint8_t options) +static int mcux_wdog32_setup(const struct device *dev, uint8_t options) { const struct mcux_wdog32_config *config = dev->config; struct mcux_wdog32_data *data = dev->data; @@ -61,7 +61,7 @@ static int mcux_wdog32_setup(struct device *dev, uint8_t options) return 0; } -static int mcux_wdog32_disable(struct device *dev) +static int mcux_wdog32_disable(const struct device *dev) { const struct mcux_wdog32_config *config = dev->config; struct mcux_wdog32_data *data = dev->data; @@ -77,7 +77,7 @@ static int mcux_wdog32_disable(struct device *dev) #define MSEC_TO_WDOG32_TICKS(clock_freq, divider, msec) \ ((uint32_t)(clock_freq * msec / 1000U / divider)) -static int mcux_wdog32_install_timeout(struct device *dev, +static int mcux_wdog32_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { const struct mcux_wdog32_config *config = dev->config; @@ -93,7 +93,7 @@ static int mcux_wdog32_install_timeout(struct device *dev, #if DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) clock_freq = config->clock_frequency; #else /* !DT_NODE_HAS_PROP(DT_INST_PHANDLE(0, clocks), clock_frequency) */ - struct device *clock_dev = device_get_binding(config->clock_name); + const struct device *clock_dev = device_get_binding(config->clock_name); if (clock_dev == NULL) { return -EINVAL; } @@ -137,7 +137,7 @@ static int mcux_wdog32_install_timeout(struct device *dev, return 0; } -static int mcux_wdog32_feed(struct device *dev, int channel_id) +static int mcux_wdog32_feed(const struct device *dev, int channel_id) { const struct mcux_wdog32_config *config = dev->config; WDOG_Type *base = config->base; @@ -155,7 +155,7 @@ static int mcux_wdog32_feed(struct device *dev, int channel_id) static void mcux_wdog32_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_wdog32_config *config = dev->config; struct mcux_wdog32_data *data = dev->data; WDOG_Type *base = config->base; @@ -169,7 +169,7 @@ static void mcux_wdog32_isr(void *arg) } } -static int mcux_wdog32_init(struct device *dev) +static int mcux_wdog32_init(const struct device *dev) { const struct mcux_wdog32_config *config = dev->config; @@ -188,7 +188,7 @@ static const struct wdt_driver_api mcux_wdog32_api = { #define TO_WDOG32_CLK_SRC(val) _DO_CONCAT(kWDOG32_ClockSource, val) #define TO_WDOG32_CLK_DIV(val) _DO_CONCAT(kWDOG32_ClockPrescalerDivide, val) -static void mcux_wdog32_config_func_0(struct device *dev); +static void mcux_wdog32_config_func_0(const struct device *dev); static const struct mcux_wdog32_config mcux_wdog32_config_0 = { .base = (WDOG_Type *) DT_INST_REG_ADDR(0), @@ -214,7 +214,7 @@ DEVICE_AND_API_INIT(mcux_wdog32_0, DT_INST_LABEL(0), CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_wdog32_api); -static void mcux_wdog32_config_func_0(struct device *dev) +static void mcux_wdog32_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/watchdog/wdt_mcux_wwdt.c b/drivers/watchdog/wdt_mcux_wwdt.c index 1f1a3682747bf7..962ae9819f9bbb 100644 --- a/drivers/watchdog/wdt_mcux_wwdt.c +++ b/drivers/watchdog/wdt_mcux_wwdt.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(wdt_mcux_wwdt); struct mcux_wwdt_config { WWDT_Type *base; uint8_t clk_divider; - void (*irq_config_func)(struct device *dev); + void (*irq_config_func)(const struct device *dev); }; struct mcux_wwdt_data { @@ -32,7 +32,7 @@ struct mcux_wwdt_data { bool timeout_valid; }; -static int mcux_wwdt_setup(struct device *dev, uint8_t options) +static int mcux_wwdt_setup(const struct device *dev, uint8_t options) { const struct mcux_wwdt_config *config = dev->config; struct mcux_wwdt_data *data = dev->data; @@ -49,7 +49,7 @@ static int mcux_wwdt_setup(struct device *dev, uint8_t options) return 0; } -static int mcux_wwdt_disable(struct device *dev) +static int mcux_wwdt_disable(const struct device *dev) { const struct mcux_wwdt_config *config = dev->config; struct mcux_wwdt_data *data = dev->data; @@ -69,7 +69,7 @@ static int mcux_wwdt_disable(struct device *dev) #define MSEC_TO_WWDT_TICKS(clock_freq, msec) \ ((uint32_t)(clock_freq * msec / MSEC_PER_SEC / 4)) -static int mcux_wwdt_install_timeout(struct device *dev, +static int mcux_wwdt_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { const struct mcux_wwdt_config *config = dev->config; @@ -115,7 +115,7 @@ static int mcux_wwdt_install_timeout(struct device *dev, return 0; } -static int mcux_wwdt_feed(struct device *dev, int channel_id) +static int mcux_wwdt_feed(const struct device *dev, int channel_id) { const struct mcux_wwdt_config *config = dev->config; WWDT_Type *base = config->base; @@ -133,7 +133,7 @@ static int mcux_wwdt_feed(struct device *dev, int channel_id) static void mcux_wwdt_isr(void *arg) { - struct device *dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; const struct mcux_wwdt_config *config = dev->config; struct mcux_wwdt_data *data = dev->data; WWDT_Type *base = config->base; @@ -147,7 +147,7 @@ static void mcux_wwdt_isr(void *arg) } } -static int mcux_wwdt_init(struct device *dev) +static int mcux_wwdt_init(const struct device *dev) { const struct mcux_wwdt_config *config = dev->config; @@ -163,7 +163,7 @@ static const struct wdt_driver_api mcux_wwdt_api = { .feed = mcux_wwdt_feed, }; -static void mcux_wwdt_config_func_0(struct device *dev); +static void mcux_wwdt_config_func_0(const struct device *dev); static const struct mcux_wwdt_config mcux_wwdt_config_0 = { .base = (WWDT_Type *) DT_INST_REG_ADDR(0), @@ -180,7 +180,7 @@ DEVICE_AND_API_INIT(mcux_wwdt_0, DT_INST_LABEL(0), CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &mcux_wwdt_api); -static void mcux_wwdt_config_func_0(struct device *dev) +static void mcux_wwdt_config_func_0(const struct device *dev) { IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority), diff --git a/drivers/watchdog/wdt_nrfx.c b/drivers/watchdog/wdt_nrfx.c index 5bd8867830d953..8f96d4ee50c158 100644 --- a/drivers/watchdog/wdt_nrfx.c +++ b/drivers/watchdog/wdt_nrfx.c @@ -22,18 +22,18 @@ struct wdt_nrfx_config { nrfx_wdt_config_t config; }; -static inline struct wdt_nrfx_data *get_dev_data(struct device *dev) +static inline struct wdt_nrfx_data *get_dev_data(const struct device *dev) { return dev->data; } -static inline const struct wdt_nrfx_config *get_dev_config(struct device *dev) +static inline const struct wdt_nrfx_config *get_dev_config(const struct device *dev) { return dev->config; } -static int wdt_nrf_setup(struct device *dev, uint8_t options) +static int wdt_nrf_setup(const struct device *dev, uint8_t options) { nrf_wdt_behaviour_t behaviour; @@ -64,14 +64,14 @@ static int wdt_nrf_setup(struct device *dev, uint8_t options) return 0; } -static int wdt_nrf_disable(struct device *dev) +static int wdt_nrf_disable(const struct device *dev) { /* Started watchdog cannot be stopped on nRF devices. */ ARG_UNUSED(dev); return -EPERM; } -static int wdt_nrf_install_timeout(struct device *dev, +static int wdt_nrf_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { nrfx_err_t err_code; @@ -117,7 +117,7 @@ static int wdt_nrf_install_timeout(struct device *dev, return channel_id; } -static int wdt_nrf_feed(struct device *dev, int channel_id) +static int wdt_nrf_feed(const struct device *dev, int channel_id) { if (channel_id > get_dev_data(dev)->m_allocated_channels) { return -EINVAL; @@ -136,7 +136,7 @@ static const struct wdt_driver_api wdt_nrfx_driver_api = { .feed = wdt_nrf_feed, }; -static void wdt_event_handler(struct device *dev) +static void wdt_event_handler(const struct device *dev) { int i; diff --git a/drivers/watchdog/wdt_sam.c b/drivers/watchdog/wdt_sam.c index ab8515c4200808..cf0855068c53b0 100644 --- a/drivers/watchdog/wdt_sam.c +++ b/drivers/watchdog/wdt_sam.c @@ -48,7 +48,7 @@ static struct wdt_sam_dev_data wdt_sam_data = { 0 }; #define DEV_CFG(dev) \ ((const struct wdt_sam_dev_cfg *const)(dev)->config) -static void wdt_sam_isr(struct device *dev) +static void wdt_sam_isr(const struct device *dev) { uint32_t wdt_sr; Wdt *const wdt = DEV_CFG(dev)->regs; @@ -83,7 +83,7 @@ int wdt_sam_convert_timeout(uint32_t timeout, uint32_t sclk) return WDT_MR_WDV(timeout / min); } -static int wdt_sam_disable(struct device *dev) +static int wdt_sam_disable(const struct device *dev) { Wdt *const wdt = DEV_CFG(dev)->regs; struct wdt_sam_dev_data *data = dev->data; @@ -106,7 +106,7 @@ static int wdt_sam_disable(struct device *dev) return 0; } -static int wdt_sam_setup(struct device *dev, uint8_t options) +static int wdt_sam_setup(const struct device *dev, uint8_t options) { Wdt *const wdt = DEV_CFG(dev)->regs; @@ -139,7 +139,7 @@ static int wdt_sam_setup(struct device *dev, uint8_t options) return 0; } -static int wdt_sam_install_timeout(struct device *dev, +static int wdt_sam_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { uint32_t wdt_mode = 0U; @@ -208,7 +208,7 @@ static int wdt_sam_install_timeout(struct device *dev, return 0; } -static int wdt_sam_feed(struct device *dev, int channel_id) +static int wdt_sam_feed(const struct device *dev, int channel_id) { /* * On watchdog restart the Watchdog counter is immediately @@ -241,7 +241,7 @@ static void wdt_sam_irq_config(void) irq_enable(DT_INST_IRQN(0)); } -static int wdt_sam_init(struct device *dev) +static int wdt_sam_init(const struct device *dev) { #ifdef CONFIG_WDT_DISABLE_AT_BOOT wdt_sam_disable(dev); diff --git a/drivers/watchdog/wdt_sam0.c b/drivers/watchdog/wdt_sam0.c index dce69841742336..b2879ab788a764 100644 --- a/drivers/watchdog/wdt_sam0.c +++ b/drivers/watchdog/wdt_sam0.c @@ -85,7 +85,7 @@ static uint32_t wdt_sam0_timeout_to_wdt_period(uint32_t timeout_ms) return find_msb_set(next_pow2 >> 4); } -static void wdt_sam0_isr(struct device *dev) +static void wdt_sam0_isr(const struct device *dev) { struct wdt_sam0_dev_data *data = dev->data; @@ -96,7 +96,7 @@ static void wdt_sam0_isr(struct device *dev) } } -static int wdt_sam0_setup(struct device *dev, uint8_t options) +static int wdt_sam0_setup(const struct device *dev, uint8_t options) { struct wdt_sam0_dev_data *data = dev->data; @@ -127,7 +127,7 @@ static int wdt_sam0_setup(struct device *dev, uint8_t options) return 0; } -static int wdt_sam0_disable(struct device *dev) +static int wdt_sam0_disable(const struct device *dev) { if (!wdt_sam0_is_enabled()) { return -EFAULT; @@ -139,8 +139,8 @@ static int wdt_sam0_disable(struct device *dev) return 0; } -static int wdt_sam0_install_timeout(struct device *dev, - const struct wdt_timeout_cfg *cfg) +static int wdt_sam0_install_timeout(const struct device *dev, + const struct wdt_timeout_cfg *cfg) { struct wdt_sam0_dev_data *data = dev->data; uint32_t window, per; @@ -225,7 +225,7 @@ static int wdt_sam0_install_timeout(struct device *dev, return -EINVAL; } -static int wdt_sam0_feed(struct device *dev, int channel_id) +static int wdt_sam0_feed(const struct device *dev, int channel_id) { struct wdt_sam0_dev_data *data = dev->data; @@ -250,7 +250,7 @@ static const struct wdt_driver_api wdt_sam0_api = { .feed = wdt_sam0_feed, }; -static int wdt_sam0_init(struct device *dev) +static int wdt_sam0_init(const struct device *dev) { #ifdef CONFIG_WDT_DISABLE_AT_BOOT /* Ignore any errors */ diff --git a/drivers/watchdog/wdt_wwdg_stm32.c b/drivers/watchdog/wdt_wwdg_stm32.c index df7778c7161c5d..a9486de4a06530 100644 --- a/drivers/watchdog/wdt_wwdg_stm32.c +++ b/drivers/watchdog/wdt_wwdg_stm32.c @@ -61,11 +61,11 @@ LOG_MODULE_REGISTER(wdt_wwdg_stm32); (ABS_DIFF_UINT(__TIMEOUT_GOLDEN__, __TIMEOUT__) < \ WWDG_TIMEOUT_ERROR_MARGIN) -static void wwdg_stm32_irq_config(struct device *dev); +static void wwdg_stm32_irq_config(const struct device *dev); -static uint32_t wwdg_stm32_get_pclk(struct device *dev) +static uint32_t wwdg_stm32_get_pclk(const struct device *dev) { - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); const struct wwdg_stm32_config *cfg = WWDG_STM32_CFG(dev); uint32_t pclk_rate; @@ -88,8 +88,9 @@ static uint32_t wwdg_stm32_get_pclk(struct device *dev) * @param counter The counter value. * @return The timeout calculated in microseconds. */ -static uint32_t wwdg_stm32_get_timeout(struct device *dev, uint32_t prescaler, - uint32_t counter) +static uint32_t wwdg_stm32_get_timeout(const struct device *dev, + uint32_t prescaler, + uint32_t counter) { uint32_t divider = WWDG_INTERNAL_DIVIDER * (1 << (prescaler >> 7)); float f_wwdg = (float)wwdg_stm32_get_pclk(dev) / divider; @@ -105,7 +106,8 @@ static uint32_t wwdg_stm32_get_timeout(struct device *dev, uint32_t prescaler, * @param prescaler Pointer to prescaler value. * @param counter Pointer to counter value. */ -static void wwdg_stm32_convert_timeout(struct device *dev, uint32_t timeout, +static void wwdg_stm32_convert_timeout(const struct device *dev, + uint32_t timeout, uint32_t *prescaler, uint32_t *counter) { @@ -135,7 +137,7 @@ static void wwdg_stm32_convert_timeout(struct device *dev, uint32_t timeout, } } -static int wwdg_stm32_setup(struct device *dev, uint8_t options) +static int wwdg_stm32_setup(const struct device *dev, uint8_t options) { WWDG_TypeDef *wwdg = WWDG_STM32_STRUCT(dev); @@ -162,7 +164,7 @@ static int wwdg_stm32_setup(struct device *dev, uint8_t options) return 0; } -static int wwdg_stm32_disable(struct device *dev) +static int wwdg_stm32_disable(const struct device *dev) { /* watchdog cannot be stopped once started unless SOC gets a reset */ ARG_UNUSED(dev); @@ -170,7 +172,7 @@ static int wwdg_stm32_disable(struct device *dev) return -EPERM; } -static int wwdg_stm32_install_timeout(struct device *dev, +static int wwdg_stm32_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *config) { struct wwdg_stm32_data *data = WWDG_STM32_DATA(dev); @@ -208,7 +210,7 @@ static int wwdg_stm32_install_timeout(struct device *dev, return 0; } -static int wwdg_stm32_feed(struct device *dev, int channel_id) +static int wwdg_stm32_feed(const struct device *dev, int channel_id) { WWDG_TypeDef *wwdg = WWDG_STM32_STRUCT(dev); struct wwdg_stm32_data *data = WWDG_STM32_DATA(dev); @@ -221,7 +223,7 @@ static int wwdg_stm32_feed(struct device *dev, int channel_id) void wwdg_stm32_isr(void *arg) { - struct device *const dev = (struct device *)arg; + const struct device *dev = (const struct device *)arg; struct wwdg_stm32_data *data = WWDG_STM32_DATA(dev); WWDG_TypeDef *wwdg = WWDG_STM32_STRUCT(dev); @@ -240,9 +242,9 @@ static const struct wdt_driver_api wwdg_stm32_api = { .feed = wwdg_stm32_feed, }; -static int wwdg_stm32_init(struct device *dev) +static int wwdg_stm32_init(const struct device *dev) { - struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); + const struct device *clk = device_get_binding(STM32_CLOCK_CONTROL_NAME); const struct wwdg_stm32_config *cfg = WWDG_STM32_CFG(dev); __ASSERT_NO_MSG(clk); @@ -272,7 +274,7 @@ DEVICE_AND_API_INIT(wwdg_stm32, DT_INST_LABEL(0), POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &wwdg_stm32_api); -static void wwdg_stm32_irq_config(struct device *dev) +static void wwdg_stm32_irq_config(const struct device *dev) { WWDG_TypeDef *wwdg = WWDG_STM32_STRUCT(dev); diff --git a/drivers/wifi/esp/esp.c b/drivers/wifi/esp/esp.c index 0343ff9572bee9..8170d8d32fd1f0 100644 --- a/drivers/wifi/esp/esp.c +++ b/drivers/wifi/esp/esp.c @@ -85,7 +85,7 @@ MODEM_CMD_DEFINE(on_cmd_error) } /* RX thread */ -static void esp_rx(struct device *dev) +static void esp_rx(const struct device *dev) { struct esp_data *data = dev->data; @@ -535,7 +535,7 @@ static void esp_mgmt_scan_work(struct k_work *work) dev->scan_cb = NULL; } -static int esp_mgmt_scan(struct device *dev, scan_result_cb_t cb) +static int esp_mgmt_scan(const struct device *dev, scan_result_cb_t cb) { struct esp_data *data = dev->data; @@ -598,7 +598,7 @@ static void esp_mgmt_connect_work(struct k_work *work) esp_flag_clear(dev, EDF_STA_CONNECTING); } -static int esp_mgmt_connect(struct device *dev, +static int esp_mgmt_connect(const struct device *dev, struct wifi_connect_req_params *params) { struct esp_data *data = dev->data; @@ -635,7 +635,7 @@ static int esp_mgmt_connect(struct device *dev, return 0; } -static int esp_mgmt_disconnect(struct device *dev) +static int esp_mgmt_disconnect(const struct device *dev) { struct esp_data *data = dev->data; int ret; @@ -647,7 +647,7 @@ static int esp_mgmt_disconnect(struct device *dev) return ret; } -static int esp_mgmt_ap_enable(struct device *dev, +static int esp_mgmt_ap_enable(const struct device *dev, struct wifi_connect_req_params *params) { char cmd[sizeof("AT+"_CWSAP"=\"\",\"\",xx,x") + WIFI_SSID_MAX_LEN + @@ -686,7 +686,7 @@ static int esp_mgmt_ap_enable(struct device *dev, return ret; } -static int esp_mgmt_ap_disable(struct device *dev) +static int esp_mgmt_ap_disable(const struct device *dev) { struct esp_data *data = dev->data; int ret; @@ -784,7 +784,7 @@ static void esp_reset(struct esp_data *dev) static void esp_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct esp_data *data = dev->data; net_if_flag_set(iface, NET_IF_NO_AUTO_START); @@ -802,7 +802,7 @@ static const struct net_wifi_mgmt_offload esp_api = { .ap_disable = esp_mgmt_ap_disable, }; -static int esp_init(struct device *dev) +static int esp_init(const struct device *dev) { struct esp_data *data = dev->data; int ret = 0; diff --git a/drivers/wifi/eswifi/eswifi.h b/drivers/wifi/eswifi/eswifi.h index 77b1767b50e835..3bcdbb94b76b2d 100644 --- a/drivers/wifi/eswifi/eswifi.h +++ b/drivers/wifi/eswifi/eswifi.h @@ -24,7 +24,7 @@ #define AT_RSP_DELIMITER_LEN 2 struct eswifi_gpio { - struct device *dev; + const struct device *dev; unsigned int pin; }; diff --git a/drivers/wifi/eswifi/eswifi_bus_spi.c b/drivers/wifi/eswifi/eswifi_bus_spi.c index f61daddae8c0b6..06c61c62db034a 100644 --- a/drivers/wifi/eswifi/eswifi_bus_spi.c +++ b/drivers/wifi/eswifi/eswifi_bus_spi.c @@ -24,7 +24,7 @@ K_KERNEL_STACK_MEMBER(eswifi_spi_poll_stack, ESWIFI_SPI_THREAD_STACK_SIZE); #define SPI_READ_CHUNK_SIZE 32 struct eswifi_spi_data { - struct device *spi_dev; + const struct device *spi_dev; struct eswifi_gpio csn; struct eswifi_gpio dr; struct k_thread poll_thread; diff --git a/drivers/wifi/eswifi/eswifi_core.c b/drivers/wifi/eswifi/eswifi_core.c index e013cb4ecf54d7..ebeed3e3f2cb09 100644 --- a/drivers/wifi/eswifi/eswifi_core.c +++ b/drivers/wifi/eswifi/eswifi_core.c @@ -410,7 +410,7 @@ static void eswifi_iface_init(struct net_if *iface) } -static int eswifi_mgmt_scan(struct device *dev, scan_result_cb_t cb) +static int eswifi_mgmt_scan(const struct device *dev, scan_result_cb_t cb) { struct eswifi_dev *eswifi = dev->data; @@ -427,7 +427,7 @@ static int eswifi_mgmt_scan(struct device *dev, scan_result_cb_t cb) return 0; } -static int eswifi_mgmt_disconnect(struct device *dev) +static int eswifi_mgmt_disconnect(const struct device *dev) { struct eswifi_dev *eswifi = dev->data; @@ -472,7 +472,7 @@ static int __eswifi_sta_config(struct eswifi_dev *eswifi, return 0; } -static int eswifi_mgmt_connect(struct device *dev, +static int eswifi_mgmt_connect(const struct device *dev, struct wifi_connect_req_params *params) { struct eswifi_dev *eswifi = dev->data; @@ -500,7 +500,7 @@ void eswifi_async_msg(struct eswifi_dev *eswifi, char *msg, size_t len) } #if defined(CONFIG_NET_IPV4) -static int eswifi_mgmt_ap_enable(struct device *dev, +static int eswifi_mgmt_ap_enable(const struct device *dev, struct wifi_connect_req_params *params) { struct eswifi_dev *eswifi = dev->data; @@ -599,7 +599,7 @@ static int eswifi_mgmt_ap_enable(struct device *dev, return err; } #else -static int eswifi_mgmt_ap_enable(struct device *dev, +static int eswifi_mgmt_ap_enable(const struct device *dev, struct wifi_connect_req_params *params) { LOG_ERR("IPv4 requested for AP mode"); @@ -607,7 +607,7 @@ static int eswifi_mgmt_ap_enable(struct device *dev, } #endif /* CONFIG_NET_IPV4 */ -static int eswifi_mgmt_ap_disable(struct device *dev) +static int eswifi_mgmt_ap_disable(const struct device *dev) { struct eswifi_dev *eswifi = dev->data; char cmd[] = "AE\r"; @@ -628,7 +628,7 @@ static int eswifi_mgmt_ap_disable(struct device *dev) return 0; } -static int eswifi_init(struct device *dev) +static int eswifi_init(const struct device *dev) { struct eswifi_dev *eswifi = dev->data; diff --git a/drivers/wifi/simplelink/simplelink.c b/drivers/wifi/simplelink/simplelink.c index d66b87f8ad7899..8ee553d29b63dc 100644 --- a/drivers/wifi/simplelink/simplelink.c +++ b/drivers/wifi/simplelink/simplelink.c @@ -137,7 +137,7 @@ static void simplelink_scan_work_handler(struct k_work *work) } } -static int simplelink_mgmt_scan(struct device *dev, scan_result_cb_t cb) +static int simplelink_mgmt_scan(const struct device *dev, scan_result_cb_t cb) { int err; int status; @@ -169,7 +169,7 @@ static int simplelink_mgmt_scan(struct device *dev, scan_result_cb_t cb) return status; } -static int simplelink_mgmt_connect(struct device *dev, +static int simplelink_mgmt_connect(const struct device *dev, struct wifi_connect_req_params *params) { int ret; @@ -179,7 +179,7 @@ static int simplelink_mgmt_connect(struct device *dev, return ret ? -EIO : ret; } -static int simplelink_mgmt_disconnect(struct device *dev) +static int simplelink_mgmt_disconnect(const struct device *dev) { int ret; @@ -269,7 +269,7 @@ static const struct net_wifi_mgmt_offload simplelink_api = { .disconnect = simplelink_mgmt_disconnect, }; -static int simplelink_init(struct device *dev) +static int simplelink_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/drivers/wifi/winc1500/wifi_winc1500.c b/drivers/wifi/winc1500/wifi_winc1500.c index 2407a0ecae0953..442d42e924afe3 100644 --- a/drivers/wifi/winc1500/wifi_winc1500.c +++ b/drivers/wifi/winc1500/wifi_winc1500.c @@ -957,7 +957,7 @@ static void winc1500_thread(void) } } -static int winc1500_mgmt_scan(struct device *dev, scan_result_cb_t cb) +static int winc1500_mgmt_scan(const struct device *dev, scan_result_cb_t cb) { if (w1500_data.scan_cb) { return -EALREADY; @@ -974,7 +974,7 @@ static int winc1500_mgmt_scan(struct device *dev, scan_result_cb_t cb) return 0; } -static int winc1500_mgmt_connect(struct device *dev, +static int winc1500_mgmt_connect(const struct device *dev, struct wifi_connect_req_params *params) { uint8_t ssid[M2M_MAX_SSID_LEN]; @@ -1020,7 +1020,7 @@ static int winc1500_mgmt_connect(struct device *dev, return 0; } -static int winc1500_mgmt_disconnect(struct device *device) +static int winc1500_mgmt_disconnect(const struct device *device) { if (!w1500_data.connected) { return -EALREADY; @@ -1055,7 +1055,7 @@ static const struct net_wifi_mgmt_offload winc1500_api = { .disconnect = winc1500_mgmt_disconnect, }; -static int winc1500_init(struct device *dev) +static int winc1500_init(const struct device *dev) { tstrWifiInitParam param = { .pfAppWifiCb = winc1500_wifi_cb, diff --git a/drivers/wifi/winc1500/wifi_winc1500_nm_bsp.c b/drivers/wifi/winc1500/wifi_winc1500_nm_bsp.c index 3fe1fd891c447d..a0d75755f8012e 100644 --- a/drivers/wifi/winc1500/wifi_winc1500_nm_bsp.c +++ b/drivers/wifi/winc1500/wifi_winc1500_nm_bsp.c @@ -15,7 +15,7 @@ struct winc1500_device winc1500; void (*isr_function)(void); -static inline void chip_isr(struct device *port, +static inline void chip_isr(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins) { diff --git a/drivers/wifi/winc1500/wifi_winc1500_nm_bsp_internal.h b/drivers/wifi/winc1500/wifi_winc1500_nm_bsp_internal.h index 1ea15d7c7aa3c1..847fabd3b76c39 100644 --- a/drivers/wifi/winc1500/wifi_winc1500_nm_bsp_internal.h +++ b/drivers/wifi/winc1500/wifi_winc1500_nm_bsp_internal.h @@ -30,14 +30,14 @@ enum winc1500_gpio_index { }; struct winc1500_gpio_configuration { - struct device *dev; + const struct device *dev; uint32_t pin; }; struct winc1500_device { struct winc1500_gpio_configuration *gpios; struct gpio_callback gpio_cb; - struct device *spi; + const struct device *spi; struct spi_config spi_cfg; }; diff --git a/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c b/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c index 7d3d00ff876359..619dc8242757ea 100644 --- a/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c +++ b/drivers/wifi/winc1500/wifi_winc1500_nm_bus_wrapper.c @@ -98,7 +98,7 @@ static int8_t spi_rw(uint8_t *mosi, uint8_t *miso, uint16_t size) struct winc1500_gpio_configuration *winc1500_configure_gpios(void) { - struct device *gpio_en, *gpio_irq, *gpio_reset; + const struct device *gpio_en, *gpio_irq, *gpio_reset; gpio_en = device_get_binding( DT_INST_GPIO_LABEL(0, enable_gpios)); diff --git a/include/audio/codec.h b/include/audio/codec.h index d8468b0631a149..677da302e8ba1b 100644 --- a/include/audio/codec.h +++ b/include/audio/codec.h @@ -116,12 +116,15 @@ typedef union { * For internal use only, skip these in public documentation. */ struct audio_codec_api { - int (*configure)(struct device *dev, struct audio_codec_cfg *cfg); - void (*start_output)(struct device *dev); - void (*stop_output)(struct device *dev); - int (*set_property)(struct device *dev, audio_property_t property, - audio_channel_t channel, audio_property_value_t val); - int (*apply_properties)(struct device *dev); + int (*configure)(const struct device *dev, + struct audio_codec_cfg *cfg); + void (*start_output)(const struct device *dev); + void (*stop_output)(const struct device *dev); + int (*set_property)(const struct device *dev, + audio_property_t property, + audio_channel_t channel, + audio_property_value_t val); + int (*apply_properties)(const struct device *dev); }; /** * @endcond @@ -138,8 +141,8 @@ struct audio_codec_api { * * @return 0 on success, negative error code on failure */ -static inline int audio_codec_configure(struct device *dev, - struct audio_codec_cfg *cfg) +static inline int audio_codec_configure(const struct device *dev, + struct audio_codec_cfg *cfg) { const struct audio_codec_api *api = (const struct audio_codec_api *)dev->api; @@ -156,7 +159,7 @@ static inline int audio_codec_configure(struct device *dev, * * @return none */ -static inline void audio_codec_start_output(struct device *dev) +static inline void audio_codec_start_output(const struct device *dev) { const struct audio_codec_api *api = (const struct audio_codec_api *)dev->api; @@ -173,7 +176,7 @@ static inline void audio_codec_start_output(struct device *dev) * * @return none */ -static inline void audio_codec_stop_output(struct device *dev) +static inline void audio_codec_stop_output(const struct device *dev) { const struct audio_codec_api *api = (const struct audio_codec_api *)dev->api; @@ -193,8 +196,10 @@ static inline void audio_codec_stop_output(struct device *dev) * * @return 0 on success, negative error code on failure */ -static inline int audio_codec_set_property(struct device *dev, audio_property_t property, - audio_channel_t channel, audio_property_value_t val) +static inline int audio_codec_set_property(const struct device *dev, + audio_property_t property, + audio_channel_t channel, + audio_property_value_t val) { const struct audio_codec_api *api = (const struct audio_codec_api *)dev->api; @@ -213,7 +218,7 @@ static inline int audio_codec_set_property(struct device *dev, audio_property_t * * @return 0 on success, negative error code on failure */ -static inline int audio_codec_apply_properties(struct device *dev) +static inline int audio_codec_apply_properties(const struct device *dev) { const struct audio_codec_api *api = (const struct audio_codec_api *)dev->api; diff --git a/include/audio/dmic.h b/include/audio/dmic.h index f10fef6959ead9..6da08d680d8bf1 100644 --- a/include/audio/dmic.h +++ b/include/audio/dmic.h @@ -167,9 +167,9 @@ struct dmic_cfg { * Function pointers for the DMIC driver operations */ struct _dmic_ops { - int (*configure)(struct device *dev, struct dmic_cfg *config); - int (*trigger)(struct device *dev, enum dmic_trigger cmd); - int (*read)(struct device *dev, uint8_t stream, void **buffer, + int (*configure)(const struct device *dev, struct dmic_cfg *config); + int (*trigger)(const struct device *dev, enum dmic_trigger cmd); + int (*read)(const struct device *dev, uint8_t stream, void **buffer, size_t *size, int32_t timeout); }; @@ -245,7 +245,8 @@ static inline uint32_t dmic_build_clk_skew_map(uint8_t pdm, uint8_t skew) * * @return 0 on success, a negative error code on failure */ -static inline int dmic_configure(struct device *dev, struct dmic_cfg *cfg) +static inline int dmic_configure(const struct device *dev, + struct dmic_cfg *cfg) { const struct _dmic_ops *api = (const struct _dmic_ops *)dev->api; @@ -263,7 +264,8 @@ static inline int dmic_configure(struct device *dev, struct dmic_cfg *cfg) * * @return 0 on success, a negative error code on failure */ -static inline int dmic_trigger(struct device *dev, enum dmic_trigger cmd) +static inline int dmic_trigger(const struct device *dev, + enum dmic_trigger cmd) { const struct _dmic_ops *api = (const struct _dmic_ops *)dev->api; @@ -286,8 +288,9 @@ static inline int dmic_trigger(struct device *dev, enum dmic_trigger cmd) * * @return 0 on success, a negative error code on failure */ -static inline int dmic_read(struct device *dev, uint8_t stream, void **buffer, - size_t *size, int32_t timeout) +static inline int dmic_read(const struct device *dev, uint8_t stream, + void **buffer, + size_t *size, int32_t timeout) { const struct _dmic_ops *api = (const struct _dmic_ops *)dev->api; diff --git a/include/canbus/isotp.h b/include/canbus/isotp.h index 1ee29a68e692f5..60ad12edceee82 100644 --- a/include/canbus/isotp.h +++ b/include/canbus/isotp.h @@ -155,7 +155,7 @@ struct isotp_recv_ctx; * @retval ISOTP_N_OK on success * @retval ISOTP_NO_FREE_FILTER if CAN device has no filters left. */ -int isotp_bind(struct isotp_recv_ctx *ctx, struct device *can_dev, +int isotp_bind(struct isotp_recv_ctx *ctx, const struct device *can_dev, const struct isotp_msg_id *rx_addr, const struct isotp_msg_id *tx_addr, const struct isotp_fc_opts *opts, @@ -235,7 +235,7 @@ int isotp_recv_net(struct isotp_recv_ctx *ctx, struct net_buf **buffer, * @retval ISOTP_N_OK on success * @retval ISOTP_N_* on error */ -int isotp_send(struct isotp_send_ctx *ctx, struct device *can_dev, +int isotp_send(struct isotp_send_ctx *ctx, const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -260,7 +260,7 @@ int isotp_send(struct isotp_send_ctx *ctx, struct device *can_dev, * @retval ISOTP_N_OK on success * @retval ISOTP_N_* on error */ -int isotp_send_ctx_buf(struct device *can_dev, +int isotp_send_ctx_buf(const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -285,7 +285,7 @@ int isotp_send_ctx_buf(struct device *can_dev, * @retval ISOTP_N_OK on success * @retval ISOTP_* on error */ -int isotp_send_net_ctx_buf(struct device *can_dev, +int isotp_send_net_ctx_buf(const struct device *can_dev, struct net_buf *data, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -315,7 +315,7 @@ int isotp_send_net_ctx_buf(struct device *can_dev, * @retval ISOTP_N_OK on success * @retval ISOTP_* on error */ -int isotp_send_buf(struct device *can_dev, +int isotp_send_buf(const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -333,7 +333,7 @@ struct isotp_callback { struct isotp_send_ctx { int filter_id; uint32_t error_nr; - struct device *can_dev; + const struct device *can_dev; union { struct net_buf *buf; struct { @@ -362,7 +362,7 @@ struct isotp_send_ctx { struct isotp_recv_ctx { int filter_id; - struct device *can_dev; + const struct device *can_dev; struct net_buf *buf; struct net_buf *act_frag; sys_snode_t alloc_node; diff --git a/include/console/tty.h b/include/console/tty.h index 3419d73667760b..4c75a60207c91b 100644 --- a/include/console/tty.h +++ b/include/console/tty.h @@ -16,7 +16,7 @@ extern "C" { #endif struct tty_serial { - struct device *uart_dev; + const struct device *uart_dev; struct k_sem rx_sem; uint8_t *rx_ringbuf; @@ -49,7 +49,7 @@ struct tty_serial { * * @return 0 on success, error code (<0) otherwise */ -int tty_init(struct tty_serial *tty, struct device *uart_dev); +int tty_init(struct tty_serial *tty, const struct device *uart_dev); /** * @brief Set receive timeout for tty device. diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index 1652ef455c1ea2..920ed948c6100f 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -40,18 +40,18 @@ /* The API a crypto driver should implement */ __subsystem struct crypto_driver_api { - int (*query_hw_caps)(struct device *dev); + int (*query_hw_caps)(const struct device *dev); /* Setup a crypto session */ - int (*begin_session)(struct device *dev, struct cipher_ctx *ctx, - enum cipher_algo algo, enum cipher_mode mode, - enum cipher_op op_type); + int (*begin_session)(const struct device *dev, struct cipher_ctx *ctx, + enum cipher_algo algo, enum cipher_mode mode, + enum cipher_op op_type); /* Tear down an established session */ - int (*free_session)(struct device *dev, struct cipher_ctx *ctx); + int (*free_session)(const struct device *dev, struct cipher_ctx *ctx); /* Register async crypto op completion callback with the driver */ - int (*crypto_async_callback_set)(struct device *dev, + int (*crypto_async_callback_set)(const struct device *dev, crypto_completion_cb cb); }; @@ -73,7 +73,7 @@ __subsystem struct crypto_driver_api { * * @return bitmask of supported options. */ -static inline int cipher_query_hwcaps(struct device *dev) +static inline int cipher_query_hwcaps(const struct device *dev) { struct crypto_driver_api *api; int tmp; @@ -113,7 +113,7 @@ static inline int cipher_query_hwcaps(struct device *dev) * * @return 0 on success, negative errno code on fail. */ -static inline int cipher_begin_session(struct device *dev, +static inline int cipher_begin_session(const struct device *dev, struct cipher_ctx *ctx, enum cipher_algo algo, enum cipher_mode mode, @@ -155,7 +155,7 @@ static inline int cipher_begin_session(struct device *dev, * * @return 0 on success, negative errno code on fail. */ -static inline int cipher_free_session(struct device *dev, +static inline int cipher_free_session(const struct device *dev, struct cipher_ctx *ctx) { struct crypto_driver_api *api; @@ -179,7 +179,7 @@ static inline int cipher_free_session(struct device *dev, * @return 0 on success, -ENOTSUP if the driver does not support async op, * negative errno code on other error. */ -static inline int cipher_callback_set(struct device *dev, +static inline int cipher_callback_set(const struct device *dev, crypto_completion_cb cb) { struct crypto_driver_api *api; diff --git a/include/crypto/cipher_structs.h b/include/crypto/cipher_structs.h index 16acb60b0385a4..fec7070c71ca11 100644 --- a/include/crypto/cipher_structs.h +++ b/include/crypto/cipher_structs.h @@ -128,7 +128,7 @@ struct cipher_ctx { /** The device driver instance this crypto context relates to. Will be * populated by the begin_session() API. */ - struct device *device; + const struct device *device; /** If the driver supports multiple simultaneously crypto sessions, this * will identify the specific driver state this crypto session relates diff --git a/include/device.h b/include/device.h index e25160455763cb..4a0061dc9f221c 100644 --- a/include/device.h +++ b/include/device.h @@ -169,7 +169,7 @@ extern "C" { */ #define DEVICE_DECLARE(name) static const struct device DEVICE_NAME_GET(name) -typedef void (*device_pm_cb)(struct device *dev, +typedef void (*device_pm_cb)(const struct device *dev, int status, void *context, void *arg); /** @@ -177,7 +177,7 @@ typedef void (*device_pm_cb)(struct device *dev, */ struct device_pm { /** Pointer to the device */ - struct device *dev; + const struct device *dev; /** Lock to synchronize the get/put operations */ struct k_sem lock; /** Device pm enable flag */ @@ -208,7 +208,7 @@ struct device { void * const data; #ifdef CONFIG_DEVICE_POWER_MANAGEMENT /** Power Management function */ - int (*device_pm_control)(struct device *dev, uint32_t command, + int (*device_pm_control)(const struct device *dev, uint32_t command, void *context, device_pm_cb cb, void *arg); /** Pointer to device instance power management data */ struct device_pm * const pm; @@ -227,7 +227,7 @@ struct device { * * @return pointer to device structure; NULL if not found or cannot be used. */ -__syscall struct device *device_get_binding(const char *name); +__syscall const struct device *device_get_binding(const char *name); /** @brief Get access to the static array of static devices. * @@ -237,7 +237,7 @@ __syscall struct device *device_get_binding(const char *name); * * @return the number of statically allocated devices. */ -size_t z_device_get_all_static(struct device **devices); +size_t z_device_get_all_static(const struct device * *devices); /** @brief Determine whether a device has been successfully initialized. * @@ -330,7 +330,7 @@ const char *device_pm_state_str(uint32_t state); * * @param busy_dev Pointer to device structure of the driver instance. */ -void device_busy_set(struct device *busy_dev); +void device_busy_set(const struct device *busy_dev); /** * @brief Indicate that the device has completed its transaction @@ -339,7 +339,7 @@ void device_busy_set(struct device *busy_dev); * * @param busy_dev Pointer to device structure of the driver instance. */ -void device_busy_clear(struct device *busy_dev); +void device_busy_clear(const struct device *busy_dev); #ifdef CONFIG_DEVICE_POWER_MANAGEMENT /* @@ -360,7 +360,7 @@ void device_busy_clear(struct device *busy_dev); * * @retval -ENOTSUP for all operations. */ -int device_pm_control_nop(struct device *unused_device, +int device_pm_control_nop(const struct device *unused_device, uint32_t unused_ctrl_command, void *unused_context, device_pm_cb cb, @@ -379,7 +379,7 @@ int device_pm_control_nop(struct device *unused_device, * @retval 0 If successful in queuing the request or changing the state. * @retval Errno Negative errno code if failure. Callback will not be called. */ -static inline int device_set_power_state(struct device *dev, +static inline int device_set_power_state(const struct device *dev, uint32_t device_power_state, device_pm_cb cb, void *arg) { @@ -401,7 +401,7 @@ static inline int device_set_power_state(struct device *dev, * @retval 0 If successful. * @retval Errno Negative errno code if failure. */ -static inline int device_get_power_state(struct device *dev, +static inline int device_get_power_state(const struct device *dev, uint32_t *device_power_state) { return dev->device_pm_control(dev, @@ -423,7 +423,8 @@ static inline int device_get_power_state(struct device *dev, * * @deprecated in 2.4 release, replace with z_device_get_all_static() */ -__deprecated static inline void device_list_get(struct device **device_list, int *device_count) +__deprecated static inline void device_list_get(const struct device * *device_list, + int *device_count) { *device_count = z_device_get_all_static(device_list); } @@ -450,7 +451,7 @@ int device_any_busy_check(void); * @retval 0 if the device is not busy * @retval -EBUSY if the device is busy */ -int device_busy_check(struct device *chk_dev); +int device_busy_check(const struct device *chk_dev); #ifdef CONFIG_DEVICE_IDLE_PM @@ -472,7 +473,7 @@ enum device_pm_fsm_state { * @param dev Pointer to device structure of the specific device driver * the caller is interested in. */ -void device_pm_enable(struct device *dev); +void device_pm_enable(const struct device *dev); /** * @brief Disable device idle PM @@ -483,7 +484,7 @@ void device_pm_enable(struct device *dev); * @param dev Pointer to device structure of the specific device driver * the caller is interested in. */ -void device_pm_disable(struct device *dev); +void device_pm_disable(const struct device *dev); /** * @brief Call device resume asynchronously based on usage count @@ -499,7 +500,7 @@ void device_pm_disable(struct device *dev); * pm signal mechanism to know the completion of resume operation. * @retval Errno Negative errno code if failure. */ -int device_pm_get(struct device *dev); +int device_pm_get(const struct device *dev); /** * @brief Call device resume synchronously based on usage count @@ -514,7 +515,7 @@ int device_pm_get(struct device *dev); * @retval 0 If successful. * @retval Errno Negative errno code if failure. */ -int device_pm_get_sync(struct device *dev); +int device_pm_get_sync(const struct device *dev); /** * @brief Call device suspend asynchronously based on usage count @@ -530,7 +531,7 @@ int device_pm_get_sync(struct device *dev); * signal mechanism to know the completion of suspend operation. * @retval Errno Negative errno code if failure. */ -int device_pm_put(struct device *dev); +int device_pm_put(const struct device *dev); /** * @brief Call device suspend synchronously based on usage count @@ -545,14 +546,14 @@ int device_pm_put(struct device *dev); * @retval 0 If successful. * @retval Errno Negative errno code if failure. */ -int device_pm_put_sync(struct device *dev); +int device_pm_put_sync(const struct device *dev); #else -static inline void device_pm_enable(struct device *dev) { } -static inline void device_pm_disable(struct device *dev) { } -static inline int device_pm_get(struct device *dev) { return -ENOTSUP; } -static inline int device_pm_get_sync(struct device *dev) { return -ENOTSUP; } -static inline int device_pm_put(struct device *dev) { return -ENOTSUP; } -static inline int device_pm_put_sync(struct device *dev) { return -ENOTSUP; } +static inline void device_pm_enable(const struct device *dev) { } +static inline void device_pm_disable(const struct device *dev) { } +static inline int device_pm_get(const struct device *dev) { return -ENOTSUP; } +static inline int device_pm_get_sync(const struct device *dev) { return -ENOTSUP; } +static inline int device_pm_put(const struct device *dev) { return -ENOTSUP; } +static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; } #endif #else #define device_pm_control_nop(...) NULL diff --git a/include/disk/disk_access.h b/include/disk/disk_access.h index 03fd14a94e10ed..bb250aabea6675 100644 --- a/include/disk/disk_access.h +++ b/include/disk/disk_access.h @@ -58,7 +58,7 @@ struct disk_info { const struct disk_operations *ops; /* Disk device associated to this disk. */ - struct device *dev; + const struct device *dev; }; struct disk_operations { diff --git a/include/display/cfb.h b/include/display/cfb.h index 96339fbbb63fbd..7c36ea150f40fa 100644 --- a/include/display/cfb.h +++ b/include/display/cfb.h @@ -88,7 +88,7 @@ struct cfb_font { * * @return 0 on success, negative value otherwise */ -int cfb_print(struct device *dev, char *str, uint16_t x, uint16_t y); +int cfb_print(const struct device *dev, char *str, uint16_t x, uint16_t y); /** * @brief Clear framebuffer. @@ -98,7 +98,7 @@ int cfb_print(struct device *dev, char *str, uint16_t x, uint16_t y); * * @return 0 on success, negative value otherwise */ -int cfb_framebuffer_clear(struct device *dev, bool clear_display); +int cfb_framebuffer_clear(const struct device *dev, bool clear_display); /** * @brief Invert Pixels. @@ -107,7 +107,7 @@ int cfb_framebuffer_clear(struct device *dev, bool clear_display); * * @return 0 on success, negative value otherwise */ -int cfb_framebuffer_invert(struct device *dev); +int cfb_framebuffer_invert(const struct device *dev); /** * @brief Finalize framebuffer and write it to display RAM, @@ -117,7 +117,7 @@ int cfb_framebuffer_invert(struct device *dev); * * @return 0 on success, negative value otherwise */ -int cfb_framebuffer_finalize(struct device *dev); +int cfb_framebuffer_finalize(const struct device *dev); /** * @brief Get display parameter. @@ -127,7 +127,8 @@ int cfb_framebuffer_finalize(struct device *dev); * * @return Display parameter value */ -int cfb_get_display_parameter(struct device *dev, enum cfb_display_param); +int cfb_get_display_parameter(const struct device *dev, + enum cfb_display_param); /** * @brief Set font. @@ -137,7 +138,7 @@ int cfb_get_display_parameter(struct device *dev, enum cfb_display_param); * * @return 0 on success, negative value otherwise */ -int cfb_framebuffer_set_font(struct device *dev, uint8_t idx); +int cfb_framebuffer_set_font(const struct device *dev, uint8_t idx); /** * @brief Get font size. @@ -149,7 +150,8 @@ int cfb_framebuffer_set_font(struct device *dev, uint8_t idx); * * @return 0 on success, negative value otherwise */ -int cfb_get_font_size(struct device *dev, uint8_t idx, uint8_t *width, uint8_t *height); +int cfb_get_font_size(const struct device *dev, uint8_t idx, uint8_t *width, + uint8_t *height); /** * @brief Get number of fonts. @@ -158,7 +160,7 @@ int cfb_get_font_size(struct device *dev, uint8_t idx, uint8_t *width, uint8_t * * * @return number of fonts */ -int cfb_get_numof_fonts(struct device *dev); +int cfb_get_numof_fonts(const struct device *dev); /** * @brief Initialize Character Framebuffer. @@ -167,7 +169,7 @@ int cfb_get_numof_fonts(struct device *dev); * * @return 0 on success, negative value otherwise */ -int cfb_framebuffer_init(struct device *dev); +int cfb_framebuffer_init(const struct device *dev); #ifdef __cplusplus } diff --git a/include/display/grove_lcd.h b/include/display/grove_lcd.h index 60eb411eff48d0..cb357e450f6b32 100644 --- a/include/display/grove_lcd.h +++ b/include/display/grove_lcd.h @@ -34,7 +34,7 @@ extern "C" { * @param data the ASCII text to display * @param size the length of the text in bytes */ -void glcd_print(struct device *port, char *data, uint32_t size); +void glcd_print(const struct device *port, char *data, uint32_t size); /** @@ -44,14 +44,14 @@ void glcd_print(struct device *port, char *data, uint32_t size); * @param col the column for the cursor to be moved to (0-15) * @param row the row it should be moved to (0 or 1) */ -void glcd_cursor_pos_set(struct device *port, uint8_t col, uint8_t row); +void glcd_cursor_pos_set(const struct device *port, uint8_t col, uint8_t row); /** * @brief Clear the current display * * @param port Pointer to device structure for driver instance. */ -void glcd_clear(struct device *port); +void glcd_clear(const struct device *port); /* Defines for the GLCD_CMD_DISPLAY_SWITCH options */ #define GLCD_DS_DISPLAY_ON (1 << 2) @@ -71,7 +71,7 @@ void glcd_clear(struct device *port); * @param opt An 8bit bitmask of GLCD_DS_* options. * */ -void glcd_display_state_set(struct device *port, uint8_t opt); +void glcd_display_state_set(const struct device *port, uint8_t opt); /** * @brief return the display feature set associated with the device @@ -80,7 +80,7 @@ void glcd_display_state_set(struct device *port, uint8_t opt); * * @return the display feature set associated with the device. */ -uint8_t glcd_display_state_get(struct device *port); +uint8_t glcd_display_state_get(const struct device *port); /* Defines for the GLCD_CMD_INPUT_SET to change text direction */ #define GLCD_IS_SHIFT_INCREMENT (1 << 1) @@ -97,7 +97,7 @@ uint8_t glcd_display_state_get(struct device *port); * @param opt A bitmask of GLCD_IS_* options * */ -void glcd_input_state_set(struct device *port, uint8_t opt); +void glcd_input_state_set(const struct device *port, uint8_t opt); /** * @brief return the input set associated with the device @@ -106,7 +106,7 @@ void glcd_input_state_set(struct device *port, uint8_t opt); * * @return the input set associated with the device. */ -uint8_t glcd_input_state_get(struct device *port); +uint8_t glcd_input_state_get(const struct device *port); /* Defines for the LCD_FUNCTION_SET */ #define GLCD_FS_8BIT_MODE (1 << 4) @@ -125,7 +125,7 @@ uint8_t glcd_input_state_get(struct device *port); * of the display as per needed. Controlling things like the number of rows, * dot size, and text display quality. */ -void glcd_function_set(struct device *port, uint8_t opt); +void glcd_function_set(const struct device *port, uint8_t opt); /** * @brief return the function set associated with the device @@ -134,7 +134,7 @@ void glcd_function_set(struct device *port, uint8_t opt); * * @return the function features set associated with the device. */ -uint8_t glcd_function_get(struct device *port); +uint8_t glcd_function_get(const struct device *port); /* Available color selections */ @@ -147,7 +147,7 @@ uint8_t glcd_function_get(struct device *port); * @param port Pointer to device structure for driver instance. * @param color One of the predefined color options */ -void glcd_color_select(struct device *port, uint8_t color); +void glcd_color_select(const struct device *port, uint8_t color); /** @@ -158,7 +158,8 @@ void glcd_color_select(struct device *port, uint8_t color); * @param g A numeric value for the green color (max is 255) * @param b A numeric value for the blue color (max is 255) */ -void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b); +void glcd_color_set(const struct device *port, uint8_t r, uint8_t g, + uint8_t b); /** @@ -168,7 +169,7 @@ void glcd_color_set(struct device *port, uint8_t r, uint8_t g, uint8_t b); * * @return Returns 0 if all passes */ -int glcd_initialize(struct device *port); +int glcd_initialize(const struct device *port); /** diff --git a/include/drivers/adc.h b/include/drivers/adc.h index 23210a588a6676..314384b9eb8385 100644 --- a/include/drivers/adc.h +++ b/include/drivers/adc.h @@ -224,10 +224,9 @@ enum adc_action { * * @returns Action to be performed by the driver. See @ref adc_action. */ -typedef enum adc_action (*adc_sequence_callback)( - struct device *dev, - const struct adc_sequence *sequence, - uint16_t sampling_index); +typedef enum adc_action (*adc_sequence_callback)(const struct device *dev, + const struct adc_sequence *sequence, + uint16_t sampling_index); /** * @brief Structure defining additional options for an ADC sampling sequence. @@ -327,14 +326,14 @@ struct adc_sequence { * @brief Type definition of ADC API function for configuring a channel. * See adc_channel_setup() for argument descriptions. */ -typedef int (*adc_api_channel_setup)(struct device *dev, +typedef int (*adc_api_channel_setup)(const struct device *dev, const struct adc_channel_cfg *channel_cfg); /** * @brief Type definition of ADC API function for setting a read request. * See adc_read() for argument descriptions. */ -typedef int (*adc_api_read)(struct device *dev, +typedef int (*adc_api_read)(const struct device *dev, const struct adc_sequence *sequence); #ifdef CONFIG_ADC_ASYNC @@ -343,7 +342,7 @@ typedef int (*adc_api_read)(struct device *dev, * read request. * See adc_read_async() for argument descriptions. */ -typedef int (*adc_api_read_async)(struct device *dev, +typedef int (*adc_api_read_async)(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async); #endif @@ -374,11 +373,11 @@ __subsystem struct adc_driver_api { * @retval 0 On success. * @retval -EINVAL If a parameter with an invalid value has been provided. */ -__syscall int adc_channel_setup(struct device *dev, +__syscall int adc_channel_setup(const struct device *dev, const struct adc_channel_cfg *channel_cfg); -static inline int z_impl_adc_channel_setup(struct device *dev, - const struct adc_channel_cfg *channel_cfg) +static inline int z_impl_adc_channel_setup(const struct device *dev, + const struct adc_channel_cfg *channel_cfg) { const struct adc_driver_api *api = (const struct adc_driver_api *)dev->api; @@ -407,10 +406,10 @@ static inline int z_impl_adc_channel_setup(struct device *dev, * in the buffer, but at least some of them were taken with * an extra delay compared to what was scheduled. */ -__syscall int adc_read(struct device *dev, +__syscall int adc_read(const struct device *dev, const struct adc_sequence *sequence); -static inline int z_impl_adc_read(struct device *dev, +static inline int z_impl_adc_read(const struct device *dev, const struct adc_sequence *sequence) { const struct adc_driver_api *api = @@ -436,12 +435,12 @@ static inline int z_impl_adc_read(struct device *dev, * @returns 0 on success, negative error code otherwise. * */ -__syscall int adc_read_async(struct device *dev, +__syscall int adc_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async); -static inline int z_impl_adc_read_async(struct device *dev, +static inline int z_impl_adc_read_async(const struct device *dev, const struct adc_sequence *sequence, struct k_poll_signal *async) { @@ -461,7 +460,7 @@ static inline int z_impl_adc_read_async(struct device *dev, * @return a positive value is the reference voltage value. Returns * zero if reference voltage information is not available. */ -static inline uint16_t adc_ref_internal(struct device *dev) +static inline uint16_t adc_ref_internal(const struct device *dev) { const struct adc_driver_api *api = (const struct adc_driver_api *)dev->api; diff --git a/include/drivers/adc/lmp90xxx.h b/include/drivers/adc/lmp90xxx.h index f00b216c2cc389..44308e272c95d9 100644 --- a/include/drivers/adc/lmp90xxx.h +++ b/include/drivers/adc/lmp90xxx.h @@ -13,25 +13,30 @@ /* LMP90xxx supports GPIO D0..D6 */ #define LMP90XXX_GPIO_MAX 6 -int lmp90xxx_gpio_set_output(struct device *dev, uint8_t pin); +int lmp90xxx_gpio_set_output(const struct device *dev, uint8_t pin); -int lmp90xxx_gpio_set_input(struct device *dev, uint8_t pin); +int lmp90xxx_gpio_set_input(const struct device *dev, uint8_t pin); -int lmp90xxx_gpio_set_pin_value(struct device *dev, uint8_t pin, bool value); +int lmp90xxx_gpio_set_pin_value(const struct device *dev, uint8_t pin, + bool value); -int lmp90xxx_gpio_get_pin_value(struct device *dev, uint8_t pin, bool *value); +int lmp90xxx_gpio_get_pin_value(const struct device *dev, uint8_t pin, + bool *value); -int lmp90xxx_gpio_port_get_raw(struct device *dev, gpio_port_value_t *value); +int lmp90xxx_gpio_port_get_raw(const struct device *dev, + gpio_port_value_t *value); -int lmp90xxx_gpio_port_set_masked_raw(struct device *dev, +int lmp90xxx_gpio_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask, gpio_port_value_t value); -int lmp90xxx_gpio_port_set_bits_raw(struct device *dev, gpio_port_pins_t pins); +int lmp90xxx_gpio_port_set_bits_raw(const struct device *dev, + gpio_port_pins_t pins); -int lmp90xxx_gpio_port_clear_bits_raw(struct device *dev, +int lmp90xxx_gpio_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins); -int lmp90xxx_gpio_port_toggle_bits(struct device *dev, gpio_port_pins_t pins); +int lmp90xxx_gpio_port_toggle_bits(const struct device *dev, + gpio_port_pins_t pins); #endif /* ZEPHYR_INCLUDE_DRIVERS_ADC_LMP90XXX_H_ */ diff --git a/include/drivers/bluetooth/hci_driver.h b/include/drivers/bluetooth/hci_driver.h index f2520dfc1058b2..ecdf4925653f62 100644 --- a/include/drivers/bluetooth/hci_driver.h +++ b/include/drivers/bluetooth/hci_driver.h @@ -208,7 +208,7 @@ int bt_hci_driver_register(const struct bt_hci_driver *drv); * * @return 0 on success, negative error value on failure */ -int bt_hci_transport_setup(struct device *dev); +int bt_hci_transport_setup(const struct device *dev); /** Allocate an HCI event buffer. * diff --git a/include/drivers/can.h b/include/drivers/can.h index 532610691b891e..c6b13edbc626a9 100644 --- a/include/drivers/can.h +++ b/include/drivers/can.h @@ -265,29 +265,32 @@ typedef void (*can_rx_callback_t)(struct zcan_frame *msg, void *arg); typedef void(*can_state_change_isr_t)(enum can_state state, struct can_bus_err_cnt err_cnt); -typedef int (*can_configure_t)(struct device *dev, enum can_mode mode, +typedef int (*can_configure_t)(const struct device *dev, enum can_mode mode, uint32_t bitrate); -typedef int (*can_send_t)(struct device *dev, const struct zcan_frame *msg, +typedef int (*can_send_t)(const struct device *dev, + const struct zcan_frame *msg, k_timeout_t timeout, can_tx_callback_t callback_isr, void *callback_arg); -typedef int (*can_attach_msgq_t)(struct device *dev, struct k_msgq *msg_q, +typedef int (*can_attach_msgq_t)(const struct device *dev, + struct k_msgq *msg_q, const struct zcan_filter *filter); -typedef int (*can_attach_isr_t)(struct device *dev, can_rx_callback_t isr, +typedef int (*can_attach_isr_t)(const struct device *dev, + can_rx_callback_t isr, void *callback_arg, const struct zcan_filter *filter); -typedef void (*can_detach_t)(struct device *dev, int filter_id); +typedef void (*can_detach_t)(const struct device *dev, int filter_id); -typedef int (*can_recover_t)(struct device *dev, k_timeout_t timeout); +typedef int (*can_recover_t)(const struct device *dev, k_timeout_t timeout); -typedef enum can_state (*can_get_state_t)(struct device *dev, +typedef enum can_state (*can_get_state_t)(const struct device *dev, struct can_bus_err_cnt *err_cnt); -typedef void(*can_register_state_change_isr_t)(struct device *dev, +typedef void(*can_register_state_change_isr_t)(const struct device *dev, can_state_change_isr_t isr); #ifndef CONFIG_CAN_WORKQ_FRAMES_BUF_CNT @@ -343,15 +346,15 @@ __subsystem struct can_driver_api { * @retval 0 If successful. * @retval CAN_TX_* on failure. */ -__syscall int can_send(struct device *dev, const struct zcan_frame *msg, +__syscall int can_send(const struct device *dev, const struct zcan_frame *msg, k_timeout_t timeout, can_tx_callback_t callback_isr, void *callback_arg); -static inline int z_impl_can_send(struct device *dev, - const struct zcan_frame *msg, - k_timeout_t timeout, - can_tx_callback_t callback_isr, - void *callback_arg) +static inline int z_impl_can_send(const struct device *dev, + const struct zcan_frame *msg, + k_timeout_t timeout, + can_tx_callback_t callback_isr, + void *callback_arg) { const struct can_driver_api *api = (const struct can_driver_api *)dev->api; @@ -379,7 +382,8 @@ static inline int z_impl_can_send(struct device *dev, * @retval -EIO General input / output error. * @retval -EINVAL if length > 8. */ -static inline int can_write(struct device *dev, const uint8_t *data, uint8_t length, +static inline int can_write(const struct device *dev, const uint8_t *data, + uint8_t length, uint32_t id, enum can_rtr rtr, k_timeout_t timeout) { struct zcan_frame msg; @@ -426,7 +430,7 @@ static inline int can_write(struct device *dev, const uint8_t *data, uint8_t len * @retval filter_id on success. * @retval CAN_NO_FREE_FILTER if there is no filter left. */ -int can_attach_workq(struct device *dev, struct k_work_q *work_q, +int can_attach_workq(const struct device *dev, struct k_work_q *work_q, struct zcan_work *work, can_rx_callback_t callback, void *callback_arg, const struct zcan_filter *filter); @@ -450,7 +454,7 @@ int can_attach_workq(struct device *dev, struct k_work_q *work_q, * @retval filter_id on success. * @retval CAN_NO_FREE_FILTER if there is no filter left. */ -__syscall int can_attach_msgq(struct device *dev, struct k_msgq *msg_q, +__syscall int can_attach_msgq(const struct device *dev, struct k_msgq *msg_q, const struct zcan_filter *filter); /** @@ -472,7 +476,7 @@ __syscall int can_attach_msgq(struct device *dev, struct k_msgq *msg_q, * @retval filter_id on success. * @retval CAN_NO_FREE_FILTER if there is no filter left. */ -static inline int can_attach_isr(struct device *dev, +static inline int can_attach_isr(const struct device *dev, can_rx_callback_t isr, void *callback_arg, const struct zcan_filter *filter) @@ -494,9 +498,9 @@ static inline int can_attach_isr(struct device *dev, * * @retval none */ -__syscall void can_detach(struct device *dev, int filter_id); +__syscall void can_detach(const struct device *dev, int filter_id); -static inline void z_impl_can_detach(struct device *dev, int filter_id) +static inline void z_impl_can_detach(const struct device *dev, int filter_id) { const struct can_driver_api *api = (const struct can_driver_api *)dev->api; @@ -514,11 +518,12 @@ static inline void z_impl_can_detach(struct device *dev, int filter_id) * @retval 0 If successful. * @retval -EIO General input / output error, failed to configure device. */ -__syscall int can_configure(struct device *dev, enum can_mode mode, +__syscall int can_configure(const struct device *dev, enum can_mode mode, uint32_t bitrate); -static inline int z_impl_can_configure(struct device *dev, enum can_mode mode, - uint32_t bitrate) +static inline int z_impl_can_configure(const struct device *dev, + enum can_mode mode, + uint32_t bitrate) { const struct can_driver_api *api = (const struct can_driver_api *)dev->api; @@ -536,11 +541,11 @@ static inline int z_impl_can_configure(struct device *dev, enum can_mode mode, * * @retval state */ -__syscall enum can_state can_get_state(struct device *dev, +__syscall enum can_state can_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt); static inline -enum can_state z_impl_can_get_state(struct device *dev, +enum can_state z_impl_can_get_state(const struct device *dev, struct can_bus_err_cnt *err_cnt) { const struct can_driver_api *api = @@ -561,9 +566,10 @@ enum can_state z_impl_can_get_state(struct device *dev, * @retval CAN_TIMEOUT on timeout. */ #ifndef CONFIG_CAN_AUTO_BUS_OFF_RECOVERY -__syscall int can_recover(struct device *dev, k_timeout_t timeout); +__syscall int can_recover(const struct device *dev, k_timeout_t timeout); -static inline int z_impl_can_recover(struct device *dev, k_timeout_t timeout) +static inline int z_impl_can_recover(const struct device *dev, + k_timeout_t timeout) { const struct can_driver_api *api = (const struct can_driver_api *)dev->api; @@ -572,7 +578,8 @@ static inline int z_impl_can_recover(struct device *dev, k_timeout_t timeout) } #else /* This implementation prevents inking errors for auto recovery */ -static inline int z_impl_can_recover(struct device *dev, k_timeout_t timeout) +static inline int z_impl_can_recover(const struct device *dev, + k_timeout_t timeout) { return 0; } @@ -588,7 +595,7 @@ static inline int z_impl_can_recover(struct device *dev, k_timeout_t timeout) * @param isr Pointer to ISR */ static inline -void can_register_state_change_isr(struct device *dev, +void can_register_state_change_isr(const struct device *dev, can_state_change_isr_t isr) { const struct can_driver_api *api = diff --git a/include/drivers/clock_control.h b/include/drivers/clock_control.h index 08f8bf2c36bc7f..c9cd1a9a63b2d1 100644 --- a/include/drivers/clock_control.h +++ b/include/drivers/clock_control.h @@ -72,7 +72,7 @@ typedef void *clock_control_subsys_t; * @param subsys Opaque data representing the clock. * @param user_data User data. */ -typedef void (*clock_control_cb_t)(struct device *dev, +typedef void (*clock_control_cb_t)(const struct device *dev, clock_control_subsys_t subsys, void *user_data); @@ -100,19 +100,19 @@ struct clock_control_async_data { void *user_data; }; -typedef int (*clock_control)(struct device *dev, clock_control_subsys_t sys); +typedef int (*clock_control)(const struct device *dev, + clock_control_subsys_t sys); -typedef int (*clock_control_get)(struct device *dev, +typedef int (*clock_control_get)(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate); -typedef int (*clock_control_async_on_fn)(struct device *dev, - clock_control_subsys_t sys, - struct clock_control_async_data *data); +typedef int (*clock_control_async_on_fn)(const struct device *dev, + clock_control_subsys_t sys, + struct clock_control_async_data *data); -typedef enum clock_control_status (*clock_control_get_status_fn)( - struct device *dev, - clock_control_subsys_t sys); +typedef enum clock_control_status (*clock_control_get_status_fn)(const struct device *dev, + clock_control_subsys_t sys); struct clock_control_driver_api { clock_control on; @@ -135,7 +135,7 @@ struct clock_control_driver_api { * @param sys Opaque data representing the clock. * @return 0 on success, negative errno on failure. */ -static inline int clock_control_on(struct device *dev, +static inline int clock_control_on(const struct device *dev, clock_control_subsys_t sys) { const struct clock_control_driver_api *api = @@ -154,7 +154,7 @@ static inline int clock_control_on(struct device *dev, * @param sys Opaque data representing the clock * @return 0 on success, negative errno on failure. */ -static inline int clock_control_off(struct device *dev, +static inline int clock_control_off(const struct device *dev, clock_control_subsys_t sys) { const struct clock_control_driver_api *api = @@ -181,7 +181,7 @@ static inline int clock_control_off(struct device *dev, * @retval -EBUSY if same request already scheduled and not yet completed. * @retval -ENOTSUP if not supported. */ -static inline int clock_control_async_on(struct device *dev, +static inline int clock_control_async_on(const struct device *dev, clock_control_subsys_t sys, struct clock_control_async_data *data) { @@ -203,9 +203,8 @@ static inline int clock_control_async_on(struct device *dev, * * @return Status. */ -static inline enum clock_control_status clock_control_get_status( - struct device *dev, - clock_control_subsys_t sys) +static inline enum clock_control_status clock_control_get_status(const struct device *dev, + clock_control_subsys_t sys) { const struct clock_control_driver_api *api = (const struct clock_control_driver_api *)dev->api; @@ -224,7 +223,7 @@ static inline enum clock_control_status clock_control_get_status( * @param sys A pointer to an opaque data representing the sub-system * @param[out] rate Subsystem clock rate */ -static inline int clock_control_get_rate(struct device *dev, +static inline int clock_control_get_rate(const struct device *dev, clock_control_subsys_t sys, uint32_t *rate) { diff --git a/include/drivers/console/ipm_console.h b/include/drivers/console/ipm_console.h index 96002d30b436d1..d58fdb01e07c16 100644 --- a/include/drivers/console/ipm_console.h +++ b/include/drivers/console/ipm_console.h @@ -71,7 +71,7 @@ struct ipm_console_receiver_runtime_data { struct k_sem sem; /** pointer to the bound low-level IPM device */ - struct device *ipm_device; + const struct device *ipm_device; /** Indicator that the channel is temporarily disabled due to * full buffer @@ -94,11 +94,11 @@ struct ipm_console_sender_config_info { }; #if CONFIG_IPM_CONSOLE_RECEIVER -int ipm_console_receiver_init(struct device *d); +int ipm_console_receiver_init(const struct device *d); #endif #if CONFIG_IPM_CONSOLE_SENDER -int ipm_console_sender_init(struct device *d); +int ipm_console_sender_init(const struct device *d); #endif #ifdef __cplusplus diff --git a/include/drivers/console/uart_mux.h b/include/drivers/console/uart_mux.h index 1b697f6fc76a60..ee989c0829f958 100644 --- a/include/drivers/console/uart_mux.h +++ b/include/drivers/console/uart_mux.h @@ -39,7 +39,8 @@ struct gsm_dlci; * @param connected True if DLCI is connected, false otherwise. * @param user_data Arbitrary user data. */ -typedef void (*uart_mux_attach_cb_t)(struct device *mux, int dlci_address, +typedef void (*uart_mux_attach_cb_t)(const struct device *mux, + int dlci_address, bool connected, void *user_data); /** @brief UART mux driver API structure. */ @@ -55,7 +56,7 @@ __subsystem struct uart_mux_driver_api { * Attach the mux to this UART. The API will call the callback after * the DLCI is created or not. */ - int (*attach)(struct device *mux, struct device *uart, + int (*attach)(const struct device *mux, const struct device *uart, int dlci_address, uart_mux_attach_cb_t cb, void *user_data); }; @@ -72,7 +73,8 @@ __subsystem struct uart_mux_driver_api { * @retval 0 No errors, the attachment was successful * @retval <0 Error */ -static inline int uart_mux_attach(struct device *mux, struct device *uart, +static inline int uart_mux_attach(const struct device *mux, + const struct device *uart, int dlci_address, uart_mux_attach_cb_t cb, void *user_data) { @@ -89,7 +91,7 @@ static inline int uart_mux_attach(struct device *mux, struct device *uart, * * @return UART device if found, NULL otherwise */ -__syscall struct device *uart_mux_find(int dlci_address); +__syscall const struct device *uart_mux_find(int dlci_address); /** * @brief Allocate muxing UART device. @@ -102,7 +104,7 @@ __syscall struct device *uart_mux_find(int dlci_address); * @retval device New UART device that will automatically mux data sent to it. * @retval NULL if error */ -struct device *uart_mux_alloc(void); +const struct device *uart_mux_alloc(void); /** * @typedef uart_mux_cb_t @@ -113,7 +115,8 @@ struct device *uart_mux_alloc(void); * @param dlci_address DLCI channel id this UART is muxed * @param user_data A valid pointer to user data or NULL */ -typedef void (*uart_mux_cb_t)(struct device *uart, struct device *dev, +typedef void (*uart_mux_cb_t)(const struct device *uart, + const struct device *dev, int dlci_address, void *user_data); /** diff --git a/include/drivers/counter.h b/include/drivers/counter.h index 415c35a95a0c0d..b47e305cc5a0b0 100644 --- a/include/drivers/counter.h +++ b/include/drivers/counter.h @@ -105,7 +105,7 @@ extern "C" { * @param ticks Counter value that triggered the alarm. * @param user_data User data. */ -typedef void (*counter_alarm_callback_t)(struct device *dev, +typedef void (*counter_alarm_callback_t)(const struct device *dev, uint8_t chan_id, uint32_t ticks, void *user_data); @@ -135,7 +135,8 @@ struct counter_alarm_cfg { * @param dev Pointer to the device structure for the driver instance. * @param user_data User data provided in @ref counter_set_top_value. */ -typedef void (*counter_top_callback_t)(struct device *dev, void *user_data); +typedef void (*counter_top_callback_t)(const struct device *dev, + void *user_data); /** @brief Top value configuration structure. * @@ -169,19 +170,24 @@ struct counter_config_info { uint8_t channels; }; -typedef int (*counter_api_start)(struct device *dev); -typedef int (*counter_api_stop)(struct device *dev); -typedef int (*counter_api_get_value)(struct device *dev, uint32_t *ticks); -typedef int (*counter_api_set_alarm)(struct device *dev, uint8_t chan_id, - const struct counter_alarm_cfg *alarm_cfg); -typedef int (*counter_api_cancel_alarm)(struct device *dev, uint8_t chan_id); -typedef int (*counter_api_set_top_value)(struct device *dev, +typedef int (*counter_api_start)(const struct device *dev); +typedef int (*counter_api_stop)(const struct device *dev); +typedef int (*counter_api_get_value)(const struct device *dev, + uint32_t *ticks); +typedef int (*counter_api_set_alarm)(const struct device *dev, + uint8_t chan_id, + const struct counter_alarm_cfg *alarm_cfg); +typedef int (*counter_api_cancel_alarm)(const struct device *dev, + uint8_t chan_id); +typedef int (*counter_api_set_top_value)(const struct device *dev, const struct counter_top_cfg *cfg); -typedef uint32_t (*counter_api_get_pending_int)(struct device *dev); -typedef uint32_t (*counter_api_get_top_value)(struct device *dev); -typedef uint32_t (*counter_api_get_max_relative_alarm)(struct device *dev); -typedef uint32_t (*counter_api_get_guard_period)(struct device *dev, uint32_t flags); -typedef int (*counter_api_set_guard_period)(struct device *dev, uint32_t ticks, +typedef uint32_t (*counter_api_get_pending_int)(const struct device *dev); +typedef uint32_t (*counter_api_get_top_value)(const struct device *dev); +typedef uint32_t (*counter_api_get_max_relative_alarm)(const struct device *dev); +typedef uint32_t (*counter_api_get_guard_period)(const struct device *dev, + uint32_t flags); +typedef int (*counter_api_set_guard_period)(const struct device *dev, + uint32_t ticks, uint32_t flags); __subsystem struct counter_driver_api { @@ -315,9 +321,9 @@ static inline uint32_t z_impl_counter_get_max_top_value(const struct device *dev * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int counter_start(struct device *dev); +__syscall int counter_start(const struct device *dev); -static inline int z_impl_counter_start(struct device *dev) +static inline int z_impl_counter_start(const struct device *dev) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -334,9 +340,9 @@ static inline int z_impl_counter_start(struct device *dev) * @retval -ENOTSUP if the device doesn't support stopping the * counter. */ -__syscall int counter_stop(struct device *dev); +__syscall int counter_stop(const struct device *dev); -static inline int z_impl_counter_stop(struct device *dev) +static inline int z_impl_counter_stop(const struct device *dev) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -352,9 +358,10 @@ static inline int z_impl_counter_stop(struct device *dev) * @retval 0 If successful. * @retval Negative error code on failure getting the counter value */ -__syscall int counter_get_value(struct device *dev, uint32_t *ticks); +__syscall int counter_get_value(const struct device *dev, uint32_t *ticks); -static inline int z_impl_counter_get_value(struct device *dev, uint32_t *ticks) +static inline int z_impl_counter_get_value(const struct device *dev, + uint32_t *ticks) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -381,11 +388,13 @@ static inline int z_impl_counter_get_value(struct device *dev, uint32_t *ticks) * @retval -EINVAL if alarm settings are invalid. * @retval -ETIME if absolute alarm was set too late. */ -__syscall int counter_set_channel_alarm(struct device *dev, uint8_t chan_id, - const struct counter_alarm_cfg *alarm_cfg); +__syscall int counter_set_channel_alarm(const struct device *dev, + uint8_t chan_id, + const struct counter_alarm_cfg *alarm_cfg); -static inline int z_impl_counter_set_channel_alarm(struct device *dev, - uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) +static inline int z_impl_counter_set_channel_alarm(const struct device *dev, + uint8_t chan_id, + const struct counter_alarm_cfg *alarm_cfg) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -409,9 +418,10 @@ static inline int z_impl_counter_set_channel_alarm(struct device *dev, * @retval -ENOTSUP if request is not supported or the counter was not started * yet. */ -__syscall int counter_cancel_channel_alarm(struct device *dev, uint8_t chan_id); +__syscall int counter_cancel_channel_alarm(const struct device *dev, + uint8_t chan_id); -static inline int z_impl_counter_cancel_channel_alarm(struct device *dev, +static inline int z_impl_counter_cancel_channel_alarm(const struct device *dev, uint8_t chan_id) { const struct counter_driver_api *api = @@ -448,10 +458,10 @@ static inline int z_impl_counter_cancel_channel_alarm(struct device *dev, * @retval -ETIME if @ref COUNTER_TOP_CFG_DONT_RESET was set and new top value * is smaller than current counter value (counter counting up). */ -__syscall int counter_set_top_value(struct device *dev, +__syscall int counter_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg); -static inline int z_impl_counter_set_top_value(struct device *dev, +static inline int z_impl_counter_set_top_value(const struct device *dev, const struct counter_top_cfg *cfg) { @@ -478,9 +488,9 @@ static inline int z_impl_counter_set_top_value(struct device *dev, * @retval 1 if any counter interrupt is pending. * @retval 0 if no counter interrupt is pending. */ -__syscall int counter_get_pending_int(struct device *dev); +__syscall int counter_get_pending_int(const struct device *dev); -static inline int z_impl_counter_get_pending_int(struct device *dev) +static inline int z_impl_counter_get_pending_int(const struct device *dev) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -495,9 +505,9 @@ static inline int z_impl_counter_get_pending_int(struct device *dev) * * @return Top value. */ -__syscall uint32_t counter_get_top_value(struct device *dev); +__syscall uint32_t counter_get_top_value(const struct device *dev); -static inline uint32_t z_impl_counter_get_top_value(struct device *dev) +static inline uint32_t z_impl_counter_get_top_value(const struct device *dev) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -513,9 +523,9 @@ static inline uint32_t z_impl_counter_get_top_value(struct device *dev) * * @return Max alarm value. */ -__deprecated __syscall uint32_t counter_get_max_relative_alarm(struct device *dev); +__deprecated __syscall uint32_t counter_get_max_relative_alarm(const struct device *dev); -static inline uint32_t z_impl_counter_get_max_relative_alarm(struct device *dev) +static inline uint32_t z_impl_counter_get_max_relative_alarm(const struct device *dev) { const struct counter_driver_api *api = (struct counter_driver_api *)dev->api; @@ -551,10 +561,11 @@ static inline uint32_t z_impl_counter_get_max_relative_alarm(struct device *dev) * @retval -ENOTSUP if function or flags are not supported. * @retval -EINVAL if ticks value is invalid. */ -__syscall int counter_set_guard_period(struct device *dev, uint32_t ticks, +__syscall int counter_set_guard_period(const struct device *dev, + uint32_t ticks, uint32_t flags); -static inline int z_impl_counter_set_guard_period(struct device *dev, +static inline int z_impl_counter_set_guard_period(const struct device *dev, uint32_t ticks, uint32_t flags) { const struct counter_driver_api *api = @@ -578,9 +589,10 @@ static inline int z_impl_counter_set_guard_period(struct device *dev, * @return Guard period given in counter ticks or 0 if function or flags are * not supported. */ -__syscall uint32_t counter_get_guard_period(struct device *dev, uint32_t flags); +__syscall uint32_t counter_get_guard_period(const struct device *dev, + uint32_t flags); -static inline uint32_t z_impl_counter_get_guard_period(struct device *dev, +static inline uint32_t z_impl_counter_get_guard_period(const struct device *dev, uint32_t flags) { const struct counter_driver_api *api = @@ -590,10 +602,10 @@ static inline uint32_t z_impl_counter_get_guard_period(struct device *dev, } /* Deprecated counter callback. */ -typedef void (*counter_callback_t)(struct device *dev, void *user_data); +typedef void (*counter_callback_t)(const struct device *dev, void *user_data); /* Deprecated counter read function. Use counter_get_value() instead. */ -__deprecated static inline uint32_t counter_read(struct device *dev) +__deprecated static inline uint32_t counter_read(const struct device *dev) { uint32_t ticks; diff --git a/include/drivers/dac.h b/include/drivers/dac.h index de2fb9f9187496..9948abe5d1e76b 100644 --- a/include/drivers/dac.h +++ b/include/drivers/dac.h @@ -48,14 +48,14 @@ struct dac_channel_cfg { * Type definition of DAC API function for configuring a channel. * See dac_channel_setup() for argument descriptions. */ -typedef int (*dac_api_channel_setup)(struct device *dev, - const struct dac_channel_cfg *channel_cfg); +typedef int (*dac_api_channel_setup)(const struct device *dev, + const struct dac_channel_cfg *channel_cfg); /* * Type definition of DAC API function for setting a write request. * See dac_write_value() for argument descriptions. */ -typedef int (*dac_api_write_value)(struct device *dev, +typedef int (*dac_api_write_value)(const struct device *dev, uint8_t channel, uint32_t value); /* @@ -85,11 +85,11 @@ __subsystem struct dac_driver_api { * @retval -EINVAL If a parameter with an invalid value has been provided. * @retval -ENOTSUP If the requested resolution is not supported. */ -__syscall int dac_channel_setup(struct device *dev, +__syscall int dac_channel_setup(const struct device *dev, const struct dac_channel_cfg *channel_cfg); -static inline int z_impl_dac_channel_setup(struct device *dev, - const struct dac_channel_cfg *channel_cfg) +static inline int z_impl_dac_channel_setup(const struct device *dev, + const struct dac_channel_cfg *channel_cfg) { const struct dac_driver_api *api = (const struct dac_driver_api *)dev->api; @@ -107,9 +107,10 @@ static inline int z_impl_dac_channel_setup(struct device *dev, * @retval 0 On success. * @retval -EINVAL If a parameter with an invalid value has been provided. */ -__syscall int dac_write_value(struct device *dev, uint8_t channel, uint32_t value); +__syscall int dac_write_value(const struct device *dev, uint8_t channel, + uint32_t value); -static inline int z_impl_dac_write_value(struct device *dev, +static inline int z_impl_dac_write_value(const struct device *dev, uint8_t channel, uint32_t value) { const struct dac_driver_api *api = diff --git a/include/drivers/dma.h b/include/drivers/dma.h index 9f391630cffa14..19a4148c022a56 100644 --- a/include/drivers/dma.h +++ b/include/drivers/dma.h @@ -113,7 +113,7 @@ struct dma_block_config { * @param channel The channel number * @param status 0 on success, a negative errno otherwise */ -typedef void (*dma_callback_t)(struct device *dev, void *user_data, +typedef void (*dma_callback_t)(const struct device *dev, void *user_data, uint32_t channel, int status); /** @@ -200,22 +200,22 @@ struct dma_status { * public documentation. */ -typedef int (*dma_api_config)(struct device *dev, uint32_t channel, +typedef int (*dma_api_config)(const struct device *dev, uint32_t channel, struct dma_config *config); #ifdef CONFIG_DMA_64BIT -typedef int (*dma_api_reload)(struct device *dev, uint32_t channel, - uint64_t src, uint64_t dst, size_t size); +typedef int (*dma_api_reload)(const struct device *dev, uint32_t channel, + uint64_t src, uint64_t dst, size_t size); #else -typedef int (*dma_api_reload)(struct device *dev, uint32_t channel, - uint32_t src, uint32_t dst, size_t size); +typedef int (*dma_api_reload)(const struct device *dev, uint32_t channel, + uint32_t src, uint32_t dst, size_t size); #endif -typedef int (*dma_api_start)(struct device *dev, uint32_t channel); +typedef int (*dma_api_start)(const struct device *dev, uint32_t channel); -typedef int (*dma_api_stop)(struct device *dev, uint32_t channel); +typedef int (*dma_api_stop)(const struct device *dev, uint32_t channel); -typedef int (*dma_api_get_status)(struct device *dev, uint32_t channel, +typedef int (*dma_api_get_status)(const struct device *dev, uint32_t channel, struct dma_status *status); __subsystem struct dma_driver_api { @@ -240,7 +240,7 @@ __subsystem struct dma_driver_api { * @retval 0 if successful. * @retval Negative errno code if failure. */ -static inline int dma_config(struct device *dev, uint32_t channel, +static inline int dma_config(const struct device *dev, uint32_t channel, struct dma_config *config) { const struct dma_driver_api *api = @@ -263,8 +263,8 @@ static inline int dma_config(struct device *dev, uint32_t channel, * @retval Negative errno code if failure. */ #ifdef CONFIG_DMA_64BIT -static inline int dma_reload(struct device *dev, uint32_t channel, - uint64_t src, uint64_t dst, size_t size) +static inline int dma_reload(const struct device *dev, uint32_t channel, + uint64_t src, uint64_t dst, size_t size) #else static inline int dma_reload(struct device *dev, uint32_t channel, uint32_t src, uint32_t dst, size_t size) @@ -294,9 +294,9 @@ static inline int dma_reload(struct device *dev, uint32_t channel, * @retval 0 if successful. * @retval Negative errno code if failure. */ -__syscall int dma_start(struct device *dev, uint32_t channel); +__syscall int dma_start(const struct device *dev, uint32_t channel); -static inline int z_impl_dma_start(struct device *dev, uint32_t channel) +static inline int z_impl_dma_start(const struct device *dev, uint32_t channel) { const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api; @@ -317,9 +317,9 @@ static inline int z_impl_dma_start(struct device *dev, uint32_t channel) * @retval 0 if successful. * @retval Negative errno code if failure. */ -__syscall int dma_stop(struct device *dev, uint32_t channel); +__syscall int dma_stop(const struct device *dev, uint32_t channel); -static inline int z_impl_dma_stop(struct device *dev, uint32_t channel) +static inline int z_impl_dma_stop(const struct device *dev, uint32_t channel) { const struct dma_driver_api *api = (const struct dma_driver_api *)dev->api; @@ -341,7 +341,7 @@ static inline int z_impl_dma_stop(struct device *dev, uint32_t channel) * @retval non-negative if successful. * @retval Negative errno code if failure. */ -static inline int dma_get_status(struct device *dev, uint32_t channel, +static inline int dma_get_status(const struct device *dev, uint32_t channel, struct dma_status *stat) { const struct dma_driver_api *api = diff --git a/include/drivers/eeprom.h b/include/drivers/eeprom.h index 2d2677249ae9e8..b296c0a964e813 100644 --- a/include/drivers/eeprom.h +++ b/include/drivers/eeprom.h @@ -32,11 +32,12 @@ extern "C" { #endif -typedef int (*eeprom_api_read)(struct device *dev, off_t offset, void *data, +typedef int (*eeprom_api_read)(const struct device *dev, off_t offset, + void *data, size_t len); -typedef int (*eeprom_api_write)(struct device *dev, off_t offset, +typedef int (*eeprom_api_write)(const struct device *dev, off_t offset, const void *data, size_t len); -typedef size_t (*eeprom_api_size)(struct device *dev); +typedef size_t (*eeprom_api_size)(const struct device *dev); __subsystem struct eeprom_driver_api { eeprom_api_read read; @@ -54,10 +55,10 @@ __subsystem struct eeprom_driver_api { * * @return 0 on success, negative errno code on failure. */ -__syscall int eeprom_read(struct device *dev, off_t offset, void *data, +__syscall int eeprom_read(const struct device *dev, off_t offset, void *data, size_t len); -static inline int z_impl_eeprom_read(struct device *dev, off_t offset, +static inline int z_impl_eeprom_read(const struct device *dev, off_t offset, void *data, size_t len) { const struct eeprom_driver_api *api = @@ -76,10 +77,11 @@ static inline int z_impl_eeprom_read(struct device *dev, off_t offset, * * @return 0 on success, negative errno code on failure. */ -__syscall int eeprom_write(struct device *dev, off_t offset, const void *data, +__syscall int eeprom_write(const struct device *dev, off_t offset, + const void *data, size_t len); -static inline int z_impl_eeprom_write(struct device *dev, off_t offset, +static inline int z_impl_eeprom_write(const struct device *dev, off_t offset, const void *data, size_t len) { const struct eeprom_driver_api *api = @@ -95,9 +97,9 @@ static inline int z_impl_eeprom_write(struct device *dev, off_t offset, * * @return EEPROM size in bytes. */ -__syscall size_t eeprom_get_size(struct device *dev); +__syscall size_t eeprom_get_size(const struct device *dev); -static inline size_t z_impl_eeprom_get_size(struct device *dev) +static inline size_t z_impl_eeprom_get_size(const struct device *dev) { const struct eeprom_driver_api *api = (const struct eeprom_driver_api *)dev->api; diff --git a/include/drivers/entropy.h b/include/drivers/entropy.h index 2c7614d9e936e2..aff2555c1db0cb 100644 --- a/include/drivers/entropy.h +++ b/include/drivers/entropy.h @@ -33,16 +33,16 @@ extern "C" { * * See entropy_get_entropy() for argument description */ -typedef int (*entropy_get_entropy_t)(struct device *dev, - uint8_t *buffer, - uint16_t length); +typedef int (*entropy_get_entropy_t)(const struct device *dev, + uint8_t *buffer, + uint16_t length); /** * @typedef entropy_get_entropy_isr_t * @brief Callback API to get entropy from an ISR. * * See entropy_get_entropy_isr() for argument description */ -typedef int (*entropy_get_entropy_isr_t)(struct device *dev, +typedef int (*entropy_get_entropy_isr_t)(const struct device *dev, uint8_t *buffer, uint16_t length, uint32_t flags); @@ -61,13 +61,13 @@ __subsystem struct entropy_driver_api { * @retval 0 on success. * @retval -ERRNO errno code on error. */ -__syscall int entropy_get_entropy(struct device *dev, +__syscall int entropy_get_entropy(const struct device *dev, uint8_t *buffer, uint16_t length); -static inline int z_impl_entropy_get_entropy(struct device *dev, - uint8_t *buffer, - uint16_t length) +static inline int z_impl_entropy_get_entropy(const struct device *dev, + uint8_t *buffer, + uint16_t length) { const struct entropy_driver_api *api = (const struct entropy_driver_api *)dev->api; @@ -90,7 +90,7 @@ static inline int z_impl_entropy_get_entropy(struct device *dev, * @param flags Flags to modify the behavior of the call. * @retval number of bytes filled with entropy or -error. */ -static inline int entropy_get_entropy_isr(struct device *dev, +static inline int entropy_get_entropy_isr(const struct device *dev, uint8_t *buffer, uint16_t length, uint32_t flags) diff --git a/include/drivers/espi.h b/include/drivers/espi.h index 320817f87d1ed8..118a5f3e796f29 100644 --- a/include/drivers/espi.h +++ b/include/drivers/espi.h @@ -289,7 +289,7 @@ struct espi_callback; * @param espi_evt event details that trigger the callback handler. * */ -typedef void (*espi_callback_handler_t) (struct device *dev, +typedef void (*espi_callback_handler_t) (const struct device *dev, struct espi_callback *cb, struct espi_event espi_evt); @@ -326,39 +326,41 @@ struct espi_callback { * * (Internal use only.) */ -typedef int (*espi_api_config)(struct device *dev, struct espi_cfg *cfg); -typedef bool (*espi_api_get_channel_status)(struct device *dev, +typedef int (*espi_api_config)(const struct device *dev, struct espi_cfg *cfg); +typedef bool (*espi_api_get_channel_status)(const struct device *dev, enum espi_channel ch); /* Logical Channel 0 APIs */ -typedef int (*espi_api_read_request)(struct device *dev, +typedef int (*espi_api_read_request)(const struct device *dev, struct espi_request_packet *req); -typedef int (*espi_api_write_request)(struct device *dev, +typedef int (*espi_api_write_request)(const struct device *dev, struct espi_request_packet *req); -typedef int (*espi_api_lpc_read_request)(struct device *dev, - enum lpc_peripheral_opcode op, uint32_t *data); -typedef int (*espi_api_lpc_write_request)(struct device *dev, - enum lpc_peripheral_opcode op, uint32_t *data); +typedef int (*espi_api_lpc_read_request)(const struct device *dev, + enum lpc_peripheral_opcode op, + uint32_t *data); +typedef int (*espi_api_lpc_write_request)(const struct device *dev, + enum lpc_peripheral_opcode op, + uint32_t *data); /* Logical Channel 1 APIs */ -typedef int (*espi_api_send_vwire)(struct device *dev, +typedef int (*espi_api_send_vwire)(const struct device *dev, enum espi_vwire_signal vw, uint8_t level); -typedef int (*espi_api_receive_vwire)(struct device *dev, +typedef int (*espi_api_receive_vwire)(const struct device *dev, enum espi_vwire_signal vw, uint8_t *level); /* Logical Channel 2 APIs */ -typedef int (*espi_api_send_oob)(struct device *dev, +typedef int (*espi_api_send_oob)(const struct device *dev, struct espi_oob_packet *pckt); -typedef int (*espi_api_receive_oob)(struct device *dev, +typedef int (*espi_api_receive_oob)(const struct device *dev, struct espi_oob_packet *pckt); /* Logical Channel 3 APIs */ -typedef int (*espi_api_flash_read)(struct device *dev, +typedef int (*espi_api_flash_read)(const struct device *dev, struct espi_flash_packet *pckt); -typedef int (*espi_api_flash_write)(struct device *dev, +typedef int (*espi_api_flash_write)(const struct device *dev, struct espi_flash_packet *pckt); -typedef int (*espi_api_flash_erase)(struct device *dev, +typedef int (*espi_api_flash_erase)(const struct device *dev, struct espi_flash_packet *pckt); /* Callbacks and traffic intercept */ -typedef int (*espi_api_manage_callback)(struct device *dev, +typedef int (*espi_api_manage_callback)(const struct device *dev, struct espi_callback *callback, bool set); @@ -429,9 +431,9 @@ __subsystem struct espi_driver_api { * @retval -EINVAL invalid capabilities, failed to configure device. * @retval -ENOTSUP capability not supported by eSPI slave. */ -__syscall int espi_config(struct device *dev, struct espi_cfg *cfg); +__syscall int espi_config(const struct device *dev, struct espi_cfg *cfg); -static inline int z_impl_espi_config(struct device *dev, +static inline int z_impl_espi_config(const struct device *dev, struct espi_cfg *cfg) { const struct espi_driver_api *api = @@ -452,10 +454,10 @@ static inline int z_impl_espi_config(struct device *dev, * @retval true If eSPI channel is ready. * @retval false otherwise. */ -__syscall bool espi_get_channel_status(struct device *dev, +__syscall bool espi_get_channel_status(const struct device *dev, enum espi_channel ch); -static inline bool z_impl_espi_get_channel_status(struct device *dev, +static inline bool z_impl_espi_get_channel_status(const struct device *dev, enum espi_channel ch) { const struct espi_driver_api *api = @@ -478,10 +480,10 @@ static inline bool z_impl_espi_get_channel_status(struct device *dev, * low memory transactions are handled by controller hardware directly. * @retval -EIO General input / output error, failed to send over the bus. */ -__syscall int espi_read_request(struct device *dev, +__syscall int espi_read_request(const struct device *dev, struct espi_request_packet *req); -static inline int z_impl_espi_read_request(struct device *dev, +static inline int z_impl_espi_read_request(const struct device *dev, struct espi_request_packet *req) { const struct espi_driver_api *api = @@ -508,10 +510,10 @@ static inline int z_impl_espi_read_request(struct device *dev, * low memory transactions are handled by controller hardware directly. * @retval -EINVAL General input / output error, failed to send over the bus. */ -__syscall int espi_write_request(struct device *dev, +__syscall int espi_write_request(const struct device *dev, struct espi_request_packet *req); -static inline int z_impl_espi_write_request(struct device *dev, +static inline int z_impl_espi_write_request(const struct device *dev, struct espi_request_packet *req) { const struct espi_driver_api *api = @@ -540,10 +542,11 @@ static inline int z_impl_espi_write_request(struct device *dev, * @retval -ENOTSUP if eSPI peripheral is off or not supported. * @retval -EINVAL for unimplemented lpc opcode, but in range. */ -__syscall int espi_read_lpc_request(struct device *dev, - enum lpc_peripheral_opcode op, uint32_t *data); +__syscall int espi_read_lpc_request(const struct device *dev, + enum lpc_peripheral_opcode op, + uint32_t *data); -static inline int z_impl_espi_read_lpc_request(struct device *dev, +static inline int z_impl_espi_read_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -572,11 +575,11 @@ static inline int z_impl_espi_read_lpc_request(struct device *dev, * @retval -ENOTSUP if eSPI peripheral is off or not supported. * @retval -EINVAL for unimplemented lpc opcode, but in range. */ -__syscall int espi_write_lpc_request(struct device *dev, +__syscall int espi_write_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data); -static inline int z_impl_espi_write_lpc_request(struct device *dev, +static inline int z_impl_espi_write_lpc_request(const struct device *dev, enum lpc_peripheral_opcode op, uint32_t *data) { @@ -603,11 +606,11 @@ static inline int z_impl_espi_write_lpc_request(struct device *dev, * @retval 0 If successful. * @retval -EIO General input / output error, failed to send over the bus. */ -__syscall int espi_send_vwire(struct device *dev, +__syscall int espi_send_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t level); -static inline int z_impl_espi_send_vwire(struct device *dev, +static inline int z_impl_espi_send_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t level) { @@ -629,11 +632,11 @@ static inline int z_impl_espi_send_vwire(struct device *dev, * * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_receive_vwire(struct device *dev, +__syscall int espi_receive_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t *level); -static inline int z_impl_espi_receive_vwire(struct device *dev, +static inline int z_impl_espi_receive_vwire(const struct device *dev, enum espi_vwire_signal signal, uint8_t *level) { @@ -654,9 +657,10 @@ static inline int z_impl_espi_receive_vwire(struct device *dev, * * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_send_oob(struct device *dev, struct espi_oob_packet *pckt); +__syscall int espi_send_oob(const struct device *dev, + struct espi_oob_packet *pckt); -static inline int z_impl_espi_send_oob(struct device *dev, +static inline int z_impl_espi_send_oob(const struct device *dev, struct espi_oob_packet *pckt) { const struct espi_driver_api *api = @@ -680,10 +684,10 @@ static inline int z_impl_espi_send_oob(struct device *dev, * * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_receive_oob(struct device *dev, +__syscall int espi_receive_oob(const struct device *dev, struct espi_oob_packet *pckt); -static inline int z_impl_espi_receive_oob(struct device *dev, +static inline int z_impl_espi_receive_oob(const struct device *dev, struct espi_oob_packet *pckt) { const struct espi_driver_api *api = @@ -709,10 +713,10 @@ static inline int z_impl_espi_receive_oob(struct device *dev, * @retval -EBUSY eSPI flash channel is not ready or disabled by master. * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_read_flash(struct device *dev, +__syscall int espi_read_flash(const struct device *dev, struct espi_flash_packet *pckt); -static inline int z_impl_espi_read_flash(struct device *dev, +static inline int z_impl_espi_read_flash(const struct device *dev, struct espi_flash_packet *pckt) { const struct espi_driver_api *api = @@ -738,10 +742,10 @@ static inline int z_impl_espi_read_flash(struct device *dev, * @retval -EBUSY eSPI flash channel is not ready or disabled by master. * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_write_flash(struct device *dev, +__syscall int espi_write_flash(const struct device *dev, struct espi_flash_packet *pckt); -static inline int z_impl_espi_write_flash(struct device *dev, +static inline int z_impl_espi_write_flash(const struct device *dev, struct espi_flash_packet *pckt) { const struct espi_driver_api *api = @@ -767,10 +771,10 @@ static inline int z_impl_espi_write_flash(struct device *dev, * @retval -EBUSY eSPI flash channel is not ready or disabled by master. * @retval -EIO General input / output error, failed request to master. */ -__syscall int espi_flash_erase(struct device *dev, +__syscall int espi_flash_erase(const struct device *dev, struct espi_flash_packet *pckt); -static inline int z_impl_espi_flash_erase(struct device *dev, +static inline int z_impl_espi_flash_erase(const struct device *dev, struct espi_flash_packet *pckt) { const struct espi_driver_api *api = @@ -874,7 +878,7 @@ static inline void espi_init_callback(struct espi_callback *callback, * * Note: enables to add as many callback as needed on the same device. */ -static inline int espi_add_callback(struct device *dev, +static inline int espi_add_callback(const struct device *dev, struct espi_callback *callback) { const struct espi_driver_api *api = @@ -903,7 +907,7 @@ static inline int espi_add_callback(struct device *dev, * Note: enables to remove as many callbacks as added through * espi_add_callback(). */ -static inline int espi_remove_callback(struct device *dev, +static inline int espi_remove_callback(const struct device *dev, struct espi_callback *callback) { const struct espi_driver_api *api = diff --git a/include/drivers/flash.h b/include/drivers/flash.h index 757f7224a7c581..259d28584d7d76 100644 --- a/include/drivers/flash.h +++ b/include/drivers/flash.h @@ -46,12 +46,15 @@ struct flash_parameters { uint8_t erase_value; /* Byte value of erased flash */ }; -typedef int (*flash_api_read)(struct device *dev, off_t offset, void *data, +typedef int (*flash_api_read)(const struct device *dev, off_t offset, + void *data, size_t len); -typedef int (*flash_api_write)(struct device *dev, off_t offset, +typedef int (*flash_api_write)(const struct device *dev, off_t offset, const void *data, size_t len); -typedef int (*flash_api_erase)(struct device *dev, off_t offset, size_t size); -typedef int (*flash_api_write_protection)(struct device *dev, bool enable); +typedef int (*flash_api_erase)(const struct device *dev, off_t offset, + size_t size); +typedef int (*flash_api_write_protection)(const struct device *dev, + bool enable); typedef const struct flash_parameters* (*flash_api_get_parameters)(const struct device *dev); #if defined(CONFIG_FLASH_PAGE_LAYOUT) @@ -76,14 +79,14 @@ typedef const struct flash_parameters* (*flash_api_get_parameters)(const struct * @param layout The flash layout will be returned in this argument. * @param layout_size The number of elements in the returned layout. */ -typedef void (*flash_api_pages_layout)(struct device *dev, +typedef void (*flash_api_pages_layout)(const struct device *dev, const struct flash_pages_layout **layout, size_t *layout_size); #endif /* CONFIG_FLASH_PAGE_LAYOUT */ -typedef int (*flash_api_sfdp_read)(struct device *dev, off_t offset, +typedef int (*flash_api_sfdp_read)(const struct device *dev, off_t offset, void *data, size_t len); -typedef int (*flash_api_read_jedec_id)(struct device *dev, uint8_t *id); +typedef int (*flash_api_read_jedec_id)(const struct device *dev, uint8_t *id); __subsystem struct flash_driver_api { flash_api_read read; @@ -113,11 +116,12 @@ __subsystem struct flash_driver_api { * * @return 0 on success, negative errno code on fail. */ -__syscall int flash_read(struct device *dev, off_t offset, void *data, +__syscall int flash_read(const struct device *dev, off_t offset, void *data, size_t len); -static inline int z_impl_flash_read(struct device *dev, off_t offset, void *data, - size_t len) +static inline int z_impl_flash_read(const struct device *dev, off_t offset, + void *data, + size_t len) { const struct flash_driver_api *api = (const struct flash_driver_api *)dev->api; @@ -142,11 +146,12 @@ static inline int z_impl_flash_read(struct device *dev, off_t offset, void *data * * @return 0 on success, negative errno code on fail. */ -__syscall int flash_write(struct device *dev, off_t offset, const void *data, +__syscall int flash_write(const struct device *dev, off_t offset, + const void *data, size_t len); -static inline int z_impl_flash_write(struct device *dev, off_t offset, - const void *data, size_t len) +static inline int z_impl_flash_write(const struct device *dev, off_t offset, + const void *data, size_t len) { const struct flash_driver_api *api = (const struct flash_driver_api *)dev->api; @@ -175,10 +180,10 @@ static inline int z_impl_flash_write(struct device *dev, off_t offset, * @see flash_get_page_info_by_offs() * @see flash_get_page_info_by_idx() */ -__syscall int flash_erase(struct device *dev, off_t offset, size_t size); +__syscall int flash_erase(const struct device *dev, off_t offset, size_t size); -static inline int z_impl_flash_erase(struct device *dev, off_t offset, - size_t size) +static inline int z_impl_flash_erase(const struct device *dev, off_t offset, + size_t size) { const struct flash_driver_api *api = (const struct flash_driver_api *)dev->api; @@ -219,10 +224,11 @@ static inline int z_impl_flash_erase(struct device *dev, off_t offset, * * @return 0 on success, negative errno code on fail. */ -__syscall int flash_write_protection_set(struct device *dev, bool enable); +__syscall int flash_write_protection_set(const struct device *dev, + bool enable); -static inline int z_impl_flash_write_protection_set(struct device *dev, - bool enable) +static inline int z_impl_flash_write_protection_set(const struct device *dev, + bool enable) { const struct flash_driver_api *api = (const struct flash_driver_api *)dev->api; @@ -246,7 +252,8 @@ struct flash_pages_info { * * @return 0 on success, -EINVAL if page of the offset doesn't exist. */ -__syscall int flash_get_page_info_by_offs(struct device *dev, off_t offset, +__syscall int flash_get_page_info_by_offs(const struct device *dev, + off_t offset, struct flash_pages_info *info); /** @@ -258,7 +265,8 @@ __syscall int flash_get_page_info_by_offs(struct device *dev, off_t offset, * * @return 0 on success, -EINVAL if page of the index doesn't exist. */ -__syscall int flash_get_page_info_by_idx(struct device *dev, uint32_t page_index, +__syscall int flash_get_page_info_by_idx(const struct device *dev, + uint32_t page_index, struct flash_pages_info *info); /** @@ -268,7 +276,7 @@ __syscall int flash_get_page_info_by_idx(struct device *dev, uint32_t page_index * * @return Number of flash pages. */ -__syscall size_t flash_get_page_count(struct device *dev); +__syscall size_t flash_get_page_count(const struct device *dev); /** * @brief Callback type for iterating over flash pages present on a device. @@ -294,7 +302,8 @@ typedef bool (*flash_page_cb)(const struct flash_pages_info *info, void *data); * @param cb Callback to invoke for each flash page * @param data Private data for callback function */ -void flash_page_foreach(struct device *dev, flash_page_cb cb, void *data); +void flash_page_foreach(const struct device *dev, flash_page_cb cb, + void *data); #endif /* CONFIG_FLASH_PAGE_LAYOUT */ #if defined(CONFIG_FLASH_JESD216_API) @@ -318,10 +327,11 @@ void flash_page_foreach(struct device *dev, flash_page_cb cb, void *data); * @retval -ENOTSUP if the flash driver does not support SFDP access * @retval negative values for other errors. */ -__syscall int flash_sfdp_read(struct device *dev, off_t offset, +__syscall int flash_sfdp_read(const struct device *dev, off_t offset, void *data, size_t len); -static inline int z_impl_flash_sfdp_read(struct device *dev, off_t offset, +static inline int z_impl_flash_sfdp_read(const struct device *dev, + off_t offset, void *data, size_t len) { int rv = -ENOTSUP; @@ -345,9 +355,10 @@ static inline int z_impl_flash_sfdp_read(struct device *dev, off_t offset, * @retval -ENOTSUP if flash driver doesn't support this function * @retval negative values for other errors */ -__syscall int flash_read_jedec_id(struct device *dev, uint8_t *id); +__syscall int flash_read_jedec_id(const struct device *dev, uint8_t *id); -static inline int z_impl_flash_read_jedec_id(struct device *dev, uint8_t *id) +static inline int z_impl_flash_read_jedec_id(const struct device *dev, + uint8_t *id) { int rv = -ENOTSUP; const struct flash_driver_api *api = @@ -371,9 +382,9 @@ static inline int z_impl_flash_read_jedec_id(struct device *dev, uint8_t *id) * * @return write block size in bytes. */ -__syscall size_t flash_get_write_block_size(struct device *dev); +__syscall size_t flash_get_write_block_size(const struct device *dev); -static inline size_t z_impl_flash_get_write_block_size(struct device *dev) +static inline size_t z_impl_flash_get_write_block_size(const struct device *dev) { const struct flash_driver_api *api = (const struct flash_driver_api *)dev->api; diff --git a/include/drivers/gna.h b/include/drivers/gna.h index da22d5e3c7a5c1..dc876848fb41d2 100644 --- a/include/drivers/gna.h +++ b/include/drivers/gna.h @@ -111,12 +111,16 @@ struct gna_inference_resp { */ typedef int (*gna_callback)(struct gna_inference_resp *result); -typedef int (*gna_api_config)(struct device *dev, struct gna_config *cfg); -typedef int (*gna_api_register)(struct device *dev, - struct gna_model_info *model, void **model_handle); -typedef int (*gna_api_deregister)(struct device *dev, void *model_handle); -typedef int (*gna_api_infer)(struct device *dev, struct gna_inference_req *req, - gna_callback callback); +typedef int (*gna_api_config)(const struct device *dev, + struct gna_config *cfg); +typedef int (*gna_api_register)(const struct device *dev, + struct gna_model_info *model, + void **model_handle); +typedef int (*gna_api_deregister)(const struct device *dev, + void *model_handle); +typedef int (*gna_api_infer)(const struct device *dev, + struct gna_inference_req *req, + gna_callback callback); struct gna_driver_api { gna_api_config configure; @@ -141,7 +145,8 @@ struct gna_driver_api { * @retval 0 If the configuration is successful * @retval A negative error code in case of a failure. */ -static inline int gna_configure(struct device *dev, struct gna_config *cfg) +static inline int gna_configure(const struct device *dev, + struct gna_config *cfg) { const struct gna_driver_api *api = (const struct gna_driver_api *)dev->api; @@ -162,8 +167,9 @@ static inline int gna_configure(struct device *dev, struct gna_config *cfg) * @retval 0 If registration of the model is successful. * @retval A negative error code in case of a failure. */ -static inline int gna_register_model(struct device *dev, - struct gna_model_info *model, void **model_handle) +static inline int gna_register_model(const struct device *dev, + struct gna_model_info *model, + void **model_handle) { const struct gna_driver_api *api = (const struct gna_driver_api *)dev->api; @@ -184,7 +190,7 @@ static inline int gna_register_model(struct device *dev, * @retval 0 If de-registration of the model is successful. * @retval A negative error code in case of a failure. */ -static inline int gna_deregister_model(struct device *dev, void *model) +static inline int gna_deregister_model(const struct device *dev, void *model) { const struct gna_driver_api *api = (const struct gna_driver_api *)dev->api; @@ -206,8 +212,9 @@ static inline int gna_deregister_model(struct device *dev, void *model) * @retval 0 If the request is accepted * @retval A negative error code in case of a failure. */ -static inline int gna_infer(struct device *dev, struct gna_inference_req *req, - gna_callback callback) +static inline int gna_infer(const struct device *dev, + struct gna_inference_req *req, + gna_callback callback) { const struct gna_driver_api *api = (const struct gna_driver_api *)dev->api; diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index 7441cc9db05146..44f893a615c2ab 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -350,7 +350,7 @@ struct gpio_callback; * CONTAINER_OF() if original struct gpio_callback is stored in * another private structure. */ -typedef void (*gpio_callback_handler_t)(struct device *port, +typedef void (*gpio_callback_handler_t)(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins); @@ -410,24 +410,32 @@ enum gpio_int_trig { }; __subsystem struct gpio_driver_api { - int (*pin_configure)(struct device *port, gpio_pin_t pin, gpio_flags_t flags); - int (*port_get_raw)(struct device *port, gpio_port_value_t *value); - int (*port_set_masked_raw)(struct device *port, gpio_port_pins_t mask, + int (*pin_configure)(const struct device *port, gpio_pin_t pin, + gpio_flags_t flags); + int (*port_get_raw)(const struct device *port, + gpio_port_value_t *value); + int (*port_set_masked_raw)(const struct device *port, + gpio_port_pins_t mask, gpio_port_value_t value); - int (*port_set_bits_raw)(struct device *port, gpio_port_pins_t pins); - int (*port_clear_bits_raw)(struct device *port, gpio_port_pins_t pins); - int (*port_toggle_bits)(struct device *port, gpio_port_pins_t pins); - int (*pin_interrupt_configure)(struct device *port, gpio_pin_t pin, + int (*port_set_bits_raw)(const struct device *port, + gpio_port_pins_t pins); + int (*port_clear_bits_raw)(const struct device *port, + gpio_port_pins_t pins); + int (*port_toggle_bits)(const struct device *port, + gpio_port_pins_t pins); + int (*pin_interrupt_configure)(const struct device *port, + gpio_pin_t pin, enum gpio_int_mode, enum gpio_int_trig); - int (*manage_callback)(struct device *port, struct gpio_callback *cb, + int (*manage_callback)(const struct device *port, + struct gpio_callback *cb, bool set); - uint32_t (*get_pending_int)(struct device *dev); + uint32_t (*get_pending_int)(const struct device *dev); }; -__syscall int gpio_config(struct device *port, gpio_pin_t pin, +__syscall int gpio_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags); -static inline int z_impl_gpio_config(struct device *port, +static inline int z_impl_gpio_config(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_driver_api *api = @@ -460,11 +468,11 @@ static inline int z_impl_gpio_config(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_pin_interrupt_configure(struct device *port, +__syscall int gpio_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags); -static inline int z_impl_gpio_pin_interrupt_configure(struct device *port, +static inline int z_impl_gpio_pin_interrupt_configure(const struct device *port, gpio_pin_t pin, gpio_flags_t flags) { @@ -530,7 +538,8 @@ static inline int z_impl_gpio_pin_interrupt_configure(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_configure(struct device *port, gpio_pin_t pin, +static inline int gpio_pin_configure(const struct device *port, + gpio_pin_t pin, gpio_flags_t flags) { const struct gpio_driver_api *api = @@ -607,9 +616,10 @@ static inline int gpio_pin_configure(struct device *port, gpio_pin_t pin, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_port_get_raw(struct device *port, gpio_port_value_t *value); +__syscall int gpio_port_get_raw(const struct device *port, + gpio_port_value_t *value); -static inline int z_impl_gpio_port_get_raw(struct device *port, +static inline int z_impl_gpio_port_get_raw(const struct device *port, gpio_port_value_t *value) { const struct gpio_driver_api *api = @@ -636,7 +646,8 @@ static inline int z_impl_gpio_port_get_raw(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_get(struct device *port, gpio_port_value_t *value) +static inline int gpio_port_get(const struct device *port, + gpio_port_value_t *value) { const struct gpio_driver_data *const data = (const struct gpio_driver_data *)port->data; @@ -667,11 +678,13 @@ static inline int gpio_port_get(struct device *port, gpio_port_value_t *value) * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_port_set_masked_raw(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value); +__syscall int gpio_port_set_masked_raw(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value); -static inline int z_impl_gpio_port_set_masked_raw(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value) +static inline int z_impl_gpio_port_set_masked_raw(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value) { const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; @@ -699,8 +712,9 @@ static inline int z_impl_gpio_port_set_masked_raw(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_set_masked(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value) +static inline int gpio_port_set_masked(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value) { const struct gpio_driver_data *const data = (const struct gpio_driver_data *)port->data; @@ -720,10 +734,10 @@ static inline int gpio_port_set_masked(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_port_set_bits_raw(struct device *port, +__syscall int gpio_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins); -static inline int z_impl_gpio_port_set_bits_raw(struct device *port, +static inline int z_impl_gpio_port_set_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct gpio_driver_api *api = @@ -742,7 +756,8 @@ static inline int z_impl_gpio_port_set_bits_raw(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins) +static inline int gpio_port_set_bits(const struct device *port, + gpio_port_pins_t pins) { return gpio_port_set_masked(port, pins, pins); } @@ -757,10 +772,10 @@ static inline int gpio_port_set_bits(struct device *port, gpio_port_pins_t pins) * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_port_clear_bits_raw(struct device *port, +__syscall int gpio_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins); -static inline int z_impl_gpio_port_clear_bits_raw(struct device *port, +static inline int z_impl_gpio_port_clear_bits_raw(const struct device *port, gpio_port_pins_t pins) { const struct gpio_driver_api *api = @@ -779,7 +794,7 @@ static inline int z_impl_gpio_port_clear_bits_raw(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_clear_bits(struct device *port, +static inline int gpio_port_clear_bits(const struct device *port, gpio_port_pins_t pins) { return gpio_port_set_masked(port, pins, 0); @@ -795,9 +810,10 @@ static inline int gpio_port_clear_bits(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -__syscall int gpio_port_toggle_bits(struct device *port, gpio_port_pins_t pins); +__syscall int gpio_port_toggle_bits(const struct device *port, + gpio_port_pins_t pins); -static inline int z_impl_gpio_port_toggle_bits(struct device *port, +static inline int z_impl_gpio_port_toggle_bits(const struct device *port, gpio_port_pins_t pins) { const struct gpio_driver_api *api = @@ -817,8 +833,9 @@ static inline int z_impl_gpio_port_toggle_bits(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_set_clr_bits_raw(struct device *port, - gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins) +static inline int gpio_port_set_clr_bits_raw(const struct device *port, + gpio_port_pins_t set_pins, + gpio_port_pins_t clear_pins) { __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap"); @@ -836,8 +853,9 @@ static inline int gpio_port_set_clr_bits_raw(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_port_set_clr_bits(struct device *port, - gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins) +static inline int gpio_port_set_clr_bits(const struct device *port, + gpio_port_pins_t set_pins, + gpio_port_pins_t clear_pins) { __ASSERT((set_pins & clear_pins) == 0, "Set and Clear pins overlap"); @@ -859,7 +877,7 @@ static inline int gpio_port_set_clr_bits(struct device *port, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_get_raw(struct device *port, gpio_pin_t pin) +static inline int gpio_pin_get_raw(const struct device *port, gpio_pin_t pin) { const struct gpio_driver_config *const cfg = (const struct gpio_driver_config *)port->config; @@ -897,7 +915,7 @@ static inline int gpio_pin_get_raw(struct device *port, gpio_pin_t pin) * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_get(struct device *port, gpio_pin_t pin) +static inline int gpio_pin_get(const struct device *port, gpio_pin_t pin) { const struct gpio_driver_config *const cfg = (const struct gpio_driver_config *)port->config; @@ -931,7 +949,7 @@ static inline int gpio_pin_get(struct device *port, gpio_pin_t pin) * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_set_raw(struct device *port, gpio_pin_t pin, +static inline int gpio_pin_set_raw(const struct device *port, gpio_pin_t pin, int value) { const struct gpio_driver_config *const cfg = @@ -972,7 +990,8 @@ static inline int gpio_pin_set_raw(struct device *port, gpio_pin_t pin, * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_set(struct device *port, gpio_pin_t pin, int value) +static inline int gpio_pin_set(const struct device *port, gpio_pin_t pin, + int value) { const struct gpio_driver_config *const cfg = (const struct gpio_driver_config *)port->config; @@ -1000,7 +1019,7 @@ static inline int gpio_pin_set(struct device *port, gpio_pin_t pin, int value) * @retval -EIO I/O error when accessing an external GPIO chip. * @retval -EWOULDBLOCK if operation would block. */ -static inline int gpio_pin_toggle(struct device *port, gpio_pin_t pin) +static inline int gpio_pin_toggle(const struct device *port, gpio_pin_t pin) { const struct gpio_driver_config *const cfg = (const struct gpio_driver_config *)port->config; @@ -1041,7 +1060,7 @@ static inline void gpio_init_callback(struct gpio_callback *callback, * * Note: enables to add as many callback as needed on the same port. */ -static inline int gpio_add_callback(struct device *port, +static inline int gpio_add_callback(const struct device *port, struct gpio_callback *callback) { const struct gpio_driver_api *api = @@ -1070,7 +1089,7 @@ static inline int gpio_add_callback(struct device *port, * Note: enables to remove as many callbacks as added through * gpio_add_callback(). */ -static inline int gpio_remove_callback(struct device *port, +static inline int gpio_remove_callback(const struct device *port, struct gpio_callback *callback) { const struct gpio_driver_api *api = @@ -1096,9 +1115,9 @@ static inline int gpio_remove_callback(struct device *port, * @retval status != 0 if at least one gpio interrupt is pending. * @retval 0 if no gpio interrupt is pending. */ -__syscall int gpio_get_pending_int(struct device *dev); +__syscall int gpio_get_pending_int(const struct device *dev); -static inline int z_impl_gpio_get_pending_int(struct device *dev) +static inline int z_impl_gpio_get_pending_int(const struct device *dev) { const struct gpio_driver_api *api = (const struct gpio_driver_api *)dev->api; diff --git a/include/drivers/gpio/gpio_mmio32.h b/include/drivers/gpio/gpio_mmio32.h index 4cb41dc2e543a1..406162f4ad5de7 100644 --- a/include/drivers/gpio/gpio_mmio32.h +++ b/include/drivers/gpio/gpio_mmio32.h @@ -26,7 +26,7 @@ struct gpio_mmio32_context { const struct gpio_mmio32_config *config; }; -int gpio_mmio32_init(struct device *dev); +int gpio_mmio32_init(const struct device *dev); #ifdef CONFIG_GPIO_MMIO32 diff --git a/include/drivers/i2c.h b/include/drivers/i2c.h index 2568640256faf1..ee6d07e578107d 100644 --- a/include/drivers/i2c.h +++ b/include/drivers/i2c.h @@ -163,17 +163,17 @@ struct i2c_slave_config { const struct i2c_slave_callbacks *callbacks; }; -typedef int (*i2c_api_configure_t)(struct device *dev, +typedef int (*i2c_api_configure_t)(const struct device *dev, uint32_t dev_config); -typedef int (*i2c_api_full_io_t)(struct device *dev, +typedef int (*i2c_api_full_io_t)(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr); -typedef int (*i2c_api_slave_register_t)(struct device *dev, +typedef int (*i2c_api_slave_register_t)(const struct device *dev, struct i2c_slave_config *cfg); -typedef int (*i2c_api_slave_unregister_t)(struct device *dev, +typedef int (*i2c_api_slave_unregister_t)(const struct device *dev, struct i2c_slave_config *cfg); -typedef int (*i2c_api_recover_bus_t)(struct device *dev); +typedef int (*i2c_api_recover_bus_t)(const struct device *dev); __subsystem struct i2c_driver_api { i2c_api_configure_t configure; @@ -183,8 +183,8 @@ __subsystem struct i2c_driver_api { i2c_api_recover_bus_t recover_bus; }; -typedef int (*i2c_slave_api_register_t)(struct device *dev); -typedef int (*i2c_slave_api_unregister_t)(struct device *dev); +typedef int (*i2c_slave_api_register_t)(const struct device *dev); +typedef int (*i2c_slave_api_unregister_t)(const struct device *dev); struct i2c_slave_driver_api { i2c_slave_api_register_t driver_register; @@ -205,9 +205,10 @@ struct i2c_slave_driver_api { * @retval 0 If successful. * @retval -EIO General input / output error, failed to configure device. */ -__syscall int i2c_configure(struct device *dev, uint32_t dev_config); +__syscall int i2c_configure(const struct device *dev, uint32_t dev_config); -static inline int z_impl_i2c_configure(struct device *dev, uint32_t dev_config) +static inline int z_impl_i2c_configure(const struct device *dev, + uint32_t dev_config) { const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->api; @@ -241,13 +242,13 @@ static inline int z_impl_i2c_configure(struct device *dev, uint32_t dev_config) * @retval 0 If successful. * @retval -EIO General input / output error. */ -__syscall int i2c_transfer(struct device *dev, +__syscall int i2c_transfer(const struct device *dev, struct i2c_msg *msgs, uint8_t num_msgs, uint16_t addr); -static inline int z_impl_i2c_transfer(struct device *dev, - struct i2c_msg *msgs, uint8_t num_msgs, - uint16_t addr) +static inline int z_impl_i2c_transfer(const struct device *dev, + struct i2c_msg *msgs, uint8_t num_msgs, + uint16_t addr) { const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->api; @@ -266,9 +267,9 @@ static inline int z_impl_i2c_transfer(struct device *dev, * @retval -EIO General input / output error. * @retval -ENOTSUP If bus recovery is not supported */ -__syscall int i2c_recover_bus(struct device *dev); +__syscall int i2c_recover_bus(const struct device *dev); -static inline int z_impl_i2c_recover_bus(struct device *dev) +static inline int z_impl_i2c_recover_bus(const struct device *dev) { const struct i2c_driver_api *api = (const struct i2c_driver_api *)dev->api; @@ -303,7 +304,7 @@ static inline int z_impl_i2c_recover_bus(struct device *dev) * @retval -EIO General input / output error. * @retval -ENOTSUP If slave mode is not supported */ -static inline int i2c_slave_register(struct device *dev, +static inline int i2c_slave_register(const struct device *dev, struct i2c_slave_config *cfg) { const struct i2c_driver_api *api = @@ -331,7 +332,7 @@ static inline int i2c_slave_register(struct device *dev, * @retval -EINVAL If parameters are invalid * @retval -ENOTSUP If slave mode is not supported */ -static inline int i2c_slave_unregister(struct device *dev, +static inline int i2c_slave_unregister(const struct device *dev, struct i2c_slave_config *cfg) { const struct i2c_driver_api *api = @@ -356,9 +357,9 @@ static inline int i2c_slave_unregister(struct device *dev, * @retval -EINVAL If parameters are invalid * @retval -EIO General input / output error. */ -__syscall int i2c_slave_driver_register(struct device *dev); +__syscall int i2c_slave_driver_register(const struct device *dev); -static inline int z_impl_i2c_slave_driver_register(struct device *dev) +static inline int z_impl_i2c_slave_driver_register(const struct device *dev) { const struct i2c_slave_driver_api *api = (const struct i2c_slave_driver_api *)dev->api; @@ -378,9 +379,9 @@ static inline int z_impl_i2c_slave_driver_register(struct device *dev) * @retval 0 Is successful * @retval -EINVAL If parameters are invalid */ -__syscall int i2c_slave_driver_unregister(struct device *dev); +__syscall int i2c_slave_driver_unregister(const struct device *dev); -static inline int z_impl_i2c_slave_driver_unregister(struct device *dev) +static inline int z_impl_i2c_slave_driver_unregister(const struct device *dev) { const struct i2c_slave_driver_api *api = (const struct i2c_slave_driver_api *)dev->api; @@ -405,7 +406,7 @@ static inline int z_impl_i2c_slave_driver_unregister(struct device *dev) * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_write(struct device *dev, const uint8_t *buf, +static inline int i2c_write(const struct device *dev, const uint8_t *buf, uint32_t num_bytes, uint16_t addr) { struct i2c_msg msg; @@ -430,7 +431,7 @@ static inline int i2c_write(struct device *dev, const uint8_t *buf, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_read(struct device *dev, uint8_t *buf, +static inline int i2c_read(const struct device *dev, uint8_t *buf, uint32_t num_bytes, uint16_t addr) { struct i2c_msg msg; @@ -459,7 +460,7 @@ static inline int i2c_read(struct device *dev, uint8_t *buf, * @retval 0 if successful * @retval negative on error. */ -static inline int i2c_write_read(struct device *dev, uint16_t addr, +static inline int i2c_write_read(const struct device *dev, uint16_t addr, const void *write_buf, size_t num_write, void *read_buf, size_t num_read) { @@ -493,7 +494,7 @@ static inline int i2c_write_read(struct device *dev, uint16_t addr, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_burst_read(struct device *dev, +static inline int i2c_burst_read(const struct device *dev, uint16_t dev_addr, uint8_t start_addr, uint8_t *buf, @@ -524,7 +525,7 @@ static inline int i2c_burst_read(struct device *dev, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_burst_write(struct device *dev, +static inline int i2c_burst_write(const struct device *dev, uint16_t dev_addr, uint8_t start_addr, const uint8_t *buf, @@ -557,7 +558,8 @@ static inline int i2c_burst_write(struct device *dev, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_reg_read_byte(struct device *dev, uint16_t dev_addr, +static inline int i2c_reg_read_byte(const struct device *dev, + uint16_t dev_addr, uint8_t reg_addr, uint8_t *value) { return i2c_write_read(dev, dev_addr, @@ -582,7 +584,8 @@ static inline int i2c_reg_read_byte(struct device *dev, uint16_t dev_addr, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_reg_write_byte(struct device *dev, uint16_t dev_addr, +static inline int i2c_reg_write_byte(const struct device *dev, + uint16_t dev_addr, uint8_t reg_addr, uint8_t value) { uint8_t tx_buf[2] = {reg_addr, value}; @@ -608,7 +611,8 @@ static inline int i2c_reg_write_byte(struct device *dev, uint16_t dev_addr, * @retval 0 If successful. * @retval -EIO General input / output error. */ -static inline int i2c_reg_update_byte(struct device *dev, uint8_t dev_addr, +static inline int i2c_reg_update_byte(const struct device *dev, + uint8_t dev_addr, uint8_t reg_addr, uint8_t mask, uint8_t value) { diff --git a/include/drivers/i2c_emul.h b/include/drivers/i2c_emul.h index c464d9da2e90ae..999bc0e966121a 100644 --- a/include/drivers/i2c_emul.h +++ b/include/drivers/i2c_emul.h @@ -65,7 +65,7 @@ typedef int (*i2c_emul_transfer_t)(struct i2c_emul *emul, struct i2c_msg *msgs, * @param emul I2C emulator to use * @return 0 indicating success (always) */ -int i2c_emul_register(struct device *dev, const char *name, +int i2c_emul_register(const struct device *dev, const char *name, struct i2c_emul *emul); /** Definition of the emulator API */ diff --git a/include/drivers/i2s.h b/include/drivers/i2s.h index 91dbf89a4592e0..164587d1ebd00d 100644 --- a/include/drivers/i2s.h +++ b/include/drivers/i2s.h @@ -313,13 +313,13 @@ struct i2s_config { * For internal use only, skip these in public documentation. */ __subsystem struct i2s_driver_api { - int (*configure)(struct device *dev, enum i2s_dir dir, + int (*configure)(const struct device *dev, enum i2s_dir dir, struct i2s_config *cfg); - struct i2s_config *(*config_get)(struct device *dev, + struct i2s_config *(*config_get)(const struct device *dev, enum i2s_dir dir); - int (*read)(struct device *dev, void **mem_block, size_t *size); - int (*write)(struct device *dev, void *mem_block, size_t size); - int (*trigger)(struct device *dev, enum i2s_dir dir, + int (*read)(const struct device *dev, void **mem_block, size_t *size); + int (*write)(const struct device *dev, void *mem_block, size_t size); + int (*trigger)(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd); }; /** @@ -345,11 +345,12 @@ __subsystem struct i2s_driver_api { * @retval 0 If successful. * @retval -EINVAL Invalid argument. */ -__syscall int i2s_configure(struct device *dev, enum i2s_dir dir, +__syscall int i2s_configure(const struct device *dev, enum i2s_dir dir, struct i2s_config *cfg); -static inline int z_impl_i2s_configure(struct device *dev, enum i2s_dir dir, - struct i2s_config *cfg) +static inline int z_impl_i2s_configure(const struct device *dev, + enum i2s_dir dir, + struct i2s_config *cfg) { const struct i2s_driver_api *api = (const struct i2s_driver_api *)dev->api; @@ -365,7 +366,7 @@ static inline int z_impl_i2s_configure(struct device *dev, enum i2s_dir dir, * @retval Pointer to the structure containing configuration parameters, * or NULL if un-configured */ -static inline struct i2s_config *i2s_config_get(struct device *dev, +static inline struct i2s_config *i2s_config_get(const struct device *dev, enum i2s_dir dir) { const struct i2s_driver_api *api = @@ -405,7 +406,7 @@ static inline struct i2s_config *i2s_config_get(struct device *dev, * @retval -EBUSY Returned without waiting. * @retval -EAGAIN Waiting period timed out. */ -static inline int i2s_read(struct device *dev, void **mem_block, +static inline int i2s_read(const struct device *dev, void **mem_block, size_t *size) { const struct i2s_driver_api *api = @@ -438,7 +439,7 @@ static inline int i2s_read(struct device *dev, void **mem_block, * @retval -EBUSY Returned without waiting. * @retval -EAGAIN Waiting period timed out. */ -__syscall int i2s_buf_read(struct device *dev, void *buf, size_t *size); +__syscall int i2s_buf_read(const struct device *dev, void *buf, size_t *size); /** * @brief Write data to the TX queue. @@ -466,7 +467,8 @@ __syscall int i2s_buf_read(struct device *dev, void *buf, size_t *size); * @retval -EBUSY Returned without waiting. * @retval -EAGAIN Waiting period timed out. */ -static inline int i2s_write(struct device *dev, void *mem_block, size_t size) +static inline int i2s_write(const struct device *dev, void *mem_block, + size_t size) { const struct i2s_driver_api *api = (const struct i2s_driver_api *)dev->api; @@ -493,7 +495,7 @@ static inline int i2s_write(struct device *dev, void *mem_block, size_t size) * @retval -ENOMEM No memory in TX slab queue. * @retval -EINVAL Size parameter larger than TX queue memory block. */ -__syscall int i2s_buf_write(struct device *dev, void *buf, size_t size); +__syscall int i2s_buf_write(const struct device *dev, void *buf, size_t size); /** * @brief Send a trigger command. @@ -508,11 +510,12 @@ __syscall int i2s_buf_write(struct device *dev, void *buf, size_t size); * channel cannot be allocated. * @retval -ENOMEM RX/TX memory block not available. */ -__syscall int i2s_trigger(struct device *dev, enum i2s_dir dir, +__syscall int i2s_trigger(const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd); -static inline int z_impl_i2s_trigger(struct device *dev, enum i2s_dir dir, - enum i2s_trigger_cmd cmd) +static inline int z_impl_i2s_trigger(const struct device *dev, + enum i2s_dir dir, + enum i2s_trigger_cmd cmd) { const struct i2s_driver_api *api = (const struct i2s_driver_api *)dev->api; diff --git a/include/drivers/ipm.h b/include/drivers/ipm.h index 3e70981f7c32ea..a415f0a0283666 100644 --- a/include/drivers/ipm.h +++ b/include/drivers/ipm.h @@ -42,7 +42,7 @@ extern "C" { * @param data Message data pointer. The correct amount of data to read out * must be inferred using the message id/upper level protocol. */ -typedef void (*ipm_callback_t)(struct device *ipmdev, void *user_data, +typedef void (*ipm_callback_t)(const struct device *ipmdev, void *user_data, uint32_t id, volatile void *data); /** @@ -51,7 +51,7 @@ typedef void (*ipm_callback_t)(struct device *ipmdev, void *user_data, * * See @a ipm_send() for argument definitions. */ -typedef int (*ipm_send_t)(struct device *ipmdev, int wait, uint32_t id, +typedef int (*ipm_send_t)(const struct device *ipmdev, int wait, uint32_t id, const void *data, int size); /** * @typedef ipm_max_data_size_get_t @@ -59,7 +59,7 @@ typedef int (*ipm_send_t)(struct device *ipmdev, int wait, uint32_t id, * * See @a ipm_max_data_size_get() for argument definitions. */ -typedef int (*ipm_max_data_size_get_t)(struct device *ipmdev); +typedef int (*ipm_max_data_size_get_t)(const struct device *ipmdev); /** * @typedef ipm_max_id_val_get_t @@ -67,7 +67,7 @@ typedef int (*ipm_max_data_size_get_t)(struct device *ipmdev); * * See @a ipm_max_id_val_get() for argument definitions. */ -typedef uint32_t (*ipm_max_id_val_get_t)(struct device *ipmdev); +typedef uint32_t (*ipm_max_id_val_get_t)(const struct device *ipmdev); /** * @typedef ipm_register_callback_t @@ -75,7 +75,8 @@ typedef uint32_t (*ipm_max_id_val_get_t)(struct device *ipmdev); * * See @a ipm_register_callback() for argument definitions. */ -typedef void (*ipm_register_callback_t)(struct device *port, ipm_callback_t cb, +typedef void (*ipm_register_callback_t)(const struct device *port, + ipm_callback_t cb, void *user_data); /** @@ -84,7 +85,7 @@ typedef void (*ipm_register_callback_t)(struct device *port, ipm_callback_t cb, * * See @a ipm_set_enabled() for argument definitions. */ -typedef int (*ipm_set_enabled_t)(struct device *ipmdev, int enable); +typedef int (*ipm_set_enabled_t)(const struct device *ipmdev, int enable); __subsystem struct ipm_driver_api { ipm_send_t send; @@ -129,11 +130,12 @@ __subsystem struct ipm_driver_api { * or the device isn't an outbound IPM channel. * @retval 0 On success. */ -__syscall int ipm_send(struct device *ipmdev, int wait, uint32_t id, +__syscall int ipm_send(const struct device *ipmdev, int wait, uint32_t id, const void *data, int size); -static inline int z_impl_ipm_send(struct device *ipmdev, int wait, uint32_t id, - const void *data, int size) +static inline int z_impl_ipm_send(const struct device *ipmdev, int wait, + uint32_t id, + const void *data, int size) { const struct ipm_driver_api *api = (const struct ipm_driver_api *)ipmdev->api; @@ -149,7 +151,7 @@ static inline int z_impl_ipm_send(struct device *ipmdev, int wait, uint32_t id, * @param user_data Application-specific data pointer which will be passed * to the callback function when executed. */ -static inline void ipm_register_callback(struct device *ipmdev, +static inline void ipm_register_callback(const struct device *ipmdev, ipm_callback_t cb, void *user_data) { const struct ipm_driver_api *api = @@ -168,9 +170,9 @@ static inline void ipm_register_callback(struct device *ipmdev, * * @return Maximum possible size of a message in bytes. */ -__syscall int ipm_max_data_size_get(struct device *ipmdev); +__syscall int ipm_max_data_size_get(const struct device *ipmdev); -static inline int z_impl_ipm_max_data_size_get(struct device *ipmdev) +static inline int z_impl_ipm_max_data_size_get(const struct device *ipmdev) { const struct ipm_driver_api *api = (const struct ipm_driver_api *)ipmdev->api; @@ -189,9 +191,9 @@ static inline int z_impl_ipm_max_data_size_get(struct device *ipmdev) * * @return Maximum possible value of a message ID. */ -__syscall uint32_t ipm_max_id_val_get(struct device *ipmdev); +__syscall uint32_t ipm_max_id_val_get(const struct device *ipmdev); -static inline uint32_t z_impl_ipm_max_id_val_get(struct device *ipmdev) +static inline uint32_t z_impl_ipm_max_id_val_get(const struct device *ipmdev) { const struct ipm_driver_api *api = (const struct ipm_driver_api *)ipmdev->api; @@ -208,9 +210,10 @@ static inline uint32_t z_impl_ipm_max_id_val_get(struct device *ipmdev) * @retval 0 On success. * @retval -EINVAL If it isn't an inbound channel. */ -__syscall int ipm_set_enabled(struct device *ipmdev, int enable); +__syscall int ipm_set_enabled(const struct device *ipmdev, int enable); -static inline int z_impl_ipm_set_enabled(struct device *ipmdev, int enable) +static inline int z_impl_ipm_set_enabled(const struct device *ipmdev, + int enable) { const struct ipm_driver_api *api = (const struct ipm_driver_api *)ipmdev->api; diff --git a/include/drivers/kscan.h b/include/drivers/kscan.h index 7c1065cbf316a4..f2f2b443311f8c 100644 --- a/include/drivers/kscan.h +++ b/include/drivers/kscan.h @@ -41,7 +41,8 @@ extern "C" { * @param row Describes row change. * @param pressed Describes the kind of key event. */ -typedef void (*kscan_callback_t)(struct device *dev, uint32_t row, uint32_t column, +typedef void (*kscan_callback_t)(const struct device *dev, uint32_t row, + uint32_t column, bool pressed); /** @@ -51,10 +52,10 @@ typedef void (*kscan_callback_t)(struct device *dev, uint32_t row, uint32_t colu * * (Internal use only.) */ -typedef int (*kscan_config_t)(struct device *dev, - kscan_callback_t callback); -typedef int (*kscan_disable_callback_t)(struct device *dev); -typedef int (*kscan_enable_callback_t)(struct device *dev); +typedef int (*kscan_config_t)(const struct device *dev, + kscan_callback_t callback); +typedef int (*kscan_disable_callback_t)(const struct device *dev); +typedef int (*kscan_enable_callback_t)(const struct device *dev); __subsystem struct kscan_driver_api { kscan_config_t config; @@ -75,10 +76,10 @@ __subsystem struct kscan_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int kscan_config(struct device *dev, +__syscall int kscan_config(const struct device *dev, kscan_callback_t callback); -static inline int z_impl_kscan_config(struct device *dev, +static inline int z_impl_kscan_config(const struct device *dev, kscan_callback_t callback) { const struct kscan_driver_api *api = @@ -93,9 +94,9 @@ static inline int z_impl_kscan_config(struct device *dev, * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int kscan_enable_callback(struct device *dev); +__syscall int kscan_enable_callback(const struct device *dev); -static inline int z_impl_kscan_enable_callback(struct device *dev) +static inline int z_impl_kscan_enable_callback(const struct device *dev) { const struct kscan_driver_api *api = (const struct kscan_driver_api *)dev->api; @@ -114,9 +115,9 @@ static inline int z_impl_kscan_enable_callback(struct device *dev) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int kscan_disable_callback(struct device *dev); +__syscall int kscan_disable_callback(const struct device *dev); -static inline int z_impl_kscan_disable_callback(struct device *dev) +static inline int z_impl_kscan_disable_callback(const struct device *dev) { const struct kscan_driver_api *api = (const struct kscan_driver_api *)dev->api; diff --git a/include/drivers/led.h b/include/drivers/led.h index 1b659b520b4018..fc892099f7a9e3 100644 --- a/include/drivers/led.h +++ b/include/drivers/led.h @@ -45,7 +45,7 @@ struct led_info { * * @see led_blink() for argument descriptions. */ -typedef int (*led_api_blink)(struct device *dev, uint32_t led, +typedef int (*led_api_blink)(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off); /** @@ -54,7 +54,7 @@ typedef int (*led_api_blink)(struct device *dev, uint32_t led, * * @see led_get_info() for argument descriptions. */ -typedef int (*led_api_get_info)(struct device *dev, uint32_t led, +typedef int (*led_api_get_info)(const struct device *dev, uint32_t led, const struct led_info **info); /** @@ -63,7 +63,7 @@ typedef int (*led_api_get_info)(struct device *dev, uint32_t led, * * @see led_set_brightness() for argument descriptions. */ -typedef int (*led_api_set_brightness)(struct device *dev, uint32_t led, +typedef int (*led_api_set_brightness)(const struct device *dev, uint32_t led, uint8_t value); /** * @typedef led_api_set_color() @@ -71,7 +71,7 @@ typedef int (*led_api_set_brightness)(struct device *dev, uint32_t led, * * @see led_set_color() for argument descriptions. */ -typedef int (*led_api_set_color)(struct device *dev, uint32_t led, +typedef int (*led_api_set_color)(const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color); /** @@ -80,7 +80,7 @@ typedef int (*led_api_set_color)(struct device *dev, uint32_t led, * * @see led_on() for argument descriptions. */ -typedef int (*led_api_on)(struct device *dev, uint32_t led); +typedef int (*led_api_on)(const struct device *dev, uint32_t led); /** * @typedef led_api_off() @@ -88,7 +88,7 @@ typedef int (*led_api_on)(struct device *dev, uint32_t led); * * @see led_off() for argument descriptions. */ -typedef int (*led_api_off)(struct device *dev, uint32_t led); +typedef int (*led_api_off)(const struct device *dev, uint32_t led); /** * @typedef led_api_write_channels() @@ -96,7 +96,7 @@ typedef int (*led_api_off)(struct device *dev, uint32_t led); * * @see led_api_write_channels() for arguments descriptions. */ -typedef int (*led_api_write_channels)(struct device *dev, +typedef int (*led_api_write_channels)(const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf); @@ -128,11 +128,11 @@ __subsystem struct led_driver_api { * @param delay_off Time period (in milliseconds) an LED should be OFF * @return 0 on success, negative on error */ -__syscall int led_blink(struct device *dev, uint32_t led, +__syscall int led_blink(const struct device *dev, uint32_t led, uint32_t delay_on, uint32_t delay_off); -static inline int z_impl_led_blink(struct device *dev, uint32_t led, - uint32_t delay_on, uint32_t delay_off) +static inline int z_impl_led_blink(const struct device *dev, uint32_t led, + uint32_t delay_on, uint32_t delay_off) { const struct led_driver_api *api = (const struct led_driver_api *)dev->api; @@ -153,10 +153,10 @@ static inline int z_impl_led_blink(struct device *dev, uint32_t led, * @param info Pointer to a pointer filled with LED information * @return 0 on success, negative on error */ -__syscall int led_get_info(struct device *dev, uint32_t led, +__syscall int led_get_info(const struct device *dev, uint32_t led, const struct led_info **info); -static inline int z_impl_led_get_info(struct device *dev, uint32_t led, +static inline int z_impl_led_get_info(const struct device *dev, uint32_t led, const struct led_info **info) { const struct led_driver_api *api = @@ -180,11 +180,12 @@ static inline int z_impl_led_get_info(struct device *dev, uint32_t led, * @param value Brightness value to set in percent * @return 0 on success, negative on error */ -__syscall int led_set_brightness(struct device *dev, uint32_t led, +__syscall int led_set_brightness(const struct device *dev, uint32_t led, uint8_t value); -static inline int z_impl_led_set_brightness(struct device *dev, uint32_t led, - uint8_t value) +static inline int z_impl_led_set_brightness(const struct device *dev, + uint32_t led, + uint8_t value) { const struct led_driver_api *api = (const struct led_driver_api *)dev->api; @@ -211,11 +212,12 @@ static inline int z_impl_led_set_brightness(struct device *dev, uint32_t led, * entries must be provided. * @return 0 on success, negative on error */ -__syscall int led_write_channels(struct device *dev, uint32_t start_channel, +__syscall int led_write_channels(const struct device *dev, + uint32_t start_channel, uint32_t num_channels, const uint8_t *buf); static inline int -z_impl_led_write_channels(struct device *dev, uint32_t start_channel, +z_impl_led_write_channels(const struct device *dev, uint32_t start_channel, uint32_t num_channels, const uint8_t *buf) { const struct led_driver_api *api = @@ -239,10 +241,10 @@ z_impl_led_write_channels(struct device *dev, uint32_t start_channel, * @param value Value to configure the channel with * @return 0 on success, negative on error */ -__syscall int led_set_channel(struct device *dev, +__syscall int led_set_channel(const struct device *dev, uint32_t channel, uint8_t value); -static inline int z_impl_led_set_channel(struct device *dev, +static inline int z_impl_led_set_channel(const struct device *dev, uint32_t channel, uint8_t value) { return z_impl_led_write_channels(dev, channel, 1, &value); @@ -264,10 +266,10 @@ static inline int z_impl_led_set_channel(struct device *dev, * in struct led_info. * @return 0 on success, negative on error */ -__syscall int led_set_color(struct device *dev, uint32_t led, +__syscall int led_set_color(const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color); -static inline int z_impl_led_set_color(struct device *dev, uint32_t led, +static inline int z_impl_led_set_color(const struct device *dev, uint32_t led, uint8_t num_colors, const uint8_t *color) { const struct led_driver_api *api = @@ -288,9 +290,9 @@ static inline int z_impl_led_set_color(struct device *dev, uint32_t led, * @param led LED number * @return 0 on success, negative on error */ -__syscall int led_on(struct device *dev, uint32_t led); +__syscall int led_on(const struct device *dev, uint32_t led); -static inline int z_impl_led_on(struct device *dev, uint32_t led) +static inline int z_impl_led_on(const struct device *dev, uint32_t led) { const struct led_driver_api *api = (const struct led_driver_api *)dev->api; @@ -307,9 +309,9 @@ static inline int z_impl_led_on(struct device *dev, uint32_t led) * @param led LED number * @return 0 on success, negative on error */ -__syscall int led_off(struct device *dev, uint32_t led); +__syscall int led_off(const struct device *dev, uint32_t led); -static inline int z_impl_led_off(struct device *dev, uint32_t led) +static inline int z_impl_led_off(const struct device *dev, uint32_t led) { const struct led_driver_api *api = (const struct led_driver_api *)dev->api; diff --git a/include/drivers/led/ht16k33.h b/include/drivers/led/ht16k33.h index fb6e91de3db6db..c73c62e003d503 100644 --- a/include/drivers/led/ht16k33.h +++ b/include/drivers/led/ht16k33.h @@ -22,8 +22,8 @@ * child device (0, 1, or 2). * @return 0 if successful, negative errno code on failure. */ -int ht16k33_register_keyscan_device(struct device *parent, - struct device *child, +int ht16k33_register_keyscan_device(const struct device *parent, + const struct device *child, uint8_t keyscan_idx); /** @@ -32,7 +32,7 @@ int ht16k33_register_keyscan_device(struct device *parent, * @param parent HT16K33 parent device. * @return status != 0 if an interrupt is pending. */ -uint32_t ht16k33_get_pending_int(struct device *parent); +uint32_t ht16k33_get_pending_int(const struct device *parent); /** * Dispatch keyscan row data from a keyscan event to be handled by a @@ -41,7 +41,7 @@ uint32_t ht16k33_get_pending_int(struct device *parent); * @param child HT16K33 keyscan child device. * @param keys Bitmask of key state for the row. */ -void ht16k33_process_keyscan_row_data(struct device *child, +void ht16k33_process_keyscan_row_data(const struct device *child, uint32_t keys); #endif /* ZEPHYR_INCLUDE_DRIVERS_LED_HT16K33_H_ */ diff --git a/include/drivers/led_strip.h b/include/drivers/led_strip.h index 7f324f2add0010..d8636eb54583b0 100644 --- a/include/drivers/led_strip.h +++ b/include/drivers/led_strip.h @@ -57,7 +57,8 @@ struct led_rgb { * * @see led_strip_update_rgb() for argument descriptions. */ -typedef int (*led_api_update_rgb)(struct device *dev, struct led_rgb *pixels, +typedef int (*led_api_update_rgb)(const struct device *dev, + struct led_rgb *pixels, size_t num_pixels); /** @@ -66,7 +67,8 @@ typedef int (*led_api_update_rgb)(struct device *dev, struct led_rgb *pixels, * * @see led_strip_update_channels() for argument descriptions. */ -typedef int (*led_api_update_channels)(struct device *dev, uint8_t *channels, +typedef int (*led_api_update_channels)(const struct device *dev, + uint8_t *channels, size_t num_channels); /** @@ -94,7 +96,7 @@ struct led_strip_driver_api { * @return 0 on success, negative on error * @warning May overwrite @a pixels */ -static inline int led_strip_update_rgb(struct device *dev, +static inline int led_strip_update_rgb(const struct device *dev, struct led_rgb *pixels, size_t num_pixels) { const struct led_strip_driver_api *api = @@ -120,7 +122,7 @@ static inline int led_strip_update_rgb(struct device *dev, * @return 0 on success, negative on error * @warning May overwrite @a channels */ -static inline int led_strip_update_channels(struct device *dev, +static inline int led_strip_update_channels(const struct device *dev, uint8_t *channels, size_t num_channels) { const struct led_strip_driver_api *api = diff --git a/include/drivers/lora.h b/include/drivers/lora.h index 41ffda6364aef5..65aa71bb35f84e 100644 --- a/include/drivers/lora.h +++ b/include/drivers/lora.h @@ -54,7 +54,7 @@ struct lora_modem_config { * * @see lora_config() for argument descriptions. */ -typedef int (*lora_api_config)(struct device *dev, +typedef int (*lora_api_config)(const struct device *dev, struct lora_modem_config *config); /** @@ -63,7 +63,7 @@ typedef int (*lora_api_config)(struct device *dev, * * @see lora_send() for argument descriptions. */ -typedef int (*lora_api_send)(struct device *dev, +typedef int (*lora_api_send)(const struct device *dev, uint8_t *data, uint32_t data_len); /** @@ -72,7 +72,8 @@ typedef int (*lora_api_send)(struct device *dev, * * @see lora_recv() for argument descriptions. */ -typedef int (*lora_api_recv)(struct device *dev, uint8_t *data, uint8_t size, +typedef int (*lora_api_recv)(const struct device *dev, uint8_t *data, + uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr); /** @@ -81,7 +82,7 @@ typedef int (*lora_api_recv)(struct device *dev, uint8_t *data, uint8_t size, * * @see lora_test_cw() for argument descriptions. */ -typedef int (*lora_api_test_cw)(struct device *dev, uint32_t frequency, +typedef int (*lora_api_test_cw)(const struct device *dev, uint32_t frequency, int8_t tx_power, uint16_t duration); struct lora_driver_api { @@ -99,7 +100,7 @@ struct lora_driver_api { modem * @return 0 on success, negative on error */ -static inline int lora_config(struct device *dev, +static inline int lora_config(const struct device *dev, struct lora_modem_config *config) { const struct lora_driver_api *api = dev->api; @@ -117,7 +118,7 @@ static inline int lora_config(struct device *dev, * @param data_len Length of the data to be sent * @return 0 on success, negative on error */ -static inline int lora_send(struct device *dev, +static inline int lora_send(const struct device *dev, uint8_t *data, uint32_t data_len) { const struct lora_driver_api *api = dev->api; @@ -141,7 +142,8 @@ static inline int lora_send(struct device *dev, * @param snr SNR of received data * @return Length of the data received on success, negative on error */ -static inline int lora_recv(struct device *dev, uint8_t *data, uint8_t size, +static inline int lora_recv(const struct device *dev, uint8_t *data, + uint8_t size, k_timeout_t timeout, int16_t *rssi, int8_t *snr) { const struct lora_driver_api *api = dev->api; @@ -161,7 +163,7 @@ static inline int lora_recv(struct device *dev, uint8_t *data, uint8_t size, * @param duration Transmission duration in seconds. * @return 0 on success, negative on error */ -static inline int lora_test_cw(struct device *dev, uint32_t frequency, +static inline int lora_test_cw(const struct device *dev, uint32_t frequency, int8_t tx_power, uint16_t duration) { const struct lora_driver_api *api = dev->api; diff --git a/include/drivers/pcie/endpoint/pcie_ep.h b/include/drivers/pcie/endpoint/pcie_ep.h index f01747abdc072f..5e708aa98252b8 100644 --- a/include/drivers/pcie/endpoint/pcie_ep.h +++ b/include/drivers/pcie/endpoint/pcie_ep.h @@ -57,15 +57,19 @@ enum pcie_reset { typedef void (*pcie_ep_reset_callback_t)(void *arg); struct pcie_ep_driver_api { - int (*conf_read)(struct device *dev, uint32_t offset, uint32_t *data); - void (*conf_write)(struct device *dev, uint32_t offset, uint32_t data); - int (*map_addr)(struct device *dev, uint64_t pcie_addr, + int (*conf_read)(const struct device *dev, uint32_t offset, + uint32_t *data); + void (*conf_write)(const struct device *dev, uint32_t offset, + uint32_t data); + int (*map_addr)(const struct device *dev, uint64_t pcie_addr, uint64_t *mapped_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type); - void (*unmap_addr)(struct device *dev, uint64_t mapped_addr); - int (*raise_irq)(struct device *dev, enum pci_ep_irq_type irq_type, + void (*unmap_addr)(const struct device *dev, uint64_t mapped_addr); + int (*raise_irq)(const struct device *dev, + enum pci_ep_irq_type irq_type, uint32_t irq_num); - int (*register_reset_cb)(struct device *dev, enum pcie_reset reset, + int (*register_reset_cb)(const struct device *dev, + enum pcie_reset reset, pcie_ep_reset_callback_t cb, void *arg); }; @@ -81,7 +85,7 @@ struct pcie_ep_driver_api { * @return 0 if successful, negative errno code if failure. */ -static inline int pcie_ep_conf_read(struct device *dev, +static inline int pcie_ep_conf_read(const struct device *dev, uint32_t offset, uint32_t *data) { const struct pcie_ep_driver_api *api = @@ -102,7 +106,7 @@ static inline int pcie_ep_conf_read(struct device *dev, * @return N/A */ -static inline void pcie_ep_conf_write(struct device *dev, +static inline void pcie_ep_conf_write(const struct device *dev, uint32_t offset, uint32_t data) { const struct pcie_ep_driver_api *api = @@ -136,7 +140,8 @@ static inline void pcie_ep_conf_write(struct device *dev, * @return Negative errno code if failure. */ -static inline int pcie_ep_map_addr(struct device *dev, uint64_t pcie_addr, +static inline int pcie_ep_map_addr(const struct device *dev, + uint64_t pcie_addr, uint64_t *mapped_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type) { @@ -159,7 +164,8 @@ static inline int pcie_ep_map_addr(struct device *dev, uint64_t pcie_addr, * @return N/A */ -static inline void pcie_ep_unmap_addr(struct device *dev, uint64_t mapped_addr) +static inline void pcie_ep_unmap_addr(const struct device *dev, + uint64_t mapped_addr) { const struct pcie_ep_driver_api *api = (const struct pcie_ep_driver_api *)dev->api; @@ -179,7 +185,7 @@ static inline void pcie_ep_unmap_addr(struct device *dev, uint64_t mapped_addr) * @return 0 if successful, negative errno code if failure. */ -static inline int pcie_ep_raise_irq(struct device *dev, +static inline int pcie_ep_raise_irq(const struct device *dev, enum pci_ep_irq_type irq_type, uint32_t irq_num) { @@ -203,7 +209,7 @@ static inline int pcie_ep_raise_irq(struct device *dev, * @return 0 if successful, negative errno code if failure. */ -static inline int pcie_ep_register_reset_cb(struct device *dev, +static inline int pcie_ep_register_reset_cb(const struct device *dev, enum pcie_reset reset, pcie_ep_reset_callback_t cb, void *arg) @@ -224,7 +230,7 @@ static inline int pcie_ep_register_reset_cb(struct device *dev, * @details Helper API to achieve data transfer with memcpy * through PCIe outbound memory */ -int pcie_ep_xfer_data_memcpy(struct device *dev, uint64_t pcie_addr, +int pcie_ep_xfer_data_memcpy(const struct device *dev, uint64_t pcie_addr, uintptr_t *local_addr, uint32_t size, enum pcie_ob_mem_type ob_mem_type, enum xfer_direction dir); diff --git a/include/drivers/peci.h b/include/drivers/peci.h index 3839997d2830a7..c8155da1ff0cef 100644 --- a/include/drivers/peci.h +++ b/include/drivers/peci.h @@ -192,10 +192,10 @@ struct peci_msg { * * (Internal use only.) */ -typedef int (*peci_config_t)(struct device *dev, uint32_t bitrate); -typedef int (*peci_transfer_t)(struct device *dev, struct peci_msg *msg); -typedef int (*peci_disable_t)(struct device *dev); -typedef int (*peci_enable_t)(struct device *dev); +typedef int (*peci_config_t)(const struct device *dev, uint32_t bitrate); +typedef int (*peci_transfer_t)(const struct device *dev, struct peci_msg *msg); +typedef int (*peci_disable_t)(const struct device *dev); +typedef int (*peci_enable_t)(const struct device *dev); struct peci_driver_api { peci_config_t config; @@ -218,9 +218,10 @@ struct peci_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int peci_config(struct device *dev, uint32_t bitrate); +__syscall int peci_config(const struct device *dev, uint32_t bitrate); -static inline int z_impl_peci_config(struct device *dev, uint32_t bitrate) +static inline int z_impl_peci_config(const struct device *dev, + uint32_t bitrate) { struct peci_driver_api *api; @@ -236,9 +237,9 @@ static inline int z_impl_peci_config(struct device *dev, uint32_t bitrate) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int peci_enable(struct device *dev); +__syscall int peci_enable(const struct device *dev); -static inline int z_impl_peci_enable(struct device *dev) +static inline int z_impl_peci_enable(const struct device *dev) { struct peci_driver_api *api; @@ -254,9 +255,9 @@ static inline int z_impl_peci_enable(struct device *dev) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int peci_disable(struct device *dev); +__syscall int peci_disable(const struct device *dev); -static inline int z_impl_peci_disable(struct device *dev) +static inline int z_impl_peci_disable(const struct device *dev) { struct peci_driver_api *api; @@ -274,9 +275,9 @@ static inline int z_impl_peci_disable(struct device *dev) * @retval Negative errno code if failure. */ -__syscall int peci_transfer(struct device *dev, struct peci_msg *msg); +__syscall int peci_transfer(const struct device *dev, struct peci_msg *msg); -static inline int z_impl_peci_transfer(struct device *dev, +static inline int z_impl_peci_transfer(const struct device *dev, struct peci_msg *msg) { struct peci_driver_api *api; diff --git a/include/drivers/pinmux.h b/include/drivers/pinmux.h index b75f6d81fa0d44..d2fe68775d3152 100644 --- a/include/drivers/pinmux.h +++ b/include/drivers/pinmux.h @@ -54,25 +54,28 @@ extern "C" { * @brief Callback API upon setting a PIN's function * See pinmux_pin_set() for argument description */ -typedef int (*pmux_set)(struct device *dev, uint32_t pin, uint32_t func); +typedef int (*pmux_set)(const struct device *dev, uint32_t pin, uint32_t func); /** * @typedef pmux_get * @brief Callback API upon getting a PIN's function * See pinmux_pin_get() for argument description */ -typedef int (*pmux_get)(struct device *dev, uint32_t pin, uint32_t *func); +typedef int (*pmux_get)(const struct device *dev, uint32_t pin, + uint32_t *func); /** * @typedef pmux_pullup * @brief Callback API upon setting a PIN's pullup * See pinmix_pin_pullup() for argument description */ -typedef int (*pmux_pullup)(struct device *dev, uint32_t pin, uint8_t func); +typedef int (*pmux_pullup)(const struct device *dev, uint32_t pin, + uint8_t func); /** * @typedef pmux_input * @brief Callback API upon setting a PIN's input function * See pinmux_input() for argument description */ -typedef int (*pmux_input)(struct device *dev, uint32_t pin, uint8_t func); +typedef int (*pmux_input)(const struct device *dev, uint32_t pin, + uint8_t func); __subsystem struct pinmux_driver_api { pmux_set set; @@ -81,7 +84,8 @@ __subsystem struct pinmux_driver_api { pmux_input input; }; -static inline int pinmux_pin_set(struct device *dev, uint32_t pin, uint32_t func) +static inline int pinmux_pin_set(const struct device *dev, uint32_t pin, + uint32_t func) { const struct pinmux_driver_api *api = (const struct pinmux_driver_api *)dev->api; @@ -89,7 +93,8 @@ static inline int pinmux_pin_set(struct device *dev, uint32_t pin, uint32_t func return api->set(dev, pin, func); } -static inline int pinmux_pin_get(struct device *dev, uint32_t pin, uint32_t *func) +static inline int pinmux_pin_get(const struct device *dev, uint32_t pin, + uint32_t *func) { const struct pinmux_driver_api *api = (const struct pinmux_driver_api *)dev->api; @@ -97,7 +102,8 @@ static inline int pinmux_pin_get(struct device *dev, uint32_t pin, uint32_t *fun return api->get(dev, pin, func); } -static inline int pinmux_pin_pullup(struct device *dev, uint32_t pin, uint8_t func) +static inline int pinmux_pin_pullup(const struct device *dev, uint32_t pin, + uint8_t func) { const struct pinmux_driver_api *api = (const struct pinmux_driver_api *)dev->api; @@ -105,7 +111,8 @@ static inline int pinmux_pin_pullup(struct device *dev, uint32_t pin, uint8_t fu return api->pullup(dev, pin, func); } -static inline int pinmux_pin_input_enable(struct device *dev, uint32_t pin, +static inline int pinmux_pin_input_enable(const struct device *dev, + uint32_t pin, uint8_t func) { const struct pinmux_driver_api *api = diff --git a/include/drivers/ps2.h b/include/drivers/ps2.h index 4a54d9e8676e57..06c0edc52d1da6 100644 --- a/include/drivers/ps2.h +++ b/include/drivers/ps2.h @@ -35,7 +35,7 @@ extern "C" { * @param dev Pointer to the device structure for the driver instance. * @param data Data byte passed pack to the user. */ -typedef void (*ps2_callback_t)(struct device *dev, uint8_t data); +typedef void (*ps2_callback_t)(const struct device *dev, uint8_t data); /** * @cond INTERNAL_HIDDEN @@ -44,11 +44,12 @@ typedef void (*ps2_callback_t)(struct device *dev, uint8_t data); * * (Internal use only.) */ -typedef int (*ps2_config_t)(struct device *dev, ps2_callback_t callback_isr); -typedef int (*ps2_read_t)(struct device *dev, uint8_t *value); -typedef int (*ps2_write_t)(struct device *dev, uint8_t value); -typedef int (*ps2_disable_callback_t)(struct device *dev); -typedef int (*ps2_enable_callback_t)(struct device *dev); +typedef int (*ps2_config_t)(const struct device *dev, + ps2_callback_t callback_isr); +typedef int (*ps2_read_t)(const struct device *dev, uint8_t *value); +typedef int (*ps2_write_t)(const struct device *dev, uint8_t value); +typedef int (*ps2_disable_callback_t)(const struct device *dev); +typedef int (*ps2_enable_callback_t)(const struct device *dev); __subsystem struct ps2_driver_api { ps2_config_t config; @@ -71,9 +72,10 @@ __subsystem struct ps2_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int ps2_config(struct device *dev, ps2_callback_t callback_isr); +__syscall int ps2_config(const struct device *dev, + ps2_callback_t callback_isr); -static inline int z_impl_ps2_config(struct device *dev, +static inline int z_impl_ps2_config(const struct device *dev, ps2_callback_t callback_isr) { const struct ps2_driver_api *api = @@ -91,9 +93,9 @@ static inline int z_impl_ps2_config(struct device *dev, * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int ps2_write(struct device *dev, uint8_t value); +__syscall int ps2_write(const struct device *dev, uint8_t value); -static inline int z_impl_ps2_write(struct device *dev, uint8_t value) +static inline int z_impl_ps2_write(const struct device *dev, uint8_t value) { const struct ps2_driver_api *api = (const struct ps2_driver_api *)dev->api; @@ -109,9 +111,9 @@ static inline int z_impl_ps2_write(struct device *dev, uint8_t value) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int ps2_read(struct device *dev, uint8_t *value); +__syscall int ps2_read(const struct device *dev, uint8_t *value); -static inline int z_impl_ps2_read(struct device *dev, uint8_t *value) +static inline int z_impl_ps2_read(const struct device *dev, uint8_t *value) { const struct ps2_driver_api *api = (const struct ps2_driver_api *)dev->api; @@ -126,9 +128,9 @@ static inline int z_impl_ps2_read(struct device *dev, uint8_t *value) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int ps2_enable_callback(struct device *dev); +__syscall int ps2_enable_callback(const struct device *dev); -static inline int z_impl_ps2_enable_callback(struct device *dev) +static inline int z_impl_ps2_enable_callback(const struct device *dev) { const struct ps2_driver_api *api = (const struct ps2_driver_api *)dev->api; @@ -147,9 +149,9 @@ static inline int z_impl_ps2_enable_callback(struct device *dev) * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int ps2_disable_callback(struct device *dev); +__syscall int ps2_disable_callback(const struct device *dev); -static inline int z_impl_ps2_disable_callback(struct device *dev) +static inline int z_impl_ps2_disable_callback(const struct device *dev) { const struct ps2_driver_api *api = (const struct ps2_driver_api *)dev->api; diff --git a/include/drivers/pwm.h b/include/drivers/pwm.h index ab40b19830ea66..051d18587eeb98 100644 --- a/include/drivers/pwm.h +++ b/include/drivers/pwm.h @@ -39,7 +39,7 @@ typedef uint8_t pwm_flags_t; * @brief Callback API upon setting the pin * See @a pwm_pin_set_cycles() for argument description */ -typedef int (*pwm_pin_set_t)(struct device *dev, uint32_t pwm, +typedef int (*pwm_pin_set_t)(const struct device *dev, uint32_t pwm, uint32_t period_cycles, uint32_t pulse_cycles, pwm_flags_t flags); @@ -48,7 +48,8 @@ typedef int (*pwm_pin_set_t)(struct device *dev, uint32_t pwm, * @brief Callback API upon getting cycles per second * See @a pwm_get_cycles_per_sec() for argument description */ -typedef int (*pwm_get_cycles_per_sec_t)(struct device *dev, uint32_t pwm, +typedef int (*pwm_get_cycles_per_sec_t)(const struct device *dev, + uint32_t pwm, uint64_t *cycles); /** @brief PWM driver API definition. */ @@ -74,10 +75,11 @@ __subsystem struct pwm_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int pwm_pin_set_cycles(struct device *dev, uint32_t pwm, +__syscall int pwm_pin_set_cycles(const struct device *dev, uint32_t pwm, uint32_t period, uint32_t pulse, pwm_flags_t flags); -static inline int z_impl_pwm_pin_set_cycles(struct device *dev, uint32_t pwm, +static inline int z_impl_pwm_pin_set_cycles(const struct device *dev, + uint32_t pwm, uint32_t period, uint32_t pulse, pwm_flags_t flags) { @@ -99,11 +101,12 @@ static inline int z_impl_pwm_pin_set_cycles(struct device *dev, uint32_t pwm, * @retval Negative errno code if failure. */ -__syscall int pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, +__syscall int pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm, uint64_t *cycles); -static inline int z_impl_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm, - uint64_t *cycles) +static inline int z_impl_pwm_get_cycles_per_sec(const struct device *dev, + uint32_t pwm, + uint64_t *cycles) { struct pwm_driver_api *api; @@ -123,7 +126,7 @@ static inline int z_impl_pwm_get_cycles_per_sec(struct device *dev, uint32_t pwm * @retval 0 If successful. * @retval Negative errno code if failure. */ -static inline int pwm_pin_set_usec(struct device *dev, uint32_t pwm, +static inline int pwm_pin_set_usec(const struct device *dev, uint32_t pwm, uint32_t period, uint32_t pulse, pwm_flags_t flags) { @@ -159,7 +162,7 @@ static inline int pwm_pin_set_usec(struct device *dev, uint32_t pwm, * @retval 0 If successful. * @retval Negative errno code if failure. */ -static inline int pwm_pin_set_nsec(struct device *dev, uint32_t pwm, +static inline int pwm_pin_set_nsec(const struct device *dev, uint32_t pwm, uint32_t period, uint32_t pulse, pwm_flags_t flags) { diff --git a/include/drivers/rtc/maxim_ds3231.h b/include/drivers/rtc/maxim_ds3231.h index 64f93e8d59e415..68d91bb6b60678 100644 --- a/include/drivers/rtc/maxim_ds3231.h +++ b/include/drivers/rtc/maxim_ds3231.h @@ -228,7 +228,7 @@ extern "C" { * @param user_data the corresponding parameter from * maxim_ds3231_alarm::user_data. */ -typedef void (*maxim_ds3231_alarm_callback_handler_t)(struct device *dev, +typedef void (*maxim_ds3231_alarm_callback_handler_t)(const struct device *dev, uint8_t id, uint32_t syncclock, void *user_data); @@ -245,7 +245,7 @@ typedef void (*maxim_ds3231_alarm_callback_handler_t)(struct device *dev, * * @param res the result of the operation. */ -typedef void (*maxim_ds3231_notify_callback)(struct device *dev, +typedef void (*maxim_ds3231_notify_callback)(const struct device *dev, struct sys_notify *notify, int res); @@ -358,7 +358,7 @@ struct maxim_ds3231_syncpoint { * * @return the current value of the synchronization clock. */ -static inline uint32_t maxim_ds3231_read_syncclock(struct device *dev) +static inline uint32_t maxim_ds3231_read_syncclock(const struct device *dev) { return k_uptime_get_32(); } @@ -371,7 +371,7 @@ static inline uint32_t maxim_ds3231_read_syncclock(struct device *dev) * * @return the frequency of the selected synchronization clock. */ -static inline uint32_t maxim_ds3231_syncclock_frequency(struct device *dev) +static inline uint32_t maxim_ds3231_syncclock_frequency(const struct device *dev) { return 1000U; } @@ -393,7 +393,7 @@ static inline uint32_t maxim_ds3231_syncclock_frequency(struct device *dev) * @return the non-negative updated value of the register, or a * negative error code from an I2C transaction. */ -int maxim_ds3231_ctrl_update(struct device *dev, +int maxim_ds3231_ctrl_update(const struct device *dev, uint8_t set_bits, uint8_t clear_bits); @@ -426,7 +426,7 @@ int maxim_ds3231_ctrl_update(struct device *dev, * (disregarding the effect of clears and sets), or a negative error * code from an I2C transaction. */ -int maxim_ds3231_stat_update(struct device *dev, +int maxim_ds3231_stat_update(const struct device *dev, uint8_t set_bits, uint8_t clear_bits); @@ -448,7 +448,7 @@ int maxim_ds3231_stat_update(struct device *dev, * @return a non-negative value indicating successful conversion, or a * negative error code from an I2C transaction or invalid parameter. */ -int maxim_ds3231_get_alarm(struct device *dev, +int maxim_ds3231_get_alarm(const struct device *dev, uint8_t id, struct maxim_ds3231_alarm *cfg); @@ -472,7 +472,7 @@ int maxim_ds3231_get_alarm(struct device *dev, * @return a non-negative value on success, or a negative error code * from an I2C transaction or an invalid parameter. */ -int maxim_ds3231_set_alarm(struct device *dev, +int maxim_ds3231_set_alarm(const struct device *dev, uint8_t id, const struct maxim_ds3231_alarm *cfg); @@ -502,7 +502,7 @@ int maxim_ds3231_set_alarm(struct device *dev, * @retval -EINVAL if notify is not provided * @retval -ENOTSUP if the required interrupt is not configured */ -int maxim_ds3231_synchronize(struct device *dev, +int maxim_ds3231_synchronize(const struct device *dev, struct sys_notify *notify); /** @brief Request to update the synchronization point. @@ -520,7 +520,7 @@ int maxim_ds3231_synchronize(struct device *dev, * @retval -EBUSY if a synchronization or set is currently in progress * @retval -ENOTSUP if the required interrupt is not configured */ -__syscall int maxim_ds3231_req_syncpoint(struct device *dev, +__syscall int maxim_ds3231_req_syncpoint(const struct device *dev, struct k_poll_signal *signal); /** @brief Retrieve the most recent synchronization point. @@ -535,7 +535,7 @@ __syscall int maxim_ds3231_req_syncpoint(struct device *dev, * @retval non-negative on success * @retval -ENOENT if no syncpoint has been captured */ -__syscall int maxim_ds3231_get_syncpoint(struct device *dev, +__syscall int maxim_ds3231_get_syncpoint(const struct device *dev, struct maxim_ds3231_syncpoint *syncpoint); /** @brief Set the RTC to a time consistent with the provided @@ -565,7 +565,7 @@ __syscall int maxim_ds3231_get_syncpoint(struct device *dev, * @retval -ENOTSUP if the required interrupt signal is not configured * @retval -EBUSY if a synchronization or set is currently in progress */ -int maxim_ds3231_set(struct device *dev, +int maxim_ds3231_set(const struct device *dev, const struct maxim_ds3231_syncpoint *syncpoint, struct sys_notify *notify); @@ -586,7 +586,7 @@ int maxim_ds3231_set(struct device *dev, * @return a non-negative value that may have MAXIM_DS3231_ALARM1 and/or * MAXIM_DS3231_ALARM2 set, or a negative error code. */ -int maxim_ds3231_check_alarms(struct device *dev); +int maxim_ds3231_check_alarms(const struct device *dev); /** * @} diff --git a/include/drivers/sensor.h b/include/drivers/sensor.h index f320898d36aeca..04035f0f63ae30 100644 --- a/include/drivers/sensor.h +++ b/include/drivers/sensor.h @@ -319,7 +319,7 @@ enum sensor_attribute { * @param "struct device *dev" Pointer to the sensor device * @param "struct sensor_trigger *trigger" The trigger */ -typedef void (*sensor_trigger_handler_t)(struct device *dev, +typedef void (*sensor_trigger_handler_t)(const struct device *dev, struct sensor_trigger *trigger); /** @@ -328,7 +328,7 @@ typedef void (*sensor_trigger_handler_t)(struct device *dev, * * See sensor_attr_set() for argument description */ -typedef int (*sensor_attr_set_t)(struct device *dev, +typedef int (*sensor_attr_set_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); @@ -339,7 +339,7 @@ typedef int (*sensor_attr_set_t)(struct device *dev, * * See sensor_attr_get() for argument description */ -typedef int (*sensor_attr_get_t)(struct device *dev, +typedef int (*sensor_attr_get_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val); @@ -350,7 +350,7 @@ typedef int (*sensor_attr_get_t)(struct device *dev, * * See sensor_trigger_set() for argument description */ -typedef int (*sensor_trigger_set_t)(struct device *dev, +typedef int (*sensor_trigger_set_t)(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler); /** @@ -359,7 +359,7 @@ typedef int (*sensor_trigger_set_t)(struct device *dev, * * See sensor_sample_fetch() for argument description */ -typedef int (*sensor_sample_fetch_t)(struct device *dev, +typedef int (*sensor_sample_fetch_t)(const struct device *dev, enum sensor_channel chan); /** * @typedef sensor_channel_get_t @@ -367,7 +367,7 @@ typedef int (*sensor_sample_fetch_t)(struct device *dev, * * See sensor_channel_get() for argument description */ -typedef int (*sensor_channel_get_t)(struct device *dev, +typedef int (*sensor_channel_get_t)(const struct device *dev, enum sensor_channel chan, struct sensor_value *val); @@ -391,15 +391,15 @@ __subsystem struct sensor_driver_api { * * @return 0 if successful, negative errno code if failure. */ -__syscall int sensor_attr_set(struct device *dev, +__syscall int sensor_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val); -static inline int z_impl_sensor_attr_set(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +static inline int z_impl_sensor_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; @@ -423,15 +423,15 @@ static inline int z_impl_sensor_attr_set(struct device *dev, * * @return 0 if successful, negative errno code if failure. */ -__syscall int sensor_attr_get(struct device *dev, +__syscall int sensor_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val); -static inline int z_impl_sensor_attr_get(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - struct sensor_value *val) +static inline int z_impl_sensor_attr_get(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + struct sensor_value *val) { const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; @@ -460,7 +460,7 @@ static inline int z_impl_sensor_attr_get(struct device *dev, * * @return 0 if successful, negative errno code if failure. */ -static inline int sensor_trigger_set(struct device *dev, +static inline int sensor_trigger_set(const struct device *dev, struct sensor_trigger *trig, sensor_trigger_handler_t handler) { @@ -490,9 +490,9 @@ static inline int sensor_trigger_set(struct device *dev, * * @return 0 if successful, negative errno code if failure. */ -__syscall int sensor_sample_fetch(struct device *dev); +__syscall int sensor_sample_fetch(const struct device *dev); -static inline int z_impl_sensor_sample_fetch(struct device *dev) +static inline int z_impl_sensor_sample_fetch(const struct device *dev) { const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; @@ -519,11 +519,11 @@ static inline int z_impl_sensor_sample_fetch(struct device *dev) * * @return 0 if successful, negative errno code if failure. */ -__syscall int sensor_sample_fetch_chan(struct device *dev, +__syscall int sensor_sample_fetch_chan(const struct device *dev, enum sensor_channel type); -static inline int z_impl_sensor_sample_fetch_chan(struct device *dev, - enum sensor_channel type) +static inline int z_impl_sensor_sample_fetch_chan(const struct device *dev, + enum sensor_channel type) { const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; @@ -552,13 +552,13 @@ static inline int z_impl_sensor_sample_fetch_chan(struct device *dev, * * @return 0 if successful, negative errno code if failure. */ -__syscall int sensor_channel_get(struct device *dev, +__syscall int sensor_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val); -static inline int z_impl_sensor_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static inline int z_impl_sensor_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api; diff --git a/include/drivers/sensor/ccs811.h b/include/drivers/sensor/ccs811.h index fa28e1d82860b8..165cc9ee9ea547 100644 --- a/include/drivers/sensor/ccs811.h +++ b/include/drivers/sensor/ccs811.h @@ -80,7 +80,7 @@ struct ccs811_result_type { * * @return a pointer to the result information. */ -const struct ccs811_result_type *ccs811_result(struct device *dev); +const struct ccs811_result_type *ccs811_result(const struct device *dev); /** * @brief Get information about static CCS811 state. @@ -104,7 +104,7 @@ struct ccs811_configver_type { * * @return 0 on success, or a negative errno code on failure. */ -int ccs811_configver_fetch(struct device *dev, +int ccs811_configver_fetch(const struct device *dev, struct ccs811_configver_type *ptr); /** @@ -121,7 +121,7 @@ int ccs811_configver_fetch(struct device *dev, * @return a non-negative 16-bit register value, or a negative errno * code on failure. */ -int ccs811_baseline_fetch(struct device *dev); +int ccs811_baseline_fetch(const struct device *dev); /** * @brief Update the BASELINE register. @@ -135,7 +135,7 @@ int ccs811_baseline_fetch(struct device *dev); * * @return 0 if successful, negative errno code if failure. */ -int ccs811_baseline_update(struct device *dev, uint16_t baseline); +int ccs811_baseline_update(const struct device *dev, uint16_t baseline); /** * @brief Update the ENV_DATA register. @@ -151,7 +151,7 @@ int ccs811_baseline_update(struct device *dev, uint16_t baseline); * * @return 0 if successful, negative errno code if failure. */ -int ccs811_envdata_update(struct device *dev, +int ccs811_envdata_update(const struct device *dev, const struct sensor_value *temperature, const struct sensor_value *humidity); diff --git a/include/drivers/spi.h b/include/drivers/spi.h index d35e83d98d40ec..cdfc47813585d3 100644 --- a/include/drivers/spi.h +++ b/include/drivers/spi.h @@ -136,7 +136,7 @@ extern "C" { * spi_config. */ struct spi_cs_control { - struct device *gpio_dev; + const struct device *gpio_dev; uint32_t delay; gpio_pin_t gpio_pin; gpio_dt_flags_t gpio_dt_flags; @@ -205,7 +205,7 @@ struct spi_buf_set { * @brief Callback API for I/O * See spi_transceive() for argument descriptions */ -typedef int (*spi_api_io)(struct device *dev, +typedef int (*spi_api_io)(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs); @@ -215,7 +215,7 @@ typedef int (*spi_api_io)(struct device *dev, * @brief Callback API for asynchronous I/O * See spi_transceive_async() for argument descriptions */ -typedef int (*spi_api_io_async)(struct device *dev, +typedef int (*spi_api_io_async)(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -226,7 +226,7 @@ typedef int (*spi_api_io_async)(struct device *dev, * @brief Callback API for unlocking SPI device. * See spi_release() for argument descriptions */ -typedef int (*spi_api_release)(struct device *dev, +typedef int (*spi_api_release)(const struct device *dev, const struct spi_config *config); @@ -260,15 +260,15 @@ __subsystem struct spi_driver_api { * transaction: if successful it will return the amount of frames * received, negative errno code otherwise. */ -__syscall int spi_transceive(struct device *dev, +__syscall int spi_transceive(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs); -static inline int z_impl_spi_transceive(struct device *dev, - const struct spi_config *config, - const struct spi_buf_set *tx_bufs, - const struct spi_buf_set *rx_bufs) +static inline int z_impl_spi_transceive(const struct device *dev, + const struct spi_config *config, + const struct spi_buf_set *tx_bufs, + const struct spi_buf_set *rx_bufs) { const struct spi_driver_api *api = (const struct spi_driver_api *)dev->api; @@ -291,7 +291,7 @@ static inline int z_impl_spi_transceive(struct device *dev, * * @note This function is an helper function calling spi_transceive. */ -static inline int spi_read(struct device *dev, +static inline int spi_read(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *rx_bufs) { @@ -313,7 +313,7 @@ static inline int spi_read(struct device *dev, * * @note This function is an helper function calling spi_transceive. */ -static inline int spi_write(struct device *dev, +static inline int spi_write(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs) { @@ -342,7 +342,7 @@ static inline int spi_write(struct device *dev, * transaction: if successful it will return the amount of frames * received, negative errno code otherwise. */ -static inline int spi_transceive_async(struct device *dev, +static inline int spi_transceive_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, const struct spi_buf_set *rx_bufs, @@ -383,7 +383,7 @@ static inline int spi_transceive_async(struct device *dev, * * @note This function is an helper function calling spi_transceive_async. */ -static inline int spi_read_async(struct device *dev, +static inline int spi_read_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *rx_bufs, struct k_poll_signal *async) @@ -410,7 +410,7 @@ static inline int spi_read_async(struct device *dev, * * @note This function is an helper function calling spi_transceive_async. */ -static inline int spi_write_async(struct device *dev, +static inline int spi_write_async(const struct device *dev, const struct spi_config *config, const struct spi_buf_set *tx_bufs, struct k_poll_signal *async) @@ -433,11 +433,11 @@ static inline int spi_write_async(struct device *dev, * Pointer-comparison may be used to detect changes from * previous operations. */ -__syscall int spi_release(struct device *dev, +__syscall int spi_release(const struct device *dev, const struct spi_config *config); -static inline int z_impl_spi_release(struct device *dev, - const struct spi_config *config) +static inline int z_impl_spi_release(const struct device *dev, + const struct spi_config *config) { const struct spi_driver_api *api = (const struct spi_driver_api *)dev->api; diff --git a/include/drivers/timer/system_timer.h b/include/drivers/timer/system_timer.h index 6ad46a47612cf1..6f5b196df49efe 100644 --- a/include/drivers/timer/system_timer.h +++ b/include/drivers/timer/system_timer.h @@ -31,7 +31,7 @@ extern "C" { * initialization callback. It is a weak symbol that will be * implemented as a noop if undefined in the clock driver. */ -extern int z_clock_driver_init(struct device *device); +extern int z_clock_driver_init(const struct device *device); /** * @brief Initialize system clock driver @@ -41,7 +41,8 @@ extern int z_clock_driver_init(struct device *device); * management. It is a weak symbol that will be implemented as a noop * if undefined in the clock driver. */ -extern int z_clock_device_ctrl(struct device *device, uint32_t ctrl_command, +extern int z_clock_device_ctrl(const struct device *device, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg); /** diff --git a/include/drivers/uart.h b/include/drivers/uart.h index ef3cec732f9798..1b55944d60fa56 100644 --- a/include/drivers/uart.h +++ b/include/drivers/uart.h @@ -234,7 +234,7 @@ struct uart_event { * @param evt Pointer to uart_event structure. * @param user_data Pointer to data specified by user. */ -typedef void (*uart_callback_t)(struct device *dev, +typedef void (*uart_callback_t)(const struct device *dev, struct uart_event *evt, void *user_data); /** @@ -301,7 +301,7 @@ enum uart_config_flow_control { * @param dev UART device structure. * @param user_data Arbitrary user data. */ -typedef void (*uart_irq_callback_user_data_t)(struct device *dev, +typedef void (*uart_irq_callback_user_data_t)(const struct device *dev, void *user_data); /** @@ -312,7 +312,7 @@ typedef void (*uart_irq_callback_user_data_t)(struct device *dev, * * @internal */ -typedef void (*uart_irq_config_func_t)(struct device *dev); +typedef void (*uart_irq_config_func_t)(const struct device *dev); /** * @brief UART device configuration. @@ -341,86 +341,92 @@ __subsystem struct uart_driver_api { #ifdef CONFIG_UART_ASYNC_API - int (*callback_set)(struct device *dev, uart_callback_t callback, + int (*callback_set)(const struct device *dev, + uart_callback_t callback, void *user_data); - int (*tx)(struct device *dev, const uint8_t *buf, size_t len, + int (*tx)(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout); - int (*tx_abort)(struct device *dev); + int (*tx_abort)(const struct device *dev); - int (*rx_enable)(struct device *dev, uint8_t *buf, size_t len, + int (*rx_enable)(const struct device *dev, uint8_t *buf, size_t len, int32_t timeout); - int (*rx_buf_rsp)(struct device *dev, uint8_t *buf, size_t len); - int (*rx_disable)(struct device *dev); + int (*rx_buf_rsp)(const struct device *dev, uint8_t *buf, size_t len); + int (*rx_disable)(const struct device *dev); #endif /** Console I/O function */ - int (*poll_in)(struct device *dev, unsigned char *p_char); - void (*poll_out)(struct device *dev, unsigned char out_char); + int (*poll_in)(const struct device *dev, unsigned char *p_char); + void (*poll_out)(const struct device *dev, unsigned char out_char); /** Console I/O function */ - int (*err_check)(struct device *dev); + int (*err_check)(const struct device *dev); /** UART configuration functions */ - int (*configure)(struct device *dev, const struct uart_config *cfg); - int (*config_get)(struct device *dev, struct uart_config *cfg); + int (*configure)(const struct device *dev, + const struct uart_config *cfg); + int (*config_get)(const struct device *dev, struct uart_config *cfg); #ifdef CONFIG_UART_INTERRUPT_DRIVEN /** Interrupt driven FIFO fill function */ - int (*fifo_fill)(struct device *dev, const uint8_t *tx_data, int len); + int (*fifo_fill)(const struct device *dev, const uint8_t *tx_data, + int len); /** Interrupt driven FIFO read function */ - int (*fifo_read)(struct device *dev, uint8_t *rx_data, const int size); + int (*fifo_read)(const struct device *dev, uint8_t *rx_data, + const int size); /** Interrupt driven transfer enabling function */ - void (*irq_tx_enable)(struct device *dev); + void (*irq_tx_enable)(const struct device *dev); /** Interrupt driven transfer disabling function */ - void (*irq_tx_disable)(struct device *dev); + void (*irq_tx_disable)(const struct device *dev); /** Interrupt driven transfer ready function */ - int (*irq_tx_ready)(struct device *dev); + int (*irq_tx_ready)(const struct device *dev); /** Interrupt driven receiver enabling function */ - void (*irq_rx_enable)(struct device *dev); + void (*irq_rx_enable)(const struct device *dev); /** Interrupt driven receiver disabling function */ - void (*irq_rx_disable)(struct device *dev); + void (*irq_rx_disable)(const struct device *dev); /** Interrupt driven transfer complete function */ - int (*irq_tx_complete)(struct device *dev); + int (*irq_tx_complete)(const struct device *dev); /** Interrupt driven receiver ready function */ - int (*irq_rx_ready)(struct device *dev); + int (*irq_rx_ready)(const struct device *dev); /** Interrupt driven error enabling function */ - void (*irq_err_enable)(struct device *dev); + void (*irq_err_enable)(const struct device *dev); /** Interrupt driven error disabling function */ - void (*irq_err_disable)(struct device *dev); + void (*irq_err_disable)(const struct device *dev); /** Interrupt driven pending status function */ - int (*irq_is_pending)(struct device *dev); + int (*irq_is_pending)(const struct device *dev); /** Interrupt driven interrupt update function */ - int (*irq_update)(struct device *dev); + int (*irq_update)(const struct device *dev); /** Set the irq callback function */ - void (*irq_callback_set)(struct device *dev, + void (*irq_callback_set)(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data); #endif #ifdef CONFIG_UART_LINE_CTRL - int (*line_ctrl_set)(struct device *dev, uint32_t ctrl, uint32_t val); - int (*line_ctrl_get)(struct device *dev, uint32_t ctrl, uint32_t *val); + int (*line_ctrl_set)(const struct device *dev, uint32_t ctrl, + uint32_t val); + int (*line_ctrl_get)(const struct device *dev, uint32_t ctrl, + uint32_t *val); #endif #ifdef CONFIG_UART_DRV_CMD - int (*drv_cmd)(struct device *dev, uint32_t cmd, uint32_t p); + int (*drv_cmd)(const struct device *dev, uint32_t cmd, uint32_t p); #endif }; @@ -436,7 +442,7 @@ __subsystem struct uart_driver_api { * @retval -ENOTSUP If not supported. * @retval 0 If successful, negative errno code otherwise. */ -static inline int uart_callback_set(struct device *dev, +static inline int uart_callback_set(const struct device *dev, uart_callback_t callback, void *user_data) { @@ -466,10 +472,11 @@ static inline int uart_callback_set(struct device *dev, * @retval -EBUSY There is already an ongoing transfer. * @retval 0 If successful, negative errno code otherwise. */ -__syscall int uart_tx(struct device *dev, const uint8_t *buf, size_t len, +__syscall int uart_tx(const struct device *dev, const uint8_t *buf, + size_t len, int32_t timeout); -static inline int z_impl_uart_tx(struct device *dev, const uint8_t *buf, +static inline int z_impl_uart_tx(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout) { @@ -494,9 +501,9 @@ static inline int z_impl_uart_tx(struct device *dev, const uint8_t *buf, * @retval -EFAULT There is no active transmission. * @retval 0 If successful, negative errno code otherwise. */ -__syscall int uart_tx_abort(struct device *dev); +__syscall int uart_tx_abort(const struct device *dev); -static inline int z_impl_uart_tx_abort(struct device *dev) +static inline int z_impl_uart_tx_abort(const struct device *dev) { #ifdef CONFIG_UART_ASYNC_API const struct uart_driver_api *api = @@ -525,10 +532,12 @@ static inline int z_impl_uart_tx_abort(struct device *dev) * @retval 0 If successful, negative errno code otherwise. * */ -__syscall int uart_rx_enable(struct device *dev, uint8_t *buf, size_t len, +__syscall int uart_rx_enable(const struct device *dev, uint8_t *buf, + size_t len, int32_t timeout); -static inline int z_impl_uart_rx_enable(struct device *dev, uint8_t *buf, +static inline int z_impl_uart_rx_enable(const struct device *dev, + uint8_t *buf, size_t len, int32_t timeout) { #ifdef CONFIG_UART_ASYNC_API @@ -561,7 +570,8 @@ static inline int z_impl_uart_rx_enable(struct device *dev, uint8_t *buf, * @retval 0 If successful, negative errno code otherwise. * */ -static inline int uart_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) +static inline int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf, + size_t len) { #ifdef CONFIG_UART_ASYNC_API const struct uart_driver_api *api = @@ -587,9 +597,9 @@ static inline int uart_rx_buf_rsp(struct device *dev, uint8_t *buf, size_t len) * @retval -EFAULT There is no active reception. * @retval 0 If successful, negative errno code otherwise. */ -__syscall int uart_rx_disable(struct device *dev); +__syscall int uart_rx_disable(const struct device *dev); -static inline int z_impl_uart_rx_disable(struct device *dev) +static inline int z_impl_uart_rx_disable(const struct device *dev) { #ifdef CONFIG_UART_ASYNC_API const struct uart_driver_api *api = @@ -609,9 +619,9 @@ static inline int z_impl_uart_rx_disable(struct device *dev) * @retval uart_rx_stop_reason If error during receiving occurred. * @retval 0 Otherwise. */ -__syscall int uart_err_check(struct device *dev); +__syscall int uart_err_check(const struct device *dev); -static inline int z_impl_uart_err_check(struct device *dev) +static inline int z_impl_uart_err_check(const struct device *dev) { const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api; @@ -635,9 +645,10 @@ static inline int z_impl_uart_err_check(struct device *dev) * @retval -ENOTSUP If the operation is not supported. * @retval -EBUSY If reception was enabled using uart_rx_enabled */ -__syscall int uart_poll_in(struct device *dev, unsigned char *p_char); +__syscall int uart_poll_in(const struct device *dev, unsigned char *p_char); -static inline int z_impl_uart_poll_in(struct device *dev, unsigned char *p_char) +static inline int z_impl_uart_poll_in(const struct device *dev, + unsigned char *p_char) { const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api; @@ -658,10 +669,10 @@ static inline int z_impl_uart_poll_in(struct device *dev, unsigned char *p_char) * @param dev UART device structure. * @param out_char Character to send. */ -__syscall void uart_poll_out(struct device *dev, +__syscall void uart_poll_out(const struct device *dev, unsigned char out_char); -static inline void z_impl_uart_poll_out(struct device *dev, +static inline void z_impl_uart_poll_out(const struct device *dev, unsigned char out_char) { const struct uart_driver_api *api = @@ -683,10 +694,11 @@ static inline void z_impl_uart_poll_out(struct device *dev, * or driver does not support setting configuration in runtime. * @retval 0 If successful, negative errno code otherwise. */ -__syscall int uart_configure(struct device *dev, const struct uart_config *cfg); +__syscall int uart_configure(const struct device *dev, + const struct uart_config *cfg); -static inline int z_impl_uart_configure(struct device *dev, - const struct uart_config *cfg) +static inline int z_impl_uart_configure(const struct device *dev, + const struct uart_config *cfg) { const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api; @@ -710,10 +722,11 @@ static inline int z_impl_uart_configure(struct device *dev, * @retval -ENOTSUP If driver does not support getting current configuration. * @retval 0 If successful, negative errno code otherwise. */ -__syscall int uart_config_get(struct device *dev, struct uart_config *cfg); +__syscall int uart_config_get(const struct device *dev, + struct uart_config *cfg); -static inline int z_impl_uart_config_get(struct device *dev, - struct uart_config *cfg) +static inline int z_impl_uart_config_get(const struct device *dev, + struct uart_config *cfg) { const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api; @@ -743,7 +756,8 @@ static inline int z_impl_uart_config_get(struct device *dev, * * @return Number of bytes sent. */ -static inline int uart_fifo_fill(struct device *dev, const uint8_t *tx_data, +static inline int uart_fifo_fill(const struct device *dev, + const uint8_t *tx_data, int size) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -780,7 +794,7 @@ static inline int uart_fifo_fill(struct device *dev, const uint8_t *tx_data, * * @return Number of bytes read. */ -static inline int uart_fifo_read(struct device *dev, uint8_t *rx_data, +static inline int uart_fifo_read(const struct device *dev, uint8_t *rx_data, const int size) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -802,9 +816,9 @@ static inline int uart_fifo_read(struct device *dev, uint8_t *rx_data, * * @return N/A */ -__syscall void uart_irq_tx_enable(struct device *dev); +__syscall void uart_irq_tx_enable(const struct device *dev); -static inline void z_impl_uart_irq_tx_enable(struct device *dev) +static inline void z_impl_uart_irq_tx_enable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -822,9 +836,9 @@ static inline void z_impl_uart_irq_tx_enable(struct device *dev) * * @return N/A */ -__syscall void uart_irq_tx_disable(struct device *dev); +__syscall void uart_irq_tx_disable(const struct device *dev); -static inline void z_impl_uart_irq_tx_disable(struct device *dev) +static inline void z_impl_uart_irq_tx_disable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -851,7 +865,7 @@ static inline void z_impl_uart_irq_tx_disable(struct device *dev) * @retval 1 If at least one char can be written to UART. * @retval 0 Otherwise. */ -static inline int uart_irq_tx_ready(struct device *dev) +static inline int uart_irq_tx_ready(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -872,9 +886,9 @@ static inline int uart_irq_tx_ready(struct device *dev) * * @return N/A */ -__syscall void uart_irq_rx_enable(struct device *dev); +__syscall void uart_irq_rx_enable(const struct device *dev); -static inline void z_impl_uart_irq_rx_enable(struct device *dev) +static inline void z_impl_uart_irq_rx_enable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -893,9 +907,9 @@ static inline void z_impl_uart_irq_rx_enable(struct device *dev) * * @return N/A */ -__syscall void uart_irq_rx_disable(struct device *dev); +__syscall void uart_irq_rx_disable(const struct device *dev); -static inline void z_impl_uart_irq_rx_disable(struct device *dev) +static inline void z_impl_uart_irq_rx_disable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -925,7 +939,7 @@ static inline void z_impl_uart_irq_rx_disable(struct device *dev) * @retval 0 Otherwise. * @retval -ENOTSUP if this function is not supported */ -static inline int uart_irq_tx_complete(struct device *dev) +static inline int uart_irq_tx_complete(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -958,7 +972,7 @@ static inline int uart_irq_tx_complete(struct device *dev) * @retval 0 Otherwise. * @retval -ENOTSUP if this function is not supported */ -static inline int uart_irq_rx_ready(struct device *dev) +static inline int uart_irq_rx_ready(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -978,9 +992,9 @@ static inline int uart_irq_rx_ready(struct device *dev) * * @return N/A */ -__syscall void uart_irq_err_enable(struct device *dev); +__syscall void uart_irq_err_enable(const struct device *dev); -static inline void z_impl_uart_irq_err_enable(struct device *dev) +static inline void z_impl_uart_irq_err_enable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -1000,9 +1014,9 @@ static inline void z_impl_uart_irq_err_enable(struct device *dev) * @retval 1 If an IRQ is ready. * @retval 0 Otherwise. */ -__syscall void uart_irq_err_disable(struct device *dev); +__syscall void uart_irq_err_disable(const struct device *dev); -static inline void z_impl_uart_irq_err_disable(struct device *dev) +static inline void z_impl_uart_irq_err_disable(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -1022,9 +1036,9 @@ static inline void z_impl_uart_irq_err_disable(struct device *dev) * @retval 1 If an IRQ is pending. * @retval 0 Otherwise. */ -__syscall int uart_irq_is_pending(struct device *dev); +__syscall int uart_irq_is_pending(const struct device *dev); -static inline int z_impl_uart_irq_is_pending(struct device *dev) +static inline int z_impl_uart_irq_is_pending(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -1060,9 +1074,9 @@ static inline int z_impl_uart_irq_is_pending(struct device *dev) * * @retval 1 Always. */ -__syscall int uart_irq_update(struct device *dev); +__syscall int uart_irq_update(const struct device *dev); -static inline int z_impl_uart_irq_update(struct device *dev) +static inline int z_impl_uart_irq_update(const struct device *dev) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -1088,10 +1102,9 @@ static inline int z_impl_uart_irq_update(struct device *dev) * * @return N/A */ -static inline void uart_irq_callback_user_data_set( - struct device *dev, - uart_irq_callback_user_data_t cb, - void *user_data) +static inline void uart_irq_callback_user_data_set(const struct device *dev, + uart_irq_callback_user_data_t cb, + void *user_data) { #ifdef CONFIG_UART_INTERRUPT_DRIVEN const struct uart_driver_api *api = @@ -1114,7 +1127,7 @@ static inline void uart_irq_callback_user_data_set( * * @return N/A */ -static inline void uart_irq_callback_set(struct device *dev, +static inline void uart_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb) { uart_irq_callback_user_data_set(dev, cb, NULL); @@ -1131,11 +1144,11 @@ static inline void uart_irq_callback_set(struct device *dev, * @retval 0 If successful. * @retval failed Otherwise. */ -__syscall int uart_line_ctrl_set(struct device *dev, +__syscall int uart_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val); -static inline int z_impl_uart_line_ctrl_set(struct device *dev, - uint32_t ctrl, uint32_t val) +static inline int z_impl_uart_line_ctrl_set(const struct device *dev, + uint32_t ctrl, uint32_t val) { #ifdef CONFIG_UART_LINE_CTRL const struct uart_driver_api *api = @@ -1159,10 +1172,11 @@ static inline int z_impl_uart_line_ctrl_set(struct device *dev, * @retval 0 If successful. * @retval failed Otherwise. */ -__syscall int uart_line_ctrl_get(struct device *dev, uint32_t ctrl, uint32_t *val); +__syscall int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl, + uint32_t *val); -static inline int z_impl_uart_line_ctrl_get(struct device *dev, - uint32_t ctrl, uint32_t *val) +static inline int z_impl_uart_line_ctrl_get(const struct device *dev, + uint32_t ctrl, uint32_t *val) { #ifdef CONFIG_UART_LINE_CTRL const struct uart_driver_api *api = @@ -1189,9 +1203,10 @@ static inline int z_impl_uart_line_ctrl_get(struct device *dev, * @retval 0 If successful. * @retval failed Otherwise. */ -__syscall int uart_drv_cmd(struct device *dev, uint32_t cmd, uint32_t p); +__syscall int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p); -static inline int z_impl_uart_drv_cmd(struct device *dev, uint32_t cmd, uint32_t p) +static inline int z_impl_uart_drv_cmd(const struct device *dev, uint32_t cmd, + uint32_t p) { #ifdef CONFIG_UART_DRV_CMD const struct uart_driver_api *api = diff --git a/include/drivers/uart/cdc_acm.h b/include/drivers/uart/cdc_acm.h index 38b3de8e62b4ce..c306272a70e9a1 100644 --- a/include/drivers/uart/cdc_acm.h +++ b/include/drivers/uart/cdc_acm.h @@ -27,7 +27,8 @@ extern "C" { * * @param port Device struct for the CDC ACM device. */ -typedef void (*cdc_dte_rate_callback_t)(struct device *dev, uint32_t rate); +typedef void (*cdc_dte_rate_callback_t)(const struct device *dev, + uint32_t rate); /** * @brief Set the callback for dwDTERate SetLineCoding requests. @@ -42,7 +43,7 @@ typedef void (*cdc_dte_rate_callback_t)(struct device *dev, uint32_t rate); * * @return 0 on success. */ -int cdc_acm_dte_rate_callback_set(struct device *dev, +int cdc_acm_dte_rate_callback_set(const struct device *dev, cdc_dte_rate_callback_t callback); #ifdef __cplusplus diff --git a/include/drivers/video.h b/include/drivers/video.h index a26127b213993c..f65bd3b40a6230 100644 --- a/include/drivers/video.h +++ b/include/drivers/video.h @@ -136,7 +136,7 @@ enum video_signal_result { * @brief Set video format * See video_set_format() for argument descriptions. */ -typedef int (*video_api_set_format_t)(struct device *dev, +typedef int (*video_api_set_format_t)(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt); @@ -145,7 +145,7 @@ typedef int (*video_api_set_format_t)(struct device *dev, * @brief get current video format * See video_get_format() for argument descriptions. */ -typedef int (*video_api_get_format_t)(struct device *dev, +typedef int (*video_api_get_format_t)(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt); @@ -154,7 +154,7 @@ typedef int (*video_api_get_format_t)(struct device *dev, * @brief Enqueue a buffer in the driver’s incoming queue. * See video_enqueue() for argument descriptions. */ -typedef int (*video_api_enqueue_t)(struct device *dev, +typedef int (*video_api_enqueue_t)(const struct device *dev, enum video_endpoint_id ep, struct video_buffer *buf); @@ -163,7 +163,7 @@ typedef int (*video_api_enqueue_t)(struct device *dev, * @brief Dequeue a buffer from the driver’s outgoing queue. * See video_dequeue() for argument descriptions. */ -typedef int (*video_api_dequeue_t)(struct device *dev, +typedef int (*video_api_dequeue_t)(const struct device *dev, enum video_endpoint_id ep, struct video_buffer **buf, k_timeout_t timeout); @@ -174,7 +174,7 @@ typedef int (*video_api_dequeue_t)(struct device *dev, * outgoing queue. * See video_flush() for argument descriptions. */ -typedef int (*video_api_flush_t)(struct device *dev, +typedef int (*video_api_flush_t)(const struct device *dev, enum video_endpoint_id ep, bool cancel); @@ -183,21 +183,22 @@ typedef int (*video_api_flush_t)(struct device *dev, * @brief Start the capture or output process. * See video_stream_start() for argument descriptions. */ -typedef int (*video_api_stream_start_t)(struct device *dev); +typedef int (*video_api_stream_start_t)(const struct device *dev); /** * @typedef video_api_stream_stop_t * @brief Stop the capture or output process. * See video_stream_stop() for argument descriptions. */ -typedef int (*video_api_stream_stop_t)(struct device *dev); +typedef int (*video_api_stream_stop_t)(const struct device *dev); /** * @typedef video_api_set_ctrl_t * @brief set a video control value. * See video_set_ctrl() for argument descriptions. */ -typedef int (*video_api_set_ctrl_t)(struct device *dev, unsigned int cid, +typedef int (*video_api_set_ctrl_t)(const struct device *dev, + unsigned int cid, void *value); /** @@ -205,7 +206,8 @@ typedef int (*video_api_set_ctrl_t)(struct device *dev, unsigned int cid, * @brief get a video control value. * See video_get_ctrl() for argument descriptions. */ -typedef int (*video_api_get_ctrl_t)(struct device *dev, unsigned int cid, +typedef int (*video_api_get_ctrl_t)(const struct device *dev, + unsigned int cid, void *value); /** @@ -213,7 +215,7 @@ typedef int (*video_api_get_ctrl_t)(struct device *dev, unsigned int cid, * @brief Get capabilities of a video endpoint. * See video_get_caps() for argument descriptions. */ -typedef int (*video_api_get_caps_t)(struct device *dev, +typedef int (*video_api_get_caps_t)(const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps); @@ -222,7 +224,7 @@ typedef int (*video_api_get_caps_t)(struct device *dev, * @brief Register/Unregister poll signal for buffer events. * See video_set_signal() for argument descriptions. */ -typedef int (*video_api_set_signal_t)(struct device *dev, +typedef int (*video_api_set_signal_t)(const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal); @@ -256,7 +258,7 @@ struct video_driver_api { * @retval -ENOTSUP If format is not supported. * @retval -EIO General input / output error. */ -static inline int video_set_format(struct device *dev, +static inline int video_set_format(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt) { @@ -279,7 +281,7 @@ static inline int video_set_format(struct device *dev, * * @retval pointer to video format */ -static inline int video_get_format(struct device *dev, +static inline int video_get_format(const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt) { @@ -305,7 +307,8 @@ static inline int video_get_format(struct device *dev, * @retval -EINVAL If parameters are invalid. * @retval -EIO General input / output error. */ -static inline int video_enqueue(struct device *dev, enum video_endpoint_id ep, +static inline int video_enqueue(const struct device *dev, + enum video_endpoint_id ep, struct video_buffer *buf) { const struct video_driver_api *api = @@ -333,7 +336,8 @@ static inline int video_enqueue(struct device *dev, enum video_endpoint_id ep, * @retval -EINVAL If parameters are invalid. * @retval -EIO General input / output error. */ -static inline int video_dequeue(struct device *dev, enum video_endpoint_id ep, +static inline int video_dequeue(const struct device *dev, + enum video_endpoint_id ep, struct video_buffer **buf, k_timeout_t timeout) { @@ -362,7 +366,8 @@ static inline int video_dequeue(struct device *dev, enum video_endpoint_id ep, * * @retval 0 Is successful, -ERRNO code otherwise. */ -static inline int video_flush(struct device *dev, enum video_endpoint_id ep, +static inline int video_flush(const struct device *dev, + enum video_endpoint_id ep, bool cancel) { const struct video_driver_api *api = @@ -387,7 +392,7 @@ static inline int video_flush(struct device *dev, enum video_endpoint_id ep, * @retval 0 Is successful. * @retval -EIO General input / output error. */ -static inline int video_stream_start(struct device *dev) +static inline int video_stream_start(const struct device *dev) { const struct video_driver_api *api = (const struct video_driver_api *)dev->api; @@ -407,7 +412,7 @@ static inline int video_stream_start(struct device *dev) * @retval 0 Is successful. * @retval -EIO General input / output error. */ -static inline int video_stream_stop(struct device *dev) +static inline int video_stream_stop(const struct device *dev) { const struct video_driver_api *api = (const struct video_driver_api *)dev->api; @@ -431,7 +436,7 @@ static inline int video_stream_stop(struct device *dev) * * @retval 0 Is successful, -ERRNO code otherwise. */ -static inline int video_get_caps(struct device *dev, +static inline int video_get_caps(const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps) { @@ -458,7 +463,7 @@ static inline int video_get_caps(struct device *dev, * @retval -ENOTSUP If format is not supported. * @retval -EIO General input / output error. */ -static inline int video_set_ctrl(struct device *dev, unsigned int cid, +static inline int video_set_ctrl(const struct device *dev, unsigned int cid, void *value) { const struct video_driver_api *api = @@ -486,7 +491,7 @@ static inline int video_set_ctrl(struct device *dev, unsigned int cid, * @retval -ENOTSUP If format is not supported. * @retval -EIO General input / output error. */ -static inline int video_get_ctrl(struct device *dev, unsigned int cid, +static inline int video_get_ctrl(const struct device *dev, unsigned int cid, void *value) { const struct video_driver_api *api = @@ -512,7 +517,7 @@ static inline int video_get_ctrl(struct device *dev, unsigned int cid, * * @retval 0 Is successful, -ERRNO code otherwise. */ -static inline int video_set_signal(struct device *dev, +static inline int video_set_signal(const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal) { diff --git a/include/drivers/watchdog.h b/include/drivers/watchdog.h index 90a8c469b26eb3..669951bf23db1d 100644 --- a/include/drivers/watchdog.h +++ b/include/drivers/watchdog.h @@ -81,7 +81,7 @@ struct wdt_window { }; /** Watchdog callback. */ -typedef void (*wdt_callback_t)(struct device *dev, int channel_id); +typedef void (*wdt_callback_t)(const struct device *dev, int channel_id); /** * @brief Watchdog timeout configuration struct. @@ -110,21 +110,21 @@ struct wdt_timeout_cfg { * @brief Callback API for setting up watchdog instance. * See wdt_setup() for argument descriptions */ -typedef int (*wdt_api_setup)(struct device *dev, uint8_t options); +typedef int (*wdt_api_setup)(const struct device *dev, uint8_t options); /** * @typedef wdt_api_disable * @brief Callback API for disabling watchdog instance. * See wdt_disable() for argument descriptions */ -typedef int (*wdt_api_disable)(struct device *dev); +typedef int (*wdt_api_disable)(const struct device *dev); /** * @typedef wdt_api_install_timeout * @brief Callback API for installing new timeout. * See wdt_install_timeout() for argument descriptions */ -typedef int (*wdt_api_install_timeout)(struct device *dev, +typedef int (*wdt_api_install_timeout)(const struct device *dev, const struct wdt_timeout_cfg *cfg); /** @@ -132,7 +132,7 @@ typedef int (*wdt_api_install_timeout)(struct device *dev, * @brief Callback API for feeding specified watchdog timeout. * See (wdt_feed) for argument descriptions */ -typedef int (*wdt_api_feed)(struct device *dev, int channel_id); +typedef int (*wdt_api_feed)(const struct device *dev, int channel_id); /** @cond INTERNAL_HIDDEN */ __subsystem struct wdt_driver_api { @@ -160,9 +160,9 @@ __subsystem struct wdt_driver_api { * @retval -ENOTSUP If any of the set options is not supported. * @retval -EBUSY If watchdog instance has been already setup. */ -__syscall int wdt_setup(struct device *dev, uint8_t options); +__syscall int wdt_setup(const struct device *dev, uint8_t options); -static inline int z_impl_wdt_setup(struct device *dev, uint8_t options) +static inline int z_impl_wdt_setup(const struct device *dev, uint8_t options) { const struct wdt_driver_api *api = (const struct wdt_driver_api *)dev->api; @@ -183,9 +183,9 @@ static inline int z_impl_wdt_setup(struct device *dev, uint8_t options) * @retval -EFAULT If watchdog instance is not enabled. * @retval -EPERM If watchdog can not be disabled directly by application code. */ -__syscall int wdt_disable(struct device *dev); +__syscall int wdt_disable(const struct device *dev); -static inline int z_impl_wdt_disable(struct device *dev) +static inline int z_impl_wdt_disable(const struct device *dev) { const struct wdt_driver_api *api = (const struct wdt_driver_api *)dev->api; @@ -215,7 +215,7 @@ static inline int z_impl_wdt_disable(struct device *dev) * timeout value for all timeouts and the supplied timeout * window differs from windows for alarms installed so far. */ -static inline int wdt_install_timeout(struct device *dev, +static inline int wdt_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg) { const struct wdt_driver_api *api = @@ -236,9 +236,9 @@ static inline int wdt_install_timeout(struct device *dev, * operation such as a previous @c wdt_feed(). * @retval -EINVAL If there is no installed timeout for supplied channel. */ -__syscall int wdt_feed(struct device *dev, int channel_id); +__syscall int wdt_feed(const struct device *dev, int channel_id); -static inline int z_impl_wdt_feed(struct device *dev, int channel_id) +static inline int z_impl_wdt_feed(const struct device *dev, int channel_id) { const struct wdt_driver_api *api = (const struct wdt_driver_api *)dev->api; diff --git a/include/emul.h b/include/emul.h index 27fc9b77762a3b..1f4c8852b9264f 100644 --- a/include/emul.h +++ b/include/emul.h @@ -45,7 +45,8 @@ struct emul_list_for_bus { * @param emul Emulator to init * @param parent Parent device that is using the emulator */ -typedef int (*emul_init_t)(const struct emul *emul, struct device *parent); +typedef int (*emul_init_t)(const struct emul *emul, + const struct device *parent); /** An emulator instance */ struct emul { @@ -94,7 +95,7 @@ extern const struct emul __emul_list_end[]; * @return 0 if OK * @return negative value on error */ -int emul_init_for_bus_from_list(struct device *dev, +int emul_init_for_bus_from_list(const struct device *dev, const struct emul_list_for_bus *list); #ifdef __cplusplus diff --git a/include/fs/nvs.h b/include/fs/nvs.h index 15087b0cf9c8a6..d6ad75fc28c8b4 100644 --- a/include/fs/nvs.h +++ b/include/fs/nvs.h @@ -55,7 +55,7 @@ struct nvs_fs { bool ready; /* is the filesystem initialized ? */ struct k_mutex nvs_lock; - struct device *flash_device; + const struct device *flash_device; const struct flash_parameters *flash_parameters; }; diff --git a/include/init.h b/include/init.h index 7e3fb0c925abf9..dd5df6428f99dd 100644 --- a/include/init.h +++ b/include/init.h @@ -44,11 +44,11 @@ struct init_entry { /** Initialization function for the init entry which will take * the dev attribute as parameter. See below. */ - int (*init)(struct device *dev); + int (*init)(const struct device *dev); /** Pointer to a device driver instance structure. Can be NULL * if the init entry is not used for a device driver but a services. */ - struct device *dev; + const struct device *dev; }; void z_sys_init_run_level(int32_t _level); diff --git a/include/irq_nextlevel.h b/include/irq_nextlevel.h index 6901085ff8fdb6..b7660e8a73ca7b 100644 --- a/include/irq_nextlevel.h +++ b/include/irq_nextlevel.h @@ -21,11 +21,13 @@ extern "C" { * These are for internal use only, so skip these in * public documentation. */ -typedef void (*irq_next_level_func_t)(struct device *dev, unsigned int irq); -typedef unsigned int (*irq_next_level_get_state_t)(struct device *dev); -typedef void (*irq_next_level_priority_t)(struct device *dev, - unsigned int irq, unsigned int prio, uint32_t flags); -typedef int (*irq_next_level_get_line_state_t)(struct device *dev, +typedef void (*irq_next_level_func_t)(const struct device *dev, + unsigned int irq); +typedef unsigned int (*irq_next_level_get_state_t)(const struct device *dev); +typedef void (*irq_next_level_priority_t)(const struct device *dev, + unsigned int irq, unsigned int prio, + uint32_t flags); +typedef int (*irq_next_level_get_line_state_t)(const struct device *dev, unsigned int irq); struct irq_next_level_api { @@ -49,7 +51,8 @@ struct irq_next_level_api { * * @return N/A */ -static inline void irq_enable_next_level(struct device *dev, uint32_t irq) +static inline void irq_enable_next_level(const struct device *dev, + uint32_t irq) { const struct irq_next_level_api *api = (const struct irq_next_level_api *)dev->api; @@ -67,7 +70,8 @@ static inline void irq_enable_next_level(struct device *dev, uint32_t irq) * * @return N/A */ -static inline void irq_disable_next_level(struct device *dev, uint32_t irq) +static inline void irq_disable_next_level(const struct device *dev, + uint32_t irq) { const struct irq_next_level_api *api = (const struct irq_next_level_api *)dev->api; @@ -85,7 +89,7 @@ static inline void irq_disable_next_level(struct device *dev, uint32_t irq) * * @return interrupt enable state, true or false */ -static inline unsigned int irq_is_enabled_next_level(struct device *dev) +static inline unsigned int irq_is_enabled_next_level(const struct device *dev) { const struct irq_next_level_api *api = (const struct irq_next_level_api *)dev->api; @@ -106,8 +110,9 @@ static inline unsigned int irq_is_enabled_next_level(struct device *dev) * * @return N/A */ -static inline void irq_set_priority_next_level(struct device *dev, uint32_t irq, - uint32_t prio, uint32_t flags) +static inline void irq_set_priority_next_level(const struct device *dev, + uint32_t irq, + uint32_t prio, uint32_t flags) { const struct irq_next_level_api *api = (const struct irq_next_level_api *)dev->api; @@ -126,7 +131,7 @@ static inline void irq_set_priority_next_level(struct device *dev, uint32_t irq, * * @return interrupt enable state, true or false */ -static inline unsigned int irq_line_is_enabled_next_level(struct device *dev, +static inline unsigned int irq_line_is_enabled_next_level(const struct device *dev, unsigned int irq) { const struct irq_next_level_api *api = diff --git a/include/net/can.h b/include/net/can.h index 449ecac3ccb607..d5b5db187d8738 100644 --- a/include/net/can.h +++ b/include/net/can.h @@ -99,15 +99,15 @@ struct net_can_api { struct net_if_api iface_api; /** Send a single CAN frame */ - int (*send)(struct device *dev, const struct zcan_frame *frame, + int (*send)(const struct device *dev, const struct zcan_frame *frame, can_tx_callback_t cb, void *cb_arg, k_timeout_t timeout); /** Attach a filter with it's callback */ - int (*attach_filter)(struct device *dev, can_rx_callback_t cb, + int (*attach_filter)(const struct device *dev, can_rx_callback_t cb, void *cb_arg, const struct zcan_filter *filter); /** Detach a filter */ - void (*detach_filter)(struct device *dev, int filter_id); + void (*detach_filter)(const struct device *dev, int filter_id); /** Enable or disable the reception of frames for net CAN */ - int (*enable)(struct device *dev, bool enable); + int (*enable)(const struct device *dev, bool enable); }; /* Make sure that the network interface API is properly setup inside diff --git a/include/net/dummy.h b/include/net/dummy.h index 4f3344fcfedbee..3aeca7b0ebce4a 100644 --- a/include/net/dummy.h +++ b/include/net/dummy.h @@ -30,7 +30,7 @@ struct dummy_api { struct net_if_api iface_api; /** Send a network packet */ - int (*send)(struct device *dev, struct net_pkt *pkt); + int (*send)(const struct device *dev, struct net_pkt *pkt); }; /* Make sure that the network interface API is properly setup inside diff --git a/include/net/ethernet.h b/include/net/ethernet.h index b6b979f6b58741..b7ddd5e2d7306f 100644 --- a/include/net/ethernet.h +++ b/include/net/ethernet.h @@ -228,25 +228,25 @@ struct ethernet_api { * should be set by driver if statistics needs to be collected * for that driver. */ - struct net_stats_eth *(*get_stats)(struct device *dev); + struct net_stats_eth *(*get_stats)(const struct device *dev); #endif /** Start the device */ - int (*start)(struct device *dev); + int (*start)(const struct device *dev); /** Stop the device */ - int (*stop)(struct device *dev); + int (*stop)(const struct device *dev); /** Get the device capabilities */ - enum ethernet_hw_caps (*get_capabilities)(struct device *dev); + enum ethernet_hw_caps (*get_capabilities)(const struct device *dev); /** Set specific hardware configuration */ - int (*set_config)(struct device *dev, + int (*set_config)(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config); /** Get hardware specific configuration */ - int (*get_config)(struct device *dev, + int (*get_config)(const struct device *dev, enum ethernet_config_type type, struct ethernet_config *config); @@ -256,17 +256,17 @@ struct ethernet_api { * if it is false then the tag was removed. The driver can utilize * this information if needed. */ - int (*vlan_setup)(struct device *dev, struct net_if *iface, + int (*vlan_setup)(const struct device *dev, struct net_if *iface, uint16_t tag, bool enable); #endif /* CONFIG_NET_VLAN */ #if defined(CONFIG_PTP_CLOCK) /** Return ptp_clock device that is tied to this ethernet device */ - struct device *(*get_ptp_clock)(struct device *dev); + const struct device *(*get_ptp_clock)(const struct device *dev); #endif /* CONFIG_PTP_CLOCK */ /** Send a network packet */ - int (*send)(struct device *dev, struct net_pkt *pkt); + int (*send)(const struct device *dev, struct net_pkt *pkt); }; /* Make sure that the network interface API is properly setup inside @@ -684,9 +684,9 @@ int net_eth_promisc_mode(struct net_if *iface, bool enable); * ethernet interface does not support PTP. */ #if defined(CONFIG_PTP_CLOCK) -struct device *net_eth_get_ptp_clock(struct net_if *iface); +const struct device *net_eth_get_ptp_clock(struct net_if *iface); #else -static inline struct device *net_eth_get_ptp_clock(struct net_if *iface) +static inline const struct device *net_eth_get_ptp_clock(struct net_if *iface) { ARG_UNUSED(iface); @@ -703,7 +703,7 @@ static inline struct device *net_eth_get_ptp_clock(struct net_if *iface) * @return Pointer to PTP clock if found, NULL if not found or if this * ethernet interface index does not support PTP. */ -__syscall struct device *net_eth_get_ptp_clock_by_index(int index); +__syscall const struct device *net_eth_get_ptp_clock_by_index(int index); /** * @brief Return gPTP port number attached to this interface. diff --git a/include/net/ieee802154_radio.h b/include/net/ieee802154_radio.h index 96e70770fc4a9c..583955dc4a46ac 100644 --- a/include/net/ieee802154_radio.h +++ b/include/net/ieee802154_radio.h @@ -51,9 +51,10 @@ enum ieee802154_event { IEEE802154_EVENT_TX_STARTED /* Data transmission started */ }; -typedef void (*energy_scan_done_cb_t)(struct device *dev, int16_t max_ed); +typedef void (*energy_scan_done_cb_t)(const struct device *dev, + int16_t max_ed); -typedef void (*ieee802154_event_cb_t)(struct device *dev, +typedef void (*ieee802154_event_cb_t)(const struct device *dev, enum ieee802154_event evt, void *event_params); @@ -168,48 +169,48 @@ struct ieee802154_radio_api { struct net_if_api iface_api; /** Get the device capabilities */ - enum ieee802154_hw_caps (*get_capabilities)(struct device *dev); + enum ieee802154_hw_caps (*get_capabilities)(const struct device *dev); /** Clear Channel Assesment - Check channel's activity */ - int (*cca)(struct device *dev); + int (*cca)(const struct device *dev); /** Set current channel */ - int (*set_channel)(struct device *dev, uint16_t channel); + int (*set_channel)(const struct device *dev, uint16_t channel); /** Set/Unset filters (for IEEE802154_HW_FILTER ) */ - int (*filter)(struct device *dev, + int (*filter)(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter); /** Set TX power level in dbm */ - int (*set_txpower)(struct device *dev, int16_t dbm); + int (*set_txpower)(const struct device *dev, int16_t dbm); /** Transmit a packet fragment */ - int (*tx)(struct device *dev, enum ieee802154_tx_mode mode, + int (*tx)(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag); /** Start the device */ - int (*start)(struct device *dev); + int (*start)(const struct device *dev); /** Stop the device */ - int (*stop)(struct device *dev); + int (*stop)(const struct device *dev); /** Set specific radio driver configuration. */ - int (*configure)(struct device *dev, + int (*configure)(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config); #ifdef CONFIG_NET_L2_IEEE802154_SUB_GHZ /** Get the available amount of Sub-GHz channels */ - uint16_t (*get_subg_channel_count)(struct device *dev); + uint16_t (*get_subg_channel_count)(const struct device *dev); #endif /* CONFIG_NET_L2_IEEE802154_SUB_GHZ */ /** Run an energy detection scan. * Note: channel must be set prior to request this function. * duration parameter is in ms. */ - int (*ed_scan)(struct device *dev, + int (*ed_scan)(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb); }; diff --git a/include/net/net_config.h b/include/net/net_config.h index 25e048bf4e50de..56aebf9a0f2116 100644 --- a/include/net/net_config.h +++ b/include/net/net_config.h @@ -94,7 +94,7 @@ int net_config_init_by_iface(struct net_if *iface, const char *app_info, * * @return 0 if ok, <0 if error. */ -int net_config_init_app(struct device *device, const char *app_info); +int net_config_init_app(const struct device *device, const char *app_info); /** * @} diff --git a/include/net/net_if.h b/include/net/net_if.h index 6f6b05ea29a940..95276903fd7dc5 100644 --- a/include/net/net_if.h +++ b/include/net/net_if.h @@ -412,7 +412,7 @@ struct net_traffic_class { */ struct net_if_dev { /** The actually device driver instance the net_if is related to */ - struct device *dev; + const struct device *dev; /** Interface's L2 layer */ const struct net_l2 * const l2; @@ -587,7 +587,7 @@ static inline void *net_if_l2_data(struct net_if *iface) * * @return a pointer to the device driver instance */ -static inline struct device *net_if_get_device(struct net_if *iface) +static inline const struct device *net_if_get_device(struct net_if *iface) { return iface->if_dev->dev; } @@ -792,7 +792,7 @@ struct net_if *net_if_get_by_link_addr(struct net_linkaddr *ll_addr); * * @return a valid struct net_if pointer on success, NULL otherwise */ -struct net_if *net_if_lookup_by_dev(struct device *dev); +struct net_if *net_if_lookup_by_dev(const struct device *dev); /** * @brief Get network interface IP config diff --git a/include/net/ppp.h b/include/net/ppp.h index e38ef9d8e63ef1..fccceaa64226de 100644 --- a/include/net/ppp.h +++ b/include/net/ppp.h @@ -45,20 +45,20 @@ struct ppp_api { struct net_if_api iface_api; /** Start the device */ - int (*start)(struct device *dev); + int (*start)(const struct device *dev); /** Stop the device */ - int (*stop)(struct device *dev); + int (*stop)(const struct device *dev); /** Send a network packet */ - int (*send)(struct device *dev, struct net_pkt *pkt); + int (*send)(const struct device *dev, struct net_pkt *pkt); #if defined(CONFIG_NET_STATISTICS_PPP) /** Collect optional PPP specific statistics. This pointer * should be set by driver if statistics needs to be collected * for that driver. */ - struct net_stats_ppp *(*get_stats)(struct device *dev); + struct net_stats_ppp *(*get_stats)(const struct device *dev); #endif }; diff --git a/include/net/socket_can.h b/include/net/socket_can.h index 8aaf3d196c44fb..cb86721e55200b 100644 --- a/include/net/socket_can.h +++ b/include/net/socket_can.h @@ -63,17 +63,19 @@ struct canbus_api { struct net_if_api iface_api; /** Send a CAN packet by socket */ - int (*send)(struct device *dev, struct net_pkt *pkt); + int (*send)(const struct device *dev, struct net_pkt *pkt); /** Close the related CAN socket */ - void (*close)(struct device *dev, int filter_id); + void (*close)(const struct device *dev, int filter_id); /** Set socket CAN option */ - int (*setsockopt)(struct device *dev, void *obj, int level, int optname, + int (*setsockopt)(const struct device *dev, void *obj, int level, + int optname, const void *optval, socklen_t optlen); /** Get socket CAN option */ - int (*getsockopt)(struct device *dev, void *obj, int level, int optname, + int (*getsockopt)(const struct device *dev, void *obj, int level, + int optname, const void *optval, socklen_t *optlen); }; diff --git a/include/net/wifi_mgmt.h b/include/net/wifi_mgmt.h index 4959b754517dab..5736890865f35e 100644 --- a/include/net/wifi_mgmt.h +++ b/include/net/wifi_mgmt.h @@ -126,13 +126,13 @@ struct net_wifi_mgmt_offload { * result by the driver. The wifi mgmt part will take care of * raising the necessary event etc... */ - int (*scan)(struct device *dev, scan_result_cb_t cb); - int (*connect)(struct device *dev, + int (*scan)(const struct device *dev, scan_result_cb_t cb); + int (*connect)(const struct device *dev, struct wifi_connect_req_params *params); - int (*disconnect)(struct device *dev); - int (*ap_enable)(struct device *dev, + int (*disconnect)(const struct device *dev); + int (*ap_enable)(const struct device *dev, struct wifi_connect_req_params *params); - int (*ap_disable)(struct device *dev); + int (*ap_disable)(const struct device *dev); }; /* Make sure that the network interface API is properly setup inside diff --git a/include/ptp_clock.h b/include/ptp_clock.h index 0f7ba7e4767c0a..51e63ee3df37f2 100644 --- a/include/ptp_clock.h +++ b/include/ptp_clock.h @@ -23,10 +23,10 @@ extern "C" { #endif __subsystem struct ptp_clock_driver_api { - int (*set)(struct device *dev, struct net_ptp_time *tm); - int (*get)(struct device *dev, struct net_ptp_time *tm); - int (*adjust)(struct device *dev, int increment); - int (*rate_adjust)(struct device *dev, float ratio); + int (*set)(const struct device *dev, struct net_ptp_time *tm); + int (*get)(const struct device *dev, struct net_ptp_time *tm); + int (*adjust)(const struct device *dev, int increment); + int (*rate_adjust)(const struct device *dev, float ratio); }; /** @@ -37,7 +37,8 @@ __subsystem struct ptp_clock_driver_api { * * @return 0 if ok, <0 if error */ -static inline int ptp_clock_set(struct device *dev, struct net_ptp_time *tm) +static inline int ptp_clock_set(const struct device *dev, + struct net_ptp_time *tm) { const struct ptp_clock_driver_api *api = (const struct ptp_clock_driver_api *)dev->api; @@ -53,9 +54,9 @@ static inline int ptp_clock_set(struct device *dev, struct net_ptp_time *tm) * * @return 0 if ok, <0 if error */ -__syscall int ptp_clock_get(struct device *dev, struct net_ptp_time *tm); +__syscall int ptp_clock_get(const struct device *dev, struct net_ptp_time *tm); -static inline int z_impl_ptp_clock_get(struct device *dev, +static inline int z_impl_ptp_clock_get(const struct device *dev, struct net_ptp_time *tm) { const struct ptp_clock_driver_api *api = @@ -72,7 +73,7 @@ static inline int z_impl_ptp_clock_get(struct device *dev, * * @return 0 if ok, <0 if error */ -static inline int ptp_clock_adjust(struct device *dev, int increment) +static inline int ptp_clock_adjust(const struct device *dev, int increment) { const struct ptp_clock_driver_api *api = (const struct ptp_clock_driver_api *)dev->api; @@ -88,7 +89,7 @@ static inline int ptp_clock_adjust(struct device *dev, int increment) * * @return 0 if ok, <0 if error */ -static inline int ptp_clock_rate_adjust(struct device *dev, float rate) +static inline int ptp_clock_rate_adjust(const struct device *dev, float rate) { const struct ptp_clock_driver_api *api = (const struct ptp_clock_driver_api *)dev->api; diff --git a/include/shared_irq.h b/include/shared_irq.h index 3f7686ba4d4999..51d49908fd5d09 100644 --- a/include/shared_irq.h +++ b/include/shared_irq.h @@ -15,14 +15,16 @@ extern "C" { #endif -typedef int (*isr_t)(struct device *dev); +typedef int (*isr_t)(const struct device *dev); /* driver API definition */ -typedef int (*shared_irq_register_t)(struct device *dev, - isr_t isr_func, - struct device *isr_dev); -typedef int (*shared_irq_enable_t)(struct device *dev, struct device *isr_dev); -typedef int (*shared_irq_disable_t)(struct device *dev, struct device *isr_dev); +typedef int (*shared_irq_register_t)(const struct device *dev, + isr_t isr_func, + const struct device *isr_dev); +typedef int (*shared_irq_enable_t)(const struct device *dev, + const struct device *isr_dev); +typedef int (*shared_irq_disable_t)(const struct device *dev, + const struct device *isr_dev); struct shared_irq_driver_api { shared_irq_register_t isr_register; @@ -30,7 +32,7 @@ struct shared_irq_driver_api { shared_irq_disable_t disable; }; -extern int shared_irq_initialize(struct device *port); +extern int shared_irq_initialize(const struct device *port); typedef void (*shared_irq_config_irq_t)(void); @@ -41,7 +43,7 @@ struct shared_irq_config { }; struct shared_irq_client { - struct device *isr_dev; + const struct device *isr_dev; isr_t isr_func; uint32_t enabled; }; @@ -56,8 +58,9 @@ struct shared_irq_runtime { * @param isr_func Pointer to the ISR function for the device. * @param isr_dev Pointer to the device that will service the interrupt. */ -static inline int shared_irq_isr_register(struct device *dev, isr_t isr_func, - struct device *isr_dev) +static inline int shared_irq_isr_register(const struct device *dev, + isr_t isr_func, + const struct device *isr_dev) { const struct shared_irq_driver_api *api = (const struct shared_irq_driver_api *)dev->api; @@ -70,7 +73,8 @@ static inline int shared_irq_isr_register(struct device *dev, isr_t isr_func, * @param dev Pointer to device structure for SHARED_IRQ driver instance. * @param isr_dev Pointer to the device that will service the interrupt. */ -static inline int shared_irq_enable(struct device *dev, struct device *isr_dev) +static inline int shared_irq_enable(const struct device *dev, + const struct device *isr_dev) { const struct shared_irq_driver_api *api = (const struct shared_irq_driver_api *)dev->api; @@ -83,7 +87,8 @@ static inline int shared_irq_enable(struct device *dev, struct device *isr_dev) * @param dev Pointer to device structure for SHARED_IRQ driver instance. * @param isr_dev Pointer to the device that will service the interrupt. */ -static inline int shared_irq_disable(struct device *dev, struct device *isr_dev) +static inline int shared_irq_disable(const struct device *dev, + const struct device *isr_dev) { const struct shared_irq_driver_api *api = (const struct shared_irq_driver_api *)dev->api; diff --git a/include/shell/shell.h b/include/shell/shell.h index 91e9afac8b5206..2e264edb8e0515 100644 --- a/include/shell/shell.h +++ b/include/shell/shell.h @@ -121,7 +121,7 @@ struct shell_static_args { * devices. Indexing is done relative to devices with names that * start with this text. Pass null if no prefix match is required. */ -struct device *shell_device_lookup(size_t idx, +const struct device *shell_device_lookup(size_t idx, const char *prefix); /** diff --git a/include/shell/shell_uart.h b/include/shell/shell_uart.h index b1566a309efc4b..6e3e29b8289388 100644 --- a/include/shell/shell_uart.h +++ b/include/shell/shell_uart.h @@ -20,7 +20,7 @@ extern const struct shell_transport_api shell_uart_transport_api; /** @brief Shell UART transport instance control block (RW data). */ struct shell_uart_ctrl_blk { - struct device *dev; + const struct device *dev; shell_transport_handler_t handler; void *context; atomic_t tx_busy; diff --git a/include/storage/flash_map.h b/include/storage/flash_map.h index 4e960ae698d417..da57a04d73791e 100644 --- a/include/storage/flash_map.h +++ b/include/storage/flash_map.h @@ -207,7 +207,7 @@ int flash_area_has_driver(const struct flash_area *fa); * * @return device driver. */ -struct device *flash_area_get_device(const struct flash_area *fa); +const struct device *flash_area_get_device(const struct flash_area *fa); #define FLASH_AREA_LABEL_EXISTS(label) \ DT_HAS_FIXED_PARTITION_LABEL(label) diff --git a/include/storage/stream_flash.h b/include/storage/stream_flash.h index b101c433a84a0c..bc80bf1a793051 100644 --- a/include/storage/stream_flash.h +++ b/include/storage/stream_flash.h @@ -54,7 +54,7 @@ struct stream_flash_ctx { uint8_t *buf; /* Write buffer */ size_t buf_len; /* Length of write buffer */ size_t buf_bytes; /* Number of bytes currently stored in write buf */ - struct device *fdev; /* Flash device */ + const struct device *fdev; /* Flash device */ size_t bytes_written; /* Number of bytes written to flash */ size_t offset; /* Offset from base of flash device to write area */ size_t available; /* Available bytes in write area */ @@ -80,7 +80,7 @@ struct stream_flash_ctx { * * @return non-negative on success, negative errno code on fail */ -int stream_flash_init(struct stream_flash_ctx *ctx, struct device *fdev, +int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev, uint8_t *buf, size_t buf_len, size_t offset, size_t size, stream_flash_callback_t cb); /** diff --git a/include/syscall_handler.h b/include/syscall_handler.h index a2a6557fa3c75a..60d8bbbe2e06b4 100644 --- a/include/syscall_handler.h +++ b/include/syscall_handler.h @@ -464,7 +464,7 @@ static inline int z_obj_validation_check(struct z_object *ko, #define Z_SYSCALL_DRIVER_OP(ptr, api_name, op) \ ({ \ struct api_name *__device__ = (struct api_name *) \ - ((struct device *)ptr)->api; \ + ((const struct device *)ptr)->api; \ Z_SYSCALL_VERIFY_MSG(__device__->op != NULL, \ "Operation %s not defined for driver " \ "instance %p", \ @@ -491,7 +491,7 @@ static inline int z_obj_validation_check(struct z_object *ko, */ #define Z_SYSCALL_SPECIFIC_DRIVER(_device, _dtype, _api) \ ({ \ - struct device *_dev = (struct device *)_device; \ + const struct device *_dev = (const struct device *)_device; \ Z_SYSCALL_OBJ(_dev, _dtype) || \ Z_SYSCALL_VERIFY_MSG(_dev->api == _api, \ "API structure mismatch"); \ diff --git a/include/usb/class/usb_audio.h b/include/usb/class/usb_audio.h index 19fe21b91d460e..3a209a6162bc41 100644 --- a/include/usb/class/usb_audio.h +++ b/include/usb/class/usb_audio.h @@ -199,8 +199,8 @@ typedef void (*usb_audio_data_completion_cb_t)(const struct device *dev, * Pointer sturct is temporary and is valid only during the * execution of this callback. */ -typedef void (*usb_audio_feature_updated_cb_t)(struct device *dev, - const struct usb_audio_fu_evt *evt); +typedef void (*usb_audio_feature_updated_cb_t)(const struct device *dev, + const struct usb_audio_fu_evt *evt); /** * @brief Audio callbacks used to interact with audio devices by user App. @@ -257,7 +257,7 @@ size_t usb_audio_get_in_frame_size(const struct device *dev); * @param ops USB audio callback structure. Callback are used to * inform the user about what is happening */ -void usb_audio_register(struct device *dev, +void usb_audio_register(const struct device *dev, const struct usb_audio_ops *ops); /** diff --git a/include/usb/class/usb_hid.h b/include/usb/class/usb_hid.h index 91034d9e920609..4f2cb3bef925e2 100644 --- a/include/usb/class/usb_hid.h +++ b/include/usb/class/usb_hid.h @@ -431,7 +431,8 @@ enum hid_kbd_led { }; /* Register HID device */ -void usb_hid_register_device(struct device *dev, const uint8_t *desc, size_t size, +void usb_hid_register_device(const struct device *dev, const uint8_t *desc, + size_t size, const struct hid_ops *op); /* Write to hid interrupt endpoint */ diff --git a/kernel/device.c b/kernel/device.c index a6e8260532003f..2de2cee61bbb87 100644 --- a/kernel/device.c +++ b/kernel/device.c @@ -20,8 +20,8 @@ extern const struct init_entry __init_end[]; extern const struct init_entry __init_SMP_start[]; #endif -extern struct device __device_start[]; -extern struct device __device_end[]; +extern const struct device __device_start[]; +extern const struct device __device_end[]; extern uint32_t __device_init_status_start[]; @@ -58,7 +58,7 @@ void z_sys_init_run_level(int32_t level) const struct init_entry *entry; for (entry = levels[level]; entry < levels[level+1]; entry++) { - struct device *dev = entry->dev; + const struct device *dev = entry->dev; if (dev != NULL) { z_object_init(dev); @@ -75,9 +75,9 @@ void z_sys_init_run_level(int32_t level) } } -struct device *z_impl_device_get_binding(const char *name) +const struct device *z_impl_device_get_binding(const char *name) { - struct device *dev; + const struct device *dev; /* Split the search into two loops: in the common scenario, where * device names are stored in ROM (and are referenced by the user @@ -100,7 +100,7 @@ struct device *z_impl_device_get_binding(const char *name) } #ifdef CONFIG_USERSPACE -static inline struct device *z_vrfy_device_get_binding(const char *name) +static inline const struct device *z_vrfy_device_get_binding(const char *name) { char name_copy[Z_DEVICE_MAX_NAME_LEN]; @@ -114,7 +114,7 @@ static inline struct device *z_vrfy_device_get_binding(const char *name) #include #endif /* CONFIG_USERSPACE */ -size_t z_device_get_all_static(struct device **devices) +size_t z_device_get_all_static(struct device const **devices) { *devices = __device_start; return __device_end - __device_start; @@ -127,11 +127,11 @@ bool z_device_ready(const struct device *dev) } #ifdef CONFIG_DEVICE_POWER_MANAGEMENT -int device_pm_control_nop(struct device *unused_device, - uint32_t unused_ctrl_command, - void *unused_context, - device_pm_cb cb, - void *unused_arg) +int device_pm_control_nop(const struct device *unused_device, + uint32_t unused_ctrl_command, + void *unused_context, + device_pm_cb cb, + void *unused_arg) { return -ENOTSUP; } @@ -148,7 +148,7 @@ int device_any_busy_check(void) return 0; } -int device_busy_check(struct device *chk_dev) +int device_busy_check(const struct device *chk_dev) { if (atomic_test_bit((const atomic_t *)__device_busy_start, (chk_dev - __device_start))) { @@ -159,7 +159,7 @@ int device_busy_check(struct device *chk_dev) #endif -void device_busy_set(struct device *busy_dev) +void device_busy_set(const struct device *busy_dev) { #ifdef CONFIG_DEVICE_POWER_MANAGEMENT atomic_set_bit((atomic_t *) __device_busy_start, @@ -169,7 +169,7 @@ void device_busy_set(struct device *busy_dev) #endif } -void device_busy_clear(struct device *busy_dev) +void device_busy_clear(const struct device *busy_dev) { #ifdef CONFIG_DEVICE_POWER_MANAGEMENT atomic_clear_bit((atomic_t *) __device_busy_start, diff --git a/kernel/include/kernel_offsets.h b/kernel/include/kernel_offsets.h index 89e8107ef43f7b..1978d04dad8f08 100644 --- a/kernel/include/kernel_offsets.h +++ b/kernel/include/kernel_offsets.h @@ -80,7 +80,7 @@ GEN_OFFSET_SYM(_thread_t, custom_data); GEN_ABSOLUTE_SYM(K_THREAD_SIZEOF, sizeof(struct k_thread)); /* size of the device structure. Used by linker scripts */ -GEN_ABSOLUTE_SYM(_DEVICE_STRUCT_SIZEOF, sizeof(struct device)); +GEN_ABSOLUTE_SYM(_DEVICE_STRUCT_SIZEOF, sizeof(const struct device)); /* LCOV_EXCL_STOP */ #endif /* ZEPHYR_KERNEL_INCLUDE_KERNEL_OFFSETS_H_ */ diff --git a/kernel/init.c b/kernel/init.c index e7d5068a3a80ef..89a30b04ceb75f 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -380,7 +380,7 @@ void z_early_boot_rand_get(uint8_t *buf, size_t length) { int n = sizeof(uint32_t); #ifdef CONFIG_ENTROPY_HAS_DRIVER - struct device *entropy = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); + const struct device *entropy = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); int rc; if (entropy == NULL) { diff --git a/kernel/kheap.c b/kernel/kheap.c index 8951649b1b546b..b436e097be565c 100644 --- a/kernel/kheap.c +++ b/kernel/kheap.c @@ -15,7 +15,7 @@ void k_heap_init(struct k_heap *h, void *mem, size_t bytes) sys_heap_init(&h->heap, mem, bytes); } -static int statics_init(struct device *unused) +static int statics_init(const struct device *unused) { ARG_UNUSED(unused); Z_STRUCT_SECTION_FOREACH(k_heap, h) { diff --git a/kernel/mailbox.c b/kernel/mailbox.c index bb20e8ff10f530..db97e7810078c8 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -54,7 +54,7 @@ struct k_mbox *_trace_list_k_mbox; /* * Do run-time initialization of mailbox object subsystem. */ -static int init_mbox_module(struct device *dev) +static int init_mbox_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/mem_domain.c b/kernel/mem_domain.c index 90d4b6a67702f9..e1ab415733d12d 100644 --- a/kernel/mem_domain.c +++ b/kernel/mem_domain.c @@ -268,7 +268,7 @@ void k_mem_domain_remove_thread(k_tid_t thread) k_mem_domain_add_thread(&k_mem_domain_default, thread); } -static int init_mem_domain_module(struct device *arg) +static int init_mem_domain_module(const struct device *arg) { ARG_UNUSED(arg); diff --git a/kernel/mem_slab.c b/kernel/mem_slab.c index 7c516896a6b004..f070939c1e1bb3 100644 --- a/kernel/mem_slab.c +++ b/kernel/mem_slab.c @@ -58,7 +58,7 @@ static int create_free_list(struct k_mem_slab *slab) * * @return N/A */ -static int init_mem_slab_module(struct device *dev) +static int init_mem_slab_module(const struct device *dev) { int rc = 0; ARG_UNUSED(dev); diff --git a/kernel/mempool_sys.c b/kernel/mempool_sys.c index a8d749bf9bd864..9139dc9dfebd65 100644 --- a/kernel/mempool_sys.c +++ b/kernel/mempool_sys.c @@ -31,7 +31,7 @@ static void k_mem_pool_init(struct k_mem_pool *p) z_sys_mem_pool_base_init(&p->base); } -int init_static_pools(struct device *unused) +int init_static_pools(const struct device *unused) { ARG_UNUSED(unused); diff --git a/kernel/msg_q.c b/kernel/msg_q.c index 106d46ac599e26..93c0747ce50044 100644 --- a/kernel/msg_q.c +++ b/kernel/msg_q.c @@ -32,7 +32,7 @@ struct k_msgq *_trace_list_k_msgq; /* * Complete initialization of statically defined message queues. */ -static int init_msgq_module(struct device *dev) +static int init_msgq_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/mutex.c b/kernel/mutex.c index 71ae40b05a078a..3c41dd194544bd 100644 --- a/kernel/mutex.c +++ b/kernel/mutex.c @@ -54,7 +54,7 @@ struct k_mutex *_trace_list_k_mutex; /* * Complete initialization of statically defined mutexes. */ -static int init_mutex_module(struct device *dev) +static int init_mutex_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/pipes.c b/kernel/pipes.c index 667cf22cd47c98..1a7ed10a3a0052 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -81,7 +81,7 @@ static void pipe_async_finish(struct k_pipe_async *async_desc) /* * Do run-time initialization of pipe object subsystem. */ -static int init_pipes_module(struct device *dev) +static int init_pipes_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/queue.c b/kernel/queue.c index 3af87f911bb6d6..c10f8ea775e3f2 100644 --- a/kernel/queue.c +++ b/kernel/queue.c @@ -62,7 +62,7 @@ struct k_queue *_trace_list_k_queue; /* * Complete initialization of statically defined queues. */ -static int init_queue_module(struct device *dev) +static int init_queue_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/sem.c b/kernel/sem.c index 3af950dd83fd58..85c8946614cf79 100644 --- a/kernel/sem.c +++ b/kernel/sem.c @@ -45,7 +45,7 @@ struct k_sem *_trace_list_k_sem; /* * Complete initialization of statically defined semaphores. */ -static int init_sem_module(struct device *dev) +static int init_sem_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/stack.c b/kernel/stack.c index 4d76fa9df914d0..cfc3acabd826bc 100644 --- a/kernel/stack.c +++ b/kernel/stack.c @@ -26,7 +26,7 @@ struct k_stack *_trace_list_k_stack; /* * Complete initialization of statically defined stacks. */ -static int init_stack_module(struct device *dev) +static int init_stack_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/system_work_q.c b/kernel/system_work_q.c index c80aa1f24ab0f8..46fd1b0b3e2524 100644 --- a/kernel/system_work_q.c +++ b/kernel/system_work_q.c @@ -18,7 +18,7 @@ K_KERNEL_STACK_DEFINE(sys_work_q_stack, CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE); struct k_work_q k_sys_work_q; -static int k_sys_work_q_init(struct device *dev) +static int k_sys_work_q_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/timer.c b/kernel/timer.c index 9a9b268cd1107b..cc1c9182c505fa 100644 --- a/kernel/timer.c +++ b/kernel/timer.c @@ -22,7 +22,7 @@ struct k_timer *_trace_list_k_timer; /* * Complete initialization of statically defined timers. */ -static int init_timer_module(struct device *dev) +static int init_timer_module(const struct device *dev) { ARG_UNUSED(dev); diff --git a/kernel/userspace.c b/kernel/userspace.c index e0ee4269e352ba..9906f853ce9605 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -150,7 +150,7 @@ static size_t obj_size_get(enum k_objects otype) switch (otype) { #include default: - ret = sizeof(struct device); + ret = sizeof(const struct device); break; } @@ -798,7 +798,7 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen) extern char __app_shmem_regions_start[]; extern char __app_shmem_regions_end[]; -static int app_shmem_bss_zero(struct device *unused) +static int app_shmem_bss_zero(const struct device *unused) { struct z_app_region *region, *end; diff --git a/lib/gui/lvgl/lvgl.c b/lib/gui/lvgl/lvgl.c index f9ef8a55cf772b..0b00aebd4f862d 100644 --- a/lib/gui/lvgl/lvgl.c +++ b/lib/gui/lvgl/lvgl.c @@ -75,7 +75,7 @@ static void lvgl_log(lv_log_level_t level, const char *file, uint32_t line, static int lvgl_allocate_rendering_buffers(lv_disp_drv_t *disp_drv) { struct display_capabilities cap; - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; int err = 0; display_get_capabilities(display_dev, &cap); @@ -113,7 +113,7 @@ static int lvgl_allocate_rendering_buffers(lv_disp_drv_t *disp_drv) uint16_t buf_nbr_pixels; uint32_t buf_size; struct display_capabilities cap; - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; display_get_capabilities(display_dev, &cap); @@ -178,7 +178,8 @@ static int lvgl_allocate_rendering_buffers(lv_disp_drv_t *disp_drv) K_MSGQ_DEFINE(kscan_msgq, sizeof(lv_indev_data_t), CONFIG_LVGL_POINTER_KSCAN_MSGQ_COUNT, 4); -static void lvgl_pointer_kscan_callback(struct device *dev, uint32_t row, +static void lvgl_pointer_kscan_callback(const struct device *dev, + uint32_t row, uint32_t col, bool pressed) { lv_indev_data_t data = { @@ -213,7 +214,7 @@ static bool lvgl_pointer_kscan_read(lv_indev_drv_t *drv, lv_indev_data_t *data) static int lvgl_pointer_kscan_init(void) { - struct device *kscan_dev = + const struct device *kscan_dev = device_get_binding(CONFIG_LVGL_POINTER_KSCAN_DEV_NAME); lv_indev_drv_t indev_drv; @@ -243,11 +244,11 @@ static int lvgl_pointer_kscan_init(void) } #endif /* CONFIG_LVGL_POINTER_KSCAN */ -static int lvgl_init(struct device *dev) +static int lvgl_init(const struct device *dev) { ARG_UNUSED(dev); - struct device *display_dev = + const struct device *display_dev = device_get_binding(CONFIG_LVGL_DISPLAY_DEV_NAME); int err = 0; lv_disp_drv_t disp_drv; diff --git a/lib/gui/lvgl/lvgl_display.c b/lib/gui/lvgl/lvgl_display.c index d3cf127270c328..ccc8ea69d7a3fa 100644 --- a/lib/gui/lvgl/lvgl_display.c +++ b/lib/gui/lvgl/lvgl_display.c @@ -9,7 +9,7 @@ int set_lvgl_rendering_cb(lv_disp_drv_t *disp_drv) { int err = 0; - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; struct display_capabilities cap; display_get_capabilities(display_dev, &cap); diff --git a/lib/gui/lvgl/lvgl_display_16bit.c b/lib/gui/lvgl/lvgl_display_16bit.c index ca776fd8e63aee..b76b758eff9962 100644 --- a/lib/gui/lvgl/lvgl_display_16bit.c +++ b/lib/gui/lvgl/lvgl_display_16bit.c @@ -11,7 +11,7 @@ void lvgl_flush_cb_16bit(struct _disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; uint16_t w = area->x2 - area->x1 + 1; uint16_t h = area->y2 - area->y1 + 1; struct display_buffer_descriptor desc; diff --git a/lib/gui/lvgl/lvgl_display_24bit.c b/lib/gui/lvgl/lvgl_display_24bit.c index 38b48d0b424298..ca6c402be97cc4 100644 --- a/lib/gui/lvgl/lvgl_display_24bit.c +++ b/lib/gui/lvgl/lvgl_display_24bit.c @@ -11,7 +11,7 @@ void lvgl_flush_cb_24bit(struct _disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; uint16_t w = area->x2 - area->x1 + 1; uint16_t h = area->y2 - area->y1 + 1; struct display_buffer_descriptor desc; diff --git a/lib/gui/lvgl/lvgl_display_32bit.c b/lib/gui/lvgl/lvgl_display_32bit.c index b52b1b881ffbf8..293b3f3066b3d9 100644 --- a/lib/gui/lvgl/lvgl_display_32bit.c +++ b/lib/gui/lvgl/lvgl_display_32bit.c @@ -11,7 +11,7 @@ void lvgl_flush_cb_32bit(struct _disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; uint16_t w = area->x2 - area->x1 + 1; uint16_t h = area->y2 - area->y1 + 1; struct display_buffer_descriptor desc; diff --git a/lib/gui/lvgl/lvgl_display_mono.c b/lib/gui/lvgl/lvgl_display_mono.c index 79bbbaf7ae4ad2..774a5016907fb8 100644 --- a/lib/gui/lvgl/lvgl_display_mono.c +++ b/lib/gui/lvgl/lvgl_display_mono.c @@ -13,7 +13,7 @@ void lvgl_flush_cb_mono(struct _disp_drv_t *disp_drv, { uint16_t w = area->x2 - area->x1 + 1; uint16_t h = area->y2 - area->y1 + 1; - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; struct display_capabilities cap; struct display_buffer_descriptor desc; @@ -37,7 +37,7 @@ void lvgl_set_px_cb_mono(struct _disp_drv_t *disp_drv, uint8_t *buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa) { - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; uint8_t *buf_xy; uint8_t bit; struct display_capabilities cap; @@ -80,7 +80,7 @@ void lvgl_set_px_cb_mono(struct _disp_drv_t *disp_drv, void lvgl_rounder_cb_mono(struct _disp_drv_t *disp_drv, lv_area_t *area) { - struct device *display_dev = (struct device *)disp_drv->user_data; + const struct device *display_dev = (const struct device *)disp_drv->user_data; struct display_capabilities cap; display_get_capabilities(display_dev, &cap); diff --git a/lib/gui/lvgl/lvgl_mem_user.c b/lib/gui/lvgl/lvgl_mem_user.c index fc7714a11b829b..e52a54b7b72a89 100644 --- a/lib/gui/lvgl/lvgl_mem_user.c +++ b/lib/gui/lvgl/lvgl_mem_user.c @@ -24,7 +24,7 @@ void lvgl_free(void *ptr) sys_mem_pool_free(ptr); } -static int lvgl_mem_pool_init(struct device *unused) +static int lvgl_mem_pool_init(const struct device *unused) { sys_mem_pool_init(&lvgl_mem_pool); return 0; diff --git a/lib/libc/minimal/source/stdlib/malloc.c b/lib/libc/minimal/source/stdlib/malloc.c index d9a177ec773f14..c5572596f944a2 100644 --- a/lib/libc/minimal/source/stdlib/malloc.c +++ b/lib/libc/minimal/source/stdlib/malloc.c @@ -42,7 +42,7 @@ void *malloc(size_t size) return ret; } -static int malloc_prepare(struct device *unused) +static int malloc_prepare(const struct device *unused) { ARG_UNUSED(unused); diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c index 16291022f06c45..88ed76b6598b27 100644 --- a/lib/libc/newlib/libc-hooks.c +++ b/lib/libc/newlib/libc-hooks.c @@ -72,7 +72,7 @@ extern void *_heap_sentry; #if Z_MALLOC_PARTITION_EXISTS struct k_mem_partition z_malloc_partition; -static int malloc_prepare(struct device *unused) +static int malloc_prepare(const struct device *unused) { ARG_UNUSED(unused); diff --git a/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.c b/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.c index 6ba4a09b14dd27..01b6e794a26c02 100644 --- a/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.c +++ b/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.c @@ -17,14 +17,14 @@ static struct hello_world_dev_data { uint32_t foo; } data; -static int init(struct device *dev) +static int init(const struct device *dev) { data.foo = 5; return 0; } -static void print_impl(struct device *dev) +static void print_impl(const struct device *dev) { printk("Hello World from the kernel: %d\n", data.foo); @@ -32,7 +32,7 @@ static void print_impl(struct device *dev) } #ifdef CONFIG_USERSPACE -static inline void z_vrfy_hello_world_print(struct device *dev) +static inline void z_vrfy_hello_world_print(const struct device *dev) { Z_OOPS(Z_SYSCALL_DRIVER_HELLO_WORLD(dev, print)); diff --git a/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.h b/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.h index e0e5b664213c68..31e4200cc1fb57 100644 --- a/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.h +++ b/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/hello_world_driver.h @@ -27,11 +27,11 @@ __subsystem struct hello_world_driver_api { * pointer to a function that takes 'struct device *dev' as an * argument and returns 'void'. */ - void (*print)(struct device *dev); + void (*print)(const struct device *dev); }; -__syscall void hello_world_print(struct device *dev); -static inline void z_impl_hello_world_print(struct device *dev) +__syscall void hello_world_print(const struct device *dev); +static inline void z_impl_hello_world_print(const struct device *dev) { const struct hello_world_driver_api *api = dev->api; diff --git a/samples/application_development/out_of_tree_driver/src/main.c b/samples/application_development/out_of_tree_driver/src/main.c index e42bd48ab0a135..99e5d6a2babbda 100644 --- a/samples/application_development/out_of_tree_driver/src/main.c +++ b/samples/application_development/out_of_tree_driver/src/main.c @@ -10,7 +10,7 @@ static void user_entry(void *p1, void *p2, void *p3) { - struct device *dev = p1; + const struct device *dev = p1; hello_world_print(dev); } @@ -19,7 +19,7 @@ void main(void) { printk("Hello World from the app!\n"); - struct device *dev = device_get_binding("CUSTOM_DRIVER"); + const struct device *dev = device_get_binding("CUSTOM_DRIVER"); __ASSERT(dev, "Failed to get device binding"); diff --git a/samples/basic/blinky/src/main.c b/samples/basic/blinky/src/main.c index 8ba4fe138be770..e2fbfd3dc5497f 100644 --- a/samples/basic/blinky/src/main.c +++ b/samples/basic/blinky/src/main.c @@ -29,7 +29,7 @@ void main(void) { - struct device *dev; + const struct device *dev; bool led_is_on = true; int ret; diff --git a/samples/basic/blinky_pwm/src/main.c b/samples/basic/blinky_pwm/src/main.c index f8d6dfaeda8876..befb8342ef6f23 100644 --- a/samples/basic/blinky_pwm/src/main.c +++ b/samples/basic/blinky_pwm/src/main.c @@ -32,7 +32,7 @@ void main(void) { - struct device *pwm; + const struct device *pwm; uint32_t max_period; uint32_t period; uint8_t dir = 0U; diff --git a/samples/basic/button/src/main.c b/samples/basic/button/src/main.c index 3213c17dd655fd..3a55e6f32f5819 100644 --- a/samples/basic/button/src/main.c +++ b/samples/basic/button/src/main.c @@ -35,12 +35,13 @@ #endif /* LED helpers, which use the led0 devicetree alias if it's available. */ -static struct device *initialize_led(void); -static void match_led_to_button(struct device *button, struct device *led); +static const struct device *initialize_led(void); +static void match_led_to_button(const struct device *button, + const struct device *led); static struct gpio_callback button_cb_data; -void button_pressed(struct device *dev, struct gpio_callback *cb, +void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { printk("Button pressed at %" PRIu32 "\n", k_cycle_get_32()); @@ -48,8 +49,8 @@ void button_pressed(struct device *dev, struct gpio_callback *cb, void main(void) { - struct device *button; - struct device *led; + const struct device *button; + const struct device *led; int ret; button = device_get_binding(SW0_GPIO_LABEL); @@ -101,9 +102,9 @@ void main(void) #endif #ifdef LED0_GPIO_LABEL -static struct device *initialize_led(void) +static const struct device *initialize_led(void) { - struct device *led; + const struct device *led; int ret; led = device_get_binding(LED0_GPIO_LABEL); @@ -124,7 +125,8 @@ static struct device *initialize_led(void) return led; } -static void match_led_to_button(struct device *button, struct device *led) +static void match_led_to_button(const struct device *button, + const struct device *led) { bool val; @@ -133,13 +135,14 @@ static void match_led_to_button(struct device *button, struct device *led) } #else /* !defined(LED0_GPIO_LABEL) */ -static struct device *initialize_led(void) +static const struct device *initialize_led(void) { printk("No LED device was defined\n"); return NULL; } -static void match_led_to_button(struct device *button, struct device *led) +static void match_led_to_button(const struct device *button, + const struct device *led) { return; } diff --git a/samples/basic/fade_led/src/main.c b/samples/basic/fade_led/src/main.c index 579843482c9e4e..72d4370a235e30 100644 --- a/samples/basic/fade_led/src/main.c +++ b/samples/basic/fade_led/src/main.c @@ -39,7 +39,7 @@ void main(void) { - struct device *pwm; + const struct device *pwm; uint32_t pulse_width = 0U; uint8_t dir = 1U; int ret; diff --git a/samples/basic/rgb_led/src/main.c b/samples/basic/rgb_led/src/main.c index 355a6f96e72978..5351571be1a0ad 100644 --- a/samples/basic/rgb_led/src/main.c +++ b/samples/basic/rgb_led/src/main.c @@ -61,7 +61,7 @@ #define PERIOD_USEC (USEC_PER_SEC / 50U) #define STEPSIZE_USEC 2000 -static int pwm_set(struct device *pwm_dev, uint32_t pwm_pin, +static int pwm_set(const struct device *pwm_dev, uint32_t pwm_pin, uint32_t pulse_width, pwm_flags_t flags) { return pwm_pin_set_usec(pwm_dev, pwm_pin, PERIOD_USEC, @@ -72,7 +72,7 @@ enum { RED, GREEN, BLUE }; void main(void) { - struct device *pwm_dev[3]; + const struct device *pwm_dev[3]; uint32_t pulse_red, pulse_green, pulse_blue; /* pulse widths */ int ret; diff --git a/samples/basic/servo_motor/src/main.c b/samples/basic/servo_motor/src/main.c index da9a00866ab918..1a4b6433498295 100644 --- a/samples/basic/servo_motor/src/main.c +++ b/samples/basic/servo_motor/src/main.c @@ -38,7 +38,7 @@ enum direction { void main(void) { - struct device *pwm; + const struct device *pwm; uint32_t pulse_width = MIN_PULSE_USEC; enum direction dir = UP; int ret; diff --git a/samples/basic/threads/src/main.c b/samples/basic/threads/src/main.c index 1104d0ac88df43..5bfab933b2c1f8 100644 --- a/samples/basic/threads/src/main.c +++ b/samples/basic/threads/src/main.c @@ -37,7 +37,7 @@ struct led { void blink(const struct led *led, uint32_t sleep_ms, uint32_t id) { - struct device *gpio_dev; + const struct device *gpio_dev; int cnt = 0; int ret; diff --git a/samples/bluetooth/hci_rpmsg/src/main.c b/samples/bluetooth/hci_rpmsg/src/main.c index 4e7fc3db4fd3a7..e4c9abae7b11b3 100644 --- a/samples/bluetooth/hci_rpmsg/src/main.c +++ b/samples/bluetooth/hci_rpmsg/src/main.c @@ -57,8 +57,8 @@ BUILD_ASSERT((SHM_START_ADDR + SHM_SIZE - SHM_BASE_ADDRESS) /* End of configuration defines */ -static struct device *ipm_tx_handle; -static struct device *ipm_rx_handle; +static const struct device *ipm_tx_handle; +static const struct device *ipm_rx_handle; static metal_phys_addr_t shm_physmap[] = { SHM_START_ADDR }; static struct metal_device shm_device = { @@ -123,7 +123,7 @@ static void ipm_callback_process(struct k_work *work) virtqueue_notification(vq[1]); } -static void ipm_callback(struct device *dev, void *context, +static void ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { LOG_INF("Got callback of id %u", id); diff --git a/samples/bluetooth/hci_spi/src/main.c b/samples/bluetooth/hci_spi/src/main.c index 3769953b0c8812..526adcd0c4d0c9 100644 --- a/samples/bluetooth/hci_spi/src/main.c +++ b/samples/bluetooth/hci_spi/src/main.c @@ -71,11 +71,11 @@ const static struct spi_buf_set tx_bufs = { /* HCI buffer pools */ #define CMD_BUF_SIZE BT_BUF_RX_SIZE -static struct device *spi_hci_dev; +static const struct device *spi_hci_dev; static struct spi_config spi_cfg = { .operation = SPI_WORD_SET(8) | SPI_OP_MODE_SLAVE, }; -static struct device *gpio_dev; +static const struct device *gpio_dev; static K_THREAD_STACK_DEFINE(bt_tx_thread_stack, CONFIG_BT_HCI_TX_STACK_SIZE); static struct k_thread bt_tx_thread_data; @@ -241,7 +241,7 @@ static void bt_tx_thread(void *p1, void *p2, void *p3) } } -static int hci_spi_init(struct device *unused) +static int hci_spi_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/samples/bluetooth/hci_uart/src/main.c b/samples/bluetooth/hci_uart/src/main.c index ecdffc9f2ddf34..46c6e1ed345469 100644 --- a/samples/bluetooth/hci_uart/src/main.c +++ b/samples/bluetooth/hci_uart/src/main.c @@ -30,7 +30,7 @@ #define LOG_MODULE_NAME hci_uart LOG_MODULE_REGISTER(LOG_MODULE_NAME); -static struct device *hci_uart_dev; +static const struct device *hci_uart_dev; static K_THREAD_STACK_DEFINE(tx_thread_stack, CONFIG_BT_HCI_TX_STACK_SIZE); static struct k_thread tx_thread_data; static K_FIFO_DEFINE(tx_queue); @@ -52,7 +52,7 @@ static K_FIFO_DEFINE(uart_tx_queue); */ #define H4_DISCARD_LEN 33 -static int h4_read(struct device *uart, uint8_t *buf, +static int h4_read(const struct device *uart, uint8_t *buf, size_t len, size_t min) { int total = 0; @@ -78,7 +78,7 @@ static int h4_read(struct device *uart, uint8_t *buf, return total; } -static size_t h4_discard(struct device *uart, size_t len) +static size_t h4_discard(const struct device *uart, size_t len) { uint8_t buf[H4_DISCARD_LEN]; @@ -134,7 +134,7 @@ static void tx_isr(void) } } -static void bt_uart_isr(struct device *unused, void *user_data) +static void bt_uart_isr(const struct device *unused, void *user_data) { static struct net_buf *buf; static int remaining; @@ -296,7 +296,7 @@ void bt_ctlr_assert_handle(char *file, uint32_t line) } #endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */ -static int hci_uart_init(struct device *unused) +static int hci_uart_init(const struct device *unused) { LOG_DBG(""); diff --git a/samples/bluetooth/mesh/src/microbit.c b/samples/bluetooth/mesh/src/microbit.c index 55e3f6c43d10cf..9d666b5effd041 100644 --- a/samples/bluetooth/mesh/src/microbit.c +++ b/samples/bluetooth/mesh/src/microbit.c @@ -15,9 +15,9 @@ #include "board.h" static uint32_t oob_number; -static struct device *gpio; +static const struct device *gpio; -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mb_display *disp = mb_display_get(); diff --git a/samples/bluetooth/mesh_demo/src/microbit.c b/samples/bluetooth/mesh_demo/src/microbit.c index 2f7210afd44b2c..e37aeb0a201b90 100644 --- a/samples/bluetooth/mesh_demo/src/microbit.c +++ b/samples/bluetooth/mesh_demo/src/microbit.c @@ -29,9 +29,9 @@ #define SEQ_PAGE (NRF_FICR->CODEPAGESIZE * (NRF_FICR->CODESIZE - 1)) #define SEQ_MAX (NRF_FICR->CODEPAGESIZE * 8 * SEQ_PER_BIT) -static struct device *gpio; -static struct device *nvm; -static struct device *pwm; +static const struct device *gpio; +static const struct device *nvm; +static const struct device *pwm; static struct k_work button_work; @@ -41,7 +41,7 @@ static void button_send_pressed(struct k_work *work) board_button_1_pressed(); } -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mb_display *disp = mb_display_get(); diff --git a/samples/bluetooth/peripheral_ht/src/hts.c b/samples/bluetooth/peripheral_ht/src/hts.c index 2c7afafd87db95..0850194213706b 100644 --- a/samples/bluetooth/peripheral_ht/src/hts.c +++ b/samples/bluetooth/peripheral_ht/src/hts.c @@ -25,7 +25,7 @@ #include #include -static struct device *temp_dev; +static const struct device *temp_dev; static uint8_t simulate_htm; static uint8_t indicating; diff --git a/samples/bluetooth/st_ble_sensor/src/button_svc.c b/samples/bluetooth/st_ble_sensor/src/button_svc.c index a69469439eac15..be2b821b20c7c3 100644 --- a/samples/bluetooth/st_ble_sensor/src/button_svc.c +++ b/samples/bluetooth/st_ble_sensor/src/button_svc.c @@ -34,11 +34,11 @@ extern struct bt_conn *conn; extern struct bt_gatt_service_static stsensor_svc[]; extern volatile bool notify_enable; -static struct device *button_dev; +static const struct device *button_dev; static struct gpio_callback gpio_cb; uint16_t but_val; -void button_pressed(struct device *gpiob, struct gpio_callback *cb, +void button_pressed(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins) { int err; diff --git a/samples/bluetooth/st_ble_sensor/src/led_svc.c b/samples/bluetooth/st_ble_sensor/src/led_svc.c index 4df5ee8646fb0b..712af7d53a79ae 100644 --- a/samples/bluetooth/st_ble_sensor/src/led_svc.c +++ b/samples/bluetooth/st_ble_sensor/src/led_svc.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(led_svc); #define LED_PORT DT_GPIO_LABEL(DT_ALIAS(led0), gpios) #define LED DT_GPIO_PIN(DT_ALIAS(led0), gpios) -struct device *led_dev; +const struct device *led_dev; bool led_state; void led_on_off(bool led_state) diff --git a/samples/bluetooth/st_ble_sensor/src/main.c b/samples/bluetooth/st_ble_sensor/src/main.c index f6b3827505228a..8784c368e85d64 100644 --- a/samples/bluetooth/st_ble_sensor/src/main.c +++ b/samples/bluetooth/st_ble_sensor/src/main.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(main); extern uint16_t but_val; -extern struct device *led_dev; +extern const struct device *led_dev; extern bool led_state; /* Prototype */ diff --git a/samples/boards/96b_argonkey/microphone/src/main.c b/samples/boards/96b_argonkey/microphone/src/main.c index a696b84cf5f5bb..011d9c65bcfc57 100644 --- a/samples/boards/96b_argonkey/microphone/src/main.c +++ b/samples/boards/96b_argonkey/microphone/src/main.c @@ -48,7 +48,7 @@ struct dmic_cfg cfg = { void signal_sampling_started(void) { - static struct device *led0, *led1; + static const struct device *led0, *led1; led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), @@ -63,7 +63,7 @@ void signal_sampling_started(void) void signal_sampling_stopped(void) { - static struct device *led0, *led1; + static const struct device *led0, *led1; led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), @@ -78,7 +78,7 @@ void signal_sampling_stopped(void) void signal_print_stopped(void) { - static struct device *led0, *led1; + static const struct device *led0, *led1; led0 = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(led0), gpios)); gpio_pin_configure(led0, DT_GPIO_PIN(DT_ALIAS(led0), gpios), @@ -100,7 +100,7 @@ void main(void) uint32_t ms; #ifdef CONFIG_LP3943 - static struct device *ledc; + static const struct device *ledc; ledc = device_get_binding(DT_LABEL(DT_INST(0, ti_lp3943))); if (!ledc) { @@ -127,7 +127,7 @@ void main(void) int ret; - struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy))); + const struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy))); if (!mic_dev) { printk("Could not get pointer to %s device\n", diff --git a/samples/boards/96b_argonkey/sensors/src/main.c b/samples/boards/96b_argonkey/sensors/src/main.c index 8e85b8fd7e294f..d8ca8c72bf2a56 100644 --- a/samples/boards/96b_argonkey/sensors/src/main.c +++ b/samples/boards/96b_argonkey/sensors/src/main.c @@ -27,7 +27,7 @@ static inline float out_ev(struct sensor_value *val) static int lsm6dsl_trig_cnt; #ifdef CONFIG_LSM6DSL_TRIGGER -static void lsm6dsl_trigger_handler(struct device *dev, +static void lsm6dsl_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { #ifdef ARGONKEY_TEST_LOG @@ -107,11 +107,11 @@ void main(void) { int cnt = 0; char out_str[64]; - static struct device *led0, *led1; + static const struct device *led0, *led1; int i, on = 1; #ifdef CONFIG_LP3943 - static struct device *ledc; + static const struct device *ledc; ledc = device_get_binding(DT_LABEL(DT_INST(0, ti_lp3943))); if (!ledc) { @@ -152,7 +152,7 @@ void main(void) printk("ArgonKey test!!\n"); #ifdef CONFIG_LPS22HB - struct device *baro_dev = + const struct device *baro_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); if (!baro_dev) { @@ -163,7 +163,7 @@ void main(void) #endif #ifdef CONFIG_HTS221 - struct device *hum_dev = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); + const struct device *hum_dev = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); if (!hum_dev) { printk("Could not get pointer to %s sensor\n", @@ -173,7 +173,7 @@ void main(void) #endif #ifdef CONFIG_LSM6DSL - struct device *accel_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); + const struct device *accel_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); if (!accel_dev) { printk("Could not get pointer to %s sensor\n", @@ -238,7 +238,7 @@ void main(void) #endif #ifdef CONFIG_VL53L0X - struct device *tof_dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x))); + const struct device *tof_dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x))); if (!tof_dev) { printk("Could not get pointer to %s sensor\n", diff --git a/samples/boards/bbc_microbit/line_follower_robot/src/main.c b/samples/boards/bbc_microbit/line_follower_robot/src/main.c index 3108b9da5368f6..52005314b17ab5 100644 --- a/samples/boards/bbc_microbit/line_follower_robot/src/main.c +++ b/samples/boards/bbc_microbit/line_follower_robot/src/main.c @@ -15,15 +15,15 @@ #define EXT_P13_GPIO_PIN 23 /* P13, SPI1 SCK */ #define EXT_P14_GPIO_PIN 22 /* P14, SPI1 MISO */ -static struct device *gpio; -struct device *i2c_dev; +static const struct device *gpio; +const struct device *i2c_dev; unsigned int left_line[1]; unsigned int right_line[1]; unsigned char buf[3]; unsigned char speed_hex[1]; /* Setup gpio of the microbit board */ -static void line_detection(struct device *dev, struct gpio_callback *cb, +static void line_detection(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { left_line[0] = gpio_pin_get_raw(gpio, EXT_P13_GPIO_PIN); diff --git a/samples/boards/bbc_microbit/pong/src/main.c b/samples/boards/bbc_microbit/pong/src/main.c index 6278f879c45f29..58d797f0531b49 100644 --- a/samples/boards/bbc_microbit/pong/src/main.c +++ b/samples/boards/bbc_microbit/pong/src/main.c @@ -111,7 +111,7 @@ static int64_t b_timestamp; #define SOUND_PERIOD_PADDLE 200 #define SOUND_PERIOD_WALL 1000 -static struct device *pwm; +static const struct device *pwm; static enum sound_state { SOUND_IDLE, /* No sound */ @@ -392,7 +392,7 @@ void pong_ball_received(int8_t x_pos, int8_t y_pos, int8_t x_vel, int8_t y_vel) k_delayed_work_submit(&refresh, K_NO_WAIT); } -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { /* Filter out spurious presses */ @@ -485,7 +485,7 @@ void pong_remote_lost(void) static void configure_buttons(void) { static struct gpio_callback button_cb_data; - struct device *gpio; + const struct device *gpio; gpio = device_get_binding(DT_GPIO_LABEL(DT_ALIAS(sw0), gpios)); diff --git a/samples/boards/bbc_microbit/sound/src/main.c b/samples/boards/bbc_microbit/sound/src/main.c index 21c201031cbf2b..551b779f95f127 100644 --- a/samples/boards/bbc_microbit/sound/src/main.c +++ b/samples/boards/bbc_microbit/sound/src/main.c @@ -23,8 +23,8 @@ #define US_TO_HZ(_us) (USEC_PER_SEC / (_us)) -static struct device *pwm; -static struct device *gpio; +static const struct device *pwm; +static const struct device *gpio; static uint32_t period = PERIOD_INIT; static struct k_work beep_work; static volatile bool beep_active; @@ -45,7 +45,7 @@ static void beep(struct k_work *work) beep_active = false; } -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mb_display *disp; diff --git a/samples/boards/intel_s1000_crb/audio/src/audio_driver.c b/samples/boards/intel_s1000_crb/audio/src/audio_driver.c index 895ca8a19430eb..8c57d440fc41f2 100644 --- a/samples/boards/intel_s1000_crb/audio/src/audio_driver.c +++ b/samples/boards/intel_s1000_crb/audio/src/audio_driver.c @@ -49,10 +49,10 @@ __attribute__((section(".dma_buffers"))) static struct { int32_t mic_in[MIC_IN_BUF_COUNT][MIC_FRAME_SAMPLES]; } audio_buffers; -static struct device *codec_dev; -static struct device *i2s_spk_out_dev; -static struct device *i2s_host_dev; -static struct device *dmic_device; +static const struct device *codec_dev; +static const struct device *i2s_spk_out_dev; +static const struct device *i2s_host_dev; +static const struct device *dmic_device; static struct k_mem_slab mic_in_mem_slab; static struct k_mem_slab host_inout_mem_slab; diff --git a/samples/boards/intel_s1000_crb/audio/src/usb_transport.c b/samples/boards/intel_s1000_crb/audio/src/usb_transport.c index 7fe1e2845cfe09..a57ec2549c882a 100644 --- a/samples/boards/intel_s1000_crb/audio/src/usb_transport.c +++ b/samples/boards/intel_s1000_crb/audio/src/usb_transport.c @@ -78,7 +78,7 @@ static const uint8_t usb_transport_hid_report_desc[] = { static usb_transport_receive_callback_t receive_data_cb; -static struct device *hid_device; +static const struct device *hid_device; int usb_transport_init(usb_transport_receive_callback_t callback) { diff --git a/samples/boards/intel_s1000_crb/dmic/src/dmic_sample.c b/samples/boards/intel_s1000_crb/dmic/src/dmic_sample.c index 5f05621ec2020e..9e3f1e72ffd5c3 100644 --- a/samples/boards/intel_s1000_crb/dmic/src/dmic_sample.c +++ b/samples/boards/intel_s1000_crb/dmic/src/dmic_sample.c @@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(dmic_sample); static struct k_mem_slab dmic_mem_slab; __attribute__((section(".dma_buffers"))) static char audio_buffers[MIC_FRAME_BYTES][MIC_IN_BUF_COUNT]; -static struct device *dmic_device; +static const struct device *dmic_device; static void dmic_init(void) { diff --git a/samples/boards/intel_s1000_crb/i2s/src/i2s_sample.c b/samples/boards/intel_s1000_crb/i2s/src/i2s_sample.c index cd3b504fedb677..707719d41c6fa5 100644 --- a/samples/boards/intel_s1000_crb/i2s/src/i2s_sample.c +++ b/samples/boards/intel_s1000_crb/i2s/src/i2s_sample.c @@ -59,9 +59,9 @@ LOG_MODULE_REGISTER(i2s_sample); static struct k_mem_slab i2s_mem_slab; __attribute__((section(".dma_buffers"))) static char audio_buffers[AUDIO_FRAME_BUF_BYTES][I2S_PLAY_BUF_COUNT]; -static struct device *spk_i2s_dev; -static struct device *host_i2s_dev; -static struct device *codec_device; +static const struct device *spk_i2s_dev; +static const struct device *host_i2s_dev; +static const struct device *codec_device; #ifndef AUDIO_PLAY_FROM_HOST static inline int audio_playback_buffer_fill(float phase_delta, int32_t *buffer, @@ -208,7 +208,7 @@ static void i2s_start_audio(void) } } -static void i2s_prepare_audio(struct device *dev) +static void i2s_prepare_audio(const struct device *dev) { int frame_counter = 0; void *buffer; diff --git a/samples/boards/nrf/battery/src/battery.c b/samples/boards/nrf/battery/src/battery.c index 940a7cfc93a9c8..67b9c5576a34d5 100644 --- a/samples/boards/nrf/battery/src/battery.c +++ b/samples/boards/nrf/battery/src/battery.c @@ -79,8 +79,8 @@ static const struct divider_config divider_config = { }; struct divider_data { - struct device *adc; - struct device *gpio; + const struct device *adc; + const struct device *gpio; struct adc_channel_cfg adc_cfg; struct adc_sequence adc_seq; int16_t raw; @@ -157,7 +157,7 @@ static int divider_setup(void) static bool battery_ok; -static int battery_setup(struct device *arg) +static int battery_setup(const struct device *arg) { int rc = divider_setup(); diff --git a/samples/boards/nrf/mesh/onoff-app/src/main.c b/samples/boards/nrf/mesh/onoff-app/src/main.c index 4028525e2a568e..7e757921923e0a 100644 --- a/samples/boards/nrf/mesh/onoff-app/src/main.c +++ b/samples/boards/nrf/mesh/onoff-app/src/main.c @@ -170,7 +170,7 @@ struct onoff_state { uint8_t current; uint8_t previous; uint8_t led_gpio_pin; - struct device *led_device; + const struct device *led_device; }; /* @@ -274,7 +274,7 @@ static const struct bt_mesh_comp comp = { .elem_count = ARRAY_SIZE(elements), }; -struct device *sw_device; +const struct device *sw_device; struct sw { uint8_t sw_num; @@ -426,7 +426,7 @@ static uint8_t pin_to_sw(uint32_t pin_pos) return 0; } -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pin_pos) { /* diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c index 79e4e5c352e523..46b40240896f87 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.c @@ -10,12 +10,12 @@ #include "app_gpio.h" #include "publisher.h" -struct device *led_device[4]; -struct device *button_device[4]; +const struct device *led_device[4]; +const struct device *button_device[4]; K_WORK_DEFINE(button_work, publish); -static void button_pressed(struct device *dev, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { k_work_submit(&button_work); diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.h b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.h index 78c0beabe8a07f..884e8dc84d7875 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.h +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/app_gpio.h @@ -9,8 +9,8 @@ #define _APP_GPIO_H /* GPIO */ -extern struct device *button_device[4]; -extern struct device *led_device[4]; +extern const struct device *button_device[4]; +extern const struct device *led_device[4]; void app_gpio_init(void); diff --git a/samples/boards/nrf/system_off/src/main.c b/samples/boards/nrf/system_off/src/main.c index 021bee16729371..b67cd2f6868fcc 100644 --- a/samples/boards/nrf/system_off/src/main.c +++ b/samples/boards/nrf/system_off/src/main.c @@ -23,7 +23,7 @@ * before the threading system starts up between PRE_KERNEL_2 and * POST_KERNEL. Do it at the start of PRE_KERNEL_2. */ -static int disable_ds_1(struct device *dev) +static int disable_ds_1(const struct device *dev) { ARG_UNUSED(dev); @@ -36,7 +36,7 @@ SYS_INIT(disable_ds_1, PRE_KERNEL_2, 0); void main(void) { int rc; - struct device *cons = device_get_binding(CONSOLE_LABEL); + const struct device *cons = device_get_binding(CONSOLE_LABEL); printk("\n%s system off demo\n", CONFIG_BOARD); diff --git a/samples/boards/reel_board/mesh_badge/src/periphs.c b/samples/boards/reel_board/mesh_badge/src/periphs.c index 79ad2cd8cb9fc8..a40114e8f8fa68 100644 --- a/samples/boards/reel_board/mesh_badge/src/periphs.c +++ b/samples/boards/reel_board/mesh_badge/src/periphs.c @@ -13,7 +13,7 @@ #include struct device_info { - struct device *dev; + const struct device *dev; char *name; }; @@ -103,7 +103,8 @@ static void motion_timeout(struct k_work *work) } } -static void motion_handler(struct device *dev, struct sensor_trigger *trig) +static void motion_handler(const struct device *dev, + struct sensor_trigger *trig) { int err; diff --git a/samples/boards/reel_board/mesh_badge/src/reel_board.c b/samples/boards/reel_board/mesh_badge/src/reel_board.c index e35f9413778938..4ef8897f34279d 100644 --- a/samples/boards/reel_board/mesh_badge/src/reel_board.c +++ b/samples/boards/reel_board/mesh_badge/src/reel_board.c @@ -48,16 +48,16 @@ struct font_info { #define STAT_COUNT 128 -static struct device *epd_dev; +static const struct device *epd_dev; static bool pressed; static uint8_t screen_id = SCREEN_MAIN; -static struct device *gpio; +static const struct device *gpio; static struct k_delayed_work epd_work; static struct k_delayed_work long_press_work; static char str_buf[256]; static struct { - struct device *dev; + const struct device *dev; const char *name; gpio_pin_t pin; gpio_flags_t flags; @@ -447,7 +447,8 @@ static bool button_is_pressed(void) return gpio_pin_get(gpio, DT_GPIO_PIN(DT_ALIAS(sw0), gpios)) > 0; } -static void button_interrupt(struct device *dev, struct gpio_callback *cb, +static void button_interrupt(const struct device *dev, + struct gpio_callback *cb, uint32_t pins) { if (button_is_pressed() == pressed) { @@ -576,7 +577,7 @@ static int configure_leds(void) static int erase_storage(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL); diff --git a/samples/boards/sensortile_box/src/main.c b/samples/boards/sensortile_box/src/main.c index 0f3da04eaea722..f74293fa4ca22b 100644 --- a/samples/boards/sensortile_box/src/main.c +++ b/samples/boards/sensortile_box/src/main.c @@ -23,7 +23,7 @@ #ifdef CONFIG_LPS22HH_TRIGGER static int lps22hh_trig_cnt; -static void lps22hh_trigger_handler(struct device *dev, +static void lps22hh_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS); @@ -34,8 +34,8 @@ static void lps22hh_trigger_handler(struct device *dev, #ifdef CONFIG_LIS2DW12_TRIGGER static int lis2dw12_trig_cnt; -static void lis2dw12_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void lis2dw12_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lis2dw12_trig_cnt++; @@ -47,22 +47,22 @@ static int lsm6dso_acc_trig_cnt; static int lsm6dso_gyr_trig_cnt; static int lsm6dso_temp_trig_cnt; -static void lsm6dso_acc_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_acc_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lsm6dso_acc_trig_cnt++; } -static void lsm6dso_gyr_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_gyr_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ); lsm6dso_gyr_trig_cnt++; } -static void lsm6dso_temp_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_temp_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP); lsm6dso_temp_trig_cnt++; @@ -72,7 +72,7 @@ static void lsm6dso_temp_trig_handler(struct device *dev, #ifdef CONFIG_STTS751_TRIGGER static int stts751_trig_cnt; -static void stts751_trigger_handler(struct device *dev, +static void stts751_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { stts751_trig_cnt++; @@ -82,7 +82,7 @@ static void stts751_trigger_handler(struct device *dev, #ifdef CONFIG_IIS3DHHC_TRIGGER static int iis3dhhc_trig_cnt; -static void iis3dhhc_trigger_handler(struct device *dev, +static void iis3dhhc_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); @@ -90,7 +90,7 @@ static void iis3dhhc_trigger_handler(struct device *dev, } #endif -static void lps22hh_config(struct device *lps22hh) +static void lps22hh_config(const struct device *lps22hh) { struct sensor_value odr_attr; @@ -113,7 +113,7 @@ static void lps22hh_config(struct device *lps22hh) #endif } -static void lis2dw12_config(struct device *lis2dw12) +static void lis2dw12_config(const struct device *lis2dw12) { struct sensor_value odr_attr, fs_attr; @@ -144,7 +144,7 @@ static void lis2dw12_config(struct device *lis2dw12) #endif } -static void lsm6dso_config(struct device *lsm6dso) +static void lsm6dso_config(const struct device *lsm6dso) { struct sensor_value odr_attr, fs_attr; @@ -201,7 +201,7 @@ static void lsm6dso_config(struct device *lsm6dso) #endif } -static void stts751_config(struct device *stts751) +static void stts751_config(const struct device *stts751) { struct sensor_value odr_attr; @@ -224,7 +224,7 @@ static void stts751_config(struct device *stts751) #endif } -static void iis3dhhc_config(struct device *iis3dhhc) +static void iis3dhhc_config(const struct device *iis3dhhc) { struct sensor_value odr_attr; @@ -249,8 +249,8 @@ static void iis3dhhc_config(struct device *iis3dhhc) void main(void) { - static struct device *led0, *led1; - struct device *dev = device_get_binding( + static const struct device *led0, *led1; + const struct device *dev = device_get_binding( CONFIG_UART_CONSOLE_ON_DEV_NAME); int i, on = 1; int cnt = 1; @@ -288,13 +288,13 @@ void main(void) printk("SensorTile.box test!!\n"); - struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); - struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); - struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh))); - struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); - struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751))); - struct device *iis3dhhc = device_get_binding(DT_LABEL(DT_INST(0, st_iis3dhhc))); - struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); + const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); + const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); + const struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh))); + const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); + const struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751))); + const struct device *iis3dhhc = device_get_binding(DT_LABEL(DT_INST(0, st_iis3dhhc))); + const struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); if (!hts221) { printk("Could not get pointer to %s sensor\n", diff --git a/samples/boards/ti/cc13x2_cc26x2/system_off/src/ext_flash.c b/samples/boards/ti/cc13x2_cc26x2/system_off/src/ext_flash.c index d66466f9d20756..094376dda91dd1 100644 --- a/samples/boards/ti/cc13x2_cc26x2/system_off/src/ext_flash.c +++ b/samples/boards/ti/cc13x2_cc26x2/system_off/src/ext_flash.c @@ -21,7 +21,8 @@ /* * ======== CC1352R1_LAUNCHXL_sendExtFlashByte ======== */ -void CC1352R1_LAUNCHXL_sendExtFlashByte(struct device *dev, uint8_t byte) +void CC1352R1_LAUNCHXL_sendExtFlashByte(const struct device *dev, + uint8_t byte) { uint8_t i; @@ -56,7 +57,7 @@ void CC1352R1_LAUNCHXL_sendExtFlashByte(struct device *dev, uint8_t byte) /* * ======== CC1352R1_LAUNCHXL_wakeUpExtFlash ======== */ -void CC1352R1_LAUNCHXL_wakeUpExtFlash(struct device *dev) +void CC1352R1_LAUNCHXL_wakeUpExtFlash(const struct device *dev) { /* * To wake up we need to toggle the chip select at @@ -77,7 +78,7 @@ void CC1352R1_LAUNCHXL_wakeUpExtFlash(struct device *dev) */ void CC1352R1_LAUNCHXL_shutDownExtFlash(void) { - struct device *dev; + const struct device *dev; uint8_t extFlashShutdown = 0xB9; dev = device_get_binding(GPIO_PORT); diff --git a/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c b/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c index 9d629d927953ee..b8261f52006bdc 100644 --- a/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c +++ b/samples/boards/ti/cc13x2_cc26x2/system_off/src/main.c @@ -28,7 +28,7 @@ extern void CC1352R1_LAUNCHXL_shutDownExtFlash(void); void main(void) { uint32_t config, status; - struct device *gpiob; + const struct device *gpiob; printk("\n%s system off demo\n", CONFIG_BOARD); diff --git a/samples/boards/up_squared/gpio_counter/src/main.c b/samples/boards/up_squared/gpio_counter/src/main.c index 4faae6e31c2b81..1534589987cbf8 100644 --- a/samples/boards/up_squared/gpio_counter/src/main.c +++ b/samples/boards/up_squared/gpio_counter/src/main.c @@ -41,7 +41,7 @@ struct _pin { uint32_t hat_num; uint32_t pin; const char *gpio_dev_name; - struct device *gpio_dev; + const struct device *gpio_dev; }; struct _pin counter_pins[] = { @@ -82,7 +82,8 @@ K_SEM_DEFINE(counter_sem, 0, 1); #define NUM_PINS ARRAY_SIZE(counter_pins) #define MASK (BIT(NUM_PINS) - 1) -void button_cb(struct device *gpiodev, struct gpio_callback *cb, uint32_t pin) +void button_cb(const struct device *gpiodev, struct gpio_callback *cb, + uint32_t pin) { counter++; k_sem_give(&counter_sem); diff --git a/samples/display/cfb/src/main.c b/samples/display/cfb/src/main.c index e6fc64482b14de..4a80d9868d8951 100644 --- a/samples/display/cfb/src/main.c +++ b/samples/display/cfb/src/main.c @@ -23,7 +23,7 @@ void main(void) { - struct device *dev; + const struct device *dev; uint16_t rows; uint8_t ppt; uint8_t font_width; diff --git a/samples/display/cfb_custom_font/src/main.c b/samples/display/cfb_custom_font/src/main.c index b461141e45da21..6a3a09832ad192 100644 --- a/samples/display/cfb_custom_font/src/main.c +++ b/samples/display/cfb_custom_font/src/main.c @@ -17,7 +17,7 @@ #error Unsupported board #endif -struct device *display; +const struct device *display; void main(void) { diff --git a/samples/display/grove_display/src/main.c b/samples/display/grove_display/src/main.c index f352ef49220a0e..f4eff80f9dd085 100644 --- a/samples/display/grove_display/src/main.c +++ b/samples/display/grove_display/src/main.c @@ -33,7 +33,7 @@ uint8_t clamp_rgb(int val) void main(void) { - struct device *glcd; + const struct device *glcd; char str[20]; int rgb[] = { 0x0, 0x0, 0x0 }; uint8_t rgb_chg[3]; diff --git a/samples/display/lvgl/src/main.c b/samples/display/lvgl/src/main.c index e04a9f318a8892..b176f2abc50399 100644 --- a/samples/display/lvgl/src/main.c +++ b/samples/display/lvgl/src/main.c @@ -19,7 +19,7 @@ void main(void) { uint32_t count = 0U; char count_str[11] = {0}; - struct device *display_dev; + const struct device *display_dev; lv_obj_t *hello_world_label; lv_obj_t *count_label; diff --git a/samples/drivers/can/src/main.c b/samples/drivers/can/src/main.c index 7437052455c214..d2ab463a763e10 100644 --- a/samples/drivers/can/src/main.c +++ b/samples/drivers/can/src/main.c @@ -25,7 +25,7 @@ K_THREAD_STACK_DEFINE(rx_thread_stack, RX_THREAD_STACK_SIZE); K_THREAD_STACK_DEFINE(poll_state_stack, STATE_POLL_THREAD_STACK_SIZE); -struct device *can_dev; +const struct device *can_dev; struct k_thread rx_thread_data; struct k_thread poll_state_thread_data; @@ -79,7 +79,7 @@ void rx_thread(void *arg1, void *arg2, void *arg3) void change_led(struct zcan_frame *msg, void *led_dev_param) { - struct device *led_dev = (struct device *)led_dev_param; + const struct device *led_dev = (const struct device *)led_dev_param; #if DT_PHA_HAS_CELL(DT_ALIAS(led0), gpios, pin) && \ DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) @@ -192,7 +192,7 @@ void main(void) }; uint8_t toggle = 1; uint16_t counter = 0; - struct device *led_gpio_dev = NULL; + const struct device *led_gpio_dev = NULL; k_tid_t rx_tid, get_state_tid; int ret; diff --git a/samples/drivers/counter/alarm/src/main.c b/samples/drivers/counter/alarm/src/main.c index 76f9536e543130..a552193cfbe359 100644 --- a/samples/drivers/counter/alarm/src/main.c +++ b/samples/drivers/counter/alarm/src/main.c @@ -25,7 +25,7 @@ struct counter_alarm_cfg alarm_cfg; #define TIMER DT_LABEL(DT_NODELABEL(counter0)) #endif -static void test_counter_interrupt_fn(struct device *counter_dev, +static void test_counter_interrupt_fn(const struct device *counter_dev, uint8_t chan_id, uint32_t ticks, void *user_data) { @@ -64,7 +64,7 @@ static void test_counter_interrupt_fn(struct device *counter_dev, void main(void) { - struct device *counter_dev; + const struct device *counter_dev; int err; printk("Counter alarm sample\n\n"); diff --git a/samples/drivers/counter/maxim_ds3231/src/main.c b/samples/drivers/counter/maxim_ds3231/src/main.c index 9087f0fa4ba239..c73ca227f2519f 100644 --- a/samples/drivers/counter/maxim_ds3231/src/main.c +++ b/samples/drivers/counter/maxim_ds3231/src/main.c @@ -30,7 +30,7 @@ static const char *format_time(time_t time, return buf; } -static void sec_counter_callback(struct device *dev, +static void sec_counter_callback(const struct device *dev, uint8_t id, uint32_t ticks, void *ud) @@ -39,7 +39,7 @@ static void sec_counter_callback(struct device *dev, k_uptime_get_32(), id, ticks, ud); } -static void sec_alarm_handler(struct device *dev, +static void sec_alarm_handler(const struct device *dev, uint8_t id, uint32_t syncclock, void *ud) @@ -94,7 +94,7 @@ void timespec_add(struct timespec *apb, } } -static void min_alarm_handler(struct device *dev, +static void min_alarm_handler(const struct device *dev, uint8_t id, uint32_t syncclock, void *ud) @@ -149,7 +149,7 @@ static void min_alarm_handler(struct device *dev, struct maxim_ds3231_alarm sec_alarm; struct maxim_ds3231_alarm min_alarm; -static void show_counter(struct device *ds3231) +static void show_counter(const struct device *ds3231) { uint32_t now = 0; @@ -176,7 +176,7 @@ static void show_counter(struct device *ds3231) * Subsequent reads of the RTC time adjusted based on a syncpoint * should match the uptime relative to the programmed hour. */ -static void set_aligned_clock(struct device *ds3231) +static void set_aligned_clock(const struct device *ds3231) { if (!IS_ENABLED(CONFIG_APP_SET_ALIGNED_CLOCK)) { return; @@ -229,7 +229,7 @@ static void set_aligned_clock(struct device *ds3231) void main(void) { - struct device *ds3231; + const struct device *ds3231; const char *const dev_id = DT_LABEL(DT_INST(0, maxim_ds3231)); ds3231 = device_get_binding(dev_id); diff --git a/samples/drivers/crypto/src/main.c b/samples/drivers/crypto/src/main.c index 08a4a8ea9bb416..0f09a52e6e0216 100644 --- a/samples/drivers/crypto/src/main.c +++ b/samples/drivers/crypto/src/main.c @@ -75,7 +75,7 @@ static void print_buffer_comparison(const uint8_t *wanted_result, printk("\n"); } -int validate_hw_compatibility(struct device *dev) +int validate_hw_compatibility(const struct device *dev) { uint32_t flags = 0U; @@ -104,7 +104,7 @@ int validate_hw_compatibility(struct device *dev) } -void ecb_mode(struct device *dev) +void ecb_mode(const struct device *dev) { /* from FIPS-197 test vectors */ uint8_t ecb_key[16] = { @@ -200,7 +200,7 @@ static const uint8_t cbc_ciphertext[80] = { 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7 }; -void cbc_mode(struct device *dev) +void cbc_mode(const struct device *dev) { uint8_t encrypted[80] = {0}; uint8_t decrypted[64] = {0}; @@ -289,7 +289,7 @@ static const uint8_t ctr_ciphertext[64] = { 0xa3, 0x5c, 0x85, 0x3a, 0xb9, 0x2c, 0x6, 0xbb }; -void ctr_mode(struct device *dev) +void ctr_mode(const struct device *dev) { uint8_t encrypted[64] = {0}; uint8_t decrypted[64] = {0}; @@ -389,7 +389,7 @@ static const uint8_t ccm_expected[31] = { 0xe8, 0xd1, 0x2c, 0xfd, 0xf9, 0x26, 0xe0 }; -void ccm_mode(struct device *dev) +void ccm_mode(const struct device *dev) { uint8_t encrypted[50]; uint8_t decrypted[25]; @@ -506,7 +506,7 @@ static const uint8_t gcm_expected[58] = { 0x96, 0x04, 0x94, 0xc3 }; -void gcm_mode(struct device *dev) +void gcm_mode(const struct device *dev) { uint8_t encrypted[60] = {0}; uint8_t decrypted[44] = {0}; @@ -598,12 +598,12 @@ void gcm_mode(struct device *dev) struct mode_test { const char *mode; - void (*mode_func)(struct device *dev); + void (*mode_func)(const struct device *dev); }; void main(void) { - struct device *dev = device_get_binding(CRYPTO_DRV_NAME); + const struct device *dev = device_get_binding(CRYPTO_DRV_NAME); const struct mode_test modes[] = { { .mode = "ECB Mode", .mode_func = ecb_mode }, { .mode = "CBC Mode", .mode_func = cbc_mode }, diff --git a/samples/drivers/current_sensing/src/main.c b/samples/drivers/current_sensing/src/main.c index bdc035932ea636..67cfe21a33535c 100644 --- a/samples/drivers/current_sensing/src/main.c +++ b/samples/drivers/current_sensing/src/main.c @@ -32,7 +32,7 @@ #define CUR_LSB 100 #define PWR_LSB 2000 -int read_reg16(struct device *i2c_dev, uint8_t reg_addr, +int read_reg16(const struct device *i2c_dev, uint8_t reg_addr, uint8_t *data) { uint8_t wr_addr; @@ -56,7 +56,7 @@ int read_reg16(struct device *i2c_dev, uint8_t reg_addr, return i2c_transfer(i2c_dev, &msgs[0], 2, I2C_SLV_ADDR); } -int write_reg16(struct device *i2c_dev, uint8_t reg_addr, +int write_reg16(const struct device *i2c_dev, uint8_t reg_addr, uint8_t *data) { uint8_t wr_addr; @@ -82,7 +82,7 @@ int write_reg16(struct device *i2c_dev, uint8_t reg_addr, void main(void) { - struct device *i2c_dev; + const struct device *i2c_dev; uint8_t data[2]; uint32_t shunt_volt, bus_volt, current, power; diff --git a/samples/drivers/dac/src/main.c b/samples/drivers/dac/src/main.c index cc247b133ce8e0..8554f3e79f899e 100644 --- a/samples/drivers/dac/src/main.c +++ b/samples/drivers/dac/src/main.c @@ -36,7 +36,7 @@ static const struct dac_channel_cfg dac_ch_cfg = { void main(void) { - struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); + const struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); if (!dac_dev) { printk("Cannot get DAC device\n"); diff --git a/samples/drivers/display/src/main.c b/samples/drivers/display/src/main.c index fa5d3784862b90..d6cc95c96c1acc 100644 --- a/samples/drivers/display/src/main.c +++ b/samples/drivers/display/src/main.c @@ -201,7 +201,7 @@ void main(void) size_t grey_count; uint8_t *buf; int32_t grey_scale_sleep; - struct device *display_dev; + const struct device *display_dev; struct display_capabilities capabilities; struct display_buffer_descriptor buf_desc; size_t buf_size = 0; diff --git a/samples/drivers/entropy/src/main.c b/samples/drivers/entropy/src/main.c index e893581305a4d6..e06a790f6312a6 100644 --- a/samples/drivers/entropy/src/main.c +++ b/samples/drivers/entropy/src/main.c @@ -10,7 +10,7 @@ void main(void) { - struct device *dev; + const struct device *dev; printf("Entropy Example! %s\n", CONFIG_ARCH); diff --git a/samples/drivers/espi/src/main.c b/samples/drivers/espi/src/main.c index e15905371a4251..e5f8fc80886e90 100644 --- a/samples/drivers/espi/src/main.c +++ b/samples/drivers/espi/src/main.c @@ -62,13 +62,13 @@ struct oob_header { #define BRD_PWR_RSMRST_PIN DT_GPIO_PIN(BRD_PWR_NODE, rsm_gpios) #define BRD_PWR_PWRGD_PIN DT_GPIO_PIN(BRD_PWR_NODE, pwrg_gpios) -static struct device *pwrgd_dev; -static struct device *rsm_dev; +static const struct device *pwrgd_dev; +static const struct device *rsm_dev; #endif #define ESPI_DEV DT_LABEL(DT_NODELABEL(espi0)) -static struct device *espi_dev; +static const struct device *espi_dev; static struct espi_callback espi_bus_cb; static struct espi_callback vw_rdy_cb; static struct espi_callback vw_cb; @@ -107,7 +107,7 @@ static void host_warn_handler(uint32_t signal, uint32_t status) } /* eSPI bus event handler */ -static void espi_reset_handler(struct device *dev, +static void espi_reset_handler(const struct device *dev, struct espi_callback *cb, struct espi_event event) { @@ -118,7 +118,8 @@ static void espi_reset_handler(struct device *dev, } /* eSPI logical channels enable/disable event handler */ -static void espi_ch_handler(struct device *dev, struct espi_callback *cb, +static void espi_ch_handler(const struct device *dev, + struct espi_callback *cb, struct espi_event event) { if (event.evt_type == ESPI_BUS_EVENT_CHANNEL_READY) { @@ -139,7 +140,7 @@ static void espi_ch_handler(struct device *dev, struct espi_callback *cb, } /* eSPI vwire received event handler */ -static void vwire_handler(struct device *dev, struct espi_callback *cb, +static void vwire_handler(const struct device *dev, struct espi_callback *cb, struct espi_event event) { if (event.evt_type == ESPI_BUS_EVENT_VWIRE_RECEIVED) { @@ -162,7 +163,7 @@ static void vwire_handler(struct device *dev, struct espi_callback *cb, } /* eSPI peripheral channel notifications handler */ -static void periph_handler(struct device *dev, struct espi_callback *cb, +static void periph_handler(const struct device *dev, struct espi_callback *cb, struct espi_event event) { uint8_t periph_type; @@ -237,7 +238,8 @@ int espi_init(void) } #if DT_NODE_HAS_STATUS(BRD_PWR_NODE, okay) -static int wait_for_pin(struct device *dev, uint8_t pin, uint16_t timeout, +static int wait_for_pin(const struct device *dev, uint8_t pin, + uint16_t timeout, int exp_level) { uint16_t loop_cnt = timeout; @@ -268,7 +270,7 @@ static int wait_for_pin(struct device *dev, uint8_t pin, uint16_t timeout, } #endif -static int wait_for_vwire(struct device *espi_dev, +static int wait_for_vwire(const struct device *espi_dev, enum espi_vwire_signal signal, uint16_t timeout, uint8_t exp_level) { @@ -476,7 +478,7 @@ static int espi_flash_test(uint32_t start_flash_addr, uint8_t blocks) } #endif /* CONFIG_ESPI_FLASH_CHANNEL */ -int get_pch_temp(struct device *dev, int *temp) +int get_pch_temp(const struct device *dev, int *temp) { struct espi_oob_packet req_pckt; struct espi_oob_packet resp_pckt; diff --git a/samples/drivers/flash_shell/src/main.c b/samples/drivers/flash_shell/src/main.c index 04848ccfa03501..16adf44f85fdc5 100644 --- a/samples/drivers/flash_shell/src/main.c +++ b/samples/drivers/flash_shell/src/main.c @@ -93,7 +93,7 @@ LOG_MODULE_REGISTER(app); #error Please increase CONFIG_SHELL_ARGC_MAX parameter. #endif -static struct device *flash_device; +static const struct device *flash_device; static int check_flash_device(const struct shell *shell) { @@ -752,7 +752,7 @@ static int cmd_page_write(const struct shell *shell, size_t argc, char **argv) static int cmd_set_dev(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; const char *name; name = argv[1]; diff --git a/samples/drivers/ht16k33/src/main.c b/samples/drivers/ht16k33/src/main.c index 2f425b434ce5ea..162a857a564552 100644 --- a/samples/drivers/ht16k33/src/main.c +++ b/samples/drivers/ht16k33/src/main.c @@ -20,11 +20,11 @@ LOG_MODULE_REGISTER(main); #define KEYSCAN_DEVICES 3 -struct device *led_dev; -struct device *ks_dev[KEYSCAN_DEVICES]; +const struct device *led_dev; +const struct device *ks_dev[KEYSCAN_DEVICES]; static struct gpio_callback ks_cb[KEYSCAN_DEVICES]; -static void keyscan_callback(struct device *gpiob, +static void keyscan_callback(const struct device *gpiob, struct gpio_callback *cb, uint32_t pins) { LOG_INF("%s: 0x%08x", gpiob->name, pins); diff --git a/samples/drivers/i2c_fujitsu_fram/src/main.c b/samples/drivers/i2c_fujitsu_fram/src/main.c index 11e5aa723fd904..6ba59baa60c635 100644 --- a/samples/drivers/i2c_fujitsu_fram/src/main.c +++ b/samples/drivers/i2c_fujitsu_fram/src/main.c @@ -18,7 +18,7 @@ #define FRAM_I2C_ADDR 0x50 -static int write_bytes(struct device *i2c_dev, uint16_t addr, +static int write_bytes(const struct device *i2c_dev, uint16_t addr, uint8_t *data, uint32_t num_bytes) { uint8_t wr_addr[2]; @@ -43,7 +43,7 @@ static int write_bytes(struct device *i2c_dev, uint16_t addr, return i2c_transfer(i2c_dev, &msgs[0], 2, FRAM_I2C_ADDR); } -static int read_bytes(struct device *i2c_dev, uint16_t addr, +static int read_bytes(const struct device *i2c_dev, uint16_t addr, uint8_t *data, uint32_t num_bytes) { uint8_t wr_addr[2]; @@ -72,7 +72,7 @@ static int read_bytes(struct device *i2c_dev, uint16_t addr, void main(void) { - struct device *i2c_dev; + const struct device *i2c_dev; uint8_t cmp_data[16]; uint8_t data[16]; int i, ret; diff --git a/samples/drivers/i2s/litex/src/main.c b/samples/drivers/i2s/litex/src/main.c index b026d306a0a511..2f8a8d0801e053 100644 --- a/samples/drivers/i2s/litex/src/main.c +++ b/samples/drivers/i2s/litex/src/main.c @@ -21,8 +21,8 @@ #define I2S_PLAY_BUF_COUNT (500) -static struct device *host_i2s_rx_dev; -static struct device *host_i2s_tx_dev; +static const struct device *host_i2s_rx_dev; +static const struct device *host_i2s_tx_dev; static struct k_mem_slab i2s_rx_mem_slab; static struct k_mem_slab i2s_tx_mem_slab; static char rx_buffers[AUDIO_FRAME_BUF_BYTES * I2S_PLAY_BUF_COUNT]; diff --git a/samples/drivers/jesd216/src/main.c b/samples/drivers/jesd216/src/main.c index ac26c1075bfa23..34ab184047b30a 100644 --- a/samples/drivers/jesd216/src/main.c +++ b/samples/drivers/jesd216/src/main.c @@ -227,7 +227,7 @@ static void dump_bytes(const struct jesd216_param_header *php, void main(void) { - struct device *dev = device_get_binding(FLASH_DEVICE); + const struct device *dev = device_get_binding(FLASH_DEVICE); if (!dev) { printf("%s: device not found\n", FLASH_DEVICE); diff --git a/samples/drivers/kscan/src/main.c b/samples/drivers/kscan/src/main.c index b5539b544b9ea0..ec8bfeaab3e038 100644 --- a/samples/drivers/kscan/src/main.c +++ b/samples/drivers/kscan/src/main.c @@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(main); #define KSCAN_LABEL DT_LABEL(DT_ALIAS(kscan0)) -struct device *kscan_dev; +const struct device *kscan_dev; static struct k_timer typematic_timer; static struct k_timer block_matrix_timer; @@ -122,7 +122,8 @@ static void typematic_callback(struct k_timer *timer) LOG_INF("Typematic : %u\n", last_key); } -static void kb_callback(struct device *dev, uint32_t row, uint32_t col, bool pressed) +static void kb_callback(const struct device *dev, uint32_t row, uint32_t col, + bool pressed) { ARG_UNUSED(dev); last_key = keymap[col][row]; diff --git a/samples/drivers/kscan_touch/src/main.c b/samples/drivers/kscan_touch/src/main.c index 37ee1c7262c56a..beb3ad8c99fe50 100644 --- a/samples/drivers/kscan_touch/src/main.c +++ b/samples/drivers/kscan_touch/src/main.c @@ -15,11 +15,12 @@ LOG_MODULE_REGISTER(main); -struct device *kscan_dev; +const struct device *kscan_dev; #define TOUCH_CONTROLLER_LABEL DT_LABEL(DT_ALIAS(kscan0)) -static void k_callback(struct device *dev, uint32_t row, uint32_t col, bool pressed) +static void k_callback(const struct device *dev, uint32_t row, uint32_t col, + bool pressed) { ARG_UNUSED(dev); if (pressed) { diff --git a/samples/drivers/lcd_hd44780/src/main.c b/samples/drivers/lcd_hd44780/src/main.c index 781eb8933c6ad7..15cf675ca24d2a 100644 --- a/samples/drivers/lcd_hd44780/src/main.c +++ b/samples/drivers/lcd_hd44780/src/main.c @@ -180,7 +180,7 @@ void _set_row_offsets(int8_t row0, int8_t row1, int8_t row2, int8_t row3) } -void _pi_lcd_toggle_enable(struct device *gpio_dev) +void _pi_lcd_toggle_enable(const struct device *gpio_dev) { GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC25_E, LOW); k_msleep(ENABLE_DELAY); @@ -191,7 +191,7 @@ void _pi_lcd_toggle_enable(struct device *gpio_dev) } -void _pi_lcd_4bits_wr(struct device *gpio_dev, uint8_t bits) +void _pi_lcd_4bits_wr(const struct device *gpio_dev, uint8_t bits) { /* High bits */ GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC24_D4, LOW); @@ -236,7 +236,7 @@ void _pi_lcd_4bits_wr(struct device *gpio_dev, uint8_t bits) _pi_lcd_toggle_enable(gpio_dev); } -void _pi_lcd_8bits_wr(struct device *gpio_dev, uint8_t bits) +void _pi_lcd_8bits_wr(const struct device *gpio_dev, uint8_t bits) { /* High bits */ GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC21_D7, LOW); @@ -278,7 +278,7 @@ void _pi_lcd_8bits_wr(struct device *gpio_dev, uint8_t bits) _pi_lcd_toggle_enable(gpio_dev); } -void _pi_lcd_data(struct device *gpio_dev, uint8_t bits) +void _pi_lcd_data(const struct device *gpio_dev, uint8_t bits) { if (lcd_data.disp_func & LCD_8BIT_MODE) { _pi_lcd_8bits_wr(gpio_dev, bits); @@ -287,14 +287,14 @@ void _pi_lcd_data(struct device *gpio_dev, uint8_t bits) } } -void _pi_lcd_command(struct device *gpio_dev, uint8_t bits) +void _pi_lcd_command(const struct device *gpio_dev, uint8_t bits) { /* mode = False for command */ GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC28_RS, LOW); _pi_lcd_data(gpio_dev, bits); } -void _pi_lcd_write(struct device *gpio_dev, uint8_t bits) +void _pi_lcd_write(const struct device *gpio_dev, uint8_t bits) { /* mode = True for character */ GPIO_PIN_WR(gpio_dev, GPIO_PIN_PC28_RS, HIGH); @@ -306,14 +306,15 @@ void _pi_lcd_write(struct device *gpio_dev, uint8_t bits) * USER can use these APIs *************************/ /** Home */ -void pi_lcd_home(struct device *gpio_dev) +void pi_lcd_home(const struct device *gpio_dev) { _pi_lcd_command(gpio_dev, LCD_RETURN_HOME); k_sleep(K_MSEC(2)); /* wait for 2ms */ } /** Set curson position */ -void pi_lcd_set_cursor(struct device *gpio_dev, uint8_t col, uint8_t row) +void pi_lcd_set_cursor(const struct device *gpio_dev, uint8_t col, + uint8_t row) { size_t max_lines; @@ -329,7 +330,7 @@ void pi_lcd_set_cursor(struct device *gpio_dev, uint8_t col, uint8_t row) /** Clear display */ -void pi_lcd_clear(struct device *gpio_dev) +void pi_lcd_clear(const struct device *gpio_dev) { _pi_lcd_command(gpio_dev, LCD_CLEAR_DISPLAY); k_sleep(K_MSEC(2)); /* wait for 2ms */ @@ -337,7 +338,7 @@ void pi_lcd_clear(struct device *gpio_dev) /** Display ON */ -void pi_lcd_display_on(struct device *gpio_dev) +void pi_lcd_display_on(const struct device *gpio_dev) { lcd_data.disp_cntl |= LCD_DISPLAY_ON; _pi_lcd_command(gpio_dev, @@ -345,7 +346,7 @@ void pi_lcd_display_on(struct device *gpio_dev) } /** Display OFF */ -void pi_lcd_display_off(struct device *gpio_dev) +void pi_lcd_display_off(const struct device *gpio_dev) { lcd_data.disp_cntl &= ~LCD_DISPLAY_ON; _pi_lcd_command(gpio_dev, @@ -354,7 +355,7 @@ void pi_lcd_display_off(struct device *gpio_dev) /** Turns cursor off */ -void pi_lcd_cursor_off(struct device *gpio_dev) +void pi_lcd_cursor_off(const struct device *gpio_dev) { lcd_data.disp_cntl &= ~LCD_CURSOR_ON; _pi_lcd_command(gpio_dev, @@ -362,7 +363,7 @@ void pi_lcd_cursor_off(struct device *gpio_dev) } /** Turn cursor on */ -void pi_lcd_cursor_on(struct device *gpio_dev) +void pi_lcd_cursor_on(const struct device *gpio_dev) { lcd_data.disp_cntl |= LCD_CURSOR_ON; _pi_lcd_command(gpio_dev, @@ -371,7 +372,7 @@ void pi_lcd_cursor_on(struct device *gpio_dev) /** Turn off the blinking cursor */ -void pi_lcd_blink_off(struct device *gpio_dev) +void pi_lcd_blink_off(const struct device *gpio_dev) { lcd_data.disp_cntl &= ~LCD_BLINK_ON; _pi_lcd_command(gpio_dev, @@ -379,7 +380,7 @@ void pi_lcd_blink_off(struct device *gpio_dev) } /** Turn on the blinking cursor */ -void pi_lcd_blink_on(struct device *gpio_dev) +void pi_lcd_blink_on(const struct device *gpio_dev) { lcd_data.disp_cntl |= LCD_BLINK_ON; _pi_lcd_command(gpio_dev, @@ -387,21 +388,21 @@ void pi_lcd_blink_on(struct device *gpio_dev) } /** Scroll the display left without changing the RAM */ -void pi_lcd_scroll_left(struct device *gpio_dev) +void pi_lcd_scroll_left(const struct device *gpio_dev) { _pi_lcd_command(gpio_dev, LCD_CURSOR_SHIFT | LCD_DISPLAY_MOVE | LCD_MOVE_LEFT); } /** Scroll the display right without changing the RAM */ -void pi_lcd_scroll_right(struct device *gpio_dev) +void pi_lcd_scroll_right(const struct device *gpio_dev) { _pi_lcd_command(gpio_dev, LCD_CURSOR_SHIFT | LCD_DISPLAY_MOVE | LCD_MOVE_RIGHT); } /** Text that flows from left to right */ -void pi_lcd_left_to_right(struct device *gpio_dev) +void pi_lcd_left_to_right(const struct device *gpio_dev) { lcd_data.disp_mode |= LCD_ENTRY_LEFT; _pi_lcd_command(gpio_dev, @@ -409,7 +410,7 @@ void pi_lcd_left_to_right(struct device *gpio_dev) } /** Text that flows from right to left */ -void pi_lcd_right_to_left(struct device *gpio_dev) +void pi_lcd_right_to_left(const struct device *gpio_dev) { lcd_data.disp_mode &= ~LCD_ENTRY_LEFT; _pi_lcd_command(gpio_dev, @@ -417,7 +418,7 @@ void pi_lcd_right_to_left(struct device *gpio_dev) } /** Right justify text from the cursor location */ -void pi_lcd_auto_scroll_right(struct device *gpio_dev) +void pi_lcd_auto_scroll_right(const struct device *gpio_dev) { lcd_data.disp_mode |= LCD_ENTRY_SHIFT_INCREMENT; _pi_lcd_command(gpio_dev, @@ -425,14 +426,14 @@ void pi_lcd_auto_scroll_right(struct device *gpio_dev) } /** Left justify text from the cursor location */ -void pi_lcd_auto_scroll_left(struct device *gpio_dev) +void pi_lcd_auto_scroll_left(const struct device *gpio_dev) { lcd_data.disp_mode &= ~LCD_ENTRY_SHIFT_INCREMENT; _pi_lcd_command(gpio_dev, LCD_ENTRY_MODE_SET | lcd_data.disp_cntl); } -void pi_lcd_string(struct device *gpio_dev, char *msg) +void pi_lcd_string(const struct device *gpio_dev, char *msg) { int i; int len = 0; @@ -451,7 +452,8 @@ void pi_lcd_string(struct device *gpio_dev, char *msg) /** LCD initialization function */ -void pi_lcd_init(struct device *gpio_dev, uint8_t cols, uint8_t rows, uint8_t dotsize) +void pi_lcd_init(const struct device *gpio_dev, uint8_t cols, uint8_t rows, + uint8_t dotsize) { if (rows > 1) { lcd_data.disp_func |= LCD_2_LINE; @@ -525,7 +527,7 @@ void pi_lcd_init(struct device *gpio_dev, uint8_t cols, uint8_t rows, uint8_t do void main(void) { - struct device *gpio_dev; + const struct device *gpio_dev; gpio_dev = device_get_binding(GPIO_DRV_NAME); if (!gpio_dev) { diff --git a/samples/drivers/led_apa102/src/main.c b/samples/drivers/led_apa102/src/main.c index 8d8f7115844961..0ec5687e6f8aa5 100644 --- a/samples/drivers/led_apa102/src/main.c +++ b/samples/drivers/led_apa102/src/main.c @@ -53,7 +53,7 @@ const struct led_rgb *color_at(size_t time, size_t i) #define DELAY_TIME K_MSEC(40) void main(void) { - struct device *strip; + const struct device *strip; size_t i, time; strip = device_get_binding(DT_LABEL(DT_INST(0, apa_apa102))); diff --git a/samples/drivers/led_apa102c_bitbang/src/main.c b/samples/drivers/led_apa102c_bitbang/src/main.c index 760cda1133bc64..33f79f4db2ff03 100644 --- a/samples/drivers/led_apa102c_bitbang/src/main.c +++ b/samples/drivers/led_apa102c_bitbang/src/main.c @@ -49,7 +49,7 @@ uint32_t rgb[] = { /* Number of LEDS linked together */ #define NUM_LEDS 1 -void send_rgb(struct device *gpio_dev, uint32_t rgb) +void send_rgb(const struct device *gpio_dev, uint32_t rgb) { int i; @@ -67,7 +67,7 @@ void send_rgb(struct device *gpio_dev, uint32_t rgb) void main(void) { - struct device *gpio_dev; + const struct device *gpio_dev; int ret; int idx = 0; int leds = 0; diff --git a/samples/drivers/led_lp3943/src/main.c b/samples/drivers/led_lp3943/src/main.c index 4cac526ff6f5b7..a8ffcc8fa04ba9 100644 --- a/samples/drivers/led_lp3943/src/main.c +++ b/samples/drivers/led_lp3943/src/main.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(app); void main(void) { - struct device *led_dev; + const struct device *led_dev; int i, ret; led_dev = device_get_binding(LED_DEV_NAME); diff --git a/samples/drivers/led_lp503x/src/main.c b/samples/drivers/led_lp503x/src/main.c index ea9fdc05470172..89ceea442cd569 100644 --- a/samples/drivers/led_lp503x/src/main.c +++ b/samples/drivers/led_lp503x/src/main.c @@ -45,7 +45,7 @@ static uint8_t colors[][3] = { * @param lp503x_dev LP503X LED controller device. * @param led Number of the LED to test. */ -static int run_led_test(struct device *lp503x_dev, uint8_t led) +static int run_led_test(const struct device *lp503x_dev, uint8_t led) { uint8_t idx; int err; @@ -111,7 +111,7 @@ static int run_led_test(struct device *lp503x_dev, uint8_t led) * * @param lp503x_dev LP503X LED controller device. */ -static int run_channel_test(struct device *lp503x_dev) +static int run_channel_test(const struct device *lp503x_dev) { uint8_t idx; uint8_t buffer[LP503X_COLORS_PER_LED * LP503X_MAX_LEDS]; @@ -213,7 +213,7 @@ static int run_channel_test(struct device *lp503x_dev) void main(void) { - struct device *lp503x_dev; + const struct device *lp503x_dev; int err; uint8_t led; uint8_t num_leds = 0; diff --git a/samples/drivers/led_lp5562/src/main.c b/samples/drivers/led_lp5562/src/main.c index c3789ac5059a25..8f00b51d168890 100644 --- a/samples/drivers/led_lp5562/src/main.c +++ b/samples/drivers/led_lp5562/src/main.c @@ -66,7 +66,8 @@ static inline uint8_t scale_color_to_percent(uint8_t hex) * * @return 0 if successful, -ERRNO otherwise. */ -static int set_static_color(struct device *dev, uint8_t r, uint8_t g, uint8_t b) +static int set_static_color(const struct device *dev, uint8_t r, uint8_t g, + uint8_t b) { int ret; @@ -110,8 +111,8 @@ static int set_static_color(struct device *dev, uint8_t r, uint8_t g, uint8_t b) * * @return 0 if successful, -ERRNO otherwise. */ -static int blink_color(struct device *dev, bool r, bool g, bool b, - uint32_t delay_on, uint32_t delay_off) +static int blink_color(const struct device *dev, bool r, bool g, bool b, + uint32_t delay_on, uint32_t delay_off) { int ret; @@ -149,7 +150,7 @@ static int blink_color(struct device *dev, bool r, bool g, bool b, * * @return 0 if successful, -ERRNO otherwise. */ -static int turn_off_all_leds(struct device *dev) +static int turn_off_all_leds(const struct device *dev) { for (int i = 0; i < NUM_LEDS; i++) { int ret = led_off(dev, i); @@ -164,7 +165,7 @@ static int turn_off_all_leds(struct device *dev) void main(void) { - struct device *dev; + const struct device *dev; int i, ret; dev = device_get_binding(LED_DEV_NAME); diff --git a/samples/drivers/led_lpd8806/src/main.c b/samples/drivers/led_lpd8806/src/main.c index 3d125334637bcc..a5068e6d884531 100644 --- a/samples/drivers/led_lpd8806/src/main.c +++ b/samples/drivers/led_lpd8806/src/main.c @@ -52,7 +52,7 @@ const struct led_rgb *color_at(size_t time, size_t i) void main(void) { - struct device *strip; + const struct device *strip; size_t i, time; strip = device_get_binding(STRIP_DEV_NAME); diff --git a/samples/drivers/led_pca9633/src/main.c b/samples/drivers/led_pca9633/src/main.c index c204e8880db1b0..a4db1b989f953d 100644 --- a/samples/drivers/led_pca9633/src/main.c +++ b/samples/drivers/led_pca9633/src/main.c @@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(main); void main(void) { - struct device *led_dev; + const struct device *led_dev; int i, ret; led_dev = device_get_binding(LED_DEV_NAME); diff --git a/samples/drivers/led_ws2812/src/main.c b/samples/drivers/led_ws2812/src/main.c index 2ee641274b5feb..d23eba636b084f 100644 --- a/samples/drivers/led_ws2812/src/main.c +++ b/samples/drivers/led_ws2812/src/main.c @@ -35,7 +35,7 @@ struct led_rgb pixels[STRIP_NUM_PIXELS]; void main(void) { - struct device *strip; + const struct device *strip; size_t cursor = 0, color = 0; int rc; diff --git a/samples/drivers/lora/receive/src/main.c b/samples/drivers/lora/receive/src/main.c index 91e8e64380c3bd..063e70feb9ff18 100644 --- a/samples/drivers/lora/receive/src/main.c +++ b/samples/drivers/lora/receive/src/main.c @@ -23,7 +23,7 @@ LOG_MODULE_REGISTER(lora_receive); void main(void) { - struct device *lora_dev; + const struct device *lora_dev; struct lora_modem_config config; int ret, len; uint8_t data[MAX_DATA_LEN] = {0}; diff --git a/samples/drivers/lora/send/src/main.c b/samples/drivers/lora/send/src/main.c index 71f166f72b4425..8dce27902021d5 100644 --- a/samples/drivers/lora/send/src/main.c +++ b/samples/drivers/lora/send/src/main.c @@ -25,7 +25,7 @@ char data[MAX_DATA_LEN] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'}; void main(void) { - struct device *lora_dev; + const struct device *lora_dev; struct lora_modem_config config; int ret; diff --git a/samples/drivers/peci/src/main.c b/samples/drivers/peci/src/main.c index a386d9c5f7f035..eacfff6ef4fb05 100644 --- a/samples/drivers/peci/src/main.c +++ b/samples/drivers/peci/src/main.c @@ -23,7 +23,7 @@ #define PECI_SAFE_TEMP 72 -static struct device *peci_dev; +static const struct device *peci_dev; static bool peci_initialized; static uint8_t tjmax; static uint8_t rx_fcs; diff --git a/samples/drivers/ps2/src/main.c b/samples/drivers/ps2/src/main.c index beb37e4dd0b7e3..e15944e5ae6e15 100644 --- a/samples/drivers/ps2/src/main.c +++ b/samples/drivers/ps2/src/main.c @@ -33,7 +33,7 @@ K_MSGQ_DEFINE(aux_to_host_queue, sizeof(uint8_t), 8, 4); /* We use a timer to saturate the queue */ K_TIMER_DEFINE(block_ps2_timer, saturate_ps2, NULL); -static struct device *ps2_0_dev; +static const struct device *ps2_0_dev; static void saturate_ps2(struct k_timer *timer) { @@ -45,7 +45,7 @@ static void saturate_ps2(struct k_timer *timer) ps2_enable_callback(ps2_0_dev); } -static void mb_callback(struct device *dev, uint8_t value) +static void mb_callback(const struct device *dev, uint8_t value) { if (k_msgq_put(&aux_to_host_queue, &value, K_NO_WAIT) != 0) { ps2_disable_callback(ps2_0_dev); diff --git a/samples/drivers/soc_flash_nrf/src/main.c b/samples/drivers/soc_flash_nrf/src/main.c index bd3d842b61d447..01e6d870656c18 100644 --- a/samples/drivers/soc_flash_nrf/src/main.c +++ b/samples/drivers/soc_flash_nrf/src/main.c @@ -29,7 +29,7 @@ void main(void) { - struct device *flash_dev; + const struct device *flash_dev; uint32_t buf_array_1[4] = { TEST_DATA_WORD_0, TEST_DATA_WORD_1, TEST_DATA_WORD_2, TEST_DATA_WORD_3 }; uint32_t buf_array_2[4] = { TEST_DATA_WORD_3, TEST_DATA_WORD_1, diff --git a/samples/drivers/spi_flash/src/main.c b/samples/drivers/spi_flash/src/main.c index 6da2b98ba279c6..4306dfd690374a 100644 --- a/samples/drivers/spi_flash/src/main.c +++ b/samples/drivers/spi_flash/src/main.c @@ -39,7 +39,7 @@ void main(void) const uint8_t expected[] = { 0x55, 0xaa, 0x66, 0x99 }; const size_t len = sizeof(expected); uint8_t buf[sizeof(expected)]; - struct device *flash_dev; + const struct device *flash_dev; int rc; printf("\n" FLASH_NAME " SPI flash testing\n"); diff --git a/samples/drivers/spi_flash_at45/src/main.c b/samples/drivers/spi_flash_at45/src/main.c index 276dc35faef305..e3b06c98b263f1 100644 --- a/samples/drivers/spi_flash_at45/src/main.c +++ b/samples/drivers/spi_flash_at45/src/main.c @@ -28,7 +28,7 @@ void main(void) { printk("DataFlash sample on %s\n", CONFIG_BOARD); - struct device *flash_dev; + const struct device *flash_dev; int i; int err; uint8_t data; diff --git a/samples/drivers/spi_fujitsu_fram/src/main.c b/samples/drivers/spi_fujitsu_fram/src/main.c index f1dc54459895aa..283a8e1efa0636 100644 --- a/samples/drivers/spi_fujitsu_fram/src/main.c +++ b/samples/drivers/spi_fujitsu_fram/src/main.c @@ -22,7 +22,8 @@ static uint8_t data[MAX_USER_DATA_LENGTH], cmp_data[MAX_USER_DATA_LENGTH]; -static int mb85rs64v_access(struct device *spi, struct spi_config *spi_cfg, +static int mb85rs64v_access(const struct device *spi, + struct spi_config *spi_cfg, uint8_t cmd, uint16_t addr, void *data, size_t len) { uint8_t access[3]; @@ -64,7 +65,8 @@ static int mb85rs64v_access(struct device *spi, struct spi_config *spi_cfg, } -static int mb85rs64v_read_id(struct device *spi, struct spi_config *spi_cfg) +static int mb85rs64v_read_id(const struct device *spi, + struct spi_config *spi_cfg) { uint8_t id[4]; int err; @@ -95,7 +97,7 @@ static int mb85rs64v_read_id(struct device *spi, struct spi_config *spi_cfg) return 0; } -static int write_bytes(struct device *spi, struct spi_config *spi_cfg, +static int write_bytes(const struct device *spi, struct spi_config *spi_cfg, uint16_t addr, uint8_t *data, uint32_t num_bytes) { int err; @@ -119,7 +121,7 @@ static int write_bytes(struct device *spi, struct spi_config *spi_cfg, return 0; } -static int read_bytes(struct device *spi, struct spi_config *spi_cfg, +static int read_bytes(const struct device *spi, struct spi_config *spi_cfg, uint16_t addr, uint8_t *data, uint32_t num_bytes) { int err; @@ -137,7 +139,7 @@ static int read_bytes(struct device *spi, struct spi_config *spi_cfg, void main(void) { - struct device *spi; + const struct device *spi; struct spi_config spi_cfg = {0}; int err; diff --git a/samples/drivers/watchdog/src/main.c b/samples/drivers/watchdog/src/main.c index 3153391705ce69..ea387386715d5d 100644 --- a/samples/drivers/watchdog/src/main.c +++ b/samples/drivers/watchdog/src/main.c @@ -47,7 +47,7 @@ #error "Unsupported SoC and no watchdog0 alias in zephyr.dts" #endif -static void wdt_callback(struct device *wdt_dev, int channel_id) +static void wdt_callback(const struct device *wdt_dev, int channel_id) { static bool handled_event; @@ -65,7 +65,7 @@ void main(void) { int err; int wdt_channel_id; - struct device *wdt; + const struct device *wdt; struct wdt_timeout_cfg wdt_config; printk("Watchdog sample application\n"); diff --git a/samples/mpu/mpu_test/src/main.c b/samples/mpu/mpu_test/src/main.c index f919523242cde0..cab7dc799ea8da 100644 --- a/samples/mpu/mpu_test/src/main.c +++ b/samples/mpu/mpu_test/src/main.c @@ -46,7 +46,7 @@ static int cmd_write_mcux(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argc); ARG_UNUSED(argv); - struct device *flash_dev; + const struct device *flash_dev; uint32_t value[2]; uint32_t offset; @@ -79,7 +79,7 @@ static int cmd_write_stm32(const struct shell *shell, size_t argc, char *argv[]) ARG_UNUSED(argc); ARG_UNUSED(argv); - struct device *flash_dev; + const struct device *flash_dev; flash_dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL); diff --git a/samples/net/gsm_modem/src/main.c b/samples/net/gsm_modem/src/main.c index 3777e43a09dd10..750bf3811b9223 100644 --- a/samples/net/gsm_modem/src/main.c +++ b/samples/net/gsm_modem/src/main.c @@ -37,7 +37,7 @@ static void event_handler(struct net_mgmt_event_callback *cb, int main(void) { - struct device *uart_dev = device_get_binding(CONFIG_MODEM_GSM_UART_NAME); + const struct device *uart_dev = device_get_binding(CONFIG_MODEM_GSM_UART_NAME); LOG_INF("%s: booted board '%s' APN '%s' UART '%s' device %p", __func__, CONFIG_BOARD, CONFIG_MODEM_GSM_APN, diff --git a/samples/net/lwm2m_client/src/lwm2m-client.c b/samples/net/lwm2m_client/src/lwm2m-client.c index 8ca3e838730352..1fd5ab539a9bdf 100644 --- a/samples/net/lwm2m_client/src/lwm2m-client.c +++ b/samples/net/lwm2m_client/src/lwm2m-client.c @@ -73,7 +73,7 @@ static uint8_t bat_status = LWM2M_DEVICE_BATTERY_STATUS_CHARGING; static int mem_free = 15; static int mem_total = 25; -static struct device *led_dev; +static const struct device *led_dev; static uint32_t led_state; static struct lwm2m_ctx client; @@ -188,7 +188,7 @@ static void *temperature_get_buf(uint16_t obj_inst_id, uint16_t res_id, { /* Last read temperature value, will use 25.5C if no sensor available */ static struct float32_value v = { 25, 500000 }; - struct device *dev = NULL; + const struct device *dev = NULL; #if defined(CONFIG_FXOS8700_TEMP) dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxos8700))); diff --git a/samples/net/openthread/ncp/src/main.c b/samples/net/openthread/ncp/src/main.c index da2ab28bf4995e..3dd161bba288f4 100644 --- a/samples/net/openthread/ncp/src/main.c +++ b/samples/net/openthread/ncp/src/main.c @@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(ot_br, LOG_LEVEL_DBG); void main(void) { #if defined(CONFIG_OPENTHREAD_NCP_SPINEL_ON_UART_ACM) - struct device *dev; + const struct device *dev; uint32_t baudrate = 0U; int ret; diff --git a/samples/net/wpan_serial/src/main.c b/samples/net/wpan_serial/src/main.c index ae0909766257a1..1bc96d5d75fb7d 100644 --- a/samples/net/wpan_serial/src/main.c +++ b/samples/net/wpan_serial/src/main.c @@ -50,11 +50,11 @@ static uint8_t slip_buf[1 + 2 * CONFIG_NET_BUF_DATA_SIZE]; /* ieee802.15.4 device */ static struct ieee802154_radio_api *radio_api; -static struct device *ieee802154_dev; +static const struct device *ieee802154_dev; uint8_t mac_addr[8]; /* UART device */ -static struct device *uart_dev; +static const struct device *uart_dev; /* SLIP state machine */ static uint8_t slip_state = STATE_OK; @@ -127,7 +127,7 @@ static int slip_process_byte(unsigned char c) return 0; } -static void interrupt_handler(struct device *dev, void *user_data) +static void interrupt_handler(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); @@ -430,7 +430,7 @@ static void init_tx_queue(void) /** * FIXME choose correct OUI, or add support in L2 */ -static uint8_t *get_mac(struct device *dev) +static uint8_t *get_mac(const struct device *dev) { uint32_t *ptr = (uint32_t *)mac_addr; @@ -516,7 +516,7 @@ int net_recv_data(struct net_if *iface, struct net_pkt *pkt) void main(void) { - struct device *dev; + const struct device *dev; uint32_t baudrate, dtr = 0U; int ret; diff --git a/samples/net/wpanusb/src/wpanusb.c b/samples/net/wpanusb/src/wpanusb.c index de95f03f86e875..ba1fa92423b8a8 100644 --- a/samples/net/wpanusb/src/wpanusb.c +++ b/samples/net/wpanusb/src/wpanusb.c @@ -28,7 +28,7 @@ LOG_MODULE_REGISTER(wpanusb); #define WPANUSB_IN_EP_IDX 0 static struct ieee802154_radio_api *radio_api; -static struct device *ieee802154_dev; +static const struct device *ieee802154_dev; static struct k_fifo tx_queue; diff --git a/samples/sensor/adt7420/src/main.c b/samples/sensor/adt7420/src/main.c index c28211df9420eb..dbe625867a3c0d 100644 --- a/samples/sensor/adt7420/src/main.c +++ b/samples/sensor/adt7420/src/main.c @@ -39,7 +39,8 @@ static const char *now_str(void) h, min, s, ms); return buf; } -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { k_sem_give(&sem); } @@ -47,7 +48,8 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) static int low_ucel; static int high_ucel; -static int sensor_set_attribute(struct device *dev, enum sensor_channel chan, +static int sensor_set_attribute(const struct device *dev, + enum sensor_channel chan, enum sensor_attribute attr, int value) { struct sensor_value sensor_val; @@ -71,7 +73,7 @@ static bool temp_in_window(const struct sensor_value *val) return (temp_ucel >= low_ucel) && (temp_ucel <= high_ucel); } -static int sensor_set_window(struct device *dev, +static int sensor_set_window(const struct device *dev, const struct sensor_value *val) { int temp_ucel = val->val1 * UCEL_PER_CEL + val->val2; @@ -96,7 +98,7 @@ static int sensor_set_window(struct device *dev, return rc; } -static void process(struct device *dev) +static void process(const struct device *dev) { struct sensor_value temp_val; int ret; @@ -169,7 +171,7 @@ static void process(struct device *dev) void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adt7420))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adt7420))); if (dev == NULL) { printf("Failed to get device binding\n"); diff --git a/samples/sensor/adxl362/src/main.c b/samples/sensor/adxl362/src/main.c index 929bb72f2967f5..2c554696a64bc3 100644 --- a/samples/sensor/adxl362/src/main.c +++ b/samples/sensor/adxl362/src/main.c @@ -11,7 +11,8 @@ K_SEM_DEFINE(sem, 0, 1); -static void trigger_handler(struct device *dev, struct sensor_trigger *trig) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { switch (trig->type) { case SENSOR_TRIG_DATA_READY: @@ -33,7 +34,7 @@ void main(void) { struct sensor_value accel[3]; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl362))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl362))); if (dev == NULL) { printf("Device get binding device\n"); return; diff --git a/samples/sensor/adxl372/src/main.c b/samples/sensor/adxl372/src/main.c index ec105afd3a8c49..d76cd656a74596 100644 --- a/samples/sensor/adxl372/src/main.c +++ b/samples/sensor/adxl372/src/main.c @@ -28,7 +28,8 @@ static double sqrt(double value) K_SEM_DEFINE(sem, 0, 1); -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { ARG_UNUSED(trigger); @@ -47,7 +48,7 @@ void main(void) int i; char meter[200]; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl372))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl372))); if (dev == NULL) { printf("Could not get %s device\n", DT_LABEL(DT_INST(0, adi_adxl372))); diff --git a/samples/sensor/amg88xx/src/main.c b/samples/sensor/amg88xx/src/main.c index 3bd2860b96b74e..d1cd96663b6435 100644 --- a/samples/sensor/amg88xx/src/main.c +++ b/samples/sensor/amg88xx/src/main.c @@ -14,7 +14,8 @@ static struct sensor_value temp_value[64]; #ifdef CONFIG_AMG88XX_TRIGGER K_SEM_DEFINE(sem, 0, 1); -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { ARG_UNUSED(dev); ARG_UNUSED(trigger); @@ -50,7 +51,7 @@ void print_buffer(void *ptr, size_t l) void main(void) { int ret; - struct device *dev = device_get_binding( + const struct device *dev = device_get_binding( DT_LABEL(DT_INST(0, panasonic_amg88xx))); if (dev == NULL) { diff --git a/samples/sensor/ams_iAQcore/src/main.c b/samples/sensor/ams_iAQcore/src/main.c index 4040de85abf477..55f33ec14ab91b 100644 --- a/samples/sensor/ams_iAQcore/src/main.c +++ b/samples/sensor/ams_iAQcore/src/main.c @@ -11,7 +11,7 @@ void main(void) { - struct device *dev; + const struct device *dev; struct sensor_value co2, voc; dev = device_get_binding(DT_LABEL(DT_INST(0, ams_iaqcore))); diff --git a/samples/sensor/apds9960/src/main.c b/samples/sensor/apds9960/src/main.c index bb1ad6b8bdf719..55af544650b887 100644 --- a/samples/sensor/apds9960/src/main.c +++ b/samples/sensor/apds9960/src/main.c @@ -14,7 +14,8 @@ #ifdef CONFIG_APDS9960_TRIGGER K_SEM_DEFINE(sem, 0, 1); -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { ARG_UNUSED(dev); ARG_UNUSED(trigger); @@ -25,7 +26,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) void main(void) { - struct device *dev; + const struct device *dev; struct sensor_value intensity, pdata; printk("APDS9960 sample application\n"); diff --git a/samples/sensor/bme280/src/main.c b/samples/sensor/bme280/src/main.c index dadf847aa90a66..ef2c8aad23d6bb 100644 --- a/samples/sensor/bme280/src/main.c +++ b/samples/sensor/bme280/src/main.c @@ -20,7 +20,7 @@ void main(void) { - struct device *dev = device_get_binding(BME280_LABEL); + const struct device *dev = device_get_binding(BME280_LABEL); if (dev == NULL) { printk("No device \"%s\" found; did initialization fail?\n", diff --git a/samples/sensor/bme680/src/main.c b/samples/sensor/bme680/src/main.c index c1b660272838f5..ecfc29319f0cc3 100644 --- a/samples/sensor/bme680/src/main.c +++ b/samples/sensor/bme680/src/main.c @@ -11,7 +11,7 @@ void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, bosch_bme680))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, bosch_bme680))); struct sensor_value temp, press, humidity, gas_res; printf("Device %p name is %s\n", dev, dev->name); diff --git a/samples/sensor/bmg160/src/main.c b/samples/sensor/bmg160/src/main.c index cd186f270cdbcb..8d1044fa1f0fc6 100644 --- a/samples/sensor/bmg160/src/main.c +++ b/samples/sensor/bmg160/src/main.c @@ -17,7 +17,7 @@ #define MAX_TEST_TIME 15000 #define SLEEPTIME 300 -static void print_gyro_data(struct device *bmg160) +static void print_gyro_data(const struct device *bmg160) { struct sensor_value val[3]; @@ -32,7 +32,7 @@ static void print_gyro_data(struct device *bmg160) val[2].val1 + val[2].val2 / 1000000.0); } -static void print_temp_data(struct device *bmg160) +static void print_temp_data(const struct device *bmg160) { struct sensor_value val; @@ -45,7 +45,7 @@ static void print_temp_data(struct device *bmg160) val.val1 + val.val2 / 1000000.0); } -static void test_polling_mode(struct device *bmg160) +static void test_polling_mode(const struct device *bmg160) { int32_t remaining_test_time = MAX_TEST_TIME; @@ -65,7 +65,8 @@ static void test_polling_mode(struct device *bmg160) } while (remaining_test_time > 0); } -static void trigger_handler(struct device *bmg160, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *bmg160, + struct sensor_trigger *trigger) { if (trigger->type != SENSOR_TRIG_DATA_READY && trigger->type != SENSOR_TRIG_DELTA) { @@ -80,7 +81,7 @@ static void trigger_handler(struct device *bmg160, struct sensor_trigger *trigge print_gyro_data(bmg160); } -static void test_trigger_mode(struct device *bmg160) +static void test_trigger_mode(const struct device *bmg160) { int32_t remaining_test_time = MAX_TEST_TIME; struct sensor_trigger trig; @@ -167,7 +168,7 @@ static void test_trigger_mode(struct device *bmg160) void main(void) { - struct device *bmg160; + const struct device *bmg160; #if defined(CONFIG_BMG160_RANGE_RUNTIME) struct sensor_value attr; #endif diff --git a/samples/sensor/bmm150/src/main.c b/samples/sensor/bmm150/src/main.c index 409b623ed0d626..f31628f6be3ace 100644 --- a/samples/sensor/bmm150/src/main.c +++ b/samples/sensor/bmm150/src/main.c @@ -10,7 +10,7 @@ #include #include -void do_main(struct device *dev) +void do_main(const struct device *dev) { int ret; struct sensor_value x, y, z; @@ -35,10 +35,10 @@ void do_main(struct device *dev) } } -struct device *sensor_search() +const struct device *sensor_search() { static const char *const magn_sensor[] = { "bmm150", NULL }; - struct device *dev; + const struct device *dev; int i; i = 0; @@ -56,7 +56,7 @@ struct device *sensor_search() void main(void) { - struct device *dev; + const struct device *dev; printk("BMM150 Geomagnetic sensor Application\n"); diff --git a/samples/sensor/bq274xx/src/main.c b/samples/sensor/bq274xx/src/main.c index a088979592896b..5b620120e32dc3 100644 --- a/samples/sensor/bq274xx/src/main.c +++ b/samples/sensor/bq274xx/src/main.c @@ -24,7 +24,7 @@ static void bq274xx_show_values(const char *type, struct sensor_value value) } } -static void do_main(struct device *dev) +static void do_main(const struct device *dev) { struct sensor_value voltage, current, state_of_charge, full_charge_capacity, remaining_charge_capacity, avg_power, @@ -130,7 +130,7 @@ static void do_main(struct device *dev) void main(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding(DT_LABEL(DT_INST(0, ti_bq274xx))); if (!dev) { diff --git a/samples/sensor/ccs811/src/main.c b/samples/sensor/ccs811/src/main.c index a9f7f840ff3200..d86122c570b494 100644 --- a/samples/sensor/ccs811/src/main.c +++ b/samples/sensor/ccs811/src/main.c @@ -35,7 +35,7 @@ static const char *now_str(void) return buf; } -static int do_fetch(struct device *dev) +static int do_fetch(const struct device *dev) { struct sensor_value co2, tvoc, voltage, current; int rc = 0; @@ -78,7 +78,8 @@ static int do_fetch(struct device *dev) #ifndef CONFIG_CCS811_TRIGGER_NONE -static void trigger_handler(struct device *dev, struct sensor_trigger *trig) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { int rc = do_fetch(dev); @@ -93,7 +94,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trig) #endif /* !CONFIG_CCS811_TRIGGER_NONE */ -static void do_main(struct device *dev) +static void do_main(const struct device *dev) { while (true) { int rc = do_fetch(dev); @@ -112,7 +113,7 @@ static void do_main(struct device *dev) void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ccs811))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ccs811))); struct ccs811_configver_type cfgver; int rc; diff --git a/samples/sensor/dht/src/main.c b/samples/sensor/dht/src/main.c index d6ece0f2883d34..922a2a2c2ca170 100644 --- a/samples/sensor/dht/src/main.c +++ b/samples/sensor/dht/src/main.c @@ -33,7 +33,7 @@ static const char *now_str(void) void main(void) { const char *const label = DT_LABEL(DT_INST(0, aosong_dht)); - struct device *dht22 = device_get_binding(label); + const struct device *dht22 = device_get_binding(label); if (!dht22) { printf("Failed to find sensor %s\n", label); diff --git a/samples/sensor/dps310/src/main.c b/samples/sensor/dps310/src/main.c index f5af859de04275..e594176f69018e 100644 --- a/samples/sensor/dps310/src/main.c +++ b/samples/sensor/dps310/src/main.c @@ -12,7 +12,7 @@ void main(void) { printk("Hello DPS310\n"); - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, infineon_dps310))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, infineon_dps310))); if (dev == NULL) { printk("Could not get DPS310 device\n"); diff --git a/samples/sensor/ens210/src/main.c b/samples/sensor/ens210/src/main.c index 3d1b61121a2c2a..884846fb841f23 100644 --- a/samples/sensor/ens210/src/main.c +++ b/samples/sensor/ens210/src/main.c @@ -11,7 +11,7 @@ void main(void) { - struct device *dev; + const struct device *dev; struct sensor_value temperature, humidity; dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ens210))); diff --git a/samples/sensor/fxas21002/src/main.c b/samples/sensor/fxas21002/src/main.c index 6fa0875d074297..10a42b65a9811c 100644 --- a/samples/sensor/fxas21002/src/main.c +++ b/samples/sensor/fxas21002/src/main.c @@ -10,7 +10,8 @@ K_SEM_DEFINE(sem, 0, 1); /* starts off "not available" */ -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { k_sem_give(&sem); } @@ -18,7 +19,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) void main(void) { struct sensor_value gyro[3]; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxas21002))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxas21002))); if (dev == NULL) { printf("Could not get fxas21002 device\n"); diff --git a/samples/sensor/fxos8700-hid/src/main.c b/samples/sensor/fxos8700-hid/src/main.c index 4413740167f4eb..ad2fe895ad0488 100644 --- a/samples/sensor/fxos8700-hid/src/main.c +++ b/samples/sensor/fxos8700-hid/src/main.c @@ -58,7 +58,7 @@ static struct gpio_callback callback[4]; #define MOUSE_BTN_MIDDLE BIT(2) -static void left_button(struct device *gpio, struct gpio_callback *cb, +static void left_button(const struct device *gpio, struct gpio_callback *cb, uint32_t pins) { uint32_t cur_val; @@ -78,7 +78,7 @@ static void left_button(struct device *gpio, struct gpio_callback *cb, } #ifdef PORT1 -static void right_button(struct device *gpio, struct gpio_callback *cb, +static void right_button(const struct device *gpio, struct gpio_callback *cb, uint32_t pins) { uint32_t cur_val; @@ -98,9 +98,10 @@ static void right_button(struct device *gpio, struct gpio_callback *cb, } #endif -int callbacks_configure(struct device *gpio, uint32_t pin, int flags, - void (*handler)(struct device*, struct gpio_callback*, - uint32_t), struct gpio_callback *callback, uint32_t *val) +int callbacks_configure(const struct device *gpio, uint32_t pin, int flags, + void (*handler)(const struct device *, struct gpio_callback*, + uint32_t), + struct gpio_callback *callback, uint32_t *val) { int ret; @@ -125,7 +126,7 @@ int callbacks_configure(struct device *gpio, uint32_t pin, int flags, return 0; } -static bool read_accel(struct device *dev) +static bool read_accel(const struct device *dev) { struct sensor_value val[3]; int ret; @@ -158,7 +159,8 @@ static bool read_accel(struct device *dev) } } -static void trigger_handler(struct device *dev, struct sensor_trigger *tr) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *tr) { ARG_UNUSED(tr); @@ -179,7 +181,7 @@ void main(void) { int ret; uint8_t report[4] = { 0x00 }; - struct device *led_dev, *accel_dev, *hid_dev; + const struct device *led_dev, *accel_dev, *hid_dev; led_dev = device_get_binding(LED_PORT); if (led_dev == NULL) { diff --git a/samples/sensor/fxos8700/src/main.c b/samples/sensor/fxos8700/src/main.c index df1c6b956db27a..06c233d83300b5 100644 --- a/samples/sensor/fxos8700/src/main.c +++ b/samples/sensor/fxos8700/src/main.c @@ -12,7 +12,8 @@ K_SEM_DEFINE(sem, 0, 1); /* starts off "not available" */ #if !defined(CONFIG_FXOS8700_TRIGGER_NONE) -static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trigger) { ARG_UNUSED(trigger); @@ -31,7 +32,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trigger) void main(void) { struct sensor_value accel[3]; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxos8700))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxos8700))); if (dev == NULL) { printf("Could not get fxos8700 device\n"); diff --git a/samples/sensor/grove_light/src/main.c b/samples/sensor/grove_light/src/main.c index 8968862cdd50d3..8ca8dc6ff6d301 100644 --- a/samples/sensor/grove_light/src/main.c +++ b/samples/sensor/grove_light/src/main.c @@ -13,7 +13,7 @@ void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_light))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_light))); if (dev == NULL) { printf("device not found. aborting test.\n"); diff --git a/samples/sensor/grove_temperature/src/main.c b/samples/sensor/grove_temperature/src/main.c index 8e855264c353dc..a7f53983619451 100644 --- a/samples/sensor/grove_temperature/src/main.c +++ b/samples/sensor/grove_temperature/src/main.c @@ -19,7 +19,7 @@ void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_temperature))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_temperature))); struct sensor_value temp; int read; @@ -28,7 +28,7 @@ void main(void) return; } #ifdef CONFIG_GROVE_LCD_RGB - struct device *glcd; + const struct device *glcd; glcd = device_get_binding(GROVE_LCD_NAME); if (glcd == NULL) { diff --git a/samples/sensor/hmc5883l/src/main.c b/samples/sensor/hmc5883l/src/main.c index 8a36dcc17e09df..d9b36ba023fe29 100644 --- a/samples/sensor/hmc5883l/src/main.c +++ b/samples/sensor/hmc5883l/src/main.c @@ -11,7 +11,7 @@ #include -static int32_t read_sensor(struct device *sensor) +static int32_t read_sensor(const struct device *sensor) { struct sensor_value val[3]; int32_t ret = 0; @@ -38,7 +38,7 @@ static int32_t read_sensor(struct device *sensor) void main(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding(DT_LABEL(DT_INST(0, honeywell_hmc5883l))); diff --git a/samples/sensor/hts221/src/main.c b/samples/sensor/hts221/src/main.c index fb6360beef73ce..b6f625f906eaf1 100644 --- a/samples/sensor/hts221/src/main.c +++ b/samples/sensor/hts221/src/main.c @@ -10,7 +10,7 @@ #include #include -static void process_sample(struct device *dev) +static void process_sample(const struct device *dev) { static unsigned int obs; struct sensor_value temp, hum; @@ -40,7 +40,7 @@ static void process_sample(struct device *dev) sensor_value_to_double(&hum)); } -static void hts221_handler(struct device *dev, +static void hts221_handler(const struct device *dev, struct sensor_trigger *trig) { process_sample(dev); @@ -48,7 +48,7 @@ static void hts221_handler(struct device *dev, void main(void) { - struct device *dev = device_get_binding("HTS221"); + const struct device *dev = device_get_binding("HTS221"); if (dev == NULL) { printf("Could not get HTS221 device\n"); diff --git a/samples/sensor/isl29035/src/main.c b/samples/sensor/isl29035/src/main.c index ee0ff7b0e4842a..cb1877feafa6c2 100644 --- a/samples/sensor/isl29035/src/main.c +++ b/samples/sensor/isl29035/src/main.c @@ -15,7 +15,7 @@ static volatile bool alerted; struct k_sem sem; -static void trigger_handler(struct device *dev, +static void trigger_handler(const struct device *dev, struct sensor_trigger *trig) { #ifdef CONFIG_ISL29035_TRIGGER @@ -45,7 +45,7 @@ static const char *now_str(void) return buf; } -static void process_sample(struct device *dev) +static void process_sample(const struct device *dev) { static bool last_alerted; struct sensor_value val; @@ -102,7 +102,7 @@ static void process_sample(struct device *dev) void main(void) { - struct device *dev = device_get_binding("ISL29035"); + const struct device *dev = device_get_binding("ISL29035"); if (dev == NULL) { printf("Could not get ISL29035 device\n"); diff --git a/samples/sensor/lis2dh/src/main.c b/samples/sensor/lis2dh/src/main.c index eea3caf3dbee82..4276d85e8b3c29 100644 --- a/samples/sensor/lis2dh/src/main.c +++ b/samples/sensor/lis2dh/src/main.c @@ -9,7 +9,7 @@ #include #include -static void fetch_and_display(struct device *sensor) +static void fetch_and_display(const struct device *sensor) { static unsigned int count; struct sensor_value accel[3]; @@ -41,7 +41,7 @@ static void fetch_and_display(struct device *sensor) } #ifdef CONFIG_LIS2DH_TRIGGER -static void trigger_handler(struct device *dev, +static void trigger_handler(const struct device *dev, struct sensor_trigger *trig) { fetch_and_display(dev); @@ -50,7 +50,7 @@ static void trigger_handler(struct device *dev, void main(void) { - struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh))); + const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh))); if (sensor == NULL) { printf("Could not get %s device\n", diff --git a/samples/sensor/lps22hb/src/main.c b/samples/sensor/lps22hb/src/main.c index 9e7ba4e9663105..d76f375d7daaf5 100644 --- a/samples/sensor/lps22hb/src/main.c +++ b/samples/sensor/lps22hb/src/main.c @@ -10,7 +10,7 @@ #include #include -static void process_sample(struct device *dev) +static void process_sample(const struct device *dev) { static unsigned int obs; struct sensor_value pressure, temp; @@ -43,7 +43,7 @@ static void process_sample(struct device *dev) void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); if (dev == NULL) { printf("Could not get LPS22HB device\n"); diff --git a/samples/sensor/lps22hh/src/main.c b/samples/sensor/lps22hh/src/main.c index 08dcf37df02afc..5c29b287798a97 100644 --- a/samples/sensor/lps22hh/src/main.c +++ b/samples/sensor/lps22hh/src/main.c @@ -11,7 +11,7 @@ #include #include -static void process_sample(struct device *dev) +static void process_sample(const struct device *dev) { static unsigned int obs; struct sensor_value pressure, temp; @@ -42,15 +42,15 @@ static void process_sample(struct device *dev) } -static void lps22hh_handler(struct device *dev, - struct sensor_trigger *trig) +static void lps22hh_handler(const struct device *dev, + struct sensor_trigger *trig) { process_sample(dev); } void main(void) { - struct device *dev = device_get_binding("LPS22HH"); + const struct device *dev = device_get_binding("LPS22HH"); if (dev == NULL) { printf("Could not get LPS22HH device\n"); diff --git a/samples/sensor/lsm303dlhc/src/main.c b/samples/sensor/lsm303dlhc/src/main.c index 3718c386483c04..6733080fb18cf4 100644 --- a/samples/sensor/lsm303dlhc/src/main.c +++ b/samples/sensor/lsm303dlhc/src/main.c @@ -10,7 +10,8 @@ #include #include -static int32_t read_sensor(struct device *sensor, enum sensor_channel channel) +static int32_t read_sensor(const struct device *sensor, + enum sensor_channel channel) { struct sensor_value val[3]; int32_t ret = 0; @@ -37,9 +38,9 @@ static int32_t read_sensor(struct device *sensor, enum sensor_channel channel) void main(void) { - struct device *accelerometer = device_get_binding( + const struct device *accelerometer = device_get_binding( DT_LABEL(DT_INST(0, st_lis2dh))); - struct device *magnetometer = device_get_binding( + const struct device *magnetometer = device_get_binding( DT_LABEL(DT_INST(0, st_lsm303dlhc_magn))); if (accelerometer == NULL) { diff --git a/samples/sensor/lsm6dsl/src/main.c b/samples/sensor/lsm6dsl/src/main.c index f281935e99de7f..86fff70c92027c 100644 --- a/samples/sensor/lsm6dsl/src/main.c +++ b/samples/sensor/lsm6dsl/src/main.c @@ -28,7 +28,7 @@ static struct sensor_value press_out, temp_out; #endif #ifdef CONFIG_LSM6DSL_TRIGGER -static void lsm6dsl_trigger_handler(struct device *dev, +static void lsm6dsl_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { static struct sensor_value accel_x, accel_y, accel_z; @@ -100,7 +100,7 @@ void main(void) int cnt = 0; char out_str[64]; struct sensor_value odr_attr; - struct device *lsm6dsl_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); + const struct device *lsm6dsl_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); if (lsm6dsl_dev == NULL) { printk("Could not get LSM6DSL device\n"); diff --git a/samples/sensor/magn_polling/src/main.c b/samples/sensor/magn_polling/src/main.c index 31c4e2d8e3fb8b..83296981c4050c 100644 --- a/samples/sensor/magn_polling/src/main.c +++ b/samples/sensor/magn_polling/src/main.c @@ -10,7 +10,7 @@ #include #include -static void do_main(struct device *dev) +static void do_main(const struct device *dev) { int ret; struct sensor_value value_x, value_y, value_z; @@ -34,10 +34,10 @@ static void do_main(struct device *dev) } } -struct device *sensor_search_for_magnetometer() +const struct device *sensor_search_for_magnetometer() { static char *magn_sensors[] = {"bmc150_magn", NULL}; - struct device *dev; + const struct device *dev; int i; i = 0; @@ -54,7 +54,7 @@ struct device *sensor_search_for_magnetometer() void main(void) { - struct device *dev; + const struct device *dev; dev = sensor_search_for_magnetometer(); if (dev) { diff --git a/samples/sensor/max30101/src/main.c b/samples/sensor/max30101/src/main.c index 7c7d48c13f3f7e..5417be09779539 100644 --- a/samples/sensor/max30101/src/main.c +++ b/samples/sensor/max30101/src/main.c @@ -11,7 +11,7 @@ void main(void) { struct sensor_value green; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, max_max30101))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, max_max30101))); if (dev == NULL) { printf("Could not get max30101 device\n"); diff --git a/samples/sensor/max44009/src/main.c b/samples/sensor/max44009/src/main.c index 7f1588336eb833..483263e5cee1fc 100644 --- a/samples/sensor/max44009/src/main.c +++ b/samples/sensor/max44009/src/main.c @@ -17,7 +17,7 @@ void main(void) { - struct device *dev; + const struct device *dev; struct sensor_value val; uint32_t lum = 0U; diff --git a/samples/sensor/mcp9808/src/main.c b/samples/sensor/mcp9808/src/main.c index 1953a310e4bea0..2fa3e3d84ef61a 100644 --- a/samples/sensor/mcp9808/src/main.c +++ b/samples/sensor/mcp9808/src/main.c @@ -40,7 +40,7 @@ static const char *now_str(void) static struct sensor_trigger trig; -static int set_window(struct device *dev, +static int set_window(const struct device *dev, const struct sensor_value *temp) { const int temp_ucel = temp->val1 * UCEL_PER_CEL + temp->val2; @@ -68,8 +68,8 @@ static int set_window(struct device *dev, return rc; } -static inline int set_window_ucel(struct device *dev, - int temp_ucel) +static inline int set_window_ucel(const struct device *dev, + int temp_ucel) { struct sensor_value val = { .val1 = temp_ucel / UCEL_PER_CEL, @@ -79,7 +79,8 @@ static inline int set_window_ucel(struct device *dev, return set_window(dev, &val); } -static void trigger_handler(struct device *dev, struct sensor_trigger *trig) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { struct sensor_value temp; static size_t cnt; @@ -97,7 +98,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trig) void main(void) { const char *const devname = DT_LABEL(DT_INST(0, microchip_mcp9808)); - struct device *dev = device_get_binding(devname); + const struct device *dev = device_get_binding(devname); int rc; if (dev == NULL) { diff --git a/samples/sensor/mpr/src/main.c b/samples/sensor/mpr/src/main.c index bf695ff0b74520..09739a1a93736f 100644 --- a/samples/sensor/mpr/src/main.c +++ b/samples/sensor/mpr/src/main.c @@ -12,7 +12,7 @@ void main(void) { const char *const devname = DT_LABEL(DT_INST(0, honeywell_mpr)); - struct device *dev = device_get_binding(devname); + const struct device *dev = device_get_binding(devname); int rc; if (dev == NULL) { diff --git a/samples/sensor/mpu6050/src/main.c b/samples/sensor/mpu6050/src/main.c index 914b6b3f31933c..3975ed75a4a569 100644 --- a/samples/sensor/mpu6050/src/main.c +++ b/samples/sensor/mpu6050/src/main.c @@ -30,7 +30,7 @@ static const char *now_str(void) return buf; } -static int process_mpu6050(struct device *dev) +static int process_mpu6050(const struct device *dev) { struct sensor_value temperature; struct sensor_value accel[3]; @@ -71,7 +71,7 @@ static int process_mpu6050(struct device *dev) #ifdef CONFIG_MPU6050_TRIGGER static struct sensor_trigger trigger; -static void handle_mpu6050_drdy(struct device *dev, +static void handle_mpu6050_drdy(const struct device *dev, struct sensor_trigger *trig) { int rc = process_mpu6050(dev); @@ -87,7 +87,7 @@ static void handle_mpu6050_drdy(struct device *dev, void main(void) { const char *const label = DT_LABEL(DT_INST(0, invensense_mpu6050)); - struct device *mpu6050 = device_get_binding(label); + const struct device *mpu6050 = device_get_binding(label); if (!mpu6050) { printf("Failed to find sensor %s\n", label); diff --git a/samples/sensor/ms5837/src/main.c b/samples/sensor/ms5837/src/main.c index 900ebe9df6095c..220a7074368063 100644 --- a/samples/sensor/ms5837/src/main.c +++ b/samples/sensor/ms5837/src/main.c @@ -15,7 +15,7 @@ LOG_MODULE_REGISTER(main); void main(void) { struct sensor_value oversampling_rate = { 8192, 0 }; - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, meas_ms5837))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, meas_ms5837))); if (dev == NULL) { LOG_ERR("Could not find MS5837 device, aborting test."); diff --git a/samples/sensor/sht3xd/src/main.c b/samples/sensor/sht3xd/src/main.c index c0a7ebcffb78ad..eed883d70a1546 100644 --- a/samples/sensor/sht3xd/src/main.c +++ b/samples/sensor/sht3xd/src/main.c @@ -15,7 +15,8 @@ #ifdef CONFIG_SHT3XD_TRIGGER static volatile bool alerted; -static void trigger_handler(struct device *dev, struct sensor_trigger *trig) +static void trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { alerted = !alerted; } @@ -24,7 +25,7 @@ static void trigger_handler(struct device *dev, struct sensor_trigger *trig) void main(void) { - struct device *dev = device_get_binding("SHT3XD"); + const struct device *dev = device_get_binding("SHT3XD"); int rc; if (dev == NULL) { diff --git a/samples/sensor/sm351lt/src/main.c b/samples/sensor/sm351lt/src/main.c index 9e9dbbbe6f3e4e..5c239dc9ce6556 100644 --- a/samples/sensor/sm351lt/src/main.c +++ b/samples/sensor/sm351lt/src/main.c @@ -11,7 +11,7 @@ #include #include -static void fetch_and_display(struct device *sensor) +static void fetch_and_display(const struct device *sensor) { static unsigned int count; struct sensor_value mag; @@ -32,7 +32,7 @@ static void fetch_and_display(struct device *sensor) } #ifdef CONFIG_SM351LT_TRIGGER -static void trigger_handler(struct device *dev, +static void trigger_handler(const struct device *dev, struct sensor_trigger *trig) { fetch_and_display(dev); @@ -41,7 +41,7 @@ static void trigger_handler(struct device *dev, void main(void) { - struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, honeywell_sm351lt))); + const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, honeywell_sm351lt))); if (sensor == NULL) { printf("Could not get %s device\n", diff --git a/samples/sensor/sx9500/src/main.c b/samples/sensor/sx9500/src/main.c index 6a9be0a48e964c..07b757d09ae225 100644 --- a/samples/sensor/sx9500/src/main.c +++ b/samples/sensor/sx9500/src/main.c @@ -11,7 +11,8 @@ #include #ifdef CONFIG_SX9500_TRIGGER -static void sensor_trigger_handler(struct device *dev, struct sensor_trigger *trig) +static void sensor_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { struct sensor_value prox_value; int ret; @@ -26,7 +27,7 @@ static void sensor_trigger_handler(struct device *dev, struct sensor_trigger *tr printk("prox is %d\n", prox_value.val1); } -static void setup_trigger(struct device *dev) +static void setup_trigger(const struct device *dev) { int ret; struct sensor_trigger trig = { @@ -39,7 +40,7 @@ static void setup_trigger(struct device *dev) } } -void do_main(struct device *dev) +void do_main(const struct device *dev) { setup_trigger(dev); @@ -50,7 +51,7 @@ void do_main(struct device *dev) #else /* CONFIG_SX9500_TRIGGER */ -static void do_main(struct device *dev) +static void do_main(const struct device *dev) { int ret; struct sensor_value prox_value; @@ -73,7 +74,7 @@ static void do_main(struct device *dev) void main(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding("SX9500"); diff --git a/samples/sensor/th02/src/main.c b/samples/sensor/th02/src/main.c index d50bc7af6db371..4d2d6a8ee4ff09 100644 --- a/samples/sensor/th02/src/main.c +++ b/samples/sensor/th02/src/main.c @@ -29,7 +29,7 @@ static struct channel_info info[] = { void main(void) { - struct device *dev[ARRAY_SIZE(info)]; + const struct device *dev[ARRAY_SIZE(info)]; struct sensor_value val[ARRAY_SIZE(info)]; unsigned int i; int rc; @@ -44,7 +44,7 @@ void main(void) } #ifdef CONFIG_GROVE_LCD_RGB - struct device *glcd; + const struct device *glcd; glcd = device_get_binding(GROVE_LCD_NAME); if (glcd == NULL) { diff --git a/samples/sensor/thermometer/src/main.c b/samples/sensor/thermometer/src/main.c index b1824178e02c3a..3a632ce99b9992 100644 --- a/samples/sensor/thermometer/src/main.c +++ b/samples/sensor/thermometer/src/main.c @@ -10,7 +10,7 @@ void main(void) { - struct device *temp_dev; + const struct device *temp_dev; printf("Thermometer Example! %s\n", CONFIG_ARCH); diff --git a/samples/sensor/ti_hdc/src/main.c b/samples/sensor/ti_hdc/src/main.c index 3d97a168f3b44a..50e40af7a5d19d 100644 --- a/samples/sensor/ti_hdc/src/main.c +++ b/samples/sensor/ti_hdc/src/main.c @@ -15,7 +15,7 @@ void main(void) { printk("Running on %s!\n", CONFIG_ARCH); - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_hdc))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_hdc))); __ASSERT(dev != NULL, "Failed to get device binding"); diff --git a/samples/sensor/tmp112/src/main.c b/samples/sensor/tmp112/src/main.c index 2375b6f767b74d..96aa759cce6e4c 100644 --- a/samples/sensor/tmp112/src/main.c +++ b/samples/sensor/tmp112/src/main.c @@ -10,7 +10,7 @@ #include #include -static void do_main(struct device *dev) +static void do_main(const struct device *dev) { int ret; struct sensor_value temp_value; @@ -56,7 +56,7 @@ static void do_main(struct device *dev) void main(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding("TMP112"); __ASSERT(dev != NULL, "Failed to get device binding"); diff --git a/samples/sensor/tmp116/src/main.c b/samples/sensor/tmp116/src/main.c index 553a4f01091e26..8f72a1a6ad0930 100644 --- a/samples/sensor/tmp116/src/main.c +++ b/samples/sensor/tmp116/src/main.c @@ -12,7 +12,7 @@ void main(void) { - struct device *dev; + const struct device *dev; struct sensor_value temp_value; int ret; diff --git a/samples/sensor/vl53l0x/src/main.c b/samples/sensor/vl53l0x/src/main.c index aaf81e673fdcca..fb7038243502ac 100644 --- a/samples/sensor/vl53l0x/src/main.c +++ b/samples/sensor/vl53l0x/src/main.c @@ -12,7 +12,7 @@ void main(void) { - struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x))); + const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x))); struct sensor_value value; int ret; diff --git a/samples/sensor/wsen_itds/src/main.c b/samples/sensor/wsen_itds/src/main.c index f91252ff6a945b..6365aa186c5b22 100644 --- a/samples/sensor/wsen_itds/src/main.c +++ b/samples/sensor/wsen_itds/src/main.c @@ -17,7 +17,7 @@ #define MAX_TEST_TIME 5000 #define SLEEPTIME 300 -static void print_accl_data(struct device *itds) +static void print_accl_data(const struct device *itds) { struct sensor_value val[3]; @@ -32,7 +32,7 @@ static void print_accl_data(struct device *itds) sensor_value_to_double(&val[2])); } -static void print_temp_data(struct device *itds) +static void print_temp_data(const struct device *itds) { struct sensor_value val; @@ -45,7 +45,7 @@ static void print_temp_data(struct device *itds) sensor_value_to_double(&val)); } -static void test_polling_mode(struct device *itds) +static void test_polling_mode(const struct device *itds) { int32_t remaining_test_time = MAX_TEST_TIME; @@ -66,7 +66,7 @@ static void test_polling_mode(struct device *itds) } #if defined(CONFIG_ITDS_TRIGGER) -static void trigger_handler(struct device *itds, +static void trigger_handler(const struct device *itds, struct sensor_trigger *trigger) { switch (trigger->type) { @@ -86,7 +86,7 @@ static void trigger_handler(struct device *itds, } #endif -static void test_trigger_mode(struct device *itds) +static void test_trigger_mode(const struct device *itds) { #if defined(CONFIG_ITDS_TRIGGER) struct sensor_trigger trig; @@ -127,7 +127,7 @@ static void test_trigger_mode(struct device *itds) void main(void) { - struct device *itds; + const struct device *itds; struct sensor_value attr; printf("get device wsen-itds\n"); diff --git a/samples/shields/lmp90100_evb/rtd/src/main.c b/samples/shields/lmp90100_evb/rtd/src/main.c index 8201b913bce19e..bb4ea51029a168 100644 --- a/samples/shields/lmp90100_evb/rtd/src/main.c +++ b/samples/shields/lmp90100_evb/rtd/src/main.c @@ -47,7 +47,7 @@ static double rtd_temperature(int nom, double resistance) void main(void) { - struct device *lmp90100; + const struct device *lmp90100; double resistance; int32_t buffer; int err; diff --git a/samples/shields/x_nucleo_iks01a1/src/main.c b/samples/shields/x_nucleo_iks01a1/src/main.c index 385c768d8e8eae..9adf082bb81f03 100644 --- a/samples/shields/x_nucleo_iks01a1/src/main.c +++ b/samples/shields/x_nucleo_iks01a1/src/main.c @@ -13,7 +13,7 @@ #ifdef CONFIG_LIS3MDL_TRIGGER static int lis3mdl_trig_cnt; -static void lis3mdl_trigger_handler(struct device *dev, +static void lis3mdl_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, trig->chan); @@ -25,10 +25,10 @@ void main(void) { struct sensor_value temp, hum, press; struct sensor_value magn_xyz[3], accel_xyz[3]; - struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); - struct device *lis3mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis3mdl_magn))); - struct device *lsm6ds0 = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6ds0))); - struct device *lps25hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps25hb_press))); + const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); + const struct device *lis3mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis3mdl_magn))); + const struct device *lsm6ds0 = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6ds0))); + const struct device *lps25hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps25hb_press))); #if defined(CONFIG_LIS3MDL_TRIGGER) struct sensor_trigger trig; int cnt = 1; diff --git a/samples/shields/x_nucleo_iks01a2/src/main.c b/samples/shields/x_nucleo_iks01a2/src/main.c index 2e0e8e375b8426..d52571fffc2ff7 100644 --- a/samples/shields/x_nucleo_iks01a2/src/main.c +++ b/samples/shields/x_nucleo_iks01a2/src/main.c @@ -16,11 +16,11 @@ void main(void) struct sensor_value accel1[3], accel2[3]; struct sensor_value gyro[3]; struct sensor_value magn[3]; - struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); - struct device *lps22hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); - struct device *lsm6dsl = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); - struct device *lsm303agr_a = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh))); - struct device *lsm303agr_m = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); + const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); + const struct device *lps22hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press))); + const struct device *lsm6dsl = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl))); + const struct device *lsm303agr_a = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh))); + const struct device *lsm303agr_m = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); if (hts221 == NULL) { printf("Could not get HTS221 device\n"); diff --git a/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c b/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c index 3723c602c758c3..c4e7eb9a83f964 100644 --- a/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c +++ b/samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c @@ -13,8 +13,8 @@ #ifdef CONFIG_LIS2DW12_TRIGGER static int lis2dw12_trig_cnt; -static void lis2dw12_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void lis2dw12_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lis2dw12_trig_cnt++; @@ -26,29 +26,29 @@ static int lsm6dso_acc_trig_cnt; static int lsm6dso_gyr_trig_cnt; static int lsm6dso_temp_trig_cnt; -static void lsm6dso_acc_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_acc_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lsm6dso_acc_trig_cnt++; } -static void lsm6dso_gyr_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_gyr_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ); lsm6dso_gyr_trig_cnt++; } -static void lsm6dso_temp_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_temp_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP); lsm6dso_temp_trig_cnt++; } #endif -static void lis2dw12_config(struct device *lis2dw12) +static void lis2dw12_config(const struct device *lis2dw12) { struct sensor_value odr_attr, fs_attr; @@ -79,7 +79,7 @@ static void lis2dw12_config(struct device *lis2dw12) #endif } -static void lsm6dso_config(struct device *lsm6dso) +static void lsm6dso_config(const struct device *lsm6dso) { struct sensor_value odr_attr, fs_attr; @@ -179,8 +179,8 @@ void main(void) struct sensor_value accel1[3], accel2[3]; struct sensor_value gyro[3]; struct sensor_value magn[3]; - struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); - struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); + const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); + const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); int cnt = 1; if (lis2dw12 == NULL) { diff --git a/samples/shields/x_nucleo_iks01a3/standard/src/main.c b/samples/shields/x_nucleo_iks01a3/standard/src/main.c index 056211d8dd4c97..ab465ee3a58620 100644 --- a/samples/shields/x_nucleo_iks01a3/standard/src/main.c +++ b/samples/shields/x_nucleo_iks01a3/standard/src/main.c @@ -13,7 +13,7 @@ #ifdef CONFIG_LIS2MDL_TRIGGER static int lis2mdl_trig_cnt; -static void lis2mdl_trigger_handler(struct device *dev, +static void lis2mdl_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL); @@ -24,7 +24,7 @@ static void lis2mdl_trigger_handler(struct device *dev, #ifdef CONFIG_LPS22HH_TRIGGER static int lps22hh_trig_cnt; -static void lps22hh_trigger_handler(struct device *dev, +static void lps22hh_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_PRESS); @@ -35,7 +35,7 @@ static void lps22hh_trigger_handler(struct device *dev, #ifdef CONFIG_STTS751_TRIGGER static int stts751_trig_cnt; -static void stts751_trigger_handler(struct device *dev, +static void stts751_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { stts751_trig_cnt++; @@ -45,8 +45,8 @@ static void stts751_trigger_handler(struct device *dev, #ifdef CONFIG_LIS2DW12_TRIGGER static int lis2dw12_trig_cnt; -static void lis2dw12_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void lis2dw12_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lis2dw12_trig_cnt++; @@ -58,29 +58,29 @@ static int lsm6dso_acc_trig_cnt; static int lsm6dso_gyr_trig_cnt; static int lsm6dso_temp_trig_cnt; -static void lsm6dso_acc_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_acc_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); lsm6dso_acc_trig_cnt++; } -static void lsm6dso_gyr_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_gyr_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ); lsm6dso_gyr_trig_cnt++; } -static void lsm6dso_temp_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void lsm6dso_temp_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP); lsm6dso_temp_trig_cnt++; } #endif -static void lis2mdl_config(struct device *lis2mdl) +static void lis2mdl_config(const struct device *lis2mdl) { struct sensor_value odr_attr; @@ -103,7 +103,7 @@ static void lis2mdl_config(struct device *lis2mdl) #endif } -static void lps22hh_config(struct device *lps22hh) +static void lps22hh_config(const struct device *lps22hh) { struct sensor_value odr_attr; @@ -126,7 +126,7 @@ static void lps22hh_config(struct device *lps22hh) #endif } -static void stts751_config(struct device *stts751) +static void stts751_config(const struct device *stts751) { struct sensor_value odr_attr; @@ -149,7 +149,7 @@ static void stts751_config(struct device *stts751) #endif } -static void lis2dw12_config(struct device *lis2dw12) +static void lis2dw12_config(const struct device *lis2dw12) { struct sensor_value odr_attr, fs_attr; @@ -180,7 +180,7 @@ static void lis2dw12_config(struct device *lis2dw12) #endif } -static void lsm6dso_config(struct device *lsm6dso) +static void lsm6dso_config(const struct device *lsm6dso) { struct sensor_value odr_attr, fs_attr; @@ -247,12 +247,12 @@ void main(void) struct sensor_value accel1[3], accel2[3]; struct sensor_value gyro[3]; struct sensor_value magn[3]; - struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); - struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh))); - struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751))); - struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); - struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); - struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); + const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221))); + const struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh))); + const struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751))); + const struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl))); + const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12))); + const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso))); int cnt = 1; if (hts221 == NULL) { diff --git a/samples/shields/x_nucleo_iks02a1/microphone/src/main.c b/samples/shields/x_nucleo_iks02a1/microphone/src/main.c index 1910db158945fa..c00d646c916ea7 100644 --- a/samples/shields/x_nucleo_iks02a1/microphone/src/main.c +++ b/samples/shields/x_nucleo_iks02a1/microphone/src/main.c @@ -49,7 +49,7 @@ void main(void) uint32_t ms; int ret; - struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy))); + const struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy))); if (!mic_dev) { printk("Could not get pointer to mic device\n"); diff --git a/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c b/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c index 5988755b71b6ba..61c4622da7e66d 100644 --- a/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c +++ b/samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c @@ -13,8 +13,8 @@ #ifdef CONFIG_IIS2DLPC_TRIGGER static int iis2dlpc_trig_cnt; -static void iis2dlpc_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void iis2dlpc_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); iis2dlpc_trig_cnt++; @@ -26,29 +26,29 @@ static int ism330dhcx_acc_trig_cnt; static int ism330dhcx_gyr_trig_cnt; static int ism330dhcx_temp_trig_cnt; -static void ism330dhcx_acc_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void ism330dhcx_acc_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); ism330dhcx_acc_trig_cnt++; } -static void ism330dhcx_gyr_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void ism330dhcx_gyr_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ); ism330dhcx_gyr_trig_cnt++; } -static void ism330dhcx_temp_trig_handler(struct device *dev, - struct sensor_trigger *trig) +static void ism330dhcx_temp_trig_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_DIE_TEMP); ism330dhcx_temp_trig_cnt++; } #endif -static void iis2dlpc_config(struct device *iis2dlpc) +static void iis2dlpc_config(const struct device *iis2dlpc) { struct sensor_value odr_attr, fs_attr; @@ -79,7 +79,7 @@ static void iis2dlpc_config(struct device *iis2dlpc) #endif } -static void ism330dhcx_config(struct device *ism330dhcx) +static void ism330dhcx_config(const struct device *ism330dhcx) { struct sensor_value odr_attr, fs_attr; @@ -156,8 +156,8 @@ void main(void) struct sensor_value accel1[3], accel2[3]; struct sensor_value gyro[3]; struct sensor_value magn[3]; - struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc))); - struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx))); + const struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc))); + const struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx))); int cnt = 1; if (iis2dlpc == NULL) { diff --git a/samples/shields/x_nucleo_iks02a1/standard/src/main.c b/samples/shields/x_nucleo_iks02a1/standard/src/main.c index 695e4ef050a1dd..cdef4befb6d725 100644 --- a/samples/shields/x_nucleo_iks02a1/standard/src/main.c +++ b/samples/shields/x_nucleo_iks02a1/standard/src/main.c @@ -13,8 +13,8 @@ #ifdef CONFIG_IIS2DLPC_TRIGGER static int iis2dlpc_trig_cnt; -static void iis2dlpc_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void iis2dlpc_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); iis2dlpc_trig_cnt++; @@ -24,7 +24,7 @@ static void iis2dlpc_trigger_handler(struct device *dev, #ifdef CONFIG_IIS2MDC_TRIGGER static int iis2mdc_trig_cnt; -static void iis2mdc_trigger_handler(struct device *dev, +static void iis2mdc_trigger_handler(const struct device *dev, struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ALL); @@ -36,22 +36,22 @@ static void iis2mdc_trigger_handler(struct device *dev, static int ism330dhcx_acc_trig_cnt; static int ism330dhcx_gyr_trig_cnt; -static void ism330dhcx_acc_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void ism330dhcx_acc_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_ACCEL_XYZ); ism330dhcx_acc_trig_cnt++; } -static void ism330dhcx_gyr_trigger_handler(struct device *dev, - struct sensor_trigger *trig) +static void ism330dhcx_gyr_trigger_handler(const struct device *dev, + struct sensor_trigger *trig) { sensor_sample_fetch_chan(dev, SENSOR_CHAN_GYRO_XYZ); ism330dhcx_gyr_trig_cnt++; } #endif -static void iis2dlpc_config(struct device *iis2dlpc) +static void iis2dlpc_config(const struct device *iis2dlpc) { struct sensor_value odr_attr, fs_attr; @@ -82,7 +82,7 @@ static void iis2dlpc_config(struct device *iis2dlpc) #endif } -static void iis2mdc_config(struct device *iis2mdc) +static void iis2mdc_config(const struct device *iis2mdc) { struct sensor_value odr_attr; @@ -105,7 +105,7 @@ static void iis2mdc_config(struct device *iis2mdc) #endif } -static void ism330dhcx_config(struct device *ism330dhcx) +static void ism330dhcx_config(const struct device *ism330dhcx) { struct sensor_value odr_attr, fs_attr; @@ -167,9 +167,9 @@ void main(void) struct sensor_value accel1[3], accel2[3]; struct sensor_value gyro[3]; struct sensor_value magn[3]; - struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc))); - struct device *iis2mdc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2mdc))); - struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx))); + const struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc))); + const struct device *iis2mdc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2mdc))); + const struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx))); int cnt = 1; if (iis2dlpc == NULL) { diff --git a/samples/subsys/canbus/canopen/src/main.c b/samples/subsys/canbus/canopen/src/main.c index c65a52ff77d517..9e7ce6de5ef807 100644 --- a/samples/subsys/canbus/canopen/src/main.c +++ b/samples/subsys/canbus/canopen/src/main.c @@ -41,7 +41,7 @@ static struct gpio_callback button_callback; #endif struct led_indicator { - struct device *dev; + const struct device *dev; gpio_pin_t pin; }; @@ -145,7 +145,8 @@ static CO_SDO_abortCode_t odf_2102(CO_ODF_arg_t *odf_arg) * @param pins GPIO pin mask that triggered the interrupt. */ #ifdef BUTTON_PORT -static void button_isr_callback(struct device *port, struct gpio_callback *cb, +static void button_isr_callback(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { counter++; @@ -160,7 +161,7 @@ static void button_isr_callback(struct device *port, struct gpio_callback *cb, static void config_button(void) { #ifdef BUTTON_PORT - struct device *dev; + const struct device *dev; int err; dev = device_get_binding(BUTTON_PORT); @@ -201,7 +202,7 @@ void main(void) { CO_NMT_reset_cmd_t reset = CO_RESET_NOT; CO_ReturnError_t err; - struct device *can; + const struct device *can; uint16_t timeout; uint32_t elapsed; int64_t timestamp; diff --git a/samples/subsys/canbus/isotp/src/main.c b/samples/subsys/canbus/isotp/src/main.c index f5fea6b3c2daca..64e82127c704ca 100644 --- a/samples/subsys/canbus/isotp/src/main.c +++ b/samples/subsys/canbus/isotp/src/main.c @@ -35,7 +35,7 @@ const struct isotp_msg_id tx_addr_0_5 = { .use_ext_addr = 0 }; -struct device *can_dev; +const struct device *can_dev; struct isotp_recv_ctx recv_ctx_8_0; struct isotp_recv_ctx recv_ctx_0_5; diff --git a/samples/subsys/ipc/ipm_imx/src/main.c b/samples/subsys/ipc/ipm_imx/src/main.c index 9f205cccf4a438..de8849e4afc411 100644 --- a/samples/subsys/ipc/ipm_imx/src/main.c +++ b/samples/subsys/ipc/ipm_imx/src/main.c @@ -9,7 +9,7 @@ #include #include -static void ipm_callback(struct device *dev, void *context, +static void ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { int i; @@ -31,7 +31,7 @@ static void ipm_callback(struct device *dev, void *context, void main(void) { - struct device *ipm; + const struct device *ipm; ipm = device_get_binding("MU_B"); if (!ipm) { diff --git a/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c b/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c index 9009af11f6af3e..96930d7877db79 100644 --- a/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c +++ b/samples/subsys/ipc/ipm_mcux/remote/src/main_remote.c @@ -9,7 +9,7 @@ #include #include -void ping_ipm_callback(struct device *dev, void *context, +void ping_ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { ipm_send(dev, 1, 0, (const void *)data, 4); @@ -19,7 +19,7 @@ void ping_ipm_callback(struct device *dev, void *context, void main(void) { - struct device *ipm; + const struct device *ipm; ipm = device_get_binding(DT_LABEL(DT_INST(0, nxp_lpc_mailbox))); if (!ipm) { diff --git a/samples/subsys/ipc/ipm_mcux/src/main_master.c b/samples/subsys/ipc/ipm_mcux/src/main_master.c index bfadc3bb140410..477e954376acd3 100644 --- a/samples/subsys/ipc/ipm_mcux/src/main_master.c +++ b/samples/subsys/ipc/ipm_mcux/src/main_master.c @@ -11,7 +11,7 @@ int gcounter; -void ping_ipm_callback(struct device *dev, void *context, +void ping_ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { gcounter = *(int *)data; @@ -30,7 +30,7 @@ void main(void) int first_message = 1; /* do not start from 0, * zero value can't be sent via mailbox register */ - struct device *ipm; + const struct device *ipm; printk("Hello World from MASTER! %s\n", CONFIG_ARCH); diff --git a/samples/subsys/ipc/ipm_mhu_dual_core/src/main.c b/samples/subsys/ipc/ipm_mhu_dual_core/src/main.c index 3d28d506e6c18f..0329543ea2936d 100644 --- a/samples/subsys/ipc/ipm_mhu_dual_core/src/main.c +++ b/samples/subsys/ipc/ipm_mhu_dual_core/src/main.c @@ -14,7 +14,7 @@ enum cpu_id_t { MHU_CPU_MAX, }; -struct device *mhu0; +const struct device *mhu0; static void main_cpu_0(void) { @@ -32,7 +32,7 @@ static void main_cpu_1(void) } } -static void mhu_isr_callback(struct device *dev, void *context, +static void mhu_isr_callback(const struct device *dev, void *context, uint32_t cpu_id, volatile void *data) { const uint32_t set_mhu = 1; diff --git a/samples/subsys/ipc/openamp/remote/src/main.c b/samples/subsys/ipc/openamp/remote/src/main.c index 4e909c14d80845..2db82267db4a07 100644 --- a/samples/subsys/ipc/openamp/remote/src/main.c +++ b/samples/subsys/ipc/openamp/remote/src/main.c @@ -23,7 +23,7 @@ K_THREAD_STACK_DEFINE(thread_stack, APP_TASK_STACK_SIZE); static struct k_thread thread_data; -static struct device *ipm_handle; +static const struct device *ipm_handle; static metal_phys_addr_t shm_physmap[] = { SHM_START_ADDR }; static struct metal_device shm_device = { @@ -95,7 +95,7 @@ struct virtio_dispatch dispatch = { static K_SEM_DEFINE(data_sem, 0, 1); static K_SEM_DEFINE(data_rx_sem, 0, 1); -static void platform_ipm_callback(struct device *dev, void *context, +static void platform_ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { k_sem_give(&data_sem); diff --git a/samples/subsys/ipc/openamp/src/main.c b/samples/subsys/ipc/openamp/src/main.c index 4013d57df84bd4..7074bd94e2d150 100644 --- a/samples/subsys/ipc/openamp/src/main.c +++ b/samples/subsys/ipc/openamp/src/main.c @@ -24,7 +24,7 @@ K_THREAD_STACK_DEFINE(thread_stack, APP_TASK_STACK_SIZE); static struct k_thread thread_data; -static struct device *ipm_handle; +static const struct device *ipm_handle; static metal_phys_addr_t shm_physmap[] = { SHM_START_ADDR }; static struct metal_device shm_device = { @@ -108,7 +108,7 @@ struct virtio_dispatch dispatch = { static K_SEM_DEFINE(data_sem, 0, 1); static K_SEM_DEFINE(data_rx_sem, 0, 1); -static void platform_ipm_callback(struct device *dev, void *context, +static void platform_ipm_callback(const struct device *dev, void *context, uint32_t id, volatile void *data) { k_sem_give(&data_sem); @@ -300,7 +300,7 @@ void main(void) /* Make sure we clear out the status flag very early (before we bringup the * secondary core) so the secondary core see's the proper status */ -int init_status_flag(struct device *arg) +int init_status_flag(const struct device *arg) { virtio_set_status(NULL, 0); diff --git a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c index c516a8e7905144..d136db9994f9ec 100644 --- a/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c +++ b/samples/subsys/ipc/openamp_rsc_table/src/main_remote.c @@ -35,7 +35,7 @@ LOG_MODULE_REGISTER(openamp_rsc_table, LOG_LEVEL_DBG); K_THREAD_STACK_DEFINE(thread_stack, APP_TASK_STACK_SIZE); static struct k_thread thread_data; -static struct device *ipm_handle; +static const struct device *ipm_handle; static metal_phys_addr_t shm_physmap = SHM_START_ADDR; @@ -66,7 +66,7 @@ static struct rpmsg_endpoint rcv_ept; static K_SEM_DEFINE(data_sem, 0, 1); static K_SEM_DEFINE(data_rx_sem, 0, 1); -static void platform_ipm_callback(struct device *device, void *context, +static void platform_ipm_callback(const struct device *device, void *context, uint32_t id, volatile void *data) { LOG_DBG("%s: msg received from mb %d\n", __func__, id); diff --git a/samples/subsys/mgmt/osdp/src/main.c b/samples/subsys/mgmt/osdp/src/main.c index 26241807ebfa6f..b6e9243398ad39 100644 --- a/samples/subsys/mgmt/osdp/src/main.c +++ b/samples/subsys/mgmt/osdp/src/main.c @@ -35,7 +35,7 @@ void main(void) { int ret, led_state; uint32_t cnt = 0; - struct device *dev; + const struct device *dev; struct osdp_cmd cmd; dev = device_get_binding(LED0); diff --git a/samples/subsys/power/device_pm/src/dummy_driver.c b/samples/subsys/power/device_pm/src/dummy_driver.c index edff18f6b32561..5b200ab2bf8aad 100644 --- a/samples/subsys/power/device_pm/src/dummy_driver.c +++ b/samples/subsys/power/device_pm/src/dummy_driver.c @@ -10,9 +10,9 @@ static struct k_poll_event async_evt; uint32_t device_power_state; -static struct device *parent; +static const struct device *parent; -static int dummy_open(struct device *dev) +static int dummy_open(const struct device *dev) { int ret; int signaled = 0, result; @@ -52,7 +52,7 @@ static int dummy_open(struct device *dev) return ret; } -static int dummy_read(struct device *dev, uint32_t *val) +static int dummy_read(const struct device *dev, uint32_t *val) { struct dummy_parent_api *api; int ret; @@ -64,7 +64,7 @@ static int dummy_read(struct device *dev, uint32_t *val) return ret; } -static int dummy_write(struct device *dev, uint32_t val) +static int dummy_write(const struct device *dev, uint32_t val) { struct dummy_parent_api *api; int ret; @@ -75,7 +75,7 @@ static int dummy_write(struct device *dev, uint32_t val) return ret; } -static int dummy_close(struct device *dev) +static int dummy_close(const struct device *dev) { int ret; @@ -93,12 +93,12 @@ static int dummy_close(struct device *dev) return ret; } -static uint32_t dummy_get_power_state(struct device *dev) +static uint32_t dummy_get_power_state(const struct device *dev) { return device_power_state; } -static int dummy_suspend(struct device *dev) +static int dummy_suspend(const struct device *dev) { printk("child suspending..\n"); device_power_state = DEVICE_PM_SUSPEND_STATE; @@ -106,7 +106,7 @@ static int dummy_suspend(struct device *dev) return 0; } -static int dummy_resume_from_suspend(struct device *dev) +static int dummy_resume_from_suspend(const struct device *dev) { printk("child resuming..\n"); device_power_state = DEVICE_PM_ACTIVE_STATE; @@ -114,7 +114,8 @@ static int dummy_resume_from_suspend(struct device *dev) return 0; } -static int dummy_device_pm_ctrl(struct device *dev, uint32_t ctrl_command, +static int dummy_device_pm_ctrl(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; @@ -147,7 +148,7 @@ static const struct dummy_driver_api funcs = { .close = dummy_close, }; -int dummy_init(struct device *dev) +int dummy_init(const struct device *dev) { parent = device_get_binding(DUMMY_PARENT_NAME); if (!parent) { diff --git a/samples/subsys/power/device_pm/src/dummy_driver.h b/samples/subsys/power/device_pm/src/dummy_driver.h index dfb0683e2618fa..63e7cb5d490b85 100644 --- a/samples/subsys/power/device_pm/src/dummy_driver.h +++ b/samples/subsys/power/device_pm/src/dummy_driver.h @@ -8,13 +8,13 @@ #include #define DUMMY_DRIVER_NAME "dummy_driver" -typedef int (*dummy_api_open_t)(struct device *dev); +typedef int (*dummy_api_open_t)(const struct device *dev); -typedef int (*dummy_api_read_t)(struct device *dev, +typedef int (*dummy_api_read_t)(const struct device *dev, uint32_t *val); -typedef int (*dummy_api_write_t)(struct device *dev, +typedef int (*dummy_api_write_t)(const struct device *dev, uint32_t val); -typedef int (*dummy_api_close_t)(struct device *dev); +typedef int (*dummy_api_close_t)(const struct device *dev); struct dummy_driver_api { dummy_api_open_t open; diff --git a/samples/subsys/power/device_pm/src/dummy_parent.c b/samples/subsys/power/device_pm/src/dummy_parent.c index 8bc7b1b2cec230..730ad9a71d1a0a 100644 --- a/samples/subsys/power/device_pm/src/dummy_parent.c +++ b/samples/subsys/power/device_pm/src/dummy_parent.c @@ -10,7 +10,8 @@ static uint32_t store_value; uint32_t parent_power_state; -static int dummy_transfer(struct device *dev, uint32_t cmd, uint32_t *val) +static int dummy_transfer(const struct device *dev, uint32_t cmd, + uint32_t *val) { printk("transfer()\n"); @@ -23,12 +24,12 @@ static int dummy_transfer(struct device *dev, uint32_t cmd, uint32_t *val) return 0; } -static uint32_t dummy_get_power_state(struct device *dev) +static uint32_t dummy_get_power_state(const struct device *dev) { return parent_power_state; } -static int dummy_suspend(struct device *dev) +static int dummy_suspend(const struct device *dev) { printk("parent suspending..\n"); parent_power_state = DEVICE_PM_SUSPEND_STATE; @@ -36,7 +37,7 @@ static int dummy_suspend(struct device *dev) return 0; } -static int dummy_resume_from_suspend(struct device *dev) +static int dummy_resume_from_suspend(const struct device *dev) { printk("parent resuming..\n"); parent_power_state = DEVICE_PM_ACTIVE_STATE; @@ -44,7 +45,8 @@ static int dummy_resume_from_suspend(struct device *dev) return 0; } -static int dummy_parent_pm_ctrl(struct device *dev, uint32_t ctrl_command, +static int dummy_parent_pm_ctrl(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; @@ -73,7 +75,7 @@ static const struct dummy_parent_api funcs = { .transfer = dummy_transfer, }; -int dummy_parent_init(struct device *dev) +int dummy_parent_init(const struct device *dev) { device_pm_enable(dev); parent_power_state = DEVICE_PM_ACTIVE_STATE; diff --git a/samples/subsys/power/device_pm/src/dummy_parent.h b/samples/subsys/power/device_pm/src/dummy_parent.h index 986e294e7aa9ea..633e02dc45eda8 100644 --- a/samples/subsys/power/device_pm/src/dummy_parent.h +++ b/samples/subsys/power/device_pm/src/dummy_parent.h @@ -11,7 +11,8 @@ #define DUMMY_PARENT_RD 0 #define DUMMY_PARENT_WR 1 -typedef int (*dummy_api_transfer_t)(struct device *dev, uint32_t cmd, uint32_t *val); +typedef int (*dummy_api_transfer_t)(const struct device *dev, uint32_t cmd, + uint32_t *val); struct dummy_parent_api { dummy_api_transfer_t transfer; diff --git a/samples/subsys/power/device_pm/src/main.c b/samples/subsys/power/device_pm/src/main.c index 9740d1677cb4ef..a77a88ff80405b 100644 --- a/samples/subsys/power/device_pm/src/main.c +++ b/samples/subsys/power/device_pm/src/main.c @@ -10,7 +10,7 @@ /* Application main Thread */ void main(void) { - struct device *dev; + const struct device *dev; struct dummy_driver_api *api; int ret, val; diff --git a/samples/subsys/usb/audio/headphones_microphone/src/main.c b/samples/subsys/usb/audio/headphones_microphone/src/main.c index 6baf3aed51932b..541ad71d147e4d 100644 --- a/samples/subsys/usb/audio/headphones_microphone/src/main.c +++ b/samples/subsys/usb/audio/headphones_microphone/src/main.c @@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(main, LOG_LEVEL_INF); -static struct device *mic_dev; +static const struct device *mic_dev; static void data_received(const struct device *dev, struct net_buf *buffer, @@ -42,7 +42,7 @@ static void data_received(const struct device *dev, } } -static void feature_update(struct device *dev, +static void feature_update(const struct device *dev, const struct usb_audio_fu_evt *evt) { LOG_DBG("Control selector %d for channel %d updated", @@ -65,7 +65,7 @@ static const struct usb_audio_ops mic_ops = { void main(void) { - struct device *hp_dev = device_get_binding("HEADPHONES"); + const struct device *hp_dev = device_get_binding("HEADPHONES"); int ret; LOG_INF("Entered %s", __func__); diff --git a/samples/subsys/usb/audio/headset/src/main.c b/samples/subsys/usb/audio/headset/src/main.c index f3627783a2332b..b9ab72f16f8f49 100644 --- a/samples/subsys/usb/audio/headset/src/main.c +++ b/samples/subsys/usb/audio/headset/src/main.c @@ -40,7 +40,7 @@ static void data_received(const struct device *dev, } } -static void feature_update(struct device *dev, +static void feature_update(const struct device *dev, const struct usb_audio_fu_evt *evt) { LOG_DBG("Control selector %d for channel %d updated", @@ -59,7 +59,7 @@ static const struct usb_audio_ops ops = { void main(void) { - struct device *hs_dev; + const struct device *hs_dev; int ret; LOG_INF("Entered %s", __func__); diff --git a/samples/subsys/usb/cdc_acm/src/main.c b/samples/subsys/usb/cdc_acm/src/main.c index e79281a63d8c36..c51527fcd81203 100644 --- a/samples/subsys/usb/cdc_acm/src/main.c +++ b/samples/subsys/usb/cdc_acm/src/main.c @@ -28,7 +28,7 @@ uint8_t ring_buffer[RING_BUF_SIZE]; struct ring_buf ringbuf; -static void interrupt_handler(struct device *dev, void *user_data) +static void interrupt_handler(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); @@ -74,7 +74,7 @@ static void interrupt_handler(struct device *dev, void *user_data) void main(void) { - struct device *dev; + const struct device *dev; uint32_t baudrate, dtr = 0U; int ret; diff --git a/samples/subsys/usb/cdc_acm_composite/src/main.c b/samples/subsys/usb/cdc_acm_composite/src/main.c index 55642bc73e15e0..56a857c602e02f 100644 --- a/samples/subsys/usb/cdc_acm_composite/src/main.c +++ b/samples/subsys/usb/cdc_acm_composite/src/main.c @@ -29,17 +29,17 @@ uint8_t buffer0[RING_BUF_SIZE]; uint8_t buffer1[RING_BUF_SIZE]; static struct serial_data { - struct device *peer; + const struct device *peer; struct serial_data *peer_data; struct ring_buf ringbuf; } peers[2]; -static void interrupt_handler(struct device *dev, void *user_data) +static void interrupt_handler(const struct device *dev, void *user_data) { struct serial_data *dev_data = user_data; while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { - struct device *peer = dev_data->peer; + const struct device *peer = dev_data->peer; LOG_DBG("dev %p dev_data %p", dev, dev_data); @@ -80,7 +80,7 @@ static void interrupt_handler(struct device *dev, void *user_data) } } -static void uart_line_set(struct device *dev) +static void uart_line_set(const struct device *dev) { uint32_t baudrate; int ret; @@ -113,7 +113,7 @@ void main(void) struct serial_data *dev_data0 = &peers[0]; struct serial_data *dev_data1 = &peers[1]; - struct device *dev0, *dev1; + const struct device *dev0, *dev1; uint32_t dtr = 0U; dev0 = device_get_binding("CDC_ACM_0"); diff --git a/samples/subsys/usb/console/src/main.c b/samples/subsys/usb/console/src/main.c index 9698a38f66bf12..ecad1f631547d9 100644 --- a/samples/subsys/usb/console/src/main.c +++ b/samples/subsys/usb/console/src/main.c @@ -13,7 +13,7 @@ void main(void) { - struct device *dev = device_get_binding( + const struct device *dev = device_get_binding( CONFIG_UART_CONSOLE_ON_DEV_NAME); uint32_t dtr = 0; diff --git a/samples/subsys/usb/hid-cdc/src/main.c b/samples/subsys/usb/hid-cdc/src/main.c index 47809fb04b6c8f..6723016f00c349 100644 --- a/samples/subsys/usb/hid-cdc/src/main.c +++ b/samples/subsys/usb/hid-cdc/src/main.c @@ -376,7 +376,7 @@ static void flush_buffer_kbd(void) memset(data_buf_kbd, 0, sizeof(data_buf_kbd)); } -static void write_data(struct device *dev, const char *buf, int len) +static void write_data(const struct device *dev, const char *buf, int len) { uart_irq_tx_enable(dev); @@ -396,7 +396,7 @@ static void write_data(struct device *dev, const char *buf, int len) uart_irq_tx_disable(dev); } -static void cdc_mouse_int_handler(struct device *dev, void *user_data) +static void cdc_mouse_int_handler(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); @@ -444,7 +444,7 @@ static void cdc_mouse_int_handler(struct device *dev, void *user_data) } } -static void cdc_kbd_int_handler(struct device *dev, void *user_data) +static void cdc_kbd_int_handler(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); @@ -479,7 +479,8 @@ static void cdc_kbd_int_handler(struct device *dev, void *user_data) /* Devices */ -static void btn0(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void btn0(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -489,7 +490,8 @@ static void btn0(struct device *gpio, struct gpio_callback *cb, uint32_t pins) } #if DT_NODE_HAS_STATUS(SW1_NODE, okay) -static void btn1(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void btn1(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -500,7 +502,8 @@ static void btn1(struct device *gpio, struct gpio_callback *cb, uint32_t pins) #endif #if DT_NODE_HAS_STATUS(SW2_NODE, okay) -static void btn2(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void btn2(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -511,7 +514,8 @@ static void btn2(struct device *gpio, struct gpio_callback *cb, uint32_t pins) #endif #if DT_NODE_HAS_STATUS(SW3_NODE, okay) -static void btn3(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void btn3(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { struct app_evt_t *ev = app_evt_alloc(); @@ -521,9 +525,10 @@ static void btn3(struct device *gpio, struct gpio_callback *cb, uint32_t pins) } #endif -int callbacks_configure(struct device *gpio, uint32_t pin, int flags, - void (*handler)(struct device*, struct gpio_callback*, - uint32_t), struct gpio_callback *callback) +int callbacks_configure(const struct device *gpio, uint32_t pin, int flags, + void (*handler)(const struct device *, struct gpio_callback*, + uint32_t), + struct gpio_callback *callback) { if (!gpio) { LOG_ERR("Could not find PORT"); @@ -549,7 +554,7 @@ void main(void) { int ret; - struct device *hid0_dev, *hid1_dev, *cdc0_dev, *cdc1_dev; + const struct device *hid0_dev, *hid1_dev, *cdc0_dev, *cdc1_dev; uint32_t dtr = 0U; struct app_evt_t *ev; diff --git a/samples/subsys/usb/hid-mouse/src/main.c b/samples/subsys/usb/hid-mouse/src/main.c index feefd9478e13a2..80fe671dff6e8b 100644 --- a/samples/subsys/usb/hid-mouse/src/main.c +++ b/samples/subsys/usb/hid-mouse/src/main.c @@ -87,7 +87,7 @@ static void status_cb(enum usb_dc_status_code status, const uint8_t *param) usb_status = status; } -static void left_button(struct device *gpio, struct gpio_callback *cb, +static void left_button(const struct device *gpio, struct gpio_callback *cb, uint32_t pins) { int ret; @@ -120,7 +120,7 @@ static void left_button(struct device *gpio, struct gpio_callback *cb, } #if DT_NODE_HAS_STATUS(SW1_NODE, okay) -static void right_button(struct device *gpio, struct gpio_callback *cb, +static void right_button(const struct device *gpio, struct gpio_callback *cb, uint32_t pins) { int ret; @@ -154,7 +154,8 @@ static void right_button(struct device *gpio, struct gpio_callback *cb, #endif #if DT_NODE_HAS_STATUS(SW2_NODE, okay) -static void x_move(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void x_move(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { int ret; uint8_t state = status[MOUSE_X_REPORT_POS]; @@ -178,7 +179,8 @@ static void x_move(struct device *gpio, struct gpio_callback *cb, uint32_t pins) #endif #if DT_NODE_HAS_STATUS(SW3_NODE, okay) -static void y_move(struct device *gpio, struct gpio_callback *cb, uint32_t pins) +static void y_move(const struct device *gpio, struct gpio_callback *cb, + uint32_t pins) { int ret; uint8_t state = status[MOUSE_Y_REPORT_POS]; @@ -201,7 +203,7 @@ static void y_move(struct device *gpio, struct gpio_callback *cb, uint32_t pins) } #endif -int callbacks_configure(struct device *gpio, uint32_t pin, int flags, +int callbacks_configure(const struct device *gpio, uint32_t pin, int flags, gpio_callback_handler_t handler, struct gpio_callback *callback, uint8_t *val) { @@ -250,7 +252,7 @@ void main(void) { int ret; uint8_t report[4] = { 0x00 }; - struct device *led_dev, *hid_dev; + const struct device *led_dev, *hid_dev; led_dev = device_get_binding(LED_PORT); if (led_dev == NULL) { diff --git a/samples/subsys/usb/hid/src/main.c b/samples/subsys/usb/hid/src/main.c index beed3640f9e6b6..e836d927231cfd 100644 --- a/samples/subsys/usb/hid/src/main.c +++ b/samples/subsys/usb/hid/src/main.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(main); static struct k_delayed_work delayed_report_send; -static struct device *hdev; +static const struct device *hdev; #define REPORT_TIMEOUT K_SECONDS(2) @@ -128,7 +128,7 @@ void main(void) k_delayed_work_init(&delayed_report_send, send_report); } -static int composite_pre_init(struct device *dev) +static int composite_pre_init(const struct device *dev) { hdev = device_get_binding("HID_0"); if (hdev == NULL) { diff --git a/samples/userspace/prod_consumer/src/app_a.c b/samples/userspace/prod_consumer/src/app_a.c index 2f35f38710906b..7adeacde069419 100644 --- a/samples/userspace/prod_consumer/src/app_a.c +++ b/samples/userspace/prod_consumer/src/app_a.c @@ -49,14 +49,14 @@ K_THREAD_STACK_DEFINE(writeback_stack, 2048); * we ensure all this gets linked into the continuous region denoted by * app_a_partition. */ -APP_A_BSS struct device *sample_device; +APP_A_BSS const struct device *sample_device; APP_A_BSS unsigned int pending_count; /* ISR-level callback function. Runs in supervisor mode. Does what's needed * to get the data into this application's accessible memory and have the * worker thread running in user mode do the rest. */ -void sample_callback(struct device *dev, void *context, void *data) +void sample_callback(const struct device *dev, void *context, void *data) { int ret; diff --git a/samples/userspace/prod_consumer/src/sample_driver.h b/samples/userspace/prod_consumer/src/sample_driver.h index 0b4169b97b6cbc..e9fa222950e862 100644 --- a/samples/userspace/prod_consumer/src/sample_driver.h +++ b/samples/userspace/prod_consumer/src/sample_driver.h @@ -12,16 +12,17 @@ #define SAMPLE_DRIVER_NAME_0 "SAMPLE_DRIVER_0" #define SAMPLE_DRIVER_MSG_SIZE 128 -typedef void (*sample_driver_callback_t)(struct device *dev, +typedef void (*sample_driver_callback_t)(const struct device *dev, void *context, void *data); -typedef int (*sample_driver_write_t)(struct device *dev, void *buf); +typedef int (*sample_driver_write_t)(const struct device *dev, void *buf); -typedef int (*sample_driver_set_callback_t)(struct device *dev, +typedef int (*sample_driver_set_callback_t)(const struct device *dev, sample_driver_callback_t cb, void *context); -typedef int (*sample_driver_state_set_t)(struct device *dev, bool active); +typedef int (*sample_driver_state_set_t)(const struct device *dev, + bool active); __subsystem struct sample_driver_api { sample_driver_write_t write; @@ -39,9 +40,10 @@ __subsystem struct sample_driver_api { * @param buf Processed data, of size SAMPLE_DRIVER_MSG_SIZE * @return 0 Success, nonzero if an error occurred */ -__syscall int sample_driver_write(struct device *dev, void *buf); +__syscall int sample_driver_write(const struct device *dev, void *buf); -static inline int z_impl_sample_driver_write(struct device *dev, void *buf) +static inline int z_impl_sample_driver_write(const struct device *dev, + void *buf) { const struct sample_driver_api *api = dev->api; @@ -54,9 +56,9 @@ static inline int z_impl_sample_driver_write(struct device *dev, void *buf) * @param dev Sample driver device * @param active Whether to activate/deactivate interrupts */ -__syscall int sample_driver_state_set(struct device *dev, bool active); +__syscall int sample_driver_state_set(const struct device *dev, bool active); -static inline int z_impl_sample_driver_state_set(struct device *dev, +static inline int z_impl_sample_driver_state_set(const struct device *dev, bool active) { const struct sample_driver_api *api = dev->api; @@ -75,7 +77,7 @@ static inline int z_impl_sample_driver_state_set(struct device *dev, * @param context Context passed to callback function, or NULL if not needed * @return 0 Success, nonzero if an error occurred */ -static inline int sample_driver_set_callback(struct device *dev, +static inline int sample_driver_set_callback(const struct device *dev, sample_driver_callback_t cb, void *context) { diff --git a/samples/userspace/prod_consumer/src/sample_driver_foo.c b/samples/userspace/prod_consumer/src/sample_driver_foo.c index df190e00fb26f4..6dc94953f71e7f 100644 --- a/samples/userspace/prod_consumer/src/sample_driver_foo.c +++ b/samples/userspace/prod_consumer/src/sample_driver_foo.c @@ -30,16 +30,16 @@ struct sample_driver_foo_dev_data { uint32_t count; }; -static int sample_driver_foo_write(struct device *dev, void *buf) +static int sample_driver_foo_write(const struct device *dev, void *buf) { LOG_DBG("%s(%p, %p)", __func__, dev, buf); return 0; } -static int sample_driver_foo_set_callback(struct device *dev, - sample_driver_callback_t cb, - void *context) +static int sample_driver_foo_set_callback(const struct device *dev, + sample_driver_callback_t cb, + void *context) { struct sample_driver_foo_dev_data *data = DEV_DATA(dev); int key = irq_lock(); @@ -51,7 +51,7 @@ static int sample_driver_foo_set_callback(struct device *dev, return 0; } -static int sample_driver_foo_state_set(struct device *dev, bool active) +static int sample_driver_foo_state_set(const struct device *dev, bool active) { struct sample_driver_foo_dev_data *data = DEV_DATA(dev); @@ -75,7 +75,7 @@ static struct sample_driver_api sample_driver_foo_api = { static void sample_driver_foo_isr(void *param) { - struct device *dev = param; + const struct device *dev = param; struct sample_driver_foo_dev_data *data = DEV_DATA(dev); char data_payload[SAMPLE_DRIVER_MSG_SIZE]; @@ -96,7 +96,7 @@ static void sample_driver_timer_cb(struct k_timer *timer) sample_driver_foo_isr(timer->user_data); } -static int sample_driver_foo_init(struct device *dev) +static int sample_driver_foo_init(const struct device *dev) { struct sample_driver_foo_dev_data *data = DEV_DATA(dev); diff --git a/samples/userspace/prod_consumer/src/sample_driver_handlers.c b/samples/userspace/prod_consumer/src/sample_driver_handlers.c index 6446ff133371bf..909becbd9c6033 100644 --- a/samples/userspace/prod_consumer/src/sample_driver_handlers.c +++ b/samples/userspace/prod_consumer/src/sample_driver_handlers.c @@ -8,7 +8,7 @@ #include #include "sample_driver.h" -int z_vrfy_sample_driver_state_set(struct device *dev, bool active) +int z_vrfy_sample_driver_state_set(const struct device *dev, bool active) { if (Z_SYSCALL_DRIVER_SAMPLE(dev, state_set)) { return -EINVAL; @@ -19,7 +19,7 @@ int z_vrfy_sample_driver_state_set(struct device *dev, bool active) #include -int z_vrfy_sample_driver_write(struct device *dev, void *buf) +int z_vrfy_sample_driver_write(const struct device *dev, void *buf) { if (Z_SYSCALL_DRIVER_SAMPLE(dev, write)) { return -EINVAL; diff --git a/samples/video/capture/src/main.c b/samples/video/capture/src/main.c index b2d6cf22d4de54..c1ab4127d3e2ea 100644 --- a/samples/video/capture/src/main.c +++ b/samples/video/capture/src/main.c @@ -24,7 +24,7 @@ void main(void) struct video_buffer *buffers[2], *vbuf; struct video_format fmt; struct video_caps caps; - struct device *video; + const struct device *video; unsigned int frame = 0; size_t bsize; int i = 0; @@ -39,7 +39,7 @@ void main(void) /* But would be better to use a real video device if any */ #ifdef VIDEO_DEV { - struct device *dev = device_get_binding(VIDEO_DEV); + const struct device *dev = device_get_binding(VIDEO_DEV); if (dev == NULL) { LOG_ERR("Video device %s not found, " diff --git a/samples/video/tcpserversink/src/main.c b/samples/video/tcpserversink/src/main.c index 9aa8725ac760d2..2c761c6a5eb800 100644 --- a/samples/video/tcpserversink/src/main.c +++ b/samples/video/tcpserversink/src/main.c @@ -46,7 +46,7 @@ void main(void) struct video_buffer *buffers[2], *vbuf; int i, ret, sock, client; struct video_format fmt; - struct device *video; + const struct device *video; /* Prepare Network */ (void)memset(&addr, 0, sizeof(addr)); diff --git a/soc/arc/snps_arc_hsdk/soc.c b/soc/arc/snps_arc_hsdk/soc.c index 098c7b76a0553d..99fcd51469374e 100644 --- a/soc/arc/snps_arc_hsdk/soc.c +++ b/soc/arc/snps_arc_hsdk/soc.c @@ -12,7 +12,7 @@ #include #include "soc.h" -static int arc_hsdk_init(struct device *dev) +static int arc_hsdk_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arc/snps_arc_iot/soc.c b/soc/arc/snps_arc_iot/soc.c index 9f6397920780a4..c9be0b8528e166 100644 --- a/soc/arc/snps_arc_iot/soc.c +++ b/soc/arc/snps_arc_iot/soc.c @@ -15,7 +15,7 @@ #define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency) -static int arc_iot_init(struct device *dev) +static int arc_iot_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arc/snps_emsk/soc_config.c b/soc/arc/snps_emsk/soc_config.c index 5d77f4d50ac1bc..e0812430c5df3e 100644 --- a/soc/arc/snps_emsk/soc_config.c +++ b/soc/arc/snps_emsk/soc_config.c @@ -11,7 +11,7 @@ #ifdef CONFIG_UART_NS16550 -static int uart_ns16550_init(struct device *dev) +static int uart_ns16550_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arc/snps_nsim/soc.c b/soc/arc/snps_nsim/soc.c index 5a9fc38faa7640..e93668c7797ea1 100644 --- a/soc/arc/snps_nsim/soc.c +++ b/soc/arc/snps_nsim/soc.c @@ -17,7 +17,7 @@ #include "soc.h" #ifdef CONFIG_SMP -static int arc_nsim_init(struct device *dev) +static int arc_nsim_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arm/arm/beetle/soc.c b/soc/arm/arm/beetle/soc.c index e89d2f6d9f7c6c..678992c5180c2f 100644 --- a/soc/arm/arm/beetle/soc.c +++ b/soc/arm/arm/beetle/soc.c @@ -30,7 +30,7 @@ * * @return 0 */ -static int arm_beetle_init(struct device *arg) +static int arm_beetle_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/arm/designstart/soc.c b/soc/arm/arm/designstart/soc.c index cc8c62a2803928..bf195add710185 100644 --- a/soc/arm/arm/designstart/soc.c +++ b/soc/arm/arm/designstart/soc.c @@ -6,7 +6,7 @@ #include -static int arm_designstart_init(struct device *arg) +static int arm_designstart_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/arm/mps2/soc.c b/soc/arm/arm/mps2/soc.c index 1d6f9565997abf..d0f563723b1c45 100644 --- a/soc/arm/arm/mps2/soc.c +++ b/soc/arm/arm/mps2/soc.c @@ -81,7 +81,7 @@ uint32_t sse_200_platform_get_cpu_id(void) * * @return 0 */ -static int arm_mps2_init(struct device *arg) +static int arm_mps2_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/arm/musca_a/soc.c b/soc/arm/arm/musca_a/soc.c index 83f5fa08c50b18..f3bfb7bbb2a03f 100644 --- a/soc/arm/arm/musca_a/soc.c +++ b/soc/arm/arm/musca_a/soc.c @@ -52,7 +52,7 @@ uint32_t sse_200_platform_get_cpu_id(void) * * @return 0 */ -static int arm_musca_init(struct device *arg) +static int arm_musca_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/arm/musca_b1/soc.c b/soc/arm/arm/musca_b1/soc.c index 7e8fb8fa93dc7a..177eae3c37f46b 100644 --- a/soc/arm/arm/musca_b1/soc.c +++ b/soc/arm/arm/musca_b1/soc.c @@ -52,7 +52,7 @@ uint32_t sse_200_platform_get_cpu_id(void) * * @return 0 */ -static int arm_musca_b1_init(struct device *arg) +static int arm_musca_b1_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/atmel_sam/sam3x/soc.c b/soc/arm/atmel_sam/sam3x/soc.c index 03ffb5aeff5a95..e0db6f9019136e 100644 --- a/soc/arm/atmel_sam/sam3x/soc.c +++ b/soc/arm/atmel_sam/sam3x/soc.c @@ -201,7 +201,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int atmel_sam3x_init(struct device *arg) +static int atmel_sam3x_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam/sam4e/soc.c b/soc/arm/atmel_sam/sam4e/soc.c index 8d7f032aa219c6..3e768ff2c415d3 100644 --- a/soc/arm/atmel_sam/sam4e/soc.c +++ b/soc/arm/atmel_sam/sam4e/soc.c @@ -189,7 +189,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int atmel_sam4e_init(struct device *arg) +static int atmel_sam4e_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam/sam4s/soc.c b/soc/arm/atmel_sam/sam4s/soc.c index 5e480620733d83..06989b6791086c 100644 --- a/soc/arm/atmel_sam/sam4s/soc.c +++ b/soc/arm/atmel_sam/sam4s/soc.c @@ -188,7 +188,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int atmel_sam4s_init(struct device *arg) +static int atmel_sam4s_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam/same70/soc.c b/soc/arm/atmel_sam/same70/soc.c index a152114fde17f2..77a7fe0cf3004c 100644 --- a/soc/arm/atmel_sam/same70/soc.c +++ b/soc/arm/atmel_sam/same70/soc.c @@ -223,7 +223,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int atmel_same70_init(struct device *arg) +static int atmel_same70_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam/same70/soc_config.c b/soc/arm/atmel_sam/same70/soc_config.c index 82750efe84826c..410b08b2abaea5 100644 --- a/soc/arm/atmel_sam/same70/soc_config.c +++ b/soc/arm/atmel_sam/same70/soc_config.c @@ -20,7 +20,7 @@ * * @return 0 */ -static int atmel_same70_config(struct device *dev) +static int atmel_same70_config(const struct device *dev) { #ifdef CONFIG_SOC_ATMEL_SAME70_DISABLE_ERASE_PIN /* Disable ERASE function on PB12 pin, this is controlled by Bus Matrix */ diff --git a/soc/arm/atmel_sam/samv71/soc.c b/soc/arm/atmel_sam/samv71/soc.c index d0d5a8fd3a649c..29334846ccc618 100644 --- a/soc/arm/atmel_sam/samv71/soc.c +++ b/soc/arm/atmel_sam/samv71/soc.c @@ -224,7 +224,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int atmel_samv71_init(struct device *arg) +static int atmel_samv71_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam/samv71/soc_config.c b/soc/arm/atmel_sam/samv71/soc_config.c index b308540aa0bd75..72cafdc4aa8e73 100644 --- a/soc/arm/atmel_sam/samv71/soc_config.c +++ b/soc/arm/atmel_sam/samv71/soc_config.c @@ -21,7 +21,7 @@ * * @return 0 */ -static int atmel_samv71_config(struct device *dev) +static int atmel_samv71_config(const struct device *dev) { #ifdef CONFIG_SOC_ATMEL_SAMV71_DISABLE_ERASE_PIN /* Disable ERASE function on PB12 pin, this is controlled by Bus diff --git a/soc/arm/atmel_sam0/common/bossa.c b/soc/arm/atmel_sam0/common/bossa.c index 94b5cf1b591f71..8c36f6f9b6974e 100644 --- a/soc/arm/atmel_sam0/common/bossa.c +++ b/soc/arm/atmel_sam0/common/bossa.c @@ -23,7 +23,7 @@ #if defined(CONFIG_BOOTLOADER_BOSSA_DEVICE_NAME) -static void bossa_reset(struct device *dev, uint32_t rate) +static void bossa_reset(const struct device *dev, uint32_t rate) { uint32_t *top; @@ -43,9 +43,9 @@ static void bossa_reset(struct device *dev, uint32_t rate) NVIC_SystemReset(); } -static int bossa_init(struct device *unused) +static int bossa_init(const struct device *unused) { - struct device *dev = + const struct device *dev = device_get_binding(CONFIG_BOOTLOADER_BOSSA_DEVICE_NAME); if (dev == NULL) { diff --git a/soc/arm/atmel_sam0/common/soc_samd2x.c b/soc/arm/atmel_sam0/common/soc_samd2x.c index 89dca11380ca35..6166d9ee794063 100644 --- a/soc/arm/atmel_sam0/common/soc_samd2x.c +++ b/soc/arm/atmel_sam0/common/soc_samd2x.c @@ -172,7 +172,7 @@ static void dividers_init(void) /* TODO(mlhx): enable clock failure detection? */ } -static int atmel_samd_init(struct device *arg) +static int atmel_samd_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/atmel_sam0/common/soc_samd5x.c b/soc/arm/atmel_sam0/common/soc_samd5x.c index 53ecaa9b77414d..cfc38d1627d969 100644 --- a/soc/arm/atmel_sam0/common/soc_samd5x.c +++ b/soc/arm/atmel_sam0/common/soc_samd5x.c @@ -98,7 +98,7 @@ static void gclk_connect(uint8_t gclk, uint8_t src, uint8_t div) | GCLK_GENCTRL_GENEN; } -static int atmel_samd_init(struct device *arg) +static int atmel_samd_init(const struct device *arg) { uint32_t key; uint8_t dfll_div; diff --git a/soc/arm/bcm_vk/valkyrie/soc.c b/soc/arm/bcm_vk/valkyrie/soc.c index 7a2e39147a7f97..0d48d681d8738a 100644 --- a/soc/arm/bcm_vk/valkyrie/soc.c +++ b/soc/arm/bcm_vk/valkyrie/soc.c @@ -16,7 +16,7 @@ * * @return 0 */ -static int valkyrie_init(struct device *arg) +static int valkyrie_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/bcm_vk/viper/soc.c b/soc/arm/bcm_vk/viper/soc.c index e6903d73bd30e7..479c14b0842510 100644 --- a/soc/arm/bcm_vk/viper/soc.c +++ b/soc/arm/bcm_vk/viper/soc.c @@ -17,7 +17,7 @@ * * @return 0 */ -static int viper_init(struct device *arg) +static int viper_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/cypress/psoc6/soc.c b/soc/arm/cypress/psoc6/soc.c index 562b33e1377d2d..efe1177ae6def0 100644 --- a/soc/arm/cypress/psoc6/soc.c +++ b/soc/arm/cypress/psoc6/soc.c @@ -370,7 +370,7 @@ void Cy_SystemInit(void) Cy_SysClk_PeriphEnableDivider(CY_SYSCLK_DIV_8_BIT, 0u); } -static int init_cycfg_platform_wraper(struct device *arg) +static int init_cycfg_platform_wraper(const struct device *arg) { ARG_UNUSED(arg); SystemInit(); diff --git a/soc/arm/microchip_mec/mec1501/soc.c b/soc/arm/microchip_mec/mec1501/soc.c index 8ccf2b487025b7..80206e93af9558 100644 --- a/soc/arm/microchip_mec/mec1501/soc.c +++ b/soc/arm/microchip_mec/mec1501/soc.c @@ -132,7 +132,7 @@ static int soc_ecia_init(void) return 0; } -static int soc_init(struct device *dev) +static int soc_init(const struct device *dev) { uint32_t isave; diff --git a/soc/arm/microchip_mec/mec1701/soc.c b/soc/arm/microchip_mec/mec1701/soc.c index 83226f5eeaff32..4004334575f05b 100644 --- a/soc/arm/microchip_mec/mec1701/soc.c +++ b/soc/arm/microchip_mec/mec1701/soc.c @@ -10,7 +10,7 @@ #include -static int soc_init(struct device *dev) +static int soc_init(const struct device *dev) { __IO uint32_t *girc_enable_set; diff --git a/soc/arm/nordic_nrf/nrf51/soc.c b/soc/arm/nordic_nrf/nrf51/soc.c index b05ad00d8246bd..5503eafb6da448 100644 --- a/soc/arm/nordic_nrf/nrf51/soc.c +++ b/soc/arm/nordic_nrf/nrf51/soc.c @@ -38,7 +38,7 @@ void sys_arch_reboot(int type) NVIC_SystemReset(); } -static int nordicsemi_nrf51_init(struct device *arg) +static int nordicsemi_nrf51_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/nordic_nrf/nrf52/soc.c b/soc/arm/nordic_nrf/nrf52/soc.c index a59c7eb5dcfc0a..02bc3d1890cbc3 100644 --- a/soc/arm/nordic_nrf/nrf52/soc.c +++ b/soc/arm/nordic_nrf/nrf52/soc.c @@ -55,7 +55,7 @@ void sys_arch_reboot(int type) NVIC_SystemReset(); } -static int nordicsemi_nrf52_init(struct device *arg) +static int nordicsemi_nrf52_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/nordic_nrf/nrf53/soc.c b/soc/arm/nordic_nrf/nrf53/soc.c index 905558a3dcde10..82a218207f7b69 100644 --- a/soc/arm/nordic_nrf/nrf53/soc.c +++ b/soc/arm/nordic_nrf/nrf53/soc.c @@ -36,7 +36,7 @@ extern void z_arm_nmi_init(void); #define LOG_LEVEL CONFIG_SOC_LOG_LEVEL LOG_MODULE_REGISTER(soc); -static int nordicsemi_nrf53_init(struct device *arg) +static int nordicsemi_nrf53_init(const struct device *arg) { uint32_t key; @@ -102,7 +102,7 @@ bool nrf53_has_erratum19(void) } #ifndef CONFIG_NRF5340_CPUAPP_ERRATUM19 -static int check_erratum19(struct device *arg) +static int check_erratum19(const struct device *arg) { ARG_UNUSED(arg); if (nrf53_has_erratum19()) { diff --git a/soc/arm/nordic_nrf/nrf91/soc.c b/soc/arm/nordic_nrf/nrf91/soc.c index ac239dcced5e19..fcbed59349da6d 100644 --- a/soc/arm/nordic_nrf/nrf91/soc.c +++ b/soc/arm/nordic_nrf/nrf91/soc.c @@ -34,7 +34,7 @@ extern void z_arm_nmi_init(void); #define LOG_LEVEL CONFIG_SOC_LOG_LEVEL LOG_MODULE_REGISTER(soc); -static int nordicsemi_nrf91_init(struct device *arg) +static int nordicsemi_nrf91_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/nuvoton_npcx/common/soc_gpio.h b/soc/arm/nuvoton_npcx/common/soc_gpio.h index f1692a9b4da8d2..4fb3b3d0a518e5 100644 --- a/soc/arm/nuvoton_npcx/common/soc_gpio.h +++ b/soc/arm/nuvoton_npcx/common/soc_gpio.h @@ -22,7 +22,7 @@ extern "C" { * @retval Pointer to structure device * @retval NULL Invalid parameter of GPIO port index */ -struct device *soc_get_gpio_dev(int port); +const struct device *soc_get_gpio_dev(int port); #ifdef __cplusplus } diff --git a/soc/arm/nuvoton_npcx/common/soc_miwu.h b/soc/arm/nuvoton_npcx/common/soc_miwu.h index 21676cd52d69c7..976ad48f278c34 100644 --- a/soc/arm/nuvoton_npcx/common/soc_miwu.h +++ b/soc/arm/nuvoton_npcx/common/soc_miwu.h @@ -65,7 +65,7 @@ struct npcx_wui { * of generic hardware. Its parameters contain the device issued interrupt * and corresponding WUI source. */ -typedef void (*miwu_dev_callback_handler_t)(struct device *source, +typedef void (*miwu_dev_callback_handler_t)(const struct device *source, struct npcx_wui *wui); /** @@ -114,7 +114,7 @@ struct miwu_dev_callback { /** Callback function being called when device event occurred */ miwu_dev_callback_handler_t handler; /** Device instance register callback function */ - struct device *source; + const struct device *source; /* Wake-up input source */ struct npcx_wui wui; }; @@ -176,7 +176,7 @@ void soc_miwu_init_gpio_callback(struct miwu_io_callback *callback, void soc_miwu_init_dev_callback(struct miwu_dev_callback *callback, const struct npcx_wui *dev_wui, miwu_dev_callback_handler_t handler, - struct device *source); + const struct device *source); /** * @brief Function to insert or remove a IO callback from a callback list diff --git a/soc/arm/nuvoton_npcx/npcx7/soc.c b/soc/arm/nuvoton_npcx/npcx7/soc.c index 78bbcd1f541e12..a30c3d72680f34 100644 --- a/soc/arm/nuvoton_npcx/npcx7/soc.c +++ b/soc/arm/nuvoton_npcx/npcx7/soc.c @@ -9,7 +9,7 @@ #include #include -static int soc_init(struct device *dev) +static int soc_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arm/nxp_imx/mcimx6x_m4/soc.c b/soc/arm/nxp_imx/mcimx6x_m4/soc.c index e324b31daac448..66108e120a568c 100644 --- a/soc/arm/nxp_imx/mcimx6x_m4/soc.c +++ b/soc/arm/nxp_imx/mcimx6x_m4/soc.c @@ -169,7 +169,7 @@ static void SOC_ClockInit(void) * * @return 0 */ -static int mcimx6x_m4_init(struct device *arg) +static int mcimx6x_m4_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_imx/mcimx7_m4/soc.c b/soc/arm/nxp_imx/mcimx7_m4/soc.c index ec8b32d9d06be9..69d6c51f0d56d0 100644 --- a/soc/arm/nxp_imx/mcimx7_m4/soc.c +++ b/soc/arm/nxp_imx/mcimx7_m4/soc.c @@ -221,7 +221,7 @@ static void nxp_mcimx7_mu_config(void) } #endif /* CONFIG_IPM_IMX */ -static int nxp_mcimx7_init(struct device *arg) +static int nxp_mcimx7_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_imx/mimx8mm6_m4/soc.c b/soc/arm/nxp_imx/mimx8mm6_m4/soc.c index eb609f14270571..c357e673e62bc0 100644 --- a/soc/arm/nxp_imx/mimx8mm6_m4/soc.c +++ b/soc/arm/nxp_imx/mimx8mm6_m4/soc.c @@ -128,7 +128,7 @@ static void SOC_ClockInit(void) CLOCK_EnableClock(kCLOCK_Uart4); } -static int nxp_mimx8mm6_init(struct device *arg) +static int nxp_mimx8mm6_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_imx/rt/soc.c b/soc/arm/nxp_imx/rt/soc.c index 52eecc416b0d40..f7597feba6a635 100644 --- a/soc/arm/nxp_imx/rt/soc.c +++ b/soc/arm/nxp_imx/rt/soc.c @@ -254,7 +254,7 @@ void imxrt_usdhc_pinmux(uint16_t nusdhc, bool init, * @return 0 */ -static int imxrt_init(struct device *arg) +static int imxrt_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_imx/rt6xx/soc.c b/soc/arm/nxp_imx/rt6xx/soc.c index 27fb4e03281d8b..c7f9f22123c3f3 100644 --- a/soc/arm/nxp_imx/rt6xx/soc.c +++ b/soc/arm/nxp_imx/rt6xx/soc.c @@ -172,7 +172,7 @@ static ALWAYS_INLINE void clock_init(void) * @return 0 */ -static int nxp_rt600_init(struct device *arg) +static int nxp_rt600_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/k2x/soc.c b/soc/arm/nxp_kinetis/k2x/soc.c index 9320e211a85367..fe0012df223b37 100644 --- a/soc/arm/nxp_kinetis/k2x/soc.c +++ b/soc/arm/nxp_kinetis/k2x/soc.c @@ -120,7 +120,7 @@ static ALWAYS_INLINE void clock_init(void) * @return 0 */ -static int fsl_frdm_k22f_init(struct device *arg) +static int fsl_frdm_k22f_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/k6x/soc.c b/soc/arm/nxp_kinetis/k6x/soc.c index c8d8fbee1dd3ee..75aee6ff665aab 100644 --- a/soc/arm/nxp_kinetis/k6x/soc.c +++ b/soc/arm/nxp_kinetis/k6x/soc.c @@ -125,7 +125,7 @@ static ALWAYS_INLINE void clock_init(void) * @return 0 */ -static int k6x_init(struct device *arg) +static int k6x_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/k8x/soc.c b/soc/arm/nxp_kinetis/k8x/soc.c index 1697c9e3d80bb2..6486a711546771 100644 --- a/soc/arm/nxp_kinetis/k8x/soc.c +++ b/soc/arm/nxp_kinetis/k8x/soc.c @@ -95,7 +95,7 @@ static ALWAYS_INLINE void clk_init(void) #endif } -static int k8x_init(struct device *arg) +static int k8x_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/ke1xf/soc.c b/soc/arm/nxp_kinetis/ke1xf/soc.c index da523924797477..2e1112ceccd969 100644 --- a/soc/arm/nxp_kinetis/ke1xf/soc.c +++ b/soc/arm/nxp_kinetis/ke1xf/soc.c @@ -221,7 +221,7 @@ static ALWAYS_INLINE void clk_init(void) #endif } -static int ke1xf_init(struct device *arg) +static int ke1xf_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/kl2x/soc.c b/soc/arm/nxp_kinetis/kl2x/soc.c index 290a37521e45a7..5cbf774e64fc49 100644 --- a/soc/arm/nxp_kinetis/kl2x/soc.c +++ b/soc/arm/nxp_kinetis/kl2x/soc.c @@ -72,7 +72,7 @@ static ALWAYS_INLINE void clock_init(void) #endif } -static int kl2x_init(struct device *arg) +static int kl2x_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/kv5x/soc.c b/soc/arm/nxp_kinetis/kv5x/soc.c index ab5de986711390..6104f8b1a5ab7b 100644 --- a/soc/arm/nxp_kinetis/kv5x/soc.c +++ b/soc/arm/nxp_kinetis/kv5x/soc.c @@ -80,7 +80,7 @@ static ALWAYS_INLINE void clk_init(void) CLOCK_SetSimConfig(&sim_config); } -static int kv5x_init(struct device *arg) +static int kv5x_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/kwx/soc_kw2xd.c b/soc/arm/nxp_kinetis/kwx/soc_kw2xd.c index 57e3ea7c4faad8..00b415e1a44687 100644 --- a/soc/arm/nxp_kinetis/kwx/soc_kw2xd.c +++ b/soc/arm/nxp_kinetis/kwx/soc_kw2xd.c @@ -145,7 +145,7 @@ static ALWAYS_INLINE void clock_init(void) * * @return 0 */ -static int kw2xd_init(struct device *arg) +static int kw2xd_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_kinetis/kwx/soc_kw4xz.c b/soc/arm/nxp_kinetis/kwx/soc_kw4xz.c index 96c6e5a976fb48..1320d02f506bca 100644 --- a/soc/arm/nxp_kinetis/kwx/soc_kw4xz.c +++ b/soc/arm/nxp_kinetis/kwx/soc_kw4xz.c @@ -79,7 +79,7 @@ static ALWAYS_INLINE void clock_init(void) #endif } -static int kwx_init(struct device *arg) +static int kwx_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_lpc/lpc11u6x/soc.c b/soc/arm/nxp_lpc/lpc11u6x/soc.c index eb6e05e90d780e..6c7f4703ebe13e 100644 --- a/soc/arm/nxp_lpc/lpc11u6x/soc.c +++ b/soc/arm/nxp_lpc/lpc11u6x/soc.c @@ -30,7 +30,7 @@ * @return 0 */ -static int nxp_lpc11u6x_init(struct device *arg) +static int nxp_lpc11u6x_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.c b/soc/arm/nxp_lpc/lpc54xxx/soc.c index 5df9426c4f7b64..cce8f1acb7c25d 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.c @@ -96,7 +96,7 @@ static ALWAYS_INLINE void clock_init(void) * @return 0 */ -static int nxp_lpc54114_init(struct device *arg) +static int nxp_lpc54114_init(const struct device *arg) { ARG_UNUSED(arg); @@ -145,7 +145,7 @@ static const char core_m0[] = { * @return N/A */ /* This function is also called at deep sleep resume. */ -int _slave_init(struct device *arg) +int _slave_init(const struct device *arg) { int32_t temp; diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index a8f304feb2e493..1b3ab052bcc0d8 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -95,7 +95,7 @@ static ALWAYS_INLINE void clock_init(void) * @return 0 */ -static int nxp_lpc55xxx_init(struct device *arg) +static int nxp_lpc55xxx_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/silabs_exx32/common/soc.c b/soc/arm/silabs_exx32/common/soc.c index 0f5f8c4862b29e..4b54ba103b4312 100644 --- a/soc/arm/silabs_exx32/common/soc.c +++ b/soc/arm/silabs_exx32/common/soc.c @@ -183,7 +183,7 @@ static void swo_init(void) * * @return 0 */ -static int silabs_exx32_init(struct device *arg) +static int silabs_exx32_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/st_stm32/stm32f0/soc.c b/soc/arm/st_stm32/stm32f0/soc.c index 23ca8fe52a3475..ea6ed29bbc3b9e 100644 --- a/soc/arm/st_stm32/stm32f0/soc.c +++ b/soc/arm/st_stm32/stm32f0/soc.c @@ -54,7 +54,7 @@ void relocate_vector_table(void) * * @return 0 */ -static int stm32f0_init(struct device *arg) +static int stm32f0_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32f1/soc.c b/soc/arm/st_stm32/stm32f1/soc.c index c7ffd03418b904..009a0058bc678e 100644 --- a/soc/arm/st_stm32/stm32f1/soc.c +++ b/soc/arm/st_stm32/stm32f1/soc.c @@ -22,7 +22,7 @@ * * @return 0 */ -static int stm32f1_init(struct device *arg) +static int stm32f1_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32f2/soc.c b/soc/arm/st_stm32/stm32f2/soc.c index f238ebc71ba025..e95c37cdb08f01 100644 --- a/soc/arm/st_stm32/stm32f2/soc.c +++ b/soc/arm/st_stm32/stm32f2/soc.c @@ -26,7 +26,7 @@ * * @return 0 */ -static int stm32f2_init(struct device *arg) +static int stm32f2_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32f3/soc.c b/soc/arm/st_stm32/stm32f3/soc.c index fa1d116b74eb2e..a9f839ebdbcef5 100644 --- a/soc/arm/st_stm32/stm32f3/soc.c +++ b/soc/arm/st_stm32/stm32f3/soc.c @@ -22,7 +22,7 @@ * * @return 0 */ -static int stm32f3_init(struct device *arg) +static int stm32f3_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32f4/soc.c b/soc/arm/st_stm32/stm32f4/soc.c index 0a2f3e8e9f479a..03882e322485d8 100644 --- a/soc/arm/st_stm32/stm32f4/soc.c +++ b/soc/arm/st_stm32/stm32f4/soc.c @@ -23,7 +23,7 @@ * * @return 0 */ -static int st_stm32f4_init(struct device *arg) +static int st_stm32f4_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32f7/soc.c b/soc/arm/st_stm32/stm32f7/soc.c index 0b39fbbb04838a..f749dce733db5b 100644 --- a/soc/arm/st_stm32/stm32f7/soc.c +++ b/soc/arm/st_stm32/stm32f7/soc.c @@ -24,7 +24,7 @@ * * @return 0 */ -static int st_stm32f7_init(struct device *arg) +static int st_stm32f7_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32g0/soc.c b/soc/arm/st_stm32/stm32g0/soc.c index 354f602fd29094..48bec1369f49ea 100644 --- a/soc/arm/st_stm32/stm32g0/soc.c +++ b/soc/arm/st_stm32/stm32g0/soc.c @@ -25,7 +25,7 @@ * * @return 0 */ -static int stm32g0_init(struct device *arg) +static int stm32g0_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32g4/soc.c b/soc/arm/st_stm32/stm32g4/soc.c index 906e48932308f4..8959de1e2c860b 100644 --- a/soc/arm/st_stm32/stm32g4/soc.c +++ b/soc/arm/st_stm32/stm32g4/soc.c @@ -22,7 +22,7 @@ * * @return 0 */ -static int stm32g4_init(struct device *arg) +static int stm32g4_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32h7/soc_m4.c b/soc/arm/st_stm32/stm32h7/soc_m4.c index e55a2fa8415cd2..3b2d678290b844 100644 --- a/soc/arm/st_stm32/stm32h7/soc_m4.c +++ b/soc/arm/st_stm32/stm32h7/soc_m4.c @@ -58,7 +58,7 @@ void stm32h7_m4_boot_stop(void) * * @return 0 */ -static int stm32h7_m4_init(struct device *arg) +static int stm32h7_m4_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32h7/soc_m7.c b/soc/arm/st_stm32/stm32h7/soc_m7.c index 7304d9241fdd64..3cb14dc3b126db 100644 --- a/soc/arm/st_stm32/stm32h7/soc_m7.c +++ b/soc/arm/st_stm32/stm32h7/soc_m7.c @@ -18,7 +18,7 @@ #include "stm32_hsem.h" #if defined(CONFIG_STM32H7_DUAL_CORE) -static int stm32h7_m4_wakeup(struct device *arg) +static int stm32h7_m4_wakeup(const struct device *arg) { /* HW semaphore and SysCfg Clock enable */ @@ -66,7 +66,7 @@ static int stm32h7_m4_wakeup(struct device *arg) * * @return 0 */ -static int stm32h7_init(struct device *arg) +static int stm32h7_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32l0/soc.c b/soc/arm/st_stm32/stm32l0/soc.c index afde0b6fbec4b7..cfc23ede3752ad 100644 --- a/soc/arm/st_stm32/stm32l0/soc.c +++ b/soc/arm/st_stm32/stm32l0/soc.c @@ -24,7 +24,7 @@ * * @return 0 */ -static int stm32l0_init(struct device *arg) +static int stm32l0_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32l1/soc.c b/soc/arm/st_stm32/stm32l1/soc.c index 77b30dde266f4a..b6baba07a17186 100644 --- a/soc/arm/st_stm32/stm32l1/soc.c +++ b/soc/arm/st_stm32/stm32l1/soc.c @@ -24,7 +24,7 @@ * * @return 0 */ -static int stm32l1_init(struct device *arg) +static int stm32l1_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32l4/power.c b/soc/arm/st_stm32/stm32l4/power.c index c2fd91f013af21..bcb4fb4c49c37f 100644 --- a/soc/arm/st_stm32/stm32l4/power.c +++ b/soc/arm/st_stm32/stm32l4/power.c @@ -109,7 +109,7 @@ void _sys_pm_power_state_exit_post_ops(enum power_states state) } /* Initialize STM32 Power */ -static int stm32_power_init(struct device *dev) +static int stm32_power_init(const struct device *dev) { unsigned int ret; diff --git a/soc/arm/st_stm32/stm32l4/soc.c b/soc/arm/st_stm32/stm32l4/soc.c index 833dca735229a2..d2399c99feebf6 100644 --- a/soc/arm/st_stm32/stm32l4/soc.c +++ b/soc/arm/st_stm32/stm32l4/soc.c @@ -23,7 +23,7 @@ * * @return 0 */ -static int stm32l4_init(struct device *arg) +static int stm32l4_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32l5/soc.c b/soc/arm/st_stm32/stm32l5/soc.c index 68cce1005b1470..f7cc4ff8ffb1ea 100644 --- a/soc/arm/st_stm32/stm32l5/soc.c +++ b/soc/arm/st_stm32/stm32l5/soc.c @@ -22,7 +22,7 @@ * * @return 0 */ -static int stm32l5_init(struct device *arg) +static int stm32l5_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32mp1/soc.c b/soc/arm/st_stm32/stm32mp1/soc.c index 2ff68bc2bb9b27..6c19c985fc4227 100644 --- a/soc/arm/st_stm32/stm32mp1/soc.c +++ b/soc/arm/st_stm32/stm32mp1/soc.c @@ -24,7 +24,7 @@ * * @return 0 */ -static int stm32m4_init(struct device *arg) +static int stm32m4_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/st_stm32/stm32wb/soc.c b/soc/arm/st_stm32/stm32wb/soc.c index c8fb3c5ffe9043..3737eccd32dcc4 100644 --- a/soc/arm/st_stm32/stm32wb/soc.c +++ b/soc/arm/st_stm32/stm32wb/soc.c @@ -22,7 +22,7 @@ * * @return 0 */ -static int stm32wb_init(struct device *arg) +static int stm32wb_init(const struct device *arg) { uint32_t key; diff --git a/soc/arm/ti_lm3s6965/soc.c b/soc/arm/ti_lm3s6965/soc.c index 402a84db29a41a..116d31610485b1 100644 --- a/soc/arm/ti_lm3s6965/soc.c +++ b/soc/arm/ti_lm3s6965/soc.c @@ -30,7 +30,7 @@ * @return 0 */ -static int ti_lm3s6965_init(struct device *arg) +static int ti_lm3s6965_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/ti_lm3s6965/soc_config.c b/soc/arm/ti_lm3s6965/soc_config.c index e23267b4ffe3c3..e57a36c161ad40 100644 --- a/soc/arm/ti_lm3s6965/soc_config.c +++ b/soc/arm/ti_lm3s6965/soc_config.c @@ -24,7 +24,7 @@ #define RCGC1_UART1_EN 0x00000002 #define RCGC1_UART2_EN 0x00000004 -static int uart_stellaris_init(struct device *dev) +static int uart_stellaris_init(const struct device *dev) { #ifdef CONFIG_UART_STELLARIS_PORT_0 RCGC1 |= RCGC1_UART0_EN; @@ -52,7 +52,7 @@ SYS_INIT(uart_stellaris_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); #define RCGC2_PHY_EN 0x40000000 #define RCGC2_EMAC_EN 0x10000000 -static int eth_stellaris_init(struct device *dev) +static int eth_stellaris_init(const struct device *dev) { RCGC2 |= (RCGC2_PHY_EN | RCGC2_EMAC_EN); return 0; diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c b/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c index 2d9dacf09e0878..d30e3a77209bd1 100644 --- a/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/power.c @@ -126,7 +126,7 @@ void _sys_pm_power_state_exit_post_ops(enum power_states state) } /* Initialize TI Power module */ -static int power_initialize(struct device *dev) +static int power_initialize(const struct device *dev) { unsigned int ret; @@ -144,7 +144,7 @@ static int power_initialize(struct device *dev) * This needs to be called during POST_KERNEL in order for "Booting Zephyr" * message to show up */ -static int unlatch_pins(struct device *dev) +static int unlatch_pins(const struct device *dev) { /* Get the reason for reset. */ uint32_t rSrc = SysCtrlResetSourceGet(); diff --git a/soc/arm/ti_simplelink/cc13x2_cc26x2/soc.c b/soc/arm/ti_simplelink/cc13x2_cc26x2/soc.c index 210ac1fa183ac8..7ddd376378c5a5 100644 --- a/soc/arm/ti_simplelink/cc13x2_cc26x2/soc.c +++ b/soc/arm/ti_simplelink/cc13x2_cc26x2/soc.c @@ -8,7 +8,7 @@ #include -static int ti_cc13x2_cc26x2_init(struct device *dev) +static int ti_cc13x2_cc26x2_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/arm/ti_simplelink/cc32xx/soc.c b/soc/arm/ti_simplelink/cc32xx/soc.c index d655be7a313fbe..3d9055e4373180 100644 --- a/soc/arm/ti_simplelink/cc32xx/soc.c +++ b/soc/arm/ti_simplelink/cc32xx/soc.c @@ -12,7 +12,7 @@ #include #include -static int ti_cc32xx_init(struct device *arg) +static int ti_cc32xx_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/ti_simplelink/msp432p4xx/soc.c b/soc/arm/ti_simplelink/msp432p4xx/soc.c index 185157816bff1a..471179779bad9a 100644 --- a/soc/arm/ti_simplelink/msp432p4xx/soc.c +++ b/soc/arm/ti_simplelink/msp432p4xx/soc.c @@ -9,7 +9,7 @@ #include #include -static int ti_msp432p4xx_init(struct device *arg) +static int ti_msp432p4xx_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/arm/xilinx_zynqmp/soc.c b/soc/arm/xilinx_zynqmp/soc.c index 1e621c95a042bd..0732e4d161e223 100644 --- a/soc/arm/xilinx_zynqmp/soc.c +++ b/soc/arm/xilinx_zynqmp/soc.c @@ -17,7 +17,7 @@ * @return 0 */ -static int soc_init(struct device *arg) +static int soc_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/soc/riscv/openisa_rv32m1/soc.c b/soc/riscv/openisa_rv32m1/soc.c index c21336864ead97..ee9c730869f36c 100644 --- a/soc/riscv/openisa_rv32m1/soc.c +++ b/soc/riscv/openisa_rv32m1/soc.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(soc); #define SCG_LPFLL_DISABLE 0U -static struct device *dev_intmux; +static const struct device *dev_intmux; /* * Run-mode configuration for the fast internal reference clock (FIRC). @@ -218,7 +218,7 @@ static void rv32m1_setup_peripheral_clocks(void) * * @return 0 */ -static int soc_rv32m1_init(struct device *arg) +static int soc_rv32m1_init(const struct device *arg) { unsigned int key; diff --git a/soc/riscv/riscv-privilege/sifive-freedom/fe310_clock.c b/soc/riscv/riscv-privilege/sifive-freedom/fe310_clock.c index 4814bc5bc0afde..bedb3c8da15645 100644 --- a/soc/riscv/riscv-privilege/sifive-freedom/fe310_clock.c +++ b/soc/riscv/riscv-privilege/sifive-freedom/fe310_clock.c @@ -11,7 +11,7 @@ /* Selects the 16MHz oscilator on the HiFive1 board, which provides a clock * that's accurate enough to actually drive serial ports off of. */ -static int fe310_clock_init(struct device *dev) +static int fe310_clock_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/soc/xtensa/intel_apl_adsp/adsp.c b/soc/xtensa/intel_apl_adsp/adsp.c index cdc58b8106089b..9220fe691c1f90 100644 --- a/soc/xtensa/intel_apl_adsp/adsp.c +++ b/soc/xtensa/intel_apl_adsp/adsp.c @@ -114,7 +114,7 @@ static void send_fw_ready(void) ipc_write(IPC_DIPCI, (0x80000000 | ADSP_IPC_FW_READY)); } -static int adsp_init(struct device *dev) +static int adsp_init(const struct device *dev) { prepare_host_windows(); diff --git a/soc/xtensa/intel_apl_adsp/soc.c b/soc/xtensa/intel_apl_adsp/soc.c index 4fccad5c2f9cdd..7f3c7a555f8a63 100644 --- a/soc/xtensa/intel_apl_adsp/soc.c +++ b/soc/xtensa/intel_apl_adsp/soc.c @@ -25,7 +25,7 @@ LOG_MODULE_REGISTER(soc); void z_soc_irq_enable(uint32_t irq) { - struct device *dev_cavs; + const struct device *dev_cavs; switch (XTENSA_IRQ_NUMBER(irq)) { case DT_IRQN(CAVS_INTC_NODE(0)): @@ -63,7 +63,7 @@ void z_soc_irq_enable(uint32_t irq) void z_soc_irq_disable(uint32_t irq) { - struct device *dev_cavs; + const struct device *dev_cavs; switch (XTENSA_IRQ_NUMBER(irq)) { case DT_IRQN(CAVS_INTC_NODE(0)): @@ -103,7 +103,7 @@ void z_soc_irq_disable(uint32_t irq) int z_soc_irq_is_enabled(unsigned int irq) { - struct device *dev_cavs; + const struct device *dev_cavs; int ret = 0; switch (XTENSA_IRQ_NUMBER(irq)) { @@ -226,7 +226,7 @@ static inline void soc_set_power_and_clock(void) dsp_shim_regs->lpsctl = dsp_shim_regs->lpsctl; } -static int soc_init(struct device *dev) +static int soc_init(const struct device *dev) { soc_set_power_and_clock(); diff --git a/soc/xtensa/intel_apl_adsp/soc_mp.c b/soc/xtensa/intel_apl_adsp/soc_mp.c index 671307238a50ae..2b0d0499391ab8 100644 --- a/soc/xtensa/intel_apl_adsp/soc_mp.c +++ b/soc/xtensa/intel_apl_adsp/soc_mp.c @@ -49,7 +49,7 @@ LOG_MODULE_REGISTER(soc_mp, CONFIG_SOC_LOG_LEVEL); #define IDC_MSG_POWER_UP_EXT(x) IDC_EXTENSION((x) >> 2) -static struct device *idc; +static const struct device *idc; #endif extern void __start(void); diff --git a/soc/xtensa/intel_s1000/soc.c b/soc/xtensa/intel_s1000/soc.c index d7dcc33378cd25..0883ddfad5ebfc 100644 --- a/soc/xtensa/intel_s1000/soc.c +++ b/soc/xtensa/intel_s1000/soc.c @@ -23,7 +23,7 @@ static uint32_t ref_clk_freq; void z_soc_irq_enable(uint32_t irq) { - struct device *dev_cavs, *dev_ictl; + const struct device *dev_cavs, *dev_ictl; switch (XTENSA_IRQ_NUMBER(irq)) { case DT_IRQN(CAVS_INTC_NODE(0)): @@ -82,7 +82,7 @@ void z_soc_irq_enable(uint32_t irq) void z_soc_irq_disable(uint32_t irq) { - struct device *dev_cavs, *dev_ictl; + const struct device *dev_cavs, *dev_ictl; switch (XTENSA_IRQ_NUMBER(irq)) { case DT_IRQN(CAVS_INTC_NODE(0)): @@ -151,7 +151,7 @@ void z_soc_irq_disable(uint32_t irq) int z_soc_irq_is_enabled(unsigned int irq) { - struct device *dev_cavs, *dev_ictl; + const struct device *dev_cavs, *dev_ictl; int ret = -EINVAL; switch (XTENSA_IRQ_NUMBER(irq)) { @@ -317,7 +317,7 @@ static inline void soc_read_bootstraps(void) } } -static int soc_init(struct device *dev) +static int soc_init(const struct device *dev) { soc_read_bootstraps(); diff --git a/soc/xtensa/intel_s1000/soc_mp.c b/soc/xtensa/intel_s1000/soc_mp.c index 74c6d7c769b9ae..b48ba7de09a005 100644 --- a/soc/xtensa/intel_s1000/soc_mp.c +++ b/soc/xtensa/intel_s1000/soc_mp.c @@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(soc_mp, CONFIG_SOC_LOG_LEVEL); #include #include -static struct device *idc; +static const struct device *idc; #endif extern void __start(void); diff --git a/subsys/bluetooth/controller/hci/hci_driver.c b/subsys/bluetooth/controller/hci/hci_driver.c index bf0ce07399ff55..cf961ae8268cad 100644 --- a/subsys/bluetooth/controller/hci/hci_driver.c +++ b/subsys/bluetooth/controller/hci/hci_driver.c @@ -523,7 +523,7 @@ static const struct bt_hci_driver drv = { .send = hci_driver_send, }; -static int hci_driver_init(struct device *unused) +static int hci_driver_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c index c2b5c4f03d6510..6639242c76e7d2 100644 --- a/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/nordic/lll/lll.c @@ -49,7 +49,7 @@ static struct { } event; /* Entropy device */ -static struct device *dev_entropy; +static const struct device *dev_entropy; static int init_reset(void); static int prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb, diff --git a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h index a87978678504a0..299509dc10024a 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h +++ b/subsys/bluetooth/controller/ll_sw/openisa/hal/RV32M1/debug.h @@ -31,9 +31,9 @@ #include -extern struct device *vega_debug_portb; -extern struct device *vega_debug_portc; -extern struct device *vega_debug_portd; +extern const struct device *vega_debug_portb; +extern const struct device *vega_debug_portc; +extern const struct device *vega_debug_portd; #define DEBUG0_PIN 5 #define DEBUG0_PORT vega_debug_portd diff --git a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c index 11dd89d2a306d6..43faa27c1e74ba 100644 --- a/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c +++ b/subsys/bluetooth/controller/ll_sw/openisa/lll/lll.c @@ -42,11 +42,11 @@ static struct { } event; static struct { - struct device *clk; + const struct device *clk; } lll; /* Entropy device */ -static struct device *dev_entropy; +static const struct device *dev_entropy; static int init_reset(void); static int prepare(lll_is_abort_cb_t is_abort_cb, lll_abort_cb_t abort_cb, @@ -110,7 +110,7 @@ static void swi_ull_low_rv32m1_isr(void *arg) int lll_init(void) { - struct device *clk_k32; + const struct device *clk_k32; int err; ARG_UNUSED(clk_k32); diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index a0a79c06ad6606..d0dda9d789c9eb 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -45,7 +45,7 @@ /* Maximum (string) length of a log message */ #define MONITOR_MSG_MAX 128 -static struct device *monitor_dev; +static const struct device *monitor_dev; enum { BT_LOG_BUSY, @@ -322,7 +322,7 @@ static const struct log_backend_api monitor_log_api = { LOG_BACKEND_DEFINE(bt_monitor, monitor_log_api, true); #endif /* CONFIG_LOG_MINIMAL */ -static int bt_monitor_init(struct device *d) +static int bt_monitor_init(const struct device *d) { ARG_UNUSED(d); diff --git a/subsys/bluetooth/services/bas.c b/subsys/bluetooth/services/bas.c index 60220920a46568..e1a5422fd44991 100644 --- a/subsys/bluetooth/services/bas.c +++ b/subsys/bluetooth/services/bas.c @@ -57,7 +57,7 @@ BT_GATT_SERVICE_DEFINE(bas, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), ); -static int bas_init(struct device *dev) +static int bas_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/bluetooth/services/hrs.c b/subsys/bluetooth/services/hrs.c index ebefe3b73feac6..9bbc4ddfb371b4 100644 --- a/subsys/bluetooth/services/hrs.c +++ b/subsys/bluetooth/services/hrs.c @@ -56,7 +56,7 @@ BT_GATT_SERVICE_DEFINE(hrs_svc, BT_GATT_PERM_NONE, NULL, NULL, NULL), ); -static int hrs_init(struct device *dev) +static int hrs_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/canbus/canopen/CO_driver.c b/subsys/canbus/canopen/CO_driver.c index 7ed7e434c7b898..f89e5e8459927a 100644 --- a/subsys/canbus/canopen/CO_driver.c +++ b/subsys/canbus/canopen/CO_driver.c @@ -463,7 +463,7 @@ void CO_CANverifyErrors(CO_CANmodule_t *CANmodule) } } -static int canopen_init(struct device *dev) +static int canopen_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/canbus/canopen/CO_driver_target.h b/subsys/canbus/canopen/CO_driver_target.h index 686c6bec4e2d16..16afaa0bdc0f38 100644 --- a/subsys/canbus/canopen/CO_driver_target.h +++ b/subsys/canbus/canopen/CO_driver_target.h @@ -80,7 +80,7 @@ typedef struct canopen_tx { } CO_CANtx_t; typedef struct canopen_module { - struct device *dev; + const struct device *dev; CO_CANrx_t *rx_array; CO_CANtx_t *tx_array; uint16_t rx_size; diff --git a/subsys/canbus/isotp/isotp.c b/subsys/canbus/isotp/isotp.c index 3b025468ecc8f3..7515067714df84 100644 --- a/subsys/canbus/isotp/isotp.c +++ b/subsys/canbus/isotp/isotp.c @@ -547,7 +547,7 @@ static inline int attach_ff_filter(struct isotp_recv_ctx *ctx) return 0; } -int isotp_bind(struct isotp_recv_ctx *ctx, struct device *can_dev, +int isotp_bind(struct isotp_recv_ctx *ctx, const struct device *can_dev, const struct isotp_msg_id *rx_addr, const struct isotp_msg_id *tx_addr, const struct isotp_fc_opts *opts, @@ -1096,7 +1096,7 @@ static inline int attach_fc_filter(struct isotp_send_ctx *ctx) return 0; } -static int send(struct isotp_send_ctx *ctx, struct device *can_dev, +static int send(struct isotp_send_ctx *ctx, const struct device *can_dev, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, isotp_tx_callback_t complete_cb, void *cb_arg) @@ -1159,7 +1159,7 @@ static int send(struct isotp_send_ctx *ctx, struct device *can_dev, return ISOTP_N_OK; } -int isotp_send(struct isotp_send_ctx *ctx, struct device *can_dev, +int isotp_send(struct isotp_send_ctx *ctx, const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -1175,7 +1175,7 @@ int isotp_send(struct isotp_send_ctx *ctx, struct device *can_dev, #ifdef CONFIG_ISOTP_ENABLE_CONTEXT_BUFFERS -int isotp_send_ctx_buf(struct device *can_dev, +int isotp_send_ctx_buf(const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -1199,7 +1199,7 @@ int isotp_send_ctx_buf(struct device *can_dev, return send(ctx, can_dev, tx_addr, rx_addr, complete_cb, cb_arg); } -int isotp_send_net_ctx_buf(struct device *can_dev, +int isotp_send_net_ctx_buf(const struct device *can_dev, struct net_buf *data, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -1223,7 +1223,7 @@ int isotp_send_net_ctx_buf(struct device *can_dev, } #ifdef CONFIG_ISOTP_USE_TX_BUF -int isotp_send_buf(struct device *can_dev, +int isotp_send_buf(const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, @@ -1257,7 +1257,7 @@ int isotp_send_buf(struct device *can_dev, #endif /*CONFIG_ISOTP_USE_TX_BUF*/ #endif /*CONFIG_ISOTP_ENABLE_CONTEXT_BUFFERS*/ -static int isotp_workq_init(struct device *dev) +static int isotp_workq_init(const struct device *dev) { ARG_UNUSED(dev); LOG_DBG("Starting workqueue"); diff --git a/subsys/console/getchar.c b/subsys/console/getchar.c index 1741b03627aee3..f9434f5f09b155 100644 --- a/subsys/console/getchar.c +++ b/subsys/console/getchar.c @@ -49,7 +49,7 @@ int console_getchar(void) int console_init(void) { - struct device *uart_dev; + const struct device *uart_dev; int ret; uart_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); diff --git a/subsys/console/tty.c b/subsys/console/tty.c index 6302b6dbb7855f..a6256cf8518dbd 100644 --- a/subsys/console/tty.c +++ b/subsys/console/tty.c @@ -12,7 +12,7 @@ static int tty_irq_input_hook(struct tty_serial *tty, uint8_t c); static int tty_putchar(struct tty_serial *tty, uint8_t c); -static void tty_uart_isr(struct device *dev, void *user_data) +static void tty_uart_isr(const struct device *dev, void *user_data) { struct tty_serial *tty = user_data; @@ -238,7 +238,7 @@ ssize_t tty_read(struct tty_serial *tty, void *buf, size_t size) return out_size; } -int tty_init(struct tty_serial *tty, struct device *uart_dev) +int tty_init(struct tty_serial *tty, const struct device *uart_dev) { if (!uart_dev) { return -ENODEV; diff --git a/subsys/dfu/img_util/flash_img.c b/subsys/dfu/img_util/flash_img.c index e2191fc18c881e..77d0414dd1840c 100644 --- a/subsys/dfu/img_util/flash_img.c +++ b/subsys/dfu/img_util/flash_img.c @@ -64,7 +64,7 @@ size_t flash_img_bytes_written(struct flash_img_context *ctx) int flash_img_init_id(struct flash_img_context *ctx, uint8_t area_id) { int rc; - struct device *flash_dev; + const struct device *flash_dev; rc = flash_area_open(area_id, (const struct flash_area **)&(ctx->flash_area)); diff --git a/subsys/disk/disk_access.c b/subsys/disk/disk_access.c index 3d119088881489..37cdfac55bae09 100644 --- a/subsys/disk/disk_access.c +++ b/subsys/disk/disk_access.c @@ -169,7 +169,7 @@ int disk_access_unregister(struct disk_info *disk) return rc; } -static int disk_init(struct device *dev) +static int disk_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/disk/disk_access_flash.c b/subsys/disk/disk_access_flash.c index b89237e3a5330c..fe9937281052eb 100644 --- a/subsys/disk/disk_access_flash.c +++ b/subsys/disk/disk_access_flash.c @@ -16,7 +16,7 @@ #define SECTOR_SIZE 512 -static struct device *flash_dev; +static const struct device *flash_dev; /* flash read-copy-erase-write operation */ static uint8_t __aligned(4) read_copy_buf[CONFIG_DISK_ERASE_BLOCK_SIZE]; @@ -289,7 +289,7 @@ static struct disk_info flash_disk = { .ops = &flash_disk_ops, }; -static int disk_flash_init(struct device *dev) +static int disk_flash_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/disk/disk_access_ram.c b/subsys/disk/disk_access_ram.c index d3a056015b0cfb..a9222ab70f8a4e 100644 --- a/subsys/disk/disk_access_ram.c +++ b/subsys/disk/disk_access_ram.c @@ -95,7 +95,7 @@ static struct disk_info ram_disk = { .ops = &ram_disk_ops, }; -static int disk_ram_init(struct device *dev) +static int disk_ram_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/disk/disk_access_spi_sdhc.c b/subsys/disk/disk_access_spi_sdhc.c index d2c118d60f1029..5d59225735b3ee 100644 --- a/subsys/disk/disk_access_spi_sdhc.c +++ b/subsys/disk/disk_access_spi_sdhc.c @@ -26,7 +26,7 @@ LOG_MODULE_REGISTER(sdhc_spi, CONFIG_DISK_LOG_LEVEL); #warning NO SDHC slot specified on board #else struct sdhc_spi_data { - struct device *spi; + const struct device *spi; struct spi_config cfg; #if DT_SPI_DEV_HAS_CS_GPIOS(SPI_SDHC_NODE) struct spi_cs_control cs; @@ -748,9 +748,9 @@ static int sdhc_spi_write(struct sdhc_spi_data *data, return err; } -static int disk_spi_sdhc_init(struct device *dev); +static int disk_spi_sdhc_init(const struct device *dev); -static int sdhc_spi_init(struct device *dev) +static int sdhc_spi_init(const struct device *dev) { struct sdhc_spi_data *data = dev->data; @@ -777,7 +777,7 @@ static int sdhc_spi_init(struct device *dev) static int disk_spi_sdhc_access_status(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct sdhc_spi_data *data = dev->data; return data->status; @@ -786,7 +786,7 @@ static int disk_spi_sdhc_access_status(struct disk_info *disk) static int disk_spi_sdhc_access_read(struct disk_info *disk, uint8_t *buf, uint32_t sector, uint32_t count) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct sdhc_spi_data *data = dev->data; int err; @@ -804,7 +804,7 @@ static int disk_spi_sdhc_access_read(struct disk_info *disk, static int disk_spi_sdhc_access_write(struct disk_info *disk, const uint8_t *buf, uint32_t sector, uint32_t count) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct sdhc_spi_data *data = dev->data; int err; @@ -822,7 +822,7 @@ static int disk_spi_sdhc_access_write(struct disk_info *disk, static int disk_spi_sdhc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buf) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct sdhc_spi_data *data = dev->data; int err; @@ -852,7 +852,7 @@ static int disk_spi_sdhc_access_ioctl(struct disk_info *disk, static int disk_spi_sdhc_access_init(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct sdhc_spi_data *data = dev->data; int err; @@ -875,7 +875,7 @@ static struct disk_info spi_sdhc_disk = { .ops = &spi_sdhc_disk_ops, }; -static int disk_spi_sdhc_init(struct device *dev) +static int disk_spi_sdhc_init(const struct device *dev) { struct sdhc_spi_data *data = dev->data; diff --git a/subsys/disk/disk_access_stm32_sdmmc.c b/subsys/disk/disk_access_stm32_sdmmc.c index 15ed86c77f901a..70085d56079d11 100644 --- a/subsys/disk/disk_access_stm32_sdmmc.c +++ b/subsys/disk/disk_access_stm32_sdmmc.c @@ -23,13 +23,13 @@ struct stm32_sdmmc_priv { struct gpio_callback cd_cb; struct { const char *name; - struct device *port; + const struct device *port; int pin; int flags; } cd; struct { const char *name; - struct device *port; + const struct device *port; int pin; int flags; } pe; @@ -38,7 +38,7 @@ struct stm32_sdmmc_priv { static int stm32_sdmmc_clock_enable(struct stm32_sdmmc_priv *priv) { - struct device *clock; + const struct device *clock; #if CONFIG_SOC_SERIES_STM32L4X LL_RCC_PLLSAI1_Disable(); @@ -71,7 +71,7 @@ static int stm32_sdmmc_clock_enable(struct stm32_sdmmc_priv *priv) static int stm32_sdmmc_clock_disable(struct stm32_sdmmc_priv *priv) { - struct device *clock; + const struct device *clock; clock = device_get_binding(STM32_CLOCK_CONTROL_NAME); if (!clock) { @@ -84,7 +84,7 @@ static int stm32_sdmmc_clock_disable(struct stm32_sdmmc_priv *priv) static int stm32_sdmmc_access_init(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct stm32_sdmmc_priv *priv = dev->data; int err; @@ -120,7 +120,7 @@ static void stm32_sdmmc_access_deinit(struct stm32_sdmmc_priv *priv) static int stm32_sdmmc_access_status(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct stm32_sdmmc_priv *priv = dev->data; return priv->status; @@ -129,7 +129,7 @@ static int stm32_sdmmc_access_status(struct disk_info *disk) static int stm32_sdmmc_access_read(struct disk_info *disk, uint8_t *data_buf, uint32_t start_sector, uint32_t num_sector) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct stm32_sdmmc_priv *priv = dev->data; int err; @@ -150,7 +150,7 @@ static int stm32_sdmmc_access_write(struct disk_info *disk, const uint8_t *data_buf, uint32_t start_sector, uint32_t num_sector) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct stm32_sdmmc_priv *priv = dev->data; int err; @@ -169,7 +169,7 @@ static int stm32_sdmmc_access_write(struct disk_info *disk, static int stm32_sdmmc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buff) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct stm32_sdmmc_priv *priv = dev->data; HAL_SD_CardInfoTypeDef info; int err; @@ -251,7 +251,7 @@ static void stm32_sdmmc_cd_handler(struct k_work *item) } } -static void stm32_sdmmc_cd_callback(struct device *gpiodev, +static void stm32_sdmmc_cd_callback(const struct device *gpiodev, struct gpio_callback *cb, uint32_t pin) { @@ -350,7 +350,7 @@ static int stm32_sdmmc_pwr_uninit(struct stm32_sdmmc_priv *priv) return 0; } -static int disk_stm32_sdmmc_init(struct device *dev) +static int disk_stm32_sdmmc_init(const struct device *dev) { struct stm32_sdmmc_priv *priv = dev->data; int err; diff --git a/subsys/disk/disk_access_usdhc.c b/subsys/disk/disk_access_usdhc.c index a9fbf760dc85c9..cde0ba4f24db80 100644 --- a/subsys/disk/disk_access_usdhc.c +++ b/subsys/disk/disk_access_usdhc.c @@ -453,14 +453,14 @@ struct usdhc_priv { bool host_ready; uint8_t status; - struct device *pwr_gpio; - struct device *detect_gpio; + const struct device *pwr_gpio; + const struct device *detect_gpio; struct gpio_callback detect_cb; enum host_detect_type detect_type; bool inserted; - struct device *clock_dev; + const struct device *clock_dev; uint32_t src_clk_hz; const struct usdhc_config *config; @@ -2223,7 +2223,7 @@ static void usdhc_host_hw_init(USDHC_Type *base, } -static void usdhc_cd_gpio_cb(struct device *dev, +static void usdhc_cd_gpio_cb(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct usdhc_priv *priv = @@ -2233,9 +2233,9 @@ static void usdhc_cd_gpio_cb(struct device *dev, gpio_pin_interrupt_configure(dev, config->detect_pin, GPIO_INT_DISABLE); } -static int usdhc_cd_gpio_init(struct device *detect_gpio, - uint32_t pin, gpio_dt_flags_t flags, - struct gpio_callback *callback) +static int usdhc_cd_gpio_init(const struct device *detect_gpio, + uint32_t pin, gpio_dt_flags_t flags, + struct gpio_callback *callback) { int ret; @@ -2708,7 +2708,7 @@ static int usdhc_access_init(const struct device *dev) static int disk_usdhc_access_status(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct usdhc_priv *priv = dev->data; return priv->status; @@ -2717,7 +2717,7 @@ static int disk_usdhc_access_status(struct disk_info *disk) static int disk_usdhc_access_read(struct disk_info *disk, uint8_t *buf, uint32_t sector, uint32_t count) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct usdhc_priv *priv = dev->data; LOG_DBG("sector=%u count=%u", sector, count); @@ -2728,7 +2728,7 @@ static int disk_usdhc_access_read(struct disk_info *disk, uint8_t *buf, static int disk_usdhc_access_write(struct disk_info *disk, const uint8_t *buf, uint32_t sector, uint32_t count) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct usdhc_priv *priv = dev->data; LOG_DBG("sector=%u count=%u", sector, count); @@ -2738,7 +2738,7 @@ static int disk_usdhc_access_write(struct disk_info *disk, const uint8_t *buf, static int disk_usdhc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *buf) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct usdhc_priv *priv = dev->data; int err; @@ -2768,7 +2768,7 @@ static int disk_usdhc_access_ioctl(struct disk_info *disk, uint8_t cmd, void *bu static int disk_usdhc_access_init(struct disk_info *disk) { - struct device *dev = disk->dev; + const struct device *dev = disk->dev; struct usdhc_priv *priv = dev->data; if (priv->status == DISK_STATUS_OK) { @@ -2792,7 +2792,7 @@ static struct disk_info usdhc_disk = { .ops = &usdhc_disk_ops, }; -static int disk_usdhc_init(struct device *dev) +static int disk_usdhc_init(const struct device *dev) { struct usdhc_priv *priv = dev->data; diff --git a/subsys/emul/emul.c b/subsys/emul/emul.c index 3fb8c6476bc688..9c484920261637 100644 --- a/subsys/emul/emul.c +++ b/subsys/emul/emul.c @@ -33,7 +33,7 @@ emul_find_by_link(const struct emul_link_for_bus *emul) return NULL; } -int emul_init_for_bus_from_list(struct device *dev, +int emul_init_for_bus_from_list(const struct device *dev, const struct emul_list_for_bus *list) { const struct emul_list_for_bus *cfg = dev->config; diff --git a/subsys/emul/i2c/emul_atmel_at24.c b/subsys/emul/i2c/emul_atmel_at24.c index a431eec15828f7..c8f70ae5347bfd 100644 --- a/subsys/emul/i2c/emul_atmel_at24.c +++ b/subsys/emul/i2c/emul_atmel_at24.c @@ -21,7 +21,7 @@ struct at24_emul_data { /** I2C emulator detail */ struct i2c_emul emul; /** AT24 device being emulated */ - struct device *i2c; + const struct device *i2c; /** Configuration information */ const struct at24_emul_cfg *cfg; /** Current register to read (address) */ @@ -137,7 +137,8 @@ static struct i2c_emul_api at24_emul_api = { * @param parent Device to emulate (must use AT24 driver) * @return 0 indicating success (always) */ -static int emul_atmel_at24_init(const struct emul *emul, struct device *parent) +static int emul_atmel_at24_init(const struct emul *emul, + const struct device *parent) { const struct at24_emul_cfg *cfg = emul->cfg; struct at24_emul_data *data = cfg->data; diff --git a/subsys/fb/cfb.c b/subsys/fb/cfb.c index aa196f33b3c2f2..ea5691a4498954 100644 --- a/subsys/fb/cfb.c +++ b/subsys/fb/cfb.c @@ -119,7 +119,7 @@ static uint8_t draw_char_vtmono(const struct char_framebuffer *fb, return fptr->width; } -int cfb_print(struct device *dev, char *str, uint16_t x, uint16_t y) +int cfb_print(const struct device *dev, char *str, uint16_t x, uint16_t y) { const struct char_framebuffer *fb = &char_fb; const struct cfb_font *fptr; @@ -159,7 +159,7 @@ static int cfb_invert(const struct char_framebuffer *fb) return 0; } -int cfb_framebuffer_clear(struct device *dev, bool clear_display) +int cfb_framebuffer_clear(const struct device *dev, bool clear_display) { const struct char_framebuffer *fb = &char_fb; struct display_buffer_descriptor desc; @@ -178,7 +178,7 @@ int cfb_framebuffer_clear(struct device *dev, bool clear_display) } -int cfb_framebuffer_invert(struct device *dev) +int cfb_framebuffer_invert(const struct device *dev) { struct char_framebuffer *fb = &char_fb; @@ -191,7 +191,7 @@ int cfb_framebuffer_invert(struct device *dev) return 0; } -int cfb_framebuffer_finalize(struct device *dev) +int cfb_framebuffer_finalize(const struct device *dev) { const struct display_driver_api *api = dev->api; const struct char_framebuffer *fb = &char_fb; @@ -213,7 +213,7 @@ int cfb_framebuffer_finalize(struct device *dev) return api->write(dev, 0, 0, &desc, fb->buf); } -int cfb_get_display_parameter(struct device *dev, +int cfb_get_display_parameter(const struct device *dev, enum cfb_display_param param) { const struct char_framebuffer *fb = &char_fb; @@ -239,7 +239,7 @@ int cfb_get_display_parameter(struct device *dev, return 0; } -int cfb_framebuffer_set_font(struct device *dev, uint8_t idx) +int cfb_framebuffer_set_font(const struct device *dev, uint8_t idx) { struct char_framebuffer *fb = &char_fb; @@ -252,7 +252,8 @@ int cfb_framebuffer_set_font(struct device *dev, uint8_t idx) return 0; } -int cfb_get_font_size(struct device *dev, uint8_t idx, uint8_t *width, uint8_t *height) +int cfb_get_font_size(const struct device *dev, uint8_t idx, uint8_t *width, + uint8_t *height) { const struct char_framebuffer *fb = &char_fb; @@ -271,14 +272,14 @@ int cfb_get_font_size(struct device *dev, uint8_t idx, uint8_t *width, uint8_t * return 0; } -int cfb_get_numof_fonts(struct device *dev) +int cfb_get_numof_fonts(const struct device *dev) { const struct char_framebuffer *fb = &char_fb; return fb->numof_fonts; } -int cfb_framebuffer_init(struct device *dev) +int cfb_framebuffer_init(const struct device *dev) { const struct display_driver_api *api = dev->api; struct char_framebuffer *fb = &char_fb; diff --git a/subsys/fb/cfb_shell.c b/subsys/fb/cfb_shell.c index 54bf49207057fc..e8b63d3ea1d460 100644 --- a/subsys/fb/cfb_shell.c +++ b/subsys/fb/cfb_shell.c @@ -22,7 +22,7 @@ #define DISPLAY_DRIVER CONFIG_CHARACTER_FRAMEBUFFER_SHELL_DRIVER_NAME -static struct device *dev; +static const struct device *dev; static const char * const param_name[] = { "height", "width", "ppt", "rows", "cols"}; diff --git a/subsys/fs/fat_fs.c b/subsys/fs/fat_fs.c index 6e3ee49adb5bac..6e364c26df05ee 100644 --- a/subsys/fs/fat_fs.c +++ b/subsys/fs/fat_fs.c @@ -428,7 +428,7 @@ static struct fs_file_system_t fatfs_fs = { .statvfs = fatfs_statvfs, }; -static int fatfs_init(struct device *dev) +static int fatfs_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/fs/fs.c b/subsys/fs/fs.c index 2ca1cb514b380c..5b6cc14ae0da7f 100644 --- a/subsys/fs/fs.c +++ b/subsys/fs/fs.c @@ -700,7 +700,7 @@ int fs_unregister(enum fs_type type, struct fs_file_system_t *fs) return rc; } -static int fs_init(struct device *dev) +static int fs_init(const struct device *dev) { k_mutex_init(&mutex); sys_dlist_init(&fs_mnt_list); diff --git a/subsys/fs/littlefs_fs.c b/subsys/fs/littlefs_fs.c index 259b176aa929b7..5f3c00de836a31 100644 --- a/subsys/fs/littlefs_fs.c +++ b/subsys/fs/littlefs_fs.c @@ -536,7 +536,7 @@ static lfs_size_t get_block_size(const struct flash_area *fa) .area = fa, .max_size = 0, }; - struct device *dev = flash_area_get_device(fa); + const struct device *dev = flash_area_get_device(fa); flash_page_foreach(dev, get_page_cb, &ctx); @@ -548,7 +548,7 @@ static int littlefs_mount(struct fs_mount_t *mountp) int ret; struct fs_littlefs *fs = mountp->fs_data; unsigned int area_id = (uintptr_t)mountp->storage_dev; - struct device *dev; + const struct device *dev; LOG_INF("LittleFS version %u.%u, disk version %u.%u", LFS_VERSION_MAJOR, LFS_VERSION_MINOR, @@ -743,7 +743,7 @@ static struct fs_file_system_t littlefs_fs = { .statvfs = littlefs_statvfs, }; -static int littlefs_init(struct device *dev) +static int littlefs_init(const struct device *dev) { ARG_UNUSED(dev); return fs_register(FS_LITTLEFS, &littlefs_fs); diff --git a/subsys/logging/log_backend_uart.c b/subsys/logging/log_backend_uart.c index dc5e99b596a295..09c43158a296bf 100644 --- a/subsys/logging/log_backend_uart.c +++ b/subsys/logging/log_backend_uart.c @@ -15,7 +15,7 @@ static int char_out(uint8_t *data, size_t length, void *ctx) { - struct device *dev = (struct device *)ctx; + const struct device *dev = (const struct device *)ctx; for (size_t i = 0; i < length; i++) { uart_poll_out(dev, data[i]); @@ -39,7 +39,7 @@ static void put(const struct log_backend *const backend, static void log_backend_uart_init(void) { - struct device *dev; + const struct device *dev; dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); assert(dev); diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index 033271f77478be..a68a1ffd84ebbf 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -1189,7 +1189,7 @@ static void log_process_thread_func(void *dummy1, void *dummy2, void *dummy3) K_KERNEL_STACK_DEFINE(logging_stack, CONFIG_LOG_PROCESS_THREAD_STACK_SIZE); struct k_thread logging_thread; -static int enable_logger(struct device *arg) +static int enable_logger(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/logging/log_output.c b/subsys/logging/log_output.c index 12b59641b5f533..a867937714aba3 100644 --- a/subsys/logging/log_output.c +++ b/subsys/logging/log_output.c @@ -658,7 +658,7 @@ void log_output_dropped_process(const struct log_output *log_output, uint32_t cn static const char postfix[] = " messages dropped ---\r\n" DROPPED_COLOR_POSTFIX; log_output_func_t outf = log_output->func; - struct device *dev = (struct device *)log_output->control_block->ctx; + const struct device *dev = (const struct device *)log_output->control_block->ctx; cnt = MIN(cnt, 9999); len = snprintk(buf, sizeof(buf), "%d", cnt); diff --git a/subsys/logging/log_output_syst.c b/subsys/logging/log_output_syst.c index c530e3eef72c1e..ab876604bd5a56 100644 --- a/subsys/logging/log_output_syst.c +++ b/subsys/logging/log_output_syst.c @@ -370,7 +370,7 @@ void log_output_hexdump_syst_process(const struct log_output *log_output, MIPI_SYST_WRITE(&log_syst_handle, severity, 0x1A, data, length); } -static int syst_init(struct device *arg) +static int syst_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/mgmt/mcumgr/smp_bt.c b/subsys/mgmt/mcumgr/smp_bt.c index 8eb94d19bd1a27..f2e01b3fe043f2 100644 --- a/subsys/mgmt/mcumgr/smp_bt.c +++ b/subsys/mgmt/mcumgr/smp_bt.c @@ -190,7 +190,7 @@ int smp_bt_unregister(void) return bt_gatt_service_unregister(&smp_bt_svc); } -static int smp_bt_init(struct device *dev) +static int smp_bt_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/mgmt/mcumgr/smp_uart.c b/subsys/mgmt/mcumgr/smp_uart.c index 3ddf1e857e1f52..94705c2bc04693 100644 --- a/subsys/mgmt/mcumgr/smp_uart.c +++ b/subsys/mgmt/mcumgr/smp_uart.c @@ -87,7 +87,7 @@ static int smp_uart_tx_pkt(struct zephyr_smp_transport *zst, return rc; } -static int smp_uart_init(struct device *dev) +static int smp_uart_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/mgmt/mcumgr/smp_udp.c b/subsys/mgmt/mcumgr/smp_udp.c index 11392f3d98913f..264c6a6ac43f31 100644 --- a/subsys/mgmt/mcumgr/smp_udp.c +++ b/subsys/mgmt/mcumgr/smp_udp.c @@ -132,7 +132,7 @@ static void smp_udp_receive_thread(void *p1, void *p2, void *p3) } } -static int smp_udp_init(struct device *dev) +static int smp_udp_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/mgmt/osdp/src/osdp.c b/subsys/mgmt/osdp/src/osdp.c index a5d85ff3a9e9b1..13292b8fbe96f1 100644 --- a/subsys/mgmt/osdp/src/osdp.c +++ b/subsys/mgmt/osdp/src/osdp.c @@ -23,7 +23,7 @@ struct osdp_device { struct k_fifo rx_event_fifo; uint8_t rx_fbuf[CONFIG_OSDP_UART_BUFFER_LENGTH]; uint8_t tx_fbuf[CONFIG_OSDP_UART_BUFFER_LENGTH]; - struct device *dev; + const struct device *dev; }; static struct osdp osdp_ctx; @@ -33,7 +33,7 @@ static struct osdp_device osdp_device; static struct k_thread osdp_refresh_thread; static K_THREAD_STACK_DEFINE(osdp_thread_stack, CONFIG_OSDP_THREAD_STACK_SIZE); -static void osdp_uart_isr(struct device *dev, void *user_data) +static void osdp_uart_isr(const struct device *dev, void *user_data) { uint8_t buf[64]; size_t read, wrote, len; @@ -127,7 +127,7 @@ void osdp_refresh(void *arg1, void *arg2, void *arg3) } } -static int osdp_init(struct device *arg) +static int osdp_init(const struct device *arg) { ARG_UNUSED(arg); uint8_t c; diff --git a/subsys/net/ip/net_core.c b/subsys/net/ip/net_core.c index c82bcfc938c8a5..5f3ab94fbcec6f 100644 --- a/subsys/net/ip/net_core.c +++ b/subsys/net/ip/net_core.c @@ -448,7 +448,7 @@ static inline int services_init(void) return status; } -static int net_init(struct device *unused) +static int net_init(const struct device *unused) { net_hostname_init(); diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index f77c6c48852a06..5db57e6894ecc4 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -520,7 +520,7 @@ struct net_if *net_if_get_by_link_addr(struct net_linkaddr *ll_addr) return NULL; } -struct net_if *net_if_lookup_by_dev(struct device *dev) +struct net_if *net_if_lookup_by_dev(const struct device *dev) { Z_STRUCT_SECTION_FOREACH(net_if, iface) { if (net_if_get_device(iface) == dev) { diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index 3ab8711eb319e8..3e32abfdb22e62 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -4312,7 +4312,7 @@ static int cmd_net_suspend(const struct shell *shell, size_t argc, #if defined(CONFIG_NET_POWER_MANAGEMENT) if (argv[1]) { struct net_if *iface = NULL; - struct device *dev; + const struct device *dev; int idx; int ret; @@ -4357,7 +4357,7 @@ static int cmd_net_resume(const struct shell *shell, size_t argc, #if defined(CONFIG_NET_POWER_MANAGEMENT) if (argv[1]) { struct net_if *iface = NULL; - struct device *dev; + const struct device *dev; int idx; int ret; diff --git a/subsys/net/l2/bluetooth/bluetooth.c b/subsys/net/l2/bluetooth/bluetooth.c index 78fedad12e8dec..dc4ea3d3ccf8b2 100644 --- a/subsys/net/l2/bluetooth/bluetooth.c +++ b/subsys/net/l2/bluetooth/bluetooth.c @@ -602,7 +602,7 @@ static struct bt_conn_cb conn_callbacks = { }; #endif /* CONFIG_NET_L2_BT_MGMT */ -static int net_bt_init(struct device *dev) +static int net_bt_init(const struct device *dev) { NET_DBG("dev %p driver_data %p", dev, dev->data); diff --git a/subsys/net/l2/canbus/6locan.c b/subsys/net/l2/canbus/6locan.c index ca7600cdde170e..e660ad27d6101e 100644 --- a/subsys/net/l2/canbus/6locan.c +++ b/subsys/net/l2/canbus/6locan.c @@ -426,7 +426,7 @@ static void canbus_fc_send_cb(uint32_t err_flags, void *arg) } } -static int canbus_send_fc(struct device *net_can_dev, +static int canbus_send_fc(const struct device *net_can_dev, struct net_canbus_lladdr *dest, struct net_canbus_lladdr *src, uint8_t fs) { @@ -497,7 +497,7 @@ static enum net_verdict canbus_process_cf(struct net_pkt *pkt) { struct canbus_isotp_rx_ctx *rx_ctx; enum net_verdict ret; - struct device *net_can_dev; + const struct device *net_can_dev; struct net_canbus_lladdr src, dest; bool mcast; @@ -557,7 +557,7 @@ static enum net_verdict canbus_process_cf(struct net_pkt *pkt) static enum net_verdict canbus_process_ff(struct net_pkt *pkt) { - struct device *net_can_dev = net_if_get_device(pkt->iface); + const struct device *net_can_dev = net_if_get_device(pkt->iface); struct canbus_isotp_rx_ctx *rx_ctx = NULL; struct net_pkt *new_pkt = NULL; int ret; @@ -698,7 +698,7 @@ static void canbus_tx_frame_isr(uint32_t err_flags, void *arg) static inline int canbus_send_cf(struct net_pkt *pkt) { struct canbus_isotp_tx_ctx *ctx = pkt->canbus_tx_ctx; - struct device *net_can_dev = net_if_get_device(pkt->iface); + const struct device *net_can_dev = net_if_get_device(pkt->iface); const struct net_can_api *api = net_can_dev->api; struct zcan_frame frame; struct net_pkt_cursor cursor_backup; @@ -873,7 +873,7 @@ static enum net_verdict canbus_process_fc(struct net_pkt *pkt) static inline int canbus_send_ff(struct net_pkt *pkt, size_t len, bool mcast, struct net_canbus_lladdr *dest_addr) { - struct device *net_can_dev = net_if_get_device(pkt->iface); + const struct device *net_can_dev = net_if_get_device(pkt->iface); const struct net_can_api *api = net_can_dev->api; struct net_linkaddr *lladdr_inline; struct zcan_frame frame; @@ -943,7 +943,7 @@ static inline int canbus_send_single_frame(struct net_pkt *pkt, size_t len, bool mcast, struct net_canbus_lladdr *dest_addr) { - struct device *net_can_dev = net_if_get_device(pkt->iface); + const struct device *net_can_dev = net_if_get_device(pkt->iface); const struct net_can_api *api = net_can_dev->api; int index = 0; struct zcan_frame frame; @@ -1496,7 +1496,7 @@ static enum net_verdict canbus_recv(struct net_if *iface, return ret; } -static inline int canbus_send_dad_request(struct device *net_can_dev, +static inline int canbus_send_dad_request(const struct device *net_can_dev, struct net_canbus_lladdr *ll_addr) { const struct net_can_api *api = net_can_dev->api; @@ -1542,7 +1542,7 @@ static inline void canbus_send_dad_response(struct k_work *item) dad_work); struct net_if *iface = ctx->iface; struct net_linkaddr *ll_addr = net_if_get_link_addr(iface); - struct device *net_can_dev = net_if_get_device(iface); + const struct device *net_can_dev = net_if_get_device(iface); const struct net_can_api *api = net_can_dev->api; struct zcan_frame frame; int ret; @@ -1562,7 +1562,7 @@ static inline void canbus_send_dad_response(struct k_work *item) } } -static inline void canbus_detach_filter(struct device *net_can_dev, +static inline void canbus_detach_filter(const struct device *net_can_dev, int filter_id) { const struct net_can_api *api = net_can_dev->api; @@ -1578,7 +1578,7 @@ static void canbus_dad_resp_cb(struct zcan_frame *frame, void *arg) } static inline -int canbus_attach_dad_resp_filter(struct device *net_can_dev, +int canbus_attach_dad_resp_filter(const struct device *net_can_dev, struct net_canbus_lladdr *ll_addr, struct k_sem *dad_sem) { @@ -1609,7 +1609,7 @@ static void canbus_dad_request_cb(struct zcan_frame *frame, void *arg) k_work_submit_to_queue(&net_canbus_workq, work); } -static inline int canbus_attach_dad_filter(struct device *net_can_dev, +static inline int canbus_attach_dad_filter(const struct device *net_can_dev, struct net_canbus_lladdr *ll_addr, struct k_work *dad_work) { @@ -1636,7 +1636,7 @@ static inline int canbus_attach_dad_filter(struct device *net_can_dev, static inline int canbus_init_ll_addr(struct net_if *iface) { struct canbus_net_ctx *ctx = net_if_l2_data(iface); - struct device *net_can_dev = net_if_get_device(iface); + const struct device *net_can_dev = net_if_get_device(iface); int dad_resp_filter_id = CAN_NET_FILTER_NOT_SET; struct net_canbus_lladdr ll_addr; int ret; @@ -1743,7 +1743,7 @@ void net_6locan_init(struct net_if *iface) static int canbus_enable(struct net_if *iface, bool state) { - struct device *net_can_dev = net_if_get_device(iface); + const struct device *net_can_dev = net_if_get_device(iface); const struct net_can_api *api = net_can_dev->api; struct canbus_net_ctx *ctx = net_if_l2_data(iface); int dad_retry_cnt, ret; diff --git a/subsys/net/l2/ethernet/ethernet.c b/subsys/net/l2/ethernet/ethernet.c index d230663e89649f..723f95c0377aa3 100644 --- a/subsys/net/l2/ethernet/ethernet.c +++ b/subsys/net/l2/ethernet/ethernet.c @@ -145,7 +145,7 @@ static void ethernet_update_rx_stats(struct net_if *iface, static inline bool eth_is_vlan_tag_stripped(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); const struct ethernet_api *api = dev->api; return (api->get_capabilities(dev) & ETHERNET_HW_VLAN_TAG_STRIP); @@ -1043,9 +1043,9 @@ void net_eth_carrier_off(struct net_if *iface) } #if defined(CONFIG_PTP_CLOCK) -struct device *net_eth_get_ptp_clock(struct net_if *iface) +const struct device *net_eth_get_ptp_clock(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); const struct ethernet_api *api = dev->api; if (!api) { @@ -1069,7 +1069,7 @@ struct device *net_eth_get_ptp_clock(struct net_if *iface) #endif /* CONFIG_PTP_CLOCK */ #if defined(CONFIG_PTP_CLOCK) -struct device *z_impl_net_eth_get_ptp_clock_by_index(int index) +const struct device *z_impl_net_eth_get_ptp_clock_by_index(int index) { struct net_if *iface; @@ -1082,14 +1082,14 @@ struct device *z_impl_net_eth_get_ptp_clock_by_index(int index) } #ifdef CONFIG_USERSPACE -static inline struct device *z_vrfy_net_eth_get_ptp_clock_by_index(int index) +static inline const struct device *z_vrfy_net_eth_get_ptp_clock_by_index(int index) { return z_impl_net_eth_get_ptp_clock_by_index(index); } #include #endif /* CONFIG_USERSPACE */ #else /* CONFIG_PTP_CLOCK */ -struct device *z_impl_net_eth_get_ptp_clock_by_index(int index) +const struct device *z_impl_net_eth_get_ptp_clock_by_index(int index) { ARG_UNUSED(index); diff --git a/subsys/net/l2/ethernet/ethernet_mgmt.c b/subsys/net/l2/ethernet/ethernet_mgmt.c index 978f7f119a37f8..92ab4e856f797e 100644 --- a/subsys/net/l2/ethernet/ethernet_mgmt.c +++ b/subsys/net/l2/ethernet/ethernet_mgmt.c @@ -13,7 +13,7 @@ LOG_MODULE_REGISTER(net_ethernet_mgmt, CONFIG_NET_L2_ETHERNET_LOG_LEVEL); #include #include -static inline bool is_hw_caps_supported(struct device *dev, +static inline bool is_hw_caps_supported(const struct device *dev, enum ethernet_hw_caps caps) { const struct ethernet_api *api = dev->api; @@ -30,7 +30,7 @@ static int ethernet_set_config(uint32_t mgmt_request, void *data, size_t len) { struct ethernet_req_params *params = (struct ethernet_req_params *)data; - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); const struct ethernet_api *api = dev->api; struct ethernet_config config = { 0 }; enum ethernet_config_type type; @@ -176,7 +176,7 @@ static int ethernet_get_config(uint32_t mgmt_request, void *data, size_t len) { struct ethernet_req_params *params = (struct ethernet_req_params *)data; - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); const struct ethernet_api *api = dev->api; struct ethernet_config config = { 0 }; int ret = 0; diff --git a/subsys/net/l2/ethernet/gptp/gptp.c b/subsys/net/l2/ethernet/gptp/gptp.c index 0c23eca97e87a0..cc02707816d4af 100644 --- a/subsys/net/l2/ethernet/gptp/gptp.c +++ b/subsys/net/l2/ethernet/gptp/gptp.c @@ -564,7 +564,7 @@ static void gptp_thread(void) static void gptp_add_port(struct net_if *iface, void *user_data) { int *num_ports = user_data; - struct device *clk; + const struct device *clk; if (*num_ports >= CONFIG_NET_GPTP_NUM_PORTS) { return; @@ -828,7 +828,7 @@ struct port_user_data { static void gptp_get_port(struct net_if *iface, void *user_data) { struct port_user_data *ud = user_data; - struct device *clk; + const struct device *clk; /* Check if interface has a PTP clock. */ clk = net_eth_get_ptp_clock(iface); diff --git a/subsys/net/l2/ethernet/gptp/gptp_mi.c b/subsys/net/l2/ethernet/gptp/gptp_mi.c index ab6e2eb9aab9db..9fd54035a02df7 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_mi.c +++ b/subsys/net/l2/ethernet/gptp/gptp_mi.c @@ -332,7 +332,7 @@ void gptp_mi_init_state_machine(void) uint64_t gptp_get_current_time_nanosecond(int port) { - struct device *clk; + const struct device *clk; clk = net_eth_get_ptp_clock(GPTP_PORT_IFACE(port)); if (clk) { @@ -742,7 +742,7 @@ static void gptp_update_local_port_clock(void) int port; int64_t nanosecond_diff; int64_t second_diff; - struct device *clk; + const struct device *clk; struct net_ptp_time tm; int key; diff --git a/subsys/net/l2/ethernet/gptp/gptp_user_api.c b/subsys/net/l2/ethernet/gptp/gptp_user_api.c index d5c9d17ab4579c..77edb0a2796171 100644 --- a/subsys/net/l2/ethernet/gptp/gptp_user_api.c +++ b/subsys/net/l2/ethernet/gptp/gptp_user_api.c @@ -54,7 +54,7 @@ void gptp_call_phase_dis_cb(void) int gptp_event_capture(struct net_ptp_time *slave_time, bool *gm_present) { int port, key; - struct device *clk; + const struct device *clk; key = irq_lock(); *gm_present = GPTP_GLOBAL_DS()->gm_present; diff --git a/subsys/net/l2/ieee802154/ieee802154_security.c b/subsys/net/l2/ieee802154/ieee802154_security.c index f6f35b5c288250..40359799ff527c 100644 --- a/subsys/net/l2/ieee802154/ieee802154_security.c +++ b/subsys/net/l2/ieee802154/ieee802154_security.c @@ -173,7 +173,7 @@ bool ieee802154_encrypt_auth(struct ieee802154_security_ctx *sec_ctx, int ieee802154_security_init(struct ieee802154_security_ctx *sec_ctx) { - struct device *dev; + const struct device *dev; (void)memset(&sec_ctx->enc, 0, sizeof(struct cipher_ctx)); (void)memset(&sec_ctx->dec, 0, sizeof(struct cipher_ctx)); diff --git a/subsys/net/l2/wifi/wifi_mgmt.c b/subsys/net/l2/wifi/wifi_mgmt.c index 58edd9eb988f94..500cc991eb840e 100644 --- a/subsys/net/l2/wifi/wifi_mgmt.c +++ b/subsys/net/l2/wifi/wifi_mgmt.c @@ -18,7 +18,7 @@ static int wifi_connect(uint32_t mgmt_request, struct net_if *iface, { struct wifi_connect_req_params *params = (struct wifi_connect_req_params *)data; - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_wifi_mgmt_offload *off_api = (struct net_wifi_mgmt_offload *) dev->api; @@ -72,7 +72,7 @@ static void scan_result_cb(struct net_if *iface, int status, static int wifi_scan(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_wifi_mgmt_offload *off_api = (struct net_wifi_mgmt_offload *) dev->api; @@ -89,7 +89,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_SCAN, wifi_scan); static int wifi_disconnect(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_wifi_mgmt_offload *off_api = (struct net_wifi_mgmt_offload *) dev->api; @@ -129,7 +129,7 @@ static int wifi_ap_enable(uint32_t mgmt_request, struct net_if *iface, { struct wifi_connect_req_params *params = (struct wifi_connect_req_params *)data; - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_wifi_mgmt_offload *off_api = (struct net_wifi_mgmt_offload *) dev->api; @@ -145,7 +145,7 @@ NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_ENABLE, wifi_ap_enable); static int wifi_ap_disable(uint32_t mgmt_request, struct net_if *iface, void *data, size_t len) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct net_wifi_mgmt_offload *off_api = (struct net_wifi_mgmt_offload *) dev->api; diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 9ad177986509d0..f41dc9a2341880 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -328,7 +328,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(wifi_commands, SHELL_CMD_REGISTER(wifi, &wifi_commands, "Wifi commands", NULL); -static int wifi_shell_init(struct device *unused) +static int wifi_shell_init(const struct device *unused) { ARG_UNUSED(unused); diff --git a/subsys/net/lib/config/bt_settings.c b/subsys/net/lib/config/bt_settings.c index f98d56eaa676fc..558630f4dea3a5 100644 --- a/subsys/net/lib/config/bt_settings.c +++ b/subsys/net/lib/config/bt_settings.c @@ -33,7 +33,7 @@ BT_GATT_SERVICE_DEFINE(ipss_svc, int z_net_config_bt_setup(void) { struct net_if *iface; - struct device *dev; + const struct device *dev; int err; err = bt_enable(NULL); diff --git a/subsys/net/lib/config/ieee802154_settings.c b/subsys/net/lib/config/ieee802154_settings.c index 375632d9371104..57e9875dbd68be 100644 --- a/subsys/net/lib/config/ieee802154_settings.c +++ b/subsys/net/lib/config/ieee802154_settings.c @@ -33,7 +33,7 @@ int z_net_config_ieee802154_setup(void) #endif /* CONFIG_NET_L2_IEEE802154_SECURITY */ struct net_if *iface; - struct device *dev; + const struct device *dev; dev = device_get_binding(CONFIG_NET_CONFIG_IEEE802154_DEV_NAME); if (!dev) { diff --git a/subsys/net/lib/config/init.c b/subsys/net/lib/config/init.c index 4ea5bbb7ca1081..f8ffcb34a2239b 100644 --- a/subsys/net/lib/config/init.c +++ b/subsys/net/lib/config/init.c @@ -420,7 +420,7 @@ int net_config_init(const char *app_info, uint32_t flags, return net_config_init_by_iface(NULL, app_info, flags, timeout); } -int net_config_init_app(struct device *dev, const char *app_info) +int net_config_init_app(const struct device *dev, const char *app_info) { struct net_if *iface = NULL; uint32_t flags = 0U; @@ -485,7 +485,7 @@ int net_config_init_app(struct device *dev, const char *app_info) } #if defined(CONFIG_NET_CONFIG_AUTO_INIT) -static int init_app(struct device *dev) +static int init_app(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/net/lib/conn_mgr/conn_mgr.c b/subsys/net/lib/conn_mgr/conn_mgr.c index c1303184d4a56c..e3241384cf5206 100644 --- a/subsys/net/lib/conn_mgr/conn_mgr.c +++ b/subsys/net/lib/conn_mgr/conn_mgr.c @@ -183,7 +183,7 @@ void net_conn_mgr_resend_status(void) } } -static int conn_mgr_init(struct device *dev) +static int conn_mgr_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/net/lib/dns/llmnr_responder.c b/subsys/net/lib/dns/llmnr_responder.c index 8d8567694d5613..bd6109c1ef984c 100644 --- a/subsys/net/lib/dns/llmnr_responder.c +++ b/subsys/net/lib/dns/llmnr_responder.c @@ -651,7 +651,7 @@ static int init_listener(void) return !ok; } -static int llmnr_responder_init(struct device *device) +static int llmnr_responder_init(const struct device *device) { ARG_UNUSED(device); diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c index 4440e6a115a528..34652c51e11cea 100644 --- a/subsys/net/lib/dns/mdns_responder.c +++ b/subsys/net/lib/dns/mdns_responder.c @@ -514,7 +514,7 @@ static int init_listener(void) return !ok; } -static int mdns_responder_init(struct device *device) +static int mdns_responder_init(const struct device *device) { ARG_UNUSED(device); diff --git a/subsys/net/lib/lwm2m/ipso_accelerometer.c b/subsys/net/lib/lwm2m/ipso_accelerometer.c index 07358423a6b909..33f87151e36627 100644 --- a/subsys/net/lib/lwm2m/ipso_accelerometer.c +++ b/subsys/net/lib/lwm2m/ipso_accelerometer.c @@ -142,7 +142,7 @@ static struct lwm2m_engine_obj_inst *accel_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_accel_init(struct device *dev) +static int ipso_accel_init(const struct device *dev) { accel.obj_id = IPSO_OBJECT_ACCELEROMETER_ID; accel.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_buzzer.c b/subsys/net/lib/lwm2m/ipso_buzzer.c index d797607ad6fafb..8497a841403b09 100644 --- a/subsys/net/lib/lwm2m/ipso_buzzer.c +++ b/subsys/net/lib/lwm2m/ipso_buzzer.c @@ -243,7 +243,7 @@ static struct lwm2m_engine_obj_inst *buzzer_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_buzzer_init(struct device *dev) +static int ipso_buzzer_init(const struct device *dev) { buzzer.obj_id = IPSO_OBJECT_BUZZER_ID; buzzer.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_generic_sensor.c b/subsys/net/lib/lwm2m/ipso_generic_sensor.c index 6e4e968cf15024..31ac090b80c53e 100644 --- a/subsys/net/lib/lwm2m/ipso_generic_sensor.c +++ b/subsys/net/lib/lwm2m/ipso_generic_sensor.c @@ -231,7 +231,7 @@ static struct lwm2m_engine_obj_inst *generic_sensor_create(uint16_t obj_inst_id) return &inst[index]; } -static int ipso_generic_sensor_init(struct device *dev) +static int ipso_generic_sensor_init(const struct device *dev) { sensor.obj_id = IPSO_OBJECT_ID; sensor.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_humidity_sensor.c b/subsys/net/lib/lwm2m/ipso_humidity_sensor.c index d0a3af1325f513..74e025aa096a36 100644 --- a/subsys/net/lib/lwm2m/ipso_humidity_sensor.c +++ b/subsys/net/lib/lwm2m/ipso_humidity_sensor.c @@ -215,7 +215,7 @@ humidity_sensor_create(uint16_t obj_inst_id) return &inst[index]; } -static int ipso_humidity_sensor_init(struct device *dev) +static int ipso_humidity_sensor_init(const struct device *dev) { sensor.obj_id = IPSO_OBJECT_ID; sensor.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_light_control.c b/subsys/net/lib/lwm2m/ipso_light_control.c index 3719672f5bc241..5ed74d8c6a165d 100644 --- a/subsys/net/lib/lwm2m/ipso_light_control.c +++ b/subsys/net/lib/lwm2m/ipso_light_control.c @@ -199,7 +199,7 @@ static struct lwm2m_engine_obj_inst *light_control_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_light_control_init(struct device *dev) +static int ipso_light_control_init(const struct device *dev) { light_control.obj_id = IPSO_OBJECT_LIGHT_CONTROL_ID; light_control.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_onoff_switch.c b/subsys/net/lib/lwm2m/ipso_onoff_switch.c index 2ea0dd05f3f4f9..5c5f915580c0c4 100644 --- a/subsys/net/lib/lwm2m/ipso_onoff_switch.c +++ b/subsys/net/lib/lwm2m/ipso_onoff_switch.c @@ -240,7 +240,7 @@ static struct lwm2m_engine_obj_inst *switch_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_switch_init(struct device *dev) +static int ipso_switch_init(const struct device *dev) { onoff_switch.obj_id = IPSO_OBJECT_ONOFF_SWITCH_ID; onoff_switch.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_pressure_sensor.c b/subsys/net/lib/lwm2m/ipso_pressure_sensor.c index 9356cc9e718658..8df48b896314f0 100644 --- a/subsys/net/lib/lwm2m/ipso_pressure_sensor.c +++ b/subsys/net/lib/lwm2m/ipso_pressure_sensor.c @@ -215,7 +215,7 @@ pressure_sensor_create(uint16_t obj_inst_id) return &inst[index]; } -static int ipso_pressure_sensor_init(struct device *dev) +static int ipso_pressure_sensor_init(const struct device *dev) { sensor.obj_id = IPSO_OBJECT_ID; sensor.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_push_button.c b/subsys/net/lib/lwm2m/ipso_push_button.c index 9248304adcf8ac..04c2403c5e3cac 100644 --- a/subsys/net/lib/lwm2m/ipso_push_button.c +++ b/subsys/net/lib/lwm2m/ipso_push_button.c @@ -166,7 +166,7 @@ static struct lwm2m_engine_obj_inst *button_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_button_init(struct device *dev) +static int ipso_button_init(const struct device *dev) { onoff_switch.obj_id = IPSO_OBJECT_PUSH_BUTTON_ID; onoff_switch.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_temp_sensor.c b/subsys/net/lib/lwm2m/ipso_temp_sensor.c index eb1918fda3516e..3b30c1662e3955 100644 --- a/subsys/net/lib/lwm2m/ipso_temp_sensor.c +++ b/subsys/net/lib/lwm2m/ipso_temp_sensor.c @@ -232,7 +232,7 @@ static struct lwm2m_engine_obj_inst *temp_sensor_create(uint16_t obj_inst_id) return &inst[index]; } -static int ipso_temp_sensor_init(struct device *dev) +static int ipso_temp_sensor_init(const struct device *dev) { temp_sensor.obj_id = IPSO_OBJECT_TEMP_SENSOR_ID; temp_sensor.fields = fields; diff --git a/subsys/net/lib/lwm2m/ipso_timer.c b/subsys/net/lib/lwm2m/ipso_timer.c index e66d32064d0b38..74097eb8f24dc1 100644 --- a/subsys/net/lib/lwm2m/ipso_timer.c +++ b/subsys/net/lib/lwm2m/ipso_timer.c @@ -382,7 +382,7 @@ static struct lwm2m_engine_obj_inst *timer_create(uint16_t obj_inst_id) return &inst[avail]; } -static int ipso_timer_init(struct device *dev) +static int ipso_timer_init(const struct device *dev) { timer.obj_id = IPSO_OBJECT_TIMER_ID; timer.fields = fields; diff --git a/subsys/net/lib/lwm2m/lwm2m_engine.c b/subsys/net/lib/lwm2m/lwm2m_engine.c index f7fdf41e5a322d..fb2a8dfda7934c 100644 --- a/subsys/net/lib/lwm2m/lwm2m_engine.c +++ b/subsys/net/lib/lwm2m/lwm2m_engine.c @@ -4515,7 +4515,7 @@ int lwm2m_engine_start(struct lwm2m_ctx *client_ctx) return lwm2m_socket_start(client_ctx); } -static int lwm2m_engine_init(struct device *dev) +static int lwm2m_engine_init(const struct device *dev) { int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_connmon.c b/subsys/net/lib/lwm2m/lwm2m_obj_connmon.c index 9e87b8c5c7e74c..f24ef823732169 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_connmon.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_connmon.c @@ -141,7 +141,7 @@ static struct lwm2m_engine_obj_inst *connmon_create(uint16_t obj_inst_id) return &inst; } -static int lwm2m_connmon_init(struct device *dev) +static int lwm2m_connmon_init(const struct device *dev) { struct lwm2m_engine_obj_inst *obj_inst = NULL; int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_device.c b/subsys/net/lib/lwm2m/lwm2m_obj_device.c index 44f71b3fae02d1..a3f241c6e82570 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_device.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_device.c @@ -249,7 +249,7 @@ static struct lwm2m_engine_obj_inst *device_create(uint16_t obj_inst_id) return &inst; } -static int lwm2m_device_init(struct device *dev) +static int lwm2m_device_init(const struct device *dev) { struct lwm2m_engine_obj_inst *obj_inst = NULL; int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c b/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c index c004976f0c4f73..66f20ca04c7905 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_firmware.c @@ -335,7 +335,7 @@ static struct lwm2m_engine_obj_inst *firmware_create(uint16_t obj_inst_id) return &inst; } -static int lwm2m_firmware_init(struct device *dev) +static int lwm2m_firmware_init(const struct device *dev) { struct lwm2m_engine_obj_inst *obj_inst = NULL; int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_location.c b/subsys/net/lib/lwm2m/lwm2m_obj_location.c index a9e2a9bcb6ab94..12982fee97d542 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_location.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_location.c @@ -90,7 +90,7 @@ static struct lwm2m_engine_obj_inst *location_create(uint16_t obj_inst_id) return &inst; } -static int ipso_location_init(struct device *dev) +static int ipso_location_init(const struct device *dev) { int ret; struct lwm2m_engine_obj_inst *obj_inst = NULL; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_security.c b/subsys/net/lib/lwm2m/lwm2m_obj_security.c index a7ed28a47bb5e2..b3b69c5fa8b074 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_security.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_security.c @@ -170,7 +170,7 @@ int lwm2m_security_index_to_inst_id(int index) return inst[index].obj_inst_id; } -static int lwm2m_security_init(struct device *dev) +static int lwm2m_security_init(const struct device *dev) { struct lwm2m_engine_obj_inst *obj_inst = NULL; int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_obj_server.c b/subsys/net/lib/lwm2m/lwm2m_obj_server.c index 9d8432188f1947..7059412454b6e9 100644 --- a/subsys/net/lib/lwm2m/lwm2m_obj_server.c +++ b/subsys/net/lib/lwm2m/lwm2m_obj_server.c @@ -222,7 +222,7 @@ static struct lwm2m_engine_obj_inst *server_create(uint16_t obj_inst_id) return &inst[index]; } -static int lwm2m_server_init(struct device *dev) +static int lwm2m_server_init(const struct device *dev) { struct lwm2m_engine_obj_inst *obj_inst = NULL; int ret = 0; diff --git a/subsys/net/lib/lwm2m/lwm2m_rd_client.c b/subsys/net/lib/lwm2m/lwm2m_rd_client.c index 406c7540912153..0acb905be9afc5 100644 --- a/subsys/net/lib/lwm2m/lwm2m_rd_client.c +++ b/subsys/net/lib/lwm2m/lwm2m_rd_client.c @@ -943,7 +943,7 @@ void lwm2m_rd_client_stop(struct lwm2m_ctx *client_ctx, LOG_INF("Stop LWM2M Client: %s", log_strdup(client.ep_name)); } -static int lwm2m_rd_client_init(struct device *dev) +static int lwm2m_rd_client_init(const struct device *dev) { return lwm2m_engine_add_service(lwm2m_rd_client_service, STATE_MACHINE_UPDATE_INTERVAL_MS); diff --git a/subsys/net/lib/openthread/platform/entropy.c b/subsys/net/lib/openthread/platform/entropy.c index 35a3d37bacb5e8..f9dcc39b208a2e 100644 --- a/subsys/net/lib/openthread/platform/entropy.c +++ b/subsys/net/lib/openthread/platform/entropy.c @@ -22,7 +22,7 @@ LOG_MODULE_REGISTER(net_otPlat_entropy, CONFIG_OPENTHREAD_L2_LOG_LEVEL); otError otPlatEntropyGet(uint8_t *aOutput, uint16_t aOutputLength) { /* static to obtain it once in a first call */ - static struct device *dev; + static const struct device *dev; int err; if ((aOutput == NULL) || (aOutputLength == 0)) { diff --git a/subsys/net/lib/openthread/platform/flash.c b/subsys/net/lib/openthread/platform/flash.c index 94f0be07b532dc..ee45b8b1c34f94 100644 --- a/subsys/net/lib/openthread/platform/flash.c +++ b/subsys/net/lib/openthread/platform/flash.c @@ -9,7 +9,7 @@ #include "platform-zephyr.h" -static struct device *flash_dev; +static const struct device *flash_dev; static size_t ot_flash_size; static size_t ot_flash_offset; diff --git a/subsys/net/lib/openthread/platform/radio.c b/subsys/net/lib/openthread/platform/radio.c index b42380bf50e9b4..f91b1c4591146b 100644 --- a/subsys/net/lib/openthread/platform/radio.c +++ b/subsys/net/lib/openthread/platform/radio.c @@ -70,7 +70,7 @@ static uint8_t ack_psdu[ACK_PKT_LENGTH]; static struct net_pkt *tx_pkt; static struct net_buf *tx_payload; -static struct device *radio_dev; +static const struct device *radio_dev; static struct ieee802154_radio_api *radio_api; static int8_t tx_power; @@ -110,7 +110,7 @@ static inline void clear_pending_events(void) atomic_clear(pending_events); } -void energy_detected(struct device *dev, int16_t max_ed) +void energy_detected(const struct device *dev, int16_t max_ed) { if (dev == radio_dev) { energy_detected_value = max_ed; @@ -150,7 +150,7 @@ enum net_verdict ieee802154_radio_handle_ack(struct net_if *iface, return NET_OK; } -void handle_radio_event(struct device *dev, enum ieee802154_event evt, +void handle_radio_event(const struct device *dev, enum ieee802154_event evt, void *event_params) { ARG_UNUSED(event_params); @@ -559,7 +559,7 @@ otRadioFrame *otPlatRadioGetTransmitBuffer(otInstance *aInstance) return &sTransmitFrame; } -static void get_rssi_energy_detected(struct device *dev, int16_t max_ed) +static void get_rssi_energy_detected(const struct device *dev, int16_t max_ed) { ARG_UNUSED(dev); energy_detected_value = max_ed; diff --git a/subsys/net/lib/openthread/platform/uart.c b/subsys/net/lib/openthread/platform/uart.c index 1b13d11421d2e1..73e5ec2566f556 100644 --- a/subsys/net/lib/openthread/platform/uart.c +++ b/subsys/net/lib/openthread/platform/uart.c @@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); struct openthread_uart { struct ring_buf *rx_ringbuf; - struct device *dev; + const struct device *dev; atomic_t tx_busy; atomic_t tx_finished; }; @@ -49,7 +49,7 @@ static bool is_panic_mode; static const uint8_t *write_buffer; static uint16_t write_length; -static void uart_rx_handle(struct device *dev) +static void uart_rx_handle(const struct device *dev) { uint8_t *data; uint32_t len; @@ -85,7 +85,7 @@ static void uart_rx_handle(struct device *dev) } } -static void uart_tx_handle(struct device *dev) +static void uart_tx_handle(const struct device *dev) { uint32_t len; @@ -101,7 +101,7 @@ static void uart_tx_handle(struct device *dev) } } -static void uart_callback(struct device *dev, void *user_data) +static void uart_callback(const struct device *dev, void *user_data) { ARG_UNUSED(user_data); diff --git a/subsys/net/lib/sockets/sockets_can.c b/subsys/net/lib/sockets/sockets_can.c index 97fcc15cdec604..06aa66f66cff26 100644 --- a/subsys/net/lib/sockets/sockets_can.c +++ b/subsys/net/lib/sockets/sockets_can.c @@ -360,7 +360,7 @@ static int close_socket(struct net_context *ctx) { const struct canbus_api *api; struct net_if *iface; - struct device *dev; + const struct device *dev; iface = net_context_get_iface(ctx); dev = net_if_get_device(iface); @@ -481,7 +481,7 @@ static int can_sock_getsockopt_vmeth(void *obj, int level, int optname, if (level == SOL_CAN_RAW) { const struct canbus_api *api; struct net_if *iface; - struct device *dev; + const struct device *dev; if (optval == NULL) { errno = EINVAL; @@ -590,7 +590,7 @@ static int can_sock_setsockopt_vmeth(void *obj, int level, int optname, { const struct canbus_api *api; struct net_if *iface; - struct device *dev; + const struct device *dev; int ret; if (level != SOL_CAN_RAW) { diff --git a/subsys/net/lib/sockets/sockets_tls.c b/subsys/net/lib/sockets/sockets_tls.c index b11d66d8815ad9..9851fb33d9b1c2 100644 --- a/subsys/net/lib/sockets/sockets_tls.c +++ b/subsys/net/lib/sockets/sockets_tls.c @@ -252,13 +252,13 @@ static int dtls_timing_get_delay(void *data) #endif /* CONFIG_NET_SOCKETS_ENABLE_DTLS */ /* Initialize TLS internals. */ -static int tls_init(struct device *unused) +static int tls_init(const struct device *unused) { ARG_UNUSED(unused); int ret; static const unsigned char drbg_seed[] = "zephyr"; - struct device *dev = NULL; + const struct device *dev = NULL; #if defined(CONFIG_ENTROPY_HAS_DRIVER) dev = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); diff --git a/subsys/net/lib/tls_credentials/tls_credentials.c b/subsys/net/lib/tls_credentials/tls_credentials.c index 61f7144f159426..aa47cdc675305a 100644 --- a/subsys/net/lib/tls_credentials/tls_credentials.c +++ b/subsys/net/lib/tls_credentials/tls_credentials.c @@ -16,7 +16,7 @@ static struct tls_credential credentials[CONFIG_TLS_MAX_CREDENTIALS_NUMBER]; /* A mutex for protecting access to the credentials array. */ static struct k_mutex credential_lock; -static int credentials_init(struct device *unused) +static int credentials_init(const struct device *unused) { (void)memset(credentials, 0, sizeof(credentials)); diff --git a/subsys/power/device.c b/subsys/power/device.c index 1beb0acf462a09..99074357039083 100644 --- a/subsys/power/device.c +++ b/subsys/power/device.c @@ -60,7 +60,7 @@ typedef uint16_t device_idx_t; #define DEVICE_IDX_MAX ((device_idx_t)(-1)) /* An array of all devices in the application. */ -static struct device *all_devices; +static const struct device *all_devices; /* Indexes into all_devices for devices that support pm, * in dependency order (later may depend on earlier). @@ -97,7 +97,7 @@ static int _sys_pm_devices(uint32_t state) for (int i = num_pm - 1; i >= 0; i--) { device_idx_t idx = pm_devices[i]; - struct device *dev = &all_devices[idx]; + const struct device *dev = &all_devices[idx]; int rc; /* TODO: Improve the logic by checking device status diff --git a/subsys/power/device_pm.c b/subsys/power/device_pm.c index 45e8a23cf03a38..7658406edb7f8e 100644 --- a/subsys/power/device_pm.c +++ b/subsys/power/device_pm.c @@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(power); #define DEVICE_PM_SYNC (0 << 0) #define DEVICE_PM_ASYNC (1 << 0) -static void device_pm_callback(struct device *dev, +static void device_pm_callback(const struct device *dev, int retval, void *context, void *arg) { __ASSERT(retval == 0, "Device set power state failed"); @@ -38,7 +38,7 @@ static void pm_work_handler(struct k_work *work) { struct device_pm *pm = CONTAINER_OF(work, struct device_pm, work); - struct device *dev = pm->dev; + const struct device *dev = pm->dev; int ret = 0; uint8_t pm_state; @@ -85,7 +85,7 @@ static void pm_work_handler(struct k_work *work) k_poll_signal_raise(&dev->pm->signal, pm_state); } -static int device_pm_request(struct device *dev, +static int device_pm_request(const struct device *dev, uint32_t target_state, uint32_t pm_flags) { int result, signaled = 0; @@ -125,29 +125,29 @@ static int device_pm_request(struct device *dev, return result == target_state ? 0 : -EIO; } -int device_pm_get(struct device *dev) +int device_pm_get(const struct device *dev) { return device_pm_request(dev, DEVICE_PM_ACTIVE_STATE, DEVICE_PM_ASYNC); } -int device_pm_get_sync(struct device *dev) +int device_pm_get_sync(const struct device *dev) { return device_pm_request(dev, DEVICE_PM_ACTIVE_STATE, 0); } -int device_pm_put(struct device *dev) +int device_pm_put(const struct device *dev) { return device_pm_request(dev, DEVICE_PM_SUSPEND_STATE, DEVICE_PM_ASYNC); } -int device_pm_put_sync(struct device *dev) +int device_pm_put_sync(const struct device *dev) { return device_pm_request(dev, DEVICE_PM_SUSPEND_STATE, 0); } -void device_pm_enable(struct device *dev) +void device_pm_enable(const struct device *dev) { k_sem_take(&dev->pm->lock, K_FOREVER); dev->pm->enable = true; @@ -167,7 +167,7 @@ void device_pm_enable(struct device *dev) k_sem_give(&dev->pm->lock); } -void device_pm_disable(struct device *dev) +void device_pm_disable(const struct device *dev) { k_sem_take(&dev->pm->lock, K_FOREVER); dev->pm->enable = false; diff --git a/subsys/power/power.c b/subsys/power/power.c index d458b6511aefa5..4ff7cdb5d80742 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -192,7 +192,7 @@ void _sys_resume(void) } #if CONFIG_DEVICE_POWER_MANAGEMENT -static int sys_pm_init(struct device *dev) +static int sys_pm_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/subsys/random/rand32_ctr_drbg.c b/subsys/random/rand32_ctr_drbg.c index 7cfa20ea5b253a..324c57d406f81e 100644 --- a/subsys/random/rand32_ctr_drbg.c +++ b/subsys/random/rand32_ctr_drbg.c @@ -28,7 +28,7 @@ static K_SEM_DEFINE(state_sem, 1, 1); -static struct device *entropy_driver; +static const struct device *entropy_driver; static const unsigned char drbg_seed[] = CONFIG_CS_CTR_DRBG_PERSONALIZATION; #if defined(CONFIG_MBEDTLS) diff --git a/subsys/random/rand32_entropy_device.c b/subsys/random/rand32_entropy_device.c index 4c57efe152e355..367adcf098da13 100644 --- a/subsys/random/rand32_entropy_device.c +++ b/subsys/random/rand32_entropy_device.c @@ -9,12 +9,12 @@ #include #include -static struct device *entropy_driver; +static const struct device *entropy_driver; #if defined(CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR) uint32_t z_impl_sys_rand32_get(void) { - struct device *dev = entropy_driver; + const struct device *dev = entropy_driver; uint32_t random_num; int ret; @@ -48,7 +48,7 @@ uint32_t z_impl_sys_rand32_get(void) static int rand_get(uint8_t *dst, size_t outlen, bool csrand) { - struct device *dev = entropy_driver; + const struct device *dev = entropy_driver; uint32_t random_num; int ret; diff --git a/subsys/random/rand32_xoroshiro128.c b/subsys/random/rand32_xoroshiro128.c index 1f5dd45bcb7060..280d41c08fb64d 100644 --- a/subsys/random/rand32_xoroshiro128.c +++ b/subsys/random/rand32_xoroshiro128.c @@ -50,7 +50,7 @@ static inline uint64_t rotl(const uint64_t x, int k) return (x << k) | (x >> (64 - k)); } -static int xoroshiro128_initialize(struct device *dev) +static int xoroshiro128_initialize(const struct device *dev) { dev = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); if (!dev) { diff --git a/subsys/shell/modules/device_service.c b/subsys/shell/modules/device_service.c index 1c1fb425f293bd..b5539aa52e5311 100644 --- a/subsys/shell/modules/device_service.c +++ b/subsys/shell/modules/device_service.c @@ -21,7 +21,7 @@ extern struct device __device_end[]; extern struct device __device_SMP_start[]; #endif -static struct device *levels[] = { +static const struct device *levels[] = { __device_PRE_KERNEL_1_start, __device_PRE_KERNEL_2_start, __device_POST_KERNEL_start, @@ -35,7 +35,7 @@ static struct device *levels[] = { static bool device_get_config_level(const struct shell *shell, int level) { - struct device *dev; + const struct device *dev; bool devices = false; for (dev = levels[level]; dev < levels[level+1]; dev++) { @@ -85,7 +85,7 @@ static int cmd_device_levels(const struct shell *shell, static int cmd_device_list(const struct shell *shell, size_t argc, char **argv) { - struct device *dev; + const struct device *dev; ARG_UNUSED(argc); ARG_UNUSED(argv); diff --git a/subsys/shell/shell_dummy.c b/subsys/shell/shell_dummy.c index 29e83dba8ba61f..2ff824d5731b0f 100644 --- a/subsys/shell/shell_dummy.c +++ b/subsys/shell/shell_dummy.c @@ -98,7 +98,7 @@ const struct shell_transport_api shell_dummy_transport_api = { .read = read }; -static int enable_shell_dummy(struct device *arg) +static int enable_shell_dummy(const struct device *arg) { ARG_UNUSED(arg); shell_init(&shell_dummy, NULL, true, true, LOG_LEVEL_INF); diff --git a/subsys/shell/shell_rtt.c b/subsys/shell/shell_rtt.c index e2219c04cbf646..1480a3690c920c 100644 --- a/subsys/shell/shell_rtt.c +++ b/subsys/shell/shell_rtt.c @@ -107,7 +107,7 @@ const struct shell_transport_api shell_rtt_transport_api = { .read = read }; -static int enable_shell_rtt(struct device *arg) +static int enable_shell_rtt(const struct device *arg) { ARG_UNUSED(arg); bool log_backend = CONFIG_SHELL_RTT_INIT_LOG_LEVEL > 0; diff --git a/subsys/shell/shell_telnet.c b/subsys/shell/shell_telnet.c index 1b12d4770d1f07..7618c288c644cf 100644 --- a/subsys/shell/shell_telnet.c +++ b/subsys/shell/shell_telnet.c @@ -485,7 +485,7 @@ const struct shell_transport_api shell_telnet_transport_api = { .read = read }; -static int enable_shell_telnet(struct device *arg) +static int enable_shell_telnet(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/shell/shell_uart.c b/subsys/shell/shell_uart.c index 50e7c2c0c03fd5..9612066f1d9594 100644 --- a/subsys/shell/shell_uart.c +++ b/subsys/shell/shell_uart.c @@ -27,7 +27,7 @@ SHELL_DEFINE(shell_uart, CONFIG_SHELL_PROMPT_UART, &shell_transport_uart, SHELL_FLAG_OLF_CRLF); #ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN -static void uart_rx_handle(struct device *dev, +static void uart_rx_handle(const struct device *dev, const struct shell_uart *sh_uart) { uint8_t *data; @@ -99,7 +99,8 @@ static void uart_rx_handle(struct device *dev, } } -static void uart_tx_handle(struct device *dev, const struct shell_uart *sh_uart) +static void uart_tx_handle(const struct device *dev, + const struct shell_uart *sh_uart) { uint32_t len; int err; @@ -120,7 +121,7 @@ static void uart_tx_handle(struct device *dev, const struct shell_uart *sh_uart) sh_uart->ctrl_blk->context); } -static void uart_callback(struct device *dev, void *user_data) +static void uart_callback(const struct device *dev, void *user_data) { const struct shell_uart *sh_uart = (struct shell_uart *)user_data; @@ -139,7 +140,7 @@ static void uart_callback(struct device *dev, void *user_data) static void uart_irq_init(const struct shell_uart *sh_uart) { #ifdef CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN - struct device *dev = sh_uart->ctrl_blk->dev; + const struct device *dev = sh_uart->ctrl_blk->dev; uart_irq_callback_user_data_set(dev, uart_callback, (void *)sh_uart); uart_irq_rx_enable(dev); @@ -168,7 +169,7 @@ static int init(const struct shell_transport *transport, { const struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx; - sh_uart->ctrl_blk->dev = (struct device *)config; + sh_uart->ctrl_blk->dev = (const struct device *)config; sh_uart->ctrl_blk->handler = evt_handler; sh_uart->ctrl_blk->context = context; @@ -188,7 +189,7 @@ static int uninit(const struct shell_transport *transport) const struct shell_uart *sh_uart = (struct shell_uart *)transport->ctx; if (IS_ENABLED(CONFIG_SHELL_BACKEND_SERIAL_INTERRUPT_DRIVEN)) { - struct device *dev = sh_uart->ctrl_blk->dev; + const struct device *dev = sh_uart->ctrl_blk->dev; uart_irq_rx_disable(dev); } else { @@ -278,10 +279,10 @@ const struct shell_transport_api shell_uart_transport_api = { #endif /* CONFIG_MCUMGR_SMP_SHELL */ }; -static int enable_shell_uart(struct device *arg) +static int enable_shell_uart(const struct device *arg) { ARG_UNUSED(arg); - struct device *dev = + const struct device *dev = device_get_binding(CONFIG_UART_SHELL_ON_DEV_NAME); bool log_backend = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > 0; uint32_t level = diff --git a/subsys/shell/shell_utils.c b/subsys/shell/shell_utils.c index 87c6f27b4c91e2..c1cea352ee551e 100644 --- a/subsys/shell/shell_utils.c +++ b/subsys/shell/shell_utils.c @@ -461,13 +461,13 @@ void shell_cmd_trim(const struct shell *shell) shell->ctx->cmd_buff_pos = shell->ctx->cmd_buff_len; } -struct device *shell_device_lookup(size_t idx, +const struct device *shell_device_lookup(size_t idx, const char *prefix) { size_t match_idx = 0; - struct device *dev; + const struct device *dev; size_t len = z_device_get_all_static(&dev); - struct device *dev_end = dev + len; + const struct device *dev_end = dev + len; while (dev < dev_end) { if (z_device_ready(dev) diff --git a/subsys/storage/flash_map/flash_map.c b/subsys/storage/flash_map/flash_map.c index 25a18ec9795771..954b81f6099cde 100644 --- a/subsys/storage/flash_map/flash_map.c +++ b/subsys/storage/flash_map/flash_map.c @@ -118,7 +118,7 @@ static bool should_bail(const struct flash_pages_info *info, static int flash_area_layout(int idx, uint32_t *cnt, void *ret, flash_page_cb cb, struct layout_data *cb_data) { - struct device *flash_dev; + const struct device *flash_dev; cb_data->area_idx = idx; @@ -180,7 +180,7 @@ int flash_area_get_sectors(int idx, uint32_t *cnt, struct flash_sector *ret) int flash_area_read(const struct flash_area *fa, off_t off, void *dst, size_t len) { - struct device *dev; + const struct device *dev; if (!is_in_flash_area_bounds(fa, off, len)) { return -EINVAL; @@ -194,7 +194,7 @@ int flash_area_read(const struct flash_area *fa, off_t off, void *dst, int flash_area_write(const struct flash_area *fa, off_t off, const void *src, size_t len) { - struct device *flash_dev; + const struct device *flash_dev; int rc; if (!is_in_flash_area_bounds(fa, off, len)) { @@ -218,7 +218,7 @@ int flash_area_write(const struct flash_area *fa, off_t off, const void *src, int flash_area_erase(const struct flash_area *fa, off_t off, size_t len) { - struct device *flash_dev; + const struct device *flash_dev; int rc; if (!is_in_flash_area_bounds(fa, off, len)) { @@ -242,7 +242,7 @@ int flash_area_erase(const struct flash_area *fa, off_t off, size_t len) uint8_t flash_area_align(const struct flash_area *fa) { - struct device *dev; + const struct device *dev; dev = device_get_binding(fa->fa_dev_name); @@ -258,7 +258,7 @@ int flash_area_has_driver(const struct flash_area *fa) return 1; } -struct device *flash_area_get_device(const struct flash_area *fa) +const struct device *flash_area_get_device(const struct flash_area *fa) { return device_get_binding(fa->fa_dev_name); } diff --git a/subsys/storage/stream/stream_flash.c b/subsys/storage/stream/stream_flash.c index 40f4bddc5286cc..dd1e5158b79d33 100644 --- a/subsys/storage/stream/stream_flash.c +++ b/subsys/storage/stream/stream_flash.c @@ -181,7 +181,7 @@ size_t stream_flash_bytes_written(struct stream_flash_ctx *ctx) return ctx->bytes_written; } -int stream_flash_init(struct stream_flash_ctx *ctx, struct device *fdev, +int stream_flash_init(struct stream_flash_ctx *ctx, const struct device *fdev, uint8_t *buf, size_t buf_len, size_t offset, size_t size, stream_flash_callback_t cb) { diff --git a/subsys/tracing/cpu_stats.c b/subsys/tracing/cpu_stats.c index 9902bab63bdd8d..dc01d02e049ffd 100644 --- a/subsys/tracing/cpu_stats.c +++ b/subsys/tracing/cpu_stats.c @@ -163,7 +163,7 @@ static void cpu_stats_log_fn(struct k_work *item) K_MSEC(CONFIG_TRACING_CPU_STATS_INTERVAL)); } -static int cpu_stats_log_init(struct device *dev) +static int cpu_stats_log_init(const struct device *dev) { k_delayed_work_init(&cpu_stats_log, cpu_stats_log_fn); k_delayed_work_submit(&cpu_stats_log, diff --git a/subsys/tracing/sysview/sysview.c b/subsys/tracing/sysview/sysview.c index 04c329e15b04bb..5d14198ecf6b08 100644 --- a/subsys/tracing/sysview/sysview.c +++ b/subsys/tracing/sysview/sysview.c @@ -136,7 +136,7 @@ const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI = { }; -static int sysview_init(struct device *arg) +static int sysview_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/tracing/tracing_backend_uart.c b/subsys/tracing/tracing_backend_uart.c index 5980311188a544..014a50e51e119b 100644 --- a/subsys/tracing/tracing_backend_uart.c +++ b/subsys/tracing/tracing_backend_uart.c @@ -14,10 +14,10 @@ #include #include -static struct device *tracing_uart_dev; +static const struct device *tracing_uart_dev; #ifdef CONFIG_TRACING_HANDLE_HOST_CMD -static void uart_isr(struct device *dev, void *user_data) +static void uart_isr(const struct device *dev, void *user_data) { int rx; uint8_t byte; diff --git a/subsys/tracing/tracing_core.c b/subsys/tracing/tracing_core.c index 86c45f186824ac..87e0968f14ca3d 100644 --- a/subsys/tracing/tracing_core.c +++ b/subsys/tracing/tracing_core.c @@ -80,7 +80,7 @@ static void tracing_set_state(enum tracing_state state) atomic_set(&tracing_state, state); } -static int tracing_init(struct device *arg) +static int tracing_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/usb/class/audio/audio.c b/subsys/usb/class/audio/audio.c index 885061b72fa7ad..98adbc060742b4 100644 --- a/subsys/usb/class/audio/audio.c +++ b/subsys/usb/class/audio/audio.c @@ -774,7 +774,7 @@ static int audio_class_handle_req(struct usb_setup_packet *pSetup, } } -static int usb_audio_device_init(struct device *dev) +static int usb_audio_device_init(const struct device *dev) { LOG_DBG("Init Audio Device: dev %p (%s)", dev, dev->name); @@ -896,7 +896,7 @@ static void audio_receive_cb(uint8_t ep, enum usb_dc_ep_cb_status_code status) } } -void usb_audio_register(struct device *dev, +void usb_audio_register(const struct device *dev, const struct usb_audio_ops *ops) { struct usb_audio_dev_data *audio_dev_data = dev->data; diff --git a/subsys/usb/class/bluetooth.c b/subsys/usb/class/bluetooth.c index cd3a509c544ebf..5511b24dc0ba6f 100644 --- a/subsys/usb/class/bluetooth.c +++ b/subsys/usb/class/bluetooth.c @@ -333,7 +333,7 @@ USBD_CFG_DATA_DEFINE(primary, hci) struct usb_cfg_data bluetooth_config = { .endpoint = bluetooth_ep_data, }; -static int bluetooth_init(struct device *dev) +static int bluetooth_init(const struct device *dev) { int ret; diff --git a/subsys/usb/class/bt_h4.c b/subsys/usb/class/bt_h4.c index 2de683c115f6c0..f3d679167879f8 100644 --- a/subsys/usb/class/bt_h4.c +++ b/subsys/usb/class/bt_h4.c @@ -221,7 +221,7 @@ USBD_CFG_DATA_DEFINE(primary, hci_h4) struct usb_cfg_data bt_h4_config = { .endpoint = bt_h4_ep_data, }; -static int bt_h4_init(struct device *dev) +static int bt_h4_init(const struct device *dev) { int ret; diff --git a/subsys/usb/class/cdc_acm.c b/subsys/usb/class/cdc_acm.c index fadf8269837d14..a2a269d9aec559 100644 --- a/subsys/usb/class/cdc_acm.c +++ b/subsys/usb/class/cdc_acm.c @@ -303,7 +303,7 @@ static void tx_work_handler(struct k_work *work) { struct cdc_acm_dev_data_t *dev_data = CONTAINER_OF(work, struct cdc_acm_dev_data_t, tx_work); - struct device *dev = dev_data->common.dev; + const struct device *dev = dev_data->common.dev; struct usb_cfg_data *cfg = (void *)dev->config; uint8_t ep = cfg->endpoint[ACM_IN_EP_IDX].ep_addr; uint8_t *data; @@ -417,7 +417,7 @@ static void cdc_acm_do_cb(struct cdc_acm_dev_data_t *dev_data, enum usb_dc_status_code status, const uint8_t *param) { - struct device *dev = dev_data->common.dev; + const struct device *dev = dev_data->common.dev; struct usb_cfg_data *cfg = (void *)dev->config; /* Check the USB status and do needed action if required */ @@ -539,7 +539,7 @@ static void cdc_acm_irq_callback_work_handler(struct k_work *work) * * @return 0 always. */ -static int cdc_acm_init(struct device *dev) +static int cdc_acm_init(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); int ret = 0; @@ -566,7 +566,7 @@ static int cdc_acm_init(struct device *dev) * * @return Number of bytes sent. */ -static int cdc_acm_fifo_fill(struct device *dev, +static int cdc_acm_fifo_fill(const struct device *dev, const uint8_t *tx_data, int len) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -603,7 +603,8 @@ static int cdc_acm_fifo_fill(struct device *dev, * * @return Number of bytes read. */ -static int cdc_acm_fifo_read(struct device *dev, uint8_t *rx_data, const int size) +static int cdc_acm_fifo_read(const struct device *dev, uint8_t *rx_data, + const int size) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); uint32_t len; @@ -627,7 +628,7 @@ static int cdc_acm_fifo_read(struct device *dev, uint8_t *rx_data, const int siz * * @return N/A. */ -static void cdc_acm_irq_tx_enable(struct device *dev) +static void cdc_acm_irq_tx_enable(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -645,7 +646,7 @@ static void cdc_acm_irq_tx_enable(struct device *dev) * * @return N/A. */ -static void cdc_acm_irq_tx_disable(struct device *dev) +static void cdc_acm_irq_tx_disable(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -659,7 +660,7 @@ static void cdc_acm_irq_tx_disable(struct device *dev) * * @return 1 if a Tx IRQ is pending, 0 otherwise. */ -static int cdc_acm_irq_tx_ready(struct device *dev) +static int cdc_acm_irq_tx_ready(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -677,7 +678,7 @@ static int cdc_acm_irq_tx_ready(struct device *dev) * * @return N/A */ -static void cdc_acm_irq_rx_enable(struct device *dev) +static void cdc_acm_irq_rx_enable(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -695,7 +696,7 @@ static void cdc_acm_irq_rx_enable(struct device *dev) * * @return N/A. */ -static void cdc_acm_irq_rx_disable(struct device *dev) +static void cdc_acm_irq_rx_disable(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -709,7 +710,7 @@ static void cdc_acm_irq_rx_disable(struct device *dev) * * @return 1 if an IRQ is ready, 0 otherwise. */ -static int cdc_acm_irq_rx_ready(struct device *dev) +static int cdc_acm_irq_rx_ready(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -727,7 +728,7 @@ static int cdc_acm_irq_rx_ready(struct device *dev) * * @return 1 if a Tx or Rx IRQ is pending, 0 otherwise. */ -static int cdc_acm_irq_is_pending(struct device *dev) +static int cdc_acm_irq_is_pending(const struct device *dev) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -747,7 +748,7 @@ static int cdc_acm_irq_is_pending(struct device *dev) * * @return Always 1 */ -static int cdc_acm_irq_update(struct device *dev) +static int cdc_acm_irq_update(const struct device *dev) { ARG_UNUSED(dev); @@ -762,7 +763,7 @@ static int cdc_acm_irq_update(struct device *dev) * * @return N/A */ -static void cdc_acm_irq_callback_set(struct device *dev, +static void cdc_acm_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *cb_data) { @@ -773,7 +774,7 @@ static void cdc_acm_irq_callback_set(struct device *dev, } #if defined(CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT) -int cdc_acm_dte_rate_callback_set(struct device *dev, +int cdc_acm_dte_rate_callback_set(const struct device *dev, cdc_dte_rate_callback_t callback) { struct cdc_acm_dev_data_t *const dev_data = DEV_DATA(dev); @@ -800,7 +801,7 @@ int cdc_acm_dte_rate_callback_set(struct device *dev, * * @return N/A. */ -static void cdc_acm_baudrate_set(struct device *dev, uint32_t baudrate) +static void cdc_acm_baudrate_set(const struct device *dev, uint32_t baudrate) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -818,7 +819,8 @@ static void cdc_acm_baudrate_set(struct device *dev, uint32_t baudrate) * * @return N/A. */ -static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) +static int cdc_acm_send_notification(const struct device *dev, + uint16_t serial_state) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); struct usb_cfg_data * const cfg = (void *)dev->config; @@ -859,7 +861,7 @@ static int cdc_acm_send_notification(struct device *dev, uint16_t serial_state) * * @return 0 if successful, failed otherwise. */ -static int cdc_acm_line_ctrl_set(struct device *dev, +static int cdc_acm_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -940,7 +942,7 @@ static int cdc_acm_line_ctrl_set(struct device *dev, * * @return 0 if successful, failed otherwise. */ -static int cdc_acm_line_ctrl_get(struct device *dev, +static int cdc_acm_line_ctrl_get(const struct device *dev, uint32_t ctrl, uint32_t *val) { struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(dev); @@ -972,7 +974,7 @@ static int cdc_acm_line_ctrl_get(struct device *dev, * exported by CDC ACM driver. Apps should use fifo_read API instead. */ -static int cdc_acm_poll_in(struct device *dev, unsigned char *c) +static int cdc_acm_poll_in(const struct device *dev, unsigned char *c) { ARG_UNUSED(dev); ARG_UNUSED(c); @@ -986,7 +988,7 @@ static int cdc_acm_poll_in(struct device *dev, unsigned char *c) * The UART poll method for USB UART is simulated by waiting till * we get the next BULK In upcall from the USB device controller or 100 ms. */ -static void cdc_acm_poll_out(struct device *dev, +static void cdc_acm_poll_out(const struct device *dev, unsigned char c) { cdc_acm_fifo_fill(dev, &c, 1); diff --git a/subsys/usb/class/hid/core.c b/subsys/usb/class/hid/core.c index a809bbb884cdd2..38dc4a8f892a1d 100644 --- a/subsys/usb/class/hid/core.c +++ b/subsys/usb/class/hid/core.c @@ -673,7 +673,7 @@ int usb_hid_init(const struct device *dev) return 0; } -void usb_hid_register_device(struct device *dev, const uint8_t *desc, +void usb_hid_register_device(const struct device *dev, const uint8_t *desc, size_t size, const struct hid_ops *ops) { struct hid_device_info *dev_data = dev->data; @@ -723,7 +723,7 @@ static const struct usb_hid_device_api { void (*init)(void); } hid_api; -static int usb_hid_device_init(struct device *dev) +static int usb_hid_device_init(const struct device *dev) { LOG_DBG("Init HID Device: dev %p (%s)", dev, dev->name); diff --git a/subsys/usb/class/mass_storage.c b/subsys/usb/class/mass_storage.c index a5a8a150d9edff..4739847b4d36a3 100644 --- a/subsys/usb/class/mass_storage.c +++ b/subsys/usb/class/mass_storage.c @@ -946,7 +946,7 @@ static void mass_thread_main(int arg1, int unused) * * @return negative errno code on fatal failure, 0 otherwise */ -static int mass_storage_init(struct device *dev) +static int mass_storage_init(const struct device *dev) { uint32_t block_size = 0U; diff --git a/subsys/usb/class/netusb/function_rndis.c b/subsys/usb/class/netusb/function_rndis.c index e37b69d85df43c..3335a01b4de088 100644 --- a/subsys/usb/class/netusb/function_rndis.c +++ b/subsys/usb/class/netusb/function_rndis.c @@ -1075,7 +1075,7 @@ static struct usb_os_descriptor os_desc = { }; #endif /* CONFIG_USB_DEVICE_OS_DESC */ -static int rndis_init(struct device *arg) +static int rndis_init(const struct device *arg) { ARG_UNUSED(arg); diff --git a/subsys/usb/class/netusb/netusb.c b/subsys/usb/class/netusb/netusb.c index 39c14eaa842e95..d58edc206204ac 100644 --- a/subsys/usb/class/netusb/netusb.c +++ b/subsys/usb/class/netusb/netusb.c @@ -26,7 +26,7 @@ static struct __netusb { const struct netusb_function *func; } netusb; -static int netusb_send(struct device *dev, struct net_pkt *pkt) +static int netusb_send(const struct device *dev, struct net_pkt *pkt) { int ret; @@ -146,7 +146,7 @@ static const struct ethernet_api netusb_api_funcs = { .send = netusb_send, }; -static int netusb_init_dev(struct device *dev) +static int netusb_init_dev(const struct device *dev) { ARG_UNUSED(dev); return 0; diff --git a/subsys/usb/class/usb_dfu.c b/subsys/usb/class/usb_dfu.c index d36a083f3209f8..fc7c1a7d1dd2b2 100644 --- a/subsys/usb/class/usb_dfu.c +++ b/subsys/usb/class/usb_dfu.c @@ -761,7 +761,7 @@ static void dfu_work_handler(struct k_work *item) } } -static int usb_dfu_init(struct device *dev) +static int usb_dfu_init(const struct device *dev) { const struct flash_area *fa; diff --git a/subsys/usb/usb_descriptor.c b/subsys/usb/usb_descriptor.c index 0772fba5ecdc5e..7528657c0c6044 100644 --- a/subsys/usb/usb_descriptor.c +++ b/subsys/usb/usb_descriptor.c @@ -484,7 +484,7 @@ struct usb_dev_data *usb_get_dev_data_by_cfg(sys_slist_t *list, struct usb_dev_data *dev_data; SYS_SLIST_FOR_EACH_CONTAINER(list, dev_data, node) { - struct device *dev = dev_data->dev; + const struct device *dev = dev_data->dev; const struct usb_cfg_data *cfg_cur = dev->config; if (cfg_cur == cfg) { @@ -503,7 +503,7 @@ struct usb_dev_data *usb_get_dev_data_by_iface(sys_slist_t *list, struct usb_dev_data *dev_data; SYS_SLIST_FOR_EACH_CONTAINER(list, dev_data, node) { - struct device *dev = dev_data->dev; + const struct device *dev = dev_data->dev; const struct usb_cfg_data *cfg = dev->config; const struct usb_if_descriptor *if_desc = cfg->interface_descriptor; @@ -523,7 +523,7 @@ struct usb_dev_data *usb_get_dev_data_by_ep(sys_slist_t *list, uint8_t ep) struct usb_dev_data *dev_data; SYS_SLIST_FOR_EACH_CONTAINER(list, dev_data, node) { - struct device *dev = dev_data->dev; + const struct device *dev = dev_data->dev; const struct usb_cfg_data *cfg = dev->config; const struct usb_ep_cfg_data *ep_data = cfg->endpoint; diff --git a/subsys/usb/usb_descriptor.h b/subsys/usb/usb_descriptor.h index 3ad856add18eb1..5d125107aca015 100644 --- a/subsys/usb/usb_descriptor.h +++ b/subsys/usb/usb_descriptor.h @@ -39,7 +39,7 @@ /* Common part of device data */ struct usb_dev_data { - struct device *dev; + const struct device *dev; sys_snode_t node; }; diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index d2a8ef3c3d45bb..06ac39b929a416 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -1065,7 +1065,7 @@ static int usb_vbus_set(bool on) #if DT_NODE_HAS_STATUS(USB_DEV_NODE, okay) && \ DT_NODE_HAS_PROP(USB_DEV_NODE, vbus_gpios) int ret = 0; - struct device *gpio_dev; + const struct device *gpio_dev; gpio_dev = device_get_binding(DT_LABEL(USB_DEV_NODE)); if (!gpio_dev) { @@ -1432,7 +1432,7 @@ int usb_enable(usb_dc_status_callback status_cb) * This function configures the USB device stack based on USB descriptor and * usb_cfg_data. */ -static int usb_device_init(struct device *dev) +static int usb_device_init(const struct device *dev) { uint8_t *device_descriptor; diff --git a/tests/application_development/cpp/src/main.cpp b/tests/application_development/cpp/src/main.cpp index 5505ef6b5ff430..641c8232b502aa 100644 --- a/tests/application_development/cpp/src/main.cpp +++ b/tests/application_development/cpp/src/main.cpp @@ -50,7 +50,7 @@ static struct foo foos[5]; BUILD_ASSERT(ARRAY_SIZE(foos) == 5, "expected 5 elements"); /* Check that SYS_INIT() compiles. */ -static int test_init(struct device *dev) +static int test_init(const struct device *dev) { return 0; } diff --git a/tests/arch/x86/info/src/timer.c b/tests/arch/x86/info/src/timer.c index 0c5f4f22152fad..99a72f8a7aca22 100644 --- a/tests/arch/x86/info/src/timer.c +++ b/tests/arch/x86/info/src/timer.c @@ -9,7 +9,7 @@ #define NR_SAMPLES 10 /* sample timer 10 times */ -static uint32_t sync(struct device *cmos) +static uint32_t sync(const struct device *cmos) { uint32_t this, last; int err; @@ -34,7 +34,7 @@ static uint32_t sync(struct device *cmos) void timer(void) { - struct device *cmos; + const struct device *cmos; #if defined(CONFIG_LOAPIC_TIMER) printk("TIMER: legacy local APIC"); diff --git a/tests/bluetooth/mesh/src/microbit.c b/tests/bluetooth/mesh/src/microbit.c index 13f9d4e6e63598..4a644bbd84d6c8 100644 --- a/tests/bluetooth/mesh/src/microbit.c +++ b/tests/bluetooth/mesh/src/microbit.c @@ -15,9 +15,9 @@ #include "board.h" static uint32_t oob_number; -static struct device *gpio; +static const struct device *gpio; -static void button_pressed(struct device *dev, struct gpio_callback *cb, +static void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct mb_display *disp = mb_display_get(); diff --git a/tests/boards/altera_max10/i2c_master/src/i2c_master.c b/tests/boards/altera_max10/i2c_master/src/i2c_master.c index c3cdc3f82ca574..63605a0956b4d9 100644 --- a/tests/boards/altera_max10/i2c_master/src/i2c_master.c +++ b/tests/boards/altera_max10/i2c_master/src/i2c_master.c @@ -28,7 +28,7 @@ #define ADV7513_WRITE_TEST_REG 0x2 #define WRITE_TEST_VAL 0x66 -static int powerup_adv7513(struct device *i2c_dev) +static int powerup_adv7513(const struct device *i2c_dev) { uint8_t data; @@ -65,7 +65,7 @@ static int powerup_adv7513(struct device *i2c_dev) static int test_i2c_adv7513(void) { - struct device *i2c_dev = device_get_binding(DT_LABEL(DT_INST(0, nios2_i2c))); + const struct device *i2c_dev = device_get_binding(DT_LABEL(DT_INST(0, nios2_i2c))); uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER; uint8_t data; diff --git a/tests/boards/altera_max10/msgdma/src/dma.c b/tests/boards/altera_max10/msgdma/src/dma.c index 3afd46501fe4fe..b8de3d6cb4283a 100644 --- a/tests/boards/altera_max10/msgdma/src/dma.c +++ b/tests/boards/altera_max10/msgdma/src/dma.c @@ -26,7 +26,7 @@ static char rx_data[DMA_BUFF_SIZE]; static struct dma_config dma_cfg = {0}; static struct dma_block_config dma_block_cfg = {0}; -static void dma_user_callback(struct device *dma_dev, void *arg, +static void dma_user_callback(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { if (error_code == 0) { @@ -40,7 +40,7 @@ static void dma_user_callback(struct device *dma_dev, void *arg, void test_msgdma(void) { - struct device *dma; + const struct device *dma; static uint32_t chan_id; int i; diff --git a/tests/boards/altera_max10/qspi/src/qspi_flash.c b/tests/boards/altera_max10/qspi/src/qspi_flash.c index 1f6cd084e2eee5..964b8e03340f59 100644 --- a/tests/boards/altera_max10/qspi/src/qspi_flash.c +++ b/tests/boards/altera_max10/qspi/src/qspi_flash.c @@ -17,7 +17,7 @@ void test_qspi_flash(void) { - struct device *flash_dev; + const struct device *flash_dev; uint32_t i, offset, rd_val, wr_val; uint8_t wr_buf[4] = {0xAA, 0xBB, 0xCC, 0xDD}; uint8_t rd_buf[2]; diff --git a/tests/boards/intel_s1000_crb/main/src/dma_test.c b/tests/boards/intel_s1000_crb/main/src/dma_test.c index a2ccb5d81c89c1..07c9ecad8ad20d 100644 --- a/tests/boards/intel_s1000_crb/main/src/dma_test.c +++ b/tests/boards/intel_s1000_crb/main/src/dma_test.c @@ -97,10 +97,10 @@ static struct transfers transfer_blocks[MAX_TRANSFERS] = { .size = sizeof(tx_data4), }, }; -static struct device *dma_device; +static const struct device *dma_device; static uint32_t current_block_count, total_block_count; -static void test_done(struct device *dma_dev, void *arg, +static void test_done(const struct device *dma_dev, void *arg, uint32_t channel, int error_code) { uint32_t src, dst; diff --git a/tests/boards/intel_s1000_crb/main/src/gpio_test.c b/tests/boards/intel_s1000_crb/main/src/gpio_test.c index 56b97531065380..59ef5c48c1c264 100644 --- a/tests/boards/intel_s1000_crb/main/src/gpio_test.c +++ b/tests/boards/intel_s1000_crb/main/src/gpio_test.c @@ -49,15 +49,15 @@ extern struct k_sem thread_sem; -void gpio_test_callback(struct device *port, - struct gpio_callback *cb, uint32_t pins) +void gpio_test_callback(const struct device *port, + struct gpio_callback *cb, uint32_t pins) { printk(GPIO_NAME "%d triggered\n", GPIO_INT_PIN); } static struct gpio_callback gpio_cb; -void setup_gpio(struct device *gpio_dev) +void setup_gpio(const struct device *gpio_dev) { int ret; @@ -94,7 +94,7 @@ void setup_gpio(struct device *gpio_dev) /* gpio_thread is a static thread that is spawned automatically */ void gpio_thread(void *dummy1, void *dummy2, void *dummy3) { - struct device *gpio_dev; + const struct device *gpio_dev; int ret; ARG_UNUSED(dummy1); diff --git a/tests/boards/intel_s1000_crb/main/src/i2c_test.c b/tests/boards/intel_s1000_crb/main/src/i2c_test.c index 5b2fde337123dd..61cada6311ce78 100644 --- a/tests/boards/intel_s1000_crb/main/src/i2c_test.c +++ b/tests/boards/intel_s1000_crb/main/src/i2c_test.c @@ -54,7 +54,8 @@ extern struct k_sem thread_sem; -void test_i2c_write_led(struct device *i2c_dev, uint16_t i2c_slave_led, uint8_t color) +void test_i2c_write_led(const struct device *i2c_dev, uint16_t i2c_slave_led, + uint8_t color) { int ret; int led_val[6]; @@ -120,7 +121,7 @@ void test_i2c_write_led(struct device *i2c_dev, uint16_t i2c_slave_led, uint8_t } } -void test_i2c_read_led(struct device *i2c_dev, uint16_t i2c_slave_led) +void test_i2c_read_led(const struct device *i2c_dev, uint16_t i2c_slave_led) { int ret; uint8_t data = 0U; @@ -136,7 +137,7 @@ void test_i2c_read_led(struct device *i2c_dev, uint16_t i2c_slave_led) /* i2c_thread is a static thread that is spawned automatically */ void i2c_thread(void *dummy1, void *dummy2, void *dummy3) { - struct device *i2c_dev; + const struct device *i2c_dev; int toggle = LED_LIGHT_PAT; ARG_UNUSED(dummy1); diff --git a/tests/boards/intel_s1000_crb/main/src/i2s_test.c b/tests/boards/intel_s1000_crb/main/src/i2s_test.c index f0afb0fd494dc2..5479c9f7d64117 100644 --- a/tests/boards/intel_s1000_crb/main/src/i2s_test.c +++ b/tests/boards/intel_s1000_crb/main/src/i2s_test.c @@ -55,7 +55,7 @@ static struct k_mem_slab i2s_mem_slab; void test_i2s_bidirectional_transfer_configure(void) { int ret; - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; k_mem_slab_init(&i2s_mem_slab, audio_buffers, BLOCK_SIZE_BYTES, @@ -96,7 +96,7 @@ void test_i2s_bidirectional_transfer_configure(void) */ void test_i2s_bidirectional_transfer(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int frames = 0; void *buffer; size_t size; diff --git a/tests/boards/intel_s1000_crb/main/src/spi_flash.c b/tests/boards/intel_s1000_crb/main/src/spi_flash.c index ab4766c2bf9406..d024d68b32d4ff 100644 --- a/tests/boards/intel_s1000_crb/main/src/spi_flash.c +++ b/tests/boards/intel_s1000_crb/main/src/spi_flash.c @@ -51,7 +51,7 @@ int flash_region_is_empty(uint32_t off, void *dst, uint32_t len) void test_flash(void) { - struct device *flash_dev; + const struct device *flash_dev; uint8_t buf[TEST_DATA_LEN]; uint32_t magic[4]; int i; diff --git a/tests/boards/intel_s1000_crb/main/src/test_hid.c b/tests/boards/intel_s1000_crb/main/src/test_hid.c index 7ef209247f2b47..d8c7cd08c45aa7 100644 --- a/tests/boards/intel_s1000_crb/main/src/test_hid.c +++ b/tests/boards/intel_s1000_crb/main/src/test_hid.c @@ -98,7 +98,7 @@ static struct hid_ops ops = { void hid_thread(void) { uint8_t report_1[2] = { REPORT_ID_1, 0x00 }; - struct device *hid_dev; + const struct device *hid_dev; int ret, wrote; LOG_DBG("Starting application"); diff --git a/tests/drivers/adc/adc_api/src/main.c b/tests/drivers/adc/adc_api/src/main.c index 77b35ab4153d6f..fa5c0f2be2d36b 100644 --- a/tests/drivers/adc/adc_api/src/main.c +++ b/tests/drivers/adc/adc_api/src/main.c @@ -15,7 +15,7 @@ extern void test_adc_asynchronous_call(void); extern void test_adc_sample_with_interval(void); extern void test_adc_repeated_samplings(void); extern void test_adc_invalid_request(void); -extern struct device *get_adc_device(void); +extern const struct device *get_adc_device(void); extern struct k_poll_signal async_sig; void test_main(void) diff --git a/tests/drivers/adc/adc_api/src/test_adc.c b/tests/drivers/adc/adc_api/src/test_adc.c index f6412c25a76e43..b5b754e6f601e1 100644 --- a/tests/drivers/adc/adc_api/src/test_adc.c +++ b/tests/drivers/adc/adc_api/src/test_adc.c @@ -235,15 +235,15 @@ static const struct adc_channel_cfg m_2nd_channel_cfg = { }; #endif /* defined(ADC_2ND_CHANNEL_ID) */ -struct device *get_adc_device(void) +const struct device *get_adc_device(void) { return device_get_binding(ADC_DEVICE_NAME); } -static struct device *init_adc(void) +static const struct device *init_adc(void) { int ret; - struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME); + const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME); zassert_not_null(adc_dev, "Cannot get ADC device"); @@ -295,7 +295,7 @@ static int test_task_one_channel(void) .resolution = ADC_RESOLUTION, }; - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; @@ -329,7 +329,7 @@ static int test_task_two_channels(void) .resolution = ADC_RESOLUTION, }; - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; @@ -378,7 +378,7 @@ static int test_task_asynchronous_call(void) K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &async_sig); - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; @@ -408,10 +408,9 @@ void test_adc_asynchronous_call(void) /* * test_adc_sample_with_interval */ -static enum adc_action sample_with_interval_callback( - struct device *dev, - const struct adc_sequence *sequence, - uint16_t sampling_index) +static enum adc_action sample_with_interval_callback(const struct device *dev, + const struct adc_sequence *sequence, + uint16_t sampling_index) { TC_PRINT("%s: sampling %d\n", __func__, sampling_index); return ADC_ACTION_CONTINUE; @@ -433,7 +432,7 @@ static int test_task_with_interval(void) .resolution = ADC_RESOLUTION, }; - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; @@ -456,10 +455,9 @@ void test_adc_sample_with_interval(void) * test_adc_repeated_samplings */ static uint8_t m_samplings_done; -static enum adc_action repeated_samplings_callback( - struct device *dev, - const struct adc_sequence *sequence, - uint16_t sampling_index) +static enum adc_action repeated_samplings_callback(const struct device *dev, + const struct adc_sequence *sequence, + uint16_t sampling_index) { ++m_samplings_done; TC_PRINT("%s: done %d\n", __func__, m_samplings_done); @@ -521,7 +519,7 @@ static int test_task_repeated_samplings(void) .resolution = ADC_RESOLUTION, }; - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; @@ -551,7 +549,7 @@ static int test_task_invalid_request(void) .resolution = 0, /* intentionally invalid value */ }; - struct device *adc_dev = init_adc(); + const struct device *adc_dev = init_adc(); if (!adc_dev) { return TC_FAIL; diff --git a/tests/drivers/can/api/src/main.c b/tests/drivers/can/api/src/main.c index 30bdc3f18a0359..bb5afc848815ca 100644 --- a/tests/drivers/can/api/src/main.c +++ b/tests/drivers/can/api/src/main.c @@ -51,7 +51,7 @@ CAN_DEFINE_MSGQ(can_msgq, 5); struct k_sem rx_isr_sem; struct k_sem rx_cb_sem; struct k_sem tx_cb_sem; -struct device *can_dev; +const struct device *can_dev; struct zcan_frame test_std_msg = { .id_type = CAN_STANDARD_IDENTIFIER, @@ -245,7 +245,8 @@ static void rx_ext_mask_cb(struct zcan_frame *msg, void *arg) k_sem_give(&rx_cb_sem); } -static void send_test_msg(struct device *can_dev, struct zcan_frame *msg) +static void send_test_msg(const struct device *can_dev, + struct zcan_frame *msg) { int ret; @@ -255,7 +256,8 @@ static void send_test_msg(struct device *can_dev, struct zcan_frame *msg) zassert_equal(ret, CAN_TX_OK, "Can't send a message. Err: %d", ret); } -static void send_test_msg_nowait(struct device *can_dev, struct zcan_frame *msg) +static void send_test_msg_nowait(const struct device *can_dev, + struct zcan_frame *msg) { int ret; @@ -282,7 +284,7 @@ static void send_test_msg_nowait(struct device *can_dev, struct zcan_frame *msg) zassert_equal(ret, CAN_TX_OK, "Can't send a message. Err: %d", ret); } -static inline int attach_msgq(struct device *can_dev, +static inline int attach_msgq(const struct device *can_dev, const struct zcan_filter *filter) { int filter_id; @@ -295,8 +297,8 @@ static inline int attach_msgq(struct device *can_dev, return filter_id; } -static inline int attach_workq(struct device *can_dev, - const struct zcan_filter *filter) +static inline int attach_workq(const struct device *can_dev, + const struct zcan_filter *filter) { int filter_id; @@ -329,7 +331,7 @@ static inline int attach_workq(struct device *can_dev, return filter_id; } -static inline int attach_isr(struct device *can_dev, +static inline int attach_isr(const struct device *can_dev, const struct zcan_filter *filter) { int filter_id; diff --git a/tests/drivers/can/stm32/src/main.c b/tests/drivers/can/stm32/src/main.c index f5086a57164dd7..7d2bf76c0667fc 100644 --- a/tests/drivers/can/stm32/src/main.c +++ b/tests/drivers/can/stm32/src/main.c @@ -109,7 +109,8 @@ static inline void check_msg(struct zcan_frame *msg1, struct zcan_frame *msg2) zassert_equal(cmp_res, 0, "Received data differ"); } -static void send_test_msg(struct device *can_dev, struct zcan_frame *msg) +static void send_test_msg(const struct device *can_dev, + struct zcan_frame *msg) { int ret; @@ -126,7 +127,7 @@ static void send_test_msg(struct device *can_dev, struct zcan_frame *msg) */ static void test_filter_handling(void) { - struct device *can_dev; + const struct device *can_dev; int ret, filter_id_1, filter_id_2; struct zcan_frame msg_buffer; diff --git a/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c b/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c index ac21f60bcd024c..cfc2c994c43ee2 100644 --- a/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c +++ b/tests/drivers/clock_control/clock_control_api/src/test_clock_control.c @@ -55,7 +55,7 @@ typedef bool (*test_capability_check_t)(const char *dev_name, static void setup_instance(const char *dev_name, clock_control_subsys_t subsys) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); int err; k_busy_wait(1000); do { @@ -82,7 +82,7 @@ static void tear_down_instance(const char *dev_name, { #if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_clock) /* Turn on LF clock using onoff service if it is disabled. */ - struct device *clk = + const struct device *clk = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock))); struct onoff_client cli; struct onoff_manager *mgr = @@ -143,7 +143,7 @@ static void test_on_off_status_instance(const char *dev_name, clock_control_subsys_t subsys, uint32_t startup_us) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); enum clock_control_status status; int err; @@ -173,7 +173,7 @@ static void test_on_off_status(void) test_all_instances(test_on_off_status_instance, NULL); } -static void async_capable_callback(struct device *dev, +static void async_capable_callback(const struct device *dev, clock_control_subsys_t subsys, void *user_data) { @@ -183,7 +183,7 @@ static void async_capable_callback(struct device *dev, /* Function checks if clock supports asynchronous starting. */ static bool async_capable(const char *dev_name, clock_control_subsys_t subsys) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct clock_control_async_data data = { .cb = async_capable_callback }; @@ -212,7 +212,7 @@ static bool async_capable(const char *dev_name, clock_control_subsys_t subsys) /* * Test checks that callbacks are called after clock is started. */ -static void clock_on_callback(struct device *dev, +static void clock_on_callback(const struct device *dev, clock_control_subsys_t subsys, void *user_data) { @@ -225,7 +225,7 @@ static void test_async_on_instance(const char *dev_name, clock_control_subsys_t subsys, uint32_t startup_us) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); enum clock_control_status status; int err; bool executed = false; @@ -264,7 +264,7 @@ static void test_async_on_stopped_on_instance(const char *dev_name, clock_control_subsys_t subsys, uint32_t startup_us) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); enum clock_control_status status; int err; int key; @@ -306,7 +306,7 @@ static void test_double_start_on_instance(const char *dev_name, clock_control_subsys_t subsys, uint32_t startup_us) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); enum clock_control_status status; int err; @@ -334,7 +334,7 @@ static void test_double_stop_on_instance(const char *dev_name, clock_control_subsys_t subsys, uint32_t startup_us) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); enum clock_control_status status; int err; diff --git a/tests/drivers/clock_control/nrf_clock_calibration/src/mock_temp_nrf5.c b/tests/drivers/clock_control/nrf_clock_calibration/src/mock_temp_nrf5.c index 4d9b0f67be7c16..6580803c1da077 100644 --- a/tests/drivers/clock_control/nrf_clock_calibration/src/mock_temp_nrf5.c +++ b/tests/drivers/clock_control/nrf_clock_calibration/src/mock_temp_nrf5.c @@ -18,21 +18,21 @@ void mock_temp_nrf5_value_set(struct sensor_value *val) value = *val; } -static int mock_temp_nrf5_init(struct device *dev) +static int mock_temp_nrf5_init(const struct device *dev) { return 0; } -static int mock_temp_nrf5_sample_fetch(struct device *dev, +static int mock_temp_nrf5_sample_fetch(const struct device *dev, enum sensor_channel chan) { k_sleep(K_MSEC(1)); return 0; } -static int mock_temp_nrf5_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static int mock_temp_nrf5_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { *val = value; return 0; diff --git a/tests/drivers/clock_control/nrf_clock_calibration/src/test_nrf_clock_calibration.c b/tests/drivers/clock_control/nrf_clock_calibration/src/test_nrf_clock_calibration.c index 69ea1b0b814e64..08e233c53dcce3 100644 --- a/tests/drivers/clock_control/nrf_clock_calibration/src/test_nrf_clock_calibration.c +++ b/tests/drivers/clock_control/nrf_clock_calibration/src/test_nrf_clock_calibration.c @@ -19,7 +19,8 @@ LOG_MODULE_REGISTER(test); extern void mock_temp_nrf5_value_set(struct sensor_value *val); -static void turn_on_clock(struct device *dev, clock_control_subsys_t subsys) +static void turn_on_clock(const struct device *dev, + clock_control_subsys_t subsys) { int err; int res; @@ -35,7 +36,8 @@ static void turn_on_clock(struct device *dev, clock_control_subsys_t subsys) } } -static void turn_off_clock(struct device *dev, clock_control_subsys_t subsys) +static void turn_off_clock(const struct device *dev, + clock_control_subsys_t subsys) { int err; struct onoff_manager *mgr = z_nrf_clock_control_get_onoff(subsys); @@ -110,7 +112,7 @@ static void test_basic_clock_calibration(void) /* Test checks if calibration happens just after clock is enabled. */ static void test_calibration_after_enabling_lfclk(void) { - struct device *clk_dev = + const struct device *clk_dev = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock))); struct sensor_value value = { .val1 = 0, .val2 = 0 }; diff --git a/tests/drivers/clock_control/nrf_onoff_and_bt/src/main.c b/tests/drivers/clock_control/nrf_onoff_and_bt/src/main.c index 5a506540e2cd2f..461613199b3e69 100644 --- a/tests/drivers/clock_control/nrf_onoff_and_bt/src/main.c +++ b/tests/drivers/clock_control/nrf_onoff_and_bt/src/main.c @@ -67,7 +67,8 @@ static void bt_timeout_handler(struct k_timer *timer) K_TIMER_DEFINE(timer1, bt_timeout_handler, NULL); -static void check_hf_status(struct device *dev, bool exp_on, bool sw_check) +static void check_hf_status(const struct device *dev, bool exp_on, + bool sw_check) { nrf_clock_hfclk_t type; @@ -98,9 +99,9 @@ static void check_hf_status(struct device *dev, bool exp_on, bool sw_check) */ static void test_onoff_interrupted(void) { - struct device *clock_dev = + const struct device *clock_dev = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock))); - struct device *entropy = + const struct device *entropy = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); struct onoff_client cli; uint64_t start_time = k_uptime_get(); @@ -193,9 +194,9 @@ K_TIMER_DEFINE(timer2, onoff_timeout_handler, NULL); */ static void test_bt_interrupted(void) { - struct device *clock_dev = + const struct device *clock_dev = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock))); - struct device *entropy = + const struct device *entropy = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL); uint64_t start_time = k_uptime_get(); uint64_t elapsed; diff --git a/tests/drivers/clock_control/onoff/src/test_clock_control_onoff.c b/tests/drivers/clock_control/onoff/src/test_clock_control_onoff.c index 8ca4b1175d2958..8918dec21da3f2 100644 --- a/tests/drivers/clock_control/onoff/src/test_clock_control_onoff.c +++ b/tests/drivers/clock_control/onoff/src/test_clock_control_onoff.c @@ -17,7 +17,7 @@ static struct onoff_manager *get_mgr(void) static bool clock_is_off(void) { - struct device *clk = + const struct device *clk = device_get_binding(DT_LABEL(DT_INST(0, nordic_nrf_clock))); return clock_control_get_status(clk, CLOCK_CONTROL_NRF_SUBSYS_HF) == diff --git a/tests/drivers/counter/counter_basic_api/src/test_counter.c b/tests/drivers/counter/counter_basic_api/src/test_counter.c index 495ce7bcce5e83..798df17439b2cd 100644 --- a/tests/drivers/counter/counter_basic_api/src/test_counter.c +++ b/tests/drivers/counter/counter_basic_api/src/test_counter.c @@ -13,7 +13,7 @@ LOG_MODULE_REGISTER(test); static struct k_sem top_cnt_sem; static struct k_sem alarm_cnt_sem; -static void top_handler(struct device *dev, void *user_data); +static void top_handler(const struct device *dev, void *user_data); void *exp_user_data = (void *)199; @@ -92,7 +92,7 @@ static void counter_setup_instance(const char *dev_name) static void counter_tear_down_instance(const char *dev_name) { int err; - struct device *dev; + const struct device *dev; struct counter_top_cfg top_cfg = { .callback = NULL, .user_data = NULL, @@ -137,7 +137,7 @@ static void test_all_instances(counter_test_func_t func, static bool set_top_value_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct counter_top_cfg cfg = { .ticks = counter_get_top_value(dev) - 1 }; @@ -157,7 +157,7 @@ static bool set_top_value_capable(const char *dev_name) return true; } -static void top_handler(struct device *dev, void *user_data) +static void top_handler(const struct device *dev, void *user_data) { zassert_true(user_data == exp_user_data, "%s: Unexpected callback", dev->name); @@ -166,7 +166,7 @@ static void top_handler(struct device *dev, void *user_data) void test_set_top_value_with_alarm_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t cnt; uint32_t counter_period_us; @@ -224,7 +224,7 @@ void test_set_top_value_with_alarm(void) void test_set_top_value_without_alarm_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t cnt; uint32_t top_cnt; @@ -275,7 +275,8 @@ void test_set_top_value_without_alarm(void) set_top_value_capable); } -static void alarm_handler(struct device *dev, uint8_t chan_id, uint32_t counter, +static void alarm_handler(const struct device *dev, uint8_t chan_id, + uint32_t counter, void *user_data) { /* Arbitrary limit for alarm processing - time between hw expiration @@ -318,7 +319,7 @@ static void alarm_handler(struct device *dev, uint8_t chan_id, uint32_t counter, void test_single_shot_alarm_instance(const char *dev_name, bool set_top) { - struct device *dev; + const struct device *dev; int err; uint32_t ticks; uint32_t alarm_cnt; @@ -416,7 +417,7 @@ void test_single_shot_alarm_top_instance(const char *dev_name) static bool single_channel_alarm_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); return (counter_get_num_of_channels(dev) > 0); } @@ -441,7 +442,8 @@ void test_single_shot_alarm_top(void) static void *clbk_data[10]; -static void alarm_handler2(struct device *dev, uint8_t chan_id, uint32_t counter, +static void alarm_handler2(const struct device *dev, uint8_t chan_id, + uint32_t counter, void *user_data) { clbk_data[k_sem_count_get(&alarm_cnt_sem)] = user_data; @@ -456,7 +458,7 @@ static void alarm_handler2(struct device *dev, uint8_t chan_id, uint32_t counter */ void test_multiple_alarms_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t ticks; uint32_t alarm_cnt; @@ -533,7 +535,7 @@ void test_multiple_alarms_instance(const char *dev_name) static bool multiple_channel_alarm_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); return (counter_get_num_of_channels(dev) > 1); } @@ -546,7 +548,7 @@ void test_multiple_alarms(void) void test_all_channels_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; const int n = 10; int nchan = 0; @@ -616,7 +618,7 @@ void test_late_alarm_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); uint32_t guard = counter_us_to_ticks(dev, 200); struct counter_alarm_cfg alarm_cfg = { @@ -667,7 +669,7 @@ void test_late_alarm_instance(const char *dev_name) void test_late_alarm_error_instance(const char *dev_name) { int err; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); uint32_t guard = counter_us_to_ticks(dev, 200); struct counter_alarm_cfg alarm_cfg = { @@ -703,7 +705,7 @@ void test_late_alarm_error_instance(const char *dev_name) static bool late_detection_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t guard = counter_get_guard_period(dev, COUNTER_GUARD_PERIOD_LATE_TO_SET); int err = counter_set_guard_period(dev, guard, @@ -731,7 +733,7 @@ static void test_short_relative_alarm_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); struct counter_alarm_cfg alarm_cfg = { .callback = alarm_handler, @@ -766,7 +768,7 @@ static void test_short_relative_alarm_instance(const char *dev_name) */ static bool short_relative_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct counter_alarm_cfg alarm_cfg = { .callback = alarm_handler, .flags = 0, @@ -822,7 +824,7 @@ static void test_cancelled_alarm_does_not_expire_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t us = 1000; uint32_t ticks = counter_us_to_ticks(dev, us); uint32_t top = counter_get_top_value(dev); @@ -938,7 +940,7 @@ void test_cancelled_alarm_does_not_expire(void) void test_main(void) { - struct device *dev; + const struct device *dev; int i; /* Give required clocks some time to stabilize. In particular, nRF SoCs diff --git a/tests/drivers/counter/counter_cmos/src/main.c b/tests/drivers/counter/counter_cmos/src/main.c index 1c5b00961a8a18..c5374c125426b2 100644 --- a/tests/drivers/counter/counter_cmos/src/main.c +++ b/tests/drivers/counter/counter_cmos/src/main.c @@ -17,7 +17,7 @@ void test_cmos_rate(void) { - struct device *cmos; + const struct device *cmos; uint32_t start, elapsed; int err; diff --git a/tests/drivers/counter/counter_nrf_rtc/fixed_top/src/test_counter_fixed_top.c b/tests/drivers/counter/counter_nrf_rtc/fixed_top/src/test_counter_fixed_top.c index 8d92e27ce6437e..e0775a29573ce8 100644 --- a/tests/drivers/counter/counter_nrf_rtc/fixed_top/src/test_counter_fixed_top.c +++ b/tests/drivers/counter/counter_nrf_rtc/fixed_top/src/test_counter_fixed_top.c @@ -35,7 +35,7 @@ static void counter_setup_instance(const char *dev_name) static void counter_tear_down_instance(const char *dev_name) { int err; - struct device *dev; + const struct device *dev; dev = device_get_binding(dev_name); @@ -57,7 +57,7 @@ static void test_all_instances(counter_test_func_t func) void test_set_custom_top_value_fails_on_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; struct counter_top_cfg top_cfg = { .callback = NULL, @@ -76,14 +76,14 @@ void test_set_custom_top_value_fails(void) test_all_instances(test_set_custom_top_value_fails_on_instance); } -static void top_handler(struct device *dev, void *user_data) +static void top_handler(const struct device *dev, void *user_data) { top_cnt++; } void test_top_handler_on_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; uint32_t tmp_top_cnt; int err; struct counter_top_cfg top_cfg = { diff --git a/tests/drivers/counter/maxim_ds3231_api/src/test_counter.c b/tests/drivers/counter/maxim_ds3231_api/src/test_counter.c index c3c28d543040f8..053234235ed54b 100644 --- a/tests/drivers/counter/maxim_ds3231_api/src/test_counter.c +++ b/tests/drivers/counter/maxim_ds3231_api/src/test_counter.c @@ -15,7 +15,7 @@ static struct k_sem top_cnt_sem; static struct k_sem alarm_cnt_sem; static struct k_poll_signal sync_sig; -static void top_handler(struct device *dev, void *user_data); +static void top_handler(const struct device *dev, void *user_data); void *exp_user_data = (void *)199; @@ -40,7 +40,7 @@ static void counter_setup_instance(const char *dev_name) static void counter_tear_down_instance(const char *dev_name) { int err; - struct device *dev; + const struct device *dev; struct counter_top_cfg top_cfg = { .callback = NULL, .user_data = NULL, @@ -86,7 +86,7 @@ static void test_all_instances(counter_test_func_t func, static bool set_top_value_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct counter_top_cfg cfg = { .ticks = counter_get_top_value(dev) - 1 }; @@ -106,7 +106,7 @@ static bool set_top_value_capable(const char *dev_name) return true; } -static void top_handler(struct device *dev, void *user_data) +static void top_handler(const struct device *dev, void *user_data) { zassert_true(user_data == exp_user_data, "%s: Unexpected callback", dev->name); @@ -115,7 +115,7 @@ static void top_handler(struct device *dev, void *user_data) void test_set_top_value_with_alarm_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t cnt; uint32_t top_cnt; @@ -165,7 +165,7 @@ void test_set_top_value_with_alarm(void) void test_set_top_value_without_alarm_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t cnt; uint32_t top_cnt; @@ -208,7 +208,8 @@ void test_set_top_value_without_alarm(void) set_top_value_capable); } -static void alarm_handler(struct device *dev, uint8_t chan_id, uint32_t counter, +static void alarm_handler(const struct device *dev, uint8_t chan_id, + uint32_t counter, void *user_data) { uint32_t now; @@ -241,7 +242,7 @@ static void alarm_handler(struct device *dev, uint8_t chan_id, uint32_t counter, void test_single_shot_alarm_instance(const char *dev_name, bool set_top) { - struct device *dev; + const struct device *dev; int err; uint32_t ticks; uint32_t alarm_cnt; @@ -333,7 +334,7 @@ void test_single_shot_alarm_top_instance(const char *dev_name) static bool single_channel_alarm_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); return (counter_get_num_of_channels(dev) > 0); } @@ -358,7 +359,8 @@ void test_single_shot_alarm_top(void) static void *clbk_data[10]; -static void alarm_handler2(struct device *dev, uint8_t chan_id, uint32_t counter, +static void alarm_handler2(const struct device *dev, uint8_t chan_id, + uint32_t counter, void *user_data) { clbk_data[k_sem_count_get(&alarm_cnt_sem)] = user_data; @@ -373,7 +375,7 @@ static void alarm_handler2(struct device *dev, uint8_t chan_id, uint32_t counter */ void test_multiple_alarms_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; uint32_t ticks; uint32_t alarm_cnt; @@ -443,7 +445,7 @@ void test_multiple_alarms_instance(const char *dev_name) static bool multiple_channel_alarm_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); return (counter_get_num_of_channels(dev) > 1); } @@ -469,7 +471,7 @@ void test_multiple_alarms(void) void test_all_channels_instance(const char *dev_name) { - struct device *dev; + const struct device *dev; int err; const int n = 10; int nchan = 0; @@ -540,7 +542,7 @@ void test_late_alarm_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); uint32_t guard = counter_us_to_ticks(dev, 200); struct counter_alarm_cfg alarm_cfg = { @@ -591,7 +593,7 @@ void test_late_alarm_instance(const char *dev_name) void test_late_alarm_error_instance(const char *dev_name) { int err; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); uint32_t guard = counter_us_to_ticks(dev, 200); struct counter_alarm_cfg alarm_cfg = { @@ -627,7 +629,7 @@ void test_late_alarm_error_instance(const char *dev_name) static bool late_detection_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t guard = counter_get_guard_period(dev, COUNTER_GUARD_PERIOD_LATE_TO_SET); int err = counter_set_guard_period(dev, guard, @@ -655,7 +657,7 @@ static void test_short_relative_alarm_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t tick_us = (uint32_t)counter_ticks_to_us(dev, 1); struct counter_alarm_cfg alarm_cfg = { .callback = alarm_handler, @@ -690,7 +692,7 @@ static void test_short_relative_alarm_instance(const char *dev_name) */ static bool short_relative_capable(const char *dev_name) { - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct counter_alarm_cfg alarm_cfg = { .callback = alarm_handler, .flags = 0, @@ -746,7 +748,7 @@ static void test_cancelled_alarm_does_not_expire_instance(const char *dev_name) { int err; uint32_t alarm_cnt; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); uint32_t us = 1000; uint32_t ticks = counter_us_to_ticks(dev, us); @@ -855,7 +857,7 @@ void test_cancelled_alarm_does_not_expire(void) static void test_ds3231_synchronize(void) { const char *dev_name = devices[0]; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct sys_notify notify; struct k_poll_event evt = K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, @@ -884,7 +886,7 @@ static void test_ds3231_synchronize(void) static void test_ds3231_get_syncpoint(void) { const char *dev_name = devices[0]; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct maxim_ds3231_syncpoint syncpoint; int rc; @@ -901,7 +903,7 @@ static void test_ds3231_get_syncpoint(void) static void test_ds3231_req_syncpoint(void) { const char *dev_name = devices[0]; - struct device *dev = device_get_binding(dev_name); + const struct device *dev = device_get_binding(dev_name); struct k_poll_event evt = K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY, &sync_sig); @@ -922,7 +924,7 @@ static void test_ds3231_req_syncpoint(void) void test_main(void) { - struct device *dev; + const struct device *dev; int i; /* Give required clocks some time to stabilize. In particular, nRF SoCs diff --git a/tests/drivers/dac/dac_api/src/main.c b/tests/drivers/dac/dac_api/src/main.c index 42b8b4f6d535b1..1967cdf143fb51 100644 --- a/tests/drivers/dac/dac_api/src/main.c +++ b/tests/drivers/dac/dac_api/src/main.c @@ -8,7 +8,7 @@ #include extern void test_dac_write_value(void); -extern struct device *get_dac_device(void); +extern const struct device *get_dac_device(void); void test_main(void) { diff --git a/tests/drivers/dac/dac_api/src/test_dac.c b/tests/drivers/dac/dac_api/src/test_dac.c index dd48f6d225cf19..61068bed6e29c3 100644 --- a/tests/drivers/dac/dac_api/src/test_dac.c +++ b/tests/drivers/dac/dac_api/src/test_dac.c @@ -37,15 +37,15 @@ static const struct dac_channel_cfg dac_ch_cfg = { .resolution = DAC_RESOLUTION }; -struct device *get_dac_device(void) +const struct device *get_dac_device(void) { return device_get_binding(DAC_DEVICE_NAME); } -static struct device *init_dac(void) +static const struct device *init_dac(void) { int ret; - struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); + const struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); zassert_not_null(dac_dev, "Cannot get DAC device"); @@ -63,7 +63,7 @@ static int test_task_write_value(void) { int ret; - struct device *dac_dev = init_dac(); + const struct device *dac_dev = init_dac(); if (!dac_dev) { return TC_FAIL; diff --git a/tests/drivers/dac/dac_loopback/src/test_dac.c b/tests/drivers/dac/dac_loopback/src/test_dac.c index bd6679396b4e39..44aaf89591240a 100644 --- a/tests/drivers/dac/dac_loopback/src/test_dac.c +++ b/tests/drivers/dac/dac_loopback/src/test_dac.c @@ -111,10 +111,10 @@ static const struct adc_channel_cfg adc_ch_cfg = { .channel_id = ADC_CHANNEL_ID, }; -static struct device *init_dac(void) +static const struct device *init_dac(void) { int ret; - struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); + const struct device *dac_dev = device_get_binding(DAC_DEVICE_NAME); zassert_not_null(dac_dev, "Cannot get DAC device"); @@ -126,10 +126,10 @@ static struct device *init_dac(void) } /* ADC necessary to read back the value from DAC */ -static struct device *init_adc(void) +static const struct device *init_adc(void) { int ret; - struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME); + const struct device *adc_dev = device_get_binding(ADC_DEVICE_NAME); zassert_not_null(adc_dev, "Cannot get ADC device"); @@ -147,8 +147,8 @@ static int test_task_loopback(void) { int ret; - struct device *dac_dev = init_dac(); - struct device *adc_dev = init_adc(); + const struct device *dac_dev = init_dac(); + const struct device *adc_dev = init_adc(); if (!dac_dev || !adc_dev) { return TC_FAIL; diff --git a/tests/drivers/dma/chan_blen_transfer/src/test_dma.c b/tests/drivers/dma/chan_blen_transfer/src/test_dma.c index c9bd127ea6c302..65e46b5b583855 100644 --- a/tests/drivers/dma/chan_blen_transfer/src/test_dma.c +++ b/tests/drivers/dma/chan_blen_transfer/src/test_dma.c @@ -34,7 +34,7 @@ static const char tx_data[] = "It is harder to be kind than to be wise........"; static char rx_data[RX_BUFF_SIZE] = { 0 }; #endif -static void test_done(struct device *dma_dev, void *arg, +static void test_done(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { if (error_code == 0) { @@ -48,7 +48,7 @@ static int test_task(uint32_t chan_id, uint32_t blen) { struct dma_config dma_cfg = { 0 }; struct dma_block_config dma_block_cfg = { 0 }; - struct device *dma = device_get_binding(DMA_DEVICE_NAME); + const struct device *dma = device_get_binding(DMA_DEVICE_NAME); if (!dma) { TC_PRINT("Cannot get dma controller\n"); diff --git a/tests/drivers/dma/loop_transfer/src/dma.c b/tests/drivers/dma/loop_transfer/src/dma.c index 734db1d5510f29..316ac0a0e8f225 100644 --- a/tests/drivers/dma/loop_transfer/src/dma.c +++ b/tests/drivers/dma/loop_transfer/src/dma.c @@ -38,7 +38,7 @@ volatile uint8_t transfer_count; static struct dma_config dma_cfg = {0}; static struct dma_block_config dma_block_cfg = {0}; -static void test_transfer(struct device *dev, uint32_t id) +static void test_transfer(const struct device *dev, uint32_t id) { int ret; transfer_count++; @@ -59,7 +59,7 @@ static void test_error(void) printk("DMA could not proceed, an error occurred\n"); } -static void dma_user_callback(struct device *dma_dev, void *arg, +static void dma_user_callback(const struct device *dma_dev, void *arg, uint32_t id, int error_code) { if (error_code == 0) { @@ -71,7 +71,7 @@ static void dma_user_callback(struct device *dma_dev, void *arg, void main(void) { - struct device *dma; + const struct device *dma; static uint32_t chan_id; printk("DMA memory to memory transfer started on %s\n", diff --git a/tests/drivers/eeprom/src/main.c b/tests/drivers/eeprom/src/main.c index 1b79034e48dbb3..8ac3533e4ab13e 100644 --- a/tests/drivers/eeprom/src/main.c +++ b/tests/drivers/eeprom/src/main.c @@ -14,7 +14,7 @@ ZTEST_BMEM static const char *eeprom_label; static void test_size(void) { - struct device *eeprom; + const struct device *eeprom; size_t size; eeprom = device_get_binding(eeprom_label); @@ -26,7 +26,7 @@ static void test_size(void) static void test_out_of_bounds(void) { const uint8_t data[4] = { 0x01, 0x02, 0x03, 0x03 }; - struct device *eeprom; + const struct device *eeprom; size_t size; int rc; @@ -42,7 +42,7 @@ static void test_write_and_verify(void) const uint8_t wr_buf1[4] = { 0xFF, 0xEE, 0xDD, 0xCC }; const uint8_t wr_buf2[sizeof(wr_buf1)] = { 0xAA, 0xBB, 0xCC, 0xDD }; uint8_t rd_buf[sizeof(wr_buf1)]; - struct device *eeprom; + const struct device *eeprom; int rc; eeprom = device_get_binding(eeprom_label); @@ -71,7 +71,7 @@ static void test_zero_length_write(void) const uint8_t wr_buf1[4] = { 0x10, 0x20, 0x30, 0x40 }; const uint8_t wr_buf2[sizeof(wr_buf1)] = { 0xAA, 0xBB, 0xCC, 0xDD }; uint8_t rd_buf[sizeof(wr_buf1)]; - struct device *eeprom; + const struct device *eeprom; int rc; eeprom = device_get_binding(eeprom_label); @@ -98,7 +98,7 @@ static void test_zero_length_write(void) /* Run all of our tests on EEPROM device with the given label */ static void run_tests_on_eeprom(const char *label) { - struct device *eeprom = device_get_binding(label); + const struct device *eeprom = device_get_binding(label); zassert_not_null(eeprom, "Unable to get EEPROM device"); k_object_access_grant(eeprom, k_current_get()); diff --git a/tests/drivers/entropy/api/src/main.c b/tests/drivers/entropy/api/src/main.c index fb90f1a8b46061..3c7d8ba412ec07 100644 --- a/tests/drivers/entropy/api/src/main.c +++ b/tests/drivers/entropy/api/src/main.c @@ -24,7 +24,7 @@ #define BUFFER_LENGTH 10 #define RECHECK_RANDOM_ENTROPY 0x10 -static int random_entropy(struct device *dev, char *buffer, char num) +static int random_entropy(const struct device *dev, char *buffer, char num) { int ret, i; int count = 0; @@ -67,7 +67,7 @@ static int random_entropy(struct device *dev, char *buffer, char num) */ static int get_entropy(void) { - struct device *dev; + const struct device *dev; uint8_t buffer[BUFFER_LENGTH] = { 0 }; int ret; diff --git a/tests/drivers/flash/src/main.c b/tests/drivers/flash/src/main.c index 53316fec285e99..ab84dd82d687c8 100644 --- a/tests/drivers/flash/src/main.c +++ b/tests/drivers/flash/src/main.c @@ -33,7 +33,7 @@ #define EXPECTED_SIZE 256 #define CANARY 0xff -static struct device *flash_dev; +static const struct device *flash_dev; static struct flash_pages_info page_info; static uint8_t __aligned(4) expected[EXPECTED_SIZE]; diff --git a/tests/drivers/flash_simulator/src/main.c b/tests/drivers/flash_simulator/src/main.c index d7073a65746737..87ebab5892ab8e 100644 --- a/tests/drivers/flash_simulator/src/main.c +++ b/tests/drivers/flash_simulator/src/main.c @@ -32,7 +32,7 @@ (((((((0xff & pat) << 8) | (0xff & pat)) << 8) | \ (0xff & pat)) << 8) | (0xff & pat)) -static struct device *flash_dev; +static const struct device *flash_dev; static uint8_t test_read_buf[TEST_SIM_FLASH_SIZE]; static uint32_t p32_inc; diff --git a/tests/drivers/gpio/gpio_api_1pin/src/test_config.c b/tests/drivers/gpio/gpio_api_1pin/src/test_config.c index e9003feb190d47..fa69e29a7eeff2 100644 --- a/tests/drivers/gpio/gpio_api_1pin/src/test_config.c +++ b/tests/drivers/gpio/gpio_api_1pin/src/test_config.c @@ -12,7 +12,8 @@ #define TEST_GPIO_MAX_SINGLE_ENDED_RISE_FALL_TIME_MS 100 #define TEST_POINT(n) (n) -static void pin_get_raw_and_verify(struct device *port, unsigned int pin, +static void pin_get_raw_and_verify(const struct device *port, + unsigned int pin, int val_expected, int idx) { int val_actual; @@ -24,7 +25,8 @@ static void pin_get_raw_and_verify(struct device *port, unsigned int pin, "Test point %d: invalid pin get value", idx); } -static void pin_set_raw_and_verify(struct device *port, unsigned int pin, +static void pin_set_raw_and_verify(const struct device *port, + unsigned int pin, int val, int idx) { zassert_equal(gpio_pin_set_raw(port, pin, val), 0, @@ -45,7 +47,7 @@ static void pin_set_raw_and_verify(struct device *port, unsigned int pin, */ void test_gpio_pin_configure_push_pull(void) { - struct device *port; + const struct device *port; int ret; port = device_get_binding(TEST_DEV); @@ -158,7 +160,7 @@ void test_gpio_pin_configure_push_pull(void) */ void test_gpio_pin_configure_single_ended(void) { - struct device *port; + const struct device *port; int pin_in_val; int pin_val; unsigned int cfg_flag; diff --git a/tests/drivers/gpio/gpio_api_1pin/src/test_pin.c b/tests/drivers/gpio/gpio_api_1pin/src/test_pin.c index 89cfe3fe6a8bfd..f11f6480ca85b1 100644 --- a/tests/drivers/gpio/gpio_api_1pin/src/test_pin.c +++ b/tests/drivers/gpio/gpio_api_1pin/src/test_pin.c @@ -9,7 +9,8 @@ #include #include "test_gpio_api.h" -static void pin_get_raw_and_verify(struct device *port, unsigned int pin, +static void pin_get_raw_and_verify(const struct device *port, + unsigned int pin, int val_expected, int idx) { int val_actual; @@ -21,7 +22,7 @@ static void pin_get_raw_and_verify(struct device *port, unsigned int pin, "Test point %d: invalid physical pin get value", idx); } -static void pin_get_and_verify(struct device *port, unsigned int pin, +static void pin_get_and_verify(const struct device *port, unsigned int pin, int val_expected, int idx) { int val_actual; @@ -33,7 +34,8 @@ static void pin_get_and_verify(struct device *port, unsigned int pin, "Test point %d: invalid logical pin get value", idx); } -static void pin_set_raw_and_verify(struct device *port, unsigned int pin, +static void pin_set_raw_and_verify(const struct device *port, + unsigned int pin, int val, int idx) { zassert_equal(gpio_pin_set_raw(port, pin, val), 0, @@ -41,7 +43,8 @@ static void pin_set_raw_and_verify(struct device *port, unsigned int pin, k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void pin_set_and_verify(struct device *port, unsigned int pin, int val, +static void pin_set_and_verify(const struct device *port, unsigned int pin, + int val, int idx) { zassert_equal(gpio_pin_set(port, pin, val), 0, @@ -56,7 +59,7 @@ static void pin_set_and_verify(struct device *port, unsigned int pin, int val, */ void test_gpio_pin_toggle(void) { - struct device *port; + const struct device *port; int val_expected; int ret; @@ -98,7 +101,7 @@ void test_gpio_pin_toggle(void) */ void test_gpio_pin_toggle_visual(void) { - struct device *port; + const struct device *port; int val_expected; int ret; @@ -133,7 +136,7 @@ void test_gpio_pin_toggle_visual(void) */ void test_gpio_pin_set_get_raw(void) { - struct device *port; + const struct device *port; int val_expected; int ret; @@ -170,7 +173,7 @@ void test_gpio_pin_set_get_raw(void) */ void test_gpio_pin_set_get(void) { - struct device *port; + const struct device *port; int val_expected; int ret; @@ -209,7 +212,7 @@ void test_gpio_pin_set_get(void) */ void test_gpio_pin_set_get_active_high(void) { - struct device *port; + const struct device *port; int val_expected; int ret; @@ -259,7 +262,7 @@ void test_gpio_pin_set_get_active_high(void) */ void test_gpio_pin_set_get_active_low(void) { - struct device *port; + const struct device *port; int val_expected, val_raw_expected; int ret; diff --git a/tests/drivers/gpio/gpio_api_1pin/src/test_pin_interrupt.c b/tests/drivers/gpio/gpio_api_1pin/src/test_pin_interrupt.c index aa17f47b910076..3921105469480e 100644 --- a/tests/drivers/gpio/gpio_api_1pin/src/test_pin_interrupt.c +++ b/tests/drivers/gpio/gpio_api_1pin/src/test_pin_interrupt.c @@ -12,7 +12,7 @@ struct gpio_callback gpio_cb; static int cb_count; -static void callback_edge(struct device *port, struct gpio_callback *cb, +static void callback_edge(const struct device *port, struct gpio_callback *cb, gpio_port_pins_t pins) { zassert_equal(pins, BIT(TEST_PIN), @@ -20,7 +20,8 @@ static void callback_edge(struct device *port, struct gpio_callback *cb, cb_count++; } -static void callback_level(struct device *port, struct gpio_callback *cb, +static void callback_level(const struct device *port, + struct gpio_callback *cb, gpio_port_pins_t pins) { int ret; @@ -35,7 +36,8 @@ static void callback_level(struct device *port, struct gpio_callback *cb, cb_count++; } -static void pin_set_and_verify(struct device *port, unsigned int pin, int val, +static void pin_set_and_verify(const struct device *port, unsigned int pin, + int val, int idx) { zassert_equal(gpio_pin_set(port, pin, val), 0, @@ -46,7 +48,7 @@ static void pin_set_and_verify(struct device *port, unsigned int pin, int val, void test_gpio_pin_interrupt_edge(unsigned int cfg_flags, unsigned int int_flags) { - struct device *port; + const struct device *port; int cb_count_expected; unsigned int cfg_out_flag; int ret; @@ -119,7 +121,7 @@ void test_gpio_pin_interrupt_edge(unsigned int cfg_flags, void test_gpio_pin_interrupt_level(unsigned int cfg_flags, unsigned int int_flags) { - struct device *port; + const struct device *port; int cb_count_expected; unsigned int cfg_out_flag; int pin_out_val; diff --git a/tests/drivers/gpio/gpio_api_1pin/src/test_port.c b/tests/drivers/gpio/gpio_api_1pin/src/test_port.c index c09b52f747e9df..04b505637c5c89 100644 --- a/tests/drivers/gpio/gpio_api_1pin/src/test_port.c +++ b/tests/drivers/gpio/gpio_api_1pin/src/test_port.c @@ -11,7 +11,8 @@ #define TEST_GPIO_PORT_VALUE_MAX ((1LLU << GPIO_MAX_PINS_PER_PORT) - 1) -static void port_get_raw_and_verify(struct device *port, gpio_port_pins_t mask, +static void port_get_raw_and_verify(const struct device *port, + gpio_port_pins_t mask, gpio_port_value_t val_expected, int idx) { gpio_port_value_t val_actual; @@ -22,7 +23,8 @@ static void port_get_raw_and_verify(struct device *port, gpio_port_pins_t mask, "Test point %d: invalid physical port get value", idx); } -static void port_get_and_verify(struct device *port, gpio_port_pins_t mask, +static void port_get_and_verify(const struct device *port, + gpio_port_pins_t mask, gpio_port_value_t val_expected, int idx) { gpio_port_value_t val_actual; @@ -33,64 +35,68 @@ static void port_get_and_verify(struct device *port, gpio_port_pins_t mask, "Test point %d: invalid logical port get value", idx); } -static void port_set_masked_raw_and_verify(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value, int idx) +static void port_set_masked_raw_and_verify(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value, int idx) { zassert_equal(gpio_port_set_masked_raw(port, mask, value), 0, "Test point %d: failed to set physical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_set_masked_and_verify(struct device *port, - gpio_port_pins_t mask, gpio_port_value_t value, int idx) +static void port_set_masked_and_verify(const struct device *port, + gpio_port_pins_t mask, + gpio_port_value_t value, int idx) { zassert_equal(gpio_port_set_masked(port, mask, value), 0, "Test point %d: failed to set logical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_set_bits_raw_and_verify(struct device *port, - gpio_port_pins_t pins, int idx) +static void port_set_bits_raw_and_verify(const struct device *port, + gpio_port_pins_t pins, int idx) { zassert_equal(gpio_port_set_bits_raw(port, pins), 0, "Test point %d: failed to set physical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_set_bits_and_verify(struct device *port, - gpio_port_pins_t pins, int idx) +static void port_set_bits_and_verify(const struct device *port, + gpio_port_pins_t pins, int idx) { zassert_equal(gpio_port_set_bits(port, pins), 0, "Test point %d: failed to set logical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_clear_bits_raw_and_verify(struct device *port, - gpio_port_pins_t pins, int idx) +static void port_clear_bits_raw_and_verify(const struct device *port, + gpio_port_pins_t pins, int idx) { zassert_equal(gpio_port_clear_bits_raw(port, pins), 0, "Test point %d: failed to set physical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_clear_bits_and_verify(struct device *port, - gpio_port_pins_t pins, int idx) +static void port_clear_bits_and_verify(const struct device *port, + gpio_port_pins_t pins, int idx) { zassert_equal(gpio_port_clear_bits(port, pins), 0, "Test point %d: failed to set logical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_set_clr_bits_raw(struct device *port, - gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins, int idx) +static void port_set_clr_bits_raw(const struct device *port, + gpio_port_pins_t set_pins, + gpio_port_pins_t clear_pins, int idx) { zassert_equal(gpio_port_set_clr_bits_raw(port, set_pins, clear_pins), 0, "Test point %d: failed to set physical port value", idx); k_busy_wait(TEST_GPIO_MAX_RISE_FALL_TIME_US); } -static void port_set_clr_bits(struct device *port, - gpio_port_pins_t set_pins, gpio_port_pins_t clear_pins, int idx) +static void port_set_clr_bits(const struct device *port, + gpio_port_pins_t set_pins, + gpio_port_pins_t clear_pins, int idx) { zassert_equal(gpio_port_set_clr_bits(port, set_pins, clear_pins), 0, "Test point %d: failed to set logical port value", idx); @@ -104,7 +110,7 @@ static void port_set_clr_bits(struct device *port, */ void test_gpio_port_toggle(void) { - struct device *port; + const struct device *port; gpio_port_value_t val_expected; int ret; @@ -138,7 +144,7 @@ void test_gpio_port_toggle(void) void test_gpio_port_set_masked_get_raw(void) { - struct device *port; + const struct device *port; int ret; const gpio_port_value_t test_vector[] = { @@ -178,7 +184,7 @@ void test_gpio_port_set_masked_get_raw(void) void test_gpio_port_set_masked_get(void) { - struct device *port; + const struct device *port; int ret; const gpio_port_value_t test_vector[] = { @@ -218,7 +224,7 @@ void test_gpio_port_set_masked_get(void) void test_gpio_port_set_masked_get_active_high(void) { - struct device *port; + const struct device *port; int ret; const gpio_port_value_t test_vector[] = { @@ -269,7 +275,7 @@ void test_gpio_port_set_masked_get_active_high(void) void test_gpio_port_set_masked_get_active_low(void) { - struct device *port; + const struct device *port; int ret; const gpio_port_value_t test_vector[] = { @@ -320,7 +326,7 @@ void test_gpio_port_set_masked_get_active_low(void) void test_gpio_port_set_bits_clear_bits_raw(void) { - struct device *port; + const struct device *port; gpio_port_value_t val_expected = 0; int ret; @@ -359,7 +365,7 @@ void test_gpio_port_set_bits_clear_bits_raw(void) void test_gpio_port_set_bits_clear_bits(void) { - struct device *port; + const struct device *port; gpio_port_value_t val_expected = 0; int ret; @@ -398,7 +404,7 @@ void test_gpio_port_set_bits_clear_bits(void) void test_gpio_port_set_clr_bits_raw(void) { - struct device *port; + const struct device *port; gpio_port_value_t val_expected = 0; int ret; @@ -436,7 +442,7 @@ void test_gpio_port_set_clr_bits_raw(void) void test_gpio_port_set_clr_bits(void) { - struct device *port; + const struct device *port; gpio_port_value_t val_expected = 0; int ret; diff --git a/tests/drivers/gpio/gpio_basic_api/src/main.c b/tests/drivers/gpio/gpio_basic_api/src/main.c index 4b41e7bef90300..bedf96f2f7a365 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/main.c +++ b/tests/drivers/gpio/gpio_basic_api/src/main.c @@ -36,7 +36,7 @@ static void board_setup(void) #if defined(CONFIG_BOARD_FRDM_K64F) /* TODO figure out how to get this from "GPIO_2" */ const char *pmx_name = "portc"; - struct device *pmx = device_get_binding(pmx_name); + const struct device *pmx = device_get_binding(pmx_name); pinmux_pin_set(pmx, PIN_OUT, PORT_PCR_MUX(kPORT_MuxAsGpio)); pinmux_pin_set(pmx, PIN_IN, PORT_PCR_MUX(kPORT_MuxAsGpio)); @@ -98,7 +98,7 @@ static void board_setup(void) IOMUXC_SW_PAD_CTL_PAD_DSE(6)); #elif defined(CONFIG_SOC_FAMILY_LPC) /* Assumes ARDUINO pins are mapped on PORT0 on all boards*/ - struct device *port0 = + const struct device *port0 = device_get_binding(CONFIG_PINMUX_MCUX_LPC_PORT0_NAME); const uint32_t pin_config = ( IOCON_PIO_FUNC0 | @@ -111,7 +111,7 @@ static void board_setup(void) pinmux_pin_set(port0, PIN_OUT, pin_config); #elif defined(CONFIG_BOARD_RV32M1_VEGA) const char *pmx_name = DT_LABEL(DT_NODELABEL(porta)); - struct device *pmx = device_get_binding(pmx_name); + const struct device *pmx = device_get_binding(pmx_name); pinmux_pin_set(pmx, PIN_OUT, PORT_PCR_MUX(kPORT_MuxAsGpio)); pinmux_pin_set(pmx, PIN_IN, PORT_PCR_MUX(kPORT_MuxAsGpio)); diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c b/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c index ebb5482cdb0454..500fccb16434b3 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c @@ -10,21 +10,21 @@ static struct drv_data cb_data[2]; static int cb_cnt[2]; -static void callback_1(struct device *dev, +static void callback_1(const struct device *dev, struct gpio_callback *gpio_cb, uint32_t pins) { TC_PRINT("%s triggered: %d\n", __func__, ++cb_cnt[0]); } -static void callback_2(struct device *dev, +static void callback_2(const struct device *dev, struct gpio_callback *gpio_cb, uint32_t pins) { TC_PRINT("%s triggered: %d\n", __func__, ++cb_cnt[1]); } -static void callback_remove_self(struct device *dev, - struct gpio_callback *gpio_cb, uint32_t pins) +static void callback_remove_self(const struct device *dev, + struct gpio_callback *gpio_cb, uint32_t pins) { struct drv_data *dd = CONTAINER_OF(gpio_cb, struct drv_data, gpio_cb); @@ -32,7 +32,7 @@ static void callback_remove_self(struct device *dev, dd->aux = gpio_remove_callback(dev, gpio_cb); } -static int init_callback(struct device *dev, +static int init_callback(const struct device *dev, gpio_callback_handler_t handler_1, gpio_callback_handler_t handler_2) { @@ -65,7 +65,7 @@ static int init_callback(struct device *dev, return rc; } -static void trigger_callback(struct device *dev, int enable_cb) +static void trigger_callback(const struct device *dev, int enable_cb) { gpio_pin_set(dev, PIN_OUT, 0); k_sleep(K_MSEC(100)); @@ -84,7 +84,7 @@ static void trigger_callback(struct device *dev, int enable_cb) static int test_callback_add_remove(void) { - struct device *dev = device_get_binding(DEV_NAME); + const struct device *dev = device_get_binding(DEV_NAME); /* SetUp: initialize environment */ int rc = init_callback(dev, callback_1, callback_2); @@ -133,7 +133,7 @@ static int test_callback_add_remove(void) static int test_callback_self_remove(void) { int res = TC_FAIL; - struct device *dev = device_get_binding(DEV_NAME); + const struct device *dev = device_get_binding(DEV_NAME); /* SetUp: initialize environment */ int rc = init_callback(dev, callback_1, callback_remove_self); @@ -185,7 +185,7 @@ static int test_callback_self_remove(void) static int test_callback_enable_disable(void) { - struct device *dev = device_get_binding(DEV_NAME); + const struct device *dev = device_get_binding(DEV_NAME); /* SetUp: initialize environment */ int rc = init_callback(dev, callback_1, callback_2); diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c b/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c index 7470867b7c2547..57f6deddfbb98b 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c @@ -10,7 +10,7 @@ static struct drv_data data; static int cb_cnt; -static void callback(struct device *dev, +static void callback(const struct device *dev, struct gpio_callback *gpio_cb, uint32_t pins) { const struct drv_data *dd = CONTAINER_OF(gpio_cb, @@ -33,7 +33,7 @@ static void callback(struct device *dev, static int test_callback(int mode) { - struct device *dev = device_get_binding(DEV_NAME); + const struct device *dev = device_get_binding(DEV_NAME); struct drv_data *drv_data = &data; gpio_pin_interrupt_configure(dev, PIN_IN, GPIO_INT_DISABLE); diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c b/tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c index 9176ea8fe49ec0..60c65f0303effd 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_gpio_port.c @@ -9,7 +9,7 @@ #define ALL_BITS ((gpio_port_value_t)-1) -static struct device *dev; +static const struct device *dev; /* Short-hand for a checked read of PIN_IN raw state */ static bool raw_in(void) diff --git a/tests/drivers/i2c/i2c_api/src/test_i2c.c b/tests/drivers/i2c/i2c_api/src/test_i2c.c index 57184952feae7e..5b52c8f484f183 100644 --- a/tests/drivers/i2c/i2c_api/src/test_i2c.c +++ b/tests/drivers/i2c/i2c_api/src/test_i2c.c @@ -31,7 +31,7 @@ uint32_t i2c_cfg = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER; static int test_gy271(void) { unsigned char datas[6]; - struct device *i2c_dev = device_get_binding(I2C_DEV_NAME); + const struct device *i2c_dev = device_get_binding(I2C_DEV_NAME); if (!i2c_dev) { TC_PRINT("Cannot get I2C device\n"); @@ -86,7 +86,7 @@ static int test_gy271(void) static int test_burst_gy271(void) { unsigned char datas[6]; - struct device *i2c_dev = device_get_binding(I2C_DEV_NAME); + const struct device *i2c_dev = device_get_binding(I2C_DEV_NAME); if (!i2c_dev) { TC_PRINT("Cannot get I2C device\n"); diff --git a/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c b/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c index 456b84f9425dde..facd87559a4bee 100644 --- a/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c +++ b/tests/drivers/i2c/i2c_slave_api/common/i2c_virtual.c @@ -21,7 +21,7 @@ struct i2c_virtual_data { sys_slist_t slaves; }; -int i2c_virtual_runtime_configure(struct device *dev, uint32_t config) +int i2c_virtual_runtime_configure(const struct device *dev, uint32_t config) { return 0; } @@ -47,7 +47,7 @@ static struct i2c_slave_config *find_address(struct i2c_virtual_data *data, } /* Attach I2C slaves */ -int i2c_virtual_slave_register(struct device *dev, +int i2c_virtual_slave_register(const struct device *dev, struct i2c_slave_config *config) { struct i2c_virtual_data *data = DEV_DATA(dev); @@ -68,7 +68,7 @@ int i2c_virtual_slave_register(struct device *dev, } -int i2c_virtual_slave_unregister(struct device *dev, +int i2c_virtual_slave_unregister(const struct device *dev, struct i2c_slave_config *config) { struct i2c_virtual_data *data = DEV_DATA(dev); @@ -84,7 +84,8 @@ int i2c_virtual_slave_unregister(struct device *dev, return 0; } -static int i2c_virtual_msg_write(struct device *dev, struct i2c_msg *msg, +static int i2c_virtual_msg_write(const struct device *dev, + struct i2c_msg *msg, struct i2c_slave_config *config, bool prev_write) { @@ -118,7 +119,7 @@ static int i2c_virtual_msg_write(struct device *dev, struct i2c_msg *msg, return -EIO; } -static int i2c_virtual_msg_read(struct device *dev, struct i2c_msg *msg, +static int i2c_virtual_msg_read(const struct device *dev, struct i2c_msg *msg, struct i2c_slave_config *config) { unsigned int len = msg->len; @@ -147,8 +148,8 @@ static int i2c_virtual_msg_read(struct device *dev, struct i2c_msg *msg, #define OPERATION(msg) (((struct i2c_msg *) msg)->flags & I2C_MSG_RW_MASK) -static int i2c_virtual_transfer(struct device *dev, struct i2c_msg *msg, - uint8_t num_msgs, uint16_t slave) +static int i2c_virtual_transfer(const struct device *dev, struct i2c_msg *msg, + uint8_t num_msgs, uint16_t slave) { struct i2c_virtual_data *data = DEV_DATA(dev); struct i2c_msg *current, *next; @@ -212,7 +213,7 @@ static const struct i2c_driver_api api_funcs = { .slave_unregister = i2c_virtual_slave_unregister, }; -static int i2c_virtual_init(struct device *dev) +static int i2c_virtual_init(const struct device *dev) { struct i2c_virtual_data *data = DEV_DATA(dev); diff --git a/tests/drivers/i2c/i2c_slave_api/src/eeprom.h b/tests/drivers/i2c/i2c_slave_api/src/eeprom.h index 3dfdff20e8b00f..02deaf71636bd4 100644 --- a/tests/drivers/i2c/i2c_slave_api/src/eeprom.h +++ b/tests/drivers/i2c/i2c_slave_api/src/eeprom.h @@ -29,7 +29,7 @@ * @retval 0 If successful. * @retval -EINVAL Invalid data size */ -int eeprom_slave_program(struct device *dev, const uint8_t *eeprom_data, +int eeprom_slave_program(const struct device *dev, const uint8_t *eeprom_data, unsigned int length); /** @@ -42,7 +42,7 @@ int eeprom_slave_program(struct device *dev, const uint8_t *eeprom_data, * @retval 0 If successful. * @retval -EINVAL Invalid data pointer or offset */ -int eeprom_slave_read(struct device *dev, uint8_t *eeprom_data, +int eeprom_slave_read(const struct device *dev, uint8_t *eeprom_data, unsigned int offset); /** diff --git a/tests/drivers/i2c/i2c_slave_api/src/eeprom_slave.c b/tests/drivers/i2c/i2c_slave_api/src/eeprom_slave.c index 26f90a0fe257c6..9de4fa7b1cd806 100644 --- a/tests/drivers/i2c/i2c_slave_api/src/eeprom_slave.c +++ b/tests/drivers/i2c/i2c_slave_api/src/eeprom_slave.c @@ -18,7 +18,7 @@ LOG_MODULE_REGISTER(eeprom_slave); struct i2c_eeprom_slave_data { - struct device *i2c_controller; + const struct device *i2c_controller; struct i2c_slave_config config; uint32_t buffer_size; uint8_t *buffer; @@ -40,7 +40,7 @@ struct i2c_eeprom_slave_config { #define DEV_DATA(dev) \ ((struct i2c_eeprom_slave_data * const)(dev)->data) -int eeprom_slave_program(struct device *dev, const uint8_t *eeprom_data, +int eeprom_slave_program(const struct device *dev, const uint8_t *eeprom_data, unsigned int length) { struct i2c_eeprom_slave_data *data = dev->data; @@ -54,7 +54,7 @@ int eeprom_slave_program(struct device *dev, const uint8_t *eeprom_data, return 0; } -int eeprom_slave_read(struct device *dev, uint8_t *eeprom_data, +int eeprom_slave_read(const struct device *dev, uint8_t *eeprom_data, unsigned int offset) { struct i2c_eeprom_slave_data *data = dev->data; @@ -157,14 +157,14 @@ static int eeprom_slave_stop(struct i2c_slave_config *config) return 0; } -static int eeprom_slave_register(struct device *dev) +static int eeprom_slave_register(const struct device *dev) { struct i2c_eeprom_slave_data *data = dev->data; return i2c_slave_register(data->i2c_controller, &data->config); } -static int eeprom_slave_unregister(struct device *dev) +static int eeprom_slave_unregister(const struct device *dev) { struct i2c_eeprom_slave_data *data = dev->data; @@ -184,7 +184,7 @@ static const struct i2c_slave_callbacks eeprom_callbacks = { .stop = eeprom_slave_stop, }; -static int i2c_eeprom_slave_init(struct device *dev) +static int i2c_eeprom_slave_init(const struct device *dev) { struct i2c_eeprom_slave_data *data = DEV_DATA(dev); const struct i2c_eeprom_slave_config *cfg = DEV_CFG(dev); diff --git a/tests/drivers/i2c/i2c_slave_api/src/main.c b/tests/drivers/i2c/i2c_slave_api/src/main.c index 85c40d1d9338f5..512566210856c1 100644 --- a/tests/drivers/i2c/i2c_slave_api/src/main.c +++ b/tests/drivers/i2c/i2c_slave_api/src/main.c @@ -46,7 +46,7 @@ static void to_display_format(const uint8_t *src, size_t size, char *dst) } } -static int run_full_read(struct device *i2c, uint8_t addr, +static int run_full_read(const struct device *i2c, uint8_t addr, const uint8_t *comp_buffer) { int ret; @@ -74,7 +74,7 @@ static int run_full_read(struct device *i2c, uint8_t addr, return 0; } -static int run_partial_read(struct device *i2c, uint8_t addr, +static int run_partial_read(const struct device *i2c, uint8_t addr, const uint8_t *comp_buffer, unsigned int offset) { int ret; @@ -101,7 +101,8 @@ static int run_partial_read(struct device *i2c, uint8_t addr, return 0; } -static int run_program_read(struct device *i2c, uint8_t addr, unsigned int offset) +static int run_program_read(const struct device *i2c, uint8_t addr, + unsigned int offset) { int ret, i; @@ -138,12 +139,12 @@ static int run_program_read(struct device *i2c, uint8_t addr, unsigned int offse void test_eeprom_slave(void) { const char *label_0 = DT_LABEL(NODE_EP0); - struct device *eeprom_0 = device_get_binding(label_0); - struct device *i2c_0 = device_get_binding(DT_BUS_LABEL(NODE_EP0)); + const struct device *eeprom_0 = device_get_binding(label_0); + const struct device *i2c_0 = device_get_binding(DT_BUS_LABEL(NODE_EP0)); int addr_0 = DT_REG_ADDR(NODE_EP0); const char *label_1 = DT_LABEL(NODE_EP1); - struct device *eeprom_1 = device_get_binding(label_1); - struct device *i2c_1 = device_get_binding(DT_BUS_LABEL(NODE_EP1)); + const struct device *eeprom_1 = device_get_binding(label_1); + const struct device *i2c_1 = device_get_binding(DT_BUS_LABEL(NODE_EP1)); int addr_1 = DT_REG_ADDR(NODE_EP1); int ret, offset; diff --git a/tests/drivers/i2s/i2s_api/src/common.c b/tests/drivers/i2s/i2s_api/src/common.c index d70c0e507a346f..923e94623457e4 100644 --- a/tests/drivers/i2s/i2s_api/src/common.c +++ b/tests/drivers/i2s/i2s_api/src/common.c @@ -81,7 +81,7 @@ int verify_buf_const(int16_t *rx_block, int16_t val_l, int16_t val_r) return TC_PASS; } -int tx_block_write_slab(struct device *dev_i2s, int att, int err, +int tx_block_write_slab(const struct device *dev_i2s, int att, int err, struct k_mem_slab *slab) { char tx_block[BLOCK_SIZE]; @@ -98,7 +98,7 @@ int tx_block_write_slab(struct device *dev_i2s, int att, int err, return TC_PASS; } -int rx_block_read_slab(struct device *dev_i2s, int att, +int rx_block_read_slab(const struct device *dev_i2s, int att, struct k_mem_slab *slab) { char rx_block[BLOCK_SIZE]; diff --git a/tests/drivers/i2s/i2s_api/src/i2s_api_test.h b/tests/drivers/i2s/i2s_api/src/i2s_api_test.h index 442f7a017d1b06..ee1245ece64576 100644 --- a/tests/drivers/i2s/i2s_api/src/i2s_api_test.h +++ b/tests/drivers/i2s/i2s_api/src/i2s_api_test.h @@ -43,9 +43,9 @@ extern int16_t data_r[SAMPLE_NO]; #define I2S_DEV_NAME "I2S_0" #define BLOCK_SIZE (2 * sizeof(data_l)) -int rx_block_read_slab(struct device *dev_i2s, int att, +int rx_block_read_slab(const struct device *dev_i2s, int att, struct k_mem_slab *slab); -int tx_block_write_slab(struct device *dev_i2s, int att, int err, +int tx_block_write_slab(const struct device *dev_i2s, int att, int err, struct k_mem_slab *slab); void fill_buf_const(int16_t *tx_block, int16_t val_l, int16_t val_r); diff --git a/tests/drivers/i2s/i2s_api/src/main.c b/tests/drivers/i2s/i2s_api/src/main.c index ebdb1d2f2fbdac..6d32cfbfb1889b 100644 --- a/tests/drivers/i2s/i2s_api/src/main.c +++ b/tests/drivers/i2s/i2s_api/src/main.c @@ -12,7 +12,7 @@ void test_main(void) { - struct device *dev_i2s; + const struct device *dev_i2s; k_thread_access_grant(k_current_get(), &rx_0_mem_slab, &tx_0_mem_slab, diff --git a/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c b/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c index 27c8e6681597c0..4efd9873148da7 100644 --- a/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c +++ b/tests/drivers/i2s/i2s_api/src/test_i2s_loopback.c @@ -15,11 +15,11 @@ K_MEM_SLAB_DEFINE(rx_0_mem_slab, BLOCK_SIZE, NUM_RX_BLOCKS, 32); K_MEM_SLAB_DEFINE(tx_0_mem_slab, BLOCK_SIZE, NUM_TX_BLOCKS, 32); -static int tx_block_write(struct device *dev_i2s, int att, int err) +static int tx_block_write(const struct device *dev_i2s, int att, int err) { return tx_block_write_slab(dev_i2s, att, err, &tx_0_mem_slab); } -static int rx_block_read(struct device *dev_i2s, int att) +static int rx_block_read(const struct device *dev_i2s, int att) { return rx_block_read_slab(dev_i2s, att, &rx_0_mem_slab); } @@ -27,7 +27,7 @@ static int rx_block_read(struct device *dev_i2s, int att) /** Configure I2S TX transfer. */ void test_i2s_tx_transfer_configure_0(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -53,7 +53,7 @@ void test_i2s_tx_transfer_configure_0(void) /** Configure I2S RX transfer. */ void test_i2s_rx_transfer_configure_0(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -86,7 +86,7 @@ void test_i2s_rx_transfer_configure_0(void) */ void test_i2s_transfer_short(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); @@ -150,7 +150,7 @@ void test_i2s_transfer_short(void) */ void test_i2s_transfer_long(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); @@ -202,7 +202,7 @@ void test_i2s_transfer_long(void) */ void test_i2s_rx_sync_start(void) { - struct device *dev_i2s; + const struct device *dev_i2s; size_t rx_size; int ret; char buf[BLOCK_SIZE]; @@ -252,7 +252,7 @@ void test_i2s_rx_sync_start(void) */ void test_i2s_rx_empty_timeout(void) { - struct device *dev_i2s; + const struct device *dev_i2s; size_t rx_size; int ret; char buf[BLOCK_SIZE]; @@ -272,7 +272,7 @@ void test_i2s_rx_empty_timeout(void) */ void test_i2s_transfer_restart(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); @@ -355,7 +355,7 @@ void test_i2s_transfer_restart(void) */ void test_i2s_transfer_rx_overrun(void) { - struct device *dev_i2s; + const struct device *dev_i2s; size_t rx_size; int ret; char rx_buf[BLOCK_SIZE]; @@ -427,7 +427,7 @@ void test_i2s_transfer_rx_overrun(void) */ void test_i2s_transfer_tx_underrun(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); diff --git a/tests/drivers/i2s/i2s_api/src/test_i2s_states.c b/tests/drivers/i2s/i2s_api/src/test_i2s_states.c index 70416675969722..ee370ce433ecbb 100644 --- a/tests/drivers/i2s/i2s_api/src/test_i2s_states.c +++ b/tests/drivers/i2s/i2s_api/src/test_i2s_states.c @@ -15,11 +15,11 @@ K_MEM_SLAB_DEFINE(rx_1_mem_slab, BLOCK_SIZE, NUM_RX_BLOCKS, 32); K_MEM_SLAB_DEFINE(tx_1_mem_slab, BLOCK_SIZE, NUM_TX_BLOCKS, 32); -static int tx_block_write(struct device *dev_i2s, int att, int err) +static int tx_block_write(const struct device *dev_i2s, int att, int err) { return tx_block_write_slab(dev_i2s, att, err, &tx_1_mem_slab); } -static int rx_block_read(struct device *dev_i2s, int att) +static int rx_block_read(const struct device *dev_i2s, int att) { return rx_block_read_slab(dev_i2s, att, &rx_1_mem_slab); } @@ -27,7 +27,7 @@ static int rx_block_read(struct device *dev_i2s, int att) /** Configure I2S TX transfer. */ void test_i2s_tx_transfer_configure_1(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -53,7 +53,7 @@ void test_i2s_tx_transfer_configure_1(void) /** Configure I2S RX transfer. */ void test_i2s_rx_transfer_configure_1(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -85,7 +85,7 @@ void test_i2s_rx_transfer_configure_1(void) */ void test_i2s_state_not_ready_neg(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; size_t rx_size; int ret; @@ -149,7 +149,7 @@ void test_i2s_state_not_ready_neg(void) */ void test_i2s_state_ready_neg(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -209,7 +209,7 @@ void test_i2s_state_ready_neg(void) */ void test_i2s_state_running_neg(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); @@ -264,7 +264,7 @@ void test_i2s_state_running_neg(void) */ void test_i2s_state_stopping_neg(void) { - struct device *dev_i2s; + const struct device *dev_i2s; int ret; dev_i2s = device_get_binding(I2S_DEV_NAME); @@ -326,7 +326,7 @@ void test_i2s_state_stopping_neg(void) */ void test_i2s_state_error_neg(void) { - struct device *dev_i2s; + const struct device *dev_i2s; size_t rx_size; int ret; char rx_buf[BLOCK_SIZE]; diff --git a/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c b/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c index 3852704cfd9e66..e0f0b18ed12f54 100644 --- a/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c +++ b/tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c @@ -76,7 +76,7 @@ static int verify_buf(int16_t *rx_block, int att) /** Configure I2S TX transfer. */ void test_i2s_tx_transfer_configure(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -102,7 +102,7 @@ void test_i2s_tx_transfer_configure(void) /** Configure I2S RX transfer. */ void test_i2s_rx_transfer_configure(void) { - struct device *dev_i2s; + const struct device *dev_i2s; struct i2s_config i2s_cfg; int ret; @@ -135,7 +135,7 @@ void test_i2s_rx_transfer_configure(void) */ void test_i2s_transfer_short(void) { - struct device *dev_i2s; + const struct device *dev_i2s; void *rx_block[3]; void *tx_block; size_t rx_size; @@ -211,7 +211,7 @@ void test_i2s_transfer_short(void) */ void test_i2s_transfer_long(void) { - struct device *dev_i2s; + const struct device *dev_i2s; void *rx_block[NUM_BLOCKS]; void *tx_block[NUM_BLOCKS]; size_t rx_size; diff --git a/tests/drivers/ipm/src/ipm_dummy.c b/tests/drivers/ipm/src/ipm_dummy.c index 3b2896a732788c..732393e547a0e4 100644 --- a/tests/drivers/ipm/src/ipm_dummy.c +++ b/tests/drivers/ipm/src/ipm_dummy.c @@ -23,7 +23,7 @@ */ static void ipm_dummy_isr(void *data) { - struct device *d = (struct device *)data; + const struct device *d = (const struct device *)data; struct ipm_dummy_driver_data *driver_data = d->data; /* In a real driver the interrupt simply wouldn't fire, we fake @@ -44,7 +44,7 @@ static void ipm_dummy_isr(void *data) /* IPM API functions for the dummy driver */ -static int ipm_dummy_send(struct device *d, int wait, uint32_t id, +static int ipm_dummy_send(const struct device *d, int wait, uint32_t id, const void *data, int size) { struct ipm_dummy_driver_data *driver_data; @@ -80,7 +80,8 @@ static int ipm_dummy_send(struct device *d, int wait, uint32_t id, return 0; } -static void ipm_dummy_register_callback(struct device *d, ipm_callback_t cb, +static void ipm_dummy_register_callback(const struct device *d, + ipm_callback_t cb, void *cb_context) { struct ipm_dummy_driver_data *driver_data; @@ -90,7 +91,7 @@ static void ipm_dummy_register_callback(struct device *d, ipm_callback_t cb, driver_data->cb_context = cb_context; } -static int ipm_dummy_set_enabled(struct device *d, int enable) +static int ipm_dummy_set_enabled(const struct device *d, int enable) { struct ipm_dummy_driver_data *driver_data = d->data; @@ -102,12 +103,12 @@ static int ipm_dummy_set_enabled(struct device *d, int enable) return 0; } -static uint32_t ipm_dummy_max_id_val_get(struct device *d) +static uint32_t ipm_dummy_max_id_val_get(const struct device *d) { return 0xFFFFFFFF; } -static int ipm_dummy_max_data_size_get(struct device *d) +static int ipm_dummy_max_data_size_get(const struct device *d) { return DUMMY_IPM_DATA_WORDS * sizeof(uint32_t); } @@ -124,7 +125,7 @@ struct ipm_driver_api ipm_dummy_api = { * to high-level drivers under test */ -int ipm_dummy_init(struct device *d) +int ipm_dummy_init(const struct device *d) { struct ipm_dummy_driver_data *driver_data; diff --git a/tests/drivers/ipm/src/ipm_dummy.h b/tests/drivers/ipm/src/ipm_dummy.h index f800369211b5ea..ee8be601b4b998 100644 --- a/tests/drivers/ipm/src/ipm_dummy.h +++ b/tests/drivers/ipm/src/ipm_dummy.h @@ -28,5 +28,5 @@ struct ipm_dummy_driver_data { volatile struct ipm_dummy_regs regs; }; -int ipm_dummy_init(struct device *d); +int ipm_dummy_init(const struct device *d); #endif diff --git a/tests/drivers/ipm/src/main.c b/tests/drivers/ipm/src/main.c index 0970aa66be027a..2ee77df61f7763 100644 --- a/tests/drivers/ipm/src/main.c +++ b/tests/drivers/ipm/src/main.c @@ -76,7 +76,7 @@ static const char thestr[] = "everything is awesome\n"; void main(void) { int rv, i; - struct device *ipm; + const struct device *ipm; TC_START("Test IPM"); ipm = device_get_binding("ipm_dummy0"); diff --git a/tests/drivers/kscan/kscan_api/src/test_kscan.c b/tests/drivers/kscan/kscan_api/src/test_kscan.c index 0b8bff27c9ab58..4717e592c2888f 100644 --- a/tests/drivers/kscan/kscan_api/src/test_kscan.c +++ b/tests/drivers/kscan/kscan_api/src/test_kscan.c @@ -12,7 +12,8 @@ #define KSCAN_DEV_NAME DT_LABEL(DT_ALIAS(kscan0)) -static void kb_callback(struct device *dev, uint32_t row, uint32_t col, bool pressed) +static void kb_callback(const struct device *dev, uint32_t row, uint32_t col, + bool pressed) { ARG_UNUSED(dev); ARG_UNUSED(row); @@ -22,7 +23,7 @@ static void kb_callback(struct device *dev, uint32_t row, uint32_t col, bool pre static int test_kb_callback(void) { - struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); + const struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); if (!kscan_dev) { TC_PRINT("Cannot get KBSCAN device\n"); @@ -39,7 +40,7 @@ static int test_kb_callback(void) static int test_null_callback(void) { - struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); + const struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); if (!kscan_dev) { TC_PRINT("Cannot get KBSCAN device\n"); @@ -56,7 +57,7 @@ static int test_null_callback(void) static int test_disable_enable_callback(void) { - struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); + const struct device *kscan_dev = device_get_binding(KSCAN_DEV_NAME); if (!kscan_dev) { TC_PRINT("Cannot get KBSCAN device\n"); diff --git a/tests/drivers/led/led_api/src/test_led_api.c b/tests/drivers/led/led_api/src/test_led_api.c index a073fb67a23289..ac5b6ff89b85dd 100644 --- a/tests/drivers/led/led_api/src/test_led_api.c +++ b/tests/drivers/led/led_api/src/test_led_api.c @@ -61,9 +61,9 @@ static ZTEST_DMEM int num_leds = ARRAY_SIZE(test_led_info) LED_CONTROLLER_INFO(LED_CTRL_NODE_ID); -static ZTEST_BMEM struct device *led_ctrl; +static ZTEST_BMEM const struct device *led_ctrl; -struct device *get_led_controller(void) +const struct device *get_led_controller(void) { return device_get_binding(LED_CTRL_DEV_NAME); } diff --git a/tests/drivers/led/led_api/src/test_led_api.h b/tests/drivers/led/led_api/src/test_led_api.h index 4895ae94f1a1dd..5759dd9a646635 100644 --- a/tests/drivers/led/led_api/src/test_led_api.h +++ b/tests/drivers/led/led_api/src/test_led_api.h @@ -7,7 +7,7 @@ #ifndef TEST_LED_API_H_ #define TEST_LED_API_H_ -struct device *get_led_controller(void); +const struct device *get_led_controller(void); void test_led_setup(void); void test_led_get_info(void); diff --git a/tests/drivers/pwm/pwm_api/src/test_pwm.c b/tests/drivers/pwm/pwm_api/src/test_pwm.c index 09823c83f4616c..a218bcc79adf31 100644 --- a/tests/drivers/pwm/pwm_api/src/test_pwm.c +++ b/tests/drivers/pwm/pwm_api/src/test_pwm.c @@ -84,7 +84,7 @@ static int test_task(uint32_t port, uint32_t period, uint32_t pulse, uint8_t uni TC_PRINT("[PWM]: %" PRIu8 ", [period]: %" PRIu32 ", [pulse]: %" PRIu32 "\n", port, period, pulse); - struct device *pwm_dev = device_get_binding(PWM_DEV_NAME); + const struct device *pwm_dev = device_get_binding(PWM_DEV_NAME); if (!pwm_dev) { TC_PRINT("Cannot get PWM device\n"); diff --git a/tests/drivers/sensor/src/dummy_sensor.c b/tests/drivers/sensor/src/dummy_sensor.c index 19e0d143f3f8d2..6efd60342db275 100644 --- a/tests/drivers/sensor/src/dummy_sensor.c +++ b/tests/drivers/sensor/src/dummy_sensor.c @@ -19,8 +19,8 @@ static const struct dummy_sensor_config dummy_config = { .i2c_address = 123 }; -static int dummy_sensor_sample_fetch(struct device *dev, - enum sensor_channel chan) +static int dummy_sensor_sample_fetch(const struct device *dev, + enum sensor_channel chan) { ARG_UNUSED(dev); ARG_UNUSED(chan); @@ -29,9 +29,9 @@ static int dummy_sensor_sample_fetch(struct device *dev, return 0; } -static int dummy_sensor_channel_get(struct device *dev, - enum sensor_channel chan, - struct sensor_value *val) +static int dummy_sensor_channel_get(const struct device *dev, + enum sensor_channel chan, + struct sensor_value *val) { struct dummy_sensor_data *data = dev->data; @@ -64,19 +64,19 @@ static int dummy_sensor_channel_get(struct device *dev, } /* return 0 for dummy driver to imitate interrupt */ -static int dummy_init_interrupt(struct device *dev) +static int dummy_init_interrupt(const struct device *dev) { ARG_UNUSED(dev); return 0; } -static int dummy_sensor_init(struct device *dev) +static int dummy_sensor_init(const struct device *dev) { struct dummy_sensor_data *data = dev->data; const struct dummy_sensor_config *config = dev->config; /* i2c should be null for dummy driver */ - struct device *i2c = device_get_binding(config->i2c_name); + const struct device *i2c = device_get_binding(config->i2c_name); if (i2c != NULL) { LOG_ERR("Should be Null for %s device!", config->i2c_name); @@ -97,10 +97,10 @@ static int dummy_sensor_init(struct device *dev) return 0; } -int dummy_sensor_attr_set(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - const struct sensor_value *val) +int dummy_sensor_attr_set(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + const struct sensor_value *val) { struct dummy_sensor_data *data = dev->data; @@ -114,10 +114,10 @@ int dummy_sensor_attr_set(struct device *dev, return -ENOTSUP; } -int dummy_sensor_attr_get(struct device *dev, - enum sensor_channel chan, - enum sensor_attribute attr, - struct sensor_value *val) +int dummy_sensor_attr_get(const struct device *dev, + enum sensor_channel chan, + enum sensor_attribute attr, + struct sensor_value *val) { struct dummy_sensor_data *data = dev->data; @@ -131,9 +131,9 @@ int dummy_sensor_attr_get(struct device *dev, return -ENOTSUP; } -int dummy_sensor_trigger_set(struct device *dev, - const struct sensor_trigger *trig, - sensor_trigger_handler_t handler) +int dummy_sensor_trigger_set(const struct device *dev, + const struct sensor_trigger *trig, + sensor_trigger_handler_t handler) { struct dummy_sensor_data *data = dev->data; diff --git a/tests/drivers/sensor/src/main.c b/tests/drivers/sensor/src/main.c index 96f91a092e0dad..e4bb4cee129baf 100644 --- a/tests/drivers/sensor/src/main.c +++ b/tests/drivers/sensor/src/main.c @@ -77,7 +77,7 @@ static struct trigger_sequence trigger_elements[] = { */ void test_sensor_get_channels(void) { - struct device *dev; + const struct device *dev; struct sensor_value data; dev = device_get_binding(DUMMY_SENSOR_NAME); @@ -98,7 +98,7 @@ void test_sensor_get_channels(void) } } -static void trigger_handler(struct device *dev, +static void trigger_handler(const struct device *dev, struct sensor_trigger *trigger) { ARG_UNUSED(dev); @@ -123,7 +123,7 @@ static void trigger_handler(struct device *dev, */ void test_sensor_handle_triggers(void) { - struct device *dev; + const struct device *dev; struct sensor_value data; dev = device_get_binding(DUMMY_SENSOR_NAME); diff --git a/tests/drivers/spi/spi_loopback/src/spi.c b/tests/drivers/spi/spi_loopback/src/spi.c index 54b8598c55bed1..db450f50f7d7fc 100644 --- a/tests/drivers/spi/spi_loopback/src/spi.c +++ b/tests/drivers/spi/spi_loopback/src/spi.c @@ -103,7 +103,7 @@ static int cs_ctrl_gpio_config(void) #endif /* CONFIG_SPI_LOOPBACK_CS_GPIO */ /* test transferring different buffers on the same dma channels */ -static int spi_complete_multiple(struct device *dev, +static int spi_complete_multiple(const struct device *dev, struct spi_config *spi_conf) { struct spi_buf tx_bufs[2]; @@ -168,7 +168,8 @@ static int spi_complete_multiple(struct device *dev, return 0; } -static int spi_complete_loop(struct device *dev, struct spi_config *spi_conf) +static int spi_complete_loop(const struct device *dev, + struct spi_config *spi_conf) { const struct spi_buf tx_bufs[] = { { @@ -218,7 +219,8 @@ static int spi_complete_loop(struct device *dev, struct spi_config *spi_conf) return 0; } -static int spi_null_tx_buf(struct device *dev, struct spi_config *spi_conf) +static int spi_null_tx_buf(const struct device *dev, + struct spi_config *spi_conf) { static const uint8_t EXPECTED_NOP_RETURN_BUF[BUF_SIZE] = { 0 }; (void)memset(buffer_rx, 0x77, BUF_SIZE); @@ -273,7 +275,8 @@ static int spi_null_tx_buf(struct device *dev, struct spi_config *spi_conf) return 0; } -static int spi_rx_half_start(struct device *dev, struct spi_config *spi_conf) +static int spi_rx_half_start(const struct device *dev, + struct spi_config *spi_conf) { const struct spi_buf tx_bufs[] = { { @@ -324,7 +327,8 @@ static int spi_rx_half_start(struct device *dev, struct spi_config *spi_conf) return 0; } -static int spi_rx_half_end(struct device *dev, struct spi_config *spi_conf) +static int spi_rx_half_end(const struct device *dev, + struct spi_config *spi_conf) { const struct spi_buf tx_bufs[] = { { @@ -384,7 +388,8 @@ static int spi_rx_half_end(struct device *dev, struct spi_config *spi_conf) return 0; } -static int spi_rx_every_4(struct device *dev, struct spi_config *spi_conf) +static int spi_rx_every_4(const struct device *dev, + struct spi_config *spi_conf) { const struct spi_buf tx_bufs[] = { { @@ -492,7 +497,8 @@ static void spi_async_call_cb(struct k_poll_event *async_evt, } } -static int spi_async_call(struct device *dev, struct spi_config *spi_conf) +static int spi_async_call(const struct device *dev, + struct spi_config *spi_conf) { const struct spi_buf tx_bufs[] = { { @@ -544,9 +550,9 @@ static int spi_async_call(struct device *dev, struct spi_config *spi_conf) } #endif -static int spi_resource_lock_test(struct device *lock_dev, +static int spi_resource_lock_test(const struct device *lock_dev, struct spi_config *spi_conf_lock, - struct device *try_dev, + const struct device *try_dev, struct spi_config *spi_conf_try) { spi_conf_lock->operation |= SPI_LOCK_ON; @@ -574,8 +580,8 @@ void test_spi_loopback(void) struct k_thread async_thread; k_tid_t async_thread_id; #endif - struct device *spi_slow; - struct device *spi_fast; + const struct device *spi_slow; + const struct device *spi_fast; LOG_INF("SPI test on buffers TX/RX %p/%p", buffer_tx, buffer_rx); diff --git a/tests/drivers/uart/uart_async_api/src/test_uart_async.c b/tests/drivers/uart/uart_async_api/src/test_uart_async.c index 850b4bd00e8286..5e0e24d5d01920 100644 --- a/tests/drivers/uart/uart_async_api/src/test_uart_async.c +++ b/tests/drivers/uart/uart_async_api/src/test_uart_async.c @@ -17,7 +17,7 @@ ZTEST_BMEM volatile bool failed_in_isr; #ifdef CONFIG_USERSPACE void set_permissions(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); k_thread_access_grant(k_current_get(), &tx_done, &tx_aborted, &rx_rdy, &rx_buf_released, &rx_disabled, @@ -25,7 +25,7 @@ void set_permissions(void) } #endif -void test_single_read_callback(struct device *dev, +void test_single_read_callback(const struct device *dev, struct uart_event *evt, void *user_data) { ARG_UNUSED(dev); @@ -56,7 +56,7 @@ ZTEST_BMEM volatile uint32_t tx_aborted_count; void test_single_read_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_single_read_callback, @@ -65,7 +65,7 @@ void test_single_read_setup(void) void test_single_read(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t rx_buf[10] = {0}; @@ -101,7 +101,7 @@ ZTEST_DMEM uint8_t buf_num = 1U; ZTEST_BMEM uint8_t *read_ptr; ZTEST_BMEM volatile size_t read_len; -void test_chained_read_callback(struct device *uart_dev, +void test_chained_read_callback(const struct device *uart_dev, struct uart_event *evt, void *user_data) { switch (evt->type) { @@ -137,14 +137,14 @@ void test_chained_read_callback(struct device *uart_dev, void test_chained_read_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_chained_read_callback, NULL); } void test_chained_read(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t tx_buf[10]; uart_rx_enable(uart_dev, chained_read_buf0, 10, 50); @@ -174,7 +174,7 @@ void test_chained_read(void) ZTEST_BMEM uint8_t double_buffer[2][12]; ZTEST_DMEM uint8_t *next_buf = double_buffer[1]; -void test_double_buffer_callback(struct device *uart_dev, +void test_double_buffer_callback(const struct device *uart_dev, struct uart_event *evt, void *user_data) { switch (evt->type) { @@ -203,14 +203,14 @@ void test_double_buffer_callback(struct device *uart_dev, void test_double_buffer_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_double_buffer_callback, NULL); } void test_double_buffer(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t tx_buf[4]; zassert_equal(uart_rx_enable(uart_dev, @@ -236,7 +236,7 @@ void test_double_buffer(void) "RX_DISABLED timeout"); } -void test_read_abort_callback(struct device *dev, +void test_read_abort_callback(const struct device *dev, struct uart_event *evt, void *user_data) { int err; @@ -267,7 +267,7 @@ void test_read_abort_callback(struct device *dev, void test_read_abort_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); failed_in_isr = false; uart_callback_set(uart_dev, test_read_abort_callback, NULL); @@ -280,7 +280,7 @@ void test_read_abort_setup(void) void test_read_abort(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t rx_buf[100]; uint8_t tx_buf[100]; @@ -313,7 +313,7 @@ void test_read_abort(void) ZTEST_BMEM volatile size_t sent; ZTEST_BMEM volatile size_t received; -void test_write_abort_callback(struct device *dev, +void test_write_abort_callback(const struct device *dev, struct uart_event *evt, void *user_data) { ARG_UNUSED(dev); @@ -343,14 +343,14 @@ void test_write_abort_callback(struct device *dev, void test_write_abort_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_write_abort_callback, NULL); } void test_write_abort(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t rx_buf[100]; uint8_t tx_buf[100]; @@ -383,7 +383,7 @@ void test_write_abort(void) } -void test_forever_timeout_callback(struct device *dev, +void test_forever_timeout_callback(const struct device *dev, struct uart_event *evt, void *user_data) { ARG_UNUSED(dev); @@ -413,14 +413,14 @@ void test_forever_timeout_callback(struct device *dev, void test_forever_timeout_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_forever_timeout_callback, NULL); } void test_forever_timeout(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t rx_buf[100]; uint8_t tx_buf[100]; @@ -460,7 +460,7 @@ ZTEST_DMEM uint8_t chained_write_tx_bufs[2][10] = {"Message 1", "Message 2"}; ZTEST_DMEM bool chained_write_next_buf = true; ZTEST_BMEM volatile uint8_t tx_sent; -void test_chained_write_callback(struct device *uart_dev, +void test_chained_write_callback(const struct device *uart_dev, struct uart_event *evt, void *user_data) { switch (evt->type) { @@ -493,14 +493,14 @@ void test_chained_write_callback(struct device *uart_dev, void test_chained_write_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_chained_write_callback, NULL); } void test_chained_write(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uint8_t rx_buf[20]; @@ -534,7 +534,8 @@ ZTEST_BMEM uint8_t long_tx_buf[1000]; ZTEST_BMEM volatile uint8_t evt_num; ZTEST_BMEM size_t long_received[2]; -void test_long_buffers_callback(struct device *uart_dev, struct uart_event *evt, void *user_data) +void test_long_buffers_callback(const struct device *uart_dev, + struct uart_event *evt, void *user_data) { static bool next_buf = true; @@ -571,14 +572,14 @@ void test_long_buffers_callback(struct device *uart_dev, struct uart_event *evt, void test_long_buffers_setup(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); uart_callback_set(uart_dev, test_long_buffers_callback, NULL); } void test_long_buffers(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); memset(long_rx_buf, 0, sizeof(long_rx_buf)); memset(long_tx_buf, 1, sizeof(long_tx_buf)); diff --git a/tests/drivers/uart/uart_basic_api/src/test_uart_config.c b/tests/drivers/uart/uart_basic_api/src/test_uart_config.c index e80ceb18771178..3c24866996ecd6 100644 --- a/tests/drivers/uart/uart_basic_api/src/test_uart_config.c +++ b/tests/drivers/uart/uart_basic_api/src/test_uart_config.c @@ -36,7 +36,7 @@ const struct uart_config uart_cfg = { static int test_configure(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); if (!uart_dev) { TC_PRINT("Cannot get UART device\n"); @@ -58,7 +58,7 @@ static int test_configure(void) /* test UART configure get (retrieve configuration) */ static int test_config_get(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); if (!uart_dev) { TC_PRINT("Cannot get UART device\n"); diff --git a/tests/drivers/uart/uart_basic_api/src/test_uart_fifo.c b/tests/drivers/uart/uart_basic_api/src/test_uart_fifo.c index 42e9f11fd2f8e1..8ecdf1e3ac38b1 100644 --- a/tests/drivers/uart/uart_basic_api/src/test_uart_fifo.c +++ b/tests/drivers/uart/uart_basic_api/src/test_uart_fifo.c @@ -41,7 +41,7 @@ static const char fifo_data[] = "This is a FIFO test.\r\n"; #define DATA_SIZE (sizeof(fifo_data) - 1) -static void uart_fifo_callback(struct device *dev, void *user_data) +static void uart_fifo_callback(const struct device *dev, void *user_data) { uint8_t recvData; static int tx_data_idx; @@ -92,7 +92,7 @@ static void uart_fifo_callback(struct device *dev, void *user_data) static int test_fifo_read(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); /* Verify uart_irq_callback_set() */ uart_irq_callback_set(uart_dev, uart_fifo_callback); @@ -115,7 +115,7 @@ static int test_fifo_read(void) static int test_fifo_fill(void) { - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); char_sent = 0; diff --git a/tests/drivers/uart/uart_basic_api/src/test_uart_poll.c b/tests/drivers/uart/uart_basic_api/src/test_uart_poll.c index 1fb6e5991b6b0b..9b536dc054fc2c 100644 --- a/tests/drivers/uart/uart_basic_api/src/test_uart_poll.c +++ b/tests/drivers/uart/uart_basic_api/src/test_uart_poll.c @@ -11,7 +11,7 @@ static const char *poll_data = "This is a POLL test.\r\n"; static int test_poll_in(void) { unsigned char recv_char; - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); if (!uart_dev) { TC_PRINT("Cannot get UART device\n"); @@ -38,7 +38,7 @@ static int test_poll_in(void) static int test_poll_out(void) { int i; - struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); + const struct device *uart_dev = device_get_binding(UART_DEVICE_NAME); if (!uart_dev) { TC_PRINT("Cannot get UART device\n"); diff --git a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c index 3859b1cc6c2564..7901033a4cbd61 100644 --- a/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c +++ b/tests/drivers/watchdog/wdt_basic_api/src/test_wdt.c @@ -131,7 +131,7 @@ volatile uint32_t m_testcase_index __attribute__((section(".noinit.test_wdt"))); volatile uint32_t m_testvalue __attribute__((section(".noinit.test_wdt"))); #if TEST_WDT_CALLBACK_1 -static void wdt_int_cb0(struct device *wdt_dev, int channel_id) +static void wdt_int_cb0(const struct device *wdt_dev, int channel_id) { ARG_UNUSED(wdt_dev); ARG_UNUSED(channel_id); @@ -140,7 +140,7 @@ static void wdt_int_cb0(struct device *wdt_dev, int channel_id) #endif #if TEST_WDT_CALLBACK_2 -static void wdt_int_cb1(struct device *wdt_dev, int channel_id) +static void wdt_int_cb1(const struct device *wdt_dev, int channel_id) { ARG_UNUSED(wdt_dev); ARG_UNUSED(channel_id); @@ -151,7 +151,7 @@ static void wdt_int_cb1(struct device *wdt_dev, int channel_id) static int test_wdt_no_callback(void) { int err; - struct device *wdt = device_get_binding(WDT_DEV_NAME); + const struct device *wdt = device_get_binding(WDT_DEV_NAME); if (!wdt) { TC_PRINT("Cannot get WDT device\n"); @@ -192,7 +192,7 @@ static int test_wdt_no_callback(void) static int test_wdt_callback_1(void) { int err; - struct device *wdt = device_get_binding(WDT_DEV_NAME); + const struct device *wdt = device_get_binding(WDT_DEV_NAME); if (!wdt) { TC_PRINT("Cannot get WDT device\n"); @@ -247,7 +247,7 @@ static int test_wdt_callback_1(void) static int test_wdt_callback_2(void) { int err; - struct device *wdt = device_get_binding(WDT_DEV_NAME); + const struct device *wdt = device_get_binding(WDT_DEV_NAME); if (!wdt) { TC_PRINT("Cannot get WDT device\n"); @@ -308,7 +308,7 @@ static int test_wdt_callback_2(void) static int test_wdt_bad_window_max(void) { int err; - struct device *wdt = device_get_binding(WDT_DEV_NAME); + const struct device *wdt = device_get_binding(WDT_DEV_NAME); if (!wdt) { TC_PRINT("Cannot get WDT device\n"); diff --git a/tests/kernel/device/src/abstract_driver.c b/tests/kernel/device/src/abstract_driver.c index 4a6b63fc8c4150..22110378dd5ff3 100644 --- a/tests/kernel/device/src/abstract_driver.c +++ b/tests/kernel/device/src/abstract_driver.c @@ -12,12 +12,13 @@ #define MY_DRIVER_B "my_driver_B" /* define indivial driver A */ -static int my_driver_A_do_this(struct device *device, int foo, int bar) +static int my_driver_A_do_this(const struct device *device, int foo, int bar) { return foo + bar; } -static void my_driver_A_do_that(struct device *device, unsigned int *baz) +static void my_driver_A_do_that(const struct device *device, + unsigned int *baz) { *baz = 1; } @@ -27,18 +28,19 @@ static struct subsystem_api my_driver_A_api_funcs = { .do_that = my_driver_A_do_that }; -int common_driver_init(struct device *dev) +int common_driver_init(const struct device *dev) { return 0; } /* define indivial driver B */ -static int my_driver_B_do_this(struct device *device, int foo, int bar) +static int my_driver_B_do_this(const struct device *device, int foo, int bar) { return foo - bar; } -static void my_driver_B_do_that(struct device *device, unsigned int *baz) +static void my_driver_B_do_that(const struct device *device, + unsigned int *baz) { *baz = 2; } diff --git a/tests/kernel/device/src/abstract_driver.h b/tests/kernel/device/src/abstract_driver.h index 1b471a3859aa24..ad785444c928ff 100644 --- a/tests/kernel/device/src/abstract_driver.h +++ b/tests/kernel/device/src/abstract_driver.h @@ -8,15 +8,18 @@ #include /* define subsystem common API for drivers */ -typedef int (*subsystem_do_this_t)(struct device *device, int foo, int bar); -typedef void (*subsystem_do_that_t)(struct device *device, unsigned int *baz); +typedef int (*subsystem_do_this_t)(const struct device *device, int foo, + int bar); +typedef void (*subsystem_do_that_t)(const struct device *device, + unsigned int *baz); struct subsystem_api { subsystem_do_this_t do_this; subsystem_do_that_t do_that; }; -static inline int subsystem_do_this(struct device *device, int foo, int bar) +static inline int subsystem_do_this(const struct device *device, int foo, + int bar) { struct subsystem_api *api; @@ -24,7 +27,8 @@ static inline int subsystem_do_this(struct device *device, int foo, int bar) return api->do_this(device, foo, bar); } -static inline void subsystem_do_that(struct device *device, unsigned int *baz) +static inline void subsystem_do_that(const struct device *device, + unsigned int *baz) { struct subsystem_api *api; diff --git a/tests/kernel/device/src/bad_driver.c b/tests/kernel/device/src/bad_driver.c index 989810320ca6b1..79c00a6750b243 100644 --- a/tests/kernel/device/src/bad_driver.c +++ b/tests/kernel/device/src/bad_driver.c @@ -10,7 +10,7 @@ #define BAD_DRIVER_NAME "bad_driver" -typedef int (*bad_api_configure_t)(struct device *dev, +typedef int (*bad_api_configure_t)(const struct device *dev, uint32_t dev_config); @@ -18,7 +18,7 @@ struct bad_driver_api { bad_api_configure_t configure; }; -static int bad_configure(struct device *dev, uint32_t config) +static int bad_configure(const struct device *dev, uint32_t config) { return 0; } @@ -27,7 +27,7 @@ static const struct bad_driver_api funcs = { .configure = bad_configure, }; -int bad_driver_init(struct device *dev) +int bad_driver_init(const struct device *dev) { return -EINVAL; } diff --git a/tests/kernel/device/src/dummy_driver.c b/tests/kernel/device/src/dummy_driver.c index c719dba589dabe..48dba6d8307569 100644 --- a/tests/kernel/device/src/dummy_driver.c +++ b/tests/kernel/device/src/dummy_driver.c @@ -10,7 +10,7 @@ #define DUMMY_DRIVER_NAME "dummy_driver" -typedef int (*dummy_api_configure_t)(struct device *dev, +typedef int (*dummy_api_configure_t)(const struct device *dev, uint32_t dev_config); @@ -18,7 +18,7 @@ struct dummy_driver_api { dummy_api_configure_t configure; }; -static int dummy_configure(struct device *dev, uint32_t config) +static int dummy_configure(const struct device *dev, uint32_t config) { return 0; } @@ -27,7 +27,7 @@ static const struct dummy_driver_api funcs = { .configure = dummy_configure, }; -int dummy_init(struct device *dev) +int dummy_init(const struct device *dev) { return 0; } diff --git a/tests/kernel/device/src/main.c b/tests/kernel/device/src/main.c index c04ef9225aef8e..f0ea29df9714a2 100644 --- a/tests/kernel/device/src/main.c +++ b/tests/kernel/device/src/main.c @@ -55,7 +55,7 @@ extern void test_mmio_device_map(void); */ void test_dummy_device(void) { - struct device *dev; + const struct device *dev; /* Validates device binding for a non-existing device object */ dev = device_get_binding(DUMMY_PORT_1); @@ -84,7 +84,7 @@ void test_dummy_device(void) */ static void test_dynamic_name(void) { - struct device *mux; + const struct device *mux; char name[sizeof(DUMMY_PORT_2)]; snprintk(name, sizeof(name), "%s", DUMMY_PORT_2); @@ -102,7 +102,7 @@ static void test_dynamic_name(void) */ static void test_bogus_dynamic_name(void) { - struct device *mux; + const struct device *mux; char name[64]; snprintk(name, sizeof(name), "ANOTHER_BOGUS_NAME"); @@ -127,22 +127,22 @@ static int add_init_record(bool pre_kernel) return 0; } -static int pre1_fn(struct device *dev) +static int pre1_fn(const struct device *dev) { return add_init_record(true); } -static int pre2_fn(struct device *dev) +static int pre2_fn(const struct device *dev) { return add_init_record(true); } -static int post_fn(struct device *dev) +static int post_fn(const struct device *dev) { return add_init_record(false); } -static int app_fn(struct device *dev) +static int app_fn(const struct device *dev) { return add_init_record(false); } @@ -196,7 +196,7 @@ void test_pre_kernel_detection(void) */ static void test_build_suspend_device_list(void) { - struct device *devices; + struct device const *devices; size_t devcount = z_device_get_all_static(&devices); zassert_false((devcount == 0), NULL); @@ -215,7 +215,7 @@ static void test_build_suspend_device_list(void) */ void test_dummy_device_pm(void) { - struct device *dev; + const struct device *dev; int busy, ret; dev = device_get_binding(DUMMY_PORT_2); @@ -343,7 +343,7 @@ void test_device_init_priority(void) */ void test_abstraction_driver_common(void) { - struct device *dev; + const struct device *dev; int ret; int foo = 2; int bar = 1; diff --git a/tests/kernel/device/src/mmio.c b/tests/kernel/device/src/mmio.c index fcbe53a606fb55..97f6592db99227 100644 --- a/tests/kernel/device/src/mmio.c +++ b/tests/kernel/device/src/mmio.c @@ -28,7 +28,7 @@ const struct foo_single_config_info foo0_config = { DEVICE_MMIO_ROM_INIT(DT_DRV_INST(0)), }; -int foo_single_init(struct device *device) +int foo_single_init(const struct device *device) { DEVICE_MMIO_MAP(device, K_MEM_CACHE_NONE); @@ -60,7 +60,7 @@ DEVICE_AND_API_INIT(foo0, "foo0", foo_single_init, &foo0_data, &foo0_config, void test_mmio_single(void) { struct z_device_mmio_rom *rom; - struct device *dev = device_get_binding("foo0"); + const struct device *dev = device_get_binding("foo0"); mm_reg_t regs; zassert_not_null(dev, "null foo0"); @@ -121,7 +121,7 @@ const struct foo_mult_config_info foo12_config = { #define DEV_DATA(dev) ((struct foo_mult_dev_data *)((dev)->data)) #define DEV_CFG(dev) ((struct foo_mult_config_info *)((dev)->config)) -int foo_mult_init(struct device *device) +int foo_mult_init(const struct device *device) { DEVICE_MMIO_NAMED_MAP(device, courge, K_MEM_CACHE_NONE); DEVICE_MMIO_NAMED_MAP(device, grault, K_MEM_CACHE_NONE); @@ -156,7 +156,7 @@ DEVICE_AND_API_INIT(foo12, "foo12", foo_mult_init, &foo12_data, &foo12_config, void test_mmio_multiple(void) { /* See comments for test_mmio_single */ - struct device *dev = device_get_binding("foo12"); + const struct device *dev = device_get_binding("foo12"); mm_reg_t regs_courge, regs_grault; const struct z_device_mmio_rom *rom_courge, *rom_grault; diff --git a/tests/kernel/device/src/test_driver_init.c b/tests/kernel/device/src/test_driver_init.c index 5269454e9324df..2bcc4ab4b4ab2e 100644 --- a/tests/kernel/device/src/test_driver_init.c +++ b/tests/kernel/device/src/test_driver_init.c @@ -42,13 +42,13 @@ unsigned int seq_level_cnt; unsigned int seq_priority_cnt; /* define driver type 1: for testing initialize levels and priorites */ -typedef int (*my_api_configure_t)(struct device *dev, int dev_config); +typedef int (*my_api_configure_t)(const struct device *dev, int dev_config); struct my_driver_api { my_api_configure_t configure; }; -static int my_configure(struct device *dev, int config) +static int my_configure(const struct device *dev, int config) { return 0; } @@ -58,7 +58,7 @@ static const struct my_driver_api funcs_my_drivers = { }; /* driver init function of testing level */ -static int my_driver_lv_1_init(struct device *dev) +static int my_driver_lv_1_init(const struct device *dev) { init_level_sequence[seq_level_cnt] = LEVEL_PRE_KERNEL_1; seq_level_cnt++; @@ -66,7 +66,7 @@ static int my_driver_lv_1_init(struct device *dev) return 0; } -static int my_driver_lv_2_init(struct device *dev) +static int my_driver_lv_2_init(const struct device *dev) { init_level_sequence[seq_level_cnt] = LEVEL_PRE_KERNEL_2; seq_level_cnt++; @@ -74,7 +74,7 @@ static int my_driver_lv_2_init(struct device *dev) return 0; } -static int my_driver_lv_3_init(struct device *dev) +static int my_driver_lv_3_init(const struct device *dev) { init_level_sequence[seq_level_cnt] = LEVEL_POST_KERNEL; seq_level_cnt++; @@ -82,7 +82,7 @@ static int my_driver_lv_3_init(struct device *dev) return 0; } -static int my_driver_lv_4_init(struct device *dev) +static int my_driver_lv_4_init(const struct device *dev) { init_level_sequence[seq_level_cnt] = LEVEL_APPLICATION; seq_level_cnt++; @@ -91,7 +91,7 @@ static int my_driver_lv_4_init(struct device *dev) } /* driver init function of testing priority */ -static int my_driver_pri_1_init(struct device *dev) +static int my_driver_pri_1_init(const struct device *dev) { init_priority_sequence[seq_priority_cnt] = PRIORITY_1; seq_priority_cnt++; @@ -99,7 +99,7 @@ static int my_driver_pri_1_init(struct device *dev) return 0; } -static int my_driver_pri_2_init(struct device *dev) +static int my_driver_pri_2_init(const struct device *dev) { init_priority_sequence[seq_priority_cnt] = PRIORITY_2; seq_priority_cnt++; @@ -107,7 +107,7 @@ static int my_driver_pri_2_init(struct device *dev) return 0; } -static int my_driver_pri_3_init(struct device *dev) +static int my_driver_pri_3_init(const struct device *dev) { init_priority_sequence[seq_priority_cnt] = PRIORITY_3; seq_priority_cnt++; @@ -115,7 +115,7 @@ static int my_driver_pri_3_init(struct device *dev) return 0; } -static int my_driver_pri_4_init(struct device *dev) +static int my_driver_pri_4_init(const struct device *dev) { init_priority_sequence[seq_priority_cnt] = PRIORITY_4; seq_priority_cnt++; diff --git a/tests/kernel/early_sleep/src/main.c b/tests/kernel/early_sleep/src/main.c index 99e1435992b97e..79ac2b829ce760 100644 --- a/tests/kernel/early_sleep/src/main.c +++ b/tests/kernel/early_sleep/src/main.c @@ -65,7 +65,7 @@ static int ticks_to_sleep(int ticks) } -static int test_early_sleep_post_kernel(struct device *unused) +static int test_early_sleep_post_kernel(const struct device *unused) { ARG_UNUSED(unused); actual_post_kernel_sleep_ticks = ticks_to_sleep(TEST_TICKS_TO_SLEEP); @@ -75,7 +75,7 @@ static int test_early_sleep_post_kernel(struct device *unused) SYS_INIT(test_early_sleep_post_kernel, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); -static int test_early_sleep_app(struct device *unused) +static int test_early_sleep_app(const struct device *unused) { ARG_UNUSED(unused); actual_app_sleep_ticks = ticks_to_sleep(TEST_TICKS_TO_SLEEP); diff --git a/tests/lib/devicetree/api/src/main.c b/tests/lib/devicetree/api/src/main.c index 81e58219b77f3c..85a58d84426c9f 100644 --- a/tests/lib/devicetree/api/src/main.c +++ b/tests/lib/devicetree/api/src/main.c @@ -1265,7 +1265,7 @@ struct test_gpio_data { bool is_gpio_ctlr; }; -static int test_gpio_init(struct device *dev) +static int test_gpio_init(const struct device *dev) { struct test_gpio_data *data = dev->data; @@ -1299,21 +1299,21 @@ static const struct gpio_driver_api test_api; DT_INST_FOREACH_STATUS_OKAY(TEST_GPIO_INIT) -static inline struct test_gpio_data *to_data(struct device *dev) +static inline struct test_gpio_data *to_data(const struct device *dev) { return (struct test_gpio_data *)dev->data; } -static inline const struct test_gpio_info *to_info(struct device *dev) +static inline const struct test_gpio_info *to_info(const struct device *dev) { return (const struct test_gpio_info *)dev->config; } static void test_devices(void) { - struct device *devs[3]; + const struct device *devs[3]; int i = 0; - struct device *dev_abcd; + const struct device *dev_abcd; unsigned int val; zassert_equal(DT_NUM_INST_STATUS_OKAY(vnd_gpio), 2, diff --git a/tests/net/6lo/src/main.c b/tests/net/6lo/src/main.c index c37c1bd3c6cf18..198ea15475538c 100644 --- a/tests/net/6lo/src/main.c +++ b/tests/net/6lo/src/main.c @@ -245,7 +245,7 @@ struct net_6lo_data { } __packed; -int net_6lo_dev_init(struct device *dev) +int net_6lo_dev_init(const struct device *dev) { struct net_6lo_context *net_6lo_context = dev->data; @@ -259,7 +259,7 @@ static void net_6lo_iface_init(struct net_if *iface) net_if_set_link_addr(iface, src_mac, 8, NET_LINK_IEEE802154); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { return 0; } diff --git a/tests/net/arp/src/main.c b/tests/net/arp/src/main.c index 1da4d07d34c943..b7840872d782ec 100644 --- a/tests/net/arp/src/main.c +++ b/tests/net/arp/src/main.c @@ -50,7 +50,7 @@ struct net_arp_context { struct net_linkaddr ll_addr; }; -int net_arp_dev_init(struct device *dev) +int net_arp_dev_init(const struct device *dev) { struct net_arp_context *net_arp_context = dev->data; @@ -59,7 +59,7 @@ int net_arp_dev_init(struct device *dev) return 0; } -static uint8_t *net_arp_get_mac(struct device *dev) +static uint8_t *net_arp_get_mac(const struct device *dev) { struct net_arp_context *context = dev->data; @@ -83,7 +83,7 @@ static void net_arp_iface_init(struct net_if *iface) net_if_set_link_addr(iface, mac, 6, NET_LINK_ETHERNET); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct net_eth_hdr *hdr; diff --git a/tests/net/checksum_offload/src/main.c b/tests/net/checksum_offload/src/main.c index 5618334433d6cf..690ab06096efd3 100644 --- a/tests/net/checksum_offload/src/main.c +++ b/tests/net/checksum_offload/src/main.c @@ -96,7 +96,7 @@ static struct eth_context eth_context_offloading_enabled; static void eth_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; net_if_set_link_addr(iface, context->mac_addr, @@ -136,7 +136,8 @@ static uint16_t get_udp_chksum(struct net_pkt *pkt) return udp_hdr->chksum; } -static int eth_tx_offloading_disabled(struct device *dev, struct net_pkt *pkt) +static int eth_tx_offloading_disabled(const struct device *dev, + struct net_pkt *pkt) { struct eth_context *context = dev->data; @@ -215,7 +216,8 @@ static int eth_tx_offloading_disabled(struct device *dev, struct net_pkt *pkt) return 0; } -static int eth_tx_offloading_enabled(struct device *dev, struct net_pkt *pkt) +static int eth_tx_offloading_enabled(const struct device *dev, + struct net_pkt *pkt) { struct eth_context *context = dev->data; @@ -243,13 +245,13 @@ static int eth_tx_offloading_enabled(struct device *dev, struct net_pkt *pkt) return 0; } -static enum ethernet_hw_caps eth_offloading_enabled(struct device *dev) +static enum ethernet_hw_caps eth_offloading_enabled(const struct device *dev) { return ETHERNET_HW_TX_CHKSUM_OFFLOAD | ETHERNET_HW_RX_CHKSUM_OFFLOAD; } -static enum ethernet_hw_caps eth_offloading_disabled(struct device *dev) +static enum ethernet_hw_caps eth_offloading_disabled(const struct device *dev) { return 0; } @@ -279,7 +281,7 @@ static void generate_mac(uint8_t *mac_addr) mac_addr[5] = sys_rand32_get(); } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; diff --git a/tests/net/context/src/main.c b/tests/net/context/src/main.c index 659dcde9b760c4..7ce45c106f6503 100644 --- a/tests/net/context/src/main.c +++ b/tests/net/context/src/main.c @@ -857,12 +857,12 @@ struct net_context_test { struct net_linkaddr ll_addr; }; -int net_context_dev_init(struct device *dev) +int net_context_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_context_get_mac(struct device *dev) +static uint8_t *net_context_get_mac(const struct device *dev) { struct net_context_test *context = dev->data; @@ -887,7 +887,7 @@ static void net_context_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct net_udp_hdr hdr, *udp_hdr; diff --git a/tests/net/dhcpv4/src/main.c b/tests/net/dhcpv4/src/main.c index c63803f98ce3e9..c8254228d047b3 100644 --- a/tests/net/dhcpv4/src/main.c +++ b/tests/net/dhcpv4/src/main.c @@ -163,7 +163,7 @@ struct net_dhcpv4_context { struct net_linkaddr ll_addr; }; -static int net_dhcpv4_dev_init(struct device *dev) +static int net_dhcpv4_dev_init(const struct device *dev) { struct net_dhcpv4_context *net_dhcpv4_context = dev->data; @@ -172,7 +172,7 @@ static int net_dhcpv4_dev_init(struct device *dev) return 0; } -static uint8_t *net_dhcpv4_get_mac(struct device *dev) +static uint8_t *net_dhcpv4_get_mac(const struct device *dev) { struct net_dhcpv4_context *context = dev->data; @@ -331,7 +331,7 @@ static int parse_dhcp_message(struct net_pkt *pkt, struct dhcp_msg *msg) return 0; } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct net_pkt *rpkt; struct dhcp_msg msg; diff --git a/tests/net/ethernet_mgmt/src/main.c b/tests/net/ethernet_mgmt/src/main.c index 762e2b0b017f77..ecaabbf98aece0 100644 --- a/tests/net/ethernet_mgmt/src/main.c +++ b/tests/net/ethernet_mgmt/src/main.c @@ -41,7 +41,7 @@ static struct eth_fake_context eth_fake_data; static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -53,7 +53,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); @@ -62,7 +62,7 @@ static int eth_fake_send(struct device *dev, return 0; } -static enum ethernet_hw_caps eth_fake_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_fake_get_capabilities(const struct device *dev) { return ETHERNET_AUTO_NEGOTIATION_SET | ETHERNET_LINK_10BASE_T | ETHERNET_LINK_100BASE_T | ETHERNET_DUPLEX_SET | ETHERNET_QAV | @@ -115,7 +115,7 @@ static void eth_fake_recalc_qav_idle_slopes(struct eth_fake_context *ctx) } } -static int eth_fake_set_config(struct device *dev, +static int eth_fake_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -210,7 +210,7 @@ static int eth_fake_set_config(struct device *dev, return 0; } -static int eth_fake_get_config(struct device *dev, +static int eth_fake_get_config(const struct device *dev, enum ethernet_config_type type, struct ethernet_config *config) { @@ -272,7 +272,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { struct eth_fake_context *ctx = dev->data; int i; @@ -445,7 +445,7 @@ static void test_change_same_duplex(void) static void test_change_qav_params(void) { struct net_if *iface = net_if_get_default(); - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; struct ethernet_req_params params; int available_priority_queues; diff --git a/tests/net/hostname/src/main.c b/tests/net/hostname/src/main.c index b096749129dd37..943e4a1365e05c 100644 --- a/tests/net/hostname/src/main.c +++ b/tests/net/hostname/src/main.c @@ -62,12 +62,12 @@ struct net_if_test { struct net_linkaddr ll_addr; }; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -95,7 +95,7 @@ static void net_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); @@ -140,7 +140,7 @@ static struct eth_fake_context eth_fake_data; static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -160,7 +160,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); @@ -174,7 +174,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { struct eth_fake_context *ctx = dev->data; diff --git a/tests/net/icmpv4/src/main.c b/tests/net/icmpv4/src/main.c index 40e65d5616ac15..bf09d4a81177d0 100644 --- a/tests/net/icmpv4/src/main.c +++ b/tests/net/icmpv4/src/main.c @@ -137,7 +137,7 @@ struct net_icmpv4_context { struct net_linkaddr ll_addr; }; -static int net_icmpv4_dev_init(struct device *dev) +static int net_icmpv4_dev_init(const struct device *dev) { struct net_icmpv4_context *net_icmpv4_context = dev->data; @@ -146,7 +146,7 @@ static int net_icmpv4_dev_init(struct device *dev) return 0; } -static uint8_t *net_icmpv4_get_mac(struct device *dev) +static uint8_t *net_icmpv4_get_mac(const struct device *dev) { struct net_icmpv4_context *context = dev->data; @@ -286,7 +286,7 @@ static int verify_echo_reply_with_opts(struct net_pkt *pkt) return 0; } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { if (current == TEST_ICMPV4_ECHO_REQ) { return verify_echo_reply(pkt); diff --git a/tests/net/ieee802154/fragment/src/main.c b/tests/net/ieee802154/fragment/src/main.c index b9feebaaa93f51..2ea02e43e1d0a2 100644 --- a/tests/net/ieee802154/fragment/src/main.c +++ b/tests/net/ieee802154/fragment/src/main.c @@ -159,7 +159,7 @@ struct net_fragment_data { } __packed; -int net_fragment_dev_init(struct device *dev) +int net_fragment_dev_init(const struct device *dev) { return 0; } @@ -171,7 +171,7 @@ static void net_fragment_iface_init(struct net_if *iface) net_if_set_link_addr(iface, mac, 8, NET_LINK_IEEE802154); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { return 0; } diff --git a/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c b/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c index 65f2064e888be2..7b2ef2ca90c8e9 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c +++ b/tests/net/ieee802154/l2/src/ieee802154_fake_driver.c @@ -20,24 +20,24 @@ LOG_MODULE_REGISTER(net_ieee802154_fake_driver, LOG_LEVEL_DBG); extern struct net_pkt *current_pkt; extern struct k_sem driver_lock; -static enum ieee802154_hw_caps fake_get_capabilities(struct device *dev) +static enum ieee802154_hw_caps fake_get_capabilities(const struct device *dev) { return IEEE802154_HW_FCS | IEEE802154_HW_2_4_GHZ; } -static int fake_cca(struct device *dev) +static int fake_cca(const struct device *dev) { return 0; } -static int fake_set_channel(struct device *dev, uint16_t channel) +static int fake_set_channel(const struct device *dev, uint16_t channel) { NET_INFO("Channel %u\n", channel); return 0; } -static int fake_set_txpower(struct device *dev, int16_t dbm) +static int fake_set_txpower(const struct device *dev, int16_t dbm) { NET_INFO("TX power %d dbm\n", dbm); @@ -59,7 +59,7 @@ static inline void insert_frag(struct net_pkt *pkt, struct net_buf *frag) net_pkt_frag_add(current_pkt, new_frag); } -static int fake_tx(struct device *dev, +static int fake_tx(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) @@ -78,14 +78,14 @@ static int fake_tx(struct device *dev, return 0; } -static int fake_start(struct device *dev) +static int fake_start(const struct device *dev) { NET_INFO("FAKE ieee802154 driver started\n"); return 0; } -static int fake_stop(struct device *dev) +static int fake_stop(const struct device *dev) { NET_INFO("FAKE ieee802154 driver stopped\n"); @@ -107,7 +107,7 @@ static void fake_iface_init(struct net_if *iface) NET_INFO("FAKE ieee802154 iface initialized\n"); } -static int fake_init(struct device *dev) +static int fake_init(const struct device *dev) { fake_stop(dev); diff --git a/tests/net/ieee802154/l2/src/ieee802154_test.c b/tests/net/ieee802154/l2/src/ieee802154_test.c index 1d0816a5e267f7..f168d9aed3f389 100644 --- a/tests/net/ieee802154/l2/src/ieee802154_test.c +++ b/tests/net/ieee802154/l2/src/ieee802154_test.c @@ -263,7 +263,7 @@ static bool test_ack_reply(struct ieee802154_pkt_test *t) static bool initialize_test_environment(void) { - struct device *dev; + const struct device *dev; k_sem_reset(&driver_lock); diff --git a/tests/net/iface/src/main.c b/tests/net/iface/src/main.c index d8603a8237d5c2..5a6d1591838250 100644 --- a/tests/net/iface/src/main.c +++ b/tests/net/iface/src/main.c @@ -75,12 +75,12 @@ struct net_if_test { struct net_linkaddr ll_addr; }; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -108,7 +108,7 @@ static void net_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); @@ -195,7 +195,7 @@ static struct eth_fake_context eth_fake_data; static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -207,7 +207,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); @@ -216,12 +216,12 @@ static int eth_fake_send(struct device *dev, return 0; } -static enum ethernet_hw_caps eth_fake_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_fake_get_capabilities(const struct device *dev) { return ETHERNET_PROMISC_MODE; } -static int eth_fake_set_config(struct device *dev, +static int eth_fake_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -252,7 +252,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { struct eth_fake_context *ctx = dev->data; diff --git a/tests/net/ip-addr/src/main.c b/tests/net/ip-addr/src/main.c index 5341db63ea9ebe..6c6bf638131628 100644 --- a/tests/net/ip-addr/src/main.c +++ b/tests/net/ip-addr/src/main.c @@ -105,7 +105,7 @@ struct net_test_context { struct net_linkaddr ll_addr; }; -int net_test_init(struct device *dev) +int net_test_init(const struct device *dev) { struct net_test_context *net_test_context = dev->data; @@ -114,7 +114,7 @@ int net_test_init(struct device *dev) return 0; } -static uint8_t *net_test_get_mac(struct device *dev) +static uint8_t *net_test_get_mac(const struct device *dev) { struct net_test_context *context = dev->data; @@ -138,7 +138,7 @@ static void net_test_iface_init(struct net_if *iface) net_if_set_link_addr(iface, mac, 6, NET_LINK_ETHERNET); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { return 0; } diff --git a/tests/net/ipv6/src/main.c b/tests/net/ipv6/src/main.c index be99318ed912af..080ea1809155ff 100644 --- a/tests/net/ipv6/src/main.c +++ b/tests/net/ipv6/src/main.c @@ -140,12 +140,12 @@ struct net_test_ipv6 { struct net_linkaddr ll_addr; }; -int net_test_dev_init(struct device *dev) +int net_test_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_test_get_mac(struct device *dev) +static uint8_t *net_test_get_mac(const struct device *dev) { struct net_test_ipv6 *context = dev->data; @@ -227,7 +227,7 @@ static struct net_icmp_hdr *get_icmp_hdr(struct net_pkt *pkt) } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct net_icmp_hdr *icmp; @@ -292,7 +292,7 @@ NET_DEVICE_INIT(net_test_ipv6, "net_test_ipv6", 127); /* dummy interface for multi-interface tests */ -static int dummy_send(struct device *dev, struct net_pkt *pkt) +static int dummy_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); ARG_UNUSED(pkt); diff --git a/tests/net/ipv6_fragment/src/main.c b/tests/net/ipv6_fragment/src/main.c index 2b5b39d11e3e8f..36d7825b72ed4a 100644 --- a/tests/net/ipv6_fragment/src/main.c +++ b/tests/net/ipv6_fragment/src/main.c @@ -926,12 +926,12 @@ enum net_test_type { static enum net_test_type test_type = NO_TEST_TYPE; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -1328,7 +1328,7 @@ static int verify_fragment(struct net_pkt *pkt) return 0; } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { NET_DBG("No data to send!"); diff --git a/tests/net/lib/dns_addremove/src/main.c b/tests/net/lib/dns_addremove/src/main.c index 24dd9499897f04..a5c81ea0a1e7ed 100644 --- a/tests/net/lib/dns_addremove/src/main.c +++ b/tests/net/lib/dns_addremove/src/main.c @@ -79,12 +79,12 @@ struct net_if_test { uint8_t mac_addr[sizeof(struct net_eth_addr)]; }; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -109,7 +109,7 @@ static void net_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { DBG("No data to send!\n"); diff --git a/tests/net/lib/dns_resolve/src/main.c b/tests/net/lib/dns_resolve/src/main.c index 9fa2ec1f306e1e..f1534a3ca29a0b 100644 --- a/tests/net/lib/dns_resolve/src/main.c +++ b/tests/net/lib/dns_resolve/src/main.c @@ -77,12 +77,12 @@ struct net_if_test { struct net_linkaddr ll_addr; }; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -124,7 +124,7 @@ static inline int get_slot_by_id(struct dns_resolve_context *ctx, return -1; } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { DBG("No data to send!\n"); diff --git a/tests/net/mgmt/src/mgmt.c b/tests/net/mgmt/src/mgmt.c index f30690f74a521c..27c21fac39dbd4 100644 --- a/tests/net/mgmt/src/mgmt.c +++ b/tests/net/mgmt/src/mgmt.c @@ -65,7 +65,7 @@ static int test_mgmt_request(uint32_t mgmt_request, NET_MGMT_REGISTER_REQUEST_HANDLER(TEST_MGMT_REQUEST, test_mgmt_request); -int fake_dev_init(struct device *dev) +int fake_dev_init(const struct device *dev) { ARG_UNUSED(dev); @@ -79,7 +79,7 @@ static void fake_iface_init(struct net_if *iface) net_if_set_link_addr(iface, mac, 8, NET_LINK_DUMMY); } -static int fake_iface_send(struct device *dev, struct net_pkt *pkt) +static int fake_iface_send(const struct device *dev, struct net_pkt *pkt) { return 0; } diff --git a/tests/net/mld/src/main.c b/tests/net/mld/src/main.c index 8fff1131bb6c0f..2e3a16834d83c4 100644 --- a/tests/net/mld/src/main.c +++ b/tests/net/mld/src/main.c @@ -68,12 +68,12 @@ struct net_test_mld { struct net_linkaddr ll_addr; }; -int net_test_dev_init(struct device *dev) +int net_test_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_test_get_mac(struct device *dev) +static uint8_t *net_test_get_mac(const struct device *dev) { struct net_test_mld *context = dev->data; @@ -108,7 +108,7 @@ static struct net_icmp_hdr *get_icmp_hdr(struct net_pkt *pkt) return (struct net_icmp_hdr *)net_pkt_cursor_get_pos(pkt); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct net_icmp_hdr *icmp; diff --git a/tests/net/net_pkt/src/main.c b/tests/net/net_pkt/src/main.c index bc75a12a475e8e..e93727122f0e8b 100644 --- a/tests/net/net_pkt/src/main.c +++ b/tests/net/net_pkt/src/main.c @@ -41,12 +41,12 @@ static void fake_dev_iface_init(struct net_if *iface) eth_if = iface; } -static int fake_dev_send(struct device *dev, struct net_pkt *pkt) +static int fake_dev_send(const struct device *dev, struct net_pkt *pkt) { return 0; } -int fake_dev_init(struct device *dev) +int fake_dev_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/tests/net/pm/src/main.c b/tests/net/pm/src/main.c index acb5c18d1af71a..3298409251eb0b 100644 --- a/tests/net/pm/src/main.c +++ b/tests/net/pm/src/main.c @@ -21,7 +21,7 @@ struct fake_dev_context { struct net_if *iface; }; -static int fake_dev_pm_control(struct device *dev, uint32_t command, +static int fake_dev_pm_control(const struct device *dev, uint32_t command, void *context, device_pm_cb cb, void *arg) { struct fake_dev_context *ctx = dev->data; @@ -49,7 +49,7 @@ static int fake_dev_pm_control(struct device *dev, uint32_t command, } -static int fake_dev_send(struct device *dev, struct net_pkt *pkt) +static int fake_dev_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); ARG_UNUSED(pkt); @@ -74,7 +74,7 @@ static uint8_t *fake_dev_get_mac(struct fake_dev_context *ctx) static void fake_dev_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct fake_dev_context *ctx = dev->data; uint8_t *mac = fake_dev_get_mac(ctx); @@ -83,7 +83,7 @@ static void fake_dev_iface_init(struct net_if *iface) ctx->iface = iface; } -int fake_dev_init(struct device *dev) +int fake_dev_init(const struct device *dev) { ARG_UNUSED(dev); @@ -121,7 +121,7 @@ void test_setup(void) void test_pm(void) { struct net_if *iface = net_if_get_default(); - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); char data[] = "some data"; struct sockaddr_in addr4; int sock; diff --git a/tests/net/promiscuous/src/main.c b/tests/net/promiscuous/src/main.c index 6c681bed1b4e2b..af2b7cf0febdca 100644 --- a/tests/net/promiscuous/src/main.c +++ b/tests/net/promiscuous/src/main.c @@ -76,7 +76,7 @@ static struct eth_fake_context eth_fake_data2; static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -88,7 +88,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); @@ -97,12 +97,12 @@ static int eth_fake_send(struct device *dev, return 0; } -static enum ethernet_hw_caps eth_fake_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_fake_get_capabilities(const struct device *dev) { return ETHERNET_PROMISC_MODE; } -static int eth_fake_set_config(struct device *dev, +static int eth_fake_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -133,7 +133,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { struct eth_fake_context *ctx = dev->data; diff --git a/tests/net/ptp/clock/src/main.c b/tests/net/ptp/clock/src/main.c index 7607196b01d48d..6b7857ec54e807 100644 --- a/tests/net/ptp/clock/src/main.c +++ b/tests/net/ptp/clock/src/main.c @@ -77,7 +77,7 @@ struct eth_context { uint8_t mac_addr[6]; struct net_ptp_time time; - struct device *ptp_clock; + const struct device *ptp_clock; }; static struct eth_context eth_context_1; @@ -86,7 +86,7 @@ static struct eth_context eth_context_3; static void eth_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; net_if_set_link_addr(iface, context->mac_addr, @@ -96,7 +96,7 @@ static void eth_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_context *context = dev->data; @@ -117,12 +117,12 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static enum ethernet_hw_caps eth_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_capabilities(const struct device *dev) { return ETHERNET_PTP; } -static struct device *eth_get_ptp_clock(struct device *dev) +static const struct device *eth_get_ptp_clock(const struct device *dev) { struct eth_context *context = dev->data; @@ -148,7 +148,7 @@ static void generate_mac(uint8_t *mac_addr) mac_addr[5] = sys_rand32_get(); } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; @@ -182,7 +182,7 @@ struct ptp_context { struct eth_context *eth_context; }; -static int my_ptp_clock_set(struct device *dev, struct net_ptp_time *tm) +static int my_ptp_clock_set(const struct device *dev, struct net_ptp_time *tm) { struct ptp_context *ptp_ctx = dev->data; struct eth_context *eth_ctx = ptp_ctx->eth_context; @@ -196,7 +196,7 @@ static int my_ptp_clock_set(struct device *dev, struct net_ptp_time *tm) return 0; } -static int my_ptp_clock_get(struct device *dev, struct net_ptp_time *tm) +static int my_ptp_clock_get(const struct device *dev, struct net_ptp_time *tm) { struct ptp_context *ptp_ctx = dev->data; struct eth_context *eth_ctx = ptp_ctx->eth_context; @@ -206,7 +206,7 @@ static int my_ptp_clock_get(struct device *dev, struct net_ptp_time *tm) return 0; } -static int my_ptp_clock_adjust(struct device *dev, int increment) +static int my_ptp_clock_adjust(const struct device *dev, int increment) { struct ptp_context *ptp_ctx = dev->data; struct eth_context *eth_ctx = ptp_ctx->eth_context; @@ -216,7 +216,7 @@ static int my_ptp_clock_adjust(struct device *dev, int increment) return 0; } -static int my_ptp_clock_rate_adjust(struct device *dev, float ratio) +static int my_ptp_clock_rate_adjust(const struct device *dev, float ratio) { return 0; } @@ -231,9 +231,9 @@ static const struct ptp_clock_driver_api api = { .rate_adjust = my_ptp_clock_rate_adjust, }; -static int ptp_test_1_init(struct device *port) +static int ptp_test_1_init(const struct device *port) { - struct device *eth_dev = DEVICE_GET(eth_test_1); + const struct device *eth_dev = DEVICE_GET(eth_test_1); struct eth_context *context = eth_dev->data; struct ptp_context *ptp_context = port->data; @@ -247,9 +247,9 @@ DEVICE_AND_API_INIT(ptp_clock_1, PTP_CLOCK_NAME, ptp_test_1_init, &ptp_test_1_context, NULL, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY, &api); -static int ptp_test_2_init(struct device *port) +static int ptp_test_2_init(const struct device *port) { - struct device *eth_dev = DEVICE_GET(eth_test_2); + const struct device *eth_dev = DEVICE_GET(eth_test_2); struct eth_context *context = eth_dev->data; struct ptp_context *ptp_context = port->data; @@ -290,7 +290,7 @@ static void iface_cb(struct net_if *iface, void *user_data) if (net_if_l2(iface) == &NET_L2_GET_NAME(ETHERNET)) { static int ptp_iface_idx; - struct device *clk; + const struct device *clk; if (ud->eth_if_count >= ARRAY_SIZE(eth_interfaces)) { DBG("Invalid interface %p\n", iface); @@ -396,8 +396,8 @@ static void test_address_setup(void) static void test_ptp_clock_interfaces(void) { - struct device *clk_by_index; - struct device *clk; + const struct device *clk_by_index; + const struct device *clk; int idx; idx = ptp_interface[0]; @@ -427,7 +427,7 @@ static void test_ptp_clock_iface(int idx) .second = 1, .nanosecond = 1, }; - struct device *clk; + const struct device *clk; uint64_t orig, new_value; clk = net_eth_get_ptp_clock(eth_interfaces[idx]); @@ -466,12 +466,12 @@ static void test_ptp_clock_iface_2(void) test_ptp_clock_iface(ptp_interface[1]); } -static ZTEST_BMEM struct device *clk0; -static ZTEST_BMEM struct device *clk1; +static ZTEST_BMEM const struct device *clk0; +static ZTEST_BMEM const struct device *clk1; static void test_ptp_clock_get_by_index(void) { - struct device *clk, *clk_by_index; + const struct device *clk, *clk_by_index; int idx; idx = ptp_interface[0]; @@ -501,7 +501,7 @@ static void test_ptp_clock_get_by_index(void) static void test_ptp_clock_get_by_index_user(void) { - struct device *clk_by_index; + const struct device *clk_by_index; clk_by_index = net_eth_get_ptp_clock_by_index(ptp_clocks[0]); zassert_not_null(clk_by_index, "PTP 0 not found"); @@ -517,7 +517,7 @@ static ZTEST_BMEM struct net_ptp_time empty; static void test_ptp_clock_get_by_xxx(const char *who) { - struct device *clk_by_index; + const struct device *clk_by_index; int ret; clk_by_index = net_eth_get_ptp_clock_by_index(ptp_clocks[0]); @@ -533,7 +533,7 @@ static void test_ptp_clock_get_by_xxx(const char *who) static void test_ptp_clock_get_kernel(void) { - struct device *clk; + const struct device *clk; /* Make sure that this function is really run in kernel mode by * calling a function that will not work in user mode. @@ -550,7 +550,7 @@ static void test_ptp_clock_get_user(void) void test_main(void) { - struct device *clk; + const struct device *clk; clk = device_get_binding(PTP_CLOCK_NAME); if (clk != NULL) { diff --git a/tests/net/route/src/main.c b/tests/net/route/src/main.c index 6d965e79ad1ba5..c803df32f8a6ea 100644 --- a/tests/net/route/src/main.c +++ b/tests/net/route/src/main.c @@ -93,12 +93,12 @@ struct net_route_test { struct net_linkaddr ll_addr; }; -int net_route_dev_init(struct device *dev) +int net_route_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_route_get_mac(struct device *dev) +static uint8_t *net_route_get_mac(const struct device *dev) { struct net_route_test *route = dev->data; @@ -126,7 +126,7 @@ static void net_route_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { TC_ERROR("No data to send!\n"); @@ -164,7 +164,7 @@ static int tester_send(struct device *dev, struct net_pkt *pkt) return 0; } -static int tester_send_peer(struct device *dev, struct net_pkt *pkt) +static int tester_send_peer(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { TC_ERROR("No data to send!\n"); diff --git a/tests/net/route_mcast/src/main.c b/tests/net/route_mcast/src/main.c index a6e7a1ab975dd0..e5ef6b835672e4 100644 --- a/tests/net/route_mcast/src/main.c +++ b/tests/net/route_mcast/src/main.c @@ -138,12 +138,12 @@ struct net_route_mcast_scenario_cfg { static struct net_route_mcast_scenario_cfg active_scenario; -int net_route_mcast_dev_init(struct device *dev) +int net_route_mcast_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_route_mcast_get_mac(struct device *dev) +static uint8_t *net_route_mcast_get_mac(const struct device *dev) { struct net_route_mcast_iface_cfg *cfg = dev->data; @@ -222,7 +222,7 @@ static bool check_packet_addresses(struct net_pkt *pkt) return true; } -static int iface_send(struct device *dev, struct net_pkt *pkt) +static int iface_send(const struct device *dev, struct net_pkt *pkt) { if (!active_scenario.is_active) { return 0; diff --git a/tests/net/shell/src/main.c b/tests/net/shell/src/main.c index 0c94edcb0d32a0..e8ddd3b375b22b 100644 --- a/tests/net/shell/src/main.c +++ b/tests/net/shell/src/main.c @@ -58,7 +58,7 @@ struct net_udp_context { struct net_linkaddr ll_addr; }; -int net_udp_dev_init(struct device *dev) +int net_udp_dev_init(const struct device *dev) { struct net_udp_context *net_udp_context = dev->data; @@ -67,7 +67,7 @@ int net_udp_dev_init(struct device *dev) return 0; } -static uint8_t *net_udp_get_mac(struct device *dev) +static uint8_t *net_udp_get_mac(const struct device *dev) { struct net_udp_context *context = dev->data; @@ -93,7 +93,7 @@ static void net_udp_iface_init(struct net_if *iface) static int send_status = -EINVAL; -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { DBG("No data to send!\n"); diff --git a/tests/net/socket/af_packet/src/main.c b/tests/net/socket/af_packet/src/main.c index 5078a06bd84222..2b11eb6ae17b10 100644 --- a/tests/net/socket/af_packet/src/main.c +++ b/tests/net/socket/af_packet/src/main.c @@ -36,7 +36,7 @@ static struct eth_fake_context eth_fake_data2 = { .mac_address = lladdr2 }; -static int eth_fake_send(struct device *dev, struct net_pkt *pkt) +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { struct net_pkt *recv_pkt; int ret; @@ -59,7 +59,7 @@ static int eth_fake_send(struct device *dev, struct net_pkt *pkt) static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -74,7 +74,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/tests/net/socket/net_mgmt/src/main.c b/tests/net/socket/net_mgmt/src/main.c index 7ac59a4ef40b87..11669d3217831f 100644 --- a/tests/net/socket/net_mgmt/src/main.c +++ b/tests/net/socket/net_mgmt/src/main.c @@ -53,7 +53,7 @@ static struct eth_fake_context eth_fake_data; static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -65,7 +65,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { ARG_UNUSED(dev); @@ -120,7 +120,7 @@ static void eth_fake_recalc_qav_idle_slopes(struct eth_fake_context *ctx) } } -static int eth_fake_set_config(struct device *dev, +static int eth_fake_set_config(const struct device *dev, enum ethernet_config_type type, const struct ethernet_config *config) { @@ -167,7 +167,7 @@ static int eth_fake_set_config(struct device *dev, return 0; } -static int eth_fake_get_config(struct device *dev, +static int eth_fake_get_config(const struct device *dev, enum ethernet_config_type type, struct ethernet_config *config) { @@ -217,7 +217,7 @@ static int eth_fake_get_config(struct device *dev, return 0; } -static enum ethernet_hw_caps eth_fake_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_fake_get_capabilities(const struct device *dev) { return ETHERNET_AUTO_NEGOTIATION_SET | ETHERNET_LINK_10BASE_T | ETHERNET_LINK_100BASE_T | ETHERNET_DUPLEX_SET | ETHERNET_QAV | @@ -233,7 +233,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { struct eth_fake_context *ctx = dev->data; int i; diff --git a/tests/net/socket/udp/src/main.c b/tests/net/socket/udp/src/main.c index 11c058e2daafbf..4ca4caae3db9e3 100644 --- a/tests/net/socket/udp/src/main.c +++ b/tests/net/socket/udp/src/main.c @@ -809,7 +809,7 @@ static struct net_linkaddr server_link_addr = { static void eth_fake_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_fake_context *ctx = dev->data; ctx->iface = iface; @@ -821,7 +821,7 @@ static void eth_fake_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_fake_send(struct device *dev, struct net_pkt *pkt) +static int eth_fake_send(const struct device *dev, struct net_pkt *pkt) { uint64_t txtime; @@ -849,7 +849,7 @@ static struct ethernet_api eth_fake_api_funcs = { .send = eth_fake_send, }; -static int eth_fake_init(struct device *dev) +static int eth_fake_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/tests/net/tcp/src/main.c b/tests/net/tcp/src/main.c index 94e22b80b83f3c..87eaa057121adc 100644 --- a/tests/net/tcp/src/main.c +++ b/tests/net/tcp/src/main.c @@ -85,7 +85,7 @@ static bool syn_v6_sent; struct net_tcp_context { }; -int net_tcp_dev_init(struct device *dev) +int net_tcp_dev_init(const struct device *dev) { return 0; } @@ -237,7 +237,7 @@ static void v6_send_syn_ack(struct net_pkt *req) static int send_status = -EINVAL; -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); @@ -254,7 +254,7 @@ static int tester_send(struct device *dev, struct net_pkt *pkt) return 0; } -static int tester_send_peer(struct device *dev, struct net_pkt *pkt) +static int tester_send_peer(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); diff --git a/tests/net/tcp2/src/main.c b/tests/net/tcp2/src/main.c index 70e27b54997306..b4b81ddc6f0f15 100644 --- a/tests/net/tcp2/src/main.c +++ b/tests/net/tcp2/src/main.c @@ -87,7 +87,7 @@ static enum test_state t_state; static struct k_delayed_work test_server; static void test_server_timeout(struct k_work *work); -static int tester_send(struct device *dev, struct net_pkt *pkt); +static int tester_send(const struct device *dev, struct net_pkt *pkt); static void handle_client_test(sa_family_t af, struct tcphdr *th); static void handle_server_test(sa_family_t af, struct tcphdr *th); @@ -111,7 +111,7 @@ struct net_tcp_context { struct net_linkaddr ll_addr; }; -static int net_tcp_dev_init(struct device *dev) +static int net_tcp_dev_init(const struct device *dev) { struct net_tcp_context *net_tcp_context = dev->data; @@ -120,7 +120,7 @@ static int net_tcp_dev_init(struct device *dev) return 0; } -static uint8_t *net_tcp_get_mac(struct device *dev) +static uint8_t *net_tcp_get_mac(const struct device *dev) { struct net_tcp_context *context = dev->data; @@ -346,7 +346,7 @@ static int read_tcp_header(struct net_pkt *pkt, struct tcphdr *th) return -EINVAL; } -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { struct tcphdr th; int ret; diff --git a/tests/net/traffic_class/src/main.c b/tests/net/traffic_class/src/main.c index 43474476620bc9..fcb20706b99d1e 100644 --- a/tests/net/traffic_class/src/main.c +++ b/tests/net/traffic_class/src/main.c @@ -106,7 +106,7 @@ static struct eth_context eth_context; static void eth_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; net_if_set_link_addr(iface, context->mac_addr, @@ -155,7 +155,7 @@ static bool check_higher_priority_pkt_recv(int tc, struct net_pkt *pkt) /* The eth_tx() will handle both sent packets or and it will also * simulate the receiving of the packets. */ -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); @@ -253,7 +253,7 @@ static void generate_mac(uint8_t *mac_addr) mac_addr[5] = sys_rand32_get(); } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; diff --git a/tests/net/tx_timestamp/src/main.c b/tests/net/tx_timestamp/src/main.c index ce6f2364f73b1b..83edab698e1277 100644 --- a/tests/net/tx_timestamp/src/main.c +++ b/tests/net/tx_timestamp/src/main.c @@ -88,7 +88,7 @@ static struct eth_context eth_context2; static void eth_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; net_if_set_link_addr(iface, context->mac_addr, @@ -98,7 +98,7 @@ static void eth_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { if (!pkt->buffer) { DBG("No data to send!\n"); @@ -121,7 +121,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static enum ethernet_hw_caps eth_get_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_get_capabilities(const struct device *dev) { return 0; } @@ -144,7 +144,7 @@ static void generate_mac(uint8_t *mac_addr) mac_addr[5] = sys_rand32_get(); } -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; diff --git a/tests/net/udp/src/main.c b/tests/net/udp/src/main.c index b9d863b847b283..54485d62e5af43 100644 --- a/tests/net/udp/src/main.c +++ b/tests/net/udp/src/main.c @@ -60,7 +60,7 @@ struct net_udp_context { struct net_linkaddr ll_addr; }; -int net_udp_dev_init(struct device *dev) +int net_udp_dev_init(const struct device *dev) { struct net_udp_context *net_udp_context = dev->data; @@ -69,7 +69,7 @@ int net_udp_dev_init(struct device *dev) return 0; } -static uint8_t *net_udp_get_mac(struct device *dev) +static uint8_t *net_udp_get_mac(const struct device *dev) { struct net_udp_context *context = dev->data; @@ -95,7 +95,7 @@ static void net_udp_iface_init(struct net_if *iface) static int send_status = -EINVAL; -static int tester_send(struct device *dev, struct net_pkt *pkt) +static int tester_send(const struct device *dev, struct net_pkt *pkt) { if (!pkt->frags) { DBG("No data to send!\n"); diff --git a/tests/net/vlan/src/main.c b/tests/net/vlan/src/main.c index 80c987ca50aa5f..269dcad9bea632 100644 --- a/tests/net/vlan/src/main.c +++ b/tests/net/vlan/src/main.c @@ -96,7 +96,7 @@ static struct eth_context eth_vlan_context; static void eth_vlan_iface_init(struct net_if *iface) { - struct device *dev = net_if_get_device(iface); + const struct device *dev = net_if_get_device(iface); struct eth_context *context = dev->data; net_if_set_link_addr(iface, context->mac_addr, @@ -106,7 +106,7 @@ static void eth_vlan_iface_init(struct net_if *iface) ethernet_init(iface); } -static int eth_tx(struct device *dev, struct net_pkt *pkt) +static int eth_tx(const struct device *dev, struct net_pkt *pkt) { struct eth_context *context = dev->data; @@ -139,7 +139,7 @@ static int eth_tx(struct device *dev, struct net_pkt *pkt) return 0; } -static enum ethernet_hw_caps eth_capabilities(struct device *dev) +static enum ethernet_hw_caps eth_capabilities(const struct device *dev) { return ETHERNET_HW_VLAN; } @@ -162,7 +162,7 @@ static void generate_mac(uint8_t *mac_addr) mac_addr[5] = sys_rand32_get(); } -static int eth_vlan_init(struct device *dev) +static int eth_vlan_init(const struct device *dev) { struct eth_context *context = dev->data; @@ -176,7 +176,7 @@ ETH_NET_DEVICE_INIT(eth_vlan_test, "eth_vlan_test", ð_vlan_context, NULL, CONFIG_ETH_INIT_PRIORITY, &api_funcs, NET_ETH_MTU); -static int eth_init(struct device *dev) +static int eth_init(const struct device *dev) { struct eth_context *context = dev->data; @@ -200,12 +200,12 @@ struct net_if_test { struct net_linkaddr ll_addr; }; -static int net_iface_dev_init(struct device *dev) +static int net_iface_dev_init(const struct device *dev) { return 0; } -static uint8_t *net_iface_get_mac(struct device *dev) +static uint8_t *net_iface_get_mac(const struct device *dev) { struct net_if_test *data = dev->data; @@ -233,7 +233,7 @@ static void net_iface_init(struct net_if *iface) NET_LINK_ETHERNET); } -static int sender_iface(struct device *dev, struct net_pkt *pkt) +static int sender_iface(const struct device *dev, struct net_pkt *pkt) { return 0; } diff --git a/tests/subsys/canbus/isotp/conformance/src/main.c b/tests/subsys/canbus/isotp/conformance/src/main.c index e7f77f789b85e4..2461197c8b4654 100644 --- a/tests/subsys/canbus/isotp/conformance/src/main.c +++ b/tests/subsys/canbus/isotp/conformance/src/main.c @@ -104,7 +104,7 @@ const struct isotp_msg_id tx_addr_ext = { .ext_addr = EXT_ADDR }; -struct device *can_dev; +const struct device *can_dev; struct isotp_recv_ctx recv_ctx; struct isotp_send_ctx send_ctx; uint8_t data_buf[128]; diff --git a/tests/subsys/canbus/isotp/implementation/src/main.c b/tests/subsys/canbus/isotp/implementation/src/main.c index 02881c6298c0d2..205ab97c5e0a38 100644 --- a/tests/subsys/canbus/isotp/implementation/src/main.c +++ b/tests/subsys/canbus/isotp/implementation/src/main.c @@ -31,7 +31,7 @@ * @} */ -struct device *can_dev; +const struct device *can_dev; const struct isotp_fc_opts fc_opts = { .bs = 8, @@ -61,7 +61,7 @@ void send_complette_cb(int error_nr, void *arg) zassert_equal(error_nr, ISOTP_N_OK, "Sending failed (%d)", error_nr); } -static void send_sf(struct device *can_dev) +static void send_sf(const struct device *can_dev) { int ret; @@ -110,7 +110,8 @@ void print_hex(const uint8_t *ptr, size_t len) } } -static void send_test_data(struct device *can_dev, const uint8_t *data, size_t len) +static void send_test_data(const struct device *can_dev, const uint8_t *data, + size_t len) { int ret; diff --git a/tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c b/tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c index 6c9c53ea679a87..ed7d69e2163f4f 100644 --- a/tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c +++ b/tests/subsys/fs/fat_fs_dual_drive/src/disk_access_test_drv.c @@ -88,7 +88,7 @@ static struct disk_info ram_disk = { .ops = &ram_disk_ops, }; -static int disk_ram_test_init(struct device *dev) +static int disk_ram_test_init(const struct device *dev) { ARG_UNUSED(dev); diff --git a/tests/subsys/fs/multi-fs/src/test_ram_backend.c b/tests/subsys/fs/multi-fs/src/test_ram_backend.c index 744f3701ab54de..8376da5b1b679e 100644 --- a/tests/subsys/fs/multi-fs/src/test_ram_backend.c +++ b/tests/subsys/fs/multi-fs/src/test_ram_backend.c @@ -14,17 +14,19 @@ static uint8_t rambuf[FLASH_AREA_SIZE(storage)]; -static int test_ram_flash_init(struct device *dev) +static int test_ram_flash_init(const struct device *dev) { return 0; } -static int test_flash_ram_write_protection(struct device *dev, bool enable) +static int test_flash_ram_write_protection(const struct device *dev, + bool enable) { return 0; } -static int test_flash_ram_erase(struct device *dev, off_t offset, size_t len) +static int test_flash_ram_erase(const struct device *dev, off_t offset, + size_t len) { struct flash_pages_info info; off_t end_offset = offset + len; @@ -42,7 +44,7 @@ static int test_flash_ram_erase(struct device *dev, off_t offset, size_t len) return 0; } -static int test_flash_ram_write(struct device *dev, off_t offset, +static int test_flash_ram_write(const struct device *dev, off_t offset, const void *data, size_t len) { zassert_true(offset >= 0, "invalid offset"); @@ -54,7 +56,8 @@ static int test_flash_ram_write(struct device *dev, off_t offset, return 0; } -static int test_flash_ram_read(struct device *dev, off_t offset, void *data, +static int test_flash_ram_read(const struct device *dev, off_t offset, + void *data, size_t len) { zassert_true(offset >= 0, "invalid offset"); @@ -66,9 +69,9 @@ static int test_flash_ram_read(struct device *dev, off_t offset, void *data, return 0; } -static void test_flash_ram_pages_layout(struct device *dev, - const struct flash_pages_layout **layout, - size_t *layout_size) +static void test_flash_ram_pages_layout(const struct device *dev, + const struct flash_pages_layout **layout, + size_t *layout_size) { /* Same as used in Mynewt native "flash" backend */ static struct flash_pages_layout dev_layout[] = { diff --git a/tests/subsys/fs/nvs/src/main.c b/tests/subsys/fs/nvs/src/main.c index 2365060d5994cd..ca16357b389195 100644 --- a/tests/subsys/fs/nvs/src/main.c +++ b/tests/subsys/fs/nvs/src/main.c @@ -607,7 +607,7 @@ void test_delete(void) void test_nvs_gc_corrupt_close_ate(void) { struct nvs_ate ate, close_ate; - struct device *flash_dev; + const struct device *flash_dev; uint32_t data; ssize_t len; int err; @@ -670,7 +670,7 @@ void test_nvs_gc_corrupt_close_ate(void) void test_nvs_gc_corrupt_ate(void) { struct nvs_ate corrupt_ate, close_ate; - struct device *flash_dev; + const struct device *flash_dev; int err; flash_dev = device_get_binding(DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL); diff --git a/tests/subsys/openthread/radio_stub.c b/tests/subsys/openthread/radio_stub.c index c61aab8c4c240c..591b081cd7fd36 100644 --- a/tests/subsys/openthread/radio_stub.c +++ b/tests/subsys/openthread/radio_stub.c @@ -19,7 +19,7 @@ #define CONFIG_NET_L2_OPENTHREAD 1 /* needed for stubbing device driver */ -struct device *device_get_binding_stub(const char *name); +const struct device *device_get_binding_stub(const char *name); #define device_get_binding device_get_binding_stub /* file itself */ diff --git a/tests/subsys/openthread/radio_test.c b/tests/subsys/openthread/radio_test.c index e4283b78fa03f4..08b361992ab761 100644 --- a/tests/subsys/openthread/radio_test.c +++ b/tests/subsys/openthread/radio_test.c @@ -40,20 +40,21 @@ otInstance *ot = (otInstance *)0xAAAA; otMessage *ip_msg = (otMessage *)0xBBBB; /* forward declarations */ -static int scan_mock(struct device *dev, uint16_t duration, +static int scan_mock(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb); -static enum ieee802154_hw_caps get_capabilities(struct device *dev); -static int cca_mock(struct device *dev); -static int set_channel_mock(struct device *dev, uint16_t channel); -static int filter_mock(struct device *dev, bool set, +static enum ieee802154_hw_caps get_capabilities(const struct device *dev); +static int cca_mock(const struct device *dev); +static int set_channel_mock(const struct device *dev, uint16_t channel); +static int filter_mock(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter); -static int set_txpower_mock(struct device *dev, int16_t dbm); -static int tx_mock(struct device *dev, enum ieee802154_tx_mode mode, +static int set_txpower_mock(const struct device *dev, int16_t dbm); +static int tx_mock(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag); -static int start_mock(struct device *dev); -static int stop_mock(struct device *dev); -static int configure_mock(struct device *dev, enum ieee802154_config_type type, +static int start_mock(const struct device *dev); +static int stop_mock(const struct device *dev); +static int configure_mock(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config); /* mocks */ @@ -75,7 +76,7 @@ static struct ieee802154_radio_api rapi = { static struct device radio = { .api = &rapi }; -static int scan_mock(struct device *dev, uint16_t duration, +static int scan_mock(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb) { zassert_equal(dev, &radio, "Device handle incorrect."); @@ -84,7 +85,7 @@ static int scan_mock(struct device *dev, uint16_t duration, return ztest_get_return_value(); } -static int rssi_scan_mock(struct device *dev, uint16_t duration, +static int rssi_scan_mock(const struct device *dev, uint16_t duration, energy_scan_done_cb_t done_cb) { zassert_equal(dev, &radio, "Device handle incorrect."); @@ -97,7 +98,7 @@ static int rssi_scan_mock(struct device *dev, uint16_t duration, return 0; } -static int set_channel_mock(struct device *dev, uint16_t channel) +static int set_channel_mock(const struct device *dev, uint16_t channel) { zassert_equal(dev, &radio, "Device handle incorrect."); ztest_check_expected_value(channel); @@ -143,7 +144,7 @@ void otPlatRadioTxDone(otInstance *aInstance, otRadioFrame *aFrame, ztest_check_expected_value(aError); } -static enum ieee802154_hw_caps get_capabilities(struct device *dev) +static enum ieee802154_hw_caps get_capabilities(const struct device *dev) { zassert_equal(dev, &radio, "Device handle incorrect."); @@ -152,14 +153,15 @@ static enum ieee802154_hw_caps get_capabilities(struct device *dev) IEEE802154_HW_ENERGY_SCAN | IEEE802154_HW_SLEEP_TO_TX; } -static enum ieee802154_hw_caps get_capabilities_caps_mock(struct device *dev) +static enum ieee802154_hw_caps get_capabilities_caps_mock(const struct device *dev) { zassert_equal(dev, &radio, "Device handle incorrect."); return ztest_get_return_value(); } -static int configure_mock(struct device *dev, enum ieee802154_config_type type, +static int configure_mock(const struct device *dev, + enum ieee802154_config_type type, const struct ieee802154_config *config) { zassert_equal(dev, &radio, "Device handle incorrect."); @@ -170,7 +172,7 @@ static int configure_mock(struct device *dev, enum ieee802154_config_type type, return 0; } -static int configure_match_mock(struct device *dev, +static int configure_match_mock(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config) { @@ -197,7 +199,7 @@ static int configure_match_mock(struct device *dev, return 0; } -static int configure_promiscuous_mock(struct device *dev, +static int configure_promiscuous_mock(const struct device *dev, enum ieee802154_config_type type, const struct ieee802154_config *config) { @@ -209,14 +211,14 @@ static int configure_promiscuous_mock(struct device *dev, return 0; } -static int cca_mock(struct device *dev) +static int cca_mock(const struct device *dev) { /* not using assert to verify function called */ ztest_check_expected_value(dev); return 0; } -static int filter_mock(struct device *dev, bool set, +static int filter_mock(const struct device *dev, bool set, enum ieee802154_filter_type type, const struct ieee802154_filter *filter) { @@ -241,7 +243,7 @@ static int filter_mock(struct device *dev, bool set, return 0; } -static int set_txpower_mock(struct device *dev, int16_t dbm) +static int set_txpower_mock(const struct device *dev, int16_t dbm) { zassert_equal(dev, &radio, "Device handle incorrect."); ztest_check_expected_value(dbm); @@ -249,7 +251,7 @@ static int set_txpower_mock(struct device *dev, int16_t dbm) return 0; } -static int tx_mock(struct device *dev, enum ieee802154_tx_mode mode, +static int tx_mock(const struct device *dev, enum ieee802154_tx_mode mode, struct net_pkt *pkt, struct net_buf *frag) { zassert_equal(dev, &radio, "Device handle incorrect."); @@ -258,19 +260,19 @@ static int tx_mock(struct device *dev, enum ieee802154_tx_mode mode, return 0; } -static int start_mock(struct device *dev) +static int start_mock(const struct device *dev) { ztest_check_expected_value(dev); return 0; } -static int stop_mock(struct device *dev) +static int stop_mock(const struct device *dev) { ztest_check_expected_value(dev); return 0; } -struct device *device_get_binding_stub(const char *name) +const struct device *device_get_binding_stub(const char *name) { return &radio; } diff --git a/tests/subsys/power/power_mgmt/src/dummy_driver.c b/tests/subsys/power/power_mgmt/src/dummy_driver.c index fc0c91ecc337a2..c3350b6c6e95ad 100644 --- a/tests/subsys/power/power_mgmt/src/dummy_driver.c +++ b/tests/subsys/power/power_mgmt/src/dummy_driver.c @@ -10,34 +10,35 @@ static uint32_t device_power_state; -static int dummy_open(struct device *dev) +static int dummy_open(const struct device *dev) { return device_pm_get_sync(dev); } -static int dummy_close(struct device *dev) +static int dummy_close(const struct device *dev) { return device_pm_put_sync(dev); } -static uint32_t dummy_get_power_state(struct device *dev) +static uint32_t dummy_get_power_state(const struct device *dev) { return device_power_state; } -static int dummy_suspend(struct device *dev) +static int dummy_suspend(const struct device *dev) { device_power_state = DEVICE_PM_SUSPEND_STATE; return 0; } -static int dummy_resume_from_suspend(struct device *dev) +static int dummy_resume_from_suspend(const struct device *dev) { device_power_state = DEVICE_PM_ACTIVE_STATE; return 0; } -static int dummy_device_pm_ctrl(struct device *dev, uint32_t ctrl_command, +static int dummy_device_pm_ctrl(const struct device *dev, + uint32_t ctrl_command, void *context, device_pm_cb cb, void *arg) { int ret = 0; @@ -70,7 +71,7 @@ static const struct dummy_driver_api funcs = { .close = dummy_close, }; -int dummy_init(struct device *dev) +int dummy_init(const struct device *dev) { device_pm_enable(dev); return 0; diff --git a/tests/subsys/power/power_mgmt/src/dummy_driver.h b/tests/subsys/power/power_mgmt/src/dummy_driver.h index b0898fa3b9156d..f89f302109f25f 100644 --- a/tests/subsys/power/power_mgmt/src/dummy_driver.h +++ b/tests/subsys/power/power_mgmt/src/dummy_driver.h @@ -8,9 +8,9 @@ #include #define DUMMY_DRIVER_NAME "dummy_driver" -typedef int (*dummy_api_open_t)(struct device *dev); +typedef int (*dummy_api_open_t)(const struct device *dev); -typedef int (*dummy_api_close_t)(struct device *dev); +typedef int (*dummy_api_close_t)(const struct device *dev); struct dummy_driver_api { dummy_api_open_t open; diff --git a/tests/subsys/power/power_mgmt/src/main.c b/tests/subsys/power/power_mgmt/src/main.c index bdbfb9fea88283..53516b267c36ab 100644 --- a/tests/subsys/power/power_mgmt/src/main.c +++ b/tests/subsys/power/power_mgmt/src/main.c @@ -24,7 +24,7 @@ static bool set_sys_power; static bool leave_idle; static bool idle_entered; -static struct device *dev; +static const struct device *dev; static struct dummy_driver_api *api; /* * Weak power hook functions. Used on systems that have not implemented diff --git a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c index 0db08b0a59f1d0..24ddcc2ad3b64c 100644 --- a/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c +++ b/tests/subsys/settings/fcb_init/src/settings_test_fcb_init.c @@ -89,7 +89,7 @@ void test_prepare_storage(void) */ int err; const struct flash_area *fa; - struct device *dev; + const struct device *dev; uint8_t new_val[FLASH_WRITE_BLOCK_SIZE]; if (prepared_mark[0] == ERASED_VAL) { diff --git a/tests/subsys/shell/shell_flash/src/shell_flash_test.c b/tests/subsys/shell/shell_flash/src/shell_flash_test.c index 3a69cdbc280034..f54ae9e32ee15d 100644 --- a/tests/subsys/shell/shell_flash/src/shell_flash_test.c +++ b/tests/subsys/shell/shell_flash/src/shell_flash_test.c @@ -35,7 +35,7 @@ static void test_flash_read(void) "00000020: 61 62 63 |abc |", }; const struct shell *shell = shell_backend_dummy_get_ptr(); - static struct device *flash_dev; + static const struct device *flash_dev; const char *buf; const int test_base = FLASH_SIMULATOR_BASE_OFFSET; const int test_size = 0x24; /* 32-alignment required */ diff --git a/tests/subsys/storage/flash_map/src/main.c b/tests/subsys/storage/flash_map/src/main.c index ba823b4de8fd0f..f3a5526c7bbabf 100644 --- a/tests/subsys/storage/flash_map/src/main.c +++ b/tests/subsys/storage/flash_map/src/main.c @@ -24,7 +24,7 @@ void test_flash_area_get_sectors(void) off_t off; uint8_t wd[256]; uint8_t rd[256]; - struct device *flash_dev; + const struct device *flash_dev; rc = flash_area_open(FLASH_AREA_ID(image_1), &fa); zassert_true(rc == 0, "flash_area_open() fail"); diff --git a/tests/subsys/storage/stream/stream_flash/src/main.c b/tests/subsys/storage/stream/stream_flash/src/main.c index 05f5b063211100..c91e5f329b4828 100644 --- a/tests/subsys/storage/stream/stream_flash/src/main.c +++ b/tests/subsys/storage/stream/stream_flash/src/main.c @@ -24,7 +24,7 @@ #define FLASH_BASE (64*1024) #define FLASH_AVAILABLE (FLASH_SIZE-FLASH_BASE) -static struct device *fdev; +static const struct device *fdev; static const struct flash_driver_api *api; static const struct flash_pages_layout *layout; static size_t layout_size;