media: Use of_node_name_eq for node name comparisons
Subsystems (5)
PATCH 1/1 media: Use of_node_name_eq for node name comparisons
Convert string compares of DT node names to use of_node_name_eq helper instead. This removes direct access to the node name pointer.
--- drivers/media/platform/exynos4-is/media-dev.c | 12 ++++++------ drivers/media/platform/ti-vpe/cal.c | 4 ++-- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +6 -6
@@ -445,7 +445,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,*/ np =of_get_parent (rem); -if (np && !of_node_cmp (np->name,"i2c-isp" )) +if (of_node_name_eq (np,"i2c-isp" )) pd->fimc_bus_type =FIMC_BUS_TYPE_ISP_WRITEBACK ;else pd->fimc_bus_type = pd->sensor_bus_type;
@@ -495,7 +495,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)for_each_available_child_of_node (parent, node) {struct device_node *port; -if (of_node_cmp (node->name,"csis" )) +if (!of_node_name_eq (node,"csis" ))continue ;/* The csis node can have only port subnode. */ port =of_get_next_child (node,NULL );
@@ -720,13 +720,13 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,continue ;/* If driver of any entity isn't ready try all again later. */ -if (!strcmp (node->name,CSIS_OF_NODE_NAME )) +if (of_node_name_eq (node,CSIS_OF_NODE_NAME )) plat_entity =IDX_CSIS ; -else if (!strcmp (node->name,FIMC_IS_OF_NODE_NAME )) +else if (of_node_name_eq (node,FIMC_IS_OF_NODE_NAME )) plat_entity =IDX_IS_ISP ; -else if (!strcmp (node->name,FIMC_LITE_OF_NODE_NAME )) +else if (of_node_name_eq (node,FIMC_LITE_OF_NODE_NAME )) plat_entity =IDX_FLITE ; -else if (!strcmp (node->name,FIMC_OF_NODE_NAME ) && +else if (of_node_name_eq (node,FIMC_OF_NODE_NAME ) && !of_property_read_bool (node,"samsung,lcd-wb" )) plat_entity =IDX_FIMC ;
drivers/media/platform/ti-vpe/cal.c +2 -2
@@ -1615,7 +1615,7 @@ of_get_next_port(const struct device_node *parent,return NULL ; } prev = port; - }while (of_node_cmp (port->name,"port" ) !=0 ); + }while (!of_node_name_eq (port,"port" )); }return port;
@@ -1635,7 +1635,7 @@ of_get_next_endpoint(const struct device_node *parent,if (!ep)return NULL ; prev = ep; - }while (of_node_cmp (ep->name,"endpoint" ) !=0 ); + }while (!of_node_name_eq (ep,"endpoint" ));return ep; }
drivers/media/platform/xilinx/xilinx-tpg.c +1 -1
@@ -725,7 +725,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)const struct xvip_video_format *format;struct device_node *endpoint; -if (!port->name ||of_node_cmp (port->name,"port" )) +if (!of_node_name_eq (port,"port" ))continue ; format =xvip_of_get_format (port);
drivers/media/v4l2-core/v4l2-fwnode.c +2 -4
@@ -564,8 +564,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (__fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->local_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->local_node = fwnode;
@@ -578,8 +577,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->remote_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->remote_node = fwnode;
Signature · 1 line
2.19.1
Hi Rob,
Thank you for the patch.
Quoted 47 lines · On Wednesday, 5 December 2018 21:50:29 EET Rob Herring wrote:
Convert string compares of DT node names to use
of_node_name_eqhelper instead. This removes direct access to the node name pointer.Cc Kyungmin Park <[email protected]>Cc Sylwester Nawrocki <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Kukjin Kim <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Benoit Parrot <[email protected]>Cc Hyun Kwon <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Michal Simek <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 ++++++------ drivers/media/platform/ti-vpe/cal.c | 4 ++-- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/exynos4-is/media-dev.cindex870501b0f351..ced14af56606100644drivers/media/platform/exynos4-is/media-dev.c +2
-2@@ -445,7 +445,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,*/ np =of_get_parent (rem); -if (np && !of_node_cmp (np->name,"i2c-isp" )) +if (of_node_name_eq (np,"i2c-isp" )) pd->fimc_bus_type =FIMC_BUS_TYPE_ISP_WRITEBACK ;else pd->fimc_bus_type = pd->sensor_bus_type;@@ -495,7 +495,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) for_each_available_child_of_node(parent, node) {struct device_node *port; -if (of_node_cmp (node->name,"csis" )) +if (!of_node_name_eq (node,"csis" ))continue ;/* The csis node can have only port subnode. */ port =of_get_next_child (node,NULL );
drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_register_platform_entities(struct · line 725
Quoted 8 lines
drivers/media/platform/exynos4-is/media-dev.c +2
-2@@ -720,13 +720,13 @@ static int fimc_md_register_platform_entities(structfimc_md *fmd, continue;/* If driver of any entity isn't ready try all again later. */ -if (!strcmp (node->name,CSIS_OF_NODE_NAME )) +if (of_node_name_eq (node,CSIS_OF_NODE_NAME )) plat_entity =IDX_CSIS ; -else if (!strcmp (node->name,FIMC_IS_OF_NODE_NAME )) +else if (of_node_name_eq (node,FIMC_IS_OF_NODE_NAME ))
You might want to s/if\t/if / while at it.
drivers/media/platform/exynos4-is/media-dev.c static int fimc_md_register_platform_entities(struct fimc_md *fmd, · line 729
Quoted 6 lines
drivers/media/platform/exynos4-is/media-dev.c +2
-2plat_entity =IDX_IS_ISP ; - else if (!strcmp(node->name, FIMC_LITE_OF_NODE_NAME)) + else if (of_node_name_eq(node, FIMC_LITE_OF_NODE_NAME)) plat_entity =IDX_FLITE ; - else if (!strcmp(node->name, FIMC_OF_NODE_NAME) && + else if (of_node_name_eq(node, FIMC_OF_NODE_NAME) &&
And here too.
Apart from that,
Quoted 64 lines
drivers/media/platform/exynos4-is/media-dev.c +0
-0!of_property_read_bool(node, "samsung,lcd-wb")) plat_entity =IDX_FIMC ;(quoted diff) +0
-0
b/drivers/media/platform/ti-vpe/cal.cindex95a093f41905..fc3c212b96e1100644drivers/media/platform/ti-vpe/cal.c +2
-2@@ -1615,7 +1615,7 @@ of_get_next_port(const struct device_node *parent,return NULL ; } prev = port; - }while (of_node_cmp (port->name,"port" ) !=0 ); + }while (!of_node_name_eq (port,"port" )); }return port;@@ -1635,7 +1635,7 @@ of_get_next_endpoint(const struct device_node *parent,if (!ep)return NULL ; prev = ep; - }while (of_node_cmp (ep->name,"endpoint" ) !=0 ); + }while (!of_node_name_eq (ep,"endpoint" ));return ep; }(quoted diff) +0
-0
b/drivers/media/platform/xilinx/xilinx-tpg.cindex851d20dcd550..ce686b8d6cff100644drivers/media/platform/xilinx/xilinx-tpg.c +1
-1@@ -725,7 +725,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)const struct xvip_video_format *format;struct device_node *endpoint; -if (!port->name ||of_node_cmp (port->name,"port" )) +if (!of_node_name_eq (port,"port" ))continue ; format =xvip_of_get_format (port);(quoted diff) +0
-0
b/drivers/media/v4l2-core/v4l2-fwnode.cindex218f0da0ce76..849326241b17100644drivers/media/v4l2-core/v4l2-fwnode.c +2
-4@@ -564,8 +564,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (__fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->local_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->local_node = fwnode;@@ -578,8 +577,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->remote_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->remote_node = fwnode;
Signature · 3 lines
Regards, Laurent Pinchart
Hi Rob,
For ti-vpe/cal.c,
Regards,
Benoit
Rob Herring <[email protected]> wrote on Wed [2018-Dec-05 13:50:29 -0600]:
Quoted 125 lines
Convert string compares of DT node names to use
of_node_name_eqhelper instead. This removes direct access to the node name pointer.Cc Kyungmin Park <[email protected]>Cc Sylwester Nawrocki <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Kukjin Kim <[email protected]>Cc Krzysztof Kozlowski <[email protected]>Cc Benoit Parrot <[email protected]>Cc Hyun Kwon <[email protected]>Cc Laurent Pinchart <[email protected]>Cc Michal Simek <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/media/platform/exynos4-is/media-dev.c | 12 ++++++------ drivers/media/platform/ti-vpe/cal.c | 4 ++-- drivers/media/platform/xilinx/xilinx-tpg.c | 2 +- drivers/media/v4l2-core/v4l2-fwnode.c | 6 ++---- 4 files changed, 11 insertions(+), 13 deletions(-)drivers/media/platform/exynos4-is/media-dev.c +6
-6@@ -445,7 +445,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,*/ np =of_get_parent (rem); -if (np && !of_node_cmp (np->name,"i2c-isp" )) +if (of_node_name_eq (np,"i2c-isp" )) pd->fimc_bus_type =FIMC_BUS_TYPE_ISP_WRITEBACK ;else pd->fimc_bus_type = pd->sensor_bus_type;@@ -495,7 +495,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)for_each_available_child_of_node (parent, node) {struct device_node *port; -if (of_node_cmp (node->name,"csis" )) +if (!of_node_name_eq (node,"csis" ))continue ;/* The csis node can have only port subnode. */ port =of_get_next_child (node,NULL );@@ -720,13 +720,13 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,continue ;/* If driver of any entity isn't ready try all again later. */ -if (!strcmp (node->name,CSIS_OF_NODE_NAME )) +if (of_node_name_eq (node,CSIS_OF_NODE_NAME )) plat_entity =IDX_CSIS ; -else if (!strcmp (node->name,FIMC_IS_OF_NODE_NAME )) +else if (of_node_name_eq (node,FIMC_IS_OF_NODE_NAME )) plat_entity =IDX_IS_ISP ; -else if (!strcmp (node->name,FIMC_LITE_OF_NODE_NAME )) +else if (of_node_name_eq (node,FIMC_LITE_OF_NODE_NAME )) plat_entity =IDX_FLITE ; -else if (!strcmp (node->name,FIMC_OF_NODE_NAME ) && +else if (of_node_name_eq (node,FIMC_OF_NODE_NAME ) && !of_property_read_bool (node,"samsung,lcd-wb" )) plat_entity =IDX_FIMC ;drivers/media/platform/ti-vpe/cal.c +2
-2@@ -1615,7 +1615,7 @@ of_get_next_port(const struct device_node *parent,return NULL ; } prev = port; - }while (of_node_cmp (port->name,"port" ) !=0 ); + }while (!of_node_name_eq (port,"port" )); }return port;@@ -1635,7 +1635,7 @@ of_get_next_endpoint(const struct device_node *parent,if (!ep)return NULL ; prev = ep; - }while (of_node_cmp (ep->name,"endpoint" ) !=0 ); + }while (!of_node_name_eq (ep,"endpoint" ));return ep; }drivers/media/platform/xilinx/xilinx-tpg.c +1
-1@@ -725,7 +725,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)const struct xvip_video_format *format;struct device_node *endpoint; -if (!port->name ||of_node_cmp (port->name,"port" )) +if (!of_node_name_eq (port,"port" ))continue ; format =xvip_of_get_format (port);drivers/media/v4l2-core/v4l2-fwnode.c +2
-4@@ -564,8 +564,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (__fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->local_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->local_node = fwnode;@@ -578,8 +577,7 @@ int v4l2_fwnode_parse_link(struct fwnode_handle *__fwnode, fwnode =fwnode_get_parent (fwnode);fwnode_property_read_u32 (fwnode, port_prop, &link->remote_port); fwnode =fwnode_get_next_parent (fwnode); -if (is_of_node (fwnode) && -of_node_cmp (to_of_node (fwnode)->name,"ports" ) ==0 ) +if (is_of_node (fwnode) &&of_node_name_eq (to_of_node (fwnode),"ports" )) fwnode =fwnode_get_next_parent (fwnode); link->remote_node = fwnode;Signature · 1 line
2.19.1