linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@qca.qualcomm.com>
To: kvalo@qca.qualcomm.com
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 03/10] ath6kl: move power control from sdio to core
Date: Thu, 27 Oct 2011 18:48:14 +0300	[thread overview]
Message-ID: <20111027154814.23519.93093.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20111027154746.23519.39680.stgit@localhost6.localdomain6>

In preparation for cutting down power from the chip on the fly.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/hif-ops.h |   15 +++++++++++++++
 drivers/net/wireless/ath/ath6kl/hif.h     |    2 ++
 drivers/net/wireless/ath/ath6kl/init.c    |   16 ++++++++++++----
 drivers/net/wireless/ath/ath6kl/sdio.c    |   20 ++++++++------------
 4 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/hif-ops.h b/drivers/net/wireless/ath/ath6kl/hif-ops.h
index 95e7303..34adc77 100644
--- a/drivers/net/wireless/ath/ath6kl/hif-ops.h
+++ b/drivers/net/wireless/ath/ath6kl/hif-ops.h
@@ -96,4 +96,19 @@ static inline int ath6kl_hif_resume(struct ath6kl *ar)
 
 	return ar->hif_ops->resume(ar);
 }
+
+static inline int ath6kl_hif_power_on(struct ath6kl *ar)
+{
+	ath6kl_dbg(ATH6KL_DBG_HIF, "hif power on\n");
+
+	return ar->hif_ops->power_on(ar);
+}
+
+static inline int ath6kl_hif_power_off(struct ath6kl *ar)
+{
+	ath6kl_dbg(ATH6KL_DBG_HIF, "hif power off\n");
+
+	return ar->hif_ops->power_off(ar);
+}
+
 #endif
diff --git a/drivers/net/wireless/ath/ath6kl/hif.h b/drivers/net/wireless/ath/ath6kl/hif.h
index 93d2912..ee7c31a 100644
--- a/drivers/net/wireless/ath/ath6kl/hif.h
+++ b/drivers/net/wireless/ath/ath6kl/hif.h
@@ -242,6 +242,8 @@ struct ath6kl_hif_ops {
 	void (*cleanup_scatter)(struct ath6kl *ar);
 	int (*suspend)(struct ath6kl *ar);
 	int (*resume)(struct ath6kl *ar);
+	int (*power_on)(struct ath6kl *ar);
+	int (*power_off)(struct ath6kl *ar);
 };
 
 int ath6kl_hif_setup(struct ath6kl_device *dev);
diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c
index 64975a9..0564add 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -554,6 +554,8 @@ void ath6kl_core_free(struct ath6kl *ar)
 
 void ath6kl_core_cleanup(struct ath6kl *ar)
 {
+	ath6kl_hif_power_off(ar);
+
 	destroy_workqueue(ar->ath6kl_wq);
 
 	if (ar->htc_target)
@@ -1601,27 +1603,31 @@ int ath6kl_core_init(struct ath6kl *ar)
 	if (ret)
 		goto err_wq;
 
-	ret = ath6kl_bmi_get_target_info(ar, &targ_info);
+	ret = ath6kl_hif_power_on(ar);
 	if (ret)
 		goto err_bmi_cleanup;
 
+	ret = ath6kl_bmi_get_target_info(ar, &targ_info);
+	if (ret)
+		goto err_power_off;
+
 	ar->version.target_ver = le32_to_cpu(targ_info.version);
 	ar->target_type = le32_to_cpu(targ_info.type);
 	ar->wiphy->hw_version = le32_to_cpu(targ_info.version);
 
 	ret = ath6kl_init_hw_params(ar);
 	if (ret)
-		goto err_bmi_cleanup;
+		goto err_power_off;
 
 	ret = ath6kl_configure_target(ar);
 	if (ret)
-		goto err_bmi_cleanup;
+		goto err_power_off;
 
 	ar->htc_target = ath6kl_htc_create(ar);
 
 	if (!ar->htc_target) {
 		ret = -ENOMEM;
-		goto err_bmi_cleanup;
+		goto err_power_off;
 	}
 
 	ret = ath6kl_fetch_firmwares(ar);
@@ -1640,6 +1646,8 @@ int ath6kl_core_init(struct ath6kl *ar)
 
 err_htc_cleanup:
 	ath6kl_htc_cleanup(ar->htc_target);
+err_power_off:
+	ath6kl_hif_power_off(ar);
 err_bmi_cleanup:
 	ath6kl_bmi_cleanup(ar);
 err_wq:
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index 5ce0b8b..682c47c 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -463,8 +463,9 @@ static void ath6kl_sdio_irq_handler(struct sdio_func *func)
 	WARN_ON(status && status != -ECANCELED);
 }
 
