During removal of a bus driver the bus must stay operational while child drivers are being removed, since (a) they might have been busy when the bus driver removal started and (b) the might need to access the bus to run their shutdown procedures. Only after that can the bus driver disable the bus. Add a new remove callback to struct sdw_master_ops that the bus driver can implement to disable the bus after children are removed. This is modeled on the ASoC component_remove, which indicates that the driver is no longer required. Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx> --- drivers/soundwire/bus.c | 5 +++++ include/linux/soundwire/sdw.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 99429892221b..1327a312be86 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -176,6 +176,11 @@ static int sdw_delete_slave(struct device *dev, void *data) void sdw_bus_master_delete(struct sdw_bus *bus) { device_for_each_child(bus->dev, NULL, sdw_delete_slave); + + /* Children have been removed so it is now safe for the bus to stop */ + if (bus->ops->remove) + bus->ops->remove(bus); + sdw_master_device_del(bus); sdw_bus_debugfs_exit(bus); diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index a2b31d25ea27..aa492173d5eb 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -839,6 +839,7 @@ struct sdw_defer { * @set_bus_conf: Set the bus configuration * @pre_bank_switch: Callback for pre bank switch * @post_bank_switch: Callback for post bank switch + * @remove: Called when it is safe to stop the bus controller. */ struct sdw_master_ops { int (*read_prop)(struct sdw_bus *bus); @@ -855,7 +856,7 @@ struct sdw_master_ops { struct sdw_bus_params *params); int (*pre_bank_switch)(struct sdw_bus *bus); int (*post_bank_switch)(struct sdw_bus *bus); - + void (*remove)(struct sdw_bus *bus); }; /** -- 2.30.2