Skip to content

Conversation

@henrikbrixandersen
Copy link
Member

@henrikbrixandersen henrikbrixandersen commented Apr 19, 2022

Refactor the Bosch M_CAN shared driver functions to get rid of the front-end driver wrapper functions.

This requires flipping the relationship between shared config/data structs and front-end config/data structs. Front-end drivers can now store a pointer to their custom config/data structs in the .custom fields of the can_mcan_config and can_mcan_data data structures.

Rename the private header file for the Bosch M_CAN shared driver code from can_mcan_int.h to can_mcan_priv.h to follow the common naming scheme.

Add shared initializer macros for struct can_mcan_config and struct can_mcan_data.

The changes were tested on hardware for the following drivers:

  • can_mcux_mcan (lpcxpresso55s16)
  • can_stm32fd (nucleo_g474re)

The changes were only compile-tested for the following drivers due to lack of hardware. Additional testing most welcome.

  • can_sam
  • can_stm32h7

Rename the private header file for the Bosch M_CAN shared driver code
from can_mcan_int.h to can_mcan_priv.h to follow the common naming
scheme.

Signed-off-by: Henrik Brix Andersen <[email protected]>
Refactor the Bosch M_CAN shared driver functions to get rid of the
front-end driver wrapper functions.

This requires flipping the relationship between shared config/data
structs and front-end config/data structs. Front-end drivers can now
store a pointer to their custom config/data structs in the .custom
fields of the can_mcan_config and can_mcan_data data structures.

Signed-off-by: Henrik Brix Andersen <[email protected]>
@henrikbrixandersen
Copy link
Member Author

There are no functional changes in this PR, only refactoring to get rid of the wrapper functions. Reviews are most welcome.

Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

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

lgtm, one suggestion/comment

Comment on lines 133 to 134
Copy link
Member

Choose a reason for hiding this comment

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

maybe provide DT based macros to avoid usage of DT_DRV_INST, maybe to define as well, e.g.

CAN_MCAN_CONFIG_DT_INST_DEFINE(n, &mcux_can_config_##n);

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I had initially added inst variants as the only variants, but decided to go for a more generic node_id approach. I have added both now and (re-)named them to reflect the DT part.

Add shared initializer macros for struct can_mcan_config and struct
can_mcan_data.

Signed-off-by: Henrik Brix Andersen <[email protected]>
@henrikbrixandersen
Copy link
Member Author

@alexanderwachter, @martinjaeger et al: please take a look.

@carlescufi carlescufi merged commit 41a77be into zephyrproject-rtos:main May 3, 2022
@henrikbrixandersen henrikbrixandersen deleted the can_mcan_refactoring branch May 4, 2022 11:29
@nandojve nandojve added this to the v3.1.0 milestone May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: CAN area: Devicetree platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) platform: NXP NXP platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants