linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: stmmac: sunxi cleanups
@ 2025-04-15 12:51 Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 1/3] net: stmmac: sunxi: convert to set_clk_tx_rate() Russell King (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 12:51 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Jernej Skrabec, linux-arm-kernel,
	linux-stm32, linux-sunxi, Maxime Coquelin, netdev, Paolo Abeni,
	Samuel Holland

Hi,

This series cleans up the sunxi (sun7i) code in two ways:

1. it converts to use the new set_clk_tx_rate() method, even though
   we don't use clk_tx_i. In doing so, I reformat the function to
   read better, but with no changes to the code.

2. convert from stmmac_dvr_probe() to stmmac_pltfr_probe(), and then
   to its devm variant, which allows code simplification.

 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 58 +++++++++--------------
 1 file changed, 22 insertions(+), 36 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] net: stmmac: sunxi: convert to set_clk_tx_rate()
  2025-04-15 12:51 [PATCH net-next 0/3] net: stmmac: sunxi cleanups Russell King (Oracle)
@ 2025-04-15 12:58 ` Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 2/3] net: stmmac: sunxi: use stmmac_pltfr_probe() Russell King (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 12:58 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Jernej Skrabec, linux-arm-kernel,
	linux-stm32, linux-sunxi, Maxime Coquelin, netdev, Paolo Abeni,
	Samuel Holland

Convert sunxi to use the set_clk_tx_rate() callback rather than the
fix_mac_speed() callback.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 42 +++++++++----------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index 9f098ff0ff05..a245c223a18f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -72,28 +72,28 @@ static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)
 		regulator_disable(gmac->regulator);
 }
 
-static void sun7i_fix_speed(void *priv, int speed, unsigned int mode)
+static int sun7i_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+				 phy_interface_t interface, int speed)
 {
-	struct sunxi_priv_data *gmac = priv;
-
-	/* only GMII mode requires us to reconfigure the clock lines */
-	if (gmac->interface != PHY_INTERFACE_MODE_GMII)
-		return;
-
-	if (gmac->clk_enabled) {
-		clk_disable(gmac->tx_clk);
-		gmac->clk_enabled = 0;
-	}
-	clk_unprepare(gmac->tx_clk);
-
-	if (speed == 1000) {
-		clk_set_rate(gmac->tx_clk, SUN7I_GMAC_GMII_RGMII_RATE);
-		clk_prepare_enable(gmac->tx_clk);
-		gmac->clk_enabled = 1;
-	} else {
-		clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE);
-		clk_prepare(gmac->tx_clk);
+	struct sunxi_priv_data *gmac = bsp_priv;
+
+	if (interface == PHY_INTERFACE_MODE_GMII) {
+		if (gmac->clk_enabled) {
+			clk_disable(gmac->tx_clk);
+			gmac->clk_enabled = 0;
+		}
+		clk_unprepare(gmac->tx_clk);
+
+		if (speed == 1000) {
+			clk_set_rate(gmac->tx_clk, SUN7I_GMAC_GMII_RGMII_RATE);
+			clk_prepare_enable(gmac->tx_clk);
+			gmac->clk_enabled = 1;
+		} else {
+			clk_set_rate(gmac->tx_clk, SUN7I_GMAC_MII_RATE);
+			clk_prepare(gmac->tx_clk);
+		}
 	}
+	return 0;
 }
 
 static int sun7i_gmac_probe(struct platform_device *pdev)
@@ -140,7 +140,7 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
 	plat_dat->bsp_priv = gmac;
 	plat_dat->init = sun7i_gmac_init;
 	plat_dat->exit = sun7i_gmac_exit;
-	plat_dat->fix_mac_speed = sun7i_fix_speed;
+	plat_dat->set_clk_tx_rate = sun7i_set_clk_tx_rate;
 	plat_dat->tx_fifo_size = 4096;
 	plat_dat->rx_fifo_size = 16384;
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] net: stmmac: sunxi: use stmmac_pltfr_probe()
  2025-04-15 12:51 [PATCH net-next 0/3] net: stmmac: sunxi cleanups Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 1/3] net: stmmac: sunxi: convert to set_clk_tx_rate() Russell King (Oracle)
@ 2025-04-15 12:58 ` Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 3/3] net: stmmac: sunxi: use devm_stmmac_pltfr_probe() Russell King (Oracle)
  2025-04-18  1:51 ` [PATCH net-next 0/3] net: stmmac: sunxi cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 12:58 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Jernej Skrabec, linux-arm-kernel,
	linux-stm32, linux-sunxi, Maxime Coquelin, netdev, Paolo Abeni,
	Samuel Holland

Rather than open-coding the calls to sun7i_gmac_init() and
sun7i_gmac_exit() in the probe function, use stmmac_pltfr_probe()
which will automatically call the plat_dat->init() and plat_dat->exit()
methods appropriately. This simplifies the code.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index a245c223a18f..665eab1d3409 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -144,20 +144,7 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
 	plat_dat->tx_fifo_size = 4096;
 	plat_dat->rx_fifo_size = 16384;
 
-	ret = sun7i_gmac_init(pdev, plat_dat->bsp_priv);
-	if (ret)
-		return ret;
-
-	ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
-	if (ret)
-		goto err_gmac_exit;
-
-	return 0;
-
-err_gmac_exit:
-	sun7i_gmac_exit(pdev, plat_dat->bsp_priv);
-
-	return ret;
+	return stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }
 
 static const struct of_device_id sun7i_dwmac_match[] = {
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] net: stmmac: sunxi: use devm_stmmac_pltfr_probe()
  2025-04-15 12:51 [PATCH net-next 0/3] net: stmmac: sunxi cleanups Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 1/3] net: stmmac: sunxi: convert to set_clk_tx_rate() Russell King (Oracle)
  2025-04-15 12:58 ` [PATCH net-next 2/3] net: stmmac: sunxi: use stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-15 12:58 ` Russell King (Oracle)
  2025-04-18  1:51 ` [PATCH net-next 0/3] net: stmmac: sunxi cleanups patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 12:58 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Jernej Skrabec, linux-arm-kernel,
	linux-stm32, linux-sunxi, Maxime Coquelin, netdev, Paolo Abeni,
	Samuel Holland

