wifi_pos_utils.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: wifi_pos_utils.c
  20. * This file defines the utility helper functions for wifi_pos component.
  21. */
  22. #include "qdf_types.h"
  23. #include "wlan_objmgr_cmn.h"
  24. #include "wlan_objmgr_global_obj.h"
  25. #include "wlan_objmgr_psoc_obj.h"
  26. #include "wifi_pos_utils_i.h"
  27. /*
  28. * WIFI pos command are not associated with any pdev/psoc/vdev, so the callback
  29. * registered with GENL socket does not receive any pdev/pdev/vdev object.
  30. * Since PSOC is top most object, it was decided to keep WIFI POS private obj
  31. * within PSOC and hence, this module need to hang on to the first PSOC that
  32. * was created for all its internal usage.
  33. */
  34. static struct wlan_objmgr_psoc *wifi_pos_psoc_obj;
  35. struct wlan_objmgr_psoc *wifi_pos_get_psoc(void)
  36. {
  37. return wifi_pos_psoc_obj;
  38. }
  39. void wifi_pos_set_psoc(struct wlan_objmgr_psoc *psoc)
  40. {
  41. if (wifi_pos_psoc_obj)
  42. wifi_pos_warn("global psoc obj already set");
  43. else
  44. wifi_pos_psoc_obj = psoc;
  45. }
  46. void wifi_pos_clear_psoc(void)
  47. {
  48. if (!wifi_pos_psoc_obj)
  49. wifi_pos_warn("global psoc obj already cleared");
  50. else
  51. wifi_pos_psoc_obj = NULL;
  52. }
  53. /**
  54. * wifi_pos_get_psoc_priv_obj: returns wifi_pos priv object within psoc
  55. * @psoc: pointer to psoc object
  56. *
  57. * Return: wifi_pos_psoc_priv_obj
  58. */
  59. struct wifi_pos_psoc_priv_obj *wifi_pos_get_psoc_priv_obj(
  60. struct wlan_objmgr_psoc *psoc)
  61. {
  62. struct wifi_pos_psoc_priv_obj *obj;
  63. obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
  64. WLAN_UMAC_COMP_WIFI_POS);
  65. return obj;
  66. }