Skip to contentSkip to conversation

ath5k: fix all endian issues reported by sparse

PATCH In review Pavel Roskin 3 participants 3 messages Feb 26, 2008 – Feb 27, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath5k: fix all endian issues reported by sparse

Changes-licensed-under: ISC

---

 drivers/net/wireless/ath5k/base.c |    8 ++++----
 drivers/net/wireless/ath5k/hw.c   |    4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/ath5k/base.c +4 -4
index 0b743f7..393b5f3 100644
@@ -1717,11 +1717,11 @@ ath5k_check_ibss_hw_merge(struct ath5k_softc *sc, struct sk_buff *skb)
 	u32 hw_tu;
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
 
-	if ((mgmt->frame_control & IEEE80211_FCTL_FTYPE) ==
+	if ((le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_FTYPE) ==
 		IEEE80211_FTYPE_MGMT &&
-	    (mgmt->frame_control & IEEE80211_FCTL_STYPE) ==
+	    (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) ==
 		IEEE80211_STYPE_BEACON &&
-	    mgmt->u.beacon.capab_info & WLAN_CAPABILITY_IBSS &&
+	    le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
 	    memcmp(mgmt->bssid, sc->ah->ah_bssid, ETH_ALEN) == 0) {
 		/*
 		 * Received an IBSS beacon with the same BSSID. Hardware might
@@ -1730,7 +1730,7 @@ ath5k_check_ibss_hw_merge(struct ath5k_softc *sc, struct sk_buff *skb)
 		hw_tu = TSF_TO_TU(ath5k_hw_get_tsf64(sc->ah));
 		if (hw_tu >= sc->nexttbtt) {
 			ath5k_beacon_update_timers(sc,
-				mgmt->u.beacon.timestamp);
+				le64_to_cpu(mgmt->u.beacon.timestamp));
 			ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON,
 				"detected HW merge from received beacon\n");
 		}
drivers/net/wireless/ath5k/hw.c +2 -2
index 998da6b..eec2b80 100644
@@ -531,8 +531,8 @@ static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah,
 		 * actual rate for this rate. See mac80211 tx.c
 		 * ieee80211_duration() for a brief description of
 		 * what rate we should choose to TX ACKs. */
-		tx_time = ieee80211_generic_frame_duration(sc->hw,
-			sc->vif, 10, &srate);
+		tx_time = le16_to_cpu(ieee80211_generic_frame_duration(sc->hw,
+							sc->vif, 10, &srate));
 
 		ath5k_hw_reg_write(ah, tx_time, reg);
 
Acked-by on v1 1/1
#2 lore raw
In reply to Pavel Roskin

2008/2/27, Pavel Roskin <[email protected]>:

Quoted 49 lines

Changes-licensed-under: ISC

---

  drivers/net/wireless/ath5k/base.c |    8 ++++----
  drivers/net/wireless/ath5k/hw.c   |    4 ++--
  2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c index 0b743f7..393b5f3 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -1717,11 +1717,11 @@ ath5k_check_ibss_hw_merge(struct ath5k_softc *sc, struct sk_buff *skb)

        u32 hw_tu;
        struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;

- if ((mgmt->frame_control & IEEE80211_FCTL_FTYPE) ==
+ if ((le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_FTYPE) ==

                IEEE80211_FTYPE_MGMT &&
 -           (mgmt->frame_control & IEEE80211_FCTL_STYPE) ==
 +           (le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE) ==
                IEEE80211_STYPE_BEACON &&
 -           mgmt->u.beacon.capab_info & WLAN_CAPABILITY_IBSS &&
 +           le16_to_cpu(mgmt->u.beacon.capab_info) & WLAN_CAPABILITY_IBSS &&
            memcmp(mgmt->bssid, sc->ah->ah_bssid, ETH_ALEN) == 0) {
                /*
                 * Received an IBSS beacon with the same BSSID. Hardware might
 @@ -1730,7 +1730,7 @@ ath5k_check_ibss_hw_merge(struct ath5k_softc *sc, struct sk_buff *skb)
                hw_tu = TSF_TO_TU(ath5k_hw_get_tsf64(sc->ah));
                if (hw_tu >= sc->nexttbtt) {
                        ath5k_beacon_update_timers(sc,
 -                               mgmt->u.beacon.timestamp);
 +                               le64_to_cpu(mgmt->u.beacon.timestamp));
                        ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON,
                                "detected HW merge from received beacon\n");
                }

diff --git a/drivers/net/wireless/ath5k/hw.c b/drivers/net/wireless/ath5k/hw.c index 998da6b..eec2b80 100644
--- a/drivers/net/wireless/ath5k/hw.c
+++ b/drivers/net/wireless/ath5k/hw.c
@@ -531,8 +531,8 @@ static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah,
* actual rate for this rate. See mac80211 tx.c
* ieee80211_duration() for a brief description of
* what rate we should choose to TX ACKs. */
- tx_time = ieee80211_generic_frame_duration(sc->hw,
- sc->vif, 10, &srate);
+ tx_time = le16_to_cpu(ieee80211_generic_frame_duration(sc->hw,
+ sc->vif, 10, &srate));

Quoted 2 lines
                ath5k_hw_reg_write(ah, tx_time, reg);
Signature · 3 lines
GPG ID: 0xD21DB2DB
As you read this post global entropy rises. Have Fun ;-)
Nick