diff options
author | Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> | 2020-01-10 15:57:31 -0600 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2020-01-14 11:53:12 +0530 |
commit | 6106190158d6b6a064c907a2ba3e063d06f89eaa (patch) | |
tree | 860a1779ba3ed04c3bd7da09702683139ae1cb2e | |
parent | 7181b1d41d0d9d759d3f3c444e3ccffbf7964c92 (diff) | |
download | linux-6106190158d6b6a064c907a2ba3e063d06f89eaa.tar.gz linux-6106190158d6b6a064c907a2ba3e063d06f89eaa.tar.bz2 linux-6106190158d6b6a064c907a2ba3e063d06f89eaa.zip |
soundwire: bus: check first if Slaves become UNATTACHED
Before checking for the presence of Device0, we first need to clean-up
the internal state of Slaves that are no longer attached.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200110215731.30747-7-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r-- | drivers/soundwire/bus.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index be5d437058ed..66fd09e36b73 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -979,6 +979,24 @@ int sdw_handle_slave_status(struct sdw_bus *bus, struct sdw_slave *slave; int i, ret = 0; + /* first check if any Slaves fell off the bus */ + for (i = 1; i <= SDW_MAX_DEVICES; i++) { + mutex_lock(&bus->bus_lock); + if (test_bit(i, bus->assigned) == false) { + mutex_unlock(&bus->bus_lock); + continue; + } + mutex_unlock(&bus->bus_lock); + + slave = sdw_get_slave(bus, i); + if (!slave) + continue; + + if (status[i] == SDW_SLAVE_UNATTACHED && + slave->status != SDW_SLAVE_UNATTACHED) + sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED); + } + if (status[0] == SDW_SLAVE_ATTACHED) { dev_dbg(bus->dev, "Slave attached, programming device number\n"); ret = sdw_program_device_num(bus); |