mirror of
https://github.com/torvalds/linux.git
synced 2026-06-02 03:24:19 +02:00
media: samsung: exynos4-is: Use for_each_available_child_of_node_scoped()
Avoids the need for manual cleanup of_node_put() in early exits from the loop. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
This commit is contained in:
parent
377cc006a3
commit
d2c063388d
|
|
@ -482,15 +482,12 @@ static int fimc_md_parse_one_endpoint(struct fimc_md *fmd,
|
|||
static int fimc_md_parse_port_node(struct fimc_md *fmd,
|
||||
struct device_node *port)
|
||||
{
|
||||
struct device_node *ep;
|
||||
int ret;
|
||||
|
||||
for_each_child_of_node(port, ep) {
|
||||
for_each_child_of_node_scoped(port, ep) {
|
||||
ret = fimc_md_parse_one_endpoint(fmd, ep);
|
||||
if (ret < 0) {
|
||||
of_node_put(ep);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -501,7 +498,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
|
|||
{
|
||||
struct device_node *parent = fmd->pdev->dev.of_node;
|
||||
struct device_node *ports = NULL;
|
||||
struct device_node *node;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
|
|
@ -518,7 +514,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
|
|||
fmd->num_sensors = 0;
|
||||
|
||||
/* Attach sensors linked to MIPI CSI-2 receivers */
|
||||
for_each_available_child_of_node(parent, node) {
|
||||
for_each_available_child_of_node_scoped(parent, node) {
|
||||
struct device_node *port;
|
||||
|
||||
if (!of_node_name_eq(node, "csis"))
|
||||
|
|
@ -530,10 +526,8 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
|
|||
|
||||
ret = fimc_md_parse_port_node(fmd, port);
|
||||
of_node_put(port);
|
||||
if (ret < 0) {
|
||||
of_node_put(node);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
/* Attach sensors listed in the parallel-ports node */
|
||||
|
|
@ -541,12 +535,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
|
|||
if (!ports)
|
||||
goto rpm_put;
|
||||
|
||||
for_each_child_of_node(ports, node) {
|
||||
for_each_child_of_node_scoped(ports, node) {
|
||||
ret = fimc_md_parse_port_node(fmd, node);
|
||||
if (ret < 0) {
|
||||
of_node_put(node);
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
of_node_put(ports);
|
||||
|
||||
|
|
@ -736,10 +728,9 @@ static int fimc_md_register_platform_entity(struct fimc_md *fmd,
|
|||
static int fimc_md_register_platform_entities(struct fimc_md *fmd,
|
||||
struct device_node *parent)
|
||||
{
|
||||
struct device_node *node;
|
||||
int ret = 0;
|
||||
|
||||
for_each_available_child_of_node(parent, node) {
|
||||
for_each_available_child_of_node_scoped(parent, node) {
|
||||
struct platform_device *pdev;
|
||||
int plat_entity = -1;
|
||||
|
||||
|
|
@ -762,10 +753,8 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
|
|||
ret = fimc_md_register_platform_entity(fmd, pdev,
|
||||
plat_entity);
|
||||
put_device(&pdev->dev);
|
||||
if (ret < 0) {
|
||||
of_node_put(node);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user