]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: arm_scmi: Replace the use of of_node_put() to __free(device_node)
authorSudeep Holla <sudeep.holla@arm.com>
Tue, 27 Aug 2024 14:38:37 +0000 (15:38 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Wed, 28 Aug 2024 16:16:25 +0000 (17:16 +0100)
Use __free for device_node values, and thus drop calls to of_node_put.

The goal is simplify of_node reference cleanup by using this scope-based
of_node_put() cleanup to simplify function exit handling. When using __free
a resource is allocated within a block, it is automatically freed at the
end of the block.

This cleanup aligns well with the recent change in shmem.c to use __free
instead of explicit of_node_put() calls.

Message-Id: <20240827143838.1465913-3-sudeep.holla@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/transports/mailbox.c
drivers/firmware/arm_scmi/transports/smc.c

index 9d258f5d5da8f5cd0cada0f3a5f41f3f1eb1bddf..1a754dee24f73026c289e446407cb9da187e55de 100644 (file)
@@ -129,18 +129,16 @@ static int mailbox_chan_validate(struct device *cdev, int *a2p_rx_chan,
 
        /* Bail out if provided shmem descriptors do not refer distinct areas  */
        if (num_sh > 1) {
-               struct device_node *np_tx, *np_rx;
+               struct device_node *np_tx __free(device_node) =
+                                       of_parse_phandle(np, "shmem", 0);
+               struct device_node *np_rx __free(device_node) =
+                                       of_parse_phandle(np, "shmem", 1);
 
-               np_tx = of_parse_phandle(np, "shmem", 0);
-               np_rx = of_parse_phandle(np, "shmem", 1);
                if (!np_tx || !np_rx || np_tx == np_rx) {
                        dev_warn(cdev, "Invalid shmem descriptor for '%s'\n",
                                 of_node_full_name(np));
                        ret = -EINVAL;
                }
-
-               of_node_put(np_tx);
-               of_node_put(np_rx);
        }
 
        /* Calculate channels IDs to use depending on mboxes/shmem layout */
index 2ffed5280eab26f6d932cd23cfb7ec7075e2f12e..f8dd108777f9b9aa67ef5f336da9d67db45ba89e 100644 (file)
@@ -84,12 +84,11 @@ static irqreturn_t smc_msg_done_isr(int irq, void *data)
 
 static bool smc_chan_available(struct device_node *of_node, int idx)
 {
-       struct device_node *np = of_parse_phandle(of_node, "shmem", 0);
-
+       struct device_node *np __free(device_node) =
+                                       of_parse_phandle(of_node, "shmem", 0);
        if (!np)
                return false;
 
-       of_node_put(np);
        return true;
 }