]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: gemini: Clean up phy registration
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 6 Sep 2020 19:21:13 +0000 (21:21 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sun, 6 Sep 2020 19:27:00 +0000 (12:27 -0700)
It's nice if the phy is online before we register the netdev
so try to do that first.

Stop trying to do "second tried" to register the phy, it
works perfectly fine the first time.

Stop remvoving the phy in uninit. Remove it when the
driver is remove():d, symmetric to where it is added, in
probe().

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reported-by: David Miller <davem@davemloft.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cortina/gemini.c

index ffec0f3dd9578e1d0eb61a9f1bb6fc36522bfc1b..9dcf47f576c6b17ac3828d34679ed4e351898e8d 100644 (file)
@@ -539,12 +539,6 @@ static int gmac_init(struct net_device *netdev)
        return 0;
 }
 
-static void gmac_uninit(struct net_device *netdev)
-{
-       if (netdev->phydev)
-               phy_disconnect(netdev->phydev);
-}
-
 static int gmac_setup_txqs(struct net_device *netdev)
 {
        struct gemini_ethernet_port *port = netdev_priv(netdev);
@@ -1768,15 +1762,6 @@ static int gmac_open(struct net_device *netdev)
        struct gemini_ethernet_port *port = netdev_priv(netdev);
        int err;
 
-       if (!netdev->phydev) {
-               err = gmac_setup_phy(netdev);
-               if (err) {
-                       netif_err(port, ifup, netdev,
-                                 "PHY init failed: %d\n", err);
-                       return err;
-               }
-       }
-
        err = request_irq(netdev->irq, gmac_irq,
                          IRQF_SHARED, netdev->name, netdev);
        if (err) {
@@ -2209,7 +2194,6 @@ static void gmac_get_drvinfo(struct net_device *netdev,
 
 static const struct net_device_ops gmac_351x_ops = {
        .ndo_init               = gmac_init,
-       .ndo_uninit             = gmac_uninit,
        .ndo_open               = gmac_open,
        .ndo_stop               = gmac_stop,
        .ndo_start_xmit         = gmac_start_xmit,
@@ -2295,8 +2279,10 @@ static irqreturn_t gemini_port_irq(int irq, void *data)
 
 static void gemini_port_remove(struct gemini_ethernet_port *port)
 {
-       if (port->netdev)
+       if (port->netdev) {
+               phy_disconnect(port->netdev->phydev);
                unregister_netdev(port->netdev);
+       }
        clk_disable_unprepare(port->pclk);
        geth_cleanup_freeq(port->geth);
 }
@@ -2505,6 +2491,13 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
        if (ret)
                goto unprepare;
 
+       ret = gmac_setup_phy(netdev);
+       if (ret) {
+               netdev_err(netdev,
+                          "PHY init failed\n");
+               goto unprepare;
+       }
+
        ret = register_netdev(netdev);
        if (ret)
                goto unprepare;
@@ -2513,10 +2506,6 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
                    "irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
                    port->irq, &dmares->start,
                    &gmacres->start);
-       ret = gmac_setup_phy(netdev);
-       if (ret)
-               netdev_info(netdev,
-                           "PHY init failed, deferring to ifup time\n");
        return 0;
 
 unprepare:
@@ -2529,6 +2518,7 @@ static int gemini_ethernet_port_remove(struct platform_device *pdev)
        struct gemini_ethernet_port *port = platform_get_drvdata(pdev);
 
        gemini_port_remove(port);
+
        return 0;
 }