1 /*
2 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 /**
18 * DOC: wlan_qmi_main.c
19 *
20 * QMI component core function definitions
21 */
22
23 #include "wlan_qmi_main.h"
24 #include "wlan_qmi_public_struct.h"
25 #include "wlan_qmi_objmgr.h"
26
27 QDF_STATUS
qmi_psoc_obj_create_notification(struct wlan_objmgr_psoc * psoc,void * arg)28 qmi_psoc_obj_create_notification(struct wlan_objmgr_psoc *psoc, void *arg)
29 {
30 struct wlan_qmi_psoc_context *qmi_ctx;
31 QDF_STATUS status;
32
33 qmi_ctx = qdf_mem_malloc(sizeof(*qmi_ctx));
34 if (!qmi_ctx)
35 return QDF_STATUS_E_NOMEM;
36
37 qmi_ctx->psoc = psoc;
38
39 status = wlan_objmgr_psoc_component_obj_attach(psoc, WLAN_UMAC_COMP_QMI,
40 qmi_ctx,
41 QDF_STATUS_SUCCESS);
42 if (QDF_IS_STATUS_ERROR(status)) {
43 qmi_err("Failed to attach psoc QMI component obj");
44 qdf_mem_free(qmi_ctx);
45 return status;
46 }
47
48 return status;
49 }
50
51 QDF_STATUS
qmi_psoc_obj_destroy_notification(struct wlan_objmgr_psoc * psoc,void * arg)52 qmi_psoc_obj_destroy_notification(struct wlan_objmgr_psoc *psoc, void *arg)
53 {
54 struct wlan_qmi_psoc_context *qmi_ctx;
55 QDF_STATUS status;
56
57 qmi_ctx = qmi_psoc_get_priv(psoc);
58 if (!qmi_ctx) {
59 qmi_err("psoc priv is NULL");
60 return QDF_STATUS_E_FAILURE;
61 }
62
63 status = wlan_objmgr_psoc_component_obj_detach(psoc, WLAN_UMAC_COMP_QMI,
64 qmi_ctx);
65 if (QDF_IS_STATUS_ERROR(status))
66 qmi_err("Failed to detach psoc QMI component obj");
67
68 qdf_mem_free(qmi_ctx);
69
70 return status;
71 }
72