@@ -167,30 +167,24 @@ static int dai_list_show(struct seq_file *m, void *v)
167167{
168168 struct snd_soc_component * component ;
169169 struct snd_soc_dai * dai ;
170-
171- mutex_lock (& client_mutex );
170+ guard (mutex )(& client_mutex );
172171
173172 for_each_component (component )
174173 for_each_component_dais (component , dai )
175174 seq_printf (m , "%s \n ", dai - > name );
176175
177- mutex_unlock (& client_mutex );
178-
179176 return 0 ;
180177}
181178DEFINE_SHOW_ATTRIBUTE (dai_list );
182179
183180static int component_list_show (struct seq_file * m , void * v )
184181{
185182 struct snd_soc_component * component ;
186-
187- mutex_lock (& client_mutex );
183+ guard (mutex )(& client_mutex );
188184
189185 for_each_component (component )
190186 seq_printf (m , "%s\n" , component -> name );
191187
192- mutex_unlock (& client_mutex );
193-
194188 return 0 ;
195189}
196190DEFINE_SHOW_ATTRIBUTE (component_list );
@@ -394,13 +388,9 @@ EXPORT_SYMBOL_GPL(snd_soc_lookup_component_nolocked);
394388struct snd_soc_component * snd_soc_lookup_component (struct device * dev ,
395389 const char * driver_name )
396390{
397- struct snd_soc_component * component ;
398-
399- mutex_lock (& client_mutex );
400- component = snd_soc_lookup_component_nolocked (dev , driver_name );
401- mutex_unlock (& client_mutex );
391+ guard (mutex )(& client_mutex );
402392
403- return component ;
393+ return snd_soc_lookup_component_nolocked ( dev , driver_name ) ;
404394}
405395EXPORT_SYMBOL_GPL (snd_soc_lookup_component );
406396
@@ -950,13 +940,9 @@ EXPORT_SYMBOL_GPL(snd_soc_find_dai);
950940struct snd_soc_dai * snd_soc_find_dai_with_mutex (
951941 const struct snd_soc_dai_link_component * dlc )
952942{
953- struct snd_soc_dai * dai ;
954-
955- mutex_lock (& client_mutex );
956- dai = snd_soc_find_dai (dlc );
957- mutex_unlock (& client_mutex );
943+ guard (mutex )(& client_mutex );
958944
959- return dai ;
945+ return snd_soc_find_dai ( dlc ) ;
960946}
961947EXPORT_SYMBOL_GPL (snd_soc_find_dai_with_mutex );
962948
@@ -2590,7 +2576,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
25902576 mutex_init (& card -> dapm_mutex );
25912577 mutex_init (& card -> pcm_mutex );
25922578
2593- mutex_lock (& client_mutex );
2579+ guard ( mutex ) (& client_mutex );
25942580
25952581 if (card -> devres_dev ) {
25962582 ret = devm_snd_soc_bind_card (card -> devres_dev , card );
@@ -2602,8 +2588,6 @@ int snd_soc_register_card(struct snd_soc_card *card)
26022588 ret = snd_soc_bind_card (card );
26032589 }
26042590
2605- mutex_unlock (& client_mutex );
2606-
26072591 return ret ;
26082592}
26092593EXPORT_SYMBOL_GPL (snd_soc_register_card );
@@ -2616,10 +2600,11 @@ EXPORT_SYMBOL_GPL(snd_soc_register_card);
26162600 */
26172601void snd_soc_unregister_card (struct snd_soc_card * card )
26182602{
2619- mutex_lock (& client_mutex );
2603+ guard (mutex )(& client_mutex );
2604+
26202605 snd_soc_unbind_card (card );
26212606 list_del (& card -> list );
2622- mutex_unlock ( & client_mutex );
2607+
26232608 dev_dbg (card -> dev , "ASoC: Unregistered card '%s'\n" , card -> name );
26242609}
26252610EXPORT_SYMBOL_GPL (snd_soc_unregister_card );
@@ -2896,8 +2881,7 @@ int snd_soc_add_component(struct snd_soc_component *component,
28962881 struct snd_soc_card * card , * c ;
28972882 int ret ;
28982883 int i ;
2899-
2900- mutex_lock (& client_mutex );
2884+ guard (mutex )(& client_mutex );
29012885
29022886 if (component -> driver -> endianness ) {
29032887 for (i = 0 ; i < num_dai ; i ++ ) {
@@ -2931,7 +2915,6 @@ int snd_soc_add_component(struct snd_soc_component *component,
29312915 if (ret < 0 )
29322916 snd_soc_del_component_unlocked (component );
29332917
2934- mutex_unlock (& client_mutex );
29352918 return ret ;
29362919}
29372920EXPORT_SYMBOL_GPL (snd_soc_add_component );
@@ -2971,7 +2954,8 @@ void snd_soc_unregister_component_by_driver(struct device *dev,
29712954 if (component_driver )
29722955 driver_name = component_driver -> name ;
29732956
2974- mutex_lock (& client_mutex );
2957+ guard (mutex )(& client_mutex );
2958+
29752959 while (1 ) {
29762960 struct snd_soc_component * component = snd_soc_lookup_component_nolocked (dev , driver_name );
29772961
@@ -2980,7 +2964,6 @@ void snd_soc_unregister_component_by_driver(struct device *dev,
29802964
29812965 snd_soc_del_component_unlocked (component );
29822966 }
2983- mutex_unlock (& client_mutex );
29842967}
29852968EXPORT_SYMBOL_GPL (snd_soc_unregister_component_by_driver );
29862969
@@ -3516,7 +3499,6 @@ EXPORT_SYMBOL_GPL(snd_soc_get_stream_cpu);
35163499
35173500int snd_soc_get_dai_id (struct device_node * ep )
35183501{
3519- struct snd_soc_component * component ;
35203502 struct snd_soc_dai_link_component dlc = {
35213503 .of_node = of_graph_get_port_parent (ep ),
35223504 };
@@ -3530,11 +3512,13 @@ int snd_soc_get_dai_id(struct device_node *ep)
35303512 * Then, it should have .of_xlate_dai_id
35313513 */
35323514 ret = - ENOTSUPP ;
3533- mutex_lock (& client_mutex );
3534- component = soc_find_component (& dlc );
3535- if (component )
3536- ret = snd_soc_component_of_xlate_dai_id (component , ep );
3537- mutex_unlock (& client_mutex );
3515+
3516+ scoped_guard (mutex , & client_mutex ) {
3517+ struct snd_soc_component * component = soc_find_component (& dlc );
3518+
3519+ if (component )
3520+ ret = snd_soc_component_of_xlate_dai_id (component , ep );
3521+ }
35383522
35393523 of_node_put (dlc .of_node );
35403524
@@ -3546,8 +3530,8 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_
35463530{
35473531 struct snd_soc_component * pos ;
35483532 int ret = - EPROBE_DEFER ;
3533+ guard (mutex )(& client_mutex );
35493534
3550- mutex_lock (& client_mutex );
35513535 for_each_component (pos ) {
35523536 struct device_node * component_of_node = soc_component_to_node (pos );
35533537
@@ -3602,7 +3586,6 @@ int snd_soc_get_dlc(const struct of_phandle_args *args, struct snd_soc_dai_link_
36023586 if (ret == 0 )
36033587 dlc -> of_node = args -> np ;
36043588
3605- mutex_unlock (& client_mutex );
36063589 return ret ;
36073590}
36083591EXPORT_SYMBOL_GPL (snd_soc_get_dlc );
@@ -3657,17 +3640,14 @@ struct snd_soc_dai *snd_soc_get_dai_via_args(const struct of_phandle_args *dai_a
36573640{
36583641 struct snd_soc_dai * dai ;
36593642 struct snd_soc_component * component ;
3643+ guard (mutex )(& client_mutex );
36603644
3661- mutex_lock (& client_mutex );
36623645 for_each_component (component ) {
36633646 for_each_component_dais (component , dai )
36643647 if (snd_soc_is_match_dai_args (dai -> driver -> dai_args , dai_args ))
3665- goto found ;
3648+ return dai ;
36663649 }
3667- dai = NULL ;
3668- found :
3669- mutex_unlock (& client_mutex );
3670- return dai ;
3650+ return NULL ;
36713651}
36723652EXPORT_SYMBOL_GPL (snd_soc_get_dai_via_args );
36733653
0 commit comments