Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9119C77B71 for ; Fri, 14 Apr 2023 22:07:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD70285D9D; Sat, 15 Apr 2023 00:07:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="JqyI6Ctl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 71CA485CB5; Sat, 15 Apr 2023 00:06:58 +0200 (CEST) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3D86785D4C for ; Sat, 15 Apr 2023 00:06:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=nm@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33EM6lkn062849; Fri, 14 Apr 2023 17:06:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681510007; bh=WXNQ9u21lnDtX4eLhwOGEHJfseWzClmaTiDKF3fdxWs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=JqyI6CtlKIv/Pe6pJ0pgd6PFQQ1GTFOBw7sggqNmL47w7K32iajRWILJDVb9wxfT5 VmIyVpRo3ZIV5z4JaRkrIyykac+vvKEow+ABLtO6jkdVGEnQIQhIlmDft26NkVV2XJ UcCGdmJNDpnEiriwOKSJq9PibYZXxnu9zlCYII7Y= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33EM6lpa092231 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 14 Apr 2023 17:06:47 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Fri, 14 Apr 2023 17:06:46 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Fri, 14 Apr 2023 17:06:46 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33EM6kUT130872; Fri, 14 Apr 2023 17:06:46 -0500 From: Nishanth Menon To: Marek Vasut , Tom Rini CC: Siddharth Vadapalli , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Vignesh Raghavendra , Michal Simek , Ramon Fried , , Nishanth Menon , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH V3 3/3] net: phy: Make phy_interface_is_rgmii a switch statement Date: Fri, 14 Apr 2023 17:06:45 -0500 Message-ID: <20230414220645.37092-4-nm@ti.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414220645.37092-1-nm@ti.com> References: <20230414220645.37092-1-nm@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Recent commit 75d28899e3e9 ("net: phy: Synchronize PHY interface modes with Linux") reordered the enum definitions. This exposed a problem in range checking functions to identify the interface type. Though this specific api wasn't impacted (all the RGMII definitions remained within range), this experience should be used to never to have to face this kind of challenge again. While it is possible for the phy drivers to use the enums directly, drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc use this api. Reported-by: Tom Rini Reviewed-by: Marek Vasut Reviewed-by: Marek BehĂșn Signed-off-by: Nishanth Menon --- Changes since V2: * picked up reviewed-by * s/was'nt/wasn't/g in commit message, minor rewording. V2: https://lore.kernel.org/r/20230414042433.3436425-3-nm@ti.com V1: https://lore.kernel.org/r/20230413180713.2922524-3-nm@ti.com include/phy.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/phy.h b/include/phy.h index cb87d1d4fc95..247223d92be7 100644 --- a/include/phy.h +++ b/include/phy.h @@ -361,8 +361,15 @@ int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); */ static inline bool phy_interface_is_rgmii(struct phy_device *phydev) { - return phydev->interface >= PHY_INTERFACE_MODE_RGMII && - phydev->interface <= PHY_INTERFACE_MODE_RGMII_TXID; + switch (phydev->interface) { + case PHY_INTERFACE_MODE_RGMII: + case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: + return 1; + default: + return 0; + } } bool phy_interface_is_ncsi(void); -- 2.40.0