From 169eff157da886605e30ffe0dfa9d02cd1da038b Mon Sep 17 00:00:00 2001 From: Soumya Bhat Date: Mon, 27 Mar 2017 12:26:56 +0530 Subject: [PATCH] qcacmn: Add new WMI API to unregister event handler Add new API to unregister event handler to allow converged components to move to common eventid space. Change-Id: I97f096ff3e36bc7923718498c535fb6c3c50e7e7 CRs-Fixed: 2023157 --- wmi/inc/wmi_unified_api.h | 11 +++++++++++ wmi/src/wmi_unified.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/wmi/inc/wmi_unified_api.h b/wmi/inc/wmi_unified_api.h index ca7fd63c9d..e0800051f3 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 d57ab83dbb..f0c8a064e6 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