Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 781b14a3 authored by Sujith Manoharan's avatar Sujith Manoharan Committed by John W. Linville
Browse files

ath9k: Use atomic operations



The 'sc_flags' variable is being used in a number of places
with no locking whatsoever. This patch converts the usage
of sc_flags to atomic ops.

Signed-off-by: default avatarSujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 8da07830
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ static int ath_ahb_probe(struct platform_device *pdev)
	sc->irq = irq;

	/* Will be cleared in ath9k_start() */
	sc->sc_flags |= SC_OP_INVALID;
	set_bit(SC_OP_INVALID, &sc->sc_flags);

	ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc);
	if (ret) {
+9 −7
Original line number Diff line number Diff line
@@ -604,12 +604,14 @@ void ath_ant_comb_update(struct ath_softc *sc);
#define ATH_TXPOWER_MAX         100     /* .5 dBm units */
#define ATH_RATE_DUMMY_MARKER   0

#define SC_OP_INVALID                BIT(0)
#define SC_OP_BEACONS                BIT(1)
#define SC_OP_RXFLUSH                BIT(2)
#define SC_OP_TSF_RESET              BIT(3)
#define SC_OP_ANI_RUN                BIT(4)
#define SC_OP_PRIM_STA_VIF           BIT(5)
enum sc_op_flags {
	SC_OP_INVALID,
	SC_OP_BEACONS,
	SC_OP_RXFLUSH,
	SC_OP_TSF_RESET,
	SC_OP_ANI_RUN,
	SC_OP_PRIM_STA_VIF,
};

/* Powersave flags */
#define PS_WAIT_FOR_BEACON        BIT(0)
@@ -655,9 +657,9 @@ struct ath_softc {
	struct completion paprd_complete;

	unsigned int hw_busy_count;
	unsigned long sc_flags;

	u32 intrstatus;
	u32 sc_flags; /* SC_OP_* */
	u16 ps_flags; /* PS_* */
	u16 curtxpow;
	bool ps_enabled;
+9 −9
Original line number Diff line number Diff line
@@ -390,7 +390,7 @@ void ath_beacon_tasklet(unsigned long data)
		} else if (sc->beacon.bmisscnt >= BSTUCK_THRESH) {
			ath_dbg(common, BSTUCK, "beacon is officially stuck\n");
			sc->beacon.bmisscnt = 0;
			sc->sc_flags |= SC_OP_TSF_RESET;
			set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
			ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
		}

@@ -480,16 +480,16 @@ static void ath9k_beacon_init(struct ath_softc *sc,
			      u32 next_beacon,
			      u32 beacon_period)
{
	if (sc->sc_flags & SC_OP_TSF_RESET) {
	if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) {
		ath9k_ps_wakeup(sc);
		ath9k_hw_reset_tsf(sc->sc_ah);
	}

	ath9k_hw_beaconinit(sc->sc_ah, next_beacon, beacon_period);

	if (sc->sc_flags & SC_OP_TSF_RESET) {
	if (test_bit(SC_OP_TSF_RESET, &sc->sc_flags)) {
		ath9k_ps_restore(sc);
		sc->sc_flags &= ~SC_OP_TSF_RESET;
		clear_bit(SC_OP_TSF_RESET, &sc->sc_flags);
	}
}

@@ -519,7 +519,7 @@ static void ath_beacon_config_ap(struct ath_softc *sc,
	/* Set the computed AP beacon timers */

	ath9k_hw_disable_interrupts(ah);
	sc->sc_flags |= SC_OP_TSF_RESET;
	set_bit(SC_OP_TSF_RESET, &sc->sc_flags);
	ath9k_beacon_init(sc, nexttbtt, intval);
	sc->beacon.bmisscnt = 0;
	ath9k_hw_set_interrupts(ah);
@@ -662,7 +662,7 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc,
	u32 tsf, intval, nexttbtt;

	ath9k_reset_beacon_status(sc);
	if (!(sc->sc_flags & SC_OP_BEACONS))
	if (!test_bit(SC_OP_BEACONS, &sc->sc_flags))
		ath9k_hw_settsf64(ah, sc->beacon.bc_tstamp);

	intval = TU_TO_USEC(conf->beacon_interval);
@@ -727,7 +727,7 @@ static bool ath9k_allow_beacon_config(struct ath_softc *sc,
	 */
	if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) &&
	    (vif->type == NL80211_IFTYPE_STATION) &&
	    (sc->sc_flags & SC_OP_BEACONS) &&
	    test_bit(SC_OP_BEACONS, &sc->sc_flags) &&
	    !avp->primary_sta_vif) {
		ath_dbg(common, CONFIG,
			"Beacon already configured for a station interface\n");
@@ -813,7 +813,7 @@ void ath_set_beacon(struct ath_softc *sc)
		return;
	}

	sc->sc_flags |= SC_OP_BEACONS;
	set_bit(SC_OP_BEACONS, &sc->sc_flags);
}

void ath9k_set_beaconing_status(struct ath_softc *sc, bool status)
@@ -821,7 +821,7 @@ void ath9k_set_beaconing_status(struct ath_softc *sc, bool status)
	struct ath_hw *ah = sc->sc_ah;

	if (!ath_has_valid_bslot(sc)) {
		sc->sc_flags &= ~SC_OP_BEACONS;
		clear_bit(SC_OP_BEACONS, &sc->sc_flags);
		return;
	}

+3 −3
Original line number Diff line number Diff line
@@ -205,10 +205,10 @@ static ssize_t write_file_disable_ani(struct file *file,
	common->disable_ani = !!disable_ani;

	if (disable_ani) {
		sc->sc_flags &= ~SC_OP_ANI_RUN;
		clear_bit(SC_OP_ANI_RUN, &sc->sc_flags);
		del_timer_sync(&common->ani.timer);
	} else {
		sc->sc_flags |= SC_OP_ANI_RUN;
		set_bit(SC_OP_ANI_RUN, &sc->sc_flags);
		ath_start_ani(common);
	}

@@ -1321,7 +1321,7 @@ static int open_file_bb_mac_samps(struct inode *inode, struct file *file)
	u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
	u8 nread;

	if (sc->sc_flags & SC_OP_INVALID)
	if (test_bit(SC_OP_INVALID, &sc->sc_flags))
		return -EAGAIN;

	buf = vmalloc(size);
+2 −2
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ void ath_start_rx_poll(struct ath_softc *sc, u8 nbeacon)
	if (!AR_SREV_9300(sc->sc_ah))
		return;

	if (!(sc->sc_flags & SC_OP_PRIM_STA_VIF))
	if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags))
		return;

	mod_timer(&sc->rx_poll_timer, jiffies + msecs_to_jiffies
@@ -430,7 +430,7 @@ void ath_start_ani(struct ath_common *common)
	unsigned long timestamp = jiffies_to_msecs(jiffies);
	struct ath_softc *sc = (struct ath_softc *) common->priv;

	if (!(sc->sc_flags & SC_OP_ANI_RUN))
	if (!test_bit(SC_OP_ANI_RUN, &sc->sc_flags))
		return;

	if (sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)
Loading