Ahead of reworking the reference counting logic for platform devices, encapsulate the assignment of the OF node for dynamically allocated platform devices with the provided helper.
Signed-off-by: Bartosz Golaszewski <[email protected]> --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index a4e0d5a682687533a1b034ccf56cdb363d6b7786..451b23a039cebb777f356f64924838230052dc45 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -490,10 +490,14 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv) /* Retain this platform_device pointer for later cleanup */ priv->mii_pdev = ppdev; ppdev->dev.parent = &pdev->dev; - if (dn) - ppdev->dev.of_node = bcmgenet_mii_of_find_mdio(priv); - else + + if (dn) { + struct device_node *np __free(device_node) = bcmgenet_mii_of_find_mdio(priv); + + platform_device_set_of_node(ppdev, np); + } else { ppd.phy_mask = ~0; + } ret = platform_device_add_resources(ppdev, &res, 1); if (ret) -- 2.47.3
