Skip to content

Commit e024064

Browse files
charleskeepaxvinodkoul
authored andcommitted
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 <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 2b2da40 commit e024064

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

drivers/soundwire/stream.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ int sdw_stream_add_master(struct sdw_bus *bus,
18541854
struct sdw_stream_runtime *stream)
18551855
{
18561856
struct sdw_master_runtime *m_rt;
1857-
bool alloc_master_rt = true;
1857+
bool alloc_master_rt = false;
18581858
int ret;
18591859

18601860
mutex_lock(&bus->bus_lock);
@@ -1876,10 +1876,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
18761876
* it first), if so skip allocation and go to configuration
18771877
*/
18781878
m_rt = sdw_master_rt_find(bus, stream);
1879-
if (m_rt) {
1880-
alloc_master_rt = false;
1879+
if (m_rt)
18811880
goto skip_alloc_master_rt;
1882-
}
18831881

18841882
m_rt = sdw_master_rt_alloc(bus, stream);
18851883
if (!m_rt) {
@@ -1888,6 +1886,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
18881886
ret = -ENOMEM;
18891887
goto unlock;
18901888
}
1889+
1890+
alloc_master_rt = true;
18911891
skip_alloc_master_rt:
18921892

18931893
if (sdw_master_port_allocated(m_rt))
@@ -1980,8 +1980,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
19801980
{
19811981
struct sdw_slave_runtime *s_rt;
19821982
struct sdw_master_runtime *m_rt;
1983-
bool alloc_master_rt = true;
1984-
bool alloc_slave_rt = true;
1983+
bool alloc_master_rt = false;
1984+
bool alloc_slave_rt = false;
19851985

19861986
int ret;
19871987

@@ -1992,10 +1992,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
19921992
* and go to configuration
19931993
*/
19941994
m_rt = sdw_master_rt_find(slave->bus, stream);
1995-
if (m_rt) {
1996-
alloc_master_rt = false;
1995+
if (m_rt)
19971996
goto skip_alloc_master_rt;
1998-
}
19991997

20001998
/*
20011999
* 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,
20092007
goto unlock;
20102008
}
20112009

2010+
alloc_master_rt = true;
2011+
20122012
skip_alloc_master_rt:
20132013
s_rt = sdw_slave_rt_find(slave, stream);
2014-
if (s_rt) {
2015-
alloc_slave_rt = false;
2014+
if (s_rt)
20162015
goto skip_alloc_slave_rt;
2017-
}
20182016

20192017
s_rt = sdw_slave_rt_alloc(slave, m_rt);
20202018
if (!s_rt) {
20212019
dev_err(&slave->dev, "Slave runtime alloc failed for stream:%s\n", stream->name);
2022-
alloc_slave_rt = false;
20232020
ret = -ENOMEM;
20242021
goto alloc_error;
20252022
}
20262023

2024+
alloc_slave_rt = true;
2025+
20272026
skip_alloc_slave_rt:
20282027
if (sdw_slave_port_allocated(s_rt))
20292028
goto skip_port_alloc;

0 commit comments

Comments
 (0)