net: dsa: b53: Defer port enabling to calling port_enable
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 19 Sep 2017 17:46:45 +0000 (10:46 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Sep 2017 23:08:53 +0000 (16:08 -0700)
There is no need to configure the enabled ports once in b53_setup() and then a
second time around when dsa_switch_ops::port_enable is called, just do it when
port_enable is called which is better in terms of power consumption and
correctness.

Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/b53/b53_common.c

index d8bc54cfcfbe2febb0677b69f504940f732bf5b2..3297af6aab8ac2a84cc3f2dd5b9dd42ad544fbbd 100644 (file)
@@ -815,12 +815,13 @@ static int b53_setup(struct dsa_switch *ds)
        if (ret)
                dev_err(ds->dev, "failed to apply configuration\n");
 
+       /* Configure IMP/CPU port, disable unused ports. Enabled
+        * ports will be configured with .port_enable
+        */
        for (port = 0; port < dev->num_ports; port++) {
-               if (BIT(port) & ds->enabled_port_mask)
-                       b53_enable_port(ds, port, NULL);
-               else if (dsa_is_cpu_port(ds, port))
+               if (dsa_is_cpu_port(ds, port))
                        b53_enable_cpu_port(dev, port);
-               else
+               else if (!(BIT(port) & ds->enabled_port_mask))
                        b53_disable_port(ds, port, NULL);
        }