cregit-Linux how code gets into the kernel

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

PersonTokensPropCommitsCommitProp
Svetlin Ankov49100.00%1100.00%
Total49100.00%1100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov6366.32%133.33%
Greg Kroah-Hartman2829.47%133.33%
Vaibhav Agarwal44.21%133.33%
Total95100.00%3100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov6382.89%150.00%
Vaibhav Agarwal1317.11%150.00%
Total76100.00%2100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov7484.09%133.33%
Dinko Mironov1011.36%133.33%
Vaibhav Agarwal44.55%133.33%
Total88100.00%3100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov4191.11%150.00%
Vaibhav Agarwal48.89%150.00%
Total45100.00%2100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov18100.00%1100.00%
Total18100.00%1100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov4591.84%150.00%
Vaibhav Agarwal48.16%150.00%
Total49100.00%2100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov5092.59%150.00%
Vaibhav Agarwal47.41%150.00%
Total54100.00%2100.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

PersonTokensPropCommitsCommitProp
Svetlin Ankov45100.00%1100.00%
Total45100.00%1100.00%


static void __exit manager_exit(void) { gb_audio_manager_remove_all(); kset_unregister(manager_kset); ida_destroy(&module_id); }

Contributors

PersonTokensPropCommitsCommitProp
Svetlin Ankov1773.91%150.00%
Greg Kroah-Hartman626.09%150.00%
Total23100.00%2100.00%

module_init(manager_init); module_exit(manager_exit); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Svetlin Ankov <ankov_svetlin@projectara.com>");

Overall Contributors

PersonTokensPropCommitsCommitProp
Svetlin Ankov56286.59%120.00%
Greg Kroah-Hartman396.01%120.00%
Vaibhav Agarwal355.39%120.00%
Dinko Mironov101.54%120.00%
Bartosz Golaszewski30.46%120.00%
Total649100.00%5100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.