drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
Source file repositories/reference/linux-study-clean/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c- Extension
.c- Size
- 11613 bytes
- Lines
- 431
- Domain
- Driver Families
- Bucket
- drivers/hid
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/hid.hamd_sfh_init.hamd_sfh_interface.h../hid_descriptor/amd_sfh_hid_desc.h
Detected Declarations
function Copyrightfunction amd_sfh_wait_for_responsefunction amd_sfh_hid_client_deinitfunction amd_sfh1_1_hid_client_initfunction amd_sfh_resumefunction amd_sfh_suspendfunction amd_sfh_toggle_hpdfunction amd_mp2_pci_removefunction amd_sfh_set_opsfunction amd_sfh1_1_init
Annotated Snippet
switch (i) {
case ACCEL_IDX:
case GYRO_IDX:
case MAG_IDX:
case SRA_IDX:
case ALS_IDX:
case HPD_IDX:
if (BIT(i) & slist->sl.sensors)
sensor_id[num_of_sensors++] = i;
break;
}
}
return num_of_sensors;
}
static u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id)
{
if (mp2->mp2_ops->response)
return mp2->mp2_ops->response(mp2, sid, cmd_id);
return 0;
}
static const char *get_sensor_name(int idx)
{
switch (idx) {
case ACCEL_IDX:
return "accelerometer";
case GYRO_IDX:
return "gyroscope";
case MAG_IDX:
return "magnetometer";
case SRA_IDX:
return "SRA";
case ALS_IDX:
return "ALS";
case HPD_IDX:
return "HPD";
default:
return "unknown sensor type";
}
}
static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
{
struct amdtp_cl_data *cl_data = privdata->cl_data;
int i, status;
for (i = 0; i < cl_data->num_hid_devices; i++) {
switch (cl_data->sensor_idx[i]) {
case HPD_IDX:
privdata->dev_en.is_hpd_present = false;
break;
case ALS_IDX:
privdata->dev_en.is_als_present = false;
break;
case SRA_IDX:
privdata->dev_en.is_sra_present = false;
break;
}
if (cl_data->sensor_sts[i] == SENSOR_ENABLED) {
privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]);
status = amd_sfh_wait_for_response
(privdata, cl_data->sensor_idx[i], DISABLE_SENSOR);
if (status == 0)
cl_data->sensor_sts[i] = SENSOR_DISABLED;
dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x (%s) status 0x%x\n",
cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]),
cl_data->sensor_sts[i]);
}
}
cancel_delayed_work_sync(&cl_data->work);
cancel_delayed_work_sync(&cl_data->work_buffer);
amdtp_hid_remove(cl_data);
return 0;
}
static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata)
{
struct amd_input_data *in_data = &privdata->in_data;
struct amdtp_cl_data *cl_data = privdata->cl_data;
struct amd_mp2_ops *mp2_ops = privdata->mp2_ops;
struct amd_mp2_sensor_info info;
struct request_list *req_list;
u32 feature_report_size;
u32 input_report_size;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/hid.h`, `amd_sfh_init.h`, `amd_sfh_interface.h`, `../hid_descriptor/amd_sfh_hid_desc.h`.
- Detected declarations: `function Copyright`, `function amd_sfh_wait_for_response`, `function amd_sfh_hid_client_deinit`, `function amd_sfh1_1_hid_client_init`, `function amd_sfh_resume`, `function amd_sfh_suspend`, `function amd_sfh_toggle_hpd`, `function amd_mp2_pci_remove`, `function amd_sfh_set_ops`, `function amd_sfh1_1_init`.
- Atlas domain: Driver Families / drivers/hid.
- Implementation status: source implementation candidate.
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.