aboutsummaryrefslogtreecommitdiff
path: root/drivers/soundwire
diff options
context:
space:
mode:
authorPierre-Louis Bossart2022-01-26 09:17:02 +0800
committerVinod Koul2022-02-11 12:15:36 +0530
commit1508876f02553792ca2683b4e7ea9a07ef9361b4 (patch)
tree8445924629df11e056771acf71c358a452727d09 /drivers/soundwire
parent2811221a3f64511363b830702ec112ee5a78f85b (diff)
soundwire: stream: split alloc and config in two functions
Continue the split with two functions for master and slave, and remove unused arguments. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Rander Wang <rander.wang@intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20220126011715.28204-7-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire')
-rw-r--r--drivers/soundwire/stream.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index b97c59e71bdb..e3cb55de0d12 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1218,13 +1218,10 @@ static int sdw_is_valid_port_range(struct device *dev, int num)
return 0;
}
-static int sdw_master_port_config(struct sdw_bus *bus,
- struct sdw_master_runtime *m_rt,
- struct sdw_port_config *port_config,
- unsigned int num_ports)
+static int sdw_master_port_alloc(struct sdw_master_runtime *m_rt,
+ unsigned int num_ports)
{
struct sdw_port_runtime *p_rt;
- int ret;
int i;
/* Iterate for number of ports to perform initialization */
@@ -1234,6 +1231,16 @@ static int sdw_master_port_config(struct sdw_bus *bus,
return -ENOMEM;
}
+ return 0;
+}
+
+static int sdw_master_port_config(struct sdw_master_runtime *m_rt,
+ struct sdw_port_config *port_config)
+{
+ struct sdw_port_runtime *p_rt;
+ int ret;
+ int i;
+
i = 0;
list_for_each_entry(p_rt, &m_rt->port_list, port_node) {
ret = sdw_port_config(p_rt, port_config, i);
@@ -1245,13 +1252,12 @@ static int sdw_master_port_config(struct sdw_bus *bus,
return 0;
}
-static int sdw_slave_port_config(struct sdw_slave *slave,
- struct sdw_slave_runtime *s_rt,
- struct sdw_port_config *port_config,
- unsigned int num_config)
+static int sdw_slave_port_alloc(struct sdw_slave *slave,
+ struct sdw_slave_runtime *s_rt,
+ unsigned int num_config)
{
struct sdw_port_runtime *p_rt;
- int i, ret;
+ int i;
/* Iterate for number of ports to perform initialization */
for (i = 0; i < num_config; i++) {
@@ -1260,6 +1266,17 @@ static int sdw_slave_port_config(struct sdw_slave *slave,
return -ENOMEM;
}
+ return 0;
+}
+
+static int sdw_slave_port_config(struct sdw_slave *slave,
+ struct sdw_slave_runtime *s_rt,
+ struct sdw_port_config *port_config)
+{
+ struct sdw_port_runtime *p_rt;
+ int ret;
+ int i;
+
i = 0;
list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
/*
@@ -1324,7 +1341,11 @@ int sdw_stream_add_master(struct sdw_bus *bus,
if (ret)
goto stream_error;
- ret = sdw_master_port_config(bus, m_rt, port_config, num_ports);
+ ret = sdw_master_port_alloc(m_rt, num_ports);
+ if (ret)
+ goto stream_error;
+
+ ret = sdw_master_port_config(m_rt, port_config);
if (ret)
goto stream_error;
@@ -1392,7 +1413,11 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
if (ret)
goto stream_error;
- ret = sdw_slave_port_config(slave, s_rt, port_config, num_ports);
+ ret = sdw_slave_port_alloc(slave, s_rt, num_ports);
+ if (ret)
+ goto stream_error;
+
+ ret = sdw_slave_port_config(slave, s_rt, port_config);
if (ret)
goto stream_error;