From patchwork Mon Feb 14 23:21:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Buesch X-Patchwork-Id: 557281 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1ENM7Nf001994 for ; Mon, 14 Feb 2011 23:22:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431Ab1BNXWG (ORCPT ); Mon, 14 Feb 2011 18:22:06 -0500 Received: from 80-190-117-144.ip-home.de ([80.190.117.144]:34750 "EHLO bu3sch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751799Ab1BNXWE (ORCPT ); Mon, 14 Feb 2011 18:22:04 -0500 Received: by bu3sch.de with esmtpsa (Exim 4.69) (envelope-from ) id 1Pp7k1-0007zD-DD; Tue, 15 Feb 2011 00:22:01 +0100 Subject: [PATCH] ssb: Make ssb_wait_bit multi-bit safe From: Michael =?ISO-8859-1?Q?B=FCsch?= To: John Linville Cc: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= , b43-dev , linux-wireless Date: Tue, 15 Feb 2011 00:21:50 +0100 Message-ID: <1297725710.5683.17.camel@maggie> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 14 Feb 2011 23:22:13 +0000 (UTC) Index: wireless-testing/drivers/ssb/main.c =================================================================== --- wireless-testing.orig/drivers/ssb/main.c 2010-12-30 15:49:39.235946210 +0100 +++ wireless-testing/drivers/ssb/main.c 2011-02-15 00:17:35.727816704 +0100 @@ -1192,10 +1192,10 @@ void ssb_device_enable(struct ssb_device } EXPORT_SYMBOL(ssb_device_enable); -/* Wait for a bit in a register to get set or unset. +/* Wait for bitmask in a register to get set or cleared. * timeout is in units of ten-microseconds */ -static int ssb_wait_bit(struct ssb_device *dev, u16 reg, u32 bitmask, - int timeout, int set) +static int ssb_wait_bits(struct ssb_device *dev, u16 reg, u32 bitmask, + int timeout, int set) { int i; u32 val; @@ -1203,7 +1203,7 @@ static int ssb_wait_bit(struct ssb_devic for (i = 0; i < timeout; i++) { val = ssb_read32(dev, reg); if (set) { - if (val & bitmask) + if ((val & bitmask) == bitmask) return 0; } else { if (!(val & bitmask)) @@ -1227,8 +1227,8 @@ void ssb_device_disable(struct ssb_devic reject = ssb_tmslow_reject_bitmask(dev); ssb_write32(dev, SSB_TMSLOW, reject | SSB_TMSLOW_CLOCK); - ssb_wait_bit(dev, SSB_TMSLOW, reject, 1000, 1); - ssb_wait_bit(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0); + ssb_wait_bits(dev, SSB_TMSLOW, reject, 1000, 1); + ssb_wait_bits(dev, SSB_TMSHIGH, SSB_TMSHIGH_BUSY, 1000, 0); ssb_write32(dev, SSB_TMSLOW, SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | reject | SSB_TMSLOW_RESET |