Skip to contentSkip to conversation

net-next: dsa: set_addr should be optional

PATCH In review John Crispin 4 participants 9 messages Sep 19, 2016 – Sep 20, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net-next: dsa: set_addr should be optional

The Marvell driver is the only one that actually sets the switches HW address. All other drivers have an empty stub. fix this by making the callback optional.

John Crispin (4):
net-next: dsa: fix duplicate invocation of set_addr()
net-next: dsa: make the set_addr() operation optional
net-next: dsa: b53: remove empty set_addr() stub
net-next: dsa: qca8k: remove empty set_addr() stub

 drivers/net/dsa/b53/b53_common.c |    6 ------
 drivers/net/dsa/qca8k.c          |    8 --------
 net/dsa/dsa.c                    |    8 +++++---
 net/dsa/dsa2.c                   |   12 +++++-------
 4 files changed, 10 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 3/4 net-next: dsa: b53: remove empty set_addr() stub

The set_addr() callback is now optional. Remove the empty stub that b53 has.

---
 drivers/net/dsa/b53/b53_common.c |    6 ------
 1 file changed, 6 deletions(-)
drivers/net/dsa/b53/b53_common.c +0 -6
index 0afc2e5..1a492c0 100644
@@ -764,11 +764,6 @@ static int b53_get_sset_count(struct dsa_switch *ds)
 	return b53_get_mib_size(dev);
 }
 
-static int b53_set_addr(struct dsa_switch *ds, u8 *addr)
-{
-	return 0;
-}
-
 static int b53_setup(struct dsa_switch *ds)
 {
 	struct b53_device *dev = ds->priv;
@@ -1466,7 +1461,6 @@ static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
 static struct dsa_switch_ops b53_switch_ops = {
 	.get_tag_protocol	= b53_get_tag_protocol,
 	.setup			= b53_setup,
-	.set_addr		= b53_set_addr,
 	.get_strings		= b53_get_strings,
 	.get_ethtool_stats	= b53_get_ethtool_stats,
 	.get_sset_count		= b53_get_sset_count,
Signature · 1 line
1.7.10.4
#5 lore raw

PATCH 4/4 net-next: dsa: qca8k: remove empty set_addr() stub

In reply to John Crispin

The set_addr() callback is now optional. Remove the empty stub that qca8k has.

---
 drivers/net/dsa/qca8k.c |    8 --------
 1 file changed, 8 deletions(-)
drivers/net/dsa/qca8k.c +0 -8
index 7f3f178..4788a89 100644
@@ -586,13 +586,6 @@ qca8k_setup(struct dsa_switch *ds)
 }
 
 static int
-qca8k_set_addr(struct dsa_switch *ds, u8 *addr)
-{
-	/* The subsystem always calls this function so add an empty stub */
-	return 0;
-}
-
-static int
 qca8k_phy_read(struct dsa_switch *ds, int phy, int regnum)
 {
 	struct qca8k_priv *priv = (struct qca8k_priv *)ds->priv;
@@ -921,7 +914,6 @@ qca8k_get_tag_protocol(struct dsa_switch *ds)
 static struct dsa_switch_ops qca8k_switch_ops = {
 	.get_tag_protocol	= qca8k_get_tag_protocol,
 	.setup			= qca8k_setup,
-	.set_addr		= qca8k_set_addr,
 	.get_strings		= qca8k_get_strings,
 	.phy_read		= qca8k_phy_read,
 	.phy_write		= qca8k_phy_write,
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/4 net-next: dsa: fix duplicate invocation of set_addr()

In reply to John Crispin

commit 83c0afaec7b730b ("net: dsa: Add new binding implementation") has a duplicate invocation of the set_addr() operation callback. Remove one of them.

---
 net/dsa/dsa2.c |    4 ----
 1 file changed, 4 deletions(-)
net/dsa/dsa2.c +0 -4
index 8278385..cffc19e 100644
@@ -308,10 +308,6 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 	if (err < 0)
 		return err;
 
-	err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr);
-	if (err < 0)
-		return err;
-
 	if (!ds->slave_mii_bus && ds->ops->phy_read) {
 		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
 		if (!ds->slave_mii_bus)
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/4 net-next: dsa: make the set_addr() operation optional

In reply to John Crispin

Only 1 of the 3 drivers currently has a set_addr() operation. Make the set_addr() callback optional to reduce the amount of empty stubs inside the drivers.

---
 net/dsa/dsa.c  |    8 +++++---
 net/dsa/dsa2.c |    8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
net/dsa/dsa.c +5 -3
index 66e31ac..a6902c1 100644
@@ -378,9 +378,11 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
 	if (ret < 0)
 		goto out;
 
-	ret = ops->set_addr(ds, dst->master_netdev->dev_addr);
-	if (ret < 0)
-		goto out;
+	if (ops->set_addr) {
+		ret = ops->set_addr(ds, dst->master_netdev->dev_addr);
+		if (ret < 0)
+			goto out;
+	}
 
 	if (!ds->slave_mii_bus && ops->phy_read) {
 		ds->slave_mii_bus = devm_mdiobus_alloc(parent);
net/dsa/dsa2.c +5 -3
index cffc19e..f8a7d9a 100644
@@ -304,9 +304,11 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
 	if (err < 0)
 		return err;
 
-	err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr);
-	if (err < 0)
-		return err;
+	if (ds->ops->set_addr) {
+		err = ds->ops->set_addr(ds, dst->master_netdev->dev_addr);
+		if (err < 0)
+			return err;
+	}
 
 	if (!ds->slave_mii_bus && ds->ops->phy_read) {
 		ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
Signature · 1 line
1.7.10.4
maintainer Reviewed-by on the v1 series
#6 lore raw
In reply to John Crispin
Quoted 3 lines · John Crispin

The Marvell driver is the only one that actually sets the switches HW address. All other drivers have an empty stub. fix this by making the callback optional.

Hi John

Thanks for doing this,

Andrew

Reviewed-by on the v1 series
#7 lore raw
In reply to John Crispin
Quoted 9 lines · John Crispin

The Marvell driver is the only one that actually sets the switches HW address. All other drivers have an empty stub. fix this by making the callback optional.

John Crispin (4):
net-next: dsa: fix duplicate invocation of set_addr()
net-next: dsa: make the set_addr() operation optional
net-next: dsa: b53: remove empty set_addr() stub
net-next: dsa: qca8k: remove empty set_addr() stub

Signature · 1 line
Florian
maintainer
#8 lore raw
In reply to John Crispin

From: John Crispin <[email protected]>
Date: Mon, 19 Sep 2016 15:27:59 +0200

Quoted 3 lines

The Marvell driver is the only one that actually sets the switches HW address. All other drivers have an empty stub. fix this by making the callback optional.

Series applied, thanks.