Skip to contentSkip to conversation

net: dsa: allow switch drivers to cleanup their resources

RFC PATCH Superseded Neil Armstrong 2 participants 2 messages Oct 28, 2015

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/4 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 Reviewed-by on v2 1/4
#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 463

Quoted 5 lines
net/dsa/dsa.c +2 -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 */

A nitpick:

/* Give the driver a chance to cleanup */

would be better English.

Andrew