1 /*
2 * Copyright (c) 2018 The Linux Foundation. All rights reserved.
3 *
4 *
5 * Permission to use, copy, modify, and/or distribute this software for
6 * any purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19
20 /**
21 * DOC: This implementation of init/deint functions for FTM services.
22 */
23
24 #include <wlan_ftm_init_deinit_api.h>
25 #include <wlan_ftm_ucfg_api.h>
26 #include <wlan_objmgr_global_obj.h>
27 #include "../../core/src/wlan_ftm_svc_i.h"
28 #include <wlan_cmn.h>
29 #include <qdf_module.h>
30
dispatcher_ftm_init(void)31 QDF_STATUS dispatcher_ftm_init(void)
32 {
33 QDF_STATUS status = QDF_STATUS_SUCCESS;
34
35 status = wlan_objmgr_register_pdev_create_handler(WLAN_UMAC_COMP_FTM,
36 wlan_ftm_pdev_obj_create_notification, NULL);
37
38 if (QDF_IS_STATUS_ERROR(status))
39 goto err_pdev_create;
40
41 status = wlan_objmgr_register_pdev_destroy_handler(WLAN_UMAC_COMP_FTM,
42 wlan_ftm_pdev_obj_destroy_notification, NULL);
43
44 if (QDF_IS_STATUS_ERROR(status))
45 goto err_pdev_delete;
46
47 return QDF_STATUS_SUCCESS;
48
49 err_pdev_delete:
50 wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_FTM,
51 wlan_ftm_pdev_obj_create_notification, NULL);
52 err_pdev_create:
53 return status;
54 }
55
dispatcher_ftm_deinit(void)56 QDF_STATUS dispatcher_ftm_deinit(void)
57 {
58 QDF_STATUS status = QDF_STATUS_SUCCESS;
59
60 status = wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_FTM,
61 wlan_ftm_pdev_obj_create_notification, NULL);
62
63 if (QDF_IS_STATUS_ERROR(status))
64 return QDF_STATUS_E_FAILURE;
65
66 status = wlan_objmgr_unregister_pdev_destroy_handler(WLAN_UMAC_COMP_FTM,
67 wlan_ftm_pdev_obj_destroy_notification, NULL);
68
69 if (QDF_IS_STATUS_ERROR(status))
70 return QDF_STATUS_E_FAILURE;
71
72 return QDF_STATUS_SUCCESS;
73 }
74
dispatcher_ftm_psoc_open(struct wlan_objmgr_psoc * psoc)75 QDF_STATUS dispatcher_ftm_psoc_open(struct wlan_objmgr_psoc *psoc)
76 {
77 /* calling the wmi event handler registration */
78 return wlan_ftm_testmode_attach(psoc);
79 }
80
dispatcher_ftm_psoc_close(struct wlan_objmgr_psoc * psoc)81 QDF_STATUS dispatcher_ftm_psoc_close(struct wlan_objmgr_psoc *psoc)
82 {
83 /* calling the wmi event handler de-registration */
84 return wlan_ftm_testmode_detach(psoc);
85 }
86