wifi: ath12k: Introduce and use ath12k_sta_to_arsta()
Currently, the logic to return an ath12k_sta pointer, given a ieee80211_sta pointer, uses typecasting throughout the driver. In general, conversion functions are preferable to typecasting since using a conversion function allows the compiler to validate the types of both the input and output parameters. ath12k already defines a conversion function ath12k_vif_to_arvif() for a similar conversion. So introduce ath12k_sta_to_arsta() for this use case, and convert all of the existing typecasting to use this function. Signed-off-by: Jeff Johnson <quic_jjohnson@quicinc.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://lore.kernel.org/r/20231019-upstream-ath12k_sta_to_arsta-v1-1-06f06f693338@quicinc.com
This commit is contained in:
parent
6afc57ea31
commit
9ef118152e
@ -852,6 +852,11 @@ static inline struct ath12k_vif *ath12k_vif_to_arvif(struct ieee80211_vif *vif)
|
||||
return (struct ath12k_vif *)vif->drv_priv;
|
||||
}
|
||||
|
||||
static inline struct ath12k_sta *ath12k_sta_to_arsta(struct ieee80211_sta *sta)
|
||||
{
|
||||
return (struct ath12k_sta *)sta->drv_priv;
|
||||
}
|
||||
|
||||
static inline struct ath12k *ath12k_ab_to_ar(struct ath12k_base *ab,
|
||||
int mac_id)
|
||||
{
|
||||
|
@ -2374,7 +2374,7 @@ ath12k_dp_mon_rx_update_user_stats(struct ath12k *ar,
|
||||
return;
|
||||
}
|
||||
|
||||
arsta = (struct ath12k_sta *)peer->sta->drv_priv;
|
||||
arsta = ath12k_sta_to_arsta(peer->sta);
|
||||
rx_stats = arsta->rx_stats;
|
||||
|
||||
if (!rx_stats)
|
||||
@ -2550,7 +2550,7 @@ int ath12k_dp_mon_rx_process_stats(struct ath12k *ar, int mac_id,
|
||||
}
|
||||
|
||||
if (ppdu_info->reception_type == HAL_RX_RECEPTION_TYPE_SU) {
|
||||
arsta = (struct ath12k_sta *)peer->sta->drv_priv;
|
||||
arsta = ath12k_sta_to_arsta(peer->sta);
|
||||
ath12k_dp_mon_rx_update_peer_su_stats(ar, arsta,
|
||||
ppdu_info);
|
||||
} else if ((ppdu_info->fc_valid) &&
|
||||
|
@ -1054,7 +1054,7 @@ int ath12k_dp_rx_ampdu_start(struct ath12k *ar,
|
||||
struct ieee80211_ampdu_params *params)
|
||||
{
|
||||
struct ath12k_base *ab = ar->ab;
|
||||
struct ath12k_sta *arsta = (void *)params->sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(params->sta);
|
||||
int vdev_id = arsta->arvif->vdev_id;
|
||||
int ret;
|
||||
|
||||
@ -1072,7 +1072,7 @@ int ath12k_dp_rx_ampdu_stop(struct ath12k *ar,
|
||||
{
|
||||
struct ath12k_base *ab = ar->ab;
|
||||
struct ath12k_peer *peer;
|
||||
struct ath12k_sta *arsta = (void *)params->sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(params->sta);
|
||||
int vdev_id = arsta->arvif->vdev_id;
|
||||
bool active;
|
||||
int ret;
|
||||
@ -1410,7 +1410,7 @@ ath12k_update_per_peer_tx_stats(struct ath12k *ar,
|
||||
}
|
||||
|
||||
sta = peer->sta;
|
||||
arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
arsta = ath12k_sta_to_arsta(sta);
|
||||
|
||||
memset(&arsta->txrate, 0, sizeof(arsta->txrate));
|
||||
|
||||
|
@ -3247,7 +3247,7 @@ static int ath12k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
||||
ath12k_warn(ab, "peer %pM disappeared!\n", peer_addr);
|
||||
|
||||
if (sta) {
|
||||
arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
arsta = ath12k_sta_to_arsta(sta);
|
||||
|
||||
switch (key->cipher) {
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
@ -3637,7 +3637,7 @@ static int ath12k_mac_station_add(struct ath12k *ar,
|
||||
{
|
||||
struct ath12k_base *ab = ar->ab;
|
||||
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
|
||||
struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
|
||||
struct ath12k_wmi_peer_create_arg peer_param;
|
||||
int ret;
|
||||
|
||||
@ -3744,7 +3744,7 @@ static int ath12k_mac_op_sta_state(struct ieee80211_hw *hw,
|
||||
{
|
||||
struct ath12k *ar = hw->priv;
|
||||
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
|
||||
struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
|
||||
struct ath12k_peer *peer;
|
||||
int ret = 0;
|
||||
|
||||
@ -3892,7 +3892,7 @@ static void ath12k_mac_op_sta_rc_update(struct ieee80211_hw *hw,
|
||||
u32 changed)
|
||||
{
|
||||
struct ath12k *ar = hw->priv;
|
||||
struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
|
||||
struct ath12k_vif *arvif = ath12k_vif_to_arvif(vif);
|
||||
struct ath12k_peer *peer;
|
||||
u32 bw, smps;
|
||||
@ -6762,7 +6762,7 @@ static void ath12k_mac_set_bitrate_mask_iter(void *data,
|
||||
struct ieee80211_sta *sta)
|
||||
{
|
||||
struct ath12k_vif *arvif = data;
|
||||
struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
|
||||
struct ath12k *ar = arvif->ar;
|
||||
|
||||
spin_lock_bh(&ar->data_lock);
|
||||
@ -7051,7 +7051,7 @@ static void ath12k_mac_op_sta_statistics(struct ieee80211_hw *hw,
|
||||
struct ieee80211_sta *sta,
|
||||
struct station_info *sinfo)
|
||||
{
|
||||
struct ath12k_sta *arsta = (struct ath12k_sta *)sta->drv_priv;
|
||||
struct ath12k_sta *arsta = ath12k_sta_to_arsta(sta);
|
||||
|
||||
sinfo->rx_duration = arsta->rx_duration;
|
||||
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_DURATION);
|
||||
|
Loading…
x
Reference in New Issue
Block a user