diff options
author | Andreas Eversberg <andreas@eversberg.eu> | 2008-09-28 09:40:15 -0400 |
---|---|---|
committer | Karsten Keil <kkeil@suse.de> | 2009-01-09 16:44:28 -0500 |
commit | 808a14a1583ca3790bf0a9c20c7d4cbac212c775 (patch) | |
tree | cbdd7cf346479d30aa03655761bb5532d1b4cc5e /drivers/isdn/mISDN/dsp_pipeline.c | |
parent | 87c5fa1bb42624254a2013cbbc3b170d6017f5d6 (diff) |
mISDN: Add missing release functions
Add missing release function of ec-devices. Each device require a relase
function now. All destruction (memory and list entry) must be done within
the given release function of device, rather than after unregistering device.
Signed-off-by: Andreas Eversberg <andreas@eversberg.eu>
Signed-off-by: Karsten Keil <kkeil@suse.de>
Diffstat (limited to 'drivers/isdn/mISDN/dsp_pipeline.c')
-rw-r--r-- | drivers/isdn/mISDN/dsp_pipeline.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/isdn/mISDN/dsp_pipeline.c b/drivers/isdn/mISDN/dsp_pipeline.c index 83639be7f7ad..7a3a3e1e4d80 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 | ||
78 | static void | ||
79 | mISDN_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 | |||
78 | int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) | 87 | int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) |
79 | { | 88 | { |
80 | struct dsp_element_entry *entry; | 89 | struct dsp_element_entry *entry; |
@@ -90,6 +99,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem) | |||
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 | ||
118 | err2: | 129 | err2: |
119 | device_unregister(&entry->dev); | 130 | device_unregister(&entry->dev); |
131 | return ret; | ||
120 | err1: | 132 | err1: |
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 | ||
179 | int dsp_pipeline_init(struct dsp_pipeline *pipeline) | 193 | int dsp_pipeline_init(struct dsp_pipeline *pipeline) |
@@ -258,7 +272,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg) | |||
258 | pipeline_entry = kmalloc(sizeof(struct | 272 | pipeline_entry = kmalloc(sizeof(struct |
259 | dsp_pipeline_entry), GFP_KERNEL); | 273 | dsp_pipeline_entry), GFP_KERNEL); |
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 | } |