Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: device: convert device struct instances to const #25208

Closed
wants to merge 12 commits into from

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented May 11, 2020

This PR has an alternative prototype of the part of #24873 that allows struct device instances to be put into flash. The intent of this draft PR is to examine the impact of declaring device structures with a const qualifier.

A simple representation of generic mutable driver state ("context") was selected and named to enable evaluation of the impact of making device structures immutable. The final approach to associating context with drivers will be determined in other contexts including #24873.

Initial results reveal the significance of the change:

  • Every device driver init function and sys_init function must be updated to take const struct device* where struct device* is currently passed. This can be done relatively easily using a Coccinelle script for code, and a sed script for documentation and macros where Coccinelle can't detect the pattern.
  • The passing of const device * pointers to functions with void * parameters is a much bigger issue; at this time the situations can only be detected by build failures. Many are currently being masked in this draft by a commit that removes the const qualifier from the device pointer produced by DEVICE_GET(). Device pointers are sometimes passed:
    • as parameters to thread handlers (any of the three void * arguments)
    • to ISR handlers (generally unary functions, but not always)
    • as context to log_output_ctx_set()
  • Some changes are also required in external modules, e.g. the SYS_INIT() used in the Segger RTT capability.

@pabigot pabigot added the RFC Request For Comments: want input from the community label May 11, 2020
@pabigot pabigot changed the title device: convert device struct instances to const RFC: device: convert device struct instances to const May 11, 2020
@zephyrbot
Copy link
Collaborator

zephyrbot commented May 11, 2020

Some checks failed. Please fix and resubmit.

checkpatch issues

-:292: WARNING:LONG_LINE: line over 80 characters
#292: FILE: boards/arm/actinius_icarus/board.c:17:
+	const struct device *port = device_get_binding(DT_LABEL(DT_NODELABEL(gpio0)));

-:317: WARNING:LONG_LINE: line over 80 characters
#317: FILE: boards/arm/adafruit_feather_m0_basic_proto/pinmux.c:13:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:320: WARNING:LONG_LINE: line over 80 characters
#320: FILE: boards/arm/adafruit_feather_m0_basic_proto/pinmux.c:15:
+	const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

-:349: WARNING:LONG_LINE: line over 80 characters
#349: FILE: boards/arm/adafruit_trinket_m0/pinmux.c:13:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:366: WARNING:LONG_LINE: line over 80 characters
#366: FILE: boards/arm/arduino_zero/pinmux.c:13:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:367: WARNING:LONG_LINE: line over 80 characters
#367: FILE: boards/arm/arduino_zero/pinmux.c:14:
+	const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

-:384: WARNING:LONG_LINE: line over 80 characters
#384: FILE: boards/arm/atsamd20_xpro/pinmux.c:13:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:385: WARNING:LONG_LINE: line over 80 characters
#385: FILE: boards/arm/atsamd20_xpro/pinmux.c:14:
+	const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

-:402: WARNING:LONG_LINE: line over 80 characters
#402: FILE: boards/arm/atsamd21_xpro/pinmux.c:13:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:403: WARNING:LONG_LINE: line over 80 characters
#403: FILE: boards/arm/atsamd21_xpro/pinmux.c:14:
+	const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

-:443: WARNING:LONG_LINE: line over 80 characters
#443: FILE: boards/arm/atsamr21_xpro/pinmux.c:14:
+	const struct device *muxa = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_a)));

-:444: WARNING:LONG_LINE: line over 80 characters
#444: FILE: boards/arm/atsamr21_xpro/pinmux.c:15:
+	const struct device *muxb = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_b)));

-:445: WARNING:LONG_LINE: line over 80 characters
#445: FILE: boards/arm/atsamr21_xpro/pinmux.c:16:
+	const struct device *muxc = device_get_binding(DT_LABEL(DT_NODELABEL(pinmux_c)));

-:2728: WARNING:LONG_LINE: line over 80 characters
#2728: FILE: boards/riscv/hifive1/pinmux.c:15:
+	const struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME);

-:2746: WARNING:LONG_LINE: line over 80 characters
#2746: FILE: boards/riscv/hifive1_revb/pinmux.c:15:
+	const struct device *p = device_get_binding(CONFIG_PINMUX_SIFIVE_0_NAME);

-:3125: WARNING:LONG_LINE: line over 80 characters
#3125: FILE: drivers/adc/adc_handlers.c:12:
+					   const struct adc_channel_cfg *user_channel_cfg)

-:3164: WARNING:LONG_LINE: line over 80 characters
#3164: FILE: drivers/adc/adc_handlers.c:73:
+					const struct adc_sequence *user_sequence,

-:3649: WARNING:LONG_LINE: line over 80 characters
#3649: FILE: drivers/adc/adc_mcux_adc12.c:263:
+	static void mcux_adc12_config_func_##n(const struct device *dev);	\

-:3658: WARNING:LONG_LINE: line over 80 characters
#3658: FILE: drivers/adc/adc_mcux_adc12.c:293:
+	static void mcux_adc12_config_func_##n(const struct device *dev)	\

-:3749: WARNING:LONG_LINE: line over 80 characters
#3749: FILE: drivers/adc/adc_mcux_adc16.c:280:
+	static void mcux_adc16_config_func_##n(const struct device *dev);	\

-:3758: WARNING:LONG_LINE: line over 80 characters
#3758: FILE: drivers/adc/adc_mcux_adc16.c:299:
+	static void mcux_adc16_config_func_##n(const struct device *dev)	\

-:3979: WARNING:LONG_LINE: line over 80 characters
#3979: FILE: drivers/adc/adc_sam0.c:591:
+	static void adc_sam0_config_##n(const struct device *dev);		\

-:3988: WARNING:LONG_LINE: line over 80 characters
#3988: FILE: drivers/adc/adc_sam0.c:611:
+	static void adc_sam0_config_##n(const struct device *dev)		\

-:4079: WARNING:LONG_LINE: line over 80 characters
#4079: FILE: drivers/adc/adc_sam_afec.c:354:
+	static void adc##n##_sam_cfg_func(const struct device *dev);		\

-:4088: WARNING:LONG_LINE: line over 80 characters
#4088: FILE: drivers/adc/adc_sam_afec.c:375:
+	static void adc##n##_sam_cfg_func(const struct device *dev)		\

-:5862: WARNING:LONG_LINE: line over 80 characters
#5862: FILE: drivers/clock_control/beetle_clock_control.c:131:
+						clock_control_subsys_t sub_system,

-:6190: WARNING:LONG_LINE: line over 80 characters
#6190: FILE: drivers/clock_control/clock_stm32_ll_h7.c:155:
+					       clock_control_subsys_t sub_system,

-:6234: WARNING:LONG_LINE: line over 80 characters
#6234: FILE: drivers/clock_control/clock_stm32_ll_mp1.c:118:
+					       clock_control_subsys_t sub_system,

-:6346: WARNING:LONG_LINE: line over 80 characters
#6346: FILE: drivers/clock_control/nrf_power_clock.c:104:
+						       enum clock_control_nrf_type type)

-:7212: WARNING:LONG_LINE: line over 80 characters
#7212: FILE: drivers/counter/counter_handlers.c:78:
+						   const struct counter_alarm_cfg *alarm_cfg)

