Skip to content

Conversation

@JarmouniA
Copy link
Contributor

Similar to #90402

timings is an array of struct i2c_config_timing (3 x uint32_t). i2c_timings_##index is an array of uint32_t (hence the cast when it is assigned to timings). Therefore ARRAY_SIZE(i2c_timings_##index) is off by a factor of 3 when used for n_timings.

'timings' is an array of 'struct i2c_config_timing' (3 x uint32_t).
'i2c_timings_##index' is an array of uint32_t (hence the cast when it
is assigned to 'timings'). Therefore 'ARRAY_SIZE(i2c_timings_##index)' is
off by a factor 3 when used for n_timings.

Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
@JarmouniA JarmouniA added bug The issue is a bug, or the PR is fixing a bug area: I2C platform: STM32 ST Micro STM32 area: RTIO labels May 29, 2025
@JarmouniA JarmouniA linked an issue May 29, 2025 that may be closed by this pull request
@sonarqubecloud
Copy link

Copy link
Contributor

@teburd teburd left a comment

Choose a reason for hiding this comment

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

This should likely be done in a common config struct for all driver variants, but the change is small here and likely fixing a bug?

@JarmouniA
Copy link
Contributor Author

likely fixing a bug

@teburd Yes, #90691

@erwango
Copy link
Member

erwango commented Jun 6, 2025

This should likely be done in a common config struct for all driver variants, but the change is small here and likely fixing a bug?

Indeed, this is for this king of issues I asked for refactoring of the RTIO introduction PR before it was merged.

@kartben kartben merged commit b31251b into zephyrproject-rtos:main Jun 6, 2025
40 checks passed
@JarmouniA JarmouniA deleted the fix_stm32_i2c_timings_array_size branch June 6, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: I2C area: RTIO bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: stm32 i2c: incorrect size of timings array

6 participants