From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org, Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 11/18] iwlwifi: acpi: use iwl_acpi_get_wifi_pkg when reading reading SPLC
Date: Fri, 29 Sep 2017 19:44:16 +0300 [thread overview]
Message-ID: <20170929164423.23666-12-luca@coelho.fi> (raw)
In-Reply-To: <20170929164423.23666-1-luca@coelho.fi>
From: Luca Coelho <luciano.coelho@intel.com>
Instead of finding the wifi package with its own code, we can reuse
the new iwl_acpi_get_wifi_pkg() function when reading the default
power limit from SPLC.
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
drivers/net/wireless/intel/iwlwifi/fw/acpi.h | 2 +
drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 61 +++++----------------------
2 files changed, 12 insertions(+), 51 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
index f1db619c3ea0..f5c8c856311a 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.h
@@ -85,6 +85,8 @@
#define ACPI_EWRD_WIFI_DATA_SIZE ((ACPI_SAR_PROFILE_NUM - 1) * \
ACPI_SAR_TABLE_SIZE + 3)
#define ACPI_WGDS_WIFI_DATA_SIZE 18
+#define ACPI_SPLC_WIFI_DATA_SIZE 2
+
#define ACPI_WGDS_NUM_BANDS 2
#define ACPI_WGDS_TABLE_SIZE 3
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index a6c4f096cb19..b5fce721b0b0 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -588,67 +588,26 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
#ifdef CONFIG_ACPI
-static u64 splc_get_pwr_limit(struct iwl_trans *trans, union acpi_object *splc)
-{
- union acpi_object *data_pkg, *dflt_pwr_limit;
- int i;
-
- /* We need at least two elements, one for the revision and one
- * for the data itself. Also check that the revision is
- * supported (currently only revision 0).
- */
- if (splc->type != ACPI_TYPE_PACKAGE ||
- splc->package.count < 2 ||
- splc->package.elements[0].type != ACPI_TYPE_INTEGER ||
- splc->package.elements[0].integer.value != 0) {
- IWL_DEBUG_INFO(trans,
- "Unsupported structure returned by the SPLC method. Ignoring.\n");
- return 0;
- }
-
- /* loop through all the packages to find the one for WiFi */
- for (i = 1; i < splc->package.count; i++) {
- union acpi_object *domain;
-
- data_pkg = &splc->package.elements[i];
-
- /* Skip anything that is not a package with the right
- * amount of elements (i.e. at least 2 integers).
- */
- if (data_pkg->type != ACPI_TYPE_PACKAGE ||
- data_pkg->package.count < 2 ||
- data_pkg->package.elements[0].type != ACPI_TYPE_INTEGER ||
- data_pkg->package.elements[1].type != ACPI_TYPE_INTEGER)
- continue;
-
- domain = &data_pkg->package.elements[0];
- if (domain->integer.value == ACPI_WIFI_DOMAIN)
- break;
-
- data_pkg = NULL;
- }
-
- if (!data_pkg) {
- IWL_DEBUG_INFO(trans,
- "No element for the WiFi domain returned by the SPLC method.\n");
- return 0;
- }
-
- dflt_pwr_limit = &data_pkg->package.elements[1];
- return dflt_pwr_limit->integer.value;
-}
static void set_dflt_pwr_limit(struct iwl_trans *trans, struct pci_dev *pdev)
{
- union acpi_object *data;
+ union acpi_object *data, *wifi_pkg;
data = iwl_acpi_get_object(trans->dev, ACPI_SPLC_METHOD);
if (IS_ERR(data))
return;
- trans->dflt_pwr_limit = splc_get_pwr_limit(trans, data);
+ wifi_pkg = iwl_acpi_get_wifi_pkg(trans->dev, data,
+ ACPI_SPLC_WIFI_DATA_SIZE);
+ if (IS_ERR(wifi_pkg) ||
+ wifi_pkg->package.elements[1].integer.value != ACPI_TYPE_INTEGER)
+ goto out;
+
+ trans->dflt_pwr_limit = wifi_pkg->package.elements[1].integer.value;
+
IWL_DEBUG_INFO(trans, "Default power limit set to %lld\n",
trans->dflt_pwr_limit);
+out:
kfree(data);
}
--
2.14.1
next prev 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 ` [PATCH 10/18] iwlwifi: acpi: generalize iwl_mvm_sar_find_wifi_pkg() Luca Coelho
2017-09-29 16:44 ` Luca Coelho [this message]
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-12-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