1 /*
2 * Copyright (c) 2020, The Linux Foundation. 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: This file contains various object manager related wrappers and helpers
19 */
20
21 #ifndef _FTM_TIME_SYNC_OBJMGR_H
22 #define _FTM_TIME_SYNC_OBJMGR_H
23
24 #include "wlan_cmn.h"
25 #include "wlan_objmgr_cmn.h"
26 #include "wlan_objmgr_vdev_obj.h"
27 #include "wlan_objmgr_global_obj.h"
28
29 /**
30 * ftm_time_sync_vdev_get_ref() - Wrapper to increment ftm_time_sync ref count
31 * @vdev: vdev object
32 *
33 * Wrapper for ftm_time_sync to increment ref count after checking valid
34 * object state.
35 *
36 * Return: SUCCESS/FAILURE
37 */
38 static inline
ftm_time_sync_vdev_get_ref(struct wlan_objmgr_vdev * vdev)39 QDF_STATUS ftm_time_sync_vdev_get_ref(struct wlan_objmgr_vdev *vdev)
40 {
41 return wlan_objmgr_vdev_try_get_ref(vdev, FTM_TIME_SYNC_ID);
42 }
43
44 /**
45 * ftm_time_sync_vdev_put_ref() - Wrapper to decrement ftm_time_sync ref count
46 * @vdev: vdev object
47 *
48 * Wrapper for ftm_time_sync to decrement ref count of vdev.
49 *
50 * Return: SUCCESS/FAILURE
51 */
52 static inline
ftm_time_sync_vdev_put_ref(struct wlan_objmgr_vdev * vdev)53 void ftm_time_sync_vdev_put_ref(struct wlan_objmgr_vdev *vdev)
54 {
55 return wlan_objmgr_vdev_release_ref(vdev, FTM_TIME_SYNC_ID);
56 }
57
58 /**
59 * ftm_time_sync_vdev_get_priv() - Wrapper to retrieve vdev priv obj
60 * @vdev: vdev pointer
61 *
62 * Wrapper for ftm_time_sync to get vdev private object pointer.
63 *
64 * Return: Private object of vdev
65 */
66 static inline struct ftm_time_sync_vdev_priv *
ftm_time_sync_vdev_get_priv(struct wlan_objmgr_vdev * vdev)67 ftm_time_sync_vdev_get_priv(struct wlan_objmgr_vdev *vdev)
68 {
69 struct ftm_time_sync_vdev_priv *vdev_priv;
70
71 vdev_priv = wlan_objmgr_vdev_get_comp_private_obj(
72 vdev, WLAN_UMAC_COMP_FTM_TIME_SYNC);
73 QDF_BUG(vdev_priv);
74
75 return vdev_priv;
76 }
77
78 /**
79 * ftm_time_sync_psoc_get_ref() - Wrapper to increment ftm_time sync ref count
80 * @psoc: psoc object
81 *
82 * Wrapper for ftm time sync to increment ref count after checking valid
83 * object state.
84 *
85 * Return: QDF_STATUS
86 */
87 static inline
ftm_time_sync_psoc_get_ref(struct wlan_objmgr_psoc * psoc)88 QDF_STATUS ftm_time_sync_psoc_get_ref(struct wlan_objmgr_psoc *psoc)
89 {
90 return wlan_objmgr_psoc_try_get_ref(psoc, FTM_TIME_SYNC_ID);
91 }
92
93 /**
94 * ftm_time_sync_psoc_put_ref() - Wrapper to decrement ftm time sync ref count
95 * @psoc: psoc object
96 *
97 * Wrapper for ftm time sync to decrement ref count of psoc.
98 *
99 * Return: None
100 */
101 static inline
ftm_time_sync_psoc_put_ref(struct wlan_objmgr_psoc * psoc)102 void ftm_time_sync_psoc_put_ref(struct wlan_objmgr_psoc *psoc)
103 {
104 wlan_objmgr_psoc_release_ref(psoc, FTM_TIME_SYNC_ID);
105 }
106
107 /**
108 * ftm_time_sync_psoc_get_priv() - Wrapper to retrieve psoc priv obj
109 * @psoc: psoc pointer
110 *
111 * Wrapper for ftm time sync to get psoc private object pointer.
112 *
113 * Return: ftm time sync psoc private object
114 */
115 static inline struct ftm_time_sync_psoc_priv *
ftm_time_sync_psoc_get_priv(struct wlan_objmgr_psoc * psoc)116 ftm_time_sync_psoc_get_priv(struct wlan_objmgr_psoc *psoc)
117 {
118 struct ftm_time_sync_psoc_priv *psoc_priv;
119
120 psoc_priv = wlan_objmgr_psoc_get_comp_private_obj(
121 psoc, WLAN_UMAC_COMP_FTM_TIME_SYNC);
122 QDF_BUG(psoc_priv);
123
124 return psoc_priv;
125 }
126 #endif /* _FTM_TIME_SYNC_OBJMGR_H */
127