@@ -1055,7 +1055,7 @@ struct sdw_stream_runtime *sdw_alloc_stream(const char *stream_name)
10551055EXPORT_SYMBOL (sdw_alloc_stream );
10561056
10571057static struct sdw_master_runtime
1058- * sdw_find_master_rt (struct sdw_bus * bus ,
1058+ * sdw_master_rt_find (struct sdw_bus * bus ,
10591059 struct sdw_stream_runtime * stream )
10601060{
10611061 struct sdw_master_runtime * m_rt ;
@@ -1070,17 +1070,15 @@ static struct sdw_master_runtime
10701070}
10711071
10721072/**
1073- * sdw_alloc_master_rt () - Allocates and initialize Master runtime handle
1073+ * sdw_master_rt_alloc () - Allocates a Master runtime handle
10741074 *
10751075 * @bus: SDW bus instance
1076- * @stream_config: Stream configuration
10771076 * @stream: Stream runtime handle.
10781077 *
10791078 * This function is to be called with bus_lock held.
10801079 */
10811080static struct sdw_master_runtime
1082- * sdw_alloc_master_rt (struct sdw_bus * bus ,
1083- struct sdw_stream_config * stream_config ,
1081+ * sdw_master_rt_alloc (struct sdw_bus * bus ,
10841082 struct sdw_stream_runtime * stream )
10851083{
10861084 struct sdw_master_runtime * m_rt ;
@@ -1096,14 +1094,30 @@ static struct sdw_master_runtime
10961094
10971095 list_add_tail (& m_rt -> bus_node , & bus -> m_rt_list );
10981096
1099- m_rt -> ch_count = stream_config -> ch_count ;
11001097 m_rt -> bus = bus ;
11011098 m_rt -> stream = stream ;
1102- m_rt -> direction = stream_config -> direction ;
11031099
11041100 return m_rt ;
11051101}
11061102
1103+ /**
1104+ * sdw_master_rt_config() - Configure Master runtime handle
1105+ *
1106+ * @m_rt: Master runtime handle
1107+ * @stream_config: Stream configuration
1108+ *
1109+ * This function is to be called with bus_lock held.
1110+ */
1111+
1112+ static int sdw_master_rt_config (struct sdw_master_runtime * m_rt ,
1113+ struct sdw_stream_config * stream_config )
1114+ {
1115+ m_rt -> ch_count = stream_config -> ch_count ;
1116+ m_rt -> direction = stream_config -> direction ;
1117+
1118+ return 0 ;
1119+ }
1120+
11071121/**
11081122 * sdw_alloc_slave_rt() - Allocate and initialize Slave runtime handle.
11091123 *
@@ -1321,19 +1335,21 @@ int sdw_stream_add_master(struct sdw_bus *bus,
13211335 * check if Master is already allocated (e.g. as a result of Slave adding
13221336 * it first), if so skip allocation and go to configuration
13231337 */
1324- m_rt = sdw_find_master_rt (bus , stream );
1338+ m_rt = sdw_master_rt_find (bus , stream );
13251339 if (m_rt )
13261340 goto skip_alloc_master_rt ;
13271341
1328- m_rt = sdw_alloc_master_rt (bus , stream_config , stream );
1342+ m_rt = sdw_master_rt_alloc (bus , stream );
13291343 if (!m_rt ) {
1330- dev_err (bus -> dev ,
1331- "Master runtime config failed for stream:%s\n" ,
1332- stream -> name );
1344+ dev_err (bus -> dev , "Master runtime alloc failed for stream:%s\n" , stream -> name );
13331345 ret = - ENOMEM ;
13341346 goto unlock ;
13351347 }
13361348
1349+ ret = sdw_master_rt_config (m_rt , stream_config );
1350+ if (ret < 0 )
1351+ goto unlock ;
1352+
13371353skip_alloc_master_rt :
13381354 ret = sdw_config_stream (bus -> dev , stream , stream_config , false);
13391355 if (ret )
@@ -1388,22 +1404,23 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
13881404 * check if Master is already allocated, if so skip allocation
13891405 * and go to configuration
13901406 */
1391- m_rt = sdw_find_master_rt (slave -> bus , stream );
1407+ m_rt = sdw_master_rt_find (slave -> bus , stream );
13921408 if (m_rt )
13931409 goto skip_alloc_master_rt ;
13941410
13951411 /*
13961412 * If this API is invoked by Slave first then m_rt is not valid.
13971413 * So, allocate m_rt and add Slave to it.
13981414 */
1399- m_rt = sdw_alloc_master_rt (slave -> bus , stream_config , stream );
1415+ m_rt = sdw_master_rt_alloc (slave -> bus , stream );
14001416 if (!m_rt ) {
1401- dev_err (& slave -> dev ,
1402- "alloc master runtime failed for stream:%s\n" ,
1403- stream -> name );
1417+ dev_err (& slave -> dev , "Master runtime alloc failed for stream:%s\n" , stream -> name );
14041418 ret = - ENOMEM ;
14051419 goto error ;
14061420 }
1421+ ret = sdw_master_rt_config (m_rt , stream_config );
1422+ if (ret < 0 )
1423+ goto stream_error ;
14071424
14081425skip_alloc_master_rt :
14091426 s_rt = sdw_alloc_slave_rt (slave , stream_config );
0 commit comments