From d7c3737cd5b17fe8dfe81b34f35d122e901b2ca4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 2 Aug 2021 14:27:18 -0500 Subject: [PATCH] Remove wrappers for atomic operations These wrappers were useful when this driver had the hooks for Windows, but are no longer needed. Link: https://lore.kernel.org/r/20210802192721.23110-4-Larry.Finger@lwfinger.net --- core/mesh/rtw_mesh.c | 2 +- core/mesh/rtw_mesh.h | 2 +- core/mesh/rtw_mesh_pathtbl.c | 8 +- core/mesh/rtw_mesh_pathtbl.h | 2 +- core/rtw_ap.c | 26 ++-- core/rtw_cmd.c | 22 ++-- core/rtw_debug.c | 4 +- core/rtw_io.c | 4 +- core/rtw_mlme.c | 6 +- core/rtw_mlme_ext.c | 42 +++---- core/rtw_p2p.c | 8 +- core/rtw_recv.c | 8 +- core/rtw_rm.c | 2 +- core/rtw_rm_fsm.c | 14 +-- core/rtw_sdio.c | 8 +- core/rtw_tdls.c | 14 +-- hal/hal_com.c | 16 +-- hal/hal_dm_acs.h | 12 +- hal/rtl8192e/rtl8192e_phycfg.c | 2 +- hal/rtl8192e/usb/usb_ops_linux.c | 2 +- include/drv_types.h | 39 +++--- include/osdep_service.h | 12 -- include/osdep_service_bsd.h | 3 - include/osdep_service_ce.h | 96 +++++++------- include/osdep_service_linux.h | 2 +- include/osdep_service_xp.h | 94 +++++++------- include/rtw_cmd.h | 4 +- include/rtw_mlme.h | 16 +-- include/rtw_mlme_ext.h | 2 +- include/rtw_pwrctrl.h | 6 +- include/rtw_recv.h | 2 +- include/rtw_rm.h | 2 +- include/sta_info.h | 2 +- os_dep/linux/ioctl_cfg80211.c | 10 +- os_dep/linux/ioctl_cfg80211.h | 2 +- os_dep/linux/ioctl_linux.c | 4 +- os_dep/linux/os_intfs.c | 4 +- os_dep/linux/usb_intf.c | 4 +- os_dep/linux/usb_ops_linux.c | 8 +- os_dep/osdep_service.c | 207 +++++-------------------------- 40 files changed, 284 insertions(+), 439 deletions(-) diff --git a/core/mesh/rtw_mesh.c b/core/mesh/rtw_mesh.c index 95d0f15..c0099d8 100644 --- a/core/mesh/rtw_mesh.c +++ b/core/mesh/rtw_mesh.c @@ -3087,7 +3087,7 @@ void rtw_mesh_init_mesh_info(_adapter *adapter) /* minfo->last_sn_update = rtw_get_current_time(); */ minfo->next_perr = rtw_get_current_time(); - ATOMIC_SET(&minfo->mpaths, 0); + atomic_set(&minfo->mpaths, 0); rtw_mesh_pathtbl_init(adapter); _rtw_init_queue(&minfo->mpath_tx_queue); diff --git a/core/mesh/rtw_mesh.h b/core/mesh/rtw_mesh.h index 73694f8..63d66d8 100644 --- a/core/mesh/rtw_mesh.h +++ b/core/mesh/rtw_mesh.h @@ -377,7 +377,7 @@ struct rtw_mesh_info { /* Last used Path Discovery ID */ u32 preq_id; - ATOMIC_T mpaths; + atomic_t mpaths; struct rtw_mesh_table *mesh_paths; struct rtw_mesh_table *mpp_paths; int mesh_paths_generation; diff --git a/core/mesh/rtw_mesh_pathtbl.c b/core/mesh/rtw_mesh_pathtbl.c index 5e778f6..49c3af4 100644 --- a/core/mesh/rtw_mesh_pathtbl.c +++ b/core/mesh/rtw_mesh_pathtbl.c @@ -82,7 +82,7 @@ static struct rtw_mesh_table *rtw_mesh_table_alloc(void) return NULL; rtw_hlist_head_init(&newtbl->known_gates); - ATOMIC_SET(&newtbl->entries, 0); + atomic_set(&newtbl->entries, 0); _rtw_spinlock_init(&newtbl->gates_lock); return newtbl; @@ -584,7 +584,7 @@ struct rtw_mesh_path *rtw_mesh_path_add(_adapter *adapter, if (is_multicast_mac_addr(dst)) return ERR_PTR(-ENOTSUPP); - if (ATOMIC_INC_UNLESS(&adapter->mesh_info.mpaths, RTW_MESH_MAX_MPATHS) == 0) + if (atomic_inc_unless(&adapter->mesh_info.mpaths, RTW_MESH_MAX_MPATHS) == 0) return ERR_PTR(-ENOSPC); new_mpath = rtw_mesh_path_new(adapter, dst); @@ -739,8 +739,8 @@ static void rtw_mesh_path_free_rcu(struct rtw_mesh_table *tbl, rtw_mesh_gate_del(tbl, mpath); exit_critical_bh(&mpath->state_lock); _cancel_timer_ex(&mpath->timer); - ATOMIC_DEC(&adapter->mesh_info.mpaths); - ATOMIC_DEC(&tbl->entries); + atomic_dec(&adapter->mesh_info.mpaths); + atomic_dec(&tbl->entries); _rtw_spinlock_free(&mpath->state_lock); rtw_mesh_path_flush_pending(mpath); diff --git a/core/mesh/rtw_mesh_pathtbl.h b/core/mesh/rtw_mesh_pathtbl.h index 7f5a26b..1893170 100644 --- a/core/mesh/rtw_mesh_pathtbl.h +++ b/core/mesh/rtw_mesh_pathtbl.h @@ -140,7 +140,7 @@ struct rtw_mesh_table { rtw_hlist_head known_gates; _lock gates_lock; rtw_rhashtable rhead; - ATOMIC_T entries; + atomic_t entries; }; #define RTW_MESH_PATH_EXPIRE (600 * HZ) diff --git a/core/rtw_ap.c b/core/rtw_ap.c index c041a44..34a86fd 100644 --- a/core/rtw_ap.c +++ b/core/rtw_ap.c @@ -1510,11 +1510,11 @@ static void rtw_ap_check_scan(_adapter *padapter) if (pbuf == NULL) { /* HT CAP INFO IE don't exist, it is b/g mode bss.*/ - if (_FALSE == ATOMIC_READ(&pmlmepriv->olbc)) - ATOMIC_SET(&pmlmepriv->olbc, _TRUE); + if (_FALSE == atomic_read(&pmlmepriv->olbc)) + atomic_set(&pmlmepriv->olbc, _TRUE); - if (_FALSE == ATOMIC_READ(&pmlmepriv->olbc_ht)) - ATOMIC_SET(&pmlmepriv->olbc_ht, _TRUE); + if (_FALSE == atomic_read(&pmlmepriv->olbc_ht)) + atomic_set(&pmlmepriv->olbc_ht, _TRUE); if (padapter->registrypriv.wifi_spec) RTW_INFO("%s: %s is a/b/g ap\n", __func__, pnetwork->network.Ssid.Ssid); @@ -1811,7 +1811,7 @@ update_beacon: mlme = &(pdvobj->padapters[i]->mlmepriv); #ifdef CONFIG_80211N_HT - if ((ATOMIC_READ(&mlme->olbc) == _TRUE) || (ATOMIC_READ(&mlme->olbc_ht) == _TRUE)) { + if ((atomic_read(&mlme->olbc) == _TRUE) || (atomic_read(&mlme->olbc_ht) == _TRUE)) { /* AP is not starting a 40 MHz BSS in presence of an 802.11g BSS. */ mlme->ht_op_mode &= (~HT_INFO_OPERATION_MODE_OP_MODE_MASK); mlme->ht_op_mode |= OP_MODE_MAY_BE_LEGACY_STAS; @@ -3086,7 +3086,7 @@ static void update_bcn_htinfo_ie(_adapter *padapter) __FUNCTION__, pmlmepriv->ht_op_mode); RTW_INFO("num_sta_40mhz_intolerant(%d), 20mhz_width_req(%d), intolerant_ch_rpt(%d), olbc(%d)\n", - pmlmepriv->num_sta_40mhz_intolerant, pmlmepriv->ht_20mhz_width_req, pmlmepriv->ht_intolerant_ch_reported, ATOMIC_READ(&pmlmepriv->olbc)); + pmlmepriv->num_sta_40mhz_intolerant, pmlmepriv->ht_20mhz_width_req, pmlmepriv->ht_intolerant_ch_reported, atomic_read(&pmlmepriv->olbc)); /*parsing HT_INFO_IE, currently only update ht_op_mode - pht_info->infos[1] & pht_info->infos[2] for wifi logo test*/ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); @@ -3098,7 +3098,7 @@ static void update_bcn_htinfo_ie(_adapter *padapter) /* for STA Channel Width/Secondary Channel Offset*/ if ((pmlmepriv->sw_to_20mhz == 0) && (pmlmeext->cur_channel <= 14)) { if ((pmlmepriv->num_sta_40mhz_intolerant > 0) || (pmlmepriv->ht_20mhz_width_req == _TRUE) - || (pmlmepriv->ht_intolerant_ch_reported == _TRUE) || (ATOMIC_READ(&pmlmepriv->olbc) == _TRUE)) { + || (pmlmepriv->ht_intolerant_ch_reported == _TRUE) || (atomic_read(&pmlmepriv->olbc) == _TRUE)) { SET_HT_OP_ELE_2ND_CHL_OFFSET(pht_info, 0); SET_HT_OP_ELE_STA_CHL_WIDTH(pht_info, 0); @@ -3115,7 +3115,7 @@ static void update_bcn_htinfo_ie(_adapter *padapter) } else { if ((pmlmepriv->num_sta_40mhz_intolerant == 0) && (pmlmepriv->ht_20mhz_width_req == _FALSE) - && (pmlmepriv->ht_intolerant_ch_reported == _FALSE) && (ATOMIC_READ(&pmlmepriv->olbc) == _FALSE)) { + && (pmlmepriv->ht_intolerant_ch_reported == _FALSE) && (atomic_read(&pmlmepriv->olbc) == _FALSE)) { if (pmlmeext->cur_bwmode >= CHANNEL_WIDTH_40) { @@ -3467,12 +3467,12 @@ int rtw_ht_operation_update(_adapter *padapter) } if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && - (pmlmepriv->num_sta_no_ht || ATOMIC_READ(&pmlmepriv->olbc_ht))) { + (pmlmepriv->num_sta_no_ht || atomic_read(&pmlmepriv->olbc_ht))) { pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; op_mode_changes++; } else if ((pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && - (pmlmepriv->num_sta_no_ht == 0 && !ATOMIC_READ(&pmlmepriv->olbc_ht))) { + (pmlmepriv->num_sta_no_ht == 0 && !atomic_read(&pmlmepriv->olbc_ht))) { pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; op_mode_changes++; @@ -3489,7 +3489,7 @@ int rtw_ht_operation_update(_adapter *padapter) else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH) && pmlmepriv->num_sta_ht_20mhz) new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; - else if (ATOMIC_READ(&pmlmepriv->olbc_ht)) + else if (atomic_read(&pmlmepriv->olbc_ht)) new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; else new_op_mode = OP_MODE_PURE; @@ -4148,8 +4148,8 @@ void start_ap_mode(_adapter *padapter) pmlmepriv->num_sta_ht_20mhz = 0; pmlmepriv->num_sta_40mhz_intolerant = 0; - ATOMIC_SET(&pmlmepriv->olbc, _FALSE); - ATOMIC_SET(&pmlmepriv->olbc_ht, _FALSE); + atomic_set(&pmlmepriv->olbc, _FALSE); + atomic_set(&pmlmepriv->olbc_ht, _FALSE); #ifdef CONFIG_80211N_HT pmlmepriv->ht_20mhz_width_req = _FALSE; diff --git a/core/rtw_cmd.c b/core/rtw_cmd.c index 6497716..03bcedb 100644 --- a/core/rtw_cmd.c +++ b/core/rtw_cmd.c @@ -139,7 +139,7 @@ sint _rtw_init_evt_priv(struct evt_priv *pevtpriv) #endif /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - ATOMIC_SET(&pevtpriv->event_seq, 0); + atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; #ifdef CONFIG_EVENT_THREAD_MODE @@ -424,11 +424,11 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) bAllow = _TRUE; if ((!rtw_is_hw_init_completed(pcmdpriv->padapter) && (bAllow == _FALSE)) - || ATOMIC_READ(&(pcmdpriv->cmdthd_running)) == _FALSE /* com_thread not running */ + || atomic_read(&(pcmdpriv->cmdthd_running)) == _FALSE /* com_thread not running */ ) { if (DBG_CMD_EXECUTE) RTW_INFO(ADPT_FMT" drop "CMD_FMT" hw_init_completed:%u, cmdthd_running:%u\n", ADPT_ARG(cmd_obj->padapter) - , CMD_ARG(cmd_obj), rtw_get_hw_init_completed(cmd_obj->padapter), ATOMIC_READ(&pcmdpriv->cmdthd_running)); + , CMD_ARG(cmd_obj), rtw_get_hw_init_completed(cmd_obj->padapter), atomic_read(&pcmdpriv->cmdthd_running)); if (0) rtw_warn_on(1); @@ -545,7 +545,7 @@ thread_return rtw_cmd_thread(thread_context context) pcmdbuf = pcmdpriv->cmd_buf; prspbuf = pcmdpriv->rsp_buf; - ATOMIC_SET(&(pcmdpriv->cmdthd_running), _TRUE); + atomic_set(&(pcmdpriv->cmdthd_running), _TRUE); _rtw_up_sema(&pcmdpriv->start_cmdthread_sema); @@ -702,7 +702,7 @@ post_process: #endif /* to avoid enqueue cmd after free all cmd_obj */ - ATOMIC_SET(&(pcmdpriv->cmdthd_running), _FALSE); + atomic_set(&(pcmdpriv->cmdthd_running), _FALSE); /* free all cmd_obj resources */ do { @@ -3243,8 +3243,8 @@ static void dynamic_update_bcn_check(_adapter *padapter) if (count % 10 == 0) { count = 1; #ifdef CONFIG_80211N_HT - if (_FALSE == ATOMIC_READ(&pmlmepriv->olbc) - && _FALSE == ATOMIC_READ(&pmlmepriv->olbc_ht)) { + if (_FALSE == atomic_read(&pmlmepriv->olbc) + && _FALSE == atomic_read(&pmlmepriv->olbc_ht)) { if (rtw_ht_operation_update(padapter) > 0) { update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, _FALSE); @@ -3257,16 +3257,16 @@ static void dynamic_update_bcn_check(_adapter *padapter) #ifdef CONFIG_80211N_HT /* In 2s, there are any legacy AP, update HT info, and then reset count */ - if (_FALSE != ATOMIC_READ(&pmlmepriv->olbc) - && _FALSE != ATOMIC_READ(&pmlmepriv->olbc_ht)) { + if (_FALSE != atomic_read(&pmlmepriv->olbc) + && _FALSE != atomic_read(&pmlmepriv->olbc_ht)) { if (rtw_ht_operation_update(padapter) > 0) { update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, _FALSE); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, _TRUE); } - ATOMIC_SET(&pmlmepriv->olbc, _FALSE); - ATOMIC_SET(&pmlmepriv->olbc_ht, _FALSE); + atomic_set(&pmlmepriv->olbc, _FALSE); + atomic_set(&pmlmepriv->olbc_ht, _FALSE); count = 0; } #endif /* CONFIG_80211N_HT */ diff --git a/core/rtw_debug.c b/core/rtw_debug.c index 6ad11a9..31e5de9 100644 --- a/core/rtw_debug.c +++ b/core/rtw_debug.c @@ -1718,7 +1718,7 @@ int proc_get_trx_info(struct seq_file *m, void *v) rtw_hal_get_hwreg(padapter, HW_VAR_DUMP_MAC_TXFIFO, (u8 *)m); #ifdef CONFIG_USB_HCI - RTW_PRINT_SEL(m, "rx_urb_pending_cn=%d\n", ATOMIC_READ(&(precvpriv->rx_pending_cnt))); + RTW_PRINT_SEL(m, "rx_urb_pending_cn=%d\n", atomic_read(&(precvpriv->rx_pending_cnt))); #endif dump_rx_bh_tk(m, &GET_PRIMARY_ADAPTER(padapter)->recvpriv); @@ -5132,7 +5132,7 @@ static int proc_tdls_display_tdls_function_info(struct seq_file *m) } } - RTW_PRINT_SEL(m, "%-*s = %s\n", SpaceBtwnItemAndValue, "TDLS CH SW On", (ATOMIC_READ(&ptdlsinfo->chsw_info.chsw_on) == _TRUE) ? "_TRUE" : "_FALSE"); + RTW_PRINT_SEL(m, "%-*s = %s\n", SpaceBtwnItemAndValue, "TDLS CH SW On", (atomic_read(&ptdlsinfo->chsw_info.chsw_on) == _TRUE) ? "_TRUE" : "_FALSE"); RTW_PRINT_SEL(m, "%-*s = %d\n", SpaceBtwnItemAndValue, "TDLS CH SW Off-Channel Num", ptdlsinfo->chsw_info.off_ch_num); RTW_PRINT_SEL(m, "%-*s = %d\n", SpaceBtwnItemAndValue, "TDLS CH SW Channel Offset", ptdlsinfo->chsw_info.ch_offset); RTW_PRINT_SEL(m, "%-*s = %d\n", SpaceBtwnItemAndValue, "TDLS CH SW Current Time", ptdlsinfo->chsw_info.cur_time); diff --git a/core/rtw_io.c b/core/rtw_io.c index 159894a..dc033a2 100644 --- a/core/rtw_io.c +++ b/core/rtw_io.c @@ -469,7 +469,7 @@ int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj) int ret = _FALSE; int value; - value = ATOMIC_INC_RETURN(&dvobj->continual_io_error); + value = atomic_inc_return(&dvobj->continual_io_error); if (value > MAX_CONTINUAL_IO_ERR) { RTW_INFO("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR); ret = _TRUE; @@ -484,7 +484,7 @@ int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj) */ void rtw_reset_continual_io_error(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->continual_io_error, 0); + atomic_set(&dvobj->continual_io_error, 0); } #ifdef DBG_IO diff --git a/core/rtw_mlme.c b/core/rtw_mlme.c index 9bf66f2..3922ff5 100644 --- a/core/rtw_mlme.c +++ b/core/rtw_mlme.c @@ -3527,13 +3527,13 @@ exit: inline bool rtw_is_scan_deny(_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; - return (ATOMIC_READ(&mlmepriv->set_scan_deny) != 0) ? _TRUE : _FALSE; + return (atomic_read(&mlmepriv->set_scan_deny) != 0) ? _TRUE : _FALSE; } inline void rtw_clear_scan_deny(_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; - ATOMIC_SET(&mlmepriv->set_scan_deny, 0); + atomic_set(&mlmepriv->set_scan_deny, 0); if (0) RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); } @@ -3549,7 +3549,7 @@ void rtw_set_scan_deny(_adapter *adapter, u32 ms) struct mlme_priv *mlmepriv = &adapter->mlmepriv; if (0) RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); - ATOMIC_SET(&mlmepriv->set_scan_deny, 1); + atomic_set(&mlmepriv->set_scan_deny, 1); _set_timer(&mlmepriv->set_scan_deny_timer, ms); } #endif diff --git a/core/rtw_mlme_ext.c b/core/rtw_mlme_ext.c index 1846ee5..33c2f43 100644 --- a/core/rtw_mlme_ext.c +++ b/core/rtw_mlme_ext.c @@ -935,25 +935,25 @@ bool rtw_mlme_band_check(_adapter *adapter, const u32 ch) } inline void RTW_SET_SCAN_BAND_SKIP(_adapter *padapter, int skip_band) { - int bs = ATOMIC_READ(&padapter->bandskip); + int bs = atomic_read(&padapter->bandskip); bs |= skip_band; - ATOMIC_SET(&padapter->bandskip, bs); + atomic_set(&padapter->bandskip, bs); } inline void RTW_CLR_SCAN_BAND_SKIP(_adapter *padapter, int skip_band) { - int bs = ATOMIC_READ(&padapter->bandskip); + int bs = atomic_read(&padapter->bandskip); bs &= ~(skip_band); - ATOMIC_SET(&padapter->bandskip, bs); + atomic_set(&padapter->bandskip, bs); } inline int RTW_GET_SCAN_BAND_SKIP(_adapter *padapter) { - return ATOMIC_READ(&padapter->bandskip); + return atomic_read(&padapter->bandskip); } -#define RTW_IS_SCAN_BAND_SKIP(padapter, skip_band) (ATOMIC_READ(&padapter->bandskip) & (skip_band)) +#define RTW_IS_SCAN_BAND_SKIP(padapter, skip_band) (atomic_read(&padapter->bandskip) & (skip_band)) bool rtw_mlme_ignore_chan(_adapter *adapter, const u32 ch) { @@ -1037,7 +1037,7 @@ static void init_mlme_ext_priv_value(_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - ATOMIC_SET(&pmlmeext->event_seq, 0); + atomic_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ #ifdef CONFIG_IEEE80211W pmlmeext->sa_query_seq = 0; @@ -1805,8 +1805,8 @@ static void rtw_check_legacy_ap(_adapter *padapter, u8 *pframe, u32 len) if (0) RTW_INFO("%s: "MAC_FMT" is legacy ap\n", __func__, MAC_ARG(GetAddr3Ptr(pframe))); - ATOMIC_SET(&pmlmepriv->olbc, _TRUE); - ATOMIC_SET(&pmlmepriv->olbc_ht, _TRUE); + atomic_set(&pmlmepriv->olbc, _TRUE); + atomic_set(&pmlmepriv->olbc_ht, _TRUE); } } @@ -1949,7 +1949,7 @@ unsigned int OnBeacon(_adapter *padapter, union recv_frame *precv_frame) #ifdef CONFIG_TDLS_CH_SW if (rtw_tdls_is_chsw_allowed(padapter) == _TRUE) { /* Send TDLS Channel Switch Request when receiving Beacon */ - if ((padapter->tdlsinfo.chsw_info.ch_sw_state & TDLS_CH_SW_INITIATOR_STATE) && (ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) + if ((padapter->tdlsinfo.chsw_info.ch_sw_state & TDLS_CH_SW_INITIATOR_STATE) && (atomic_read(&pchsw_info->chsw_on) == _TRUE) && (pmlmeext->cur_channel == rtw_get_oper_ch(padapter))) { ptdls_sta = rtw_get_stainfo(&padapter->stapriv, padapter->tdlsinfo.chsw_info.addr); if (ptdls_sta != NULL) { @@ -11765,7 +11765,7 @@ void report_survey_event(_adapter *padapter, union recv_frame *precv_frame) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct survey_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); @@ -11836,7 +11836,7 @@ void report_surveydone_event(_adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct surveydone_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; @@ -11884,7 +11884,7 @@ u32 report_join_res(_adapter *padapter, int aid_res, u16 status) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct joinbss_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); _rtw_memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(WLAN_BSSID_EX)); @@ -11935,7 +11935,7 @@ void report_wmm_edca_update(_adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct wmm_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_WMM); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pwmm_event = (struct wmm_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); pwmm_event->wmm = 0; @@ -11970,7 +11970,7 @@ u32 report_del_sta_event(_adapter *padapter, unsigned char *MacAddr, unsigned sh pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); _rtw_memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -12047,7 +12047,7 @@ void report_add_sta_event(_adapter *padapter, unsigned char *MacAddr) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); _rtw_memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -12842,7 +12842,7 @@ void linked_status_chk(_adapter *padapter, u8 from_timer) #ifdef CONFIG_TDLS #ifdef CONFIG_TDLS_CH_SW - if (ATOMIC_READ(&padapter->tdlsinfo.chsw_info.chsw_on) == _TRUE) + if (atomic_read(&padapter->tdlsinfo.chsw_info.chsw_on) == _TRUE) return; #endif /* CONFIG_TDLS_CH_SW */ @@ -13202,7 +13202,7 @@ void report_sta_timeout_event(_adapter *padapter, u8 *MacAddr, unsigned short re pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_TimeoutSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); _rtw_memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -13602,7 +13602,7 @@ void rtw_ft_report_reassoc_evt(_adapter *padapter, u8 *pMacAddr) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_FT_REASSOC); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); passoc_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); _rtw_memcpy((unsigned char *)(&(passoc_sta_evt->macaddr)), pMacAddr, ETH_ALEN); @@ -15815,7 +15815,7 @@ u8 mlme_evt_hdl(_adapter *padapter, unsigned char *pbuf) #ifdef CHECK_EVENT_SEQ /* checking event sequence... */ - if (evt_seq != (ATOMIC_READ(&pevt_priv->event_seq) & 0x7f)) { + if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) { pevt_priv->event_seq = (evt_seq + 1) & 0x7f; @@ -15836,7 +15836,7 @@ u8 mlme_evt_hdl(_adapter *padapter, unsigned char *pbuf) } - ATOMIC_INC(&pevt_priv->event_seq); + atomic_inc(&pevt_priv->event_seq); peventbuf += 2; diff --git a/core/rtw_p2p.c b/core/rtw_p2p.c index f66fa71..4f8bf5c 100644 --- a/core/rtw_p2p.c +++ b/core/rtw_p2p.c @@ -3363,14 +3363,14 @@ static int ro_ch_handler(_adapter *adapter, u8 *buf) if ((remain_ch != rtw_mi_get_union_chan(adapter)) && !check_fwstate(&adapter->mlmepriv, _FW_LINKED)) { if (remain_ch != pmlmeext->cur_channel #ifdef RTW_ROCH_BACK_OP - || ATOMIC_READ(&pwdev_priv->switch_ch_to) == 1 + || atomic_read(&pwdev_priv->switch_ch_to) == 1 #endif ) { rtw_leave_opch(adapter); #ifdef RTW_ROCH_BACK_OP RTW_INFO("%s, set switch ch timer, duration=%d\n", __func__, duration - pwdinfo->ext_listen_interval); - ATOMIC_SET(&pwdev_priv->switch_ch_to, 0); + atomic_set(&pwdev_priv->switch_ch_to, 0); _set_timer(&pwdinfo->ap_p2p_switch_timer, duration - pwdinfo->ext_listen_interval); #endif } @@ -3442,7 +3442,7 @@ static int cancel_ro_ch_handler(_adapter *padapter, u8 *buf) #if defined(RTW_ROCH_BACK_OP) && defined(CONFIG_CONCURRENT_MODE) _cancel_timer_ex(&pwdinfo->ap_p2p_switch_timer); - ATOMIC_SET(&pwdev_priv->switch_ch_to, 1); + atomic_set(&pwdev_priv->switch_ch_to, 1); #endif if (rtw_mi_get_ch_setting_union(padapter, &ch, &bw, &offset) != 0) { @@ -4779,7 +4779,7 @@ void ap_p2p_switch_timer_process(void *FunctionContext) return; #ifdef CONFIG_IOCTL_CFG80211 - ATOMIC_SET(&pwdev_priv->switch_ch_to, 1); + atomic_set(&pwdev_priv->switch_ch_to, 1); #endif p2p_protocol_wk_cmd(adapter, P2P_AP_P2P_CH_SWITCH_PROCESS_WK); diff --git a/core/rtw_recv.c b/core/rtw_recv.c index 4b6f152..24d6b5d 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -141,7 +141,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, _adapter *padapter) #ifdef CONFIG_USB_HCI - ATOMIC_SET(&(precvpriv->rx_pending_cnt), 1); + atomic_set(&(precvpriv->rx_pending_cnt), 1); _rtw_init_sema(&precvpriv->allrxreturnevt, 0); @@ -1254,7 +1254,7 @@ sint sta2sta_data_frame( } #ifdef CONFIG_TDLS_CH_SW - if (ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) { + if (atomic_read(&pchsw_info->chsw_on) == _TRUE) { if (adapter->mlmeextpriv.cur_channel != rtw_get_oper_ch(adapter)) { pchsw_info->ch_sw_state |= TDLS_PEER_AT_OFF_STATE; if (!(pchsw_info->ch_sw_state & TDLS_CH_SW_INITIATOR_STATE)) @@ -4905,7 +4905,7 @@ int rtw_inc_and_chk_continual_no_rx_packet(struct sta_info *sta, int tid_index) { int ret = _FALSE; - int value = ATOMIC_INC_RETURN(&sta->continual_no_rx_packet[tid_index]); + int value = atomic_inc_return(&sta->continual_no_rx_packet[tid_index]); if (value >= MAX_CONTINUAL_NORXPACKET_COUNT) ret = _TRUE; @@ -4918,7 +4918,7 @@ int rtw_inc_and_chk_continual_no_rx_packet(struct sta_info *sta, int tid_index) */ void rtw_reset_continual_no_rx_packet(struct sta_info *sta, int tid_index) { - ATOMIC_SET(&sta->continual_no_rx_packet[tid_index], 0); + atomic_set(&sta->continual_no_rx_packet[tid_index], 0); } u8 adapter_allow_bmc_data_rx(_adapter *adapter) diff --git a/core/rtw_rm.c b/core/rtw_rm.c index 6576597..d4c8019 100644 --- a/core/rtw_rm.c +++ b/core/rtw_rm.c @@ -2374,7 +2374,7 @@ static void rm_dbg_show_meas(struct rm_obj *prm, char *s) psta->cmn.aid, MAC_ARG(psta->cmn.mac_addr)); sprintf(pstr(s), "clock=%d, state=%s, rpt=%u/%u\n", - (int)ATOMIC_READ(&prm->pclock->counter), + (int)atomic_read(&prm->pclock->counter), rm_state_name(prm->state), prm->p.rpt, prm->q.rpt); } diff --git a/core/rtw_rm_fsm.c b/core/rtw_rm_fsm.c index 21fb323..44c08b9 100644 --- a/core/rtw_rm_fsm.c +++ b/core/rtw_rm_fsm.c @@ -42,12 +42,12 @@ void rm_timer_callback(void *data) for (i=0;iclock[i]; if (pclock->prm == NULL - ||(ATOMIC_READ(&(pclock->counter)) == 0)) + ||(atomic_read(&(pclock->counter)) == 0)) continue; - ATOMIC_DEC(&(pclock->counter)); + atomic_dec(&(pclock->counter)); - if (ATOMIC_READ(&(pclock->counter)) == 0) + if (atomic_read(&(pclock->counter)) == 0) rm_post_event(pclock->prm->psta->padapter, pclock->prm->rmid, prmpriv->clock[i].evid); } @@ -176,7 +176,7 @@ static int rm_enqueue_ev(_queue *queue, struct rm_event *obj, bool to_head) static void rm_set_clock(struct rm_obj *prm, u32 ms, enum RM_EV_ID evid) { - ATOMIC_SET(&(prm->pclock->counter), (ms/CLOCK_UNIT)); + atomic_set(&(prm->pclock->counter), (ms/CLOCK_UNIT)); prm->pclock->evid = evid; } @@ -192,7 +192,7 @@ static struct rm_clock *rm_alloc_clock(_adapter *padapter, struct rm_obj *prm) if (pclock->prm == NULL) { pclock->prm = prm; - ATOMIC_SET(&(pclock->counter), 0); + atomic_set(&(pclock->counter), 0); pclock->evid = RM_EV_max; break; } @@ -202,14 +202,14 @@ static struct rm_clock *rm_alloc_clock(_adapter *padapter, struct rm_obj *prm) static void rm_cancel_clock(struct rm_obj *prm) { - ATOMIC_SET(&(prm->pclock->counter), 0); + atomic_set(&(prm->pclock->counter), 0); prm->pclock->evid = RM_EV_max; } static void rm_free_clock(struct rm_clock *pclock) { pclock->prm = NULL; - ATOMIC_SET(&(pclock->counter), 0); + atomic_set(&(pclock->counter), 0); pclock->evid = RM_EV_max; } diff --git a/core/rtw_sdio.c b/core/rtw_sdio.c index e8f49bf..588f7c9 100644 --- a/core/rtw_sdio.c +++ b/core/rtw_sdio.c @@ -60,7 +60,7 @@ static u8 sdio_io(struct dvobj_priv *d, u32 addr, void *buf, size_t len, u8 writ if (retry) { RTW_INFO("%s: Retry %s OK! addr=0x%05x %zu bytes, retry=%u,%u\n", __FUNCTION__, write?"write":"read", - addr, len, retry, ATOMIC_READ(&d->continual_io_error)); + addr, len, retry, atomic_read(&d->continual_io_error)); RTW_INFO_DUMP("Data: ", buf, len); } rtw_reset_continual_io_error(d); @@ -68,14 +68,14 @@ static u8 sdio_io(struct dvobj_priv *d, u32 addr, void *buf, size_t len, u8 writ } RTW_ERR("%s: %s FAIL! error(%d) addr=0x%05x %zu bytes, retry=%u,%u\n", __FUNCTION__, write?"write":"read", err, addr, len, - retry, ATOMIC_READ(&d->continual_io_error)); + retry, atomic_read(&d->continual_io_error)); retry++; stop_retry = rtw_inc_and_chk_continual_io_error(d); if ((err == -1) || (stop_retry == _TRUE) || (retry > SD_IO_TRY_CNT)) { /* critical error, unrecoverable */ RTW_ERR("%s: Fatal error! Set surprise remove flag ON! (retry=%u,%u)\n", - __FUNCTION__, retry, ATOMIC_READ(&d->continual_io_error)); + __FUNCTION__, retry, atomic_read(&d->continual_io_error)); rtw_set_surprise_removed(dvobj_get_primary_adapter(d)); return _FAIL; } @@ -84,7 +84,7 @@ static u8 sdio_io(struct dvobj_priv *d, u32 addr, void *buf, size_t len, u8 writ if ((addr & 0x10000) || !(addr & 0xE000)) { RTW_WARN("%s: Retry %s addr=0x%05x %zu bytes, retry=%u,%u\n", __FUNCTION__, write?"write":"read", addr, len, - retry, ATOMIC_READ(&d->continual_io_error)); + retry, atomic_read(&d->continual_io_error)); continue; } return _FAIL; diff --git a/core/rtw_tdls.c b/core/rtw_tdls.c index 002ab4b..a06f616 100644 --- a/core/rtw_tdls.c +++ b/core/rtw_tdls.c @@ -47,7 +47,7 @@ void rtw_reset_tdls_info(_adapter *padapter) #ifdef CONFIG_TDLS_CH_SW ptdlsinfo->chsw_info.ch_sw_state = TDLS_STATE_NONE; - ATOMIC_SET(&ptdlsinfo->chsw_info.chsw_on, _FALSE); + atomic_set(&ptdlsinfo->chsw_info.chsw_on, _FALSE); ptdlsinfo->chsw_info.off_ch_num = 0; ptdlsinfo->chsw_info.ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; ptdlsinfo->chsw_info.cur_time = 0; @@ -945,8 +945,8 @@ void rtw_tdls_set_ch_sw_oper_control(_adapter *padapter, u8 enable) else pHalData->ch_switch_offload = _FALSE; - if (ATOMIC_READ(&padapter->tdlsinfo.chsw_info.chsw_on) != enable) - ATOMIC_SET(&padapter->tdlsinfo.chsw_info.chsw_on, enable); + if (atomic_read(&padapter->tdlsinfo.chsw_info.chsw_on) != enable) + atomic_set(&padapter->tdlsinfo.chsw_info.chsw_on, enable); rtw_hal_set_hwreg(padapter, HW_VAR_TDLS_BCN_EARLY_C2H_RPT, &enable); RTW_INFO("[TDLS] %s Bcn Early C2H Report\n", (enable == _TRUE) ? "Start" : "Stop"); @@ -959,7 +959,7 @@ void rtw_tdls_ch_sw_back_to_base_chnl(_adapter *padapter) pmlmepriv = &padapter->mlmepriv; - if ((ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) && + if ((atomic_read(&pchsw_info->chsw_on) == _TRUE) && (padapter->mlmeextpriv.cur_channel != rtw_get_oper_ch(padapter))) rtw_tdls_cmd(padapter, pchsw_info->addr, TDLS_CH_SW_TO_BASE_CHNL_UNSOLICITED); } @@ -2614,7 +2614,7 @@ sint On_TDLS_Ch_Switch_Req(_adapter *padapter, union recv_frame *precv_frame, st if (_rtw_memcmp(pchsw_info->addr, zaddr, ETH_ALEN) == _TRUE) _rtw_memcpy(pchsw_info->addr, ptdls_sta->cmn.mac_addr, ETH_ALEN); - if (ATOMIC_READ(&pchsw_info->chsw_on) == _FALSE) + if (atomic_read(&pchsw_info->chsw_on) == _FALSE) rtw_tdls_cmd(padapter, ptdls_sta->cmn.mac_addr, TDLS_CH_SW_START); rtw_tdls_cmd(padapter, ptdls_sta->cmn.mac_addr, TDLS_CH_SW_RESP); @@ -2642,7 +2642,7 @@ sint On_TDLS_Ch_Switch_Rsp(_adapter *padapter, union recv_frame *precv_frame, st /* If we receive Unsolicited TDLS Channel Switch Response when channel switch is running, */ /* we will go back to base channel and terminate this channel switch procedure */ - if (ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) { + if (atomic_read(&pchsw_info->chsw_on) == _TRUE) { if (pmlmeext->cur_channel != rtw_get_oper_ch(padapter)) { RTW_INFO("[TDLS] Rx unsolicited channel switch response\n"); rtw_tdls_cmd(padapter, ptdls_sta->cmn.mac_addr, TDLS_CH_SW_TO_BASE_CHNL); @@ -2694,7 +2694,7 @@ sint On_TDLS_Ch_Switch_Rsp(_adapter *padapter, union recv_frame *precv_frame, st if ((pmlmeext->cur_channel == rtw_get_oper_ch(padapter)) && (pchsw_info->ch_sw_state & TDLS_WAIT_CH_RSP_STATE)) { - if (ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) + if (atomic_read(&pchsw_info->chsw_on) == _TRUE) rtw_tdls_cmd(padapter, ptdls_sta->cmn.mac_addr, TDLS_CH_SW_TO_OFF_CHNL); } diff --git a/hal/hal_com.c b/hal/hal_com.c index b763866..f0c7e43 100644 --- a/hal/hal_com.c +++ b/hal/hal_com.c @@ -2489,7 +2489,7 @@ void rtw_mbid_cam_init(struct dvobj_priv *dvobj) _rtw_spinlock_init(&mbid_cam_ctl->lock); mbid_cam_ctl->bitmap = 0; - ATOMIC_SET(&mbid_cam_ctl->mbid_entry_num, 0); + atomic_set(&mbid_cam_ctl->mbid_entry_num, 0); _rtw_memset(&dvobj->mbid_cam_cache, 0, sizeof(dvobj->mbid_cam_cache)); } @@ -2511,7 +2511,7 @@ void rtw_mbid_cam_reset(_adapter *adapter) _rtw_memset(&dvobj->mbid_cam_cache, 0, sizeof(dvobj->mbid_cam_cache)); _exit_critical_bh(&mbid_cam_ctl->lock, &irqL); - ATOMIC_SET(&mbid_cam_ctl->mbid_entry_num, 0); + atomic_set(&mbid_cam_ctl->mbid_entry_num, 0); } static u8 _rtw_mbid_cam_search_by_macaddr(_adapter *adapter, u8 *mac_addr) { @@ -2601,7 +2601,7 @@ inline u8 rtw_get_mbid_cam_entry_num(_adapter *adapter) struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); struct mbid_cam_ctl_t *mbid_cam_ctl = &dvobj->mbid_cam_ctl; - return ATOMIC_READ(&mbid_cam_ctl->mbid_entry_num); + return atomic_read(&mbid_cam_ctl->mbid_entry_num); } static inline void mbid_cam_cache_init(_adapter *adapter, struct mbid_cam_cache *pmbid_cam, u8 *mac_addr) @@ -2625,7 +2625,7 @@ u8 rtw_mbid_camid_alloc(_adapter *adapter, u8 *mac_addr) u8 cam_id = INVALID_CAM_ID, i; struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); struct mbid_cam_ctl_t *mbid_cam_ctl = &dvobj->mbid_cam_ctl; - u8 entry_num = ATOMIC_READ(&mbid_cam_ctl->mbid_entry_num); + u8 entry_num = atomic_read(&mbid_cam_ctl->mbid_entry_num); if (INVALID_CAM_ID != rtw_mbid_cam_search_by_macaddr(adapter, mac_addr)) goto exit; @@ -2648,7 +2648,7 @@ u8 rtw_mbid_camid_alloc(_adapter *adapter, u8 *mac_addr) _exit_critical_bh(&mbid_cam_ctl->lock, &irqL); if (cam_id != INVALID_CAM_ID) { - ATOMIC_INC(&mbid_cam_ctl->mbid_entry_num); + atomic_inc(&mbid_cam_ctl->mbid_entry_num); RTW_INFO("%s mac:"MAC_FMT" - cam_id:%d\n", __func__, MAC_ARG(mac_addr), cam_id); #ifdef DBG_MBID_CAM_DUMP rtw_mbid_cam_cache_dump(RTW_DBGDUMP, __func__, adapter); @@ -2701,7 +2701,7 @@ u8 rtw_mbid_cam_assign(_adapter *adapter, u8 *mac_addr, u8 camid) _exit_critical_bh(&mbid_cam_ctl->lock, &irqL); if (ret == _TRUE) { - ATOMIC_INC(&mbid_cam_ctl->mbid_entry_num); + atomic_inc(&mbid_cam_ctl->mbid_entry_num); RTW_INFO("%s mac:"MAC_FMT" - cam_id:%d\n", __func__, MAC_ARG(mac_addr), camid); #ifdef DBG_MBID_CAM_DUMP rtw_mbid_cam_cache_dump(RTW_DBGDUMP, __func__, adapter); @@ -2727,7 +2727,7 @@ void rtw_mbid_camid_clean(_adapter *adapter, u8 mbss_canid) mbid_cam_cache_clr(&dvobj->mbid_cam_cache[mbss_canid]); mbid_cam_ctl->bitmap &= (~BIT(mbss_canid)); _exit_critical_bh(&mbid_cam_ctl->lock, &irqL); - ATOMIC_DEC(&mbid_cam_ctl->mbid_entry_num); + atomic_dec(&mbid_cam_ctl->mbid_entry_num); RTW_INFO("%s - cam_id:%d\n", __func__, mbss_canid); } int rtw_mbid_cam_cache_dump(void *sel, const char *fun_name, _adapter *adapter) @@ -2738,7 +2738,7 @@ int rtw_mbid_cam_cache_dump(void *sel, const char *fun_name, _adapter *adapter) u8 iface_id; struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); struct mbid_cam_ctl_t *mbid_cam_ctl = &dvobj->mbid_cam_ctl; - u8 entry_num = ATOMIC_READ(&mbid_cam_ctl->mbid_entry_num); + u8 entry_num = atomic_read(&mbid_cam_ctl->mbid_entry_num); u8 max_cam_id = rtw_get_max_mbid_cam_id(adapter); RTW_PRINT_SEL(sel, "== MBSSID CAM DUMP (%s)==\n", fun_name); diff --git a/hal/hal_dm_acs.h b/hal/hal_dm_acs.h index 871c144..a42d0de 100644 --- a/hal/hal_dm_acs.h +++ b/hal/hal_dm_acs.h @@ -60,8 +60,8 @@ void rtw_acs_version_dump(void *sel, _adapter *adapter); extern void phydm_ccx_monitor_trigger(void *p_dm_void, u16 monitor_time); extern void phydm_ccx_monitor_result(void *p_dm_void); -#define GET_ACS_STATE(padapter) (ATOMIC_READ(&GET_HAL_DATA(padapter)->acs.state)) -#define SET_ACS_STATE(padapter, set_state) (ATOMIC_SET(&GET_HAL_DATA(padapter)->acs.state, set_state)) +#define GET_ACS_STATE(padapter) (atomic_read(&GET_HAL_DATA(padapter)->acs.state)) +#define SET_ACS_STATE(padapter, set_state) (atomic_set(&GET_HAL_DATA(padapter)->acs.state, set_state)) #define IS_ACS_ENABLE(padapter) ((GET_ACS_STATE(padapter) == ACS_ENABLE) ? _TRUE : _FALSE) enum ACS_STATE { @@ -75,7 +75,7 @@ enum ACS_STATE { #define ACS_BW_160M BIT(3) struct auto_chan_sel { - ATOMIC_T state; + atomic_t state; u8 trigger_ch; bool triggered; u8 clm_ratio[MAX_CHANNEL_NUM]; @@ -142,8 +142,8 @@ void rtw_acs_stop(_adapter *adapter); #ifdef CONFIG_BACKGROUND_NOISE_MONITOR #define RTK_NOISE_MONITOR_VERSION 3 -#define GET_NM_STATE(padapter) (ATOMIC_READ(&GET_HAL_DATA(padapter)->nm.state)) -#define SET_NM_STATE(padapter, set_state) (ATOMIC_SET(&GET_HAL_DATA(padapter)->nm.state, set_state)) +#define GET_NM_STATE(padapter) (atomic_read(&GET_HAL_DATA(padapter)->nm.state)) +#define SET_NM_STATE(padapter, set_state) (atomic_set(&GET_HAL_DATA(padapter)->nm.state, set_state)) #define IS_NM_ENABLE(padapter) ((GET_NM_STATE(padapter) == NM_ENABLE) ? _TRUE : _FALSE) enum NM_STATE { @@ -152,7 +152,7 @@ enum NM_STATE { }; struct noise_monitor { - ATOMIC_T state; + atomic_t state; s16 noise[MAX_CHANNEL_NUM]; u8 bss_nums[MAX_CHANNEL_NUM]; }; diff --git a/hal/rtl8192e/rtl8192e_phycfg.c b/hal/rtl8192e/rtl8192e_phycfg.c index 619427a..2ac1a21 100644 --- a/hal/rtl8192e/rtl8192e_phycfg.c +++ b/hal/rtl8192e/rtl8192e_phycfg.c @@ -1114,7 +1114,7 @@ phy_SwChnlAndSetBwMode8192E( #ifdef CONFIG_TDLS #ifdef CONFIG_TDLS_CH_SW /* It takes too much time of setting tx power, influence channel switch */ - if ((ATOMIC_READ(&Adapter->tdlsinfo.chsw_info.chsw_on) == _FALSE)) + if ((atomic_read(&Adapter->tdlsinfo.chsw_info.chsw_on) == _FALSE)) #endif #endif /* CONFIG_TDLS */ PHY_SetTxPowerLevel8192E(Adapter, pHalData->current_channel); diff --git a/hal/rtl8192e/usb/usb_ops_linux.c b/hal/rtl8192e/usb/usb_ops_linux.c index d909f13..69efc36 100644 --- a/hal/rtl8192e/usb/usb_ops_linux.c +++ b/hal/rtl8192e/usb/usb_ops_linux.c @@ -52,7 +52,7 @@ void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf) struct tdls_ch_switch *pchsw_info = &padapter->tdlsinfo.chsw_info; u32 last_time = pchsw_info->cur_time; pchsw_info->cur_time = rtw_systime_to_ms(rtw_get_current_time()); - if ((ATOMIC_READ(&pchsw_info->chsw_on) == _TRUE) && + if ((atomic_read(&pchsw_info->chsw_on) == _TRUE) && /* Sometimes we receive multiple interrupts in very little time period, use the follow condition test to filter */ (pchsw_info->cur_time - last_time > padapter->mlmeextpriv.mlmext_info.bcn_interval - 5) && (padapter->mlmeextpriv.cur_channel != rtw_get_oper_ch(padapter))) { diff --git a/include/drv_types.h b/include/drv_types.h index 3262a8f..dbb4208 100644 --- a/include/drv_types.h +++ b/include/drv_types.h @@ -942,7 +942,7 @@ struct rf_ctl_t { struct mbid_cam_ctl_t { _lock lock; u8 bitmap; - ATOMIC_T mbid_entry_num; + atomic_t mbid_entry_num; }; struct mbid_cam_cache { u8 iface_id; @@ -995,8 +995,8 @@ struct dvobj_priv { u8 HardwareType; u8 interface_type;/*USB,SDIO,SPI,PCI*/ - ATOMIC_T bSurpriseRemoved; - ATOMIC_T bDriverStopped; + atomic_t bSurpriseRemoved; + atomic_t bDriverStopped; s32 processing_dev_remove; @@ -1076,9 +1076,9 @@ struct dvobj_priv { u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ u8 irq_alloc; - ATOMIC_T continual_io_error; + atomic_t continual_io_error; - ATOMIC_T disable_func; + atomic_t disable_func; u8 xmit_block; _lock xmit_block_lock; @@ -1248,7 +1248,6 @@ struct dvobj_priv { #endif /* also for RTK T/P Testing Mode */ u8 scan_deny; - }; #define DEV_STA_NUM(_dvobj) MSTATE_STA_NUM(&((_dvobj)->iface_state)) @@ -1286,22 +1285,22 @@ struct dvobj_priv { static inline void dev_set_surprise_removed(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->bSurpriseRemoved, _TRUE); + atomic_set(&dvobj->bSurpriseRemoved, _TRUE); } static inline void dev_clr_surprise_removed(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->bSurpriseRemoved, _FALSE); + atomic_set(&dvobj->bSurpriseRemoved, _FALSE); } static inline void dev_set_drv_stopped(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->bDriverStopped, _TRUE); + atomic_set(&dvobj->bDriverStopped, _TRUE); } static inline void dev_clr_drv_stopped(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->bDriverStopped, _FALSE); + atomic_set(&dvobj->bDriverStopped, _FALSE); } -#define dev_is_surprise_removed(dvobj) (ATOMIC_READ(&dvobj->bSurpriseRemoved) == _TRUE) -#define dev_is_drv_stopped(dvobj) (ATOMIC_READ(&dvobj->bDriverStopped) == _TRUE) +#define dev_is_surprise_removed(dvobj) (atomic_read(&dvobj->bSurpriseRemoved) == _TRUE) +#define dev_is_drv_stopped(dvobj) (atomic_read(&dvobj->bDriverStopped) == _TRUE) #ifdef PLATFORM_LINUX static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) @@ -1448,7 +1447,7 @@ struct _ADAPTER { #endif /* CONFIG_P2P */ #endif /* CONFIG_IOCTL_CFG80211 */ u32 setband; - ATOMIC_T bandskip; + atomic_t bandskip; #ifdef CONFIG_P2P struct wifidirect_info wdinfo; @@ -1741,27 +1740,27 @@ static inline void rtw_clr_drv_stopped(_adapter *padapter) #define DF_RX_BIT BIT1 /*read_port_cancel*/ #define DF_IO_BIT BIT2 -/* #define RTW_DISABLE_FUNC(padapter, func) (ATOMIC_ADD(&adapter_to_dvobj(padapter)->disable_func, (func))) */ -/* #define RTW_ENABLE_FUNC(padapter, func) (ATOMIC_SUB(&adapter_to_dvobj(padapter)->disable_func, (func))) */ +/* #define RTW_DISABLE_FUNC(padapter, func) (atomic_add(&adapter_to_dvobj(padapter)->disable_func, (func))) */ +/* #define RTW_ENABLE_FUNC(padapter, func) (atomic_sub(&adapter_to_dvobj(padapter)->disable_func, (func))) */ __inline static void RTW_DISABLE_FUNC(_adapter *padapter, int func_bit) { - int df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func); + int df = atomic_read(&adapter_to_dvobj(padapter)->disable_func); df |= func_bit; - ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df); + atomic_set(&adapter_to_dvobj(padapter)->disable_func, df); } __inline static void RTW_ENABLE_FUNC(_adapter *padapter, int func_bit) { - int df = ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func); + int df = atomic_read(&adapter_to_dvobj(padapter)->disable_func); df &= ~(func_bit); - ATOMIC_SET(&adapter_to_dvobj(padapter)->disable_func, df); + atomic_set(&adapter_to_dvobj(padapter)->disable_func, df); } #define RTW_CANNOT_RUN(padapter) \ (rtw_is_surprise_removed(padapter) || \ rtw_is_drv_stopped(padapter)) -#define RTW_IS_FUNC_DISABLED(padapter, func_bit) (ATOMIC_READ(&adapter_to_dvobj(padapter)->disable_func) & (func_bit)) +#define RTW_IS_FUNC_DISABLED(padapter, func_bit) (atomic_read(&adapter_to_dvobj(padapter)->disable_func) & (func_bit)) #define RTW_CANNOT_IO(padapter) \ (rtw_is_surprise_removed(padapter) || \ diff --git a/include/osdep_service.h b/include/osdep_service.h index 16a7e75..93f68c4 100644 --- a/include/osdep_service.h +++ b/include/osdep_service.h @@ -610,18 +610,6 @@ extern void rtw_set_bit(int nr, unsigned long *addr); extern void rtw_clear_bit(int nr, unsigned long *addr); extern int rtw_test_and_clear_bit(int nr, unsigned long *addr); -extern void ATOMIC_SET(ATOMIC_T *v, int i); -extern int ATOMIC_READ(ATOMIC_T *v); -extern void ATOMIC_ADD(ATOMIC_T *v, int i); -extern void ATOMIC_SUB(ATOMIC_T *v, int i); -extern void ATOMIC_INC(ATOMIC_T *v); -extern void ATOMIC_DEC(ATOMIC_T *v); -extern int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i); -extern int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); -extern int ATOMIC_INC_RETURN(ATOMIC_T *v); -extern int ATOMIC_DEC_RETURN(ATOMIC_T *v); -extern bool ATOMIC_INC_UNLESS(ATOMIC_T *v, int u); - /* File operation APIs, just for linux now */ extern int rtw_is_file_readable(const char *path); extern int rtw_is_file_readable_with_size(const char *path, u32 *sz); diff --git a/include/osdep_service_bsd.h b/include/osdep_service_bsd.h index 576d82a..f7399bf 100644 --- a/include/osdep_service_bsd.h +++ b/include/osdep_service_bsd.h @@ -732,9 +732,6 @@ __inline static void _set_workitem(_workitem *pwork) static __inline void thread_enter(char *name); -//Atomic integer operations -typedef uint32_t ATOMIC_T ; - #define rtw_netdev_priv(netdev) (((struct ifnet *)netdev)->if_softc) #define rtw_free_netdev(netdev) if_free((netdev)) diff --git a/include/osdep_service_ce.h b/include/osdep_service_ce.h index a406d62..f45cb60 100644 --- a/include/osdep_service_ce.h +++ b/include/osdep_service_ce.h @@ -1,17 +1,17 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2017 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - *****************************************************************************/ +/****************************************************************************** + * + * Copyright(c) 2007 - 2017 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + *****************************************************************************/ #ifndef __OSDEP_CE_SERVICE_H_ #define __OSDEP_CE_SERVICE_H_ @@ -40,11 +40,11 @@ typedef u32 _irqL; typedef NDIS_HANDLE _nic_hdl; -struct rtw_timer_list { - NDIS_MINIPORT_TIMER ndis_timer; - void (*function)(void *); - void *arg; -}; +struct rtw_timer_list { + NDIS_MINIPORT_TIMER ndis_timer; + void (*function)(void *); + void *arg; +}; struct __queue { LIST_ENTRY queue; @@ -60,7 +60,7 @@ typedef DWORD thread_return; typedef void* thread_context; typedef NDIS_WORK_ITEM _workitem; - + #define SEMA_UPBND (0x7FFFFFFF) //8192 @@ -119,33 +119,33 @@ __inline static void rtw_list_delete(_list *plist) InitializeListHead(plist); } -static inline void timer_hdl( - IN PVOID SystemSpecific1, - IN PVOID FunctionContext, - IN PVOID SystemSpecific2, - IN PVOID SystemSpecific3) -{ - _timer *timer = (_timer *)FunctionContext; - - timer->function(timer->arg); -} - -static inline void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void *cntx) -{ - ptimer->function = pfunc; - ptimer->arg = cntx; - NdisMInitializeTimer(&ptimer->ndis_timer, nic_hdl, timer_hdl, ptimer); -} - -static inline void _set_timer(_timer *ptimer, u32 delay_time) -{ - NdisMSetTimer(ptimer, delay_time); -} - -static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) -{ - NdisMCancelTimer(ptimer, bcancelled); -} +static inline void timer_hdl( + IN PVOID SystemSpecific1, + IN PVOID FunctionContext, + IN PVOID SystemSpecific2, + IN PVOID SystemSpecific3) +{ + _timer *timer = (_timer *)FunctionContext; + + timer->function(timer->arg); +} + +static inline void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void *cntx) +{ + ptimer->function = pfunc; + ptimer->arg = cntx; + NdisMInitializeTimer(&ptimer->ndis_timer, nic_hdl, timer_hdl, ptimer); +} + +static inline void _set_timer(_timer *ptimer, u32 delay_time) +{ + NdisMSetTimer(ptimer, delay_time); +} + +static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) +{ + NdisMCancelTimer(ptimer, bcancelled); +} __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) { @@ -182,7 +182,7 @@ __inline static void _set_workitem(_workitem *pwork) #define PATH_LENGTH_MAX MAX_PATH //Atomic integer operations -#define ATOMIC_T LONG +#define atomic_t LONG #define NDEV_FMT "%s" #define NDEV_ARG(ndev) "" diff --git a/include/osdep_service_linux.h b/include/osdep_service_linux.h index 2f84f97..2339af4 100644 --- a/include/osdep_service_linux.h +++ b/include/osdep_service_linux.h @@ -513,7 +513,7 @@ static inline int rtw_merge_string(char *dst, int dst_len, const char *src1, con #define PATH_LENGTH_MAX PATH_MAX /* Atomic integer operations */ -#define ATOMIC_T atomic_t +#define atomic_t atomic_t #define rtw_netdev_priv(netdev) (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) diff --git a/include/osdep_service_xp.h b/include/osdep_service_xp.h index 71dc1cd..95c3552 100644 --- a/include/osdep_service_xp.h +++ b/include/osdep_service_xp.h @@ -1,17 +1,17 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2017 Realtek Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - *****************************************************************************/ +/****************************************************************************** + * + * Copyright(c) 2007 - 2017 Realtek Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + *****************************************************************************/ #ifndef __OSDEP_LINUX_SERVICE_H_ #define __OSDEP_LINUX_SERVICE_H_ @@ -40,11 +40,11 @@ // USB_PIPE for WINCE , but handle can be use just integer under windows typedef NDIS_HANDLE _nic_hdl; - struct rtw_timer_list { - NDIS_MINIPORT_TIMER ndis_timer; - void (*function)(void *); - void *arg; - }; + struct rtw_timer_list { + NDIS_MINIPORT_TIMER ndis_timer; + void (*function)(void *); + void *arg; + }; struct __queue { LIST_ENTRY queue; @@ -128,33 +128,33 @@ __inline static void rtw_list_delete(_list *plist) InitializeListHead(plist); } -static inline void timer_hdl( - IN PVOID SystemSpecific1, - IN PVOID FunctionContext, - IN PVOID SystemSpecific2, - IN PVOID SystemSpecific3) -{ - _timer *timer = (_timer *)FunctionContext; - - timer->function(timer->arg); -} - -static inline void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void *cntx) -{ - ptimer->function = pfunc; - ptimer->arg = cntx; - NdisMInitializeTimer(&ptimer->ndis_timer, nic_hdl, timer_hdl, ptimer); -} - -static inline void _set_timer(_timer *ptimer, u32 delay_time) -{ - NdisMSetTimer(ptimer, delay_time); -} - -static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) -{ - NdisMCancelTimer(ptimer, bcancelled); -} +static inline void timer_hdl( + IN PVOID SystemSpecific1, + IN PVOID FunctionContext, + IN PVOID SystemSpecific2, + IN PVOID SystemSpecific3) +{ + _timer *timer = (_timer *)FunctionContext; + + timer->function(timer->arg); +} + +static inline void _init_timer(_timer *ptimer, _nic_hdl nic_hdl, void *pfunc, void *cntx) +{ + ptimer->function = pfunc; + ptimer->arg = cntx; + NdisMInitializeTimer(&ptimer->ndis_timer, nic_hdl, timer_hdl, ptimer); +} + +static inline void _set_timer(_timer *ptimer, u32 delay_time) +{ + NdisMSetTimer(ptimer, delay_time); +} + +static inline void _cancel_timer(_timer *ptimer, u8 *bcancelled) +{ + NdisMCancelTimer(ptimer, bcancelled); +} __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx) { @@ -192,7 +192,7 @@ __inline static void _set_workitem(_workitem *pwork) #define PATH_LENGTH_MAX MAX_PATH //Atomic integer operations -#define ATOMIC_T LONG +#define atomic_t LONG #define NDEV_FMT "%s" diff --git a/include/rtw_cmd.h b/include/rtw_cmd.h index 1f0dea6..bf1f00c 100644 --- a/include/rtw_cmd.h +++ b/include/rtw_cmd.h @@ -66,7 +66,7 @@ struct cmd_priv { u32 cmd_issued_cnt; u32 cmd_done_cnt; u32 rsp_cnt; - ATOMIC_T cmdthd_running; + atomic_t cmdthd_running; /* u8 cmdthd_running; */ _adapter *padapter; @@ -107,7 +107,7 @@ struct evt_priv { u8 lbkevt_num; u8 *cmdevt_parm; #endif - ATOMIC_T event_seq; + atomic_t event_seq; u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *evt_allocated_buf; u32 evt_done_cnt; diff --git a/include/rtw_mlme.h b/include/rtw_mlme.h index 706a25e..1fae61a 100644 --- a/include/rtw_mlme.h +++ b/include/rtw_mlme.h @@ -359,7 +359,7 @@ struct cfg80211_wifidirect_info { u8 restore_channel; struct ieee80211_channel remain_on_ch_channel; enum nl80211_channel_type remain_on_ch_type; - ATOMIC_T ro_ch_cookie_gen; + atomic_t ro_ch_cookie_gen; u64 remain_on_ch_cookie; bool is_ro_ch; struct wireless_dev *ro_ch_wdev; @@ -504,7 +504,7 @@ struct tdls_temp_mgmt { #ifdef CONFIG_TDLS_CH_SW struct tdls_ch_switch { u32 ch_sw_state; - ATOMIC_T chsw_on; + atomic_t chsw_on; u8 addr[ETH_ALEN]; u8 off_ch_num; u8 ch_offset; @@ -731,7 +731,7 @@ struct nb_rpt_hdr { u8 phy_type; }; -/*IEEE Std 80211v, Figure 7-95e2¡XBSS Termination Duration subelement field format */ +/*IEEE Std 80211v, Figure 7-95e2�XBSS Termination Duration subelement field format */ struct btm_term_duration { u8 id; u8 len; @@ -739,7 +739,7 @@ struct btm_term_duration { u16 duration; }; -/*IEEE Std 80211v, Figure 7-101n8¡XBSS Transition Management Request frame body format */ +/*IEEE Std 80211v, Figure 7-101n8�XBSS Transition Management Request frame body format */ struct btm_req_hdr { u8 req_mode; u16 disassoc_timer; @@ -843,7 +843,7 @@ struct mlme_priv { #ifdef CONFIG_SET_SCAN_DENY_TIMER _timer set_scan_deny_timer; - ATOMIC_T set_scan_deny; /* 0: allowed, 1: deny */ + atomic_t set_scan_deny; /* 0: allowed, 1: deny */ #endif u8 wpa_phase;/*wpa_phase after wps finished*/ @@ -914,7 +914,7 @@ struct mlme_priv { /* Number of associated stations that do not support Short Preamble */ int num_sta_no_short_preamble; - ATOMIC_T olbc; /* Overlapping Legacy BSS Condition (Legacy b/g)*/ + atomic_t olbc; /* Overlapping Legacy BSS Condition (Legacy b/g)*/ /* Number of HT associated stations that do not support greenfield */ int num_sta_ht_no_gf; @@ -929,7 +929,7 @@ struct mlme_priv { int num_sta_40mhz_intolerant; /* Overlapping BSS information */ - ATOMIC_T olbc_ht; + atomic_t olbc_ht; #ifdef CONFIG_80211N_HT int ht_20mhz_width_req; @@ -1019,7 +1019,7 @@ struct mlme_priv { int widi_state; int listen_state; _timer listen_timer; - ATOMIC_T rx_probe_rsp; /* 1:receive probe respone from RDS source. */ + atomic_t rx_probe_rsp; /* 1:receive probe respone from RDS source. */ u8 *l2sdTaBuffer; u8 channel_idx; u8 group_cnt; /* In WiDi 3.5, they specified another scan algo. for WFD/RDS co-existed */ diff --git a/include/rtw_mlme_ext.h b/include/rtw_mlme_ext.h index 3dc4e58..285da31 100644 --- a/include/rtw_mlme_ext.h +++ b/include/rtw_mlme_ext.h @@ -482,7 +482,7 @@ struct p2p_oper_class_map { struct mlme_ext_priv { _adapter *padapter; u8 mlmeext_init; - ATOMIC_T event_seq; + atomic_t event_seq; u16 mgnt_seq; #ifdef CONFIG_IEEE80211W u16 sa_query_seq; diff --git a/include/rtw_pwrctrl.h b/include/rtw_pwrctrl.h index 7bc5534..6afd25c 100644 --- a/include/rtw_pwrctrl.h +++ b/include/rtw_pwrctrl.h @@ -291,9 +291,9 @@ typedef struct lps_poff_info { u32 tx_bndy_dynamic; u16 ConfLenForPTK; u16 ConfLenForGTK; - ATOMIC_T bEnterPOFF; - ATOMIC_T bTxBoundInProgress; - ATOMIC_T bSetPOFFParm; + atomic_t bEnterPOFF; + atomic_t bTxBoundInProgress; + atomic_t bSetPOFFParm; } lps_poff_info_t; #endif /*CONFIG_LPS_POFF*/ diff --git a/include/rtw_recv.h b/include/rtw_recv.h index ca0ebc3..3f65e0b 100644 --- a/include/rtw_recv.h +++ b/include/rtw_recv.h @@ -387,7 +387,7 @@ struct recv_priv { /* u8 *pallocated_urb_buf; */ _sema allrxreturnevt; uint ff_hwaddr; - ATOMIC_T rx_pending_cnt; + atomic_t rx_pending_cnt; #ifdef CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX diff --git a/include/rtw_rm.h b/include/rtw_rm.h index 9efcf13..5dffa17 100644 --- a/include/rtw_rm.h +++ b/include/rtw_rm.h @@ -53,7 +53,7 @@ struct rm_event { struct rm_clock { struct rm_obj *prm; - ATOMIC_T counter; + atomic_t counter; enum RM_EV_ID evid; }; diff --git a/include/sta_info.h b/include/sta_info.h index 762933a..f64f470 100644 --- a/include/sta_info.h +++ b/include/sta_info.h @@ -357,7 +357,7 @@ struct sta_info { /* for A-MPDU Rx reordering buffer control */ struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM]; - ATOMIC_T continual_no_rx_packet[TID_NUM]; + atomic_t continual_no_rx_packet[TID_NUM]; /* for A-MPDU Tx */ /* unsigned char ampdu_txen_bitmap; */ u16 BA_starting_seqctrl[16]; diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 7c404be..ccf9c64 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -6687,7 +6687,7 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, is_p2p_find = (duration < (pwdinfo->ext_listen_interval)) ? _TRUE : _FALSE; #endif - *cookie = ATOMIC_INC_RETURN(&pcfg80211_wdinfo->ro_ch_cookie_gen); + *cookie = atomic_inc_return(&pcfg80211_wdinfo->ro_ch_cookie_gen); RTW_INFO(FUNC_ADPT_FMT"%s ch:%u duration:%d, cookie:0x%llx\n" , FUNC_ADPT_ARG(padapter), wdev == wiphy_to_pd_wdev(wiphy) ? " PD" : "" @@ -7079,7 +7079,7 @@ static int _cfg80211_rtw_mgmt_tx(_adapter *padapter, u8 tx_ch, u8 no_cck, const #if defined(RTW_ROCH_BACK_OP) && defined(CONFIG_P2P) && defined(CONFIG_CONCURRENT_MODE) if (rtw_cfg80211_get_is_roch(padapter) - && ATOMIC_READ(&pwdev_priv->switch_ch_to) == 1 + && atomic_read(&pwdev_priv->switch_ch_to) == 1 ) { u16 ext_listen_period; @@ -7087,7 +7087,7 @@ static int _cfg80211_rtw_mgmt_tx(_adapter *padapter, u8 tx_ch, u8 no_cck, const ext_listen_period = 500; else ext_listen_period = pwdinfo->ext_listen_period; - ATOMIC_SET(&pwdev_priv->switch_ch_to, 0); + atomic_set(&pwdev_priv->switch_ch_to, 0); _set_timer(&pwdinfo->ap_p2p_switch_timer, ext_listen_period); RTW_INFO("%s, set switch ch timer, period=%d\n", __func__, ext_listen_period); } @@ -9362,7 +9362,7 @@ void rtw_cfg80211_init_wdev_data(_adapter *padapter) #ifdef CONFIG_CONCURRENT_MODE struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter); - ATOMIC_SET(&pwdev_priv->switch_ch_to, 1); + atomic_set(&pwdev_priv->switch_ch_to, 1); #endif } @@ -10103,7 +10103,7 @@ int rtw_wdev_alloc(_adapter *padapter, struct wiphy *wiphy) _rtw_mutex_init(&pwdev_priv->roch_mutex); #ifdef CONFIG_CONCURRENT_MODE - ATOMIC_SET(&pwdev_priv->switch_ch_to, 1); + atomic_set(&pwdev_priv->switch_ch_to, 1); #endif #ifdef CONFIG_RTW_CFGVEDNOR_RSSIMONITOR diff --git a/os_dep/linux/ioctl_cfg80211.h b/os_dep/linux/ioctl_cfg80211.h index 6775480..146f537 100644 --- a/os_dep/linux/ioctl_cfg80211.h +++ b/os_dep/linux/ioctl_cfg80211.h @@ -177,7 +177,7 @@ struct rtw_wdev_priv { _mutex roch_mutex; #ifdef CONFIG_CONCURRENT_MODE - ATOMIC_T switch_ch_to; + atomic_t switch_ch_to; #endif #ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 04e40a2..372deef 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -6225,7 +6225,7 @@ static int rtw_dbg_port(struct net_device *dev, pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xframe_ext_cnt, precvpriv->free_recvframe_cnt); #ifdef CONFIG_USB_HCI - RTW_INFO("rx_urb_pending_cn=%d\n", ATOMIC_READ(&(precvpriv->rx_pending_cnt))); + RTW_INFO("rx_urb_pending_cn=%d\n", atomic_read(&(precvpriv->rx_pending_cnt))); #endif } break; @@ -11042,7 +11042,7 @@ static int rtw_wfd_tdls_status(struct net_device *dev, #ifdef CONFIG_TDLS_CH_SW , ptdlsinfo->chsw_info.ch_sw_state, - ATOMIC_READ(&padapter->tdlsinfo.chsw_info.chsw_on), + atomic_read(&padapter->tdlsinfo.chsw_info.chsw_on), ptdlsinfo->chsw_info.off_ch_num, ptdlsinfo->chsw_info.cur_time, ptdlsinfo->chsw_info.ch_offset, diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index 03a9c7b..9356a7c 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -2134,7 +2134,7 @@ struct dvobj_priv *devobj_init(void) pdvobj->processing_dev_remove = _FALSE; - ATOMIC_SET(&pdvobj->disable_func, 0); + atomic_set(&pdvobj->disable_func, 0); rtw_macid_ctl_init(&pdvobj->macid_ctl); #ifdef CONFIG_CLIENT_PORT_CFG @@ -4273,7 +4273,7 @@ void rtw_dev_unload(PADAPTER padapter) { rtw_stop_drv_threads(padapter); - if (ATOMIC_READ(&(pcmdpriv->cmdthd_running)) == _TRUE) { + if (atomic_read(&(pcmdpriv->cmdthd_running)) == _TRUE) { RTW_ERR("cmd_thread not stop !!\n"); rtw_warn_on(1); } diff --git a/os_dep/linux/usb_intf.c b/os_dep/linux/usb_intf.c index fd542bb..bbcfde1 100644 --- a/os_dep/linux/usb_intf.c +++ b/os_dep/linux/usb_intf.c @@ -79,7 +79,7 @@ static void rtw_dev_shutdown(struct device *dev) } } } - ATOMIC_SET(&dvobj->continual_io_error, MAX_CONTINUAL_IO_ERR + 1); + atomic_set(&dvobj->continual_io_error, MAX_CONTINUAL_IO_ERR + 1); } } } @@ -686,7 +686,7 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) devobj_deinit(dvobj); } - /* RTW_INFO("%s %d\n", __func__, ATOMIC_READ(&usb_intf->dev.kobj.kref.refcount)); */ + /* RTW_INFO("%s %d\n", __func__, atomic_read(&usb_intf->dev.kobj.kref.refcount)); */ usb_put_dev(interface_to_usbdev(usb_intf)); } diff --git a/os_dep/linux/usb_ops_linux.c b/os_dep/linux/usb_ops_linux.c index 709023a..1d20cbf 100644 --- a/os_dep/linux/usb_ops_linux.c +++ b/os_dep/linux/usb_ops_linux.c @@ -753,7 +753,7 @@ void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) _adapter *padapter = (_adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; - ATOMIC_DEC(&(precvpriv->rx_pending_cnt)); + atomic_dec(&(precvpriv->rx_pending_cnt)); if (RTW_CANNOT_RX(padapter)) { RTW_INFO("%s() RX Warning! bDriverStopped(%s) OR bSurpriseRemoved(%s)\n" @@ -837,7 +837,7 @@ u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) usb_init_recvbuf(adapter, precvbuf); if (precvbuf->pbuf) { - ATOMIC_INC(&(precvpriv->rx_pending_cnt)); + atomic_inc(&(precvpriv->rx_pending_cnt)); purb = precvbuf->purb; /* translate DMA FIFO addr to pipehandle */ @@ -906,7 +906,7 @@ void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) _adapter *padapter = (_adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; - ATOMIC_DEC(&(precvpriv->rx_pending_cnt)); + atomic_dec(&(precvpriv->rx_pending_cnt)); if (RTW_CANNOT_RX(padapter)) { RTW_INFO("%s() RX Warning! bDriverStopped(%s) OR bSurpriseRemoved(%s)\n" @@ -1046,7 +1046,7 @@ recv_buf_hook: goto exit; } - ATOMIC_INC(&(precvpriv->rx_pending_cnt)); + atomic_inc(&(precvpriv->rx_pending_cnt)); ret = _SUCCESS; exit: diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 7794059..f805308 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -20,14 +20,6 @@ #define RT_TAG '1178' -#ifdef DBG_MEMORY_LEAK -#ifdef PLATFORM_LINUX -atomic_t _malloc_cnt = ATOMIC_INIT(0); -atomic_t _malloc_size = ATOMIC_INIT(0); -#endif -#endif /* DBG_MEMORY_LEAK */ - - #if defined(PLATFORM_LINUX) /* * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE @@ -407,10 +399,10 @@ inline void _rtw_usb_buffer_free(struct usb_device *dev, size_t size, void *addr #if defined(DBG_MEM_ALLOC) struct rtw_mem_stat { - ATOMIC_T alloc; /* the memory bytes we allocate currently */ - ATOMIC_T peak; /* the peak memory bytes we allocate */ - ATOMIC_T alloc_cnt; /* the alloc count for alloc currently */ - ATOMIC_T alloc_err_cnt; /* the error times we fail to allocate memory */ + atomic_t alloc; /* the memory bytes we allocate currently */ + atomic_t peak; /* the peak memory bytes we allocate */ + atomic_t alloc_cnt; /* the alloc count for alloc currently */ + atomic_t alloc_err_cnt; /* the error times we fail to allocate memory */ }; struct rtw_mem_stat rtw_mem_type_stat[mstat_tf_idx(MSTAT_TYPE_MAX)]; @@ -448,18 +440,18 @@ void rtw_mstat_dump(void *sel) int tx_alloc, tx_peak, tx_alloc_err, rx_alloc, rx_peak, rx_alloc_err; for (i = 0; i < mstat_tf_idx(MSTAT_TYPE_MAX); i++) { - value_t[0][i] = ATOMIC_READ(&(rtw_mem_type_stat[i].alloc)); - value_t[1][i] = ATOMIC_READ(&(rtw_mem_type_stat[i].peak)); - value_t[2][i] = ATOMIC_READ(&(rtw_mem_type_stat[i].alloc_cnt)); - value_t[3][i] = ATOMIC_READ(&(rtw_mem_type_stat[i].alloc_err_cnt)); + value_t[0][i] = atomic_read(&(rtw_mem_type_stat[i].alloc)); + value_t[1][i] = atomic_read(&(rtw_mem_type_stat[i].peak)); + value_t[2][i] = atomic_read(&(rtw_mem_type_stat[i].alloc_cnt)); + value_t[3][i] = atomic_read(&(rtw_mem_type_stat[i].alloc_err_cnt)); } #ifdef RTW_MEM_FUNC_STAT for (i = 0; i < mstat_ff_idx(MSTAT_FUNC_MAX); i++) { - value_f[0][i] = ATOMIC_READ(&(rtw_mem_func_stat[i].alloc)); - value_f[1][i] = ATOMIC_READ(&(rtw_mem_func_stat[i].peak)); - value_f[2][i] = ATOMIC_READ(&(rtw_mem_func_stat[i].alloc_cnt)); - value_f[3][i] = ATOMIC_READ(&(rtw_mem_func_stat[i].alloc_err_cnt)); + value_f[0][i] = atomic_read(&(rtw_mem_func_stat[i].alloc)); + value_f[1][i] = atomic_read(&(rtw_mem_func_stat[i].peak)); + value_f[2][i] = atomic_read(&(rtw_mem_func_stat[i].alloc_cnt)); + value_f[3][i] = atomic_read(&(rtw_mem_func_stat[i].alloc_err_cnt)); } #endif @@ -484,51 +476,51 @@ void rtw_mstat_update(const enum mstat_f flags, const MSTAT_STATUS status, u32 s /* initialization */ if (!update_time) { for (i = 0; i < mstat_tf_idx(MSTAT_TYPE_MAX); i++) { - ATOMIC_SET(&(rtw_mem_type_stat[i].alloc), 0); - ATOMIC_SET(&(rtw_mem_type_stat[i].peak), 0); - ATOMIC_SET(&(rtw_mem_type_stat[i].alloc_cnt), 0); - ATOMIC_SET(&(rtw_mem_type_stat[i].alloc_err_cnt), 0); + atomic_set(&(rtw_mem_type_stat[i].alloc), 0); + atomic_set(&(rtw_mem_type_stat[i].peak), 0); + atomic_set(&(rtw_mem_type_stat[i].alloc_cnt), 0); + atomic_set(&(rtw_mem_type_stat[i].alloc_err_cnt), 0); } #ifdef RTW_MEM_FUNC_STAT for (i = 0; i < mstat_ff_idx(MSTAT_FUNC_MAX); i++) { - ATOMIC_SET(&(rtw_mem_func_stat[i].alloc), 0); - ATOMIC_SET(&(rtw_mem_func_stat[i].peak), 0); - ATOMIC_SET(&(rtw_mem_func_stat[i].alloc_cnt), 0); - ATOMIC_SET(&(rtw_mem_func_stat[i].alloc_err_cnt), 0); + atomic_set(&(rtw_mem_func_stat[i].alloc), 0); + atomic_set(&(rtw_mem_func_stat[i].peak), 0); + atomic_set(&(rtw_mem_func_stat[i].alloc_cnt), 0); + atomic_set(&(rtw_mem_func_stat[i].alloc_err_cnt), 0); } #endif } switch (status) { case MSTAT_ALLOC_SUCCESS: - ATOMIC_INC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); - alloc = ATOMIC_ADD_RETURN(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); - peak = ATOMIC_READ(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak)); + atomic_inc(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); + alloc = atomic_add_RETURN(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); + peak = atomic_read(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak)); if (peak < alloc) - ATOMIC_SET(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak), alloc); + atomic_set(&(rtw_mem_type_stat[mstat_tf_idx(flags)].peak), alloc); #ifdef RTW_MEM_FUNC_STAT - ATOMIC_INC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); - alloc = ATOMIC_ADD_RETURN(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); - peak = ATOMIC_READ(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak)); + atomic_inc(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); + alloc = atomic_add_RETURN(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); + peak = atomic_read(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak)); if (peak < alloc) - ATOMIC_SET(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak), alloc); + atomic_set(&(rtw_mem_func_stat[mstat_ff_idx(flags)].peak), alloc); #endif break; case MSTAT_ALLOC_FAIL: - ATOMIC_INC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_err_cnt)); + atomic_inc(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_err_cnt)); #ifdef RTW_MEM_FUNC_STAT - ATOMIC_INC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_err_cnt)); + atomic_inc(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_err_cnt)); #endif break; case MSTAT_FREE: - ATOMIC_DEC(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); - ATOMIC_SUB(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); + atomic_dec(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc_cnt)); + atomic_sub(&(rtw_mem_type_stat[mstat_tf_idx(flags)].alloc), sz); #ifdef RTW_MEM_FUNC_STAT - ATOMIC_DEC(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); - ATOMIC_SUB(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); + atomic_dec(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc_cnt)); + atomic_sub(&(rtw_mem_func_stat[mstat_ff_idx(flags)].alloc), sz); #endif break; }; @@ -1961,137 +1953,6 @@ inline int rtw_test_and_clear_bit(int nr, unsigned long *addr) #endif } -inline void ATOMIC_SET(ATOMIC_T *v, int i) -{ -#ifdef PLATFORM_LINUX - atomic_set(v, i); -#elif defined(PLATFORM_WINDOWS) - *v = i; /* other choice???? */ -#elif defined(PLATFORM_FREEBSD) - atomic_set_int(v, i); -#endif -} - -inline int ATOMIC_READ(ATOMIC_T *v) -{ -#ifdef PLATFORM_LINUX - return atomic_read(v); -#elif defined(PLATFORM_WINDOWS) - return *v; /* other choice???? */ -#elif defined(PLATFORM_FREEBSD) - return atomic_load_acq_32(v); -#endif -} - -inline void ATOMIC_ADD(ATOMIC_T *v, int i) -{ -#ifdef PLATFORM_LINUX - atomic_add(i, v); -#elif defined(PLATFORM_WINDOWS) - InterlockedAdd(v, i); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, i); -#endif -} -inline void ATOMIC_SUB(ATOMIC_T *v, int i) -{ -#ifdef PLATFORM_LINUX - atomic_sub(i, v); -#elif defined(PLATFORM_WINDOWS) - InterlockedAdd(v, -i); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, i); -#endif -} - -inline void ATOMIC_INC(ATOMIC_T *v) -{ -#ifdef PLATFORM_LINUX - atomic_inc(v); -#elif defined(PLATFORM_WINDOWS) - InterlockedIncrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, 1); -#endif -} - -inline void ATOMIC_DEC(ATOMIC_T *v) -{ -#ifdef PLATFORM_LINUX - atomic_dec(v); -#elif defined(PLATFORM_WINDOWS) - InterlockedDecrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, 1); -#endif -} - -inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) -{ -#ifdef PLATFORM_LINUX - return atomic_add_return(i, v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedAdd(v, i); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, i); - return atomic_load_acq_32(v); -#endif -} - -inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) -{ -#ifdef PLATFORM_LINUX - return atomic_sub_return(i, v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedAdd(v, -i); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, i); - return atomic_load_acq_32(v); -#endif -} - -inline int ATOMIC_INC_RETURN(ATOMIC_T *v) -{ -#ifdef PLATFORM_LINUX - return atomic_inc_return(v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedIncrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_add_int(v, 1); - return atomic_load_acq_32(v); -#endif -} - -inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) -{ -#ifdef PLATFORM_LINUX - return atomic_dec_return(v); -#elif defined(PLATFORM_WINDOWS) - return InterlockedDecrement(v); -#elif defined(PLATFORM_FREEBSD) - atomic_subtract_int(v, 1); - return atomic_load_acq_32(v); -#endif -} - -inline bool ATOMIC_INC_UNLESS(ATOMIC_T *v, int u) -{ -#ifdef PLATFORM_LINUX -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 15)) - return atomic_add_unless(v, 1, u); -#else - /* only make sure not exceed after this function */ - if (ATOMIC_INC_RETURN(v) > u) { - ATOMIC_DEC(v); - return 0; - } - return 1; -#endif -#else - #error "TBD\n" -#endif -} - #ifdef PLATFORM_LINUX /* * Open a file with the specific @param path, @param flag, @param mode