From patchwork Tue Sep 7 01:24:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 159641 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 o871O43k028531 for ; Tue, 7 Sep 2010 01:24:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755487Ab0IGBYD (ORCPT ); Mon, 6 Sep 2010 21:24:03 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:38699 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754017Ab0IGBYB (ORCPT ); Mon, 6 Sep 2010 21:24:01 -0400 Received: by bwz11 with SMTP id 11so3713457bwz.19 for ; Mon, 06 Sep 2010 18:24:00 -0700 (PDT) Received: by 10.204.79.223 with SMTP id q31mr3770113bkk.92.1283822640162; Mon, 06 Sep 2010 18:24:00 -0700 (PDT) Received: from localhost.localdomain (46-116-15-195.bb.netvision.net.il [46.116.15.195]) by mx.google.com with ESMTPS id g12sm4783149bkb.2.2010.09.06.18.23.54 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 06 Sep 2010 18:23:56 -0700 (PDT) From: Ohad Ben-Cohen To: Cc: Luciano Coelho , Ohad Ben-Cohen Subject: [PATCH] wl1271: sdio: claim host only when doing IO Date: Tue, 7 Sep 2010 04:24:21 +0300 Message-Id: <1283822661-16018-1-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.0.4 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 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 01:24:05 +0000 (UTC) diff --git a/drivers/net/wireless/wl12xx/wl1271_sdio.c b/drivers/net/wireless/wl12xx/wl1271_sdio.c index 7059b5c..b3c3158 100644 --- a/drivers/net/wireless/wl12xx/wl1271_sdio.c +++ b/drivers/net/wireless/wl12xx/wl1271_sdio.c @@ -107,6 +107,8 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, int ret; struct sdio_func *func = wl_to_func(wl); + sdio_claim_host(func); + if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", @@ -122,9 +124,10 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); } + sdio_release_host(func); + if (ret) wl1271_error("sdio read failed (%d)", ret); - } static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, @@ -133,6 +136,8 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, int ret; struct sdio_func *func = wl_to_func(wl); + sdio_claim_host(func); + if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x", @@ -147,9 +152,33 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, else ret = sdio_memcpy_toio(func, addr, buf, len); } + + sdio_release_host(func); + if (ret) wl1271_error("sdio write failed (%d)", ret); +} + +static int wl1271_sdio_power_on(struct wl1271 *wl) +{ + struct sdio_func *func = wl_to_func(wl); + + sdio_claim_host(func); + sdio_enable_func(func); + sdio_release_host(func); + return 0; +} + +static int wl1271_sdio_power_off(struct wl1271 *wl) +{ + struct sdio_func *func = wl_to_func(wl); + + sdio_claim_host(func); + sdio_disable_func(func); + sdio_release_host(func); + + return 0; } static void wl1271_sdio_set_power(struct wl1271 *wl, bool enable) @@ -160,13 +189,11 @@ static void wl1271_sdio_set_power(struct wl1271 *wl, bool enable) * keep host claimed while wlan is in use to keep wl1271 * alive. */ - if (enable) { - sdio_claim_host(func); - sdio_enable_func(func); - } else { - sdio_disable_func(func); - sdio_release_host(func); - } + if (enable) + return wl1271_sdio_power_on(wl); + else + return wl1271_sdio_power_off(wl); + } static struct wl1271_if_operations sdio_ops = {