@@ -21,14 +21,13 @@ static int make_magnitude_modifier(struct iforce* iforce,
2121 unsigned char data [3 ];
2222
2323 if (!no_alloc ) {
24- mutex_lock (& iforce -> mem_mutex );
25- if (allocate_resource (& (iforce -> device_memory ), mod_chunk , 2 ,
26- iforce -> device_memory .start , iforce -> device_memory .end , 2L ,
27- NULL , NULL )) {
28- mutex_unlock (& iforce -> mem_mutex );
24+ guard (mutex )(& iforce -> mem_mutex );
25+
26+ if (allocate_resource (& iforce -> device_memory , mod_chunk , 2 ,
27+ iforce -> device_memory .start ,
28+ iforce -> device_memory .end ,
29+ 2L , NULL , NULL ))
2930 return - ENOSPC ;
30- }
31- mutex_unlock (& iforce -> mem_mutex );
3231 }
3332
3433 data [0 ] = LO (mod_chunk -> start );
@@ -54,14 +53,13 @@ static int make_period_modifier(struct iforce* iforce,
5453 period = TIME_SCALE (period );
5554
5655 if (!no_alloc ) {
57- mutex_lock (& iforce -> mem_mutex );
58- if (allocate_resource (& (iforce -> device_memory ), mod_chunk , 0x0c ,
59- iforce -> device_memory .start , iforce -> device_memory .end , 2L ,
60- NULL , NULL )) {
61- mutex_unlock (& iforce -> mem_mutex );
56+ guard (mutex )(& iforce -> mem_mutex );
57+
58+ if (allocate_resource (& iforce -> device_memory , mod_chunk , 0x0c ,
59+ iforce -> device_memory .start ,
60+ iforce -> device_memory .end ,
61+ 2L , NULL , NULL ))
6262 return - ENOSPC ;
63- }
64- mutex_unlock (& iforce -> mem_mutex );
6563 }
6664
6765 data [0 ] = LO (mod_chunk -> start );
@@ -94,14 +92,13 @@ static int make_envelope_modifier(struct iforce* iforce,
9492 fade_duration = TIME_SCALE (fade_duration );
9593
9694 if (!no_alloc ) {
97- mutex_lock (& iforce -> mem_mutex );
95+ guard (mutex )(& iforce -> mem_mutex );
96+
9897 if (allocate_resource (& (iforce -> device_memory ), mod_chunk , 0x0e ,
99- iforce -> device_memory . start , iforce -> device_memory .end , 2L ,
100- NULL , NULL )) {
101- mutex_unlock ( & iforce -> mem_mutex );
98+ iforce -> device_memory .start ,
99+ iforce -> device_memory . end ,
100+ 2L , NULL , NULL ))
102101 return - ENOSPC ;
103- }
104- mutex_unlock (& iforce -> mem_mutex );
105102 }
106103
107104 data [0 ] = LO (mod_chunk -> start );
@@ -131,14 +128,13 @@ static int make_condition_modifier(struct iforce* iforce,
131128 unsigned char data [10 ];
132129
133130 if (!no_alloc ) {
134- mutex_lock (& iforce -> mem_mutex );
131+ guard (mutex )(& iforce -> mem_mutex );
132+
135133 if (allocate_resource (& (iforce -> device_memory ), mod_chunk , 8 ,
136- iforce -> device_memory . start , iforce -> device_memory .end , 2L ,
137- NULL , NULL )) {
138- mutex_unlock ( & iforce -> mem_mutex );
134+ iforce -> device_memory .start ,
135+ iforce -> device_memory . end ,
136+ 2L , NULL , NULL ))
139137 return - ENOSPC ;
140- }
141- mutex_unlock (& iforce -> mem_mutex );
142138 }
143139
144140 data [0 ] = LO (mod_chunk -> start );
0 commit comments