-:7224: WARNING:LONG_LINE: line over 80 characters
#7224: FILE: drivers/counter/counter_handlers.c:88:
+						(const struct counter_alarm_cfg *)&cfg_copy);

-:7274: WARNING:LONG_LINE: line over 80 characters
#7274: FILE: drivers/counter/counter_handlers.c:132:
+static inline u32_t z_vrfy_counter_get_max_relative_alarm(const struct device *dev)

-:7278: WARNING:LONG_LINE: line over 80 characters
#7278: FILE: drivers/counter/counter_handlers.c:135:
+	return z_impl_counter_get_max_relative_alarm((const struct device *)dev);

-:7313: WARNING:LONG_LINE: line over 80 characters
#7313: FILE: drivers/counter/counter_imx_epit.c:26:
+static inline const struct imx_epit_config *get_epit_config(const struct device *dev)

-:7401: WARNING:LONG_LINE: line over 80 characters
#7401: FILE: drivers/counter/counter_imx_epit.c:154:
+static int imx_epit_config_func_##idx(const struct device *dev);		       \

-:7743: WARNING:LONG_LINE: line over 80 characters
#7743: FILE: drivers/counter/counter_mcux_gpt.c:218:
+	static int mcux_gpt_## n ##_init(const struct device *dev);		\

-:7752: WARNING:LONG_LINE: line over 80 characters
#7752: FILE: drivers/counter/counter_mcux_gpt.c:228:
+	static int mcux_gpt_## n ##_init(const struct device *dev)		\

-:8016: WARNING:LONG_LINE: line over 80 characters
#8016: FILE: drivers/counter/counter_nrfx_rtc.c:75:
+							const struct device *dev)

-:8242: WARNING:LONG_LINE: line over 80 characters
#8242: FILE: drivers/counter/counter_nrfx_rtc.c:675:
+	static int counter_##idx##_init(const struct device *dev)		       \

-:8262: WARNING:LONG_LINE: line over 80 characters
#8262: FILE: drivers/counter/counter_nrfx_timer.c:59:
+							const struct device *dev)

-:8419: WARNING:LONG_LINE: line over 80 characters
#8419: FILE: drivers/counter/counter_nrfx_timer.c:401:
+	static int counter_##idx##_init(const struct device *dev)		       \

-:8506: WARNING:LONG_LINE: line over 80 characters
#8506: FILE: drivers/counter/counter_sam0_tc32.c:240:
+					   const struct counter_top_cfg *top_cfg)

-:8559: WARNING:LONG_LINE: line over 80 characters
#8559: FILE: drivers/counter/counter_sam0_tc32.c:424:
+	static void counter_sam0_tc32_config_##n(const struct device *dev);	\

-:8568: WARNING:LONG_LINE: line over 80 characters
#8568: FILE: drivers/counter/counter_sam0_tc32.c:453:
+	static void counter_sam0_tc32_config_##n(const struct device *dev)	\

-:8851: WARNING:LONG_LINE: line over 80 characters
#8851: FILE: drivers/counter/maxim_ds3231.c:1158:
+		const struct device *gpio = device_get_binding(cfg->isw_gpios.ctrl);

-:9020: WARNING:LONG_LINE: line over 80 characters
#9020: FILE: drivers/counter/timer_dtmr_cmsdk_apb.c:174:
+	static void dtimer_cmsdk_apb_config_##inst(const struct device *dev);	\

-:9029: WARNING:LONG_LINE: line over 80 characters
#9029: FILE: drivers/counter/timer_dtmr_cmsdk_apb.c:210:
+	static void dtimer_cmsdk_apb_config_##inst(const struct device *dev)	\

-:9131: WARNING:LONG_LINE: line over 80 characters
#9131: FILE: drivers/counter/timer_tmr_cmsdk_apb.c:166:
+	static void timer_cmsdk_apb_config_##inst(const struct device *dev);	\

-:9140: WARNING:LONG_LINE: line over 80 characters
#9140: FILE: drivers/counter/timer_tmr_cmsdk_apb.c:197:
+	static void timer_cmsdk_apb_config_##inst(const struct device *dev)	\

-:9515: WARNING:LONG_LINE: line over 80 characters
#9515: FILE: drivers/dac/dac_handlers.c:12:
+					   const struct dac_channel_cfg *user_channel_cfg)

-:10529: WARNING:LONG_LINE: line over 80 characters
#10529: FILE: drivers/dma/dma_stm32.c:631:
+static void dma_stm32_config_irq_##index(const struct device *dev);		\

-:10645: WARNING:LONG_LINE_COMMENT: line over 80 characters
#10645: FILE: drivers/dma/dmamux_stm32.h:12:
+	const struct device *dev_dma; /* pointer to the associated dma instance */

-:12106: WARNING:LONG_LINE: line over 80 characters
#12106: FILE: drivers/ethernet/eth_enc28j60.c:682:
+static enum ethernet_hw_caps eth_enc28j60_get_capabilities(const struct device *dev)

-:12289: WARNING:LONG_LINE: line over 80 characters
#12289: FILE: drivers/ethernet/eth_enc424j600.c:498:
+static enum ethernet_hw_caps enc424j600_get_capabilities(const struct device *dev)

-:12443: WARNING:LONG_LINE: line over 80 characters
#12443: FILE: drivers/ethernet/eth_gecko.c:620:
+static enum ethernet_hw_caps eth_gecko_get_capabilities(const struct device *dev)

-:12768: WARNING:LONG_LINE: line over 80 characters
#12768: FILE: drivers/ethernet/eth_native_posix.c:459:
+enum ethernet_hw_caps eth_posix_native_get_capabilities(const struct device *dev)

-:12955: WARNING:LONG_LINE: line over 80 characters
#12955: FILE: drivers/ethernet/eth_sam_gmac.c:1978:
+static enum ethernet_hw_caps eth_sam_gmac_get_capabilities(const struct device *dev)

-:13090: WARNING:LONG_LINE: line over 80 characters
#13090: FILE: drivers/ethernet/eth_smsc911x.c:414:
+static enum ethernet_hw_caps eth_smsc911x_get_capabilities(const struct device *dev)

-:13356: WARNING:LONG_LINE: line over 80 characters
#13356: FILE: drivers/ethernet/eth_stm32_hal.c:495:
+static enum ethernet_hw_caps eth_stm32_hal_get_capabilities(const struct device *dev)

-:13512: WARNING:LONG_LINE: line over 80 characters
#13512: FILE: drivers/flash/flash_handlers.c:50:
+						     struct flash_pages_info *info)

-:13520: WARNING:LONG_LINE: line over 80 characters
#13520: FILE: drivers/flash/flash_handlers.c:56:
+						  (struct flash_pages_info *)info);

-:13529: WARNING:LONG_LINE: line over 80 characters
#13529: FILE: drivers/flash/flash_handlers.c:62:
+						    struct flash_pages_info *info)

-:13537: WARNING:LONG_LINE: line over 80 characters
#13537: FILE: drivers/flash/flash_handlers.c:68:
+						 (struct flash_pages_info *)info);

-:15076: WARNING:LONG_LINE: line over 80 characters
#15076: FILE: drivers/flash/spi_flash_at45.c:84:
+static const struct spi_flash_at45_config *get_dev_config(const struct device *dev)

