Skip to content

Commit 1ea737e

Browse files
committed
drivers: video: Use endpoint DT helpers
Drop the driver-defined macros to use the endpoint DT helpers instead. Signed-off-by: Phi Bang Nguyen <[email protected]>
1 parent 6c08072 commit 1ea737e

File tree

3 files changed

+6
-45
lines changed

3 files changed

+6
-45
lines changed

drivers/video/video_emul_rx.c

+2-25
Original file line numberDiff line numberDiff line change
@@ -294,33 +294,10 @@ int emul_rx_init(const struct device *dev)
294294
return 0;
295295
}
296296

297-
/* See #80649 */
298-
299-
/* Handle the variability of "ports{port@0{}};" vs "port{};" while going down */
300-
#define DT_INST_PORT_BY_ID(inst, pid) \
301-
COND_CODE_1(DT_NODE_EXISTS(DT_INST_CHILD(inst, ports)), \
302-
(DT_CHILD(DT_INST_CHILD(inst, ports), port_##pid)), \
303-
(DT_INST_CHILD(inst, port)))
304-
305-
/* Handle the variability of "endpoint@0{};" vs "endpoint{};" while going down */
306-
#define DT_INST_ENDPOINT_BY_ID(inst, pid, eid) \
307-
COND_CODE_1(DT_NODE_EXISTS(DT_CHILD(DT_INST_PORT_BY_ID(inst, pid), endpoint)), \
308-
(DT_CHILD(DT_INST_PORT_BY_ID(inst, pid), endpoint)), \
309-
(DT_CHILD(DT_INST_PORT_BY_ID(inst, pid), endpoint_##eid)))
310-
311-
/* Handle the variability of "ports{port@0{}};" vs "port{};" while going up */
312-
#define DT_ENDPOINT_PARENT_DEVICE(node) \
313-
COND_CODE_1(DT_NODE_EXISTS(DT_CHILD(DT_GPARENT(node), port)), \
314-
(DT_GPARENT(node)), (DT_PARENT(DT_GPARENT(node))))
315-
316-
/* Handle the "remote-endpoint-label" */
317-
#define DEVICE_DT_GET_REMOTE_DEVICE(node) \
318-
DEVICE_DT_GET(DT_ENDPOINT_PARENT_DEVICE( \
319-
DT_NODELABEL(DT_STRING_TOKEN(node, remote_endpoint_label))))
320-
321297
#define EMUL_RX_DEFINE(n) \
322298
static const struct emul_rx_config emul_rx_cfg_##n = { \
323-
.source_dev = DEVICE_DT_GET_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0)), \
299+
.source_dev = \
300+
DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 0, 0))), \
324301
}; \
325302
\
326303
static struct emul_rx_data emul_rx_data_##n = { \

drivers/video/video_mcux_csi.c

+1-11
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
#include <fsl_cache.h>
1919
#endif
2020

21-
#if defined(CONFIG_VIDEO_MCUX_MIPI_CSI2RX)
22-
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
23-
DEVICE_DT_GET(DT_PARENT(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
24-
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label)))))
25-
#else
26-
#define DEVICE_DT_INST_GET_SOURCE_DEV(n) \
27-
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL(DT_STRING_TOKEN( \
28-
DT_CHILD(DT_INST_CHILD(n, port), endpoint), remote_endpoint_label))))
29-
#endif
30-
3121
struct video_mcux_csi_config {
3222
CSI_Type *base;
3323
const struct device *source_dev;
@@ -502,7 +492,7 @@ PINCTRL_DT_INST_DEFINE(0);
502492

503493
static const struct video_mcux_csi_config video_mcux_csi_config_0 = {
504494
.base = (CSI_Type *)DT_INST_REG_ADDR(0),
505-
.source_dev = DEVICE_DT_INST_GET_SOURCE_DEV(0),
495+
.source_dev = DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(0, 0, 0))),
506496
.pincfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
507497
};
508498

drivers/video/video_mcux_mipi_csi2rx.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ LOG_MODULE_REGISTER(video_mipi_csi2rx, CONFIG_VIDEO_LOG_LEVEL);
2121

2222
#define ABS(a, b) (a > b ? a - b : b - a)
2323

24-
#define DEVICE_DT_INST_GET_SENSOR_DEV(n) \
25-
DEVICE_DT_GET(DT_GPARENT(DT_NODELABEL( \
26-
DT_STRING_TOKEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
27-
remote_endpoint_label))))
28-
2924
struct mipi_csi2rx_config {
3025
const MIPI_CSI2RX_Type *base;
3126
const struct device *sensor_dev;
@@ -349,9 +344,7 @@ static int mipi_csi2rx_init(const struct device *dev)
349344

350345
#define MIPI_CSI2RX_INIT(n) \
351346
static struct mipi_csi2rx_data mipi_csi2rx_data_##n = { \
352-
.csi2rxConfig.laneNum = \
353-
DT_PROP_LEN(DT_CHILD(DT_CHILD(DT_INST_CHILD(n, ports), port_1), endpoint), \
354-
data_lanes), \
347+
.csi2rxConfig.laneNum = DT_PROP_LEN(DT_INST_ENDPOINT_BY_ID(n, 1, 0), data_lanes), \
355348
.clock_dev = DEVICE_DT_GET(DT_INST_CLOCKS_CTLR(n)), \
356349
.clock_root = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 0, name), \
357350
.clock_ui = (clock_control_subsys_t)DT_INST_CLOCKS_CELL_BY_IDX(n, 1, name), \
@@ -360,7 +353,8 @@ static int mipi_csi2rx_init(const struct device *dev)
360353
\
361354
static const struct mipi_csi2rx_config mipi_csi2rx_config_##n = { \
362355
.base = (MIPI_CSI2RX_Type *)DT_INST_REG_ADDR(n), \
363-
.sensor_dev = DEVICE_DT_INST_GET_SENSOR_DEV(n), \
356+
.sensor_dev = \
357+
DEVICE_DT_GET(DT_NODE_REMOTE_DEVICE(DT_INST_ENDPOINT_BY_ID(n, 1, 0))), \
364358
}; \
365359
\
366360
DEVICE_DT_INST_DEFINE(n, &mipi_csi2rx_init, NULL, &mipi_csi2rx_data_##n, \

0 commit comments

Comments
 (0)