diff --git a/components/pmo/core/inc/wlan_pmo_main.h b/components/pmo/core/inc/wlan_pmo_main.h index 9b58286a97..f9d783f527 100644 --- a/components/pmo/core/inc/wlan_pmo_main.h +++ b/components/pmo/core/inc/wlan_pmo_main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -188,16 +188,14 @@ static inline enum QDF_OPMODE pmo_core_get_vdev_op_mode( * * Return: None */ -static inline -void pmo_core_psoc_update_dp_handle(struct wlan_objmgr_psoc *psoc, - void *dp_hdl) +static inline void +pmo_core_psoc_update_dp_handle(struct wlan_objmgr_psoc *psoc, void *dp_hdl) { struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->dp_hdl = dp_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->dp_hdl = dp_hdl; + } } /** @@ -206,16 +204,14 @@ void pmo_core_psoc_update_dp_handle(struct wlan_objmgr_psoc *psoc, * * Return: psoc data path handle */ -static inline -void *pmo_core_psoc_get_dp_handle(struct wlan_objmgr_psoc *psoc) +static inline void *pmo_core_psoc_get_dp_handle(struct wlan_objmgr_psoc *psoc) { void *dp_hdl; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - dp_hdl = psoc_ctx->dp_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + dp_hdl = psoc_ctx->dp_hdl; + } return dp_hdl; } @@ -266,16 +262,14 @@ void *pmo_core_vdev_get_dp_handle(struct wlan_objmgr_vdev *vdev) * * Return: None */ -static inline -void pmo_core_psoc_update_htc_handle(struct wlan_objmgr_psoc *psoc, - void *htc_hdl) +static inline void +pmo_core_psoc_update_htc_handle(struct wlan_objmgr_psoc *psoc, void *htc_hdl) { struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->htc_hdl = htc_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->htc_hdl = htc_hdl; + } } /** @@ -284,16 +278,14 @@ void pmo_core_psoc_update_htc_handle(struct wlan_objmgr_psoc *psoc, * * Return: psoc htc layer handle */ -static inline -void *pmo_core_psoc_get_htc_handle(struct wlan_objmgr_psoc *psoc) +static inline void *pmo_core_psoc_get_htc_handle(struct wlan_objmgr_psoc *psoc) { void *htc_hdl; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - htc_hdl = psoc_ctx->htc_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + htc_hdl = psoc_ctx->htc_hdl; + } return htc_hdl; } diff --git a/components/pmo/core/inc/wlan_pmo_objmgr.h b/components/pmo/core/inc/wlan_pmo_objmgr.h index 75fa3d038d..61faaa0128 100644 --- a/components/pmo/core/inc/wlan_pmo_objmgr.h +++ b/components/pmo/core/inc/wlan_pmo_objmgr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -143,6 +143,11 @@ pmo_psoc_get_priv(struct wlan_objmgr_psoc *psoc) return psoc_priv; } +#define pmo_psoc_with_ctx(psoc, cursor) \ + for (cursor = pmo_psoc_get_priv(psoc), qdf_spin_lock_bh(&cursor->lock);\ + cursor; \ + qdf_spin_unlock_bh(&cursor->lock), cursor = NULL) + /* Tree Navigation: pdev */ static inline struct wlan_objmgr_psoc * diff --git a/components/pmo/core/inc/wlan_pmo_suspend_resume.h b/components/pmo/core/inc/wlan_pmo_suspend_resume.h index 484d82754c..ce05c7c591 100644 --- a/components/pmo/core/inc/wlan_pmo_suspend_resume.h +++ b/components/pmo/core/inc/wlan_pmo_suspend_resume.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -41,16 +41,14 @@ void pmo_core_configure_dynamic_wake_events(struct wlan_objmgr_psoc *psoc); * * Return: True if bus suspende else false */ -static inline -bool pmo_core_get_wow_bus_suspend(struct wlan_objmgr_psoc *psoc) +static inline bool pmo_core_get_wow_bus_suspend(struct wlan_objmgr_psoc *psoc) { bool value; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - value = psoc_ctx->wow.is_wow_bus_suspended; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + value = psoc_ctx->wow.is_wow_bus_suspended; + } return value; } @@ -249,16 +247,15 @@ uint32_t pmo_core_vdev_get_dtim_policy(struct wlan_objmgr_vdev *vdev) * * Return: None */ -static inline -void pmo_core_psoc_update_power_save_mode(struct wlan_objmgr_psoc *psoc, - uint8_t value) +static inline void +pmo_core_psoc_update_power_save_mode(struct wlan_objmgr_psoc *psoc, + uint8_t value) { struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->psoc_cfg.power_save_mode = value; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->psoc_cfg.power_save_mode = value; + } } /** @@ -267,16 +264,15 @@ void pmo_core_psoc_update_power_save_mode(struct wlan_objmgr_psoc *psoc, * * Return: vdev psoc power save mode value */ -static inline -uint8_t pmo_core_psoc_get_power_save_mode(struct wlan_objmgr_psoc *psoc) +static inline uint8_t +pmo_core_psoc_get_power_save_mode(struct wlan_objmgr_psoc *psoc) { uint8_t value; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - value = psoc_ctx->psoc_cfg.power_save_mode; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + value = psoc_ctx->psoc_cfg.power_save_mode; + } return value; } diff --git a/components/pmo/core/src/wlan_pmo_arp.c b/components/pmo/core/src/wlan_pmo_arp.c index 1c7b28b6f5..30f24ceb48 100644 --- a/components/pmo/core/src/wlan_pmo_arp.c +++ b/components/pmo/core/src/wlan_pmo_arp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -30,13 +30,11 @@ static QDF_STATUS pmo_core_cache_arp_in_vdev_priv( { QDF_STATUS status = QDF_STATUS_SUCCESS; struct pmo_arp_offload_params *request = NULL; - struct pmo_psoc_priv_obj *psoc_ctx; struct pmo_vdev_priv_obj *vdev_ctx; int index; struct qdf_mac_addr peer_bssid; PMO_ENTER(); - psoc_ctx = pmo_psoc_get_priv(arp_req->psoc); vdev_ctx = pmo_vdev_get_priv(vdev); @@ -44,13 +42,12 @@ static QDF_STATUS pmo_core_cache_arp_in_vdev_priv( if (!request) { pmo_err("cannot allocate arp request"); status = QDF_STATUS_E_NOMEM; - goto out; + goto exit_with_status; } - status = pmo_get_vdev_bss_peer_mac_addr(vdev, - &peer_bssid); + status = pmo_get_vdev_bss_peer_mac_addr(vdev, &peer_bssid); if (status != QDF_STATUS_SUCCESS) - goto out; + goto free_req; qdf_mem_copy(&request->bssid.bytes, &peer_bssid.bytes, QDF_MAC_ADDR_SIZE); @@ -75,9 +72,11 @@ static QDF_STATUS pmo_core_cache_arp_in_vdev_priv( request->host_ipv4_addr[2], request->host_ipv4_addr[3], request->enable); -out: - if (request) - qdf_mem_free(request); + +free_req: + qdf_mem_free(request); + +exit_with_status: PMO_EXIT(); return status; diff --git a/components/pmo/core/src/wlan_pmo_main.c b/components/pmo/core/src/wlan_pmo_main.c index c48f186001..dbec0db20a 100644 --- a/components/pmo/core/src/wlan_pmo_main.c +++ b/components/pmo/core/src/wlan_pmo_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -172,11 +172,10 @@ QDF_STATUS pmo_core_get_psoc_config(struct wlan_objmgr_psoc *psoc, goto out; } - psoc_ctx = pmo_psoc_get_priv(psoc); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + qdf_mem_copy(psoc_cfg, &psoc_ctx->psoc_cfg, sizeof(*psoc_cfg)); + } - qdf_spin_lock(&psoc_ctx->lock); - qdf_mem_copy(psoc_cfg, &psoc_ctx->psoc_cfg, sizeof(*psoc_cfg)); - qdf_spin_unlock(&psoc_ctx->lock); out: PMO_EXIT(); @@ -196,11 +195,10 @@ QDF_STATUS pmo_core_update_psoc_config(struct wlan_objmgr_psoc *psoc, goto out; } - psoc_ctx = pmo_psoc_get_priv(psoc); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + qdf_mem_copy(&psoc_ctx->psoc_cfg, psoc_cfg, sizeof(*psoc_cfg)); + } - qdf_spin_lock(&psoc_ctx->lock); - qdf_mem_copy(&psoc_ctx->psoc_cfg, psoc_cfg, sizeof(*psoc_cfg)); - qdf_spin_unlock(&psoc_ctx->lock); out: PMO_EXIT(); @@ -212,10 +210,9 @@ void pmo_core_psoc_set_hif_handle(struct wlan_objmgr_psoc *psoc, { struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->hif_hdl = hif_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->hif_hdl = hif_hdl; + } } void *pmo_core_psoc_get_hif_handle(struct wlan_objmgr_psoc *psoc) @@ -223,10 +220,9 @@ void *pmo_core_psoc_get_hif_handle(struct wlan_objmgr_psoc *psoc) void *hif_hdl; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - hif_hdl = psoc_ctx->hif_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + hif_hdl = psoc_ctx->hif_hdl; + } return hif_hdl; } @@ -236,10 +232,9 @@ void pmo_core_psoc_set_txrx_handle(struct wlan_objmgr_psoc *psoc, { struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->txrx_hdl = txrx_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->txrx_hdl = txrx_hdl; + } } void *pmo_core_psoc_get_txrx_handle(struct wlan_objmgr_psoc *psoc) @@ -247,10 +242,9 @@ void *pmo_core_psoc_get_txrx_handle(struct wlan_objmgr_psoc *psoc) void *txrx_hdl; struct pmo_psoc_priv_obj *psoc_ctx; - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - txrx_hdl = psoc_ctx->txrx_hdl; - qdf_spin_unlock_bh(&psoc_ctx->lock); + pmo_psoc_with_ctx(psoc, psoc_ctx) { + txrx_hdl = psoc_ctx->txrx_hdl; + } return txrx_hdl; } diff --git a/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c b/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c index 6ba272318c..e6e552ec74 100644 --- a/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c +++ b/components/pmo/dispatcher/src/wlan_pmo_obj_mgmt_api.c @@ -596,10 +596,11 @@ QDF_STATUS pmo_register_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc, pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->pause_bitmap_notifier = handler; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->pause_bitmap_notifier = handler; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS; @@ -626,11 +627,12 @@ QDF_STATUS pmo_unregister_pause_bitmap_notifier(struct wlan_objmgr_psoc *psoc, pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - if (psoc_ctx->pause_bitmap_notifier == handler) - psoc_ctx->pause_bitmap_notifier = NULL; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + if (psoc_ctx->pause_bitmap_notifier == handler) + psoc_ctx->pause_bitmap_notifier = NULL; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS; @@ -657,10 +659,11 @@ QDF_STATUS pmo_register_get_pause_bitmap(struct wlan_objmgr_psoc *psoc, pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->get_pause_bitmap = handler; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->get_pause_bitmap = handler; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS; @@ -687,11 +690,12 @@ QDF_STATUS pmo_unregister_get_pause_bitmap(struct wlan_objmgr_psoc *psoc, pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - if (psoc_ctx->get_pause_bitmap == handler) - psoc_ctx->get_pause_bitmap = NULL; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + if (psoc_ctx->get_pause_bitmap == handler) + psoc_ctx->get_pause_bitmap = NULL; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS; @@ -718,10 +722,11 @@ QDF_STATUS pmo_register_is_device_in_low_pwr_mode(struct wlan_objmgr_psoc *psoc, pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->is_device_in_low_pwr_mode = handler; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->is_device_in_low_pwr_mode = handler; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS; @@ -749,10 +754,11 @@ QDF_STATUS pmo_unregister_is_device_in_low_pwr_mode( pmo_err("pmo cannot get the reference out of psoc"); return status; } - psoc_ctx = pmo_psoc_get_priv(psoc); - qdf_spin_lock_bh(&psoc_ctx->lock); - psoc_ctx->is_device_in_low_pwr_mode = NULL; - qdf_spin_unlock_bh(&psoc_ctx->lock); + + pmo_psoc_with_ctx(psoc, psoc_ctx) { + psoc_ctx->is_device_in_low_pwr_mode = NULL; + } + pmo_psoc_put_ref(psoc); return QDF_STATUS_SUCCESS;