hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/isdn/mISDN/dsp_pipeline.c
....@@ -1,27 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * dsp_pipeline.c: pipelined audio processing
34 *
45 * Copyright (C) 2007, Nadi Sarrar
56 *
67 * Nadi Sarrar <nadi@beronet.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License as published by the Free
10
- * Software Foundation; either version 2 of the License, or (at your option)
11
- * any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful, but WITHOUT
14
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
- * more details.
17
- *
18
- * You should have received a copy of the GNU General Public License along with
19
- * this program; if not, write to the Free Software Foundation, Inc., 59
20
- * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
- *
22
- * The full GNU General Public License is included in this distribution in the
23
- * file called LICENSE.
24
- *
258 */
269
2710 #include <linux/kernel.h>
....@@ -33,9 +16,6 @@
3316 #include <linux/export.h>
3417 #include "dsp.h"
3518 #include "dsp_hwec.h"
36
-
37
-/* uncomment for debugging */
38
-/*#define PIPELINE_DEBUG*/
3919
4020 struct dsp_pipeline_entry {
4121 struct mISDN_dsp_element *elem;
....@@ -97,6 +77,7 @@
9777 if (!entry)
9878 return -ENOMEM;
9979
80
+ INIT_LIST_HEAD(&entry->list);
10081 entry->elem = elem;
10182
10283 entry->dev.class = elements_class;
....@@ -121,17 +102,13 @@
121102 }
122103 }
123104
124
-#ifdef PIPELINE_DEBUG
125
- printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
126
-#endif
127
-
128105 return 0;
129106
130107 err2:
131108 device_unregister(&entry->dev);
132109 return ret;
133110 err1:
134
- kfree(entry);
111
+ put_device(&entry->dev);
135112 return ret;
136113 }
137114 EXPORT_SYMBOL(mISDN_dsp_element_register);
....@@ -146,10 +123,6 @@
146123 list_for_each_entry_safe(entry, n, &dsp_elements, list)
147124 if (entry->elem == elem) {
148125 device_unregister(&entry->dev);
149
-#ifdef PIPELINE_DEBUG
150
- printk(KERN_DEBUG "%s: %s unregistered\n",
151
- __func__, elem->name);
152
-#endif
153126 return;
154127 }
155128 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
....@@ -161,10 +134,6 @@
161134 elements_class = class_create(THIS_MODULE, "dsp_pipeline");
162135 if (IS_ERR(elements_class))
163136 return PTR_ERR(elements_class);
164
-
165
-#ifdef PIPELINE_DEBUG
166
- printk(KERN_DEBUG "%s: dsp pipeline module initialized\n", __func__);
167
-#endif
168137
169138 dsp_hwec_init();
170139
....@@ -185,10 +154,6 @@
185154 __func__, entry->elem->name);
186155 kfree(entry);
187156 }
188
-
189
-#ifdef PIPELINE_DEBUG
190
- printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
191
-#endif
192157 }
193158
194159 int dsp_pipeline_init(struct dsp_pipeline *pipeline)
....@@ -197,10 +162,6 @@
197162 return -EINVAL;
198163
199164 INIT_LIST_HEAD(&pipeline->list);
200
-
201
-#ifdef PIPELINE_DEBUG
202
- printk(KERN_DEBUG "%s: dsp pipeline ready\n", __func__);
203
-#endif
204165
205166 return 0;
206167 }
....@@ -227,16 +188,12 @@
227188 return;
228189
229190 _dsp_pipeline_destroy(pipeline);
230
-
231
-#ifdef PIPELINE_DEBUG
232
- printk(KERN_DEBUG "%s: dsp pipeline destroyed\n", __func__);
233
-#endif
234191 }
235192
236193 int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
237194 {
238
- int incomplete = 0, found = 0;
239
- char *dup, *tok, *name, *args;
195
+ int found = 0;
196
+ char *dup, *next, *tok, *name, *args;
240197 struct dsp_element_entry *entry, *n;
241198 struct dsp_pipeline_entry *pipeline_entry;
242199 struct mISDN_dsp_element *elem;
....@@ -247,10 +204,10 @@
247204 if (!list_empty(&pipeline->list))
248205 _dsp_pipeline_destroy(pipeline);
249206
250
- dup = kstrdup(cfg, GFP_ATOMIC);
207
+ dup = next = kstrdup(cfg, GFP_ATOMIC);
251208 if (!dup)
252209 return 0;
253
- while ((tok = strsep(&dup, "|"))) {
210
+ while ((tok = strsep(&next, "|"))) {
254211 if (!strlen(tok))
255212 continue;
256213 name = strsep(&tok, "(");
....@@ -268,7 +225,6 @@
268225 printk(KERN_ERR "%s: failed to add "
269226 "entry to pipeline: %s (out of "
270227 "memory)\n", __func__, elem->name);
271
- incomplete = 1;
272228 goto _out;
273229 }
274230 pipeline_entry->elem = elem;
....@@ -285,20 +241,12 @@
285241 if (pipeline_entry->p) {
286242 list_add_tail(&pipeline_entry->
287243 list, &pipeline->list);
288
-#ifdef PIPELINE_DEBUG
289
- printk(KERN_DEBUG "%s: created "
290
- "instance of %s%s%s\n",
291
- __func__, name, args ?
292
- " with args " : "", args ?
293
- args : "");
294
-#endif
295244 } else {
296245 printk(KERN_ERR "%s: failed "
297246 "to add entry to pipeline: "
298247 "%s (new() returned NULL)\n",
299248 __func__, elem->name);
300249 kfree(pipeline_entry);
301
- incomplete = 1;
302250 }
303251 }
304252 found = 1;
....@@ -307,11 +255,9 @@
307255
308256 if (found)
309257 found = 0;
310
- else {
258
+ else
311259 printk(KERN_ERR "%s: element not found, skipping: "
312260 "%s\n", __func__, name);
313
- incomplete = 1;
314
- }
315261 }
316262
317263 _out:
....@@ -320,10 +266,6 @@
320266 else
321267 pipeline->inuse = 0;
322268
323
-#ifdef PIPELINE_DEBUG
324
- printk(KERN_DEBUG "%s: dsp pipeline built%s: %s\n",
325
- __func__, incomplete ? " incomplete" : "", cfg);
326
-#endif
327269 kfree(dup);
328270 return 0;
329271 }