Ver Fonte

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
Soumya Bhat há 8 anos atrás
pai
commit
169eff157d
2 ficheiros alterados com 50 adições e 0 exclusões
  1. 11 0
      wmi/inc/wmi_unified_api.h
  2. 39 0
      wmi/src/wmi_unified.c

+ 11 - 0
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
  *

+ 39 - 0
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