Skip to contentSkip to conversation

net: dsa: allow switch drivers to cleanup their resources

PATCH Superseded Neil Armstrong 3 participants 5 messages Oct 27, 2015 – Oct 28, 2015

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/6 net: dsa: allow switch drivers to cleanup their resources

Some switch drivers might request interrupts, remap register ranges, allow such drivers to implement a "remove" callback doing just that.

---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c     | 4 ++++
 2 files changed, 5 insertions(+)
include/net/dsa.h +1 -0
index d4d13f7..725b11f 100644
@@ -211,6 +211,7 @@ struct dsa_switch_driver {
 	 */
 	char	*(*probe)(struct device *host_dev, int sw_addr);
 	int	(*setup)(struct dsa_switch *ds);
+	void	(*remove)(struct dsa_switch *ds);
 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
 
net/dsa/dsa.c +4 -0
index aeb6a7c..7c9914b 100644
@@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 	}
 
 	mdiobus_unregister(ds->slave_mii_bus);
+
+	/* Leave a chance to the driver to cleanup */
+	if (ds->drv->remove)
+		ds->drv->remove(ds);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Neil Armstrong

Some switch drivers might request interrupts, remap register ranges, allow such drivers to implement a "remove" callback doing just that.

This should probably be a Signed-off-by tag, but there is nothing using this, so you would want to introduce an user of this function in the same patch series so we see how you intend to use it?

Quoted 34 lines
---
 include/net/dsa.h | 1 +
 net/dsa/dsa.c     | 4 ++++
 2 files changed, 5 insertions(+)
include/net/dsa.h +1 -0
index d4d13f7..725b11f 100644
@@ -211,6 +211,7 @@ struct dsa_switch_driver {
 	 */
 	char	*(*probe)(struct device *host_dev, int sw_addr);
 	int	(*setup)(struct dsa_switch *ds);
+	void	(*remove)(struct dsa_switch *ds);
 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
 
net/dsa/dsa.c +4 -0
index aeb6a7c..7c9914b 100644
@@ -459,6 +459,10 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 	}
 
 	mdiobus_unregister(ds->slave_mii_bus);
+
+	/* Leave a chance to the driver to cleanup */
+	if (ds->drv->remove)
+		ds->drv->remove(ds);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
Florian
#2 lore raw

Hi,

Quoted 11 lines · Florian Fainelli
Quoted 4 lines · Neil Armstrong

Some switch drivers might request interrupts, remap register ranges, allow such drivers to implement a "remove" callback doing just that.

This should probably be a Signed-off-by tag, but there is nothing using this, so you would want to introduce an user of this function in the same patch series so we see how you intend to use it?

Quoted 1 line

Yes, I didn't know how to handle this since it was part of a larger patch.

I forgot to add this into the cover-letter but I wanted to send an RFC serie with your bcm remove patch and a mv88e6xxx remove experimental code.

Yet, the mv88e6060 does not make usage of this.

Neil

#3 lore raw
Quoted 12 lines · Neil Armstrong

Hi,

Quoted 10 lines · Florian Fainelli
Quoted 4 lines · Neil Armstrong

Some switch drivers might request interrupts, remap register ranges, allow such drivers to implement a "remove" callback doing just that.

This should probably be a Signed-off-by tag, but there is nothing using this, so you would want to introduce an user of this function in the same patch series so we see how you intend to use it?

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Yes, I didn't know how to handle this since it was part of a larger patch.

I forgot to add this into the cover-letter but I wanted to send an RFC serie with your bcm remove patch and a mv88e6xxx remove experimental code.

Yet, the mv88e6060 does not make usage of this.

So this patch must be part of your RFC for module removal instead of this patchset.

Thanks,
-v

#4 lore raw
Quoted 7 lines · Vivien Didelot
Quoted 6 lines · Neil Armstrong

Yes, I didn't know how to handle this since it was part of a larger patch.

I forgot to add this into the cover-letter but I wanted to send an RFC serie with your bcm remove patch and a mv88e6xxx remove experimental code.

Quoted 8 lines
Quoted 1 line

Yet, the mv88e6060 does not make usage of this.

So this patch must be part of your RFC for module removal instead of this patchset.

Thanks,
-v

Vivien, Florian,

Thanks for the review, I will integrate it in the other RFC patchset with the correct Signed-off-by tag.

Neil