drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c

Source file repositories/reference/linux-study-clean/drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c

File Facts

System
Linux kernel
Corpus path
drivers/crypto/intel/qat/qat_common/adf_heartbeat_dbgfs.c
Extension
.c
Size
6280 bytes
Lines
249
Domain
Driver Families
Bucket
drivers/crypto
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

static const struct file_operations adf_hb_stats_fops = {
	.owner = THIS_MODULE,
	.open = simple_open,
	.read = adf_hb_stats_read,
};

static ssize_t adf_hb_status_read(struct file *file, char __user *user_buf,
				  size_t count, loff_t *ppos)
{
	enum adf_device_heartbeat_status hb_status;
	char ret_str[HB_STATUS_MAX_STRLEN];
	struct adf_accel_dev *accel_dev;
	int ret_code;
	size_t len;

	if (*ppos > 0)
		return 0;

	accel_dev = file->private_data;
	ret_code = HB_OK;

	adf_heartbeat_status(accel_dev, &hb_status);

	if (hb_status != HB_DEV_ALIVE)
		ret_code = HB_ERROR;

	len = scnprintf(ret_str, sizeof(ret_str), "%d\n", ret_code);

	return simple_read_from_buffer(user_buf, count, ppos, ret_str, len + 1);
}

static const struct file_operations adf_hb_status_fops = {
	.owner = THIS_MODULE,
	.open = simple_open,
	.read = adf_hb_status_read,
};

static ssize_t adf_hb_cfg_read(struct file *file, char __user *user_buf,
			       size_t count, loff_t *ppos)
{
	char timer_str[ADF_CFG_MAX_VAL_LEN_IN_BYTES];
	struct adf_accel_dev *accel_dev;
	unsigned int timer_ms;
	int len;

	if (*ppos > 0)
		return 0;

	accel_dev = file->private_data;
	timer_ms = accel_dev->heartbeat->hb_timer;
	len = scnprintf(timer_str, sizeof(timer_str), "%u\n", timer_ms);

	return simple_read_from_buffer(user_buf, count, ppos, timer_str,
				       len + 1);
}

static ssize_t adf_hb_cfg_write(struct file *file, const char __user *user_buf,
				size_t count, loff_t *ppos)
{
	char input_str[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = { };
	struct adf_accel_dev *accel_dev;
	int ret, written_chars;
	unsigned int timer_ms;
	u32 ticks;

	accel_dev = file->private_data;
	timer_ms = ADF_CFG_HB_TIMER_DEFAULT_MS;

	/* last byte left as string termination */
	if (count > sizeof(input_str) - 1)
		return -EINVAL;

	written_chars = simple_write_to_buffer(input_str, sizeof(input_str) - 1,
					       ppos, user_buf, count);
	if (written_chars > 0) {
		ret = kstrtouint(input_str, 10, &timer_ms);
		if (ret) {
			dev_err(&GET_DEV(accel_dev),
				"heartbeat_cfg: Invalid value\n");
			return ret;
		}

		if (timer_ms < ADF_CFG_HB_TIMER_MIN_MS) {
			dev_err(&GET_DEV(accel_dev),
				"heartbeat_cfg: Invalid value\n");
			return -EINVAL;
		}

		/*
		 * On 4xxx devices adf_timer is responsible for HB updates and

Annotation

Implementation Notes