-:15767: WARNING:LONG_LINE: line over 80 characters
#15767: FILE: drivers/gpio/gpio_cc32xx.c:285:
+	static int gpio_cc32xx_a##n##_init(const struct device *dev)		     \

-:15933: WARNING:LONG_LINE: line over 80 characters
#15933: FILE: drivers/gpio/gpio_cmsdk_ahb.c:279:
+	static void gpio_cmsdk_port_##n##_config_func(const struct device *dev);	\

-:15942: WARNING:LONG_LINE: line over 80 characters
#15942: FILE: drivers/gpio/gpio_cmsdk_ahb.c:305:
+	static void gpio_cmsdk_port_##n##_config_func(const struct device *dev)	\

-:16930: WARNING:LONG_LINE: line over 80 characters
#16930: FILE: drivers/gpio/gpio_imx.c:242:
+	static int imx_gpio_##n##_init(const struct device *port);		\

-:16939: WARNING:LONG_LINE: line over 80 characters
#16939: FILE: drivers/gpio/gpio_imx.c:262:
+	static int imx_gpio_##n##_init(const struct device *port)		\

-:17709: WARNING:LONG_LINE: line over 80 characters
#17709: FILE: drivers/gpio/gpio_mcux.c:294:
+	static int gpio_mcux_port## n ## _init(const struct device *dev);	\

-:17845: WARNING:LONG_LINE: line over 80 characters
#17845: FILE: drivers/gpio/gpio_mcux_igpio.c:242:
+	static int mcux_igpio_##n##_init(const struct device *dev);		\

-:17854: WARNING:LONG_LINE: line over 80 characters
#17854: FILE: drivers/gpio/gpio_mcux_igpio.c:261:
+	static int mcux_igpio_##n##_init(const struct device *dev)		\

-:18130: WARNING:LONG_LINE: line over 80 characters
#18130: FILE: drivers/gpio/gpio_nrfx.c:45:
+static inline const struct gpio_nrfx_cfg *get_port_cfg(const struct device *port)

-:18628: WARNING:LONG_LINE: line over 80 characters
#18628: FILE: drivers/gpio/gpio_rv32m1.c:334:
+	static int gpio_rv32m1_##n##_init(const struct device *dev);		\

-:18637: WARNING:LONG_LINE: line over 80 characters
#18637: FILE: drivers/gpio/gpio_rv32m1.c:359:
+	static int gpio_rv32m1_##n##_init(const struct device *dev)		\

-:18788: WARNING:LONG_LINE: line over 80 characters
#18788: FILE: drivers/gpio/gpio_sam.c:335:
+	static void port_##n##_sam_config_func(const struct device *dev);	\

-:18797: WARNING:LONG_LINE: line over 80 characters
#18797: FILE: drivers/gpio/gpio_sam.c:354:
+	static void port_##n##_sam_config_func(const struct device *dev)	\

-:19234: WARNING:LONG_LINE: line over 80 characters
#19234: FILE: drivers/gpio/gpio_stellaris.c:264:
+	static void port_## n ##_stellaris_config_func(const struct device *dev);		\

-:19243: WARNING:LONG_LINE: line over 80 characters
#19243: FILE: drivers/gpio/gpio_stellaris.c:285:
+	static void port_## n ##_stellaris_config_func(const struct device *dev)		\

-:19597: WARNING:LONG_LINE: line over 80 characters
#19597: FILE: drivers/i2c/i2c_cc13xx_cc26xx.c:47:
+static inline struct i2c_cc13xx_cc26xx_data *get_dev_data(const struct device *dev)

-:20230: WARNING:LONG_LINE: line over 80 characters
#20230: FILE: drivers/i2c/i2c_imx.c:381:
+	static void i2c_imx_config_func_##n(const struct device *dev)		\

-:20296: WARNING:LONG_LINE: line over 80 characters
#20296: FILE: drivers/i2c/i2c_ll_stm32.c:179:
+	const struct device *clock = device_get_binding(STM32_CLOCK_CONTROL_NAME);

-:20878: WARNING:LONG_LINE: line over 80 characters
#20878: FILE: drivers/i2c/i2c_mcux.c:208:
+	static void i2c_mcux_config_func_ ## n(const struct device *dev);	\

-:20887: WARNING:LONG_LINE: line over 80 characters
#20887: FILE: drivers/i2c/i2c_mcux.c:226:
+	static void i2c_mcux_config_func_ ## n(const struct device *dev)	\

-:20968: WARNING:LONG_LINE: line over 80 characters
#20968: FILE: drivers/i2c/i2c_mcux_flexcomm.c:206:
+	static void mcux_flexcomm_config_func_##id(const struct device *dev);	\

-:20977: WARNING:LONG_LINE: line over 80 characters
#20977: FILE: drivers/i2c/i2c_mcux_flexcomm.c:221:
+	static void mcux_flexcomm_config_func_##id(const struct device *dev)	\

-:21058: WARNING:LONG_LINE: line over 80 characters
#21058: FILE: drivers/i2c/i2c_mcux_lpi2c.c:226:
+	static void mcux_lpi2c_config_func_##n(const struct device *dev);	\

-:21067: WARNING:LONG_LINE: line over 80 characters
#21067: FILE: drivers/i2c/i2c_mcux_lpi2c.c:248:
+	static void mcux_lpi2c_config_func_##n(const struct device *dev)	\

-:21192: WARNING:LONG_LINE: line over 80 characters
#21192: FILE: drivers/i2c/i2c_nrfx_twi.c:254:
+	static int twi_##idx##_init(const struct device *dev)			       \

-:21356: WARNING:LONG_LINE: line over 80 characters
#21356: FILE: drivers/i2c/i2c_rv32m1_lpi2c.c:266:
+	static void rv32m1_lpi2c_irq_config_func_##id(const struct device *dev);     \

-:21365: WARNING:LONG_LINE: line over 80 characters
#21365: FILE: drivers/i2c/i2c_rv32m1_lpi2c.c:291:
+	static void rv32m1_lpi2c_irq_config_func_##id(const struct device *dev)      \

-:21486: WARNING:LONG_LINE: line over 80 characters
#21486: FILE: drivers/i2c/i2c_sam0.c:756:
+static void i2c_sam0_irq_config_##n(const struct device *dev)			\

-:21495: WARNING:LONG_LINE: line over 80 characters
#21495: FILE: drivers/i2c/i2c_sam0.c:765:
+static void i2c_sam0_irq_config_##n(const struct device *dev)			\

-:22312: WARNING:LONG_LINE: line over 80 characters
#22312: FILE: drivers/i2s/i2s_ll_stm32.c:889:
+static void i2s_stm32_irq_config_func_##index(const struct device *dev);	\

-:22344: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct stream *' should also have an identifier name
#22344: FILE: drivers/i2s/i2s_ll_stm32.h:95:
+	int (*stream_start)(struct stream *, const struct device *dev);

-:22345: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct stream *' should also have an identifier name
#22345: FILE: drivers/i2s/i2s_ll_stm32.h:96:
+	void (*stream_disable)(struct stream *, const struct device *dev);

