drivers/hwtracing/coresight/coresight-core.c

Source file repositories/reference/linux-study-clean/drivers/hwtracing/coresight/coresight-core.c

File Facts

System
Linux kernel
Corpus path
drivers/hwtracing/coresight/coresight-core.c
Extension
.c
Size
48822 bytes
Lines
1810
Domain
Driver Families
Bucket
drivers/hwtracing
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

const struct bus_type coresight_bustype = {
	.name	= "coresight",
};

static int coresight_panic_sync(struct device *dev, void *data)
{
	int mode;
	struct coresight_device *csdev;

	/* Run through panic sync handlers for all enabled devices */
	csdev = container_of(dev, struct coresight_device, dev);
	mode = coresight_get_mode(csdev);

	if ((mode == CS_MODE_SYSFS) || (mode == CS_MODE_PERF)) {
		if (panic_ops(csdev))
			panic_ops(csdev)->sync(csdev);
	}

	return 0;
}

static int coresight_panic_cb(struct notifier_block *self,
			       unsigned long v, void *p)
{
	bus_for_each_dev(&coresight_bustype, NULL, NULL,
				 coresight_panic_sync);

	return 0;
}

static struct notifier_block coresight_notifier = {
	.notifier_call = coresight_panic_cb,
};

static int __init coresight_init(void)
{
	int ret;

	ret = bus_register(&coresight_bustype);
	if (ret)
		return ret;

	ret = etm_perf_init();
	if (ret)
		goto exit_bus_unregister;

	/* Register function to be called for panic */
	ret = atomic_notifier_chain_register(&panic_notifier_list,
					     &coresight_notifier);
	if (ret)
		goto exit_perf;

	/* initialise the coresight syscfg API */
	ret = cscfg_init();
	if (!ret)
		return 0;

	atomic_notifier_chain_unregister(&panic_notifier_list,
					     &coresight_notifier);
exit_perf:
	etm_perf_exit();
exit_bus_unregister:
	bus_unregister(&coresight_bustype);
	return ret;
}

static void __exit coresight_exit(void)
{
	cscfg_exit();
	atomic_notifier_chain_unregister(&panic_notifier_list,
					     &coresight_notifier);
	etm_perf_exit();
	bus_unregister(&coresight_bustype);
	coresight_release_device_list();
}

module_init(coresight_init);
module_exit(coresight_exit);

int coresight_init_driver_with_owner(const char *drv, struct amba_driver *amba_drv,
				     struct platform_driver *pdev_drv, struct module *owner,
				     const char *mod_name)
{
	int ret;

	ret = __amba_driver_register(amba_drv, owner);
	if (ret) {
		pr_err("%s: error registering AMBA driver\n", drv);
		return ret;
	}

Annotation

Implementation Notes