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,19 +98,15 @@ 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 );
105- if (ret != 0 ) {
106- rfree (mic_priv_data );
103+ if (ret != 0 )
107104 return ret ;
108- }
109105
110106 cd -> mic_priv = mic_priv_data ;
111107
112108 ret = notifier_register (cd -> mic_priv , NULL , NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE ,
113109 mic_privacy_event , 0 );
114- if (ret != 0 )
115- rfree (mic_priv_data );
116110
117111 return ret ;
118112}
@@ -123,8 +117,6 @@ static void mic_privacy_free(struct copier_data *cd)
123117 mic_privacy_enable_dmic_irq (false);
124118
125119 notifier_unregister (cd -> mic_priv , NULL , NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE );
126-
127- rfree (cd -> mic_priv );
128120}
129121#endif
130122
@@ -144,7 +136,7 @@ __cold static int copier_init(struct processing_module *mod)
144136
145137 assert_can_be_cold ();
146138
147- cd = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* cd ));
139+ cd = mod_zalloc ( mod , sizeof (* cd ));
148140 if (!cd )
149141 return - ENOMEM ;
150142
@@ -154,10 +146,8 @@ __cold static int copier_init(struct processing_module *mod)
154146 * store it, it's only used during IPC processing, besides we haven't
155147 * allocated space for it, so don't "fix" this!
156148 */
157- if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 ) {
158- ret = - EINVAL ;
159- goto error_cd ;
160- }
149+ if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 )
150+ return - EINVAL ;
161151
162152 /* Allocate memory and store gateway_cfg in runtime. Gateway cfg has to
163153 * be kept even after copier is created e.g. during SET_PIPELINE_STATE
@@ -166,18 +156,15 @@ __cold static int copier_init(struct processing_module *mod)
166156 */
167157 if (copier -> gtw_cfg .config_length ) {
168158 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- }
159+ gtw_cfg = mod_alloc (mod , gtw_cfg_size );
160+ if (!gtw_cfg )
161+ return - ENOMEM ;
175162
176163 ret = memcpy_s (gtw_cfg , gtw_cfg_size , & copier -> gtw_cfg .config_data ,
177164 gtw_cfg_size );
178165 if (ret ) {
179166 comp_err (dev , "Unable to copy gateway config from copier blob" );
180- goto error ;
167+ return ret ;
181168 }
182169
183170 cd -> gtw_cfg = gtw_cfg ;
@@ -191,8 +178,7 @@ __cold static int copier_init(struct processing_module *mod)
191178 IPC_COMP_IGNORE_REMOTE );
192179 if (!ipc_pipe ) {
193180 comp_err (dev , "pipeline %d is not existed" , config -> pipeline_id );
194- ret = - EPIPE ;
195- goto error ;
181+ return - EPIPE ;
196182 }
197183
198184 dev -> pipeline = ipc_pipe -> pipeline ;
@@ -208,15 +194,15 @@ __cold static int copier_init(struct processing_module *mod)
208194 ret = copier_host_create (dev , cd , copier , ipc_pipe -> pipeline );
209195 if (ret < 0 ) {
210196 comp_err (dev , "unable to create host" );
211- goto error ;
197+ return ret ;
212198 }
213199#if CONFIG_INTEL_ADSP_MIC_PRIVACY
214200 if (cd -> direction == SOF_IPC_STREAM_CAPTURE &&
215201 node_id .f .dma_type == ipc4_hda_host_output_class ) {
216- ret = mic_privacy_configure (dev , cd );
202+ ret = mic_privacy_configure (mod , cd );
217203 if (ret < 0 ) {
218204 comp_err (dev , "unable to configure mic privacy" );
219- goto error ;
205+ return ret ;
220206 }
221207 }
222208#endif
@@ -231,14 +217,14 @@ __cold static int copier_init(struct processing_module *mod)
231217 ret = copier_dai_create (dev , cd , copier , ipc_pipe -> pipeline );
232218 if (ret < 0 ) {
233219 comp_err (dev , "unable to create dai" );
234- goto error ;
220+ return ret ;
235221 }
236222#if CONFIG_INTEL_ADSP_MIC_PRIVACY
237223 if (cd -> direction == SOF_IPC_STREAM_CAPTURE ) {
238- ret = mic_privacy_configure (dev , cd );
224+ ret = mic_privacy_configure (mod , cd );
239225 if (ret < 0 ) {
240226 comp_err (dev , "unable to configure mic privacy" );
241- goto error ;
227+ return ret ;
242228 }
243229 }
244230#endif
@@ -249,14 +235,13 @@ __cold static int copier_init(struct processing_module *mod)
249235 ret = copier_ipcgtw_create (dev , cd , copier , ipc_pipe -> pipeline );
250236 if (ret < 0 ) {
251237 comp_err (dev , "unable to create IPC gateway" );
252- goto error ;
238+ return ret ;
253239 }
254240 break ;
255241#endif
256242 default :
257243 comp_err (dev , "unsupported dma type %x" , (uint32_t )node_id .f .dma_type );
258- ret = - EINVAL ;
259- goto error ;
244+ return - EINVAL ;
260245 };
261246
262247 dev -> direction_set = true;
@@ -270,11 +255,6 @@ __cold static int copier_init(struct processing_module *mod)
270255 dev -> direction = cd -> direction ;
271256 dev -> state = COMP_STATE_READY ;
272257 return 0 ;
273- error :
274- rfree (gtw_cfg );
275- error_cd :
276- rfree (cd );
277- return ret ;
278258}
279259
280260__cold static int copier_free (struct processing_module * mod )
@@ -303,10 +283,6 @@ __cold static int copier_free(struct processing_module *mod)
303283 break ;
304284 }
305285
306- if (cd )
307- rfree (cd -> gtw_cfg );
308- rfree (cd );
309-
310286 return 0 ;
311287}
312288
0 commit comments