Release 4.11 drivers/staging/greybus/audio_manager.c
/*
* Greybus operations
*
* Copyright 2015-2016 Google Inc.
*
* Released under the GPLv2 only.
*/
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/rwlock.h>
#include <linux/idr.h>
#include "audio_manager.h"
#include "audio_manager_private.h"
static struct kset *manager_kset;
static LIST_HEAD(modules_list);
static DECLARE_RWSEM(modules_rwsem);
static DEFINE_IDA(module_id);
/* helpers */
static struct gb_audio_manager_module *gb_audio_manager_get_locked(int id)
{
struct gb_audio_manager_module *module;
if (id < 0)
return NULL;
list_for_each_entry(module, &modules_list, list) {
if (module->id == id)
return module;
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 49 | 100.00% | 1 | 100.00% |
Total | 49 | 100.00% | 1 | 100.00% |
/* public API */
int gb_audio_manager_add(struct gb_audio_manager_module_descriptor *desc)
{
struct gb_audio_manager_module *module;
int id;
int err;
id = ida_simple_get(&module_id, 0, 0, GFP_KERNEL);
err = gb_audio_manager_module_create(&module, manager_kset,
id, desc);
if (err) {
ida_simple_remove(&module_id, id);
return err;
}
/* Add it to the list */
down_write(&modules_rwsem);
list_add_tail(&module->list, &modules_list);
up_write(&modules_rwsem);
return module->id;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 63 | 66.32% | 1 | 33.33% |
Greg Kroah-Hartman | 28 | 29.47% | 1 | 33.33% |
Vaibhav Agarwal | 4 | 4.21% | 1 | 33.33% |
Total | 95 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_add);
int gb_audio_manager_remove(int id)
{
struct gb_audio_manager_module *module;
down_write(&modules_rwsem);
module = gb_audio_manager_get_locked(id);
if (!module) {
up_write(&modules_rwsem);
return -EINVAL;
}
list_del(&module->list);
kobject_put(&module->kobj);
up_write(&modules_rwsem);
ida_simple_remove(&module_id, id);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 63 | 82.89% | 1 | 50.00% |
Vaibhav Agarwal | 13 | 17.11% | 1 | 50.00% |
Total | 76 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_remove);
void gb_audio_manager_remove_all(void)
{
struct gb_audio_manager_module *module, *next;
int is_empty = 1;
down_write(&modules_rwsem);
list_for_each_entry_safe(module, next, &modules_list, list) {
list_del(&module->list);
kobject_put(&module->kobj);
ida_simple_remove(&module_id, module->id);
}
is_empty = list_empty(&modules_list);
up_write(&modules_rwsem);
if (!is_empty)
pr_warn("Not all nodes were deleted\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 74 | 84.09% | 1 | 33.33% |
Dinko Mironov | 10 | 11.36% | 1 | 33.33% |
Vaibhav Agarwal | 4 | 4.55% | 1 | 33.33% |
Total | 88 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_remove_all);
struct gb_audio_manager_module *gb_audio_manager_get_module(int id)
{
struct gb_audio_manager_module *module;
down_read(&modules_rwsem);
module = gb_audio_manager_get_locked(id);
kobject_get(&module->kobj);
up_read(&modules_rwsem);
return module;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 41 | 91.11% | 1 | 50.00% |
Vaibhav Agarwal | 4 | 8.89% | 1 | 50.00% |
Total | 45 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_get_module);
void gb_audio_manager_put_module(struct gb_audio_manager_module *module)
{
kobject_put(&module->kobj);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 18 | 100.00% | 1 | 100.00% |
Total | 18 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_put_module);
int gb_audio_manager_dump_module(int id)
{
struct gb_audio_manager_module *module;
down_read(&modules_rwsem);
module = gb_audio_manager_get_locked(id);
up_read(&modules_rwsem);
if (!module)
return -EINVAL;
gb_audio_manager_module_dump(module);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 45 | 91.84% | 1 | 50.00% |
Vaibhav Agarwal | 4 | 8.16% | 1 | 50.00% |
Total | 49 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_dump_module);
void gb_audio_manager_dump_all(void)
{
struct gb_audio_manager_module *module;
int count = 0;
down_read(&modules_rwsem);
list_for_each_entry(module, &modules_list, list) {
gb_audio_manager_module_dump(module);
count++;
}
up_read(&modules_rwsem);
pr_info("Number of connected modules: %d\n", count);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 50 | 92.59% | 1 | 50.00% |
Vaibhav Agarwal | 4 | 7.41% | 1 | 50.00% |
Total | 54 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(gb_audio_manager_dump_all);
/*
* module init/deinit
*/
static int __init manager_init(void)
{
manager_kset = kset_create_and_add(GB_AUDIO_MANAGER_NAME, NULL,
kernel_kobj);
if (!manager_kset)
return -ENOMEM;
#ifdef GB_AUDIO_MANAGER_SYSFS
gb_audio_manager_sysfs_init(&manager_kset->kobj);
#endif
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 45 | 100.00% | 1 | 100.00% |
Total | 45 | 100.00% | 1 | 100.00% |
static void __exit manager_exit(void)
{
gb_audio_manager_remove_all();
kset_unregister(manager_kset);
ida_destroy(&module_id);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 17 | 73.91% | 1 | 50.00% |
Greg Kroah-Hartman | 6 | 26.09% | 1 | 50.00% |
Total | 23 | 100.00% | 2 | 100.00% |
module_init(manager_init);
module_exit(manager_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Svetlin Ankov <ankov_svetlin@projectara.com>");
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Svetlin Ankov | 562 | 86.59% | 1 | 20.00% |
Greg Kroah-Hartman | 39 | 6.01% | 1 | 20.00% |
Vaibhav Agarwal | 35 | 5.39% | 1 | 20.00% |
Dinko Mironov | 10 | 1.54% | 1 | 20.00% |
Bartosz Golaszewski | 3 | 0.46% | 1 | 20.00% |
Total | 649 | 100.00% | 5 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.