-:22368: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct stream *' should also have an identifier name
#22368: FILE: drivers/i2s/i2s_sam_ssc.c:84:
+	int (*stream_start)(struct stream *, Ssc *const,

-:22368: WARNING:FUNCTION_ARGUMENTS: function definition argument 'Ssc *const' should also have an identifier name
#22368: FILE: drivers/i2s/i2s_sam_ssc.c:84:
+	int (*stream_start)(struct stream *, Ssc *const,

-:22368: WARNING:FUNCTION_ARGUMENTS: function definition argument 'const struct device *' should also have an identifier name
#22368: FILE: drivers/i2s/i2s_sam_ssc.c:84:
+	int (*stream_start)(struct stream *, Ssc *const,

-:22370: WARNING:FUNCTION_ARGUMENTS: function definition argument 'struct stream *' should also have an identifier name
#22370: FILE: drivers/i2s/i2s_sam_ssc.c:86:
+	void (*stream_disable)(struct stream *, Ssc *const,

-:22370: WARNING:FUNCTION_ARGUMENTS: function definition argument 'Ssc *const' should also have an identifier name
#22370: FILE: drivers/i2s/i2s_sam_ssc.c:86:
+	void (*stream_disable)(struct stream *, Ssc *const,

-:22370: WARNING:FUNCTION_ARGUMENTS: function definition argument 'const struct device *' should also have an identifier name
#22370: FILE: drivers/i2s/i2s_sam_ssc.c:86:
+	void (*stream_disable)(struct stream *, Ssc *const,

-:22673: WARNING:LONG_LINE: line over 80 characters
#22673: FILE: drivers/ieee802154/ieee802154_cc1200.c:737:
+static struct cc1200_gpio_configuration *configure_gpios(const struct device *dev)

-:22677: WARNING:LONG_LINE: line over 80 characters
#22677: FILE: drivers/ieee802154/ieee802154_cc1200.c:740:
+	const struct device *gpio = device_get_binding(DT_INST_GPIO_LABEL(0, int_gpios));

-:23047: WARNING:LONG_LINE: line over 80 characters
#23047: FILE: drivers/ieee802154/ieee802154_cc2520.c:974:
+static struct cc2520_gpio_configuration *configure_gpios(const struct device *dev)

-:24533: WARNING:LONG_LINE: line over 80 characters
#24533: FILE: drivers/interrupt_controller/intc_cavs.c:128:
+	static int cavs_ictl_##n##_initialize(const struct device *port)	\

-:24539: WARNING:LONG_LINE: line over 80 characters
#24539: FILE: drivers/interrupt_controller/intc_cavs.c:133:
+	static void cavs_config_##n##_irq(const struct device *port);		\

-:24548: WARNING:LONG_LINE: line over 80 characters
#24548: FILE: drivers/interrupt_controller/intc_cavs.c:151:
+	static void cavs_config_##n##_irq(const struct device *port)		\

-:25527: WARNING:LONG_LINE: line over 80 characters
#25527: FILE: drivers/ipm/ipm_nrfx_ipc.c:165:
+static int vipm_nrf_##_idx##_send(const struct device *dev, int wait,		\

-:25536: WARNING:LONG_LINE: line over 80 characters
#25536: FILE: drivers/ipm/ipm_nrfx_ipc.c:191:
+static void vipm_nrf_##_idx##_register_callback(const struct device *dev,	\

-:26182: WARNING:LONG_LINE: line over 80 characters
#26182: FILE: drivers/led/lp5562.c:478:
+					       enum lp5562_engine_exec_states state)

-:26574: WARNING:LONG_LINE: line over 80 characters
#26574: FILE: drivers/led_strip/ws2812_spi.c:212:
+	static int ws2812_spi_##idx##_init(const struct device *dev)		\

-:26729: WARNING:LONG_LINE: line over 80 characters
#26729: FILE: drivers/modem/gsm_ppp.c:246:
+	const struct device *ppp_dev = device_get_binding(CONFIG_NET_PPP_DRV_NAME);

-:26756: WARNING:LONG_LINE: line over 80 characters
#26756: FILE: drivers/modem/gsm_ppp.c:427:
+	const struct device *uart = device_get_binding(CONFIG_MODEM_GSM_UART_NAME);

-:28328: WARNING:LONG_LINE: line over 80 characters
#28328: FILE: drivers/pwm/pwm_nrfx.c:345:
+	static int pwm_##idx##_nrfx_pm_control(const struct device *dev,	\

-:29203: WARNING:LONG_LINE: line over 80 characters
#29203: FILE: drivers/sensor/adxl372/adxl372.c:165:
+					  const struct adxl372_activity_threshold *act)

-:29216: WARNING:LONG_LINE: line over 80 characters
#29216: FILE: drivers/sensor/adxl372/adxl372.c:197:
+					      const struct adxl372_activity_threshold *act)

-:30376: WARNING:LONG_LINE: line over 80 characters
#30376: FILE: drivers/sensor/bme280/bme280.c:128:
+static inline const union bme280_bus_config *to_bus_config(const struct device *dev)

-:39563: WARNING:LONG_LINE: line over 80 characters
#39563: FILE: drivers/serial/uart_cc13xx_cc26xx.c:43:
+static inline struct uart_cc13xx_cc26xx_data *get_dev_data(const struct device *dev)

-:39569: WARNING:LONG_LINE: line over 80 characters
#39569: FILE: drivers/serial/uart_cc13xx_cc26xx.c:48:
+static inline const struct uart_device_config *get_dev_conf(const struct device *dev)

-:39770: WARNING:LONG_LINE: line over 80 characters
#39770: FILE: drivers/serial/uart_cc13xx_cc26xx.c:615:
+	static int uart_cc13xx_cc26xx_init_##n(const struct device *dev)	    \

-:40473: WARNING:LONG_LINE: line over 80 characters
#40473: FILE: drivers/serial/uart_esp32.c:464:
+	static void uart_esp32_irq_config_func_##idx(const struct device *dev)     \

-:41110: WARNING:LONG_LINE: line over 80 characters
#41110: FILE: drivers/serial/uart_imx.c:295:
+	static void irq_config_func_##n(const struct device *dev)		\

-:41682: WARNING:LONG_LINE: line over 80 characters
#41682: FILE: drivers/serial/uart_mcux_flexcomm.c:293:
+	static void mcux_flexcomm_config_func_##n(const struct device *dev)	\

-:41888: WARNING:LONG_LINE: line over 80 characters
#41888: FILE: drivers/serial/uart_mcux_lpsci.c:289:
+	static void mcux_lpsci_config_func_##n(const struct device *dev)	\

-:42099: WARNING:LONG_LINE: line over 80 characters
#42099: FILE: drivers/serial/uart_mcux_lpuart.c:299:
+	static void mcux_lpuart_config_func_##n(const struct device *dev)	\

-:42542: WARNING:LONG_LINE: line over 80 characters
#42542: FILE: drivers/serial/uart_nrfx_uart.c:64:
+static inline const struct uart_nrfx_config *get_dev_config(const struct device *dev)

-:42848: WARNING:LONG_LINE: line over 80 characters
#42848: FILE: drivers/serial/uart_nrfx_uarte.c:141:
+static inline const struct uarte_nrfx_config *get_dev_config(const struct device *dev)

-:43824: WARNING:LONG_LINE: line over 80 characters
#43824: FILE: drivers/serial/uart_rtt.c:18:
+static inline const struct uart_rtt_config *get_dev_config(const struct device *dev)

-:44059: WARNING:LONG_LINE: line over 80 characters
#44059: FILE: drivers/serial/uart_rv32m1_lpuart.c:315:
+	static void rv32m1_lpuart_config_func_##n(const struct device *dev)	\

-:44109: WARNING:PREFER_KERNEL_TYPES: Prefer kernel type 'u8_t' over 'uint8_t'
#44109: FILE: drivers/serial/uart_sam.c:170:
+			      const uint8_t *tx_data,

-:44234: WARNING:LONG_LINE: line over 80 characters
#44234: FILE: drivers/serial/uart_sam.c:339:
+	static void uart##n##_sam_irq_config_func(const struct device *port)	\

-:45218: WARNING:LONG_LINE: line over 80 characters
#45218: FILE: drivers/serial/uart_stm32.c:746:
+static void uart_stm32_irq_config_func_##index(const struct device *dev)	\

-:45518: WARNING:PREFER_KERNEL_TYPES: Prefer kernel type 'u8_t' over 'uint8_t'
#45518: FILE: drivers/serial/usart_sam.c:171:
+			       const uint8_t *tx_data,

-:45643: WARNING:LONG_LINE: line over 80 characters
#45643: FILE: drivers/serial/usart_sam.c:340:
+	static void usart##n##_sam_irq_config_func(const struct device *port)	\

-:45656: WARNING:LONG_LINE: line over 80 characters
#45656: FILE: drivers/spi/spi_cc13xx_cc26xx.c:42:
+static inline struct spi_cc13xx_cc26xx_data *get_dev_data(const struct device *dev)

-:46001: ERROR:CODE_INDENT: code indent should use tabs where possible
#46001: FILE: drivers/spi/spi_litespi.c:78:
+^I^I             u16_t control)$

-:46185: WARNING:LONG_LINE: line over 80 characters
#46185: FILE: drivers/spi/spi_ll_stm32.c:838:
+static void spi_stm32_irq_config_func_##id(const struct device *dev)		\

-:46332: WARNING:LONG_LINE: line over 80 characters
#46332: FILE: drivers/spi/spi_mcux_dspi.c:282:
+	static void spi_mcux_config_func_##id(const struct device *dev);	\

-:46446: WARNING:LONG_LINE: line over 80 characters
#46446: FILE: drivers/spi/spi_mcux_flexcomm.c:271:
+	static void spi_mcux_config_func_##id(const struct device *dev);	\

-:46596: WARNING:LONG_LINE: line over 80 characters
#46596: FILE: drivers/spi/spi_nrfx_spi.c:36:
+static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev)

-:46695: WARNING:LONG_LINE: line over 80 characters
#46695: FILE: drivers/spi/spi_nrfx_spi.c:355:
+	static int spi_##idx##_init(const struct device *dev)			       \

-:46714: WARNING:LONG_LINE: line over 80 characters
#46714: FILE: drivers/spi/spi_nrfx_spim.c:41:
+static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev)

