From patchwork Mon Jul 10 09:39:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrice CHOTARD X-Patchwork-Id: 786103 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3x5gGP2NhMz9s03 for ; Mon, 10 Jul 2017 19:41:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 15F39C21DE6; Mon, 10 Jul 2017 09:39:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 954DDC21DB3; Mon, 10 Jul 2017 09:39:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9A2E9C21DED; Mon, 10 Jul 2017 09:39:39 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id 438BCC21DDB for ; Mon, 10 Jul 2017 09:39:36 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6A9Yxwq026769; Mon, 10 Jul 2017 11:39:33 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 2bjp9bhmj8-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 10 Jul 2017 11:39:33 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DC8BC34; Mon, 10 Jul 2017 09:39:32 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag6node3.st.com [10.75.127.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C74C8141B; Mon, 10 Jul 2017 09:39:32 +0000 (GMT) Received: from localhost (10.75.127.45) by SFHDAG6NODE3.st.com (10.75.127.18) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Mon, 10 Jul 2017 11:39:32 +0200 From: To: Marek Vasut , , , Date: Mon, 10 Jul 2017 11:39:22 +0200 Message-ID: <1499679563-641-5-git-send-email-patrice.chotard@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1499679563-641-1-git-send-email-patrice.chotard@st.com> References: <1499679563-641-1-git-send-email-patrice.chotard@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG6NODE3.st.com (10.75.127.18) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-10_04:, , signatures=0 Cc: christophe.kerello@st.com Subject: [U-Boot] [PATCH v6 4/5] drivers: phy: add generic_phy_valid() method X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Reviewed-by: Marek Vasut Reviewed-by: Simon Glass --- v6: _ none 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 */