[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220907101402.4685-5-rf@opensource.cirrus.com>
Date: Wed, 7 Sep 2022 11:13:59 +0100
From: Richard Fitzgerald <rf@...nsource.cirrus.com>
To: <vkoul@...nel.org>, <yung-chuan.liao@...ux.intel.com>,
<pierre-louis.bossart@...ux.intel.com>, <lgirdwood@...il.com>,
<peter.ujfalusi@...ux.intel.com>,
<ranjani.sridharan@...ux.intel.com>,
<kai.vehmanen@...ux.intel.com>, <daniel.baluta@....com>,
<sanyog.r.kale@...el.com>, <broonie@...nel.org>
CC: <alsa-devel@...a-project.org>,
<sound-open-firmware@...a-project.org>,
<linux-kernel@...r.kernel.org>, <patches@...nsource.cirrus.com>,
Richard Fitzgerald <rf@...nsource.cirrus.com>
Subject: [PATCH 4/7] soundwire: bus: Add remove callback to struct sdw_master_ops
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@...nsource.cirrus.com>
---
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
Powered by blists - more mailing lists