net: dsa: use temporary dsa_device_ops variable
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Fri, 29 Sep 2017 21:19:17 +0000 (17:19 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Oct 2017 03:15:07 +0000 (04:15 +0100)
When resolving the DSA tagging protocol used by a CPU switch, use a
temporary "tag_ops" variable to store the dsa_device_ops instead of
using directly dst->tag_ops. This will make the future patches moving
this pointer around easier to read.

There is no functional changes.

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

index dcccaeb..6a10c5c 100644 (file)
@@ -485,6 +485,7 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
                         struct dsa_switch_tree *dst,
                         struct dsa_switch *ds)
 {
+       const struct dsa_device_ops *tag_ops;
        enum dsa_tag_protocol tag_protocol;
        struct net_device *ethernet_dev;
        struct device_node *ethernet;
@@ -514,13 +515,14 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
        ds->cpu_port_mask |= BIT(index);
 
        tag_protocol = ds->ops->get_tag_protocol(ds);
-       dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
-       if (IS_ERR(dst->tag_ops)) {
+       tag_ops = dsa_resolve_tag_protocol(tag_protocol);
+       if (IS_ERR(tag_ops)) {
                dev_warn(ds->dev, "No tagger for this switch\n");
                ds->cpu_port_mask &= ~BIT(index);
-               return PTR_ERR(dst->tag_ops);
+               return PTR_ERR(tag_ops);
        }
 
+       dst->tag_ops = tag_ops;
        dst->rcv = dst->tag_ops->rcv;
 
        return 0;
index ae505d8..8e84901 100644 (file)
@@ -144,13 +144,15 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
         * switch.
         */
        if (dst->cpu_dp->ds == ds) {
+               const struct dsa_device_ops *tag_ops;
                enum dsa_tag_protocol tag_protocol;
 
                tag_protocol = ops->get_tag_protocol(ds);
-               dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
-               if (IS_ERR(dst->tag_ops))
-                       return PTR_ERR(dst->tag_ops);
+               tag_ops = dsa_resolve_tag_protocol(tag_protocol);
+               if (IS_ERR(tag_ops))
+                       return PTR_ERR(tag_ops);
 
+               dst->tag_ops = tag_ops;
                dst->rcv = dst->tag_ops->rcv;
        }