--- airo.c.orig	2004-06-27 18:01:30.000000000 +0200
+++ airo.c	2004-06-28 15:21:50.000000000 +0200
@@ -2968,6 +2968,12 @@
 			airo_send_event(dev);
 		else if (test_bit(JOB_AUTOWEP, &ai->flags))
 			timer_func(dev);
+		else
+			/*
+			 * handle a race condition, when the flags are
+			 * unset just before locking.
+			 */
+			up(&ai->sem);
 	}
 	complete_and_exit (&ai->thr_exited, 0);
 }
@@ -3816,6 +3822,7 @@
 	pRsp->rsp0 = IN4500(ai, RESP0);
 	pRsp->rsp1 = IN4500(ai, RESP1);
 	pRsp->rsp2 = IN4500(ai, RESP2);
+#if 0
 	if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET) {
 		printk (KERN_ERR "airo: cmd= %x\n", pCmd->cmd);
 		printk (KERN_ERR "airo: status= %x\n", pRsp->status);
@@ -3823,6 +3830,7 @@
 		printk (KERN_ERR "airo: Rsp1= %x\n", pRsp->rsp1);
 		printk (KERN_ERR "airo: Rsp2= %x\n", pRsp->rsp2);
 	}
+#endif
 
 	// clear stuck command busy if necessary
 	if (IN4500(ai, COMMAND) & COMMAND_BUSY) {
@@ -5602,6 +5610,27 @@
  * would not work at all... - Jean II
  */
 
+static int airo_get_quality (StatusRid *status_rid, CapabilityRid *cap_rid)
+{
+	int quality = 0;
+
+	if ((status_rid->mode & 0x3f) == 0x3f && (cap_rid->hardCap & 8)) {
+		if (memcmp(cap_rid->prodName, "350", 3))
+			if (status_rid->signalQuality > 0x20)
+				quality = 0;
+			else
+				quality = ((0x20 - status_rid->signalQuality)*100)/0x20;
+		else
+			if (status_rid->signalQuality > 0xb0)
+				quality = 0;
+			else if (status_rid->signalQuality < 0x10)
+				quality = 100;
+			else
+				quality = ((0xb0 - status_rid->signalQuality)*100)/0xa0;
+	}
+	return quality;
+}
+
 /*------------------------------------------------------------------*/
 /*
  * Wireless Handler : get protocol name
@@ -6428,7 +6457,7 @@
 	range->num_frequency = k;
 
 	/* Hum... Should put the right values there */
-	range->max_qual.qual = 10;
+	range->max_qual.qual = 100;
 	range->max_qual.level = 0x100 - 120;	/* -120 dBm */
 	range->max_qual.noise = 0;
 	range->sensitivity = 65535;
@@ -6495,7 +6524,7 @@
 	/* Experimental measurements - boundary 11/5.5 Mb/s */
 	/* Note : with or without the (local->rssi), results
 	 * are somewhat different. - Jean II */
-	range->avg_qual.qual = 6;
+	range->avg_qual.qual = 50;
 	if (local->rssi)
 		range->avg_qual.level = 186;	/* -70 dBm */
 	else
@@ -7109,6 +7138,7 @@
 {
 	StatusRid status_rid;
 	StatsRid stats_rid;
+	CapabilityRid cap_rid;
 	u32 *vals = stats_rid.vals;
 
 	/* Get stats out of the card */
@@ -7117,6 +7147,7 @@
 		up(&local->sem);
 		return;
 	}
+	readCapabilityRid(local, &cap_rid, 0);
 	readStatusRid(local, &status_rid, 0);
 	readStatsRid(local, &stats_rid, RID_STATS, 0);
 	up(&local->sem);
@@ -7125,7 +7156,7 @@
 	local->wstats.status = status_rid.mode;
 
 	/* Signal quality and co. But where is the noise level ??? */
-	local->wstats.qual.qual = status_rid.signalQuality;
+	local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid);
 	if (local->rssi)
 		local->wstats.qual.level = 0x100 - local->rssi[status_rid.sigQuality].rssidBm;
 	else
