drivers/hwtracing/coresight/coresight-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-sysfs.c- Extension
.c- Size
- 16869 bytes
- Lines
- 668
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/device.hlinux/idr.hlinux/kernel.hlinux/property.hcoresight-priv.hcoresight-trace-id.h
Detected Declarations
function coresight_simple_show_pairfunction coresight_simple_show32function coresight_enable_source_sysfsfunction coresight_disable_source_sysfsfunction coresight_find_activated_sysfs_sinkfunction coresight_validate_source_sysfsfunction coresight_enable_sysfsfunction coresight_enable_sourcefunction coresight_disable_sysfsfunction enable_sink_showfunction enable_sink_storefunction enable_source_showfunction enable_source_storefunction label_showfunction label_is_visiblefunction nr_links_showfunction coresight_create_conns_sysfs_groupfunction coresight_remove_conns_sysfs_groupfunction coresight_add_sysfs_linkfunction coresight_remove_sysfs_linkfunction coresight_make_linksfunction coresight_remove_linksexport coresight_simple_show_pairexport coresight_simple_show32export coresight_enable_sysfsexport coresight_disable_sysfsexport coresight_add_sysfs_linkexport coresight_remove_sysfs_link
Annotated Snippet
if (path == NULL) {
pr_err("Path is not found for %s\n", dev_name(&csdev->dev));
goto out;
}
idr_remove(&path_idr, hash);
break;
default:
/* We can't be here */
break;
}
coresight_disable_path(path);
coresight_release_path(path);
out:
mutex_unlock(&coresight_mutex);
}
EXPORT_SYMBOL_GPL(coresight_disable_sysfs);
static ssize_t enable_sink_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct coresight_device *csdev = to_coresight_device(dev);
return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->sysfs_sink_activated);
}
static ssize_t enable_sink_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
int ret;
unsigned long val;
struct coresight_device *csdev = to_coresight_device(dev);
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;
csdev->sysfs_sink_activated = !!val;
return size;
}
static DEVICE_ATTR_RW(enable_sink);
static ssize_t enable_source_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct coresight_device *csdev = to_coresight_device(dev);
guard(mutex)(&coresight_mutex);
return scnprintf(buf, PAGE_SIZE, "%u\n",
coresight_get_mode(csdev) == CS_MODE_SYSFS);
}
static ssize_t enable_source_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
int ret = 0;
unsigned long val;
struct coresight_device *csdev = to_coresight_device(dev);
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;
if (val) {
ret = coresight_enable_sysfs(csdev);
if (ret)
return ret;
} else {
coresight_disable_sysfs(csdev);
}
return size;
}
static DEVICE_ATTR_RW(enable_source);
static ssize_t label_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const char *str;
int ret;
ret = fwnode_property_read_string(dev_fwnode(dev), "label", &str);
if (ret == 0)
return sysfs_emit(buf, "%s\n", str);
Annotation
- Immediate include surface: `linux/device.h`, `linux/idr.h`, `linux/kernel.h`, `linux/property.h`, `coresight-priv.h`, `coresight-trace-id.h`.
- Detected declarations: `function coresight_simple_show_pair`, `function coresight_simple_show32`, `function coresight_enable_source_sysfs`, `function coresight_disable_source_sysfs`, `function coresight_find_activated_sysfs_sink`, `function coresight_validate_source_sysfs`, `function coresight_enable_sysfs`, `function coresight_enable_source`, `function coresight_disable_sysfs`, `function enable_sink_show`.
- Atlas domain: Driver Families / drivers/hwtracing.
- Implementation status: integration 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.