scsi_evt_thread
时间: 2023-10-08 13:12:11 浏览: 43
scsi_evt_thread 是一个线程,它在异步通知 sata_async_notification 中被唤醒。当事件类型为 SDEV_EVT_MEDIA_CHANGE 时,会调用该线程。该线程主要负责处理与 SCSI 设备事件相关的工作。在 scsi_alloc_sdev 初始化过程中,会将该线程设置为 scsi_evt_thread。在处理过程中,会调用 scsi_evt_thread,并通过 kobject_uevent_env 向用户空间发送事件通知。
相关问题
static void db_disc_handler(ble_db_discovery_evt_t * p_evt) { ble_cds_on_db_disc_evt(&m_cds_c, p_evt); ble_sts_on_db_disc_evt(&m_sts_c, p_evt); ble_ftms_on_db_disc_evt(&m_ftms_c, p_evt); }
这是一段 C 语言代码,其中定义了一个函数 `db_disc_handler`,它的参数是一个指向 `ble_db_discovery_evt_t` 结构体的指针 `p_evt`。在函数体内,分别调用了三个不同的函数 `ble_cds_on_db_disc_evt`、`ble_sts_on_db_disc_evt` 和 `ble_ftms_on_db_disc_evt`,并将它们的参数分别传入了三个不同的变量 `m_cds_c`、`m_sts_c` 和 `m_ftms_c`。这段代码的功能看起来是在处理 BLE 设备的数据库发现事件,但具体实现细节需要看这些函数的定义和上下文环境。
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) { uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle; uint16_t role = ble_conn_state_role(conn_handle); #if __USER_1_DEBUG__ test_printf("role = %d\r\n", role); #endif // Based on the role this device plays in the connection, dispatch to the right handler. if (role == BLE_GAP_ROLE_PERIPH || ble_evt_is_advertising_timeout(p_ble_evt)) { ble_evt_dispatch(p_ble_evt, p_context); } else if ((role == BLE_GAP_ROLE_CENTRAL) || (p_ble_evt->header.evt_id == BLE_GAP_EVT_ADV_REPORT)) { ble_module_central_evt(p_ble_evt, p_context); } }
这段代码实现了一个 BLE 事件处理函数,当发生 BLE 事件时,该函数会被调用。函数首先通过连接句柄获取 BLE 设备的角色(是从设备还是主设备),然后根据角色类型分发事件到不同的事件处理函数中。
如果该设备是从设备(BLE_GAP_ROLE_PERIPH),或者广播超时(ble_evt_is_advertising_timeout(p_ble_evt)),则直接调用 ble_evt_dispatch() 函数处理该事件。
如果该设备是主设备(BLE_GAP_ROLE_CENTRAL),或者事件 ID 是 BLE_GAP_EVT_ADV_REPORT,则调用 ble_module_central_evt() 函数处理该事件。
其中,p_ble_evt 是一个 BLE 事件结构体指针,包含了 BLE 事件的各种信息,而 p_context 则是一个用户定义的上下文指针,可以用来传递一些额外的参数或数据。