public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel•org>
To: "Russell King (Oracle)" <rmk+kernel@armlinux•org.uk>
Cc: Andrew Lunn <andrew@lunn•ch>,
	Heiner Kallweit <hkallweit1@gmail•com>,
	Alexandre Torgue <alexandre.torgue@foss•st.com>,
	Andrew Lunn <andrew+netdev@lunn•ch>,
	"David S. Miller" <davem@davemloft•net>,
	Eric Dumazet <edumazet@google•com>,
	Jakub Kicinski <kuba@kernel•org>,
	linux-arm-kernel@lists•infradead.org,
	linux-stm32@st-md-mailman•stormreply.com,
	Maxime Coquelin <mcoquelin.stm32@gmail•com>,
	netdev@vger•kernel.org, Paolo Abeni <pabeni@redhat•com>
Subject: Re: [PATCH net-next v2 11/11] net: stmmac: ingenic: use ->set_phy_intf_sel()
Date: Thu, 6 Nov 2025 16:48:31 +0000	[thread overview]
Message-ID: <aQzRX6qHy5Yo7T5x@horms.kernel.org> (raw)
In-Reply-To: <E1vGvoo-0000000DWpK-47nP@rmk-PC.armlinux.org.uk>

On Thu, Nov 06, 2025 at 08:58:10AM +0000, Russell King (Oracle) wrote:
> Rather than placing the phy_intf_sel() setup in the ->init() method,
> move it to the new ->set_phy_intf_sel() method.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux•org.uk>
> ---
>  .../ethernet/stmicro/stmmac/dwmac-ingenic.c   | 33 +++++++------------
>  1 file changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
> index 41a2071262bc..957bc78d5a1e 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ingenic.c
> @@ -134,32 +134,21 @@ static int x2000_mac_set_mode(struct ingenic_mac *mac, u8 phy_intf_sel)
>  	return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val);
>  }
>  
> -static int ingenic_mac_init(struct platform_device *pdev, void *bsp_priv)
> +static int ingenic_set_phy_intf_sel(void *bsp_priv, u8 phy_intf_sel)
>  {
>  	struct ingenic_mac *mac = bsp_priv;
> -	phy_interface_t interface;
> -	int phy_intf_sel, ret;
> -
> -	if (mac->soc_info->set_mode) {
> -		interface = mac->plat_dat->phy_interface;
> -
> -		phy_intf_sel = stmmac_get_phy_intf_sel(interface);
> -		if (phy_intf_sel < 0 || phy_intf_sel >= BITS_PER_BYTE ||
> -		    ~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel)) {
> -			dev_err(mac->dev, "unsupported interface %s\n",
> -				phy_modes(interface));
> -			return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;
> -		}
>  
> -		dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
> -			phy_modes(interface));
> +	if (!mac->soc_info->set_mode)
> +		return 0;
>  
> -		ret = mac->soc_info->set_mode(mac, phy_intf_sel);
> -		if (ret)
> -			return ret;
> -	}
> +	if (phy_intf_sel >= BITS_PER_BYTE ||
> +	    ~mac->soc_info->valid_phy_intf_sel & BIT(phy_intf_sel))
> +		return phy_intf_sel < 0 ? phy_intf_sel : -EINVAL;

nit from Smatch: phy_intf_sel is unsigned and thus cannot be negative

> +
> +	dev_dbg(mac->dev, "MAC PHY control register: interface %s\n",
> +		phy_modes(mac->plat_dat->phy_interface));
>  
> -	return 0;
> +	return mac->soc_info->set_mode(mac, phy_intf_sel);
>  }

...

  parent reply	other threads:[~2025-11-06 16:48 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-06  8:55 [PATCH net-next v2 00/11] net: stmmac: ingenic: convert to set_phy_intf_sel() Russell King (Oracle)
2025-11-06  8:57 ` [PATCH net-next v2 01/11] net: stmmac: ingenic: move ingenic_mac_init() Russell King (Oracle)
2025-11-06  9:58   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 02/11] net: stmmac: ingenic: simplify jz4775 mac_set_mode() Russell King (Oracle)
2025-11-06  9:59   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 03/11] net: stmmac: ingenic: use PHY_INTF_SEL_xxx to select PHY interface Russell King (Oracle)
2025-11-06  9:59   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 04/11] net: stmmac: ingenic: use PHY_INTF_SEL_x directly Russell King (Oracle)
2025-11-06 10:00   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 05/11] net: stmmac: ingenic: prep PHY_INTF_SEL_x field after switch() Russell King (Oracle)
2025-11-06 10:01   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 06/11] net: stmmac: ingenic: use stmmac_get_phy_intf_sel() Russell King (Oracle)
2025-11-06 10:05   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 07/11] net: stmmac: ingenic: move "MAC PHY control register" debug Russell King (Oracle)
2025-11-06 10:13   ` Maxime Chevallier
2025-11-06  8:57 ` [PATCH net-next v2 08/11] net: stmmac: ingenic: simplify mac_set_mode() methods Russell King (Oracle)
2025-11-06 10:15   ` Maxime Chevallier
2025-11-06  8:58 ` [PATCH net-next v2 09/11] net: stmmac: ingenic: simplify x2000 mac_set_mode() Russell King (Oracle)
2025-11-06 10:20   ` Maxime Chevallier
2025-11-06  8:58 ` [PATCH net-next v2 10/11] net: stmmac: ingenic: pass ingenic_mac struct rather than plat_dat Russell King (Oracle)
2025-11-06 10:22   ` Maxime Chevallier
2025-11-06  8:58 ` [PATCH net-next v2 11/11] net: stmmac: ingenic: use ->set_phy_intf_sel() Russell King (Oracle)
2025-11-06 10:30   ` Maxime Chevallier
2025-11-06 16:48   ` Simon Horman [this message]
2025-11-06  9:57 ` [PATCH net-next v2 00/11] net: stmmac: ingenic: convert to set_phy_intf_sel() Maxime Chevallier
2025-11-06 10:23   ` Russell King (Oracle)
2025-11-06 10:35     ` Maxime Chevallier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aQzRX6qHy5Yo7T5x@horms.kernel.org \
    --to=horms@kernel$(echo .)org \
    --cc=alexandre.torgue@foss$(echo .)st.com \
    --cc=andrew+netdev@lunn$(echo .)ch \
    --cc=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=hkallweit1@gmail$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-stm32@st-md-mailman$(echo .)stormreply.com \
    --cc=mcoquelin.stm32@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=rmk+kernel@armlinux$(echo .)org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox