Skip to content

Commit 9125534

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: stmmac: socfpga: call set_phy_mode() before registration
Initialisation/setup after registration is a bug. This is the second of two patches fixing this in socfpga. The set_phy_mode() functions do various hardware setup that would interfere with a netdev that has been published, and thus available to be opened by the kernel/userspace. However, set_phy_mode() relies upon the netdev having been initialised to get at the plat_stmmacenet_data structure, which is probably why it was placed after stmmac_drv_probe(). We can remove that need by storing a pointer to struct plat_stmmacenet_data in struct socfpga_dwmac. Move the call to set_phy_mode() before calling stmmac_dvr_probe(). This also simplifies the probe function as there is no need to unregister the netdev if set_phy_mode() fails. Signed-off-by: Russell King (Oracle) <[email protected]> Tested-by: Maxime Chevallier <[email protected]> Reviewed-by: Maxime Chevallier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6bf70d9 commit 9125534

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct socfpga_dwmac {
5050
u32 reg_offset;
5151
u32 reg_shift;
5252
struct device *dev;
53+
struct plat_stmmacenet_data *plat_dat;
5354
struct regmap *sys_mgr_base_addr;
5455
struct reset_control *stmmac_rst;
5556
struct reset_control *stmmac_ocp_rst;
@@ -233,10 +234,7 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *
233234

234235
static int socfpga_get_plat_phymode(struct socfpga_dwmac *dwmac)
235236
{
236-
struct net_device *ndev = dev_get_drvdata(dwmac->dev);
237-
struct stmmac_priv *priv = netdev_priv(ndev);
238-
239-
return priv->plat->mac_interface;
237+
return dwmac->plat_dat->mac_interface;
240238
}
241239

242240
static void socfpga_sgmii_config(struct socfpga_dwmac *dwmac, bool enable)
@@ -490,6 +488,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
490488
*/
491489
dwmac->stmmac_rst = plat_dat->stmmac_rst;
492490
dwmac->ops = ops;
491+
dwmac->plat_dat = plat_dat;
493492

494493
plat_dat->bsp_priv = dwmac;
495494
plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed;
@@ -501,20 +500,11 @@ static int socfpga_dwmac_probe(struct platform_device *pdev)
501500

502501
plat_dat->riwt_off = 1;
503502

504-
ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
505-
if (ret)
506-
return ret;
507-
508503
ret = socfpga_dwmac_init(pdev, dwmac);
509504
if (ret)
510-
goto err_dvr_remove;
511-
512-
return 0;
513-
514-
err_dvr_remove:
515-
stmmac_dvr_remove(&pdev->dev);
505+
return ret;
516506

517-
return ret;
507+
return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
518508
}
519509

520510
static const struct socfpga_dwmac_ops socfpga_gen5_ops = {

0 commit comments

Comments
 (0)