[PATCH v3 2/3] drivers/net: remove use of non-standard array range initialization

David Marchand david.marchand at redhat.com
Mon Jun 16 09:37:50 CEST 2025


On Thu, Jun 12, 2025 at 4:18 PM Andre Muezerie
<andremue at linux.microsoft.com> wrote:
> diff --git a/drivers/net/r8169/base/rtl8125a_mcu.c b/drivers/net/r8169/base/rtl8125a_mcu.c
> index 5a69b3e094..c9bf5fc6ad 100644
> --- a/drivers/net/r8169/base/rtl8125a_mcu.c
> +++ b/drivers/net/r8169/base/rtl8125a_mcu.c
> @@ -162,7 +162,13 @@ static void
>  rtl_release_phy_mcu_patch_key_lock(struct rtl_hw *hw)
>  {
>         switch (hw->mcfg) {
> -       case CFG_METHOD_48 ... CFG_METHOD_53:
> +       /* CFG_METHOD_48 ... CFG_METHOD_53 */
> +       case CFG_METHOD_48:
> +       case CFG_METHOD_49:
> +       case CFG_METHOD_50:
> +       case CFG_METHOD_51:
> +       case CFG_METHOD_52:
> +       case CFG_METHOD_53:
>                 rtl_mdio_direct_write_phy_ocp(hw, 0xA436, 0x0000);
>                 rtl_mdio_direct_write_phy_ocp(hw, 0xA438, 0x0000);
>                 rtl_clear_eth_phy_ocp_bit(hw, 0xB82E, BIT_0);

I don't have a strong opinion against this change.
The driver maintainer already acked this change.

So just some comment, on the form.
switch() here does not seem well suited since this driver code is
validating a range of values.
if (hw->mcfg >= CFG_METHOD_48 && hw->mcfg <= CFG_METHOD_53) seems more
robust and is easier to read.



-- 
David Marchand



More information about the dev mailing list