Skip to content

Commit 5fe164f

Browse files
robherringkuba-moo
authored andcommitted
net: Use of_property_read_bool()
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) <[email protected]> Reviewed-by: MD Danish Anwar <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0b0e9cd commit 5fe164f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

drivers/net/ethernet/freescale/fman/fman_port.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ static int fman_port_probe(struct platform_device *of_dev)
17481748
struct resource res;
17491749
struct resource *dev_res;
17501750
u32 val;
1751-
int err = 0, lenp;
1751+
int err = 0;
17521752
enum fman_port_type port_type;
17531753
u16 port_speed;
17541754
u8 port_id;
@@ -1795,7 +1795,7 @@ static int fman_port_probe(struct platform_device *of_dev)
17951795
if (of_device_is_compatible(port_node, "fsl,fman-v3-port-tx")) {
17961796
port_type = FMAN_PORT_TYPE_TX;
17971797
port_speed = 1000;
1798-
if (of_find_property(port_node, "fsl,fman-10g-port", &lenp))
1798+
if (of_property_read_bool(port_node, "fsl,fman-10g-port"))
17991799
port_speed = 10000;
18001800

18011801
} 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)
18081808
} else if (of_device_is_compatible(port_node, "fsl,fman-v3-port-rx")) {
18091809
port_type = FMAN_PORT_TYPE_RX;
18101810
port_speed = 1000;
1811-
if (of_find_property(port_node, "fsl,fman-10g-port", &lenp))
1811+
if (of_property_read_bool(port_node, "fsl,fman-10g-port"))
18121812
port_speed = 10000;
18131813

18141814
} else if (of_device_is_compatible(port_node, "fsl,fman-v2-port-rx")) {

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,8 @@ static int prueth_probe(struct platform_device *pdev)
12711271
goto exit_iep;
12721272
}
12731273

1274-
if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
1275-
prueth->emac[PRUETH_MAC0]->half_duplex = 1;
1274+
prueth->emac[PRUETH_MAC0]->half_duplex =
1275+
of_property_read_bool(eth0_node, "ti,half-duplex-capable");
12761276

12771277
prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
12781278
}
@@ -1285,8 +1285,8 @@ static int prueth_probe(struct platform_device *pdev)
12851285
goto netdev_exit;
12861286
}
12871287

1288-
if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
1289-
prueth->emac[PRUETH_MAC1]->half_duplex = 1;
1288+
prueth->emac[PRUETH_MAC1]->half_duplex =
1289+
of_property_read_bool(eth1_node, "ti,half-duplex-capable");
12901290

12911291
prueth->emac[PRUETH_MAC1]->iep = prueth->iep0;
12921292
}

drivers/net/ethernet/ti/icssg/icssg_prueth_sr1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,8 @@ static int prueth_probe(struct platform_device *pdev)
10451045
goto exit_iep;
10461046
}
10471047

1048-
if (of_find_property(eth0_node, "ti,half-duplex-capable", NULL))
1049-
prueth->emac[PRUETH_MAC0]->half_duplex = 1;
1048+
prueth->emac[PRUETH_MAC0]->half_duplex =
1049+
of_property_read_bool(eth0_node, "ti,half-duplex-capable");
10501050

10511051
prueth->emac[PRUETH_MAC0]->iep = prueth->iep0;
10521052
}
@@ -1059,8 +1059,8 @@ static int prueth_probe(struct platform_device *pdev)
10591059
goto netdev_exit;
10601060
}
10611061

1062-
if (of_find_property(eth1_node, "ti,half-duplex-capable", NULL))
1063-
prueth->emac[PRUETH_MAC1]->half_duplex = 1;
1062+
prueth->emac[PRUETH_MAC1]->half_duplex =
1063+
of_property_read_bool(eth1_node, "ti,half-duplex-capable");
10641064

10651065
prueth->emac[PRUETH_MAC1]->iep = prueth->iep1;
10661066
}

drivers/net/ethernet/xilinx/xilinx_axienet_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ static int axienet_probe(struct platform_device *pdev)
23962396
goto cleanup_clk;
23972397
}
23982398

2399-
if (!of_find_property(pdev->dev.of_node, "dmas", NULL)) {
2399+
if (!of_property_present(pdev->dev.of_node, "dmas")) {
24002400
/* Find the DMA node, map the DMA registers, and decode the DMA IRQs */
24012401
np = of_parse_phandle(pdev->dev.of_node, "axistream-connected", 0);
24022402

0 commit comments

Comments
 (0)