-
Notifications
You must be signed in to change notification settings - Fork 7.8k
drivers: video: emul_rx: hotfix: force use of constant value #88890
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
drivers: video: emul_rx: hotfix: force use of constant value #88890
Conversation
Trying on latest
The hotfix is still expected to address the error as uses the value from devicetree rather than the previously declared |
I think you need to enable some specific compiler flag for it to appear. |
Can you add more details ? I couldn't reproduce the error on my side. |
@JarmouniA good point, different flags for west build and west twister it seems.
|
It looks like the hotfix works: Before:
After:
|
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.
Marked as request-changes for now as we needs to do the same for other drivers even if it's a needed fix. But I believe this is a clang issue and already fixed in LLVM newer versions as stated in #54826 unless someone proves that this is not.
In Clang 16 run with some flags, the compiler does not accept a static const variables as struct initializer. This caused build errors in only some contexts. Always use the devicetree macros to access the source device node as a workaround. Signed-off-by: Josuah Demangeon <[email protected]>
e6dfdfe
to
f2e8156
Compare
@josuah: Thanks for adding other drivers into the PR. But do you see it is fixed in newer LLVM versions (I don't have problem using Zephyr SDK) and think it is a clang issue ? |
I confirm, it works with Testing on current Fails:
Works:
full logs
|
So, do we need to fix ? if yes, it's ok for me. |
So this fixes for clang-18 but keeps clang-16 failing, right? |
@@ -282,6 +283,6 @@ int emul_rx_init(const struct device *dev) | |||
DEVICE_DT_INST_DEFINE(n, &emul_rx_init, NULL, &emul_rx_data_##n, &emul_rx_cfg_##n, \ | |||
POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY, &emul_rx_driver_api); \ | |||
\ | |||
VIDEO_DEVICE_DEFINE(emul_rx_##n, DEVICE_DT_INST_GET(n), emul_rx_cfg_##n.source_dev); | |||
VIDEO_DEVICE_DEFINE(emul_rx_##n, DEVICE_DT_INST_GET(n), SOURCE_DEV(n)); |
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.
Regardless of this being an LLVM issue or not, to me it makes perfect sense to use the DT value here directly, instead of passing it with a struct field.
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.
No clean-up commit needed after it gets merged, then. 👍
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.
Ok.
Glad you asked, that was unclear.
|
#define NXP_VIDEO_SDMA_INIT(inst) \ | ||
PINCTRL_DT_INST_DEFINE(inst); \ | ||
const struct nxp_video_sdma_config sdma_config_##inst = { \ | ||
.dma_dev = DEVICE_DT_GET(DT_INST_PARENT(inst)), \ | ||
.sensor_dev = DEVICE_DT_GET(DT_INST_PHANDLE(inst, sensor)), \ | ||
.sensor_dev = SOURCE_DEV(n), \ |
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.
This should be .sensor_dev = SOURCE_DEV(inst)
. CI didn't detect this failure because smartdma driver does not have a built-in test. I will fix this in #88323.
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.
I checked not thoroughly enough. Thank you for the vigilance.
Checking again, the others drivers not have this mismatch.
In some compilation attempts, the compiler did not accept a static const variable as initializer. This caused build errors in only some contexts. Always use the devicetree macros to access it.
Note: this has not yet been tested: PR open to check if it fixes it in the actual Zephyr CI