]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: Use of_property_read_bool()
authorRob Herring (Arm) <robh@kernel.org>
Wed, 31 Jul 2024 19:16:00 +0000 (13:16 -0600)
committerJakub Kicinski <kuba@kernel.org>
Fri, 2 Aug 2024 01:15:18 +0000 (18:15 -0700)
Use of_property_read_bool() to read boolean properties rather than
of_find_property(). This is part of a larger effort to remove callers
of of_find_property() and similar functions. of_find_property() leaks
the DT struct property and data pointers which is a problem for
dynamically allocated nodes which may be freed.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: MD Danish Anwar <danishanwar@ti.com>
Link: https://patch.msgid.link/20240731191601.1714639-2-robh@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/fman/fman_port.c
drivers/net/ethernet/ti/icssg/icssg_prueth.c
drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c
drivers/net/ethernet/xilinx/xilinx_axienet_main.c

index 406e75e9e5ea206f6ef9ec88f9f8363dfdd1e680..f17a4e51151017ba2cf075948b85b94f3a99f881 100644 (file)
@@ -1748,7 +1748,7 @@ static int fman_port_probe(struct platform_device *of_dev)
        struct resource res;
        struct resource *dev_res;
        u32 val;
-       int err = 0, lenp;
+       int err = 0;
        enum fman_port_type port_type;
        u16 port_speed;
        u8 port_id;
@@ -1795,7 +1795,7 @@ static int fman_port_probe(struct platform_device *of_dev)
        if (of_device_is_compatible(port_node, "fsl,fman-v3-port-tx")) {
                port_type = FMAN_PORT_TYPE_TX;
                port_speed = 1000;
-               if (of_find_property(port_node, "fsl,fman-10g-port", &lenp))
+               if (of_property_read_bool(port_node, "fsl,fman-10g-port"))
                        port_speed = 10000;
 
        } else if (of_device_is_compatible(port_node, "fsl,fman-v2-port-tx")) {
@@ -1808,7 +1808,7 @@ static int fman_port_probe(struct platform_device *of_dev)
        } else if (of_device_is_compatible(port_node, "fsl,fman-v3-port-rx")) {
                port_type = FMAN_PORT_TYPE_RX;
                port_speed = 1000;
-               if (of_find_property(port_node, "fsl,fman-10g-port", &lenp))
+               if (of_property_read_bool(port_node, "fsl,fman-10g-port"))
                        port_speed = 10000;
 
        } else if (of_device_is_compatible(port_node, "fsl,fman-v2-port-rx")) {
index 3e51b3a9b0a57f3bcc74c6cf4d5c205f5018e5bb..9dc9de39bb8f0431ac8238544c06bd1ee7a8ce08 100644 (file)
@@ -1271,8 +1271,8 @@ static int prueth_probe(struct platform_device *pdev)
                        goto exit_iep;
                }
 
-               if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
-                       prueth->emac[PRUETH_MAC0]->half_duplex = 1;
+               prueth->emac[PRUETH_MAC0]->half_duplex =
+                       of_property_read_bool(eth0_node, "ti,half-duplex-capable");
 
                prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
        }
@@ -1285,8 +1285,8 @@ static int prueth_probe(struct platform_device *pdev)
                        goto netdev_exit;
                }
 
-               if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
-                       prueth->emac[PRUETH_MAC1]->half_duplex = 1;
+               prueth->emac[PRUETH_MAC1]->half_duplex =
+                       of_property_read_bool(eth1_node, "ti,half-duplex-capable");
 
                prueth->emac[PRUETH_MAC1]->iep = prueth->iep0;
        }
index e180c1166170aff61e1998ccd4c9615a3ee1362a..54b7e27608ce8538b7d519bc44c0609d0fb27af3 100644 (file)
@@ -1045,8 +1045,8 @@ static int prueth_probe(struct platform_device *pdev)
                        goto exit_iep;
                }
 
-               if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
-                       prueth->emac[PRUETH_MAC0]->half_duplex = 1;
+               prueth->emac[PRUETH_MAC0]->half_duplex =
+                       of_property_read_bool(eth0_node, "ti,half-duplex-capable");
 
                prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
        }
@@ -1059,8 +1059,8 @@ static int prueth_probe(struct platform_device *pdev)
                        goto netdev_exit;
                }
 
-               if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
-                       prueth->emac[PRUETH_MAC1]->half_duplex = 1;
+               prueth->emac[PRUETH_MAC1]->half_duplex =
+                       of_property_read_bool(eth1_node, "ti,half-duplex-capable");
 
                prueth->emac[PRUETH_MAC1]->iep = prueth->iep1;
        }
index 02fdf66e07faa33887f361c699ded2360b9cae5d..f051f0387214a9e9cb9394522b348e54548e96a2 100644 (file)
@@ -2396,7 +2396,7 @@ static int axienet_probe(struct platform_device *pdev)
                goto cleanup_clk;
        }
 
-       if (!of_find_property(pdev->dev.of_node, "dmas", NULL)) {
+       if (!of_property_present(pdev->dev.of_node, "dmas")) {
                /* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
                np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);