Messages in this thread Patch in this message | ![/](/images/icornerl.gif) | | From | Wenyu Huang <> | Subject | [drivers/virt] Eliminate uses of of_node_put | Date | Sun, 7 Apr 2024 10:22:12 -0400 |
| |
Convert the DT code to use __free() based cleanups for of_node_put(). Using __free() simplifies function exit handling.
Signed-off-by: Wenyu Huang <huangwenyuu@outlook.com> --- drivers/virt/fsl_hypervisor.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c index e92e2ceb12a4..5a5c7a767a98 100644 --- a/drivers/virt/fsl_hypervisor.c +++ b/drivers/virt/fsl_hypervisor.c @@ -725,12 +725,11 @@ static irqreturn_t fsl_hv_shutdown_isr(int irq, void *data) */ static int get_parent_handle(struct device_node *np) { - struct device_node *parent; + struct device_node *parent __free(device_node) = of_get_parent(np); const uint32_t *prop; uint32_t handle; int len; - parent = of_get_parent(np); if (!parent) /* It's not really possible for this to fail */ return -ENODEV; @@ -745,12 +744,10 @@ static int get_parent_handle(struct device_node *np) if (!prop || (len != sizeof(uint32_t))) { /* This can happen only if the node is malformed */ - of_node_put(parent); return -ENODEV; } handle = be32_to_cpup(prop); - of_node_put(parent); return handle; } @@ -789,17 +786,14 @@ EXPORT_SYMBOL(fsl_hv_failover_unregister); */ static int has_fsl_hypervisor(void) { - struct device_node *node; + struct device_node *node __free(device_node) = of_find_node_by_path("/hypervisor"); int ret; - node = of_find_node_by_path("/hypervisor"); if (!node) return 0; ret = of_property_present(node, "fsl,hv-version"); - of_node_put(node); - return ret; } -- 2.34.1
| ![\](/images/icornerr.gif) |