From mboxrd@z Thu Jan 1 00:00:00 1970 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 6384FC77B6E for ; Fri, 14 Apr 2023 04:25:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D9B0D85DDD; Fri, 14 Apr 2023 06:24:51 +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="fy4R/dcU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8971685B6E; Fri, 14 Apr 2023 06:24:45 +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 222A985B6E for ; Fri, 14 Apr 2023 06:24:42 +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 33E4OZiD095099; Thu, 13 Apr 2023 23:24:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1681446275; bh=77JFdZ7KZ4eusKBVk/aR/78Xd2k4IC4a+3CusNfa/6E=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fy4R/dcU0j1dbw3S2Zaf0FI6FdFw7toZK2Tugeyvy3Ks5S/2/XxjzJo1cFrczokDg lHBj3iOKt6UqcFDZm+AZ8zaqcdvACzmQ4pO4pjaavM8d3osAXW+i/tU6zInrCczLs+ WTD2P0ppSoMH4DN7ohHEhHVK7UPQLEV8vWy+/+K4= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33E4OZNA081757 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 13 Apr 2023 23:24:35 -0500 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE109.ent.ti.com (10.64.6.30) 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 23:24:35 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE107.ent.ti.com (10.64.6.28) 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 23:24:35 -0500 Received: from localhost (ileaxei01-snat.itg.ti.com [10.180.69.5]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33E4OZMo122975; Thu, 13 Apr 2023 23:24:35 -0500 From: Nishanth Menon To: Marek Vasut , Tom Rini CC: Siddharth Vadapalli , Vignesh Raghavendra , Michal Simek , Ramon Fried , , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Nishanth Menon Subject: [PATCH V2 1/2] net: phy: Make phy_interface_is_sgmii a switch statement Date: Thu, 13 Apr 2023 23:24:32 -0500 Message-ID: <20230414042433.3436425-2-nm@ti.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230414042433.3436425-1-nm@ti.com> References: <20230414042433.3436425-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 caused the range of enums that this api was checking to go bad. While it is possible for the phy drivers to practically use the enum's directly, drivers such as dp83867 use this helper to manage the configuration of the phy correctly. Reported-by: Tom Rini Signed-off-by: Nishanth Menon --- Changes Since v1: * Switch update based on feedback from Marek V1: https://lore.kernel.org/r/20230413180713.2922524-2-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 a837fed72352..51dadcf14478 100644 --- a/include/phy.h +++ b/include/phy.h @@ -373,8 +373,15 @@ static inline bool phy_interface_is_rgmii(struct phy_device *phydev) */ static inline bool phy_interface_is_sgmii(struct phy_device *phydev) { - return phydev->interface >= PHY_INTERFACE_MODE_SGMII && - phydev->interface <= PHY_INTERFACE_MODE_QSGMII; + switch (phydev->interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_QUSGMII: + case PHY_INTERFACE_MODE_USXGMII: + case PHY_INTERFACE_MODE_QSGMII: + return 1; + default: + return 0; + } } bool phy_interface_is_ncsi(void); -- 2.40.0