Skip to content

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions drivers/video/video_emul_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,11 @@ int emul_rx_init(const struct device *dev)
return 0;
}

#define SOURCE_DEV(n) DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0)))

#define EMUL_RX_DEFINE(n) \
static const struct emul_rx_config emul_rx_cfg_##n = { \
.source_dev = \
DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0))), \
.source_dev = SOURCE_DEV(n), \
}; \
\
static struct emul_rx_data emul_rx_data_##n = { \
Expand All @@ -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));
Copy link
Contributor

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.

Copy link
Contributor Author

@josuah josuah Apr 22, 2025

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. 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok.


DT_INST_FOREACH_STATUS_OKAY(EMUL_RX_DEFINE)
6 changes: 4 additions & 2 deletions drivers/video/video_esp32_dvp.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,11 @@ static DEVICE_API(video, esp32_driver_api) = {

PINCTRL_DT_INST_DEFINE(0);

#define SOURCE_DEV(n) DEVICE_DT_GET(DT_INST_PHANDLE(n, source))

static const struct video_esp32_config esp32_config = {
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
.source_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, source)),
.source_dev = SOURCE_DEV(0),
.dma_dev = ESP32_DT_INST_DMA_CTLR(0, rx),
.rx_dma_channel = DT_INST_DMAS_CELL_BY_NAME(0, rx, channel),
.data_width = DT_INST_PROP_OR(0, data_width, 8),
Expand All @@ -450,7 +452,7 @@ static struct video_esp32_data esp32_data = {0};
DEVICE_DT_INST_DEFINE(0, video_esp32_init, NULL, &esp32_data, &esp32_config, POST_KERNEL,
CONFIG_VIDEO_INIT_PRIORITY, &esp32_driver_api);

VIDEO_DEVICE_DEFINE(esp32, DEVICE_DT_INST_GET(0), esp32_config.source_dev);
VIDEO_DEVICE_DEFINE(esp32, DEVICE_DT_INST_GET(0), SOURCE_DEV(0));

static int video_esp32_cam_init_master_clock(void)
{
Expand Down
6 changes: 4 additions & 2 deletions drivers/video/video_mcux_csi.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,11 @@ static DEVICE_API(video, video_mcux_csi_driver_api) = {
#if 1 /* Unique Instance */
PINCTRL_DT_INST_DEFINE(0);

#define SOURCE_DEV(n) DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0)))

static const struct video_mcux_csi_config video_mcux_csi_config_0 = {
.base = (CSI_Type *)DT_INST_REG_ADDR(0),
.source_dev = DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(0, 0, 0))),
.source_dev = SOURCE_DEV(0),
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
};

Expand All @@ -481,6 +483,6 @@ DEVICE_DT_INST_DEFINE(0, &video_mcux_csi_init_0, NULL, &video_mcux_csi_data_0,
&video_mcux_csi_config_0, POST_KERNEL, CONFIG_VIDEO_MCUX_CSI_INIT_PRIORITY,
&video_mcux_csi_driver_api);

VIDEO_DEVICE_DEFINE(csi, DEVICE_DT_INST_GET(0), video_mcux_csi_config_0.source_dev);
VIDEO_DEVICE_DEFINE(csi, DEVICE_DT_INST_GET(0), SOURCE_DEV(0));

#endif
8 changes: 4 additions & 4 deletions drivers/video/video_mcux_mipi_csi2rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ static int mipi_csi2rx_init(const struct device *dev)
return mipi_csi2rx_update_settings(dev, VIDEO_EP_ALL);
}

#define SOURCE_DEV(n) DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 1, 0)))

#define MIPI_CSI2RX_INIT(n) \
static struct mipi_csi2rx_data mipi_csi2rx_data_##n = { \
.csi2rxConfig.laneNum = DT_PROP_LEN(DT_INST_ENDPOINT_BY_ID(n, 1, 0), data_lanes), \
Expand All @@ -331,15 +333,13 @@ static int mipi_csi2rx_init(const struct device *dev)
\
static const struct mipi_csi2rx_config mipi_csi2rx_config_##n = { \
.base = (MIPI_CSI2RX_Type *)DT_INST_REG_ADDR(n), \
.sensor_dev = \
DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 1, 0))), \
.sensor_dev = SOURCE_DEV(n), \
}; \
\
DEVICE_DT_INST_DEFINE(n, &mipi_csi2rx_init, NULL, &mipi_csi2rx_data_##n, \
&mipi_csi2rx_config_##n, POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY, \
&mipi_csi2rx_driver_api); \
\
VIDEO_DEVICE_DEFINE(mipi_csi2rx_##n, DEVICE_DT_INST_GET(n), \
mipi_csi2rx_config_##n.sensor_dev);
VIDEO_DEVICE_DEFINE(mipi_csi2rx_##n, DEVICE_DT_INST_GET(n), SOURCE_DEV(n));

DT_INST_FOREACH_STATUS_OKAY(MIPI_CSI2RX_INIT)
6 changes: 4 additions & 2 deletions drivers/video/video_mcux_smartdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,13 @@ static DEVICE_API(video, nxp_video_sdma_api) = {
.flush = nxp_video_sdma_flush
};

#define SOURCE_DEV(inst) DEVICE_DT_GET(DT_INST_PHANDLE(inst, sensor))

#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), \
Copy link
Contributor

@ngphibang ngphibang Apr 23, 2025

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.

Copy link
Contributor Author

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.

.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
.vsync_pin = DT_INST_PROP(inst, vsync_pin), \
.hsync_pin = DT_INST_PROP(inst, hsync_pin), \
Expand All @@ -383,6 +385,6 @@ static DEVICE_API(video, nxp_video_sdma_api) = {
&sdma_config_##inst, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &nxp_video_sdma_api); \
\
VIDEO_DEVICE_DEFINE(sdma_##inst, DEVICE_DT_INST_GET(inst), sdma_config_##inst.sensor_dev);
VIDEO_DEVICE_DEFINE(sdma_##inst, DEVICE_DT_INST_GET(inst), SOURCE_DEV(inst));

DT_INST_FOREACH_STATUS_OKAY(NXP_VIDEO_SDMA_INIT)
6 changes: 4 additions & 2 deletions drivers/video/video_stm32_dcmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,16 @@ static struct video_stm32_dcmi_data video_stm32_dcmi_data_0 = {
},
};

#define SOURCE_DEV(n) DEVICE_DT_GET(DT_INST_PHANDLE(n, sensor))

static const struct video_stm32_dcmi_config video_stm32_dcmi_config_0 = {
.pclken = {
.enr = DT_INST_CLOCKS_CELL(0, bits),
.bus = DT_INST_CLOCKS_CELL(0, bus)
},
.irq_config = video_stm32_dcmi_irq_config_func,
.pctrl = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
.sensor_dev = DEVICE_DT_GET(DT_INST_PHANDLE(0, sensor)),
.sensor_dev = SOURCE_DEV(0),
DCMI_DMA_CHANNEL(0, PERIPHERAL, MEMORY)
};

Expand Down Expand Up @@ -500,4 +502,4 @@ DEVICE_DT_INST_DEFINE(0, &video_stm32_dcmi_init,
POST_KERNEL, CONFIG_VIDEO_INIT_PRIORITY,
&video_stm32_dcmi_driver_api);

VIDEO_DEVICE_DEFINE(dcmi, DEVICE_DT_INST_GET(0), video_stm32_dcmi_config_0.sensor_dev);
VIDEO_DEVICE_DEFINE(dcmi, DEVICE_DT_INST_GET(0), SOURCE_DEV(0));