drivers/hte/hte.c

Source file repositories/reference/linux-study-clean/drivers/hte/hte.c

File Facts

System
Linux kernel
Corpus path
drivers/hte/hte.c
Extension
.c
Size
21845 bytes
Lines
943
Domain
Driver Families
Bucket
drivers/hte
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

subsys_initcall(hte_subsys_dbgfs_init);

static void hte_chip_dbgfs_init(struct hte_device *gdev)
{
	const struct hte_chip *chip = gdev->chip;
	const char *name = chip->name ? chip->name : dev_name(chip->dev);

	gdev->dbg_root = debugfs_create_dir(name, hte_root);

	debugfs_create_atomic_t("ts_requested", 0444, gdev->dbg_root,
				&gdev->ts_req);
	debugfs_create_u32("total_ts", 0444, gdev->dbg_root,
			   &gdev->nlines);
}

static void hte_ts_dbgfs_init(const char *name, struct hte_ts_info *ei)
{
	if (!ei->gdev->dbg_root || !name)
		return;

	ei->ts_dbg_root = debugfs_create_dir(name, ei->gdev->dbg_root);

	debugfs_create_atomic_t("dropped_timestamps", 0444, ei->ts_dbg_root,
				&ei->dropped_ts);
}

#else

static void hte_chip_dbgfs_init(struct hte_device *gdev)
{
}

static void hte_ts_dbgfs_init(const char *name, struct hte_ts_info *ei)
{
}

#endif

/**
 * hte_ts_put() - Release and disable timestamp for the given desc.
 *
 * @desc: timestamp descriptor.
 *
 * Context: debugfs_remove_recursive() function call may use sleeping locks,
 *	    not suitable from atomic context.
 * Returns: 0 on success or a negative error code on failure.
 */
int hte_ts_put(struct hte_ts_desc *desc)
{
	int ret = 0;
	unsigned long flag;
	struct hte_device *gdev;
	struct hte_ts_info *ei;

	if (!desc)
		return -EINVAL;

	ei = desc->hte_data;

	if (!ei || !ei->gdev)
		return -EINVAL;

	gdev = ei->gdev;

	mutex_lock(&ei->req_mlock);

	if (unlikely(!test_bit(HTE_TS_REQ, &ei->flags) &&
	    !test_bit(HTE_TS_REGISTERED, &ei->flags))) {
		dev_info(gdev->sdev, "id:%d is not requested\n",
			 desc->attr.line_id);
		ret = -EINVAL;
		goto unlock;
	}

	if (unlikely(!test_bit(HTE_TS_REQ, &ei->flags) &&
	    test_bit(HTE_TS_REGISTERED, &ei->flags))) {
		dev_info(gdev->sdev, "id:%d is registered but not requested\n",
			 desc->attr.line_id);
		ret = -EINVAL;
		goto unlock;
	}

	if (test_bit(HTE_TS_REQ, &ei->flags) &&
	    !test_bit(HTE_TS_REGISTERED, &ei->flags)) {
		clear_bit(HTE_TS_REQ, &ei->flags);
		desc->hte_data = NULL;
		ret = 0;
		goto mod_put;
	}

Annotation

Implementation Notes