drivers/staging/greybus/audio_manager_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/staging/greybus/audio_manager_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/staging/greybus/audio_manager_sysfs.c- Extension
.c- Size
- 2299 bytes
- Lines
- 102
- Domain
- Driver Families
- Bucket
- drivers/staging
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/sysfs.haudio_manager.haudio_manager_private.h
Detected Declarations
function manager_sysfs_add_storefunction manager_sysfs_remove_storefunction manager_sysfs_dump_storefunction manager_sysfs_init_attributefunction gb_audio_manager_sysfs_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Greybus operations
*
* Copyright 2015-2016 Google Inc.
*/
#include <linux/string.h>
#include <linux/sysfs.h>
#include "audio_manager.h"
#include "audio_manager_private.h"
static ssize_t manager_sysfs_add_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
struct gb_audio_manager_module_descriptor desc = { {0} };
int num = sscanf(buf,
"name=%" GB_AUDIO_MANAGER_MODULE_NAME_LEN_SSCANF
"s vid=%d pid=%d intf_id=%d i/p devices=0x%X o/p devices=0x%X",
desc.name, &desc.vid, &desc.pid, &desc.intf_id,
&desc.ip_devices, &desc.op_devices);
if (num != 7)
return -EINVAL;
num = gb_audio_manager_add(&desc);
if (num < 0)
return -EINVAL;
return count;
}
static struct kobj_attribute manager_add_attribute =
__ATTR(add, 0664, NULL, manager_sysfs_add_store);
static ssize_t manager_sysfs_remove_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
int id;
int num = kstrtoint(buf, 10, &id);
if (num != 1)
return -EINVAL;
num = gb_audio_manager_remove(id);
if (num)
return num;
return count;
}
static struct kobj_attribute manager_remove_attribute =
__ATTR(remove, 0664, NULL, manager_sysfs_remove_store);
static ssize_t manager_sysfs_dump_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t count)
{
int id;
int num = kstrtoint(buf, 10, &id);
if (num == 1) {
num = gb_audio_manager_dump_module(id);
if (num)
return num;
} else if (!strncmp("all", buf, 3)) {
gb_audio_manager_dump_all();
} else {
return -EINVAL;
}
return count;
}
static struct kobj_attribute manager_dump_attribute =
__ATTR(dump, 0664, NULL, manager_sysfs_dump_store);
static void manager_sysfs_init_attribute(struct kobject *kobj,
struct kobj_attribute *kattr)
{
int err;
err = sysfs_create_file(kobj, &kattr->attr);
if (err) {
Annotation
- Immediate include surface: `linux/string.h`, `linux/sysfs.h`, `audio_manager.h`, `audio_manager_private.h`.
- Detected declarations: `function manager_sysfs_add_store`, `function manager_sysfs_remove_store`, `function manager_sysfs_dump_store`, `function manager_sysfs_init_attribute`, `function gb_audio_manager_sysfs_init`.
- Atlas domain: Driver Families / drivers/staging.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.