-:46813: WARNING:LONG_LINE: line over 80 characters
#46813: FILE: drivers/spi/spi_nrfx_spim.c:402:
+	static int spi_##idx##_init(const struct device *dev)			       \

-:46832: WARNING:LONG_LINE: line over 80 characters
#46832: FILE: drivers/spi/spi_nrfx_spis.c:31:
+static inline const struct spi_nrfx_config *get_dev_config(const struct device *dev)

-:46914: WARNING:LONG_LINE: line over 80 characters
#46914: FILE: drivers/spi/spi_nrfx_spis.c:265:
+	static int spi_##idx##_init(const struct device *dev)			       \

-:48712: WARNING:LONG_LINE: line over 80 characters
#48712: FILE: drivers/watchdog/wdt_nrfx.c:30:
+static inline const struct wdt_nrfx_config *get_dev_config(const struct device *dev)

-:48763: WARNING:LONG_LINE: line over 80 characters
#48763: FILE: drivers/watchdog/wdt_nrfx.c:161:
+	static int wdt_##idx##_init(const struct device *dev)			       \

-:49633: WARNING:LONG_LINE: line over 80 characters
#49633: FILE: include/device.h:120:
+	static Z_DECL_ALIGN(const struct device)				\

-:49652: WARNING:LONG_LINE: line over 80 characters
#49652: FILE: include/device.h:177:
+	static Z_DECL_ALIGN(const struct device)				\

-:49692: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"
#49692: FILE: include/device.h:205:
+#define DEVICE_GET(name) ((struct device*)&DEVICE_NAME_GET(name))

-:49881: WARNING:LONG_LINE: line over 80 characters
#49881: FILE: include/device.h:598:
+static inline int device_pm_get_sync(const struct device *dev) { return -ENOTSUP; }

-:49883: WARNING:LONG_LINE: line over 80 characters
#49883: FILE: include/device.h:600:
+static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }

-:50148: WARNING:LONG_LINE: line over 80 characters
#50148: FILE: include/drivers/adc.h:381:
+					   const struct adc_channel_cfg *channel_cfg)

-:50699: WARNING:LONG_LINE: line over 80 characters
#50699: FILE: include/drivers/counter.h:391:
+					const struct counter_alarm_cfg *alarm_cfg);

-:50705: WARNING:LONG_LINE: line over 80 characters
#50705: FILE: include/drivers/counter.h:395:
+						   const struct counter_alarm_cfg *alarm_cfg)

-:50764: WARNING:LONG_LINE: line over 80 characters
#50764: FILE: include/drivers/counter.h:524:
+__deprecated __syscall u32_t counter_get_max_relative_alarm(const struct device *dev);

-:50767: WARNING:LONG_LINE: line over 80 characters
#50767: FILE: include/drivers/counter.h:526:
+static inline u32_t z_impl_counter_get_max_relative_alarm(const struct device *dev)

-:50843: WARNING:LONG_LINE: line over 80 characters
#50843: FILE: include/drivers/dac.h:92:
+					   const struct dac_channel_cfg *channel_cfg)

