]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: make tree index unsigned
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Fri, 3 Nov 2017 23:05:21 +0000 (19:05 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 5 Nov 2017 13:31:38 +0000 (22:31 +0900)
Similarly to a DSA switch and port, rename the tree index from "tree" to
"index" and make it an unsigned int because it isn't supposed to be less
than 0.

u32 is an OF specific data used to retrieve the value and has no need to
be propagated up to the tree index.

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>
include/net/dsa.h
net/dsa/dsa2.c
net/dsa/slave.c

index fa1c21ab809291687ca8373fa431c9b3714e3e03..e54332968417b5995acf4712f55a082a1a1dcfd1 100644 (file)
@@ -116,7 +116,7 @@ struct dsa_switch_tree {
        struct raw_notifier_head        nh;
 
        /* Tree identifier */
-       u32 tree;
+       unsigned int index;
 
        /* Number of switches attached to this tree */
        struct kref refcount;
index 797d1156b4e658727de5766ce02e416a5ae8d6b9..8b68dc2f570764f215dd8bac6bf7aff8742d15db 100644 (file)
@@ -27,12 +27,12 @@ static DEFINE_MUTEX(dsa2_mutex);
 static const struct devlink_ops dsa_devlink_ops = {
 };
 
-static struct dsa_switch_tree *dsa_get_dst(u32 tree)
+static struct dsa_switch_tree *dsa_get_dst(unsigned int index)
 {
        struct dsa_switch_tree *dst;
 
        list_for_each_entry(dst, &dsa_switch_trees, list)
-               if (dst->tree == tree) {
+               if (dst->index == index) {
                        kref_get(&dst->refcount);
                        return dst;
                }
@@ -53,14 +53,14 @@ static void dsa_put_dst(struct dsa_switch_tree *dst)
        kref_put(&dst->refcount, dsa_free_dst);
 }
 
-static struct dsa_switch_tree *dsa_add_dst(u32 tree)
+static struct dsa_switch_tree *dsa_add_dst(unsigned int index)
 {
        struct dsa_switch_tree *dst;
 
        dst = kzalloc(sizeof(*dst), GFP_KERNEL);
        if (!dst)
                return NULL;
-       dst->tree = tree;
+       dst->index = index;
        INIT_LIST_HEAD(&dst->list);
        list_add_tail(&dsa_switch_trees, &dst->list);
        kref_init(&dst->refcount);
@@ -454,7 +454,7 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
 
        dst->cpu_dp = NULL;
 
-       pr_info("DSA: tree %d unapplied\n", dst->tree);
+       pr_info("DSA: tree %d unapplied\n", dst->index);
        dst->applied = false;
 }
 
@@ -504,7 +504,7 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 
        }
 
-       pr_info("DSA: switch %d %d parsed\n", dst->tree, ds->index);
+       pr_info("DSA: switch %d %d parsed\n", dst->index, ds->index);
 
        return 0;
 }
@@ -549,7 +549,7 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
                }
        }
 
-       pr_info("DSA: tree %d parsed\n", dst->tree);
+       pr_info("DSA: tree %d parsed\n", dst->index);
 
        return 0;
 }
index 9b75d0ac40929b549851faa941f3620f716bbe5b..814ced75a0ccfb7945c966aaecc7d30536868e4a 100644 (file)
@@ -55,7 +55,7 @@ void dsa_slave_mii_bus_init(struct dsa_switch *ds)
        ds->slave_mii_bus->read = dsa_slave_phy_read;
        ds->slave_mii_bus->write = dsa_slave_phy_write;
        snprintf(ds->slave_mii_bus->id, MII_BUS_ID_SIZE, "dsa-%d.%d",
-                ds->dst->tree, ds->index);
+                ds->dst->index, ds->index);
        ds->slave_mii_bus->parent = ds->dev;
        ds->slave_mii_bus->phy_mask = ~ds->phys_mii_mask;
 }