[U-Boot] [PATCH v5 4/5] drivers: phy: add generic_phy_valid() method

patrice.chotard at st.com patrice.chotard at st.com
Thu Jun 1 08:14:24 UTC 2017


From: Patrice Chotard <patrice.chotard at st.com>

This allow to check if a PHY has been correctly
initialised and avoid to get access to phy struct.

Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
Reviewed-by: Marek Vasut <marex at denx.de>
Reviewed-by: Simon Glass <sjg at chromium.org>
---

v5:	_ none
v4:     _ none

 drivers/phy/phy-uclass.c | 5 +++++
 include/generic-phy.h    | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 68e518f..8ccd9bc 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -131,6 +131,11 @@ int generic_phy_power_off(struct phy *phy)
 	return ops->power_off ? ops->power_off(phy) : 0;
 }
 
+bool generic_phy_valid(struct phy *phy)
+{
+	return phy->dev != NULL;
+}
+
 UCLASS_DRIVER(phy) = {
 	.id		= UCLASS_PHY,
 	.name		= "phy",
diff --git a/include/generic-phy.h b/include/generic-phy.h
index 762704c..343ad03 100644
--- a/include/generic-phy.h
+++ b/include/generic-phy.h
@@ -220,4 +220,12 @@ int generic_phy_get_by_index(struct udevice *user, int index,
 int generic_phy_get_by_name(struct udevice *user, const char *phy_name,
 			    struct phy *phy);
 
+/**
+ * generic_phy_valid() - check if PHY port is valid
+ *
+ * @phy:	the PHY port to check
+ * @return TRUE if valid, or FALSE
+ */
+bool generic_phy_valid(struct phy *phy);
+
 #endif /*__GENERIC_PHY_H */
-- 
1.9.1



More information about the U-Boot mailing list