-:51864: WARNING:LONG_LINE: line over 80 characters
#51864: FILE: include/drivers/gpio.h:1345:
+__deprecated static inline int gpio_pin_enable_callback(const struct device *port,

-:51873: WARNING:LONG_LINE: line over 80 characters
#51873: FILE: include/drivers/gpio.h:1361:
+__deprecated static inline int gpio_pin_disable_callback(const struct device *port,

-:54279: ERROR:CODE_INDENT: code indent should use tabs where possible
#54279: FILE: include/irq_nextlevel.h:112:
+^I^I^I^I               u32_t irq,$

-:54280: ERROR:CODE_INDENT: code indent should use tabs where possible
#54280: FILE: include/irq_nextlevel.h:113:
+^I^I^I^I               u32_t prio, u32_t flags)$

-:54289: WARNING:LONG_LINE: line over 80 characters
#54289: FILE: include/irq_nextlevel.h:132:
+static inline unsigned int irq_line_is_enabled_next_level(const struct device *dev,

-:54353: WARNING:LONG_LINE: line over 80 characters
#54353: FILE: include/kernel.h:294:
+__syscall void k_object_access_grant(const void *object, struct k_thread *thread);

-:54879: WARNING:LONG_LINE: line over 80 characters
#54879: FILE: include/syscall_handler.h:60:
+extern void z_dump_object_error(int retval, const void *obj, struct z_object *ko,

-:54897: WARNING:LONG_LINE: line over 80 characters
#54897: FILE: include/syscall_handler.h:417:
+	Z_SYSCALL_VERIFY_MSG(z_obj_validation_check(z_object_find((const void *)ptr), (void *)ptr, \

-:54936: WARNING:LONG_LINE: line over 80 characters
#54936: FILE: include/usb/class/usb_audio.h:203:
+					       const struct usb_audio_fu_evt *evt);

-:55083: WARNING:LONG_LINE: line over 80 characters
#55083: FILE: kernel/init.c:380:
+	const struct device *entropy = device_get_binding(DT_CHOSEN_ZEPHYR_ENTROPY_LABEL);

-:55400: WARNING:LONG_LINE: line over 80 characters
#55400: FILE: lib/gui/lvgl/lvgl.c:91:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55445: WARNING:LONG_LINE: line over 80 characters
#55445: FILE: lib/gui/lvgl/lvgl_display.c:12:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55458: WARNING:LONG_LINE: line over 80 characters
#55458: FILE: lib/gui/lvgl/lvgl_display_16bit.c:14:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55471: WARNING:LONG_LINE: line over 80 characters
#55471: FILE: lib/gui/lvgl/lvgl_display_24bit.c:14:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55484: WARNING:LONG_LINE: line over 80 characters
#55484: FILE: lib/gui/lvgl/lvgl_display_32bit.c:14:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55497: WARNING:LONG_LINE: line over 80 characters
#55497: FILE: lib/gui/lvgl/lvgl_display_mono.c:16:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55506: WARNING:LONG_LINE: line over 80 characters
#55506: FILE: lib/gui/lvgl/lvgl_display_mono.c:40:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:55515: WARNING:LONG_LINE: line over 80 characters
#55515: FILE: lib/gui/lvgl/lvgl_display_mono.c:83:
+	const struct device *display_dev = (const struct device *)disp_drv->user_data;

-:56004: WARNING:LONG_LINE: line over 80 characters
#56004: FILE: samples/boards/96b_argonkey/microphone/src/main.c:130:
+	const struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy)));

-:56049: WARNING:LONG_LINE: line over 80 characters
#56049: FILE: samples/boards/96b_argonkey/sensors/src/main.c:166:
+	const struct device *hum_dev = device_get_binding(DT_LABEL(DT_INST(0, st_hts221)));

-:56058: WARNING:LONG_LINE: line over 80 characters
#56058: FILE: samples/boards/96b_argonkey/sensors/src/main.c:176:
+	const struct device *accel_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl)));

-:56067: WARNING:LONG_LINE: line over 80 characters
#56067: FILE: samples/boards/96b_argonkey/sensors/src/main.c:241:
+	const struct device *tof_dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x)));

-:56512: WARNING:LONG_LINE: line over 80 characters
#56512: FILE: samples/boards/sensortile_box/src/main.c:276:
+	const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221)));

-:56513: WARNING:LONG_LINE: line over 80 characters
#56513: FILE: samples/boards/sensortile_box/src/main.c:277:
+	const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12)));

-:56514: WARNING:LONG_LINE: line over 80 characters
#56514: FILE: samples/boards/sensortile_box/src/main.c:278:
+	const struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh)));

-:56515: WARNING:LONG_LINE: line over 80 characters
#56515: FILE: samples/boards/sensortile_box/src/main.c:279:
+	const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso)));

-:56516: WARNING:LONG_LINE: line over 80 characters
#56516: FILE: samples/boards/sensortile_box/src/main.c:280:
+	const struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751)));

-:56517: WARNING:LONG_LINE: line over 80 characters
#56517: FILE: samples/boards/sensortile_box/src/main.c:281:
+	const struct device *iis3dhhc = device_get_binding(DT_LABEL(DT_INST(0, st_iis3dhhc)));

-:56518: WARNING:LONG_LINE: line over 80 characters
#56518: FILE: samples/boards/sensortile_box/src/main.c:282:
+	const struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl)));

-:57642: WARNING:LONG_LINE: line over 80 characters
#57642: FILE: samples/net/gsm_modem/src/main.c:40:
+	const struct device *uart_dev = device_get_binding(CONFIG_MODEM_GSM_UART_NAME);

-:57795: WARNING:LONG_LINE: line over 80 characters
#57795: FILE: samples/sensor/adt7420/src/main.c:174:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adt7420)));

-:57818: WARNING:LONG_LINE: line over 80 characters
#57818: FILE: samples/sensor/adxl362/src/main.c:37:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl362)));

-:57841: WARNING:LONG_LINE: line over 80 characters
#57841: FILE: samples/sensor/adxl372/src/main.c:51:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, adi_adxl372)));

-:57926: WARNING:LONG_LINE: line over 80 characters
#57926: FILE: samples/sensor/bme680/src/main.c:14:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, bosch_bme680)));

-:58083: WARNING:LONG_LINE: line over 80 characters
#58083: FILE: samples/sensor/ccs811/src/main.c:116:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ams_ccs811)));

-:58109: WARNING:LONG_LINE: line over 80 characters
#58109: FILE: samples/sensor/dps310/src/main.c:15:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, infineon_dps310)));

-:58145: WARNING:LONG_LINE: line over 80 characters
#58145: FILE: samples/sensor/fxas21002/src/main.c:22:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxas21002)));

-:58179: WARNING:LONG_LINE: line over 80 characters
#58179: FILE: samples/sensor/fxos8700-hid/src/main.c:118:
+			void (*handler)(const struct device*, struct gpio_callback*,

-:58232: WARNING:LONG_LINE: line over 80 characters
#58232: FILE: samples/sensor/fxos8700/src/main.c:35:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, nxp_fxos8700)));

-:58245: WARNING:LONG_LINE: line over 80 characters
#58245: FILE: samples/sensor/grove_light/src/main.c:16:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_light)));

-:58258: WARNING:LONG_LINE: line over 80 characters
#58258: FILE: samples/sensor/grove_temperature/src/main.c:22:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, grove_temperature)));

-:58382: WARNING:LONG_LINE: line over 80 characters
#58382: FILE: samples/sensor/lis2dh/src/main.c:53:
+	const struct device *sensor = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));

-:58404: WARNING:LONG_LINE: line over 80 characters
#58404: FILE: samples/sensor/lps22hb/src/main.c:46:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press)));

-:58484: WARNING:LONG_LINE: line over 80 characters
#58484: FILE: samples/sensor/lsm6dsl/src/main.c:103:
+	const struct device *lsm6dsl_dev = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl)));

-:58532: WARNING:LONG_LINE: line over 80 characters
#58532: FILE: samples/sensor/max30101/src/main.c:14:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, max_max30101)));

-:58645: WARNING:LONG_LINE: line over 80 characters
#58645: FILE: samples/sensor/ms5837/src/main.c:18:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, meas_ms5837)));

-:58766: WARNING:LONG_LINE: line over 80 characters
#58766: FILE: samples/sensor/ti_hdc/src/main.c:18:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, ti_hdc)));

-:58814: WARNING:LONG_LINE: line over 80 characters
#58814: FILE: samples/sensor/vl53l0x/src/main.c:15:
+	const struct device *dev = device_get_binding(DT_LABEL(DT_INST(0, st_vl53l0x)));

-:58852: WARNING:LONG_LINE: line over 80 characters
#58852: FILE: samples/shields/x_nucleo_iks01a1/src/main.c:28:
+	const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221)));

