aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/mISDN/dsp_pipeline.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/mISDN/dsp_pipeline.c')
-rw-r--r--drivers/isdn/mISDN/dsp_pipeline.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c
index 83639be7f7ad..bf999bdc41c3 100644
--- a/drivers/isdn/mISDN/dsp_pipeline.c
+++ b/drivers/isdn/mISDN/dsp_pipeline.c
@@ -75,6 +75,15 @@ static struct device_attribute element_attributes[] = {
75 __ATTR(args, 0444, attr_show_args, NULL), 75 __ATTR(args, 0444, attr_show_args, NULL),
76}; 76};
77 77
78static void
79mISDN_dsp_dev_release(struct device *dev)
80{
81 struct dsp_element_entry *entry =
82 container_of(dev, struct dsp_element_entry, dev);
83 list_del(&entry->list);
84 kfree(entry);
85}
86
78int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) 87int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
79{ 88{
80 struct dsp_element_entry *entry; 89 struct dsp_element_entry *entry;
@@ -83,13 +92,14 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
83 if (!elem) 92 if (!elem)
84 return -EINVAL; 93 return -EINVAL;
85 94
86 entry = kzalloc(sizeof(struct dsp_element_entry), GFP_KERNEL); 95 entry = kzalloc(sizeof(struct dsp_element_entry), GFP_ATOMIC);
87 if (!entry) 96 if (!entry)
88 return -ENOMEM; 97 return -ENOMEM;
89 98
90 entry->elem = elem; 99 entry->elem = elem;
91 100
92 entry->dev.class = elements_class; 101 entry->dev.class = elements_class;
102 entry->dev.release = mISDN_dsp_dev_release;
93 dev_set_drvdata(&entry->dev, elem); 103 dev_set_drvdata(&entry->dev, elem);
94 dev_set_name(&entry->dev, elem->name); 104 dev_set_name(&entry->dev, elem->name);
95 ret = device_register(&entry->dev); 105 ret = device_register(&entry->dev);
@@ -98,6 +108,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
98 __func__, elem->name); 108 __func__, elem->name);
99 goto err1; 109 goto err1;
100 } 110 }
111 list_add_tail(&entry->list, &dsp_elements);
101 112
102 for (i = 0; i < (sizeof(element_attributes) 113 for (i = 0; i < (sizeof(element_attributes)
103 / sizeof(struct device_attribute)); ++i) 114 / sizeof(struct device_attribute)); ++i)
@@ -109,14 +120,15 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
109 goto err2; 120 goto err2;
110 } 121 }
111 122
112 list_add_tail(&entry->list, &dsp_elements); 123#ifdef PIPELINE_DEBUG
113
114 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name); 124 printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
125#endif
115 126
116 return 0; 127 return 0;
117 128
118err2: 129err2:
119 device_unregister(&entry->dev); 130 device_unregister(&entry->dev);
131 return ret;
120err1: 132err1:
121 kfree(entry); 133 kfree(entry);
122 return ret; 134 return ret;
@@ -132,11 +144,11 @@ void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem)
132 144
133 list_for_each_entry_safe(entry, n, &dsp_elements, list) 145 list_for_each_entry_safe(entry, n, &dsp_elements, list)
134 if (entry->elem == elem) { 146 if (entry->elem == elem) {
135 list_del(&entry->list);
136 device_unregister(&entry->dev); 147 device_unregister(&entry->dev);
137 kfree(entry); 148#ifdef PIPELINE_DEBUG
138 printk(KERN_DEBUG "%s: %s unregistered\n", 149 printk(KERN_DEBUG "%s: %s unregistered\n",
139 __func__, elem->name); 150 __func__, elem->name);
151#endif
140 return; 152 return;
141 } 153 }
142 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name); 154 printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
@@ -173,7 +185,9 @@ void dsp_pipeline_module_exit(void)
173 kfree(entry); 185 kfree(entry);
174 } 186 }
175 187
188#ifdef PIPELINE_DEBUG
176 printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__); 189 printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
190#endif
177} 191}
178 192
179int dsp_pipeline_init(struct dsp_pipeline *pipeline) 193int dsp_pipeline_init(struct dsp_pipeline *pipeline)
@@ -239,7 +253,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
239 if (!len) 253 if (!len)
240 return 0; 254 return 0;
241 255
242 dup = kmalloc(len + 1, GFP_KERNEL); 256 dup = kmalloc(len + 1, GFP_ATOMIC);
243 if (!dup) 257 if (!dup)
244 return 0; 258 return 0;
245 strcpy(dup, cfg); 259 strcpy(dup, cfg);
@@ -256,9 +270,9 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
256 elem = entry->elem; 270 elem = entry->elem;
257 271
258 pipeline_entry = kmalloc(sizeof(struct 272 pipeline_entry = kmalloc(sizeof(struct
259 dsp_pipeline_entry), GFP_KERNEL); 273 dsp_pipeline_entry), GFP_ATOMIC);
260 if (!pipeline_entry) { 274 if (!pipeline_entry) {
261 printk(KERN_DEBUG "%s: failed to add " 275 printk(KERN_ERR "%s: failed to add "
262 "entry to pipeline: %s (out of " 276 "entry to pipeline: %s (out of "
263 "memory)\n", __func__, elem->name); 277 "memory)\n", __func__, elem->name);
264 incomplete = 1; 278 incomplete = 1;
@@ -286,7 +300,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
286 args : ""); 300 args : "");
287#endif 301#endif
288 } else { 302 } else {
289 printk(KERN_DEBUG "%s: failed " 303 printk(KERN_ERR "%s: failed "
290 "to add entry to pipeline: " 304 "to add entry to pipeline: "
291 "%s (new() returned NULL)\n", 305 "%s (new() returned NULL)\n",
292 __func__, elem->name); 306 __func__, elem->name);
@@ -301,7 +315,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
301 if (found) 315 if (found)
302 found = 0; 316 found = 0;
303 else { 317 else {
304 printk(KERN_DEBUG "%s: element not found, skipping: " 318 printk(KERN_ERR "%s: element not found, skipping: "
305 "%s\n", __func__, name); 319 "%s\n", __func__, name);
306 incomplete = 1; 320 incomplete = 1;
307 } 321 }