<commit_before>/*
 * dsp_pipeline.c: pipelined audio processing
 *
 * Copyright (C) 2007, <NAME>
 *
 * <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 */

#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/mISDNif.h>
#include <linux/mISDNdsp.h>
#include "dsp.h"
#include "dsp_hwec.h"

/* uncomment for debugging */
/*#define PIPELINE_DEBUG*/

struct dsp_pipeline_entry {
	struct mISDN_dsp_element *elem;
	void                *p;
	struct list_head     list;
};
struct dsp_element_entry {
	struct mISDN_dsp_element *elem;
	struct device	     dev;
	struct list_head     list;
};

static LIST_HEAD(dsp_elements);

/* sysfs */
static struct class *elements_class;

static ssize_t
attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct mISDN_dsp_element *elem = dev_get_drvdata(dev);
	ssize_t len = 0;
	int i = 0;

	*buf = 0;
	for (; i < elem->num_args; ++i)
		len = sprintf(buf, "%sName:        %s\n%s%s%sDescription: %s\n"
			"\n", buf,
			  elem->args[i].name,
			  elem->args[i].def ? "Default:     " : "",
			  elem->args[i].def ? elem->args[i].def : "",
			  elem->args[i].def ? "\n" : "",
			  elem->args[i].desc);

	return len;
}

static struct device_attribute element_attributes[] = {
	__ATTR(args, 0444, attr_show_args, NULL),
};

int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
{
	struct dsp_element_entry *entry;
	int ret, i;

	if (!elem)
		return -EINVAL;

	entry = kzalloc(sizeof(struct dsp_element_entry), GFP_KERNEL);
	if (!entry)
		return -ENOMEM;

	entry->elem = elem;

	entry->dev.class = elements_class;
	dev_set_drvdata(&entry->dev, elem);
	snprintf(entry->dev.bus_id, BUS_ID_SIZE, elem->name);
	ret = device_register(&entry->dev);
	if (ret) {
		printk(KERN_ERR "%s: failed to register %s\n",
			__func__, elem->name);
		goto err1;
	}

	for (i = 0; i < (sizeof(element_attributes)
		/ sizeof(struct device_attribute)); ++i)
		ret = device_create_file(&entry->dev,
				&element_attributes[i]);
		if (ret) {
			printk(KERN_ERR "%s: failed to create device file\n",
				__func__);
			goto err2;
		}

	list_add_tail(&entry->list, &dsp_elements);

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

	return 0;

err2:
	device_unregister(&entry->dev);
err1:
	kfree(entry);
	return ret;
}<commit_msg>ISDN: struct device - replace bus_id with dev_name(), dev_set_name()<commit_after>/*
 * dsp_pipeline.c: pipelined audio processing
 *
 * Copyright (C) 2007, <NAME>
 *
 * <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * The full GNU General Public License is included in this distribution in the
 * file called LICENSE.
 *
 */

#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/mISDNif.h>
#include <linux/mISDNdsp.h>
#include "dsp.h"
#include "dsp_hwec.h"

/* uncomment for debugging */
/*#define PIPELINE_DEBUG*/

struct dsp_pipeline_entry {
	struct mISDN_dsp_element *elem;
	void                *p;
	struct list_head     list;
};
struct dsp_element_entry {
	struct mISDN_dsp_element *elem;
	struct device	     dev;
	struct list_head     list;
};

static LIST_HEAD(dsp_elements);

/* sysfs */
static struct class *elements_class;

static ssize_t
attr_show_args(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct mISDN_dsp_element *elem = dev_get_drvdata(dev);
	ssize_t len = 0;
	int i = 0;

	*buf = 0;
	for (; i < elem->num_args; ++i)
		len = sprintf(buf, "%sName:        %s\n%s%s%sDescription: %s\n"
			"\n", buf,
			  elem->args[i].name,
			  elem->args[i].def ? "Default:     " : "",
			  elem->args[i].def ? elem->args[i].def : "",
			  elem->args[i].def ? "\n" : "",
			  elem->args[i].desc);

	return len;
}

static struct device_attribute element_attributes[] = {
	__ATTR(args, 0444, attr_show_args, NULL),
};

int mISDN_dsp_element_register(struct mISDN_dsp_element *elem)
{
	struct dsp_element_entry *entry;
	int ret, i;

	if (!elem)
		return -EINVAL;

	entry = kzalloc(sizeof(struct dsp_element_entry), GFP_KERNEL);
	if (!entry)
		return -ENOMEM;

	entry->elem = elem;

	entry->dev.class = elements_class;
	dev_set_drvdata(&entry->dev, elem);
	dev_set_name(&entry->dev, elem->name);
	ret = device_register(&entry->dev);
	if (ret) {
		printk(KERN_ERR "%s: failed to register %s\n",
			__func__, elem->name);
		goto err1;
	}

	for (i = 0; i < (sizeof(element_attributes)
		/ sizeof(struct device_attribute)); ++i)
		ret = device_create_file(&entry->dev,
				&element_attributes[i]);
		if (ret) {
			printk(KERN_ERR "%s: failed to create device file\n",
				__func__);
			goto err2;
		}

	list_add_tail(&entry->list, &dsp_elements);

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

	return 0;

err2:
	device_unregister(&entry->dev);
err1:
	kfree(entry);
	return ret;
}
{'fraction_non_alphanumeric': 0.12883631713554988, 'fraction_numerical': 0.010230179028132993, 'mean_word_length': 3.895931142410016, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4491763', 'n_tokens_mistral': 2299, 'n_tokens_neox': 2166, 'n_words': 650}