-:58853: WARNING:LONG_LINE: line over 80 characters
#58853: FILE: samples/shields/x_nucleo_iks01a1/src/main.c:29:
+	const struct device *lis3mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis3mdl_magn)));

-:58854: WARNING:LONG_LINE: line over 80 characters
#58854: FILE: samples/shields/x_nucleo_iks01a1/src/main.c:30:
+	const struct device *lsm6ds0 = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6ds0)));

-:58855: WARNING:LONG_LINE: line over 80 characters
#58855: FILE: samples/shields/x_nucleo_iks01a1/src/main.c:31:
+	const struct device *lps25hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps25hb_press)));

-:58872: WARNING:LONG_LINE: line over 80 characters
#58872: FILE: samples/shields/x_nucleo_iks01a2/src/main.c:19:
+	const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221)));

-:58873: WARNING:LONG_LINE: line over 80 characters
#58873: FILE: samples/shields/x_nucleo_iks01a2/src/main.c:20:
+	const struct device *lps22hb = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hb_press)));

-:58874: WARNING:LONG_LINE: line over 80 characters
#58874: FILE: samples/shields/x_nucleo_iks01a2/src/main.c:21:
+	const struct device *lsm6dsl = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dsl)));

-:58875: WARNING:LONG_LINE: line over 80 characters
#58875: FILE: samples/shields/x_nucleo_iks01a2/src/main.c:22:
+	const struct device *lsm303agr_a = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dh)));

-:58876: WARNING:LONG_LINE: line over 80 characters
#58876: FILE: samples/shields/x_nucleo_iks01a2/src/main.c:23:
+	const struct device *lsm303agr_m = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl)));

-:58947: WARNING:LONG_LINE: line over 80 characters
#58947: FILE: samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:182:
+	const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12)));

-:58948: WARNING:LONG_LINE: line over 80 characters
#58948: FILE: samples/shields/x_nucleo_iks01a3/sensorhub/src/main.c:183:
+	const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso)));

-:59077: WARNING:LONG_LINE: line over 80 characters
#59077: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:250:
+	const struct device *hts221 = device_get_binding(DT_LABEL(DT_INST(0, st_hts221)));

-:59078: WARNING:LONG_LINE: line over 80 characters
#59078: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:251:
+	const struct device *lps22hh = device_get_binding(DT_LABEL(DT_INST(0, st_lps22hh)));

-:59079: WARNING:LONG_LINE: line over 80 characters
#59079: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:252:
+	const struct device *stts751 = device_get_binding(DT_LABEL(DT_INST(0, st_stts751)));

-:59080: WARNING:LONG_LINE: line over 80 characters
#59080: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:253:
+	const struct device *lis2mdl = device_get_binding(DT_LABEL(DT_INST(0, st_lis2mdl)));

-:59081: WARNING:LONG_LINE: line over 80 characters
#59081: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:254:
+	const struct device *lis2dw12 = device_get_binding(DT_LABEL(DT_INST(0, st_lis2dw12)));

-:59082: WARNING:LONG_LINE: line over 80 characters
#59082: FILE: samples/shields/x_nucleo_iks01a3/standard/src/main.c:255:
+	const struct device *lsm6dso = device_get_binding(DT_LABEL(DT_INST(0, st_lsm6dso)));

-:59095: WARNING:LONG_LINE: line over 80 characters
#59095: FILE: samples/shields/x_nucleo_iks02a1/microphone/src/main.c:52:
+	const struct device *mic_dev = device_get_binding(DT_LABEL(DT_INST(0, st_mpxxdtyy)));

-:59166: WARNING:LONG_LINE: line over 80 characters
#59166: FILE: samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:159:
+	const struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc)));

-:59167: WARNING:LONG_LINE: line over 80 characters
#59167: FILE: samples/shields/x_nucleo_iks02a1/sensorhub/src/main.c:160:
+	const struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx)));

-:59248: WARNING:LONG_LINE: line over 80 characters
#59248: FILE: samples/shields/x_nucleo_iks02a1/standard/src/main.c:170:
+	const struct device *iis2dlpc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2dlpc)));

-:59249: WARNING:LONG_LINE: line over 80 characters
#59249: FILE: samples/shields/x_nucleo_iks02a1/standard/src/main.c:171:
+	const struct device *iis2mdc = device_get_binding(DT_LABEL(DT_INST(0, st_iis2mdc)));

-:59250: WARNING:LONG_LINE: line over 80 characters
#59250: FILE: samples/shields/x_nucleo_iks02a1/standard/src/main.c:172:
+	const struct device *ism330dhcx = device_get_binding(DT_LABEL(DT_INST(0, st_ism330dhcx)));

