Re: [PATCH v2 1/4] phy: core: Add common helper to add phy phandle device link
From: Vladimir Oltean
Date: Mon Sep 07 2026 - 07:40:35 EST
On Fri, Sep 04, 2026 at 04:37:05PM +0800, Inochi Amaoto wrote:
> It is very common for adding a device link for phy phandle
> for device managed phy helper functions. So add a common
> helper for future reuse.
>
> Signed-off-by: Inochi Amaoto <inochiama@xxxxxxxxx>
> ---
> drivers/phy/phy-core.c | 38 +++++++++++++++++++++++---------------
> 1 file changed, 23 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 21aaf2f76e53..ea79913fbb87 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -606,6 +606,26 @@ int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
> }
> EXPORT_SYMBOL_GPL(phy_validate);
>
> +/**
> + * phy_add_device_link() - Associate the phy with the device
> + * @dev: the device to link the phy
> + * @phy: the phy to associate
> + *
> + * Associate the phy with the device by using device link.
I guess it would be good to specify somewhere "consumer" device, because
there are multiple devices involved.
> + */
> +static void phy_add_device_link(struct device *dev, struct phy *phy)
> +{
> + struct device_link *link;
> +
> + if (!phy)
> + return;
> +
> + link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
> + if (!link)
> + dev_dbg(dev, "failed to create device link to %s\n",
> + dev_name(phy->dev.parent));
> +}
> +
> /**
> * _of_phy_get() - lookup and obtain a reference to a phy by phandle
> * @np: device_node for which to get the phy