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 BF415C77B6E for ; Thu, 13 Apr 2023 18:07:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 89F0485A42; Thu, 13 Apr 2023 20:07:25 +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="ylTyy6iU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A313D85B34; Thu, 13 Apr 2023 20:07:23 +0200 (CEST) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (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 CCF77859C4 for ; Thu, 13 Apr 2023 20:07:19 +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 lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33DI7F4a097332; Thu, 13 Apr 2023 13:07:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681409235; bh=udmIDoYb8maGbs0aVSw2ZOjU2YhGiEzvliALzXPng04=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ylTyy6iUGye8UX1MLKr+aPRPyV4bSY6VyYEG06/iZUc3WOq5BqhbmR+IR9NHMTGNl 1KbRDxX5S/i/Sz6RYheFA1LZqo0eD2YOH+MuOE2/PvIcx4ck3/Pw/9tYJj2Z66ogM6 0/IrNp4mmedjCRV4cp2cU9juMgNOJxfRnuNtusOc= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33DI7FLP018613 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 13 Apr 2023 13:07:15 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Thu, 13 Apr 2023 13:07:15 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) 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; Thu, 13 Apr 2023 13:07:15 -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 33DI7FBO057209; Thu, 13 Apr 2023 13:07:15 -0500 From: Nishanth Menon To: Marek Vasut , Tom Rini CC: Siddharth Vadapalli , Vignesh Raghavendra , Michal Simek , Ramon Fried , , Nishanth Menon Subject: [PATCH 2/2] net: phy: Make phy_interface_is_rgmii a switch statement Date: Thu, 13 Apr 2023 13:07:13 -0500 Message-ID: <20230413180713.2922524-3-nm@ti.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230413180713.2922524-1-nm@ti.com> References: <20230413180713.2922524-1-nm@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 was'nt 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 practically use the enum's directly, drivers such as dp83867, dp83869, marvell, micrel_ksz90x1 etc use the same. Reported-by: Tom Rini Signed-off-by: Nishanth Menon --- include/phy.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/phy.h b/include/phy.h index 1c4dc23bc5ba..812694cf4a81 100644 --- a/include/phy.h +++ b/include/phy.h @@ -361,8 +361,16 @@ 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: + fallthrough; + } + return 0; } /** -- 2.40.0