aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2007-03-05 02:19:06 -0500
committerGuido Guenther <agx@bogon.sigxcpu.org>2007-03-05 10:28:37 +0100
commit4b50804c047272075f07edb5b62d857e3200d6a0 (patch)
tree21e07f0abbcd33fb8ba7fa7b69f025e8836680fb
parent72f691a24e23a3c82dc43a1f4684c91c86dc133c (diff)
[PATCH] Fix divizion by zero in ad-hoc mode
This would happen if the card gets more than one management packet in a jiffy. Fix it by updating qual->qual at most once a second. Measuremensts over a shorter period are meaningless anyway. Signed-off-by: Pavel Roskin <proski@gnu.org>
-rw-r--r--at76_usb.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/at76_usb.c b/at76_usb.c
index 59a5ed5..b3ed6fb 100644
--- a/at76_usb.c
+++ b/at76_usb.c
@@ -3202,9 +3202,15 @@ static void calc_qual(struct at76c503 *dev, struct at76c503_rx_buffer *buf, stru
(dev->board_type == BOARDTYPE_503_INTERSIL_3863)) {
qual->qual=buf->link_quality;
} else {
+ unsigned long msec;
+
+ /* Update qual at most once a second */
+ msec = jiffies_to_msecs(jiffies) - dev->beacons_last_qual;
+ if (msec < 1000)
+ return;
+
qual->qual = qual->level * dev->beacons_received *
- dev->beacon_period /
- (jiffies_to_msecs(jiffies) - dev->beacons_last_qual);
+ dev->beacon_period / msec;
dev->beacons_last_qual = jiffies_to_msecs(jiffies);
dev->beacons_received = 0;