]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: fman: Store en/disable in mac_device instead of mac_priv_s
authorSean Anderson <sean.anderson@seco.com>
Thu, 18 Aug 2022 16:16:28 +0000 (12:16 -0400)
committerJakub Kicinski <kuba@kernel.org>
Fri, 19 Aug 2022 23:35:54 +0000 (16:35 -0700)
All macs use the same start/stop functions. The actual mac-specific code
lives in enable/disable. Move these functions to an appropriate struct,
and inline the phy enable/disable calls to the caller of start/stop.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Acked-by: Camelia Groza <camelia.groza@nxp.com>
Tested-by: Camelia Groza <camelia.groza@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/fman/mac.c
drivers/net/ethernet/freescale/fman/mac.h

index 45634579adb67814dc3c228f778cf2fda2028695..a548598b2e2d603ada36930c424b5339d95ae21c 100644 (file)
@@ -288,9 +288,11 @@ static int dpaa_stop(struct net_device *net_dev)
         */
        msleep(200);
 
-       err = mac_dev->stop(mac_dev);
+       if (mac_dev->phy_dev)
+               phy_stop(mac_dev->phy_dev);
+       err = mac_dev->disable(mac_dev->fman_mac);
        if (err < 0)
-               netif_err(priv, ifdown, net_dev, "mac_dev->stop() = %d\n",
+               netif_err(priv, ifdown, net_dev, "mac_dev->disable() = %d\n",
                          err);
 
        for (i = 0; i < ARRAY_SIZE(mac_dev->port); i++) {
@@ -2942,11 +2944,12 @@ static int dpaa_open(struct net_device *net_dev)
                        goto mac_start_failed;
        }
 
-       err = priv->mac_dev->start(mac_dev);
+       err = priv->mac_dev->enable(mac_dev->fman_mac);
        if (err < 0) {
-               netif_err(priv, ifup, net_dev, "mac_dev->start() = %d\n", err);
+               netif_err(priv, ifup, net_dev, "mac_dev->enable() = %d\n", err);
                goto mac_start_failed;
        }
+       phy_start(priv->mac_dev->phy_dev);
 
        netif_tx_start_all_queues(net_dev);
 
index a8d521760ffc7ef194c7f4d100d4fe96b4d226a1..6a4eaca837006d03a86ff6f9feeaae8bb2f91762 100644 (file)
@@ -39,9 +39,6 @@ struct mac_priv_s {
        struct fixed_phy_status         *fixed_link;
        u16                             speed;
        u16                             max_speed;
-
-       int (*enable)(struct fman_mac *mac_dev);
-       int (*disable)(struct fman_mac *mac_dev);
 };
 
 struct mac_address {
@@ -241,29 +238,6 @@ static int memac_initialization(struct mac_device *mac_dev)
        return err;
 }
 
-static int start(struct mac_device *mac_dev)
-{
-       int      err;
-       struct phy_device *phy_dev = mac_dev->phy_dev;
-       struct mac_priv_s *priv = mac_dev->priv;
-
-       err = priv->enable(mac_dev->fman_mac);
-       if (!err && phy_dev)
-               phy_start(phy_dev);
-
-       return err;
-}
-
-static int stop(struct mac_device *mac_dev)
-{
-       struct mac_priv_s *priv = mac_dev->priv;
-
-       if (mac_dev->phy_dev)
-               phy_stop(mac_dev->phy_dev);
-
-       return priv->disable(mac_dev->fman_mac);
-}
-
 static int set_multi(struct net_device *net_dev, struct mac_device *mac_dev)
 {
        struct mac_priv_s       *priv;
@@ -454,11 +428,9 @@ static void setup_dtsec(struct mac_device *mac_dev)
        mac_dev->set_allmulti           = dtsec_set_allmulti;
        mac_dev->set_tstamp             = dtsec_set_tstamp;
        mac_dev->set_multi              = set_multi;
-       mac_dev->start                  = start;
-       mac_dev->stop                   = stop;
        mac_dev->adjust_link            = adjust_link_dtsec;
-       mac_dev->priv->enable           = dtsec_enable;
-       mac_dev->priv->disable          = dtsec_disable;
+       mac_dev->enable                 = dtsec_enable;
+       mac_dev->disable                = dtsec_disable;
 }
 
 static void setup_tgec(struct mac_device *mac_dev)
@@ -474,11 +446,9 @@ static void setup_tgec(struct mac_device *mac_dev)
        mac_dev->set_allmulti           = tgec_set_allmulti;
        mac_dev->set_tstamp             = tgec_set_tstamp;
        mac_dev->set_multi              = set_multi;
-       mac_dev->start                  = start;
-       mac_dev->stop                   = stop;
        mac_dev->adjust_link            = adjust_link_void;
-       mac_dev->priv->enable           = tgec_enable;
-       mac_dev->priv->disable          = tgec_disable;
+       mac_dev->enable                 = tgec_enable;
+       mac_dev->disable                = tgec_disable;
 }
 
 static void setup_memac(struct mac_device *mac_dev)
@@ -494,11 +464,9 @@ static void setup_memac(struct mac_device *mac_dev)
        mac_dev->set_allmulti           = memac_set_allmulti;
        mac_dev->set_tstamp             = memac_set_tstamp;
        mac_dev->set_multi              = set_multi;
-       mac_dev->start                  = start;
-       mac_dev->stop                   = stop;
        mac_dev->adjust_link            = adjust_link_memac;
-       mac_dev->priv->enable           = memac_enable;
-       mac_dev->priv->disable          = memac_disable;
+       mac_dev->enable                 = memac_enable;
+       mac_dev->disable                = memac_disable;
 }
 
 #define DTSEC_SUPPORTED \
index 909faf5fa2fedbf82bd9cd170740b35055b4daf1..95f67b4efb61553022d9d992b86588eb3a30c84f 100644 (file)
@@ -36,8 +36,8 @@ struct mac_device {
        bool allmulti;
 
        int (*init)(struct mac_device *mac_dev);
-       int (*start)(struct mac_device *mac_dev);
-       int (*stop)(struct mac_device *mac_dev);
+       int (*enable)(struct fman_mac *mac_dev);
+       int (*disable)(struct fman_mac *mac_dev);
        void (*adjust_link)(struct mac_device *mac_dev);
        int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
        int (*change_addr)(struct fman_mac *mac_dev, const enet_addr_t *enet_addr);