Skip to content

Commit edd5cf9

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: stream: split sdw_alloc_slave_rt() in alloc and config
Split the two parts so that we can do multiple configurations during ALSA/ASoC hw_params stage. Also follow existing convention sdw_<object>_<action> used at lower level. No functionality change here. 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-13-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent bf75ba4 commit edd5cf9

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

drivers/soundwire/stream.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,16 +1055,14 @@ struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name)
10551055
EXPORT_SYMBOL(sdw_alloc_stream);
10561056

10571057
/**
1058-
* sdw_alloc_slave_rt() - Allocate and initialize Slave runtime handle.
1058+
* sdw_slave_rt_alloc() - Allocate a Slave runtime handle.
10591059
*
10601060
* @slave: Slave handle
1061-
* @stream_config: Stream configuration
10621061
*
10631062
* This function is to be called with bus_lock held.
10641063
*/
10651064
static struct sdw_slave_runtime
1066-
*sdw_alloc_slave_rt(struct sdw_slave *slave,
1067-
struct sdw_stream_config *stream_config)
1065+
*sdw_slave_rt_alloc(struct sdw_slave *slave)
10681066
{
10691067
struct sdw_slave_runtime *s_rt;
10701068

@@ -1073,13 +1071,28 @@ static struct sdw_slave_runtime
10731071
return NULL;
10741072

10751073
INIT_LIST_HEAD(&s_rt->port_list);
1076-
s_rt->ch_count = stream_config->ch_count;
1077-
s_rt->direction = stream_config->direction;
10781074
s_rt->slave = slave;
10791075

10801076
return s_rt;
10811077
}
10821078

1079+
/**
1080+
* sdw_slave_rt_config() - Configure a Slave runtime handle.
1081+
*
1082+
* @s_rt: Slave runtime handle
1083+
* @stream_config: Stream configuration
1084+
*
1085+
* This function is to be called with bus_lock held.
1086+
*/
1087+
static int sdw_slave_rt_config(struct sdw_slave_runtime *s_rt,
1088+
struct sdw_stream_config *stream_config)
1089+
{
1090+
s_rt->ch_count = stream_config->ch_count;
1091+
s_rt->direction = stream_config->direction;
1092+
1093+
return 0;
1094+
}
1095+
10831096
static struct sdw_master_runtime
10841097
*sdw_master_rt_find(struct sdw_bus *bus,
10851098
struct sdw_stream_runtime *stream)
@@ -1423,16 +1436,18 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
14231436
goto stream_error;
14241437

14251438
skip_alloc_master_rt:
1426-
s_rt = sdw_alloc_slave_rt(slave, stream_config);
1439+
s_rt = sdw_slave_rt_alloc(slave);
14271440
if (!s_rt) {
1428-
dev_err(&slave->dev,
1429-
"Slave runtime config failed for stream:%s\n",
1430-
stream->name);
1441+
dev_err(&slave->dev, "Slave runtime alloc failed for stream:%s\n", stream->name);
14311442
ret = -ENOMEM;
14321443
goto stream_error;
14331444
}
14341445
list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list);
14351446

1447+
ret = sdw_slave_rt_config(s_rt, stream_config);
1448+
if (ret)
1449+
goto stream_error;
1450+
14361451
ret = sdw_config_stream(&slave->dev, stream, stream_config, true);
14371452
if (ret)
14381453
goto stream_error;

0 commit comments

Comments
 (0)