net: mdio: get/put device node during (un)registration
authorLuiz Angelo Daros de Luca <luizluca@gmail.com>
Wed, 20 Dec 2023 04:52:29 +0000 (01:52 -0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Jan 2024 13:01:27 +0000 (13:01 +0000)
commitcff9c565e65f3622e8dc1dcc21c1520a083dff35
treeb8648d251495b295f902ebbdabf993f873565029
parent92de776d20904b51e6dc2d39280c5f143a80f987
net: mdio: get/put device node during (un)registration

The __of_mdiobus_register() function was storing the device node in
dev.of_node without increasing its reference count. It implicitly relied
on the caller to maintain the allocated node until the mdiobus was
unregistered.

Now, __of_mdiobus_register() will acquire the node before assigning it,
and of_mdiobus_unregister_callback() will be called at the end of
mdio_unregister().

Drivers can now release the node immediately after MDIO registration.
Some of them are already doing that even before this patch.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/mdio/of_mdio.c
drivers/net/phy/mdio_bus.c
include/linux/phy.h