[PATCH v18 2/5] phy: core: Add phy_get_by_of_node()
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Sep 17 04:18:44 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] phy: phy_get_by_of_node() bypasses usb-nop-xceiv legacy check
--
commit d8c1cc00496d43b5d8e3b5f03853e461912120c9
Author: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
phy: core: Add phy_get_by_of_node()
This commit introduces phy_get_by_of_node() to allow PHY lookups by device
node. It splits the lookup logic from _of_phy_get() into a new internal
_of_phy_get_with_args() helper.
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
[ ... ]
> @@ -1001,6 +1015,41 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
> }
> EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);
>
> +/**
> + * phy_get_by_of_node() - lookup and obtain a reference to a phy by device_node
> + * @np: node containing the phy
> + *
> + * Returns the phy associated with the device node or ERR_PTR.
> + */
> +struct phy *phy_get_by_of_node(struct device_node *np)
> +{
> + struct of_phandle_args args = { .np = np, .args_count = 0 };
> + struct phy *phy;
> +
> + if (!np)
> + return ERR_PTR(-EINVAL);
> +
> + mutex_lock(&phy_provider_mutex);
> +
> + phy = _of_phy_get_with_args(&args);
[Severity: Medium]
Does this bypass the legacy compatibility check for usb-nop-xceiv PHYs?
Looking at the newly introduced helper _of_phy_get_with_args(), it does
not contain the check for usb-nop-xceiv that remains in _of_phy_get():
drivers/phy/phy-core.c:_of_phy_get() {
...
/* This phy type handled by the usb-phy subsystem for now */
if (of_device_is_compatible(args.np, "usb-nop-xceiv")) {
phy = ERR_PTR(-ENODEV);
...
}
...
}
Because phy_get_by_of_node() calls _of_phy_get_with_args() directly,
if it is called on a device node with the usb-nop-xceiv compatible string,
it will fail to find the legacy PHY provider and return -EPROBE_DEFER
instead of -ENODEV.
Could this cause caller drivers to enter infinite probe deferral loops
since the legacy PHY will never register with this generic framework?
> +
> + if (IS_ERR(phy))
> + goto out_unlock;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260917-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v18-0-f85c9103177e@linaro.org?part=2
More information about the linux-phy
mailing list