@@ -129,9 +129,9 @@ int reset_controller_register(struct reset_controller_dev *rcdev)
129129
130130 INIT_LIST_HEAD (& rcdev -> reset_control_head );
131131
132- mutex_lock (& reset_list_mutex );
132+ guard (mutex )(& reset_list_mutex );
133+
133134 list_add (& rcdev -> list , & reset_controller_list );
134- mutex_unlock (& reset_list_mutex );
135135
136136 return 0 ;
137137}
@@ -143,9 +143,9 @@ EXPORT_SYMBOL_GPL(reset_controller_register);
143143 */
144144void reset_controller_unregister (struct reset_controller_dev * rcdev )
145145{
146- mutex_lock (& reset_list_mutex );
146+ guard (mutex )(& reset_list_mutex );
147+
147148 list_del (& rcdev -> list );
148- mutex_unlock (& reset_list_mutex );
149149}
150150EXPORT_SYMBOL_GPL (reset_controller_unregister );
151151
@@ -646,25 +646,20 @@ int reset_control_acquire(struct reset_control *rstc)
646646 if (reset_control_is_array (rstc ))
647647 return reset_control_array_acquire (rstc_to_array (rstc ));
648648
649- mutex_lock (& reset_list_mutex );
649+ guard ( mutex ) (& reset_list_mutex );
650650
651- if (rstc -> acquired ) {
652- mutex_unlock (& reset_list_mutex );
651+ if (rstc -> acquired )
653652 return 0 ;
654- }
655653
656654 list_for_each_entry (rc , & rstc -> rcdev -> reset_control_head , list ) {
657655 if (rstc != rc && rstc -> id == rc -> id ) {
658- if (rc -> acquired ) {
659- mutex_unlock (& reset_list_mutex );
656+ if (rc -> acquired )
660657 return - EBUSY ;
661- }
662658 }
663659 }
664660
665661 rstc -> acquired = true;
666662
667- mutex_unlock (& reset_list_mutex );
668663 return 0 ;
669664}
670665EXPORT_SYMBOL_GPL (reset_control_acquire );
@@ -1064,36 +1059,35 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
10641059
10651060 ret = __reset_add_reset_gpio_device (node , & args );
10661061 if (ret ) {
1067- rstc = ERR_PTR ( ret );
1068- goto out_put ;
1062+ of_node_put ( args . np );
1063+ return ERR_PTR ( ret ) ;
10691064 }
10701065 }
10711066
1072- mutex_lock (& reset_list_mutex );
1067+ guard (mutex )(& reset_list_mutex );
1068+
10731069 rcdev = __reset_find_rcdev (& args , gpio_fallback );
10741070 if (!rcdev ) {
10751071 rstc = ERR_PTR (- EPROBE_DEFER );
1076- goto out_unlock ;
1072+ goto out_put ;
10771073 }
10781074
10791075 if (WARN_ON (args .args_count != rcdev -> of_reset_n_cells )) {
10801076 rstc = ERR_PTR (- EINVAL );
1081- goto out_unlock ;
1077+ goto out_put ;
10821078 }
10831079
10841080 rstc_id = rcdev -> of_xlate (rcdev , & args );
10851081 if (rstc_id < 0 ) {
10861082 rstc = ERR_PTR (rstc_id );
1087- goto out_unlock ;
1083+ goto out_put ;
10881084 }
10891085
10901086 flags &= ~RESET_CONTROL_FLAGS_BIT_OPTIONAL ;
10911087
10921088 /* reset_list_mutex also protects the rcdev's reset_control list */
10931089 rstc = __reset_control_get_internal (rcdev , rstc_id , flags );
10941090
1095- out_unlock :
1096- mutex_unlock (& reset_list_mutex );
10971091out_put :
10981092 of_node_put (args .np );
10991093
@@ -1135,10 +1129,11 @@ int __reset_control_bulk_get(struct device *dev, int num_rstcs,
11351129 return 0 ;
11361130
11371131err :
1138- mutex_lock (& reset_list_mutex );
1132+ guard (mutex )(& reset_list_mutex );
1133+
11391134 while (i -- )
11401135 __reset_control_put_internal (rstcs [i ].rstc );
1141- mutex_unlock ( & reset_list_mutex );
1136+
11421137 return ret ;
11431138}
11441139EXPORT_SYMBOL_GPL (__reset_control_bulk_get );
@@ -1147,10 +1142,10 @@ static void reset_control_array_put(struct reset_control_array *resets)
11471142{
11481143 int i ;
11491144
1150- mutex_lock (& reset_list_mutex );
1145+ guard (mutex )(& reset_list_mutex );
1146+
11511147 for (i = 0 ; i < resets -> num_rstcs ; i ++ )
11521148 __reset_control_put_internal (resets -> rstc [i ]);
1153- mutex_unlock (& reset_list_mutex );
11541149 kfree (resets );
11551150}
11561151
@@ -1168,9 +1163,9 @@ void reset_control_put(struct reset_control *rstc)
11681163 return ;
11691164 }
11701165
1171- mutex_lock (& reset_list_mutex );
1166+ guard (mutex )(& reset_list_mutex );
1167+
11721168 __reset_control_put_internal (rstc );
1173- mutex_unlock (& reset_list_mutex );
11741169}
11751170EXPORT_SYMBOL_GPL (reset_control_put );
11761171
@@ -1181,10 +1176,10 @@ EXPORT_SYMBOL_GPL(reset_control_put);
11811176 */
11821177void reset_control_bulk_put (int num_rstcs , struct reset_control_bulk_data * rstcs )
11831178{
1184- mutex_lock (& reset_list_mutex );
1179+ guard (mutex )(& reset_list_mutex );
1180+
11851181 while (num_rstcs -- )
11861182 __reset_control_put_internal (rstcs [num_rstcs ].rstc );
1187- mutex_unlock (& reset_list_mutex );
11881183}
11891184EXPORT_SYMBOL_GPL (reset_control_bulk_put );
11901185
@@ -1403,10 +1398,10 @@ of_reset_control_array_get(struct device_node *np, enum reset_control_flags flag
14031398 return & resets -> base ;
14041399
14051400err_rst :
1406- mutex_lock (& reset_list_mutex );
1401+ guard (mutex )(& reset_list_mutex );
1402+
14071403 while (-- i >= 0 )
14081404 __reset_control_put_internal (resets -> rstc [i ]);
1409- mutex_unlock (& reset_list_mutex );
14101405
14111406 kfree (resets );
14121407
0 commit comments