-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: stm32: clean indentation in instance definition macros #99085
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
base: main
Are you sure you want to change the base?
Changes from all commits
92dca6f
6089bc4
4f12e6c
02e8de8
23c1b9b
5e58f82
798a1db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -34,15 +34,15 @@ static int stm32_clk_mux_init(const struct device *dev) | |||||||
| return 0; | ||||||||
| } | ||||||||
|
|
||||||||
| #define STM32_MUX_CLK_INIT(id) \ | ||||||||
| \ | ||||||||
| static const struct stm32_clk_mux_config stm32_clk_mux_cfg_##id = { \ | ||||||||
| .pclken = STM32_CLOCK_INFO(0, DT_DRV_INST(id)) \ | ||||||||
| }; \ | ||||||||
| \ | ||||||||
| DEVICE_DT_INST_DEFINE(id, stm32_clk_mux_init, NULL, \ | ||||||||
| NULL, &stm32_clk_mux_cfg_##id, \ | ||||||||
| PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,\ | ||||||||
| NULL); | ||||||||
| #define STM32_MUX_CLK_INIT(id) \ | ||||||||
| \ | ||||||||
|
Comment on lines
+37
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| static const struct stm32_clk_mux_config stm32_clk_mux_cfg_##id = { \ | ||||||||
| .pclken = STM32_CLOCK_INFO(0, DT_DRV_INST(id)) \ | ||||||||
| }; \ | ||||||||
| \ | ||||||||
| DEVICE_DT_INST_DEFINE(id, stm32_clk_mux_init, NULL, \ | ||||||||
| NULL, &stm32_clk_mux_cfg_##id, \ | ||||||||
| PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_OBJECTS,\ | ||||||||
| NULL); | ||||||||
|
|
||||||||
| DT_INST_FOREACH_STATUS_OKAY(STM32_MUX_CLK_INIT) | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,7 +467,7 @@ void i2c_stm32_smbalert_disable(const struct device *dev) | |
| (DEVICE_DT_GET(STM32_DMA_CTLR(index, dir))), (NULL)), \ | ||
| .dma_channel = COND_CODE_1(DT_INST_DMAS_HAS_NAME(index, dir), \ | ||
| (DT_INST_DMAS_CELL_BY_NAME(index, dir, channel)), (-1)), \ | ||
| }, | ||
| }, | ||
|
|
||
| void i2c_stm32_dma_tx_cb(const struct device *dma_dev, void *user_data, | ||
| uint32_t channel, int status) | ||
|
|
@@ -498,73 +498,72 @@ void i2c_stm32_dma_rx_cb(const struct device *dma_dev, void *user_data, | |
| #define I2C_DMA_DATA_INIT(index, dir, src, dest) \ | ||
| IF_ENABLED(DT_INST_DMAS_HAS_NAME(index, dir), \ | ||
| (.dma_##dir##_cfg = { \ | ||
| .dma_slot = STM32_DMA_SLOT(index, dir, slot), \ | ||
| .channel_direction = STM32_DMA_CONFIG_DIRECTION( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .cyclic = STM32_DMA_CONFIG_CYCLIC( \ | ||
| .dma_slot = STM32_DMA_SLOT(index, dir, slot), \ | ||
| .channel_direction = STM32_DMA_CONFIG_DIRECTION( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ | ||
| .cyclic = STM32_DMA_CONFIG_CYCLIC( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .source_data_size = STM32_DMA_CONFIG_##src##_DATA_SIZE( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .dest_data_size = STM32_DMA_CONFIG_##dest##_DATA_SIZE( \ | ||
| .channel_priority = STM32_DMA_CONFIG_PRIORITY( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .source_burst_length = 1, \ | ||
| .dest_burst_length = 1, \ | ||
| .dma_callback = i2c_stm32_dma_##dir##_cb, \ | ||
| },)) | ||
| .source_data_size = STM32_DMA_CONFIG_##src##_DATA_SIZE( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .dest_data_size = STM32_DMA_CONFIG_##dest##_DATA_SIZE( \ | ||
| STM32_DMA_CHANNEL_CONFIG(index, dir)), \ | ||
| .source_burst_length = 1, \ | ||
| .dest_burst_length = 1, \ | ||
| .dma_callback = i2c_stm32_dma_##dir##_cb, \ | ||
| },)) | ||
|
|
||
| #else | ||
| #else /* CONFIG_I2C_STM32_V2_DMA */ | ||
|
|
||
| #define I2C_DMA_INIT(index, dir) | ||
| #define I2C_DMA_DATA_INIT(index, dir, src, dest) | ||
|
|
||
| #endif /* CONFIG_I2C_STM32_V2_DMA */ | ||
|
|
||
| #define I2C_STM32_INIT(index) \ | ||
| I2C_STM32_IRQ_HANDLER_DECL(index); \ | ||
| I2C_STM32_IRQ_HANDLER_DECL(index); \ | ||
| \ | ||
| IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2), \ | ||
| (static const uint32_t i2c_timings_##index[] = \ | ||
| DT_INST_PROP_OR(index, timings, {});)) \ | ||
| IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2), \ | ||
| (static const uint32_t i2c_timings_##index[] = \ | ||
| DT_INST_PROP_OR(index, timings, {});)) \ | ||
| \ | ||
| PINCTRL_DT_INST_DEFINE(index); \ | ||
| PINCTRL_DT_INST_DEFINE(index); \ | ||
| \ | ||
| static const struct stm32_pclken pclken_##index[] = \ | ||
| STM32_DT_INST_CLOCKS(index); \ | ||
| static const struct stm32_pclken pclken_##index[] = STM32_DT_INST_CLOCKS(index); \ | ||
| \ | ||
| static const struct i2c_stm32_config i2c_stm32_cfg_##index = { \ | ||
| .i2c = (I2C_TypeDef *)DT_INST_REG_ADDR(index), \ | ||
| .pclken = pclken_##index, \ | ||
| .pclk_len = DT_INST_NUM_CLOCKS(index), \ | ||
| I2C_STM32_IRQ_HANDLER_FUNCTION(index) \ | ||
| .bitrate = DT_INST_PROP(index, clock_frequency), \ | ||
| .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \ | ||
| IF_ENABLED(CONFIG_I2C_STM32_BUS_RECOVERY, \ | ||
| (.scl = GPIO_DT_SPEC_INST_GET_OR(index, scl_gpios, {0}), \ | ||
| .sda = GPIO_DT_SPEC_INST_GET_OR(index, sda_gpios, {0}),)) \ | ||
| IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2), \ | ||
| (.timings = (const struct i2c_config_timing *) i2c_timings_##index, \ | ||
| .n_timings = \ | ||
| sizeof(i2c_timings_##index) / (sizeof(struct i2c_config_timing)),)) \ | ||
| I2C_DMA_INIT(index, tx) \ | ||
| I2C_DMA_INIT(index, rx) \ | ||
| }; \ | ||
| static const struct i2c_stm32_config i2c_stm32_cfg_##index = { \ | ||
| .i2c = (I2C_TypeDef *)DT_INST_REG_ADDR(index), \ | ||
| .pclken = pclken_##index, \ | ||
| .pclk_len = DT_INST_NUM_CLOCKS(index), \ | ||
| I2C_STM32_IRQ_HANDLER_FUNCTION(index) \ | ||
| .bitrate = DT_INST_PROP(index, clock_frequency), \ | ||
| .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \ | ||
| IF_ENABLED(CONFIG_I2C_STM32_BUS_RECOVERY, \ | ||
| (.scl = GPIO_DT_SPEC_INST_GET_OR(index, scl_gpios, {0}), \ | ||
| .sda = GPIO_DT_SPEC_INST_GET_OR(index, sda_gpios, {0}),)) \ | ||
| IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_i2c_v2), \ | ||
| (.timings = (const struct i2c_config_timing *)i2c_timings_##index, \ | ||
| .n_timings = sizeof(i2c_timings_##index) / \ | ||
| (sizeof(struct i2c_config_timing)),)) \ | ||
|
Comment on lines
+547
to
+548
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: the "stray" |
||
| I2C_DMA_INIT(index, tx) \ | ||
| I2C_DMA_INIT(index, rx) \ | ||
| }; \ | ||
| \ | ||
| static struct i2c_stm32_data i2c_stm32_dev_data_##index = { \ | ||
| I2C_DMA_DATA_INIT(index, tx, MEMORY, PERIPHERAL) \ | ||
| I2C_DMA_DATA_INIT(index, rx, PERIPHERAL, MEMORY) \ | ||
| }; \ | ||
| static struct i2c_stm32_data i2c_stm32_dev_data_##index = { \ | ||
| I2C_DMA_DATA_INIT(index, tx, MEMORY, PERIPHERAL) \ | ||
| I2C_DMA_DATA_INIT(index, rx, PERIPHERAL, MEMORY) \ | ||
| }; \ | ||
| \ | ||
| PM_DEVICE_DT_INST_DEFINE(index, i2c_stm32_pm_action); \ | ||
| PM_DEVICE_DT_INST_DEFINE(index, i2c_stm32_pm_action); \ | ||
| \ | ||
| I2C_DEVICE_DT_INST_DEFINE(index, i2c_stm32_init, \ | ||
| PM_DEVICE_DT_INST_GET(index), \ | ||
| &i2c_stm32_dev_data_##index, \ | ||
| &i2c_stm32_cfg_##index, \ | ||
| POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, \ | ||
| &api_funcs); \ | ||
| I2C_DEVICE_DT_INST_DEFINE(index, i2c_stm32_init, \ | ||
| PM_DEVICE_DT_INST_GET(index), \ | ||
| &i2c_stm32_dev_data_##index, \ | ||
| &i2c_stm32_cfg_##index, \ | ||
| POST_KERNEL, CONFIG_I2C_INIT_PRIORITY, \ | ||
| &api_funcs); \ | ||
| \ | ||
| I2C_STM32_IRQ_HANDLER(index) | ||
| I2C_STM32_IRQ_HANDLER(index) | ||
|
|
||
| DT_INST_FOREACH_STATUS_OKAY(I2C_STM32_INIT) | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -719,31 +719,31 @@ static int pwm_stm32_init(const struct device *dev) | |||||
|
|
||||||
| #ifdef CONFIG_PWM_CAPTURE | ||||||
| #define IRQ_CONNECT_AND_ENABLE_BY_NAME(index, name) \ | ||||||
| { \ | ||||||
| IRQ_CONNECT(DT_IRQ_BY_NAME(PWM(index), name, irq), \ | ||||||
| DT_IRQ_BY_NAME(PWM(index), name, priority), \ | ||||||
| pwm_stm32_isr, DEVICE_DT_INST_GET(index), 0); \ | ||||||
| irq_enable(DT_IRQ_BY_NAME(PWM(index), name, irq)); \ | ||||||
| } | ||||||
| { \ | ||||||
| IRQ_CONNECT(DT_IRQ_BY_NAME(PWM(index), name, irq), \ | ||||||
| DT_IRQ_BY_NAME(PWM(index), name, priority), \ | ||||||
| pwm_stm32_isr, DEVICE_DT_INST_GET(index), 0); \ | ||||||
| irq_enable(DT_IRQ_BY_NAME(PWM(index), name, irq)); \ | ||||||
| } | ||||||
|
|
||||||
| #define IRQ_CONNECT_AND_ENABLE_DEFAULT(index) \ | ||||||
| { \ | ||||||
| IRQ_CONNECT(DT_IRQN(PWM(index)), \ | ||||||
| DT_IRQ(PWM(index), priority), \ | ||||||
| pwm_stm32_isr, DEVICE_DT_INST_GET(index), 0); \ | ||||||
| irq_enable(DT_IRQN(PWM(index))); \ | ||||||
| } | ||||||
| { \ | ||||||
| IRQ_CONNECT(DT_IRQN(PWM(index)), \ | ||||||
| DT_IRQ(PWM(index), priority), \ | ||||||
| pwm_stm32_isr, DEVICE_DT_INST_GET(index), 0); \ | ||||||
| irq_enable(DT_IRQN(PWM(index))); \ | ||||||
| } | ||||||
|
|
||||||
| #define IRQ_CONFIG_FUNC(index) \ | ||||||
| static void pwm_stm32_irq_config_func_##index(const struct device *dev) \ | ||||||
| { \ | ||||||
| COND_CODE_1(DT_IRQ_HAS_NAME(PWM(index), cc), \ | ||||||
| (IRQ_CONNECT_AND_ENABLE_BY_NAME(index, cc)), \ | ||||||
| (IRQ_CONNECT_AND_ENABLE_DEFAULT(index)) \ | ||||||
| ); \ | ||||||
| } | ||||||
| #define CAPTURE_INIT(index) \ | ||||||
| .irq_config_func = pwm_stm32_irq_config_func_##index, \ | ||||||
| static void pwm_stm32_irq_config_func_##index(const struct device *dev) \ | ||||||
| { \ | ||||||
| COND_CODE_1(DT_IRQ_HAS_NAME(PWM(index), cc), \ | ||||||
| (IRQ_CONNECT_AND_ENABLE_BY_NAME(index, cc)), \ | ||||||
| (IRQ_CONNECT_AND_ENABLE_DEFAULT(index))); \ | ||||||
| } | ||||||
|
|
||||||
| #define CAPTURE_INIT(index) \ | ||||||
| .irq_config_func = pwm_stm32_irq_config_func_##index, \ | ||||||
| .four_channel_capture_support = DT_INST_PROP(index, four_channel_capture_support) | ||||||
| #else | ||||||
| #define IRQ_CONFIG_FUNC(index) | ||||||
|
|
@@ -760,7 +760,7 @@ static void pwm_stm32_irq_config_func_##index(const struct device *dev) \ | |||||
| PINCTRL_DT_INST_DEFINE(index); \ | ||||||
| \ | ||||||
| static const struct stm32_pclken pclken_##index[] = \ | ||||||
| STM32_DT_CLOCKS(PWM(index)); \ | ||||||
| STM32_DT_CLOCKS(PWM(index)); \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: it would be better to always use tabs rather than end with spaces (general remark, as there's - alas! - no consistency across drivers...)
Suggested change
|
||||||
| \ | ||||||
| static const struct pwm_stm32_config pwm_stm32_config_##index = { \ | ||||||
| .timer = (TIM_TypeDef *)DT_REG_ADDR(PWM(index)), \ | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there's a rationale for the empty line I missed?