Skip to content

Commit

Permalink
net: macb: sort init_reset_optional() with other init()s
Browse files Browse the repository at this point in the history
init_reset_optional() is somewhat oddly placed amidst the macb_config
struct definitions. Move it to a more reasonable location alongside
the fu540 init functions.

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Conor Dooley authored and Jakub Kicinski committed Jul 8, 2022
1 parent ea242f8 commit 8a78ac7
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4600,6 +4600,40 @@ static int fu540_c000_init(struct platform_device *pdev)
return macb_init(pdev);
}

static int init_reset_optional(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct macb *bp = netdev_priv(dev);
int ret;

if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) {
/* Ensure PHY device used in SGMII mode is ready */
bp->sgmii_phy = devm_phy_optional_get(&pdev->dev, NULL);

if (IS_ERR(bp->sgmii_phy))
return dev_err_probe(&pdev->dev, PTR_ERR(bp->sgmii_phy),
"failed to get SGMII PHY\n");

ret = phy_init(bp->sgmii_phy);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"failed to init SGMII PHY\n");
}

/* Fully reset controller at hardware level if mapped in device tree */
ret = device_reset_optional(&pdev->dev);
if (ret) {
phy_exit(bp->sgmii_phy);
return dev_err_probe(&pdev->dev, ret, "failed to reset controller");
}

ret = macb_init(pdev);
if (ret)
phy_exit(bp->sgmii_phy);

return ret;
}

static const struct macb_usrio_config sama7g5_usrio = {
.mii = 0,
.rmii = 1,
Expand Down Expand Up @@ -4689,40 +4723,6 @@ static const struct macb_config np4_config = {
.usrio = &macb_default_usrio,
};

static int init_reset_optional(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct macb *bp = netdev_priv(dev);
int ret;

if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) {
/* Ensure PHY device used in SGMII mode is ready */
bp->sgmii_phy = devm_phy_optional_get(&pdev->dev, NULL);

if (IS_ERR(bp->sgmii_phy))
return dev_err_probe(&pdev->dev, PTR_ERR(bp->sgmii_phy),
"failed to get SGMII PHY\n");

ret = phy_init(bp->sgmii_phy);
if (ret)
return dev_err_probe(&pdev->dev, ret,
"failed to init SGMII PHY\n");
}

/* Fully reset controller at hardware level if mapped in device tree */
ret = device_reset_optional(&pdev->dev);
if (ret) {
phy_exit(bp->sgmii_phy);
return dev_err_probe(&pdev->dev, ret, "failed to reset controller");
}

ret = macb_init(pdev);
if (ret)
phy_exit(bp->sgmii_phy);

return ret;
}

static const struct macb_config zynqmp_config = {
.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE |
MACB_CAPS_JUMBO |
Expand Down

0 comments on commit 8a78ac7

Please sign in to comment.