Skip to content

Commit

Permalink
mac80211: pid: replace open-coded msecs_to_jiffies
Browse files Browse the repository at this point in the history
Code directly scaling by HZ and rounding can be more efficiently
and clearly performed with msecs_to_jiffies.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Bob Copeland authored and John W. Linville committed Jan 19, 2010
1 parent 1f44780 commit 8e9310c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions net/mac80211/rc80211_pid_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,7 @@ static void rate_control_pid_sample(struct rc_pid_info *pinfo,

/* In case nothing happened during the previous control interval, turn
* the sharpening factor on. */
period = (HZ * pinfo->sampling_period + 500) / 1000;
if (!period)
period = 1;
period = msecs_to_jiffies(pinfo->sampling_period);
if (jiffies - spinfo->last_sample > 2 * period)
spinfo->sharp_cnt = pinfo->sharpen_duration;

Expand Down Expand Up @@ -252,9 +250,7 @@ static void rate_control_pid_tx_status(void *priv, struct ieee80211_supported_ba
}

/* Update PID controller state. */
period = (HZ * pinfo->sampling_period + 500) / 1000;
if (!period)
period = 1;
period = msecs_to_jiffies(pinfo->sampling_period);
if (time_after(jiffies, spinfo->last_sample + period))
rate_control_pid_sample(pinfo, sband, sta, spinfo);
}
Expand Down

0 comments on commit 8e9310c

Please sign in to comment.