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.

Dependency Surface

Detected Declarations

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

Implementation Notes