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 EBEBEC6FD18 for ; Tue, 25 Apr 2023 19:13:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1FE1862B4; Tue, 25 Apr 2023 21:13:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="OHyzghSv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1680185E92; Tue, 25 Apr 2023 21:13:48 +0200 (CEST) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D4AFD85AEC for ; Tue, 25 Apr 2023 21:13:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rfried.dev@gmail.com Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-2fa0ce30ac2so5586444f8f.3 for ; Tue, 25 Apr 2023 12:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682450025; x=1685042025; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=A+n9+SKRa5dXfUz+oFRuDPKzT7YNU4COBL6dtIOItxw=; b=OHyzghSviMiRnXqIuOU5cXoL1qh5FvY0NfRdEiHnpgJcFmdCxdAnYTWAl1NmNCbmAW a6K11XqpiMwdTqw3cNWesq0bHTLGGIZdWaqznibJG2IgDsmv79xFjtLwn9poV2MCYJKS kfI4TVkKav63ke5z5GjWsqOlIv2mTVtsTRBXbOd1CWduKqi+Oe+TPEuwK1lLZX097LQc N+eVRE5UD49qcAOrEfFI4rsduFz+AbKi2EYtxhkMOiQVAP2B834tmCy93SkD2lny1BV9 yJkVuMWmJyPonwrvl0iHXlnSxeMDdX8xuby1Mz9FwopWZ0DdkLHY8fKkLlWqHLuCdQme BznA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682450025; x=1685042025; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A+n9+SKRa5dXfUz+oFRuDPKzT7YNU4COBL6dtIOItxw=; b=kmL2C2sVvIm+OI/6RzExFzQcfB/5fCl1DhcWmzwh1FQ+samF3lKjfdiCX7NVGAhLcV pDIV9yxXmJNPizPsYe+tIENUaO5V+pFzsDQMg+hbNnmMq6FJI9obVOBQQH9hUC4Wqgb2 62tI/hF96set4UinBGpzwvdSZ5KZGqQ7e9pVeUCKPQavmFHUA/Ku1jLPP/Fj14ouQoiy jgSVWwVtQEcvevESpTte19/IwQlZiOyPdgvKEI6CKrluozfVUvIT1DwtdNIQ4sq1MXtL xtFWqgxM7fAl6qkNj+U6Dx84Vb8u48HwF7h4PbQlX2hPGWJCJtJGSNhAUxSUMGyvSPtE hQtA== X-Gm-Message-State: AAQBX9d8eAz/+tPi8kyLZZd9WFSCTd+ImOU0VCf92Mhkj/GIrOhvvG64 C2crrYC3l9njAMnUsVqGKTJFFPc6XfPenYSrX0k= X-Google-Smtp-Source: AKy350a2g3Qv0QU8eFAjIoKDEaXSY8JlA/5UGLfMUw5P0G97iugNcScMzXjipr1545z0Lo6M0h4GVZmn3lkHV4nRodI= X-Received: by 2002:adf:ce88:0:b0:2fa:c2e7:55c2 with SMTP id r8-20020adfce88000000b002fac2e755c2mr13344949wrn.15.1682450025223; Tue, 25 Apr 2023 12:13:45 -0700 (PDT) MIME-Version: 1.0 References: <20230413180713.2922524-1-nm@ti.com> <20230413180713.2922524-3-nm@ti.com> In-Reply-To: <20230413180713.2922524-3-nm@ti.com> From: Ramon Fried Date: Tue, 25 Apr 2023 22:13:32 +0300 Message-ID: Subject: Re: [PATCH 2/2] net: phy: Make phy_interface_is_rgmii a switch statement To: Nishanth Menon Cc: Marek Vasut , Tom Rini , Siddharth Vadapalli , Vignesh Raghavendra , Michal Simek , u-boot@lists.denx.de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 9:07=E2=80=AFPM Nishanth Menon wrote: > > 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 de= vad, u32 *phy_id); > */ > static inline bool phy_interface_is_rgmii(struct phy_device *phydev) > { > - return phydev->interface >=3D PHY_INTERFACE_MODE_RGMII && > - phydev->interface <=3D 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 > Reviewed-by: Ramon Fried