-:59798: WARNING:LONG_LINE: line over 80 characters
#59798: FILE: samples/subsys/usb/hid-cdc/src/main.c:530:
+			void (*handler)(const struct device*, struct gpio_callback*,

-:62254: WARNING:LONG_LINE: line over 80 characters
#62254: FILE: subsys/net/l2/ethernet/ethernet.c:1059:
+static inline const struct device *z_vrfy_net_eth_get_ptp_clock_by_index(int index)

-:63716: WARNING:LONG_LINE: line over 80 characters
#63716: FILE: tests/boards/altera_max10/i2c_master/src/i2c_master.c:68:
+	const struct device *i2c_dev = device_get_binding(DT_LABEL(DT_INST(0, nios2_i2c)));

-:68100: WARNING:LONG_LINE: line over 80 characters
#68100: FILE: tests/subsys/fs/multi-fs/src/test_ram_backend.c:73:
+					const struct flash_pages_layout **layout,

-:68195: WARNING:LONG_LINE: line over 80 characters
#68195: FILE: tests/subsys/openthread/radio_test.c:154:
+static enum ieee802154_hw_caps get_capabilities_caps_mock(const struct device *dev)

- total: 4 errors, 231 warnings, 57035 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPDX_LICENSE_TAG SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Gitlint issues

Commit 01bf452:
1: T5 Title contains the word 'wip' (case-insensitive): "DNM WIP device: add illegal cast to dev pointer passed as userdata"

Commit a0eca13:
32: UC4 Line exceeds max length (73>72): "2: sed: ensure all non-code/macro references point to const struct device"

Commit b1ad4bc:
8: UC4 Line exceeds max length (83>72): " -e 's@static struct device DEVICE_NAME_GET(([^)]*));@DEVICE_DECLARE(\1);@'"

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@pabigot pabigot force-pushed the nordic/issue/22941a branch 2 times, most recently from d9cc292 to a0bec95 Compare May 12, 2020 01:01
@pabigot
Copy link
Collaborator Author

pabigot commented May 12, 2020

Existing code that passes a device pointer as an argument to a function that receives a void * parameter is going to be a huge problem. The const qualifier must be cast away in the ISR infrastructure, as well as many thread entry functions and other callback user-data parameters. At this time the necessary conversions don't appear to be automatable.

@@ -254,6 +271,7 @@ struct device {
const void *config_info;
const void *driver_api;
void * const driver_data;
struct device_context * const driver_context;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just call it context (imo all these attributes should be renamed: config_info -> config, driver_api -> api, driver_data -> data), but that's a side note.

What's the benefit exposing it that way? (adding a pointer in the struct, instead of a fully separate array as in #24873). It's a trade-off between ROM occupation and runtime computation, anything else than that?

In the very end, we should merge driver_data and driver_context, and provide the means for the drivers to access the data seamlessly (via a macro or else). I just did not go myself in that path in my RFC because it generates a lot of changes in drivers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly as you say: the right way is to put the common context into a prefix of the driver-specific data. That can't be done if they're separate objects.

This is a prototype using a different object relationship than yours; we don't know yet what the best path will be. Better to try several and compare their pros and cons.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't be done if they're separate objects.

Of course it can be. Current RFCs (mine and yours) are only trying to solve the device instance as constant.

Once done then we can move on with modifying driver_data to provide also a driver context.

But, as I said in my other comment, if the goal is only to solve the device instances to be constants, there is 0 point to introduce right now a struct device_context since an atomic bits array would just do the work.
In my RFC I did introduce such context because of all the other features (sync/lock and status reporting), not because of const-ifying devices.

So maybe we should really proceed step by steps:

  • let's fix the device constant by having such atomic bits (and let device_get_binding() check these when relevant)
  • let's add a struct device_context for everything else that would come afterwards (sync/lock & status reporting).

As you already mentioned in relevant PRs, you are not convinced about adding such sync/lock and status report features... so adding a device context right now would be a bad idea then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I was combining multiple features. I'll switch it to a bool init_ok since that's the only state we need right now.

@@ -39,7 +39,7 @@ static bool device_get_config_level(const struct shell *shell, int level)
bool devices = false;

for (dev = levels[level]; dev < levels[level+1]; dev++) {
if (dev->driver_api != NULL) {
if (dev->driver_context->init_ok) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, if we stick to the goal of this RFC: const-ifying struct device instances, then such driver context is overkill.

Better having an array of atomic bits then, like PM's busy bit array. Less changes to reach the goal.

@tbursztyka
Copy link
Collaborator

perhaps cherry-pick the obvious patches I have already done in #24873 about putting struct device to const instead of redoing them.
you'll need that one as well 3717196

@pabigot
Copy link
Collaborator Author

pabigot commented May 12, 2020

perhaps cherry-pick the obvious patches I have already done in #24873 about putting struct device to const instead of redoing them.

I looked at them and this told me it wasn't right:

                if (dev != NULL) {
-                       z_object_init(dev);
+                       z_object_init((void *)dev);
                }

We can't go removing const from pointers. It's outlawed by MISRA 11.8:

A cast shall not remove any const or volatile qualification from the type pointed to by a pointer

@tbursztyka
Copy link
Collaborator

We can't go removing const from pointers. It's outlawed by MISRA 11.8:

Did not know that, I should probably download someday the misra papers.

Anyway my point was that instead of chasing the same rabbit in parallel, let's use each-others works properly. At least, I am not going to waste my time on a task if I know somebody else is doing the same work. Unless, you want to take over this task (though it makes already my work a bit of a waste then)

@pabigot
Copy link
Collaborator Author

pabigot commented May 12, 2020

I'm not interested in taking over your wider work on the device structure, but I am interested in pursuing issues related to making struct device const. I don't feel that this work conflicts with yours, but I do feel that trying to isolate those issues in the context of a set of draft patches that touch many files is too difficult. So I'm trying to do the minimum necessary to isolate those specific issues.

I expect to have my results in the next day or two after a few more passes through shippable to identify those issues, then we can assess how to proceed. This effort has already identified existing MISRA violations in current master that should probably be addressed before 2.3 release (#25247).

@pabigot pabigot force-pushed the nordic/issue/22941a branch 3 times, most recently from a35dc88 to d249eb6 Compare May 12, 2020 16:29
@pabigot pabigot force-pushed the nordic/issue/22941a branch 6 times, most recently from 42a6497 to 99d6ac3 Compare May 14, 2020 13:39
@galak
Copy link
Collaborator

galak commented May 14, 2020

Dev-Review (May 14):

  • We should take a step back and decide if making device struct const is a direction we want to go, and thus preclude runtime creation of devices. (@galak the 2 examples I can come up with are PCI/e devices and USB, scanning a bus at runtime)
  • An alternative approach, if reducing RAM is a priority, is to ensure struct device objects are placed in flash at link-time, even though at the language level the pointers do not indicate that changing values in the object will fail.

Let's set the api at built time, or this will create a bug once device
instance pointers become constant.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
pabigot added 11 commits May 14, 2020 14:25
Replace individual device instance definitions with the macro that
expands to the equivalent change.

    git grep -l 'struct device DEVICE_NAME_GET' \
     | xargs sed -i -r \
       -e 's@static struct device DEVICE_NAME_GET\(([^)]*)\);@DEVICE_DECLARE(\1);@'

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This is done by the init infrastructure and should not be implemented
in the driver itself.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The k_object API associates mutable state structures with known kernel
objects to support userspace.  The kernel objects themselves are not
modified by the API, and in some cases (e.g. device structures) may be
const-qualified.  Update the API so that pointers to these const
kernel objects can be passed without casting away the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Avoid duplication of the encoding of the public device identifier by
using the constructing macro in definitions.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
At this time the only thing preventing moving `struct device` objects
into flash is the use of the API pointer as a flag indicating
initialization success.  Add a structure to hold dynamic state common
to all devices.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
These should now have no mutable content.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Rebases should pause immediately before this commit and run the steps
described below, which should be committed with `-C SHA` where SHA is
is the commit SHA of this commit.  This may reduce the amount of
conflict arising from upstream changes.

1: coccinelle: ensure all code references point to const struct device

/* Force struct device to be const in all pointer declarations
 * Invoke:

spatch --sp-file devptr.cocci --dir . --include-headers --very-quiet \
    --macro-file scripts/coccinelle/macros.h

 */

@
disable optional_qualifier
@
@@
+const
 struct device *

@
disable optional_qualifier
@
@@
+const
 struct device * const

2: sed: ensure all non-code/macro references point to const struct device

git grep -l '(struct device' \
  | xargs sed -i -r \
    -e 's@\(struct device@(const struct device@g'

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Now that struct device instances are immutable store the flag that
indicates whether initialization was successful in the device context.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This macro is generally used in contexts where something is expecting
a pointer to (non-const) void.  Reduce the complaints by lying about
the type.

This needs to be fixed properly by changing all API where an
application of this macro is passed as a parameter; i.e. specifically
API related to ISRs.  Here we're just testing build and behavior.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Various generic data pointers are typed as pointer-to-void but some
uses pass device pointers.  Add const-removing casts to avoid the
build errors.

Some of these were identified from shippable logs, e.g.:

grep discarded-qualif /tmp/zephyrproject-rtos-zephyr-72591.1.log \
  | sed -e 's@^.*/@@' \
  | sort \
  | uniq

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
External modules may include code with prototypes that must be updated
to accept const device objects.  Update to the version of those
modules that is ready for the new expectations.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
@pabigot
Copy link
Collaborator Author

pabigot commented May 14, 2020

Latest run passes all tests that ran before timeout, so we'll leave it here. Some of the commits should be submitted for master regardless of whether we continue with making definitions const.

https://app.shippable.com/github/zephyrproject-rtos/zephyr/runs/72918/summary/console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-review To be discussed in dev-review meeting RFC Request For Comments: want input from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants