Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 808a14a1 authored by Andreas Eversberg's avatar Andreas Eversberg Committed by Karsten Keil
Browse files

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: default avatarAndreas Eversberg <andreas@eversberg.eu>
Signed-off-by: default avatarKarsten Keil <kkeil@suse.de>
parent 87c5fa1b
Loading
Loading
Loading
Loading
+21 −7
Original line number Original line Diff line number Diff line
@@ -75,6 +75,15 @@ static struct device_attribute element_attributes[] = {
	__ATTR(args, 0444, attr_show_args, NULL),
	__ATTR(args, 0444, attr_show_args, NULL),
};
};


static void
mISDN_dsp_dev_release(struct device *dev)
{
	struct dsp_element_entry *entry =
		container_of(dev, struct dsp_element_entry, dev);
	list_del(&entry->list);
	kfree(entry);
}

int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
{
{
	struct dsp_element_entry *entry;
	struct dsp_element_entry *entry;
@@ -90,6 +99,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
	entry->elem = elem;
	entry->elem = elem;


	entry->dev.class = elements_class;
	entry->dev.class = elements_class;
	entry->dev.release = mISDN_dsp_dev_release;
	dev_set_drvdata(&entry->dev, elem);
	dev_set_drvdata(&entry->dev, elem);
	dev_set_name(&entry->dev, elem->name);
	dev_set_name(&entry->dev, elem->name);
	ret = device_register(&entry->dev);
	ret = device_register(&entry->dev);
@@ -98,6 +108,7 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
			__func__, elem->name);
			__func__, elem->name);
		goto err1;
		goto err1;
	}
	}
	list_add_tail(&entry->list, &dsp_elements);


	for (i = 0; i < (sizeof(element_attributes)
	for (i = 0; i < (sizeof(element_attributes)
		/ sizeof(struct device_attribute)); ++i)
		/ sizeof(struct device_attribute)); ++i)
@@ -109,14 +120,15 @@ int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
			goto err2;
			goto err2;
		}
		}


	list_add_tail(&entry->list, &dsp_elements);
#ifdef PIPELINE_DEBUG

	printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
	printk(KERN_DEBUG "%s: %s registered\n", __func__, elem->name);
#endif


	return 0;
	return 0;


err2:
err2:
	device_unregister(&entry->dev);
	device_unregister(&entry->dev);
	return ret;
err1:
err1:
	kfree(entry);
	kfree(entry);
	return ret;
	return ret;
@@ -132,11 +144,11 @@ void mISDN_dsp_element_unregister(struct mISDN_dsp_element *elem)


	list_for_each_entry_safe(entry, n, &dsp_elements, list)
	list_for_each_entry_safe(entry, n, &dsp_elements, list)
		if (entry->elem == elem) {
		if (entry->elem == elem) {
			list_del(&entry->list);
			device_unregister(&entry->dev);
			device_unregister(&entry->dev);
			kfree(entry);
#ifdef PIPELINE_DEBUG
			printk(KERN_DEBUG "%s: %s unregistered\n",
			printk(KERN_DEBUG "%s: %s unregistered\n",
				__func__, elem->name);
				__func__, elem->name);
#endif
			return;
			return;
		}
		}
	printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
	printk(KERN_ERR "%s: element %s not in list.\n", __func__, elem->name);
@@ -173,7 +185,9 @@ void dsp_pipeline_module_exit(void)
		kfree(entry);
		kfree(entry);
	}
	}


#ifdef PIPELINE_DEBUG
	printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
	printk(KERN_DEBUG "%s: dsp pipeline module exited\n", __func__);
#endif
}
}


int dsp_pipeline_init(struct dsp_pipeline *pipeline)
int dsp_pipeline_init(struct dsp_pipeline *pipeline)
@@ -258,7 +272,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
				pipeline_entry = kmalloc(sizeof(struct
				pipeline_entry = kmalloc(sizeof(struct
					dsp_pipeline_entry), GFP_KERNEL);
					dsp_pipeline_entry), GFP_KERNEL);
				if (!pipeline_entry) {
				if (!pipeline_entry) {
					printk(KERN_DEBUG "%s: failed to add "
					printk(KERN_ERR "%s: failed to add "
					    "entry to pipeline: %s (out of "
					    "entry to pipeline: %s (out of "
					    "memory)\n", __func__, elem->name);
					    "memory)\n", __func__, elem->name);
					incomplete = 1;
					incomplete = 1;
@@ -286,7 +300,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
						    args : "");
						    args : "");
#endif
#endif
					} else {
					} else {
						printk(KERN_DEBUG "%s: failed "
						printk(KERN_ERR "%s: failed "
						  "to add entry to pipeline: "
						  "to add entry to pipeline: "
						  "%s (new() returned NULL)\n",
						  "%s (new() returned NULL)\n",
						  __func__, elem->name);
						  __func__, elem->name);
@@ -301,7 +315,7 @@ int dsp_pipeline_build(struct dsp_pipeline *pipeline, const char *cfg)
		if (found)
		if (found)
			found = 0;
			found = 0;
		else {
		else {
			printk(KERN_DEBUG "%s: element not found, skipping: "
			printk(KERN_ERR "%s: element not found, skipping: "
				"%s\n", __func__, name);
				"%s\n", __func__, name);
			incomplete = 1;
			incomplete = 1;
		}
		}