summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.cirrus.com>2023-06-02 13:11:39 +0300
committerVinod Koul <vkoul@kernel.org>2023-06-08 14:39:11 +0300
commite0240644e7cbb0fce4ea4e3fdcefdaa1a39eb9ea (patch)
tree524abb6557bb35723a58f0b27954a321d8da4914
parent2b2da40979dde8466dd1b7b5969af5fa5aa52cbd (diff)
downloadlinux-e0240644e7cbb0fce4ea4e3fdcefdaa1a39eb9ea.tar.xz
soundwire: stream: Invert logic on runtime alloc flags
sdw_stream_add_slave/master have flags to indicate if the master or slave runtime where allocated in that call to the function. Currently these flags are cleared on all the paths where the runtime is not allocated, it is more logic and simpler to set the flag on the one path where the runtime is allocated. Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20230602101140.2040141-4-ckeepax@opensource.cirrus.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
-rw-r--r--drivers/soundwire/stream.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 6595f47b403b..df5600a80c17 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1854,7 +1854,7 @@ int sdw_stream_add_master(struct sdw_bus *bus,
struct sdw_stream_runtime *stream)
{
struct sdw_master_runtime *m_rt;
- bool alloc_master_rt = true;
+ bool alloc_master_rt = false;
int ret;
mutex_lock(&bus->bus_lock);
@@ -1876,10 +1876,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
* it first), if so skip allocation and go to configuration
*/
m_rt = sdw_master_rt_find(bus, stream);
- if (m_rt) {
- alloc_master_rt = false;
+ if (m_rt)
goto skip_alloc_master_rt;
- }
m_rt = sdw_master_rt_alloc(bus, stream);
if (!m_rt) {
@@ -1888,6 +1886,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
ret = -ENOMEM;
goto unlock;
}
+
+ alloc_master_rt = true;
skip_alloc_master_rt:
if (sdw_master_port_allocated(m_rt))
@@ -1980,8 +1980,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
{
struct sdw_slave_runtime *s_rt;
struct sdw_master_runtime *m_rt;
- bool alloc_master_rt = true;
- bool alloc_slave_rt = true;
+ bool alloc_master_rt = false;
+ bool alloc_slave_rt = false;
int ret;
@@ -1992,10 +1992,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
* and go to configuration
*/
m_rt = sdw_master_rt_find(slave->bus, stream);
- if (m_rt) {
- alloc_master_rt = false;
+ if (m_rt)
goto skip_alloc_master_rt;
- }
/*
* If this API is invoked by Slave first then m_rt is not valid.
@@ -2009,21 +2007,22 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
goto unlock;
}
+ alloc_master_rt = true;
+
skip_alloc_master_rt:
s_rt = sdw_slave_rt_find(slave, stream);
- if (s_rt) {
- alloc_slave_rt = false;
+ if (s_rt)
goto skip_alloc_slave_rt;
- }
s_rt = sdw_slave_rt_alloc(slave, m_rt);
if (!s_rt) {
dev_err(&slave->dev, "Slave runtime alloc failed for stream:%s\n", stream->name);
- alloc_slave_rt = false;
ret = -ENOMEM;
goto alloc_error;
}
+ alloc_slave_rt = true;
+
skip_alloc_slave_rt:
if (sdw_slave_port_allocated(s_rt))
goto skip_port_alloc;