From: Peter Stuge Date: Wed, 18 May 2011 03:16:11 +0200 Subject: [ath9k-devel] [RFC] ath9k: Add a debug entry to stop/start ANI In-Reply-To: <1305628166-5929-1-git-send-email-mshajakhan@atheros.com> References: <1305628166-5929-1-git-send-email-mshajakhan@atheros.com> Message-ID: <20110518011611.29521.qmail@stuge.se> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ath9k-devel@lists.ath9k.org Mohammed Shafi Shajakhan wrote: > +static ssize_t read_file_disable_ani(struct file *file, char __user *user_buf, > + size_t count, loff_t *ppos) > +{ > + struct ath_softc *sc = file->private_data; > + struct ath_common *common = ath9k_hw_common(sc->sc_ah); > + char buf[32]; > + unsigned int len; > + > + len = sprintf(buf, "%1d\n", common->disable_ani); > + return simple_read_from_buffer(user_buf, count, ppos, buf, len); > +} Note that %1d does not really guarantee the output length. The buffer is 32 chars so it should be fine, but to really make sure I would len = sprintf(buf, "%d\n", !!common->disable_ani); ..even though this is also done on input. > +static ssize_t write_file_disable_ani(struct file *file, > + const char __user *user_buf, size_t count, loff_t *ppos) > +{ .. > + common->disable_ani = !!(disable_ani); No () strictly needed. common->disable_ani = !!disable_ani; should be fine. > + if (disable_ani) { Would suggest to only use the processed and assigned value once the processing and assignment has been done, to avoid any accidents where the unprocessed value is misinterpreted, and to avoid unneccessary duplication of the processing. > +++ b/drivers/net/wireless/ath/ath9k/main.c > @@ -235,7 +235,8 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, > > sc->hw_busy_count = 0; > > - del_timer_sync(&common->ani.timer); > + if (!(common->disable_ani)) > + del_timer_sync(&common->ani.timer); > cancel_work_sync(&sc->paprd_work); > cancel_work_sync(&sc->hw_check_work); > cancel_delayed_work_sync(&sc->tx_complete_work); > @@ -302,7 +303,8 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, > ath_set_beacon(sc); > ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); > ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/2); > - ath_start_ani(common); > + if (!(common->disable_ani)) > + ath_start_ani(common); Again I personally find without the extra () to be much more readable, but maybe that's even a style violation. //Peter