From mboxrd@z Thu Jan 1 00:00:00 1970 From: patrice.chotard at st.com Date: Tue, 23 May 2017 11:57:54 +0200 Subject: [U-Boot] [PATCH v3 3/4] drivers: phy: add generic_phy_valid() method In-Reply-To: <1495533475-1553-1-git-send-email-patrice.chotard@st.com> References: <1495533475-1553-1-git-send-email-patrice.chotard@st.com> Message-ID: <1495533475-1553-4-git-send-email-patrice.chotard@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Patrice Chotard This allow to check if a PHY has been correctly initialised and avoid to get access to phy struct. Signed-off-by: Patrice Chotard --- 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 0d8bef7..43a7c18 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -133,6 +133,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 d8cf0c9..53206f0 100644 --- a/include/generic-phy.h +++ b/include/generic-phy.h @@ -221,4 +221,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