drivers: phy: add generic_phy_valid() method
authorPatrice Chotard <patrice.chotard@st.com>
Tue, 18 Jul 2017 09:38:43 +0000 (11:38 +0200)
committerMarek Vasut <marex@denx.de>
Fri, 28 Jul 2017 21:34:05 +0000 (23:34 +0200)
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@st.com>
include/generic-phy.h

index 762704c208e1674663067ac9c1f7f3dfd6ba0971..58cd2b26a9de7d880864c0a368ff53fc6e4da8fe 100644 (file)
@@ -220,4 +220,15 @@ 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
+ */
+static inline bool generic_phy_valid(struct phy *phy)
+{
+       return phy->dev != NULL;
+}
+
 #endif /*__GENERIC_PHY_H */