[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241020-phy_core_fix-v1-6-078062f7da71@quicinc.com>
Date: Sun, 20 Oct 2024 13:27:51 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>, Felipe Balbi <balbi@...com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Lee Jones <lee@...nel.org>
Cc: Zijun Hu <zijun_hu@...oud.com>, stable@...r.kernel.org,
linux-phy@...ts.infradead.org, netdev@...r.kernel.org,
linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: [PATCH 6/6] phy: core: Simplify API of_phy_simple_xlate()
implementation
From: Zijun Hu <quic_zijuhu@...cinc.com>
Simplify of_phy_simple_xlate() implementation by API
class_find_device_by_of_node() which is also safer since it
subsys_get() @phy_class subsystem firstly then iterates devices.
Also comment its parameter @dev with unused in passing since the parameter
provides no available input info but acts as an auto variable.
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
drivers/phy/phy-core.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 24bd619a33dd..102fc6b6ff71 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -748,7 +748,7 @@ EXPORT_SYMBOL_GPL(devm_phy_put);
/**
* of_phy_simple_xlate() - returns the phy instance from phy provider
- * @dev: the PHY provider device
+ * @dev: the PHY provider device unused
* @args: of_phandle_args (not used here)
*
* Intended to be used by phy provider for the common case where #phy-cells is
@@ -759,20 +759,13 @@ EXPORT_SYMBOL_GPL(devm_phy_put);
struct phy *of_phy_simple_xlate(struct device *dev,
const struct of_phandle_args *args)
{
- struct phy *phy;
- struct class_dev_iter iter;
-
- class_dev_iter_init(&iter, &phy_class, NULL, NULL);
- while ((dev = class_dev_iter_next(&iter))) {
- phy = to_phy(dev);
- if (args->np != phy->dev.of_node)
- continue;
+ struct device *target_dev;
- class_dev_iter_exit(&iter);
- return phy;
+ target_dev = class_find_device_by_of_node(&phy_class, args->np);
+ if (target_dev) {
+ put_device(target_dev);
+ return to_phy(target_dev);
}
-
- class_dev_iter_exit(&iter);
return ERR_PTR(-ENODEV);
}
EXPORT_SYMBOL_GPL(of_phy_simple_xlate);
--
2.34.1
Powered by blists - more mailing lists