-static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio)
+static int ath6kl_sdio_power_on(struct ath6kl *ar)
 {
+	struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
 	struct sdio_func *func = ar_sdio->func;
 	int ret = 0;
 
@@ -495,8 +496,9 @@ static int ath6kl_sdio_power_on(struct ath6kl_sdio *ar_sdio)
 	return ret;
 }
 
-static int ath6kl_sdio_power_off(struct ath6kl_sdio *ar_sdio)
+static int ath6kl_sdio_power_off(struct ath6kl *ar)
 {
+	struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
 	int ret;
 
 	if (ar_sdio->is_disabled)
@@ -772,6 +774,8 @@ static const struct ath6kl_hif_ops ath6kl_sdio_ops = {
 	.cleanup_scatter = ath6kl_sdio_cleanup_scatter,
 	.suspend = ath6kl_sdio_suspend,
 	.resume = ath6kl_sdio_resume,
+	.power_on = ath6kl_sdio_power_on,
+	.power_off = ath6kl_sdio_power_off,
 };
 
 static int ath6kl_sdio_probe(struct sdio_func *func,
@@ -852,10 +856,6 @@ static int ath6kl_sdio_probe(struct sdio_func *func,
 
 	sdio_release_host(func);
 
-	ret = ath6kl_sdio_power_on(ar_sdio);
-	if (ret)
-		goto err_core_alloc;
-
 	sdio_claim_host(func);
 
 	ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
@@ -863,7 +863,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,
 		ath6kl_err("Set sdio block size %d failed: %d)\n",
 			   HIF_MBOX_BLOCK_SIZE, ret);
 		sdio_release_host(func);
-		goto err_off;
+		goto err_hif;
 	}
 
 	sdio_release_host(func);
@@ -871,13 +871,11 @@ static int ath6kl_sdio_probe(struct sdio_func *func,
 	ret = ath6kl_core_init(ar);
 	if (ret) {
 		ath6kl_err("Failed to init ath6kl core\n");
-		goto err_off;
+		goto err_hif;
 	}
 
 	return ret;
 
-err_off:
-	ath6kl_sdio_power_off(ar_sdio);
 err_core_alloc:
 	ath6kl_core_free(ar_sdio->ar);
 err_dma:
@@ -903,8 +901,6 @@ static void ath6kl_sdio_remove(struct sdio_func *func)
 
 	ath6kl_core_cleanup(ar_sdio->ar);
 
-	ath6kl_sdio_power_off(ar_sdio);
-
 	kfree(ar_sdio->dma_buffer);
 	kfree(ar_sdio);
 }


  parent reply	other threads:[~2011-10-27 15:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 15:47 [PATCH 01/10] ath6kl: don't use cfg80211_scan_request after cfg80211_scan_done() Kalle Valo
2011-10-27 15:48 ` [PATCH 02/10] ath6kl: rename ath6kl_wmi_qos_state_init() to _wmi_reset() Kalle Valo
2011-10-27 15:48 ` Kalle Valo [this message]
2011-10-27 15:48 ` [PATCH 04/10] ath6kl: add a fixme to ath6kl_htc_wait_target() Kalle Valo
2011-10-27 15:48 ` [PATCH 05/10] ath6kl: merge ath6kl_init() to ath6kl_core_init() Kalle Valo
2011-10-27 15:48 ` [PATCH 06/10] ath6kl: separate hardware boot code from module initialisation code Kalle Valo
2011-10-27 15:48 ` [PATCH 07/10] ath6kl: remove useless cleanup call from ath6kl_bmi_done() Kalle Valo
2011-10-27 15:48 ` [PATCH 08/10] ath6kl: add a timeout to ath6kl_hif_intr_bh_handler() Kalle Valo
2011-10-27 15:49 ` [PATCH 09/10] ath6kl: create ath6kl_htc_reset() Kalle Valo
2011-10-27 15:49 ` [PATCH 10/10] ath6kl: don't print an error for canceled packets Kalle Valo
2011-10-28 11:22 ` [PATCH 01/10] ath6kl: don't use cfg80211_scan_request after cfg80211_scan_done() Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111027154814.23519.93093.stgit@localhost6.localdomain6 \
    --to=kvalo@qca.qualcomm.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).