Skip to contentSkip to conversation

net: dsa: allow switch drivers to cleanup their resources

RFC PATCH In review Neil Armstrong 2 participants 3 messages Oct 29, 2015

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

RFC PATCH v3 1/5 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 98ccbde..0e1502c 100644
@@ -212,6 +212,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 1eba07f..f462fc5 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
maintainer
#1 lore raw
Quoted 27 lines · Neil Armstrong

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 98ccbde..0e1502c 100644
@@ -212,6 +212,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 +0 -0
index 1eba07f..f462fc5 100644

net/dsa/dsa.c static void dsa_switch_destroy(struct dsa_switch *ds) · line 466

Quoted 8 lines
net/dsa/dsa.c +4 -0
@@ -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);
 }

https://lkml.org/lkml/2015/10/28/532 ???

Andrew

#2 lore raw
Quoted 15 lines · Andrew Lunn

net/dsa/dsa.c static void dsa_switch_destroy(struct dsa_switch *ds) · line 466

Quoted 11 lines · Neil Armstrong
net/dsa/dsa.c +4 -0
@@ -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);
 }

https://lkml.org/lkml/2015/10/28/532 ???

Quoted 2 lines

Andrew

Well, sorry, I did the change but it got lost when refactoring the ppu stuff.

Neil