-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: smbus: fix multiple errors #99128
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?
drivers: smbus: fix multiple errors #99128
Conversation
de7a7c2 to
ced7dc5
Compare
The smbus driver initialization priority was previously set to `KERNEL_INIT_PRIORITY_DEFAULT` (which is 40). However, the default init priority of devices is typically `KERNEL_INIT_PRIORITY_DEVICE` (which is 50). Since the stm32 smbus driver uses a reference to the underlying i2c device, and since this driver was not being built in CI, this led to the discovery that the smbus driver was initialized too early. ```shell ERROR: Device initialization priority validation failed, the sequence of \ initialization calls does not match the devicetree dependencies. ERROR: /smbus1 <smbus_stm32_init> is initialized before its dependency \ /soc/i2c@40005400 <i2c_stm32_init> (POST_KERNEL+1 < POST_KERNEL+4) ``` By setting the initialization priority to `KERNEL_INIT_PRIORITY_DEVICE`, both smbus1 and i2c1 have their priorities evaluated in the same group, and it becomes possible to determine relative priorities via phandle dependency. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Previously, the function `smbus_stm32_pcall()` implicitly cast
`uint16_t *` to `uint8_t *`. Add an explicit cast to avoid warning.
```shell
..drivers/smbus/smbus_stm32.c:358:32: error: initialization of \
'uint8_t *' {aka 'unsigned char *'} from incompatible pointer type \
'uint16_t *' {aka 'short unsigned int *'} \
[-Werror=incompatible-pointer-types]
358 | .buf = &send_word,
| ^
..drivers/smbus/smbus_stm32.c:358:32: note: (near initialization \
for 'messages[1].buf')
..drivers/smbus/smbus_stm32.c:363:32: error: initialization of \
'uint8_t *' {aka 'unsigned char *'} from incompatible pointer type \
'uint16_t *' {aka 'short unsigned int *'} \
[-Werror=incompatible-pointer-types]
363 | .buf = recv_word,
| ^~~~~~~~~
```
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
To ensure that code compiles error (and warning) free, add a build-all testsuite for smbus drivers. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
ced7dc5 to
6960ac6
Compare
|
|
Adding the 4.3.0 milestone to this, since a regression was added during the stabilization period, since the change itself is quite self-contained, since it fixes multiple bugs, and since it improves stability. |
|
Will determine at the release meeting if this is a "release blocker" and whether it will actually go in to the 4.3.0 release. |



This change fixes multiple errors in in the SMBus area.
CONFIG_KERNEL_INIT_PRIORITY_DEVICEWithout the first fix:
$ twister -i -c -p nucleo_g071rb -T tests/drivers/build_all/smbus/ ... Memory region Used Size Region Size %age Used FLASH: 83416 B 128 KB 63.64% RAM: 11 KB 36 KB 30.56% SRAM0: 0 GB 36 KB 0.00% IDT_LIST: 0 GB 32 KB 0.00% Generating files from ZEPHYR_BASE/twister-out/nucleo_g071rb_stm32g071xx/zephyr/tests/drivers/build_all/smbus/drivers.smbus.build.stm32/zephyr/zephyr.elf for board: nucleo_g071rb ERROR: Device initialization priority validation failed, the sequence of initialization calls does not match the devicetree dependencies. ERROR: /smbus1 <smbus_stm32_init> is initialized before its dependency /soc/i2c@40005400 <i2c_stm32_init> (POST_KERNEL+1 < POST_KERNEL+4) ninja: build stopped: subcommand failed. ...Without the second fix:
Testing done:
Fixes #99129
Fixes #99130
Fixes #99131