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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/errno.hlinux/export.hlinux/fs.hlinux/kernel.hlinux/kstrtox.hlinux/types.hadf_admin.hadf_cfg.hadf_common_drv.hadf_heartbeat.hadf_heartbeat_dbgfs.h
Detected Declarations
function adf_hb_stats_readfunction adf_hb_status_readfunction adf_hb_cfg_readfunction adf_hb_cfg_writefunction adf_hb_error_inject_writefunction adf_heartbeat_dbgfs_addfunction adf_heartbeat_dbgfs_rmexport adf_heartbeat_dbgfs_addexport adf_heartbeat_dbgfs_rm
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
- Immediate include surface: `linux/debugfs.h`, `linux/errno.h`, `linux/export.h`, `linux/fs.h`, `linux/kernel.h`, `linux/kstrtox.h`, `linux/types.h`, `adf_admin.h`.
- Detected declarations: `function adf_hb_stats_read`, `function adf_hb_status_read`, `function adf_hb_cfg_read`, `function adf_hb_cfg_write`, `function adf_hb_error_inject_write`, `function adf_heartbeat_dbgfs_add`, `function adf_heartbeat_dbgfs_rm`, `export adf_heartbeat_dbgfs_add`, `export adf_heartbeat_dbgfs_rm`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.