Skip to contentSkip to conversation

ath9: endianess fixes

PATCH In review Christoph Hellwig 2 participants 2 messages Jul 23, 2008 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9: endianess fixes

- in ath_beacon_alloc use a __le64 variable to store a byte swapped result. Keep printing the unshifted native variable.
- in ath_bar_rx add a missing le16_to_cpu for bar->control
- in ath_rx_tasklet add a missing cpu_to_be16 for skb->protocol

drivers/net/wireless/ath9k/beacon.c +3 -2
Index: linux-2.6/drivers/net/wireless/ath9k/beacon.c
===================================================================
@@ -440,6 +440,7 @@ int ath_beacon_alloc(struct ath_softc *s
 	 */
 	if (sc->sc_stagbeacons && avp->av_bslot > 0) {
 		u_int64_t tsfadjust;
+		__le64 val;
 		int intval;
 
 		/* FIXME: Use default value for now: Sujith */
@@ -458,7 +459,7 @@ int ath_beacon_alloc(struct ath_softc *s
 		 * others get a timestamp aligned to the next interval.
 		 */
 		tsfadjust = (intval * (ATH_BCBUF - avp->av_bslot)) / ATH_BCBUF;
-		tsfadjust = cpu_to_le64(tsfadjust<<10);     /* TU->TSF */
+		val = cpu_to_le64(tsfadjust << 10);     /* TU->TSF */
 
 		DPRINTF(sc, ATH_DEBUG_BEACON,
 			"%s: %s beacons, bslot %d intval %u tsfadjust %llu\n",
@@ -466,7 +467,7 @@ int ath_beacon_alloc(struct ath_softc *s
 			avp->av_bslot, intval, (unsigned long long)tsfadjust);
 
 		wh = (struct ieee80211_hdr *)skb->data;
-		memcpy(&wh[1], &tsfadjust, sizeof(tsfadjust));
+		memcpy(&wh[1], &val, sizeof(val));
 	}
 
 	bf->bf_buf_addr = ath_skb_map_single(sc, skb, PCI_DMA_TODEVICE,
drivers/net/wireless/ath9k/recv.c +2 -2
Index: linux-2.6/drivers/net/wireless/ath9k/recv.c
===================================================================
@@ -80,7 +80,7 @@ static int ath_bar_rx(struct ath_softc *
 	/* look at BAR contents	 */
 
 	bar = (struct ieee80211_bar *)skb->data;
-	tidno = (bar->control & IEEE80211_BAR_CTL_TID_M)
+	tidno = (le16_to_cpu(bar->control) & IEEE80211_BAR_CTL_TID_M)
 		>> IEEE80211_BAR_CTL_TID_S;
 	seqno = le16_to_cpu(bar->start_seq_num) >> IEEE80211_SEQ_SEQ_SHIFT;
 
@@ -1026,7 +1026,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
 		 * to receive another frame.
 		 */
 		skb_put(skb, ds->ds_rxstat.rs_datalen);
-		skb->protocol = ETH_P_CONTROL;
+		skb->protocol = cpu_to_be16(ETH_P_CONTROL);
 		rx_status.tsf = ath_extend_tsf(sc, ds->ds_rxstat.rs_tstamp);
 		rx_status.rateieee =
 			sc->sc_hwmap[ds->ds_rxstat.rs_rate].ieeerate;