From patchwork Tue Aug 17 19:46:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 120010 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7HJlfXl004169 for ; Tue, 17 Aug 2010 19:49:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752518Ab0HQTr2 (ORCPT ); Tue, 17 Aug 2010 15:47:28 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:61807 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752466Ab0HQTrZ (ORCPT ); Tue, 17 Aug 2010 15:47:25 -0400 Received: by mail-ey0-f174.google.com with SMTP id 5so2243590eyg.19 for ; Tue, 17 Aug 2010 12:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=wHEFBfc24PXtZFdmzWQo2xBdf4UAoCouidrSAP4xazw=; b=VTTuw5N1TkuIMCYA0i/kRPHp7l5xBcbek/sJG332RIeeiCuekkZk9aYeMjKS7rc8/Y dk5yRuJkICRco/in/zsO9J59vD8bM6f7nnNkioCKt+VnoDBRxYi0LG7uYklOTxVItUlv O68MPXPoqZ0ZxzgVjIGGXS0fB0aYTTbaQ0/U4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=nZuwX8d4qE4zxq2v/T+N9qX8ngjMOT7D7hZ/8b+F25X6HfLbL6dHn1kBtb93Ca08ch XcC6efzTQQ+iAuh/e2YnNZB+fDe7EOTB5RoPxzkuRcYzjfKFXYaPXPH/5mmN8BBhXQS+ LvXC0B7GlbUOwRcdqi1v+K3BQjNMx/wH7LRgs= Received: by 10.213.14.208 with SMTP id h16mr6586371eba.14.1282074444586; Tue, 17 Aug 2010 12:47:24 -0700 (PDT) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt [88.119.226.136]) by mx.google.com with ESMTPS id v59sm12710731eeh.22.2010.08.17.12.47.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 17 Aug 2010 12:47:24 -0700 (PDT) From: Grazvydas Ignotas To: "John W. Linville" Cc: linux-wireless@vger.kernel.org, Kalle Valo , Grazvydas Ignotas Subject: [PATCH 4/4] wl1251: wait for join command complete event Date: Tue, 17 Aug 2010 22:46:55 +0300 Message-Id: <1282074415-6168-5-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1282074415-6168-1-git-send-email-notasas@gmail.com> References: <1282074415-6168-1-git-send-email-notasas@gmail.com> 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 17 Aug 2010 19:49:19 +0000 (UTC) diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c index 65e0416..5e65f47 100644 --- a/drivers/net/wireless/wl12xx/wl1251_boot.c +++ b/drivers/net/wireless/wl12xx/wl1251_boot.c @@ -302,7 +302,7 @@ int wl1251_boot_run_firmware(struct wl1251 *wl) ROAMING_TRIGGER_LOW_RSSI_EVENT_ID | ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID | REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID | - BT_PTA_PREDICTION_EVENT_ID; + BT_PTA_PREDICTION_EVENT_ID | JOIN_EVENT_COMPLETE_ID; ret = wl1251_event_unmask(wl); if (ret < 0) { diff --git a/drivers/net/wireless/wl12xx/wl1251_event.c b/drivers/net/wireless/wl12xx/wl1251_event.c index 020d764..e093a1c 100644 --- a/drivers/net/wireless/wl12xx/wl1251_event.c +++ b/drivers/net/wireless/wl12xx/wl1251_event.c @@ -97,6 +97,35 @@ static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) return 0; } +/* + * Poll the mailbox event field until any of the bits in the mask is set or a + * timeout occurs (WL1251_EVENT_TIMEOUT in msecs) + */ +int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms) +{ + u32 events_vector, event; + unsigned long timeout; + + timeout = jiffies + msecs_to_jiffies(timeout_ms); + + do { + if (time_after(jiffies, timeout)) + return -ETIMEDOUT; + + msleep(1); + + /* read from both event fields */ + wl1251_mem_read(wl, wl->mbox_ptr[0], &events_vector, + sizeof(events_vector)); + event = events_vector & mask; + wl1251_mem_read(wl, wl->mbox_ptr[1], &events_vector, + sizeof(events_vector)); + event |= events_vector & mask; + } while (!event); + + return 0; +} + int wl1251_event_unmask(struct wl1251 *wl) { int ret; diff --git a/drivers/net/wireless/wl12xx/wl1251_event.h b/drivers/net/wireless/wl12xx/wl1251_event.h index f48a2b6..ec45647 100644 --- a/drivers/net/wireless/wl12xx/wl1251_event.h +++ b/drivers/net/wireless/wl12xx/wl1251_event.h @@ -117,5 +117,6 @@ struct event_mailbox { int wl1251_event_unmask(struct wl1251 *wl); void wl1251_event_mbox_config(struct wl1251 *wl); int wl1251_event_handle(struct wl1251 *wl, u8 mbox); +int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms); #endif diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c index 51474b6..c81e95b 100644 --- a/drivers/net/wireless/wl12xx/wl1251_main.c +++ b/drivers/net/wireless/wl12xx/wl1251_main.c @@ -339,11 +339,9 @@ static int wl1251_join(struct wl1251 *wl, u8 bss_type, u8 channel, if (ret < 0) goto out; - /* - * FIXME: we should wait for JOIN_EVENT_COMPLETE_ID but to simplify - * locking we just sleep instead, for now - */ - msleep(10); + ret = wl1251_event_wait(wl, JOIN_EVENT_COMPLETE_ID, 100); + if (ret < 0) + wl1251_warning("join timeout"); out: return ret;