Using devm_stmmac_pltfr_probe() simplifies the probe function. This
will not only call plat_dat->init (sun7i_dwmac_init), but also
plat_dat->exit (sun7i_dwmac_exit) appropriately if stmmac_dvr_probe()
fails. This results in an overall simplification of the glue driver.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index 665eab1d3409..1eadcf5d1ad6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -144,7 +144,7 @@ static int sun7i_gmac_probe(struct platform_device *pdev)
 	plat_dat->tx_fifo_size = 4096;
 	plat_dat->rx_fifo_size = 16384;
 
-	return stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
+	return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
 }
 
 static const struct of_device_id sun7i_dwmac_match[] = {
@@ -155,7 +155,6 @@ MODULE_DEVICE_TABLE(of, sun7i_dwmac_match);
 
 static struct platform_driver sun7i_dwmac_driver = {
 	.probe  = sun7i_gmac_probe,
-	.remove = stmmac_pltfr_remove,
 	.driver = {
 		.name           = "sun7i-dwmac",
 		.pm		= &stmmac_pltfr_pm_ops,
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] net: stmmac: sunxi cleanups
  2025-04-15 12:51 [PATCH net-next 0/3] net: stmmac: sunxi cleanups Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-04-15 12:58 ` [PATCH net-next 3/3] net: stmmac: sunxi: use devm_stmmac_pltfr_probe() Russell King (Oracle)
@ 2025-04-18  1:51 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-18  1:51 UTC (permalink / raw)
  To: Russell King
  Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, wens, davem,
	edumazet, kuba, jernej.skrabec, linux-arm-kernel, linux-stm32,
	linux-sunxi, mcoquelin.stm32, netdev, pabeni, samuel

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 15 Apr 2025 13:51:27 +0100 you wrote:
> Hi,
> 
> This series cleans up the sunxi (sun7i) code in two ways:
> 
> 1. it converts to use the new set_clk_tx_rate() method, even though
>    we don't use clk_tx_i. In doing so, I reformat the function to
>    read better, but with no changes to the code.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net: stmmac: sunxi: convert to set_clk_tx_rate()
    https://git.kernel.org/netdev/net-next/c/a27d798fd83c
  - [net-next,2/3] net: stmmac: sunxi: use stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/dd2cdba4709f
  - [net-next,3/3] net: stmmac: sunxi: use devm_stmmac_pltfr_probe()
    https://git.kernel.org/netdev/net-next/c/69b3e38e2fb5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-18  1:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 12:51 [PATCH net-next 0/3] net: stmmac: sunxi cleanups Russell King (Oracle)
2025-04-15 12:58 ` [PATCH net-next 1/3] net: stmmac: sunxi: convert to set_clk_tx_rate() Russell King (Oracle)
2025-04-15 12:58 ` [PATCH net-next 2/3] net: stmmac: sunxi: use stmmac_pltfr_probe() Russell King (Oracle)
2025-04-15 12:58 ` [PATCH net-next 3/3] net: stmmac: sunxi: use devm_stmmac_pltfr_probe() Russell King (Oracle)
2025-04-18  1:51 ` [PATCH net-next 0/3] net: stmmac: sunxi cleanups patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).