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 F061BC77B6E for ; Thu, 13 Apr 2023 18:56:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C45E85B34; Thu, 13 Apr 2023 20:56:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=nic.cz 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; secure) header.d=nic.cz header.i=@nic.cz header.b="WyFWXoAV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B321985BB5; Thu, 13 Apr 2023 20:56:06 +0200 (CEST) Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A819685A83 for ; Thu, 13 Apr 2023 20:56:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.behun@nic.cz Received: from kandell (unknown [172.20.6.87]) by mail.nic.cz (Postfix) with ESMTPS id A295A1C1856; Thu, 13 Apr 2023 20:56:02 +0200 (CEST) Authentication-Results: mail.nic.cz; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1681412162; bh=RCnQ2Wy9p9SMWBKQtQiybvR2OGQRmPQCp593C92R3+k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Reply-To: Subject:To:Cc; b=WyFWXoAVSKIS34VKcoGGiNZ3A2cIfi9KDmKwjgbwN/8EiWApVOFKJuKezLVlqhDqF L4gCsqi8BGoXsnMDfSO0ATSf6pMu2CZ2AQd5wMyBSVEk7MvmozDecHK9VkFqfYmS3P ixpcSv5hM8fBuzbtPgtR6pjh49cSJq29YTkc7HR0= Date: Thu, 13 Apr 2023 20:56:02 +0200 From: Marek =?utf-8?B?QmVow7pu?= To: Nishanth Menon Cc: Marek Vasut , Tom Rini , Siddharth Vadapalli , Vignesh Raghavendra , Michal Simek , Ramon Fried , u-boot@lists.denx.de Subject: Re: [PATCH 1/2] net: phy: Make phy_interface_is_sgmii a switch statement Message-ID: <20230413185602.3c4ysaggyxujuvug@kandell> References: <20230413180713.2922524-1-nm@ti.com> <20230413180713.2922524-2-nm@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230413180713.2922524-2-nm@ti.com> X-Spamd-Bar: / X-Rspamd-Pre-Result: action=no action; module=multimap; Matched map: WHITELISTED_IP X-Rspamd-Queue-Id: A295A1C1856 X-Rspamd-Server: mail X-Rspamd-Action: no action X-Spamd-Result: default: False [-0.10 / 20.00]; MIME_GOOD(-0.10)[text/plain]; TAGGED_RCPT(0.00)[renesas]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; WHITELISTED_IP(0.00)[172.20.6.87]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+] 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 On Thu, Apr 13, 2023 at 01:07:12PM -0500, Nishanth Menon wrote: > 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 > --- > include/phy.h | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/include/phy.h b/include/phy.h > index a837fed72352..1c4dc23bc5ba 100644 > --- a/include/phy.h > +++ b/include/phy.h > @@ -373,8 +373,16 @@ 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: > + fallthrough; Why not just put the return 0; statement here instead of fallthrough and drop it from after the switch statement? > + } > + return 0; > }