[PATCH V2 1/2] net: phy: Make phy_interface_is_sgmii a switch statement
Marek Behún
kabel at kernel.org
Fri Apr 14 10:38:52 CEST 2023
On Thu, 13 Apr 2023 23:24:32 -0500
Nishanth Menon <nm at ti.com> 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 <trini at konsulko.com>
> Signed-off-by: Nishanth Menon <nm at ti.com>
> ---
> 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);
Reviewed-by: Marek Behún <kabel at kernel.org>
Please also consider dropping this function, since it is used only in
one driver
drivers/net/phy/dp83867.c
and that device does not actually support QUSGMII, USXGMII nor QSGMII.
It only supports SGMII.
With rgmii, the corresponding phy_interface_is_rgmii() function makes
sense, but for SGMII the four modes are entirely too different for this
to make sense.
Marek
More information about the U-Boot
mailing list