[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJq09z56GmDhbZUWR_s+thOfu0WB47o66X3_Ko3KyTk44inMCg@mail.gmail.com>
Date: Wed, 3 Jan 2024 18:50:06 -0300
From: Luiz Angelo Daros de Luca <luizluca@...il.com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: kuba@...nel.org, netdev@...r.kernel.org, andrew@...n.ch,
hkallweit1@...il.com, davem@...emloft.net, edumazet@...gle.com,
pabeni@...hat.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] net: mdio: get/put device node during (un)registration
> Please test to check that this addresses your issue. Thanks.
>
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 6cf73c15635b..afbad1ad8683 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -193,6 +193,10 @@ static void mdiobus_release(struct device *d)
> bus->state != MDIOBUS_ALLOCATED,
> "%s: not in RELEASED or ALLOCATED state\n",
> bus->id);
> +
> + if (bus->state == MDIOBUS_RELEASED)
> + fwnode_handle_put(dev_fwnode(d));
> +
> kfree(bus);
> }
>
> @@ -684,6 +688,15 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
> bus->dev.groups = NULL;
> dev_set_name(&bus->dev, "%s", bus->id);
>
> + /* If the bus state is allocated, we're registering a fresh bus
> + * that may have a fwnode associated with it. Grab a reference
> + * to the fwnode. This will be dropped when the bus is released.
> + * If the bus was set to unregistered, it means that the bus was
> + * previously registered, and we've already grabbed a reference.
> + */
> + if (bus->state == MDIOBUS_ALLOCATED)
> + fwnode_handle_get(dev_fwnode(&bus->dev));
> +
> /* We need to set state to MDIOBUS_UNREGISTERED to correctly release
> * the device in mdiobus_free()
> *
> --
Thanks Russel. It is much better than my approach. You simply get/put
during registration/unregistration when a node is defined, no matter
who defined it (of_mdiobus_register or anything else). Clean and
simple.
Regards,
Luiz
Powered by blists - more mailing lists