提交 1a21892d 编写于 作者: P Pierre-Louis Bossart 提交者: Vinod Koul

soundwire: stream: simplify sdw_alloc_master_rt()

Only do the allocation in that function, and move check for allocation
in the caller. This will it easier to split allocation and
configuration.

No functionality change in this patch.
Signed-off-by: NPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: NRander Wang <rander.wang@intel.com>
Signed-off-by: NBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220126011715.28204-10-yung-chuan.liao@linux.intel.comSigned-off-by: NVinod Koul <vkoul@kernel.org>
上级 c7aa9d77
...@@ -1085,14 +1085,6 @@ static struct sdw_master_runtime ...@@ -1085,14 +1085,6 @@ static struct sdw_master_runtime
{ {
struct sdw_master_runtime *m_rt; struct sdw_master_runtime *m_rt;
/*
* check if Master is already allocated (as a result of Slave adding
* it first), if so skip allocation and go to configure
*/
m_rt = sdw_find_master_rt(bus, stream);
if (m_rt)
goto stream_config;
m_rt = kzalloc(sizeof(*m_rt), GFP_KERNEL); m_rt = kzalloc(sizeof(*m_rt), GFP_KERNEL);
if (!m_rt) if (!m_rt)
return NULL; return NULL;
...@@ -1104,7 +1096,6 @@ static struct sdw_master_runtime ...@@ -1104,7 +1096,6 @@ static struct sdw_master_runtime
list_add_tail(&m_rt->bus_node, &bus->m_rt_list); list_add_tail(&m_rt->bus_node, &bus->m_rt_list);
stream_config:
m_rt->ch_count = stream_config->ch_count; m_rt->ch_count = stream_config->ch_count;
m_rt->bus = bus; m_rt->bus = bus;
m_rt->stream = stream; m_rt->stream = stream;
...@@ -1326,6 +1317,14 @@ int sdw_stream_add_master(struct sdw_bus *bus, ...@@ -1326,6 +1317,14 @@ int sdw_stream_add_master(struct sdw_bus *bus,
goto unlock; goto unlock;
} }
/*
* check if Master is already allocated (e.g. as a result of Slave adding
* it first), if so skip allocation and go to configuration
*/
m_rt = sdw_find_master_rt(bus, stream);
if (m_rt)
goto skip_alloc_master_rt;
m_rt = sdw_alloc_master_rt(bus, stream_config, stream); m_rt = sdw_alloc_master_rt(bus, stream_config, stream);
if (!m_rt) { if (!m_rt) {
dev_err(bus->dev, dev_err(bus->dev,
...@@ -1335,6 +1334,7 @@ int sdw_stream_add_master(struct sdw_bus *bus, ...@@ -1335,6 +1334,7 @@ int sdw_stream_add_master(struct sdw_bus *bus,
goto unlock; goto unlock;
} }
skip_alloc_master_rt:
ret = sdw_config_stream(bus->dev, stream, stream_config, false); ret = sdw_config_stream(bus->dev, stream, stream_config, false);
if (ret) if (ret)
goto stream_error; goto stream_error;
...@@ -1384,6 +1384,14 @@ int sdw_stream_add_slave(struct sdw_slave *slave, ...@@ -1384,6 +1384,14 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
mutex_lock(&slave->bus->bus_lock); mutex_lock(&slave->bus->bus_lock);
/*
* check if Master is already allocated, if so skip allocation
* and go to configuration
*/
m_rt = sdw_find_master_rt(slave->bus, stream);
if (m_rt)
goto skip_alloc_master_rt;
/* /*
* If this API is invoked by Slave first then m_rt is not valid. * If this API is invoked by Slave first then m_rt is not valid.
* So, allocate m_rt and add Slave to it. * So, allocate m_rt and add Slave to it.
...@@ -1397,6 +1405,7 @@ int sdw_stream_add_slave(struct sdw_slave *slave, ...@@ -1397,6 +1405,7 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
goto error; goto error;
} }
skip_alloc_master_rt:
s_rt = sdw_alloc_slave_rt(slave, stream_config); s_rt = sdw_alloc_slave_rt(slave, stream_config);
if (!s_rt) { if (!s_rt) {
dev_err(&slave->dev, dev_err(&slave->dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册