drivers/hwtracing/coresight/coresight-cti-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-cti-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwtracing/coresight/coresight-cti-sysfs.c- Extension
.c- Size
- 31776 bytes
- Lines
- 1194
- Domain
- Driver Families
- Bucket
- drivers/hwtracing
- 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.
- 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/atomic.hlinux/coresight.hlinux/device.hlinux/io.hlinux/kernel.hlinux/spinlock.hlinux/sysfs.hcoresight-cti.h
Detected Declarations
enum cti_conn_attr_typefunction enable_showfunction enable_storefunction powered_showfunction ctmid_showfunction nr_trigger_cons_showfunction coresight_cti_reg_showfunction coresight_cti_reg_storefunction __ATTRfunction cti_reg32_showfunction scoped_guardfunction cti_reg32_storefunction scoped_guardfunction DEVICE_ATTR_RWfunction inout_sel_storefunction inen_showfunction scoped_guardfunction inen_storefunction outen_showfunction scoped_guardfunction outen_storefunction intack_storefunction appclear_storefunction apppulse_storefunction coresight_cti_regs_is_visiblefunction cti_trig_op_parsefunction trigin_attach_storefunction trigin_detach_storefunction trigout_attach_storefunction trigout_detach_storefunction chan_gate_enable_storefunction chan_gate_enable_showfunction chan_gate_disable_storefunction chan_op_parsefunction chan_set_storefunction chan_clear_storefunction chan_pulse_storefunction trig_filter_enable_showfunction trig_filter_enable_storefunction trigout_filtered_showfunction chan_xtrigs_reset_storefunction chan_xtrigs_sel_storefunction chan_xtrigs_sel_showfunction chan_xtrigs_in_showfunction chan_xtrigs_out_showfunction print_chan_listfunction chan_inuse_showfunction chan_free_show
Annotated Snippet
if (cti_is_active(config)) {
val = cti_read_single_reg(drvdata, reg_offset);
if (pcached_val)
*pcached_val = val;
} else if (pcached_val) {
val = *pcached_val;
}
}
return sprintf(buf, "%#x\n", val);
}
/*
* Store a simple 32 bit value.
* If pcached_val not NULL, then copy to here too,
* if reg_offset >= 0 then write through if enabled.
*/
static ssize_t cti_reg32_store(struct device *dev, const char *buf,
size_t size, u32 *pcached_val, int reg_offset)
{
unsigned long val;
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cti_config *config = &drvdata->config;
if (kstrtoul(buf, 0, &val))
return -EINVAL;
if (reg_offset < 0)
return -EINVAL;
scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
/* local store */
if (pcached_val)
*pcached_val = (u32)val;
/* write through if offset and enabled */
if (cti_is_active(config))
cti_write_single_reg(drvdata, reg_offset, val);
}
return size;
}
/* Standard macro for simple rw cti config registers */
#define cti_config_reg32_rw(name, cfgname, offset) \
static ssize_t name##_show(struct device *dev, \
struct device_attribute *attr, \
char *buf) \
{ \
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
return cti_reg32_show(dev, buf, \
&drvdata->config.cfgname, offset); \
} \
\
static ssize_t name##_store(struct device *dev, \
struct device_attribute *attr, \
const char *buf, size_t size) \
{ \
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent); \
return cti_reg32_store(dev, buf, size, \
&drvdata->config.cfgname, offset); \
} \
static DEVICE_ATTR_RW(name)
static ssize_t inout_sel_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
u32 val;
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
val = (u32)drvdata->config.ctiinout_sel;
return sprintf(buf, "%d\n", val);
}
static ssize_t inout_sel_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t size)
{
unsigned long val;
struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
struct cti_config *config = &drvdata->config;
if (kstrtoul(buf, 0, &val))
return -EINVAL;
if (val >= config->nr_trig_max)
return -EINVAL;
guard(raw_spinlock_irqsave)(&drvdata->spinlock);
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/coresight.h`, `linux/device.h`, `linux/io.h`, `linux/kernel.h`, `linux/spinlock.h`, `linux/sysfs.h`, `coresight-cti.h`.
- Detected declarations: `enum cti_conn_attr_type`, `function enable_show`, `function enable_store`, `function powered_show`, `function ctmid_show`, `function nr_trigger_cons_show`, `function coresight_cti_reg_show`, `function coresight_cti_reg_store`, `function __ATTR`, `function cti_reg32_show`.
- Atlas domain: Driver Families / drivers/hwtracing.
- 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.