[PATCH v18 3/5] phy: core: Add devm_phy_get_by_of_node()

sashiko-bot at kernel.org sashiko-bot at kernel.org
Thu Sep 17 04:18:45 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] phy: inconsistent log severity for device link failure
--

commit dbacb9631ec7d71b290bf2c4c3bb57ed433e17f3
Author: Bryan O'Donoghue <bryan.odonoghue at linaro.org>

phy: core: Add devm_phy_get_by_of_node()

This commit adds a devm variant of phy_get_by_of_node() to allow for
automatic resource release on the driver's exit path.

> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index 490a7cde6d40a..10e9323566803 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -833,7 +833,7 @@ struct phy *phy_get(struct device *dev, const char *string)
>  
>  	link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
>  	if (!link)
> -		dev_dbg(dev, "failed to create device link to %s\n",
> +		dev_err(dev, "failed to create device link to %s\n",

[Severity: Low]
Is this change in logging severity from dev_dbg to dev_err intentional?
If so, should it be documented in the commit message?

>  			dev_name(phy->dev.parent));
>  
>  out_unlock:

[ ... ]

> @@ -1050,6 +1050,40 @@ struct phy *phy_get_by_of_node(struct device_node *np)
>  }
>  EXPORT_SYMBOL_GPL(phy_get_by_of_node);
>  
> +/**
> + * devm_phy_get_by_of_node() - devm managed lookup and obtain phy reference by device node
> + * @dev: device requesting the PHY
> + * @np: device_node of the PHY provider
> + *
> + * Returns phy associated with the device_node or ERR_PTR. devres manages
> + * releasing resources.
> + */
> +struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
> +{
> +	struct phy **ptr, *phy;
> +	struct device_link *link;
> +
> +	ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
> +	if (!ptr)
> +		return ERR_PTR(-ENOMEM);
> +
> +	phy = phy_get_by_of_node(np);
> +	if (IS_ERR(phy)) {
> +		devres_free(ptr);
> +		return phy;
> +	}
> +
> +	*ptr = phy;
> +	devres_add(dev, ptr);
> +	link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
> +	if (!link)
> +		dev_dbg(dev, "failed to create device link to %s\n",

[Severity: Low]
Since phy_get() was updated to use dev_err() for device_link_add() failures
above, should devm_phy_get_by_of_node() also use dev_err() here for
consistency?

> +			dev_name(phy->dev.parent));
> +
> +	return phy;
> +}
> +EXPORT_SYMBOL_GPL(devm_phy_get_by_of_node);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260917-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v18-0-f85c9103177e@linaro.org?part=3



More information about the linux-phy mailing list