* [PATCH net-next v3] stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe
@ 2024-11-15 13:26 Vitalii Mordan
2024-11-19 4:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Vitalii Mordan @ 2024-11-15 13:26 UTC (permalink / raw)
To: Alexandre Torgue
Cc: Vitalii Mordan, Jose Abreu, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Maxime Coquelin, netdev,
linux-stm32, linux-arm-kernel, linux-kernel, lvc-project,
Fedor Pchelkin, Alexey Khoroshilov, Vadim Mutilin, Andrew Lunn
The driver’s compatibility with devices is confirmed earlier in
platform_match(). Since reaching probe means the device is valid,
the extra check can be removed to simplify the code.
Signed-off-by: Vitalii Mordan <mordan@ispras.ru>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
v2: Add a comment explaining why dwmac->data cannot be NULL, as per
Andrew Lunn's request.
v3: Resolve merge conflicts.
.../stmicro/stmmac/dwmac-intel-plat.c | 53 ++++++++++---------
1 file changed, 28 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index a433526dcbe8..d94f0a150e93 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -97,35 +97,38 @@ static int intel_eth_plat_probe(struct platform_device *pdev)
dwmac->dev = &pdev->dev;
dwmac->tx_clk = NULL;
+ /*
+ * This cannot return NULL at this point because the driver’s
+ * compatibility with the device has already been validated in
+ * platform_match().
+ */
dwmac->data = device_get_match_data(&pdev->dev);
- if (dwmac->data) {
- if (dwmac->data->fix_mac_speed)
- plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
-
- /* Enable TX clock */
- if (dwmac->data->tx_clk_en) {
- dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
- if (IS_ERR(dwmac->tx_clk))
- return PTR_ERR(dwmac->tx_clk);
+ if (dwmac->data->fix_mac_speed)
+ plat_dat->fix_mac_speed = dwmac->data->fix_mac_speed;
+
+ /* Enable TX clock */
+ if (dwmac->data->tx_clk_en) {
+ dwmac->tx_clk = devm_clk_get(&pdev->dev, "tx_clk");
+ if (IS_ERR(dwmac->tx_clk))
+ return PTR_ERR(dwmac->tx_clk);
+
+ ret = clk_prepare_enable(dwmac->tx_clk);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Failed to enable tx_clk\n");
+ return ret;
+ }
- ret = clk_prepare_enable(dwmac->tx_clk);
+ /* Check and configure TX clock rate */
+ rate = clk_get_rate(dwmac->tx_clk);
+ if (dwmac->data->tx_clk_rate &&
+ rate != dwmac->data->tx_clk_rate) {
+ rate = dwmac->data->tx_clk_rate;
+ ret = clk_set_rate(dwmac->tx_clk, rate);
if (ret) {
dev_err(&pdev->dev,
- "Failed to enable tx_clk\n");
- return ret;
- }
-
- /* Check and configure TX clock rate */
- rate = clk_get_rate(dwmac->tx_clk);
- if (dwmac->data->tx_clk_rate &&
- rate != dwmac->data->tx_clk_rate) {
- rate = dwmac->data->tx_clk_rate;
- ret = clk_set_rate(dwmac->tx_clk, rate);
- if (ret) {
- dev_err(&pdev->dev,
- "Failed to set tx_clk\n");
- goto err_tx_clk_disable;
- }
+ "Failed to set tx_clk\n");
+ goto err_tx_clk_disable;
}
}
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH net-next v3] stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe
2024-11-15 13:26 [PATCH net-next v3] stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe Vitalii Mordan
@ 2024-11-19 4:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-11-19 4:00 UTC (permalink / raw)
To: Vitalii Mordan
Cc: alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
mcoquelin.stm32, netdev, linux-stm32, linux-arm-kernel,
linux-kernel, lvc-project, pchelkin, khoroshilov, mutilin,
andrew
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 15 Nov 2024 16:26:32 +0300 you wrote:
> The driver’s compatibility with devices is confirmed earlier in
> platform_match(). Since reaching probe means the device is valid,
> the extra check can be removed to simplify the code.
>
> Signed-off-by: Vitalii Mordan <mordan@ispras.ru>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> [...]
Here is the summary with links:
- [net-next,v3] stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe
https://git.kernel.org/netdev/net-next/c/cc84d89ad8d4
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] 2+ messages in thread
end of thread, other threads:[~2024-11-19 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-15 13:26 [PATCH net-next v3] stmmac: dwmac-intel-plat: remove redundant dwmac->data check in probe Vitalii Mordan
2024-11-19 4:00 ` 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
Powered by JetHome