1515#include <sof/ipc/topology.h>
1616#include <rtos/interrupt.h>
1717#include <rtos/timer.h>
18- #include <rtos/alloc.h>
1918#include <rtos/cache.h>
2019#include <rtos/init.h>
2120#include <sof/lib/memory.h>
@@ -82,13 +81,12 @@ static void mic_privacy_event(void *arg, enum notify_id type, void *data)
8281 }
8382}
8483
85- static int mic_privacy_configure (struct comp_dev * dev , struct copier_data * cd )
84+ static int mic_privacy_configure (struct processing_module * mod , struct copier_data * cd )
8685{
8786 struct mic_privacy_data * mic_priv_data ;
8887 int ret ;
8988
90- mic_priv_data = rzalloc (SOF_MEM_FLAG_USER ,
91- sizeof (struct mic_privacy_data ));
89+ mic_priv_data = mod_zalloc (mod , sizeof (struct mic_privacy_data ));
9290 if (!mic_priv_data )
9391 return - ENOMEM ;
9492
@@ -100,7 +98,7 @@ static int mic_privacy_configure(struct comp_dev *dev, struct copier_data *cd)
10098 uint32_t zeroing_wait_time = (mic_privacy_get_dma_zeroing_wait_time () * 1000 ) /
10199 ADSP_RTC_FREQUENCY ;
102100
103- ret = copier_gain_set_params (dev , & mic_priv_data -> mic_priv_gain_params ,
101+ ret = copier_gain_set_params (mod -> dev , & mic_priv_data -> mic_priv_gain_params ,
104102 zeroing_wait_time , SOF_DAI_INTEL_NONE );
105103 if (ret != 0 ) {
106104 rfree (mic_priv_data );
@@ -144,7 +142,7 @@ __cold static int copier_init(struct processing_module *mod)
144142
145143 assert_can_be_cold ();
146144
147- cd = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* cd ));
145+ cd = mod_zalloc ( mod , sizeof (* cd ));
148146 if (!cd )
149147 return - ENOMEM ;
150148
@@ -154,10 +152,8 @@ __cold static int copier_init(struct processing_module *mod)
154152 * store it, it's only used during IPC processing, besides we haven't
155153 * allocated space for it, so don't "fix" this!
156154 */
157- if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 ) {
158- ret = - EINVAL ;
159- goto error_cd ;
160- }
155+ if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 )
156+ return - EINVAL ;
161157
162158 /* Allocate memory and store gateway_cfg in runtime. Gateway cfg has to
163159 * be kept even after copier is created e.g. during SET_PIPELINE_STATE
@@ -166,18 +162,15 @@ __cold static int copier_init(struct processing_module *mod)
166162 */
167163 if (copier -> gtw_cfg .config_length ) {
168164 gtw_cfg_size = copier -> gtw_cfg .config_length << 2 ;
169- gtw_cfg = rmalloc (SOF_MEM_FLAG_USER ,
170- gtw_cfg_size );
171- if (!gtw_cfg ) {
172- ret = - ENOMEM ;
173- goto error_cd ;
174- }
165+ gtw_cfg = mod_alloc (mod , gtw_cfg_size );
166+ if (!gtw_cfg )
167+ return - ENOMEM ;
175168
176169 ret = memcpy_s (gtw_cfg , gtw_cfg_size , & copier -> gtw_cfg .config_data ,
177170 gtw_cfg_size );
178171 if (ret ) {
179172 comp_err (dev , "Unable to copy gateway config from copier blob" );
180- goto error ;
173+ return ret ;
181174 }
182175
183176 cd -> gtw_cfg = gtw_cfg ;
@@ -191,8 +184,7 @@ __cold static int copier_init(struct processing_module *mod)
191184 IPC_COMP_IGNORE_REMOTE );
192185 if (!ipc_pipe ) {
193186 comp_err (dev , "pipeline %d is not existed" , config -> pipeline_id );
194- ret = - EPIPE ;
195- goto error ;
187+ return - EPIPE ;
196188 }
197189
198190 dev -> pipeline = ipc_pipe -> pipeline ;
@@ -208,15 +200,15 @@ __cold static int copier_init(struct processing_module *mod)
208200 ret = copier_host_create (dev , cd , copier , ipc_pipe -> pipeline );
209201 if (ret < 0 ) {
210202 comp_err (dev , "unable to create host" );
211- goto error ;
203+ return ret ;
212204 }
213205#if CONFIG_INTEL_ADSP_MIC_PRIVACY
214206 if (cd -> direction == SOF_IPC_STREAM_CAPTURE &&
215207 node_id .f .dma_type == ipc4_hda_host_output_class ) {
216- ret = mic_privacy_configure (dev , cd );
208+ ret = mic_privacy_configure (mod , cd );
217209 if (ret < 0 ) {
218210 comp_err (dev , "unable to configure mic privacy" );
219- goto error ;
211+ return ret ;
220212 }
221213 }
222214#endif
@@ -231,14 +223,14 @@ __cold static int copier_init(struct processing_module *mod)
231223 ret = copier_dai_create (dev , cd , copier , ipc_pipe -> pipeline );
232224 if (ret < 0 ) {
233225 comp_err (dev , "unable to create dai" );
234- goto error ;
226+ return ret ;
235227 }
236228#if CONFIG_INTEL_ADSP_MIC_PRIVACY
237229 if (cd -> direction == SOF_IPC_STREAM_CAPTURE ) {
238- ret = mic_privacy_configure (dev , cd );
230+ ret = mic_privacy_configure (mod , cd );
239231 if (ret < 0 ) {
240232 comp_err (dev , "unable to configure mic privacy" );
241- goto error ;
233+ return ret ;
242234 }
243235 }
244236#endif
@@ -249,14 +241,13 @@ __cold static int copier_init(struct processing_module *mod)
249241 ret = copier_ipcgtw_create (dev , cd , copier , ipc_pipe -> pipeline );
250242 if (ret < 0 ) {
251243 comp_err (dev , "unable to create IPC gateway" );
252- goto error ;
244+ return ret ;
253245 }
254246 break ;
255247#endif
256248 default :
257249 comp_err (dev , "unsupported dma type %x" , (uint32_t )node_id .f .dma_type );
258- ret = - EINVAL ;
259- goto error ;
250+ return - EINVAL ;
260251 };
261252
262253 dev -> direction_set = true;
@@ -270,11 +261,6 @@ __cold static int copier_init(struct processing_module *mod)
270261 dev -> direction = cd -> direction ;
271262 dev -> state = COMP_STATE_READY ;
272263 return 0 ;
273- error :
274- rfree (gtw_cfg );
275- error_cd :
276- rfree (cd );
277- return ret ;
278264}
279265
280266__cold static int copier_free (struct processing_module * mod )
@@ -303,10 +289,6 @@ __cold static int copier_free(struct processing_module *mod)
303289 break ;
304290 }
305291
306- if (cd )
307- rfree (cd -> gtw_cfg );
308- rfree (cd );
309-
310292 return 0 ;
311293}
312294
0 commit comments