Linux wireless drivers development
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 10/18] iwlwifi: acpi: generalize iwl_mvm_sar_find_wifi_pkg()
Date: Fri, 29 Sep 2017 19:44:15 +0300	[thread overview]
Message-ID: <20170929164423.23666-11-luca@coelho.fi> (raw)
In-Reply-To: <20170929164423.23666-1-luca@coelho.fi>

From: Luca Coelho <luciano.coelho@intel.com>

Move this function to acpi.c, renaming it to iwl_acpi_get_wifi_pkg(),
because it can also be used with other methods (i.e. SPLC and WRDD).

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 52 ++++++++++++++++++++++++
 drivers/net/wireless/intel/iwlwifi/fw/acpi.h | 10 +++++
 drivers/net/wireless/intel/iwlwifi/mvm/fw.c  | 60 +++-------------------------
 3 files changed, 68 insertions(+), 54 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index a7b2a48618cd..5a3b75e45f5c 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -95,3 +95,55 @@ void *iwl_acpi_get_object(struct device *dev, acpi_string method)
 	return buf.pointer;
 }
 IWL_EXPORT_SYMBOL(iwl_acpi_get_object);
+
+union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev,
+					 union acpi_object *data,
+					 int data_size)
+{
+	int i;
+	union acpi_object *wifi_pkg;
+
+	/*
+	 * We need at least one entry in the wifi package that
+	 * describes the domain, and one more entry, otherwise there's
+	 * no point in reading it.
+	 */
+	if (WARN_ON_ONCE(data_size < 2))
+		return ERR_PTR(-EINVAL);
+
+	/*
+	 * We need at least two packages, one for the revision and one
+	 * for the data itself.  Also check that the revision is valid
+	 * (i.e. it is an integer set to 0).
+	 */
+	if (data->type != ACPI_TYPE_PACKAGE ||
+	    data->package.count < 2 ||
+	    data->package.elements[0].type != ACPI_TYPE_INTEGER ||
+	    data->package.elements[0].integer.value != 0) {
+		IWL_DEBUG_DEV_RADIO(dev, "Unsupported packages structure\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* loop through all the packages to find the one for WiFi */
+	for (i = 1; i < data->package.count; i++) {
+		union acpi_object *domain;
+
+		wifi_pkg = &data->package.elements[i];
+
+		/* skip entries that are not a package with the right size */
+		if (wifi_pkg->type != ACPI_TYPE_PACKAGE ||
+		    wifi_pkg->package.count != data_size)
+			continue;
+
+		domain = &wifi_pkg->package.elements[0];
+		if (domain->type == ACPI_TYPE_INTEGER &&
+		    domain->integer.value == ACPI_WIFI_DOMAIN)
+			goto found;
+	}
+
+	return ERR_PTR(-ENOENT);
+
+found:
+	return wifi_pkg;
+}
+IWL_EXPORT_SYMBOL(iwl_acpi_get_wifi_pkg);
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
index be3f49d5713a..f1db619c3ea0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
@@ -91,6 +91,9 @@
 #ifdef CONFIG_ACPI
 
 void *iwl_acpi_get_object(struct device *dev, acpi_string method);
+union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev,
+					 union acpi_object *data,
+					 int data_size);
 
 #else /* CONFIG_ACPI */
 
@@ -99,5 +102,12 @@ static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method)
 	return ERR_PTR(-ENOENT);
 }
 
+static inline union acpi_object *iwl_acpi_get_wifi_pkg(struct device *dev,
+						       union acpi_object *data,
+						       int data_size)
+{
+	return ERR_PTR(-ENOENT);
+}
+
 #endif /* CONFIG_ACPI */
 #endif /* __iwl_fw_acpi__ */
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
index 789aa7b74110..7a7b72bf1621 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/fw.c
@@ -599,54 +599,6 @@ static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm,
 	return 0;
 }
 
-static union acpi_object *iwl_mvm_sar_find_wifi_pkg(struct iwl_mvm *mvm,
-						    union acpi_object *data,
-						    int data_size)
-{
-	union acpi_object *wifi_pkg = NULL;
-	int i;
-
-	/*
-	 * We need at least two packages, one for the revision and one
-	 * for the data itself.  Also check that the revision is valid
-	 * (i.e. it is an integer set to 0).
-	 */
-	if (data->type != ACPI_TYPE_PACKAGE ||
-	    data->package.count < 2 ||
-	    data->package.elements[0].type != ACPI_TYPE_INTEGER ||
-	    data->package.elements[0].integer.value != 0) {
-		IWL_DEBUG_RADIO(mvm, "Unsupported packages structure\n");
-		return ERR_PTR(-EINVAL);
-	}
-
-	/* loop through all the packages to find the one for WiFi */
-	for (i = 1; i < data->package.count; i++) {
-		union acpi_object *domain;
-
-		wifi_pkg = &data->package.elements[i];
-
-		/* Skip anything that is not a package with the right
-		 * amount of elements (i.e. domain_type,
-		 * enabled/disabled plus the actual data size.
-		 */
-		if (wifi_pkg->type != ACPI_TYPE_PACKAGE ||
-		    wifi_pkg->package.count != data_size)
-			continue;
-
-		domain = &wifi_pkg->package.elements[0];
-		if (domain->type == ACPI_TYPE_INTEGER &&
-		    domain->integer.value == ACPI_WIFI_DOMAIN)
-			break;
-
-		wifi_pkg = NULL;
-	}
-
-	if (!wifi_pkg)
-		return ERR_PTR(-ENOENT);
-
-	return wifi_pkg;
-}
-
 static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
 {
 	union acpi_object *wifi_pkg, *table, *data;
@@ -657,8 +609,8 @@ static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data,
-					     ACPI_WRDS_WIFI_DATA_SIZE);
+	wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
+					 ACPI_WRDS_WIFI_DATA_SIZE);
 	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
@@ -694,8 +646,8 @@ static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data,
-					     ACPI_EWRD_WIFI_DATA_SIZE);
+	wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
+					 ACPI_EWRD_WIFI_DATA_SIZE);
 	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
@@ -750,8 +702,8 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
-	wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data,
-					     ACPI_WGDS_WIFI_DATA_SIZE);
+	wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
+					 ACPI_WGDS_WIFI_DATA_SIZE);
 	if (IS_ERR(wifi_pkg)) {
 		ret = PTR_ERR(wifi_pkg);
 		goto out_free;
-- 
2.14.1

  parent reply	other threads:[~2017-09-29 16:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 16:44 [PATCH 00/18] iwlwifi: updates intended for v4.15 2017-09-29 Luca Coelho
2017-09-29 16:44 ` [PATCH 01/18] iwlwifi: mvm: don't send identical PHY_CTXT_CMD Luca Coelho
2017-09-29 16:44 ` [PATCH 02/18] iwlwifi: fw: api: remove excess enum value documentation Luca Coelho
2017-09-29 16:44 ` [PATCH 03/18] iwlwifi: mvm: add marker cmd response struct Luca Coelho
2017-09-29 16:44 ` [PATCH 04/18] iwlwifi: fix minor code style issues Luca Coelho
2017-09-29 16:44 ` [PATCH 05/18] iwlwifi: pcie: dump registers when HW becomes inaccessible Luca Coelho
2017-10-06 12:25   ` [PATCH v2 " Luca Coelho
2017-09-29 16:44 ` [PATCH 06/18] iwlwifi: mvm: change warning to warn_once() Luca Coelho
2017-09-29 16:44 ` [PATCH 07/18] iwlwifi: acpi: add common code to read from ACPI Luca Coelho
2017-09-29 16:44 ` [PATCH 08/18] iwlwifi: acpi: move ACPI method definitions to acpi.h Luca Coelho
2017-09-29 16:44 ` [PATCH 09/18] iwlwifi: acpi: move ACPI-related " Luca Coelho
2017-09-29 16:44 ` Luca Coelho [this message]
2017-09-29 16:44 ` [PATCH 11/18] iwlwifi: acpi: use iwl_acpi_get_wifi_pkg when reading reading SPLC Luca Coelho
2017-09-29 16:44 ` [PATCH 12/18] iwlwifi: acpi: make iwl_get_bios_mcc() use the common acpi functions Luca Coelho
2017-09-29 16:44 ` [PATCH 13/18] iwlwifi: acpi: remove a couple of unnecessary ifdefs Luca Coelho
2017-09-29 16:44 ` [PATCH 14/18] iwlwifi: acpi: move function to get mcc into acpi code Luca Coelho
2017-09-29 16:44 ` [PATCH 15/18] iwlwifi: fix indentation in a000 family configuration Luca Coelho
2017-09-29 16:44 ` [PATCH 16/18] iwlwifi: acpi: move code that reads SPLC to acpi Luca Coelho
2017-09-29 16:44 ` [PATCH 17/18] iwlwifi: mvm: warn on invalid statistics size Luca Coelho
2017-09-29 16:44 ` [PATCH 18/18] iwlwifi: remove dflt_pwr_limit from the transport Luca Coelho

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=20170929164423.23666-11-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    /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