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