05c82dbf6f560a63441e7b35fffddf316e55b44d
[openwrt/staging/xback.git] /
1 From 5fecb932607d83d37a703c731268e9d9051457f5 Mon Sep 17 00:00:00 2001
2 From: MarileneGarcia <marilene.agarcia@gmail.com>
3 Date: Fri, 5 Jul 2024 08:48:40 +0100
4 Subject: [PATCH] nvmem: meson-efuse: Replacing the use of of_node_put to
5 __free
6
7 Use __free for device_node values, and thus drop calls to
8 of_node_put.
9
10 The goal is to reduce memory management issues by using this
11 scope-based of_node_put() cleanup to simplify function exit
12 handling. When using __free a resource is allocated within a
13 block, it is automatically freed at the end of the block.
14
15 Suggested-by: Julia Lawall <julia.lawall@inria.fr>
16 Signed-off-by: MarileneGarcia <marilene.agarcia@gmail.com>
17 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
18 Link: https://lore.kernel.org/r/20240705074852.423202-4-srinivas.kandagatla@linaro.org
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 ---
21 drivers/nvmem/meson-efuse.c | 5 ++---
22 1 file changed, 2 insertions(+), 3 deletions(-)
23
24 --- a/drivers/nvmem/meson-efuse.c
25 +++ b/drivers/nvmem/meson-efuse.c
26 @@ -48,20 +48,19 @@ static int meson_efuse_probe(struct plat
27 {
28 struct device *dev = &pdev->dev;
29 struct meson_sm_firmware *fw;
30 - struct device_node *sm_np;
31 struct nvmem_device *nvmem;
32 struct nvmem_config *econfig;
33 struct clk *clk;
34 unsigned int size;
35 + struct device_node *sm_np __free(device_node) =
36 + of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0);
37
38 - sm_np = of_parse_phandle(pdev->dev.of_node, "secure-monitor", 0);
39 if (!sm_np) {
40 dev_err(&pdev->dev, "no secure-monitor node\n");
41 return -ENODEV;
42 }
43
44 fw = meson_sm_get(sm_np);
45 - of_node_put(sm_np);
46 if (!fw)
47 return -EPROBE_DEFER;
48