drivers/interconnect/debugfs-client.c
Source file repositories/reference/linux-study-clean/drivers/interconnect/debugfs-client.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/interconnect/debugfs-client.c- Extension
.c- Size
- 3895 bytes
- Lines
- 182
- Domain
- Driver Families
- Bucket
- drivers/interconnect
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/interconnect.hlinux/platform_device.hinternal.h
Detected Declarations
struct debugfs_pathfunction list_for_each_entryfunction icc_get_setfunction icc_commit_setfunction icc_debugfs_client_initfunction icc_debugfs_client_init
Annotated Snippet
struct debugfs_path {
const char *src;
const char *dst;
struct icc_path *path;
struct list_head list;
};
static struct icc_path *get_path(const char *src, const char *dst)
{
struct debugfs_path *path;
list_for_each_entry(path, &debugfs_paths, list) {
if (!strcmp(path->src, src) && !strcmp(path->dst, dst))
return path->path;
}
return NULL;
}
static int icc_get_set(void *data, u64 val)
{
struct debugfs_path *debugfs_path;
char *src, *dst;
int ret = 0;
mutex_lock(&debugfs_lock);
rcu_read_lock();
src = rcu_dereference(src_node);
dst = rcu_dereference(dst_node);
/*
* If we've already looked up a path, then use the existing one instead
* of calling icc_get() again. This allows for updating previous BW
* votes when "get" is written to multiple times for multiple paths.
*/
cur_path = get_path(src, dst);
if (cur_path) {
rcu_read_unlock();
goto out;
}
src = kstrdup(src, GFP_ATOMIC);
dst = kstrdup(dst, GFP_ATOMIC);
rcu_read_unlock();
if (!src || !dst) {
ret = -ENOMEM;
goto err_free;
}
cur_path = icc_get(&pdev->dev, src, dst);
if (IS_ERR(cur_path)) {
ret = PTR_ERR(cur_path);
goto err_free;
}
debugfs_path = kzalloc_obj(*debugfs_path);
if (!debugfs_path) {
ret = -ENOMEM;
goto err_put;
}
debugfs_path->path = cur_path;
debugfs_path->src = src;
debugfs_path->dst = dst;
list_add_tail(&debugfs_path->list, &debugfs_paths);
goto out;
err_put:
icc_put(cur_path);
err_free:
kfree(src);
kfree(dst);
out:
mutex_unlock(&debugfs_lock);
return ret;
}
DEFINE_DEBUGFS_ATTRIBUTE(icc_get_fops, NULL, icc_get_set, "%llu\n");
static int icc_commit_set(void *data, u64 val)
{
int ret;
mutex_lock(&debugfs_lock);
if (!cur_path) {
ret = -EINVAL;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/interconnect.h`, `linux/platform_device.h`, `internal.h`.
- Detected declarations: `struct debugfs_path`, `function list_for_each_entry`, `function icc_get_set`, `function icc_commit_set`, `function icc_debugfs_client_init`, `function icc_debugfs_client_init`.
- Atlas domain: Driver Families / drivers/interconnect.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.