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
@@ -141,7 +133,7 @@ __cold static int copier_init(struct processing_module *mod)
141133
142134 assert_can_be_cold ();
143135
144- cd = rzalloc ( SOF_MEM_FLAG_USER , sizeof (* cd ));
136+ cd = mod_zalloc ( mod , sizeof (* cd ));
145137 if (!cd )
146138 return - ENOMEM ;
147139
@@ -151,10 +143,8 @@ __cold static int copier_init(struct processing_module *mod)
151143 * store it, it's only used during IPC processing, besides we haven't
152144 * allocated space for it, so don't "fix" this!
153145 */
154- if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 ) {
155- ret = - EINVAL ;
156- goto error_cd ;
157- }
146+ if (memcpy_s (& cd -> config , sizeof (cd -> config ), copier , sizeof (* copier )) < 0 )
147+ return - EINVAL ;
158148
159149 /* Allocate memory and store gateway_cfg in runtime. Gateway cfg has to
160150 * be kept even after copier is created e.g. during SET_PIPELINE_STATE
@@ -163,18 +153,15 @@ __cold static int copier_init(struct processing_module *mod)
163153 */
164154 if (copier -> gtw_cfg .config_length ) {
165155 gtw_cfg_size = copier -> gtw_cfg .config_length << 2 ;
166- gtw_cfg = rmalloc (SOF_MEM_FLAG_USER ,
167- gtw_cfg_size );
168- if (!gtw_cfg ) {
169- ret = - ENOMEM ;
170- goto error_cd ;
171- }
156+ gtw_cfg = mod_alloc (mod , gtw_cfg_size );
157+ if (!gtw_cfg )
158+ return - ENOMEM ;
172159
173160 ret = memcpy_s (gtw_cfg , gtw_cfg_size , & copier -> gtw_cfg .config_data ,
174161 gtw_cfg_size );
175162 if (ret ) {
176163 comp_err (dev , "Unable to copy gateway config from copier blob" );
177- goto error ;
164+ return ret ;
178165 }
179166
180167 cd -> gtw_cfg = gtw_cfg ;
@@ -191,18 +178,18 @@ __cold static int copier_init(struct processing_module *mod)
191178 switch (node_id .f .dma_type ) {
192179 case ipc4_hda_host_output_class :
193180 case ipc4_hda_host_input_class :
194- ret = copier_host_create (dev , cd , copier , dev -> pipeline );
181+ ret = copier_host_create (mod , cd , copier , dev -> pipeline );
195182 if (ret < 0 ) {
196183 comp_err (dev , "unable to create host" );
197- goto error ;
184+ return ret ;
198185 }
199186#if CONFIG_INTEL_ADSP_MIC_PRIVACY
200187 if (cd -> direction == SOF_IPC_STREAM_CAPTURE &&
201188 node_id .f .dma_type == ipc4_hda_host_output_class ) {
202- ret = mic_privacy_configure (dev , cd );
189+ ret = mic_privacy_configure (mod , cd );
203190 if (ret < 0 ) {
204191 comp_err (dev , "unable to configure mic privacy" );
205- goto error ;
192+ return ret ;
206193 }
207194 }
208195#endif
@@ -217,32 +204,31 @@ __cold static int copier_init(struct processing_module *mod)
217204 ret = copier_dai_create (dev , cd , copier , dev -> pipeline );
218205 if (ret < 0 ) {
219206 comp_err (dev , "unable to create dai" );
220- goto error ;
207+ return ret ;
221208 }
222209#if CONFIG_INTEL_ADSP_MIC_PRIVACY
223210 if (cd -> direction == SOF_IPC_STREAM_CAPTURE ) {
224- ret = mic_privacy_configure (dev , cd );
211+ ret = mic_privacy_configure (mod , cd );
225212 if (ret < 0 ) {
226213 comp_err (dev , "unable to configure mic privacy" );
227- goto error ;
214+ return ret ;
228215 }
229216 }
230217#endif
231218 break ;
232219#if CONFIG_IPC4_GATEWAY
233220 case ipc4_ipc_output_class :
234221 case ipc4_ipc_input_class :
235- ret = copier_ipcgtw_create (dev , cd , copier , dev -> pipeline );
222+ ret = copier_ipcgtw_create (mod , cd , copier , dev -> pipeline );
236223 if (ret < 0 ) {
237224 comp_err (dev , "unable to create IPC gateway" );
238- goto error ;
225+ return ret ;
239226 }
240227 break ;
241228#endif
242229 default :
243230 comp_err (dev , "unsupported dma type %x" , (uint32_t )node_id .f .dma_type );
244- ret = - EINVAL ;
245- goto error ;
231+ return - EINVAL ;
246232 };
247233
248234 dev -> direction_set = true;
@@ -256,11 +242,6 @@ __cold static int copier_init(struct processing_module *mod)
256242 dev -> direction = cd -> direction ;
257243 dev -> state = COMP_STATE_READY ;
258244 return 0 ;
259- error :
260- rfree (gtw_cfg );
261- error_cd :
262- rfree (cd );
263- return ret ;
264245}
265246
266247__cold static int copier_free (struct processing_module * mod )
@@ -289,10 +270,6 @@ __cold static int copier_free(struct processing_module *mod)
289270 break ;
290271 }
291272
292- if (cd )
293- rfree (cd -> gtw_cfg );
294- rfree (cd );
295-
296273 return 0 ;
297274}
298275
0 commit comments