diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index ca7fd63c9d71..e0800051f37a 100644 --- a/wmi/inc/wmi_unified_api.h +++ b/wmi/inc/wmi_unified_api.h @@ -220,6 +220,17 @@ wmi_unified_register_event_handler(wmi_unified_t wmi_handle, wmi_unified_event_handler handler_func, uint8_t rx_ctx); +/** + * WMI event handler unregister function for converged componets + * + * @param wmi_handle : handle to WMI. + * @param event_id : WMI event ID + * @return 0 on success and -ve on failure. + */ +int +wmi_unified_unregister_event(wmi_unified_t wmi_handle, + uint32_t event_id); + /** * WMI event handler unregister function * diff --git a/wmi/src/wmi_unified.c b/wmi/src/wmi_unified.c index d57ab83dbbf3..f0c8a064e6ee 100644 --- a/wmi/src/wmi_unified.c +++ b/wmi/src/wmi_unified.c @@ -1959,6 +1959,45 @@ int wmi_unified_register_event_handler(wmi_unified_t wmi_handle, return 0; } +/** + * wmi_unified_unregister_event() - unregister wmi event handler + * @wmi_handle: handle to wmi + * @event_id: wmi event id + * + * Return: 0 on success + */ +int wmi_unified_unregister_event(wmi_unified_t wmi_handle, + uint32_t event_id) +{ + uint32_t idx = 0; + uint32_t evt_id; + struct wmi_soc *soc = wmi_handle->soc; + + if (event_id >= wmi_events_max || + wmi_handle->wmi_events[event_id] == WMI_EVENT_ID_INVALID) { + qdf_print("%s: Event id %d is unavailable\n", + __func__, event_id); + return QDF_STATUS_E_FAILURE; + } + evt_id = wmi_handle->wmi_events[event_id]; + + idx = wmi_unified_get_event_handler_ix(wmi_handle, evt_id); + if (idx == -1) { + qdf_print("%s : event handler is not registered: evt id 0x%x\n", + __func__, evt_id); + return QDF_STATUS_E_FAILURE; + } + wmi_handle->event_handler[idx] = NULL; + wmi_handle->event_id[idx] = 0; + --soc->max_event_idx; + wmi_handle->event_handler[idx] = + wmi_handle->event_handler[soc->max_event_idx]; + wmi_handle->event_id[idx] = + wmi_handle->event_id[soc->max_event_idx]; + + return 0; +} + /** * wmi_unified_unregister_event_handler() - unregister wmi event handler * @wmi_handle: handle to wmi