Commit a7456d7d authored by Zhang Zekun's avatar Zhang Zekun Committed by Daniel Lezcano

clocksource/drivers/arm_arch_timer: Using for_each_available_child_of_node_scoped()

for_each_available_child_of_node_scoped() can put the device_node
automatically. So, using it to make the code logic more simple and
remove the device_node clean up code.
Signed-off-by: default avatarZhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240807074655.52157-1-zhangzekun11@huawei.comSigned-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
parent 0c872820
...@@ -1594,7 +1594,6 @@ static int __init arch_timer_mem_of_init(struct device_node *np) ...@@ -1594,7 +1594,6 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
{ {
struct arch_timer_mem *timer_mem; struct arch_timer_mem *timer_mem;
struct arch_timer_mem_frame *frame; struct arch_timer_mem_frame *frame;
struct device_node *frame_node;
struct resource res; struct resource res;
int ret = -EINVAL; int ret = -EINVAL;
u32 rate; u32 rate;
...@@ -1608,33 +1607,29 @@ static int __init arch_timer_mem_of_init(struct device_node *np) ...@@ -1608,33 +1607,29 @@ static int __init arch_timer_mem_of_init(struct device_node *np)
timer_mem->cntctlbase = res.start; timer_mem->cntctlbase = res.start;
timer_mem->size = resource_size(&res); timer_mem->size = resource_size(&res);
for_each_available_child_of_node(np, frame_node) { for_each_available_child_of_node_scoped(np, frame_node) {
u32 n; u32 n;
struct arch_timer_mem_frame *frame; struct arch_timer_mem_frame *frame;
if (of_property_read_u32(frame_node, "frame-number", &n)) { if (of_property_read_u32(frame_node, "frame-number", &n)) {
pr_err(FW_BUG "Missing frame-number.\n"); pr_err(FW_BUG "Missing frame-number.\n");
of_node_put(frame_node);
goto out; goto out;
} }
if (n >= ARCH_TIMER_MEM_MAX_FRAMES) { if (n >= ARCH_TIMER_MEM_MAX_FRAMES) {
pr_err(FW_BUG "Wrong frame-number, only 0-%u are permitted.\n", pr_err(FW_BUG "Wrong frame-number, only 0-%u are permitted.\n",
ARCH_TIMER_MEM_MAX_FRAMES - 1); ARCH_TIMER_MEM_MAX_FRAMES - 1);
of_node_put(frame_node);
goto out; goto out;
} }
frame = &timer_mem->frame[n]; frame = &timer_mem->frame[n];
if (frame->valid) { if (frame->valid) {
pr_err(FW_BUG "Duplicated frame-number.\n"); pr_err(FW_BUG "Duplicated frame-number.\n");
of_node_put(frame_node);
goto out; goto out;
} }
if (of_address_to_resource(frame_node, 0, &res)) { if (of_address_to_resource(frame_node, 0, &res))
of_node_put(frame_node);
goto out; goto out;
}
frame->cntbase = res.start; frame->cntbase = res.start;
frame->size = resource_size(&res); frame->size = resource_size(&res);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment