提交 2fa388cf 编写于 作者: L Luca Coelho

iwlwifi: acpi: generalize iwl_mvm_sar_find_wifi_pkg()

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: NLuca Coelho <luciano.coelho@intel.com>
上级 e7a3b8d8
...@@ -95,3 +95,55 @@ void *iwl_acpi_get_object(struct device *dev, acpi_string method) ...@@ -95,3 +95,55 @@ void *iwl_acpi_get_object(struct device *dev, acpi_string method)
return buf.pointer; return buf.pointer;
} }
IWL_EXPORT_SYMBOL(iwl_acpi_get_object); 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);
...@@ -91,6 +91,9 @@ ...@@ -91,6 +91,9 @@
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
void *iwl_acpi_get_object(struct device *dev, acpi_string method); 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 */ #else /* CONFIG_ACPI */
...@@ -99,5 +102,12 @@ static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method) ...@@ -99,5 +102,12 @@ static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method)
return ERR_PTR(-ENOENT); 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 /* CONFIG_ACPI */
#endif /* __iwl_fw_acpi__ */ #endif /* __iwl_fw_acpi__ */
...@@ -599,54 +599,6 @@ static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm, ...@@ -599,54 +599,6 @@ static int iwl_mvm_sar_set_profile(struct iwl_mvm *mvm,
return 0; 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) static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
{ {
union acpi_object *wifi_pkg, *table, *data; union acpi_object *wifi_pkg, *table, *data;
...@@ -657,7 +609,7 @@ static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm) ...@@ -657,7 +609,7 @@ static int iwl_mvm_sar_get_wrds_table(struct iwl_mvm *mvm)
if (IS_ERR(data)) if (IS_ERR(data))
return PTR_ERR(data); return PTR_ERR(data);
wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data, wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
ACPI_WRDS_WIFI_DATA_SIZE); ACPI_WRDS_WIFI_DATA_SIZE);
if (IS_ERR(wifi_pkg)) { if (IS_ERR(wifi_pkg)) {
ret = PTR_ERR(wifi_pkg); ret = PTR_ERR(wifi_pkg);
...@@ -694,7 +646,7 @@ static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm) ...@@ -694,7 +646,7 @@ static int iwl_mvm_sar_get_ewrd_table(struct iwl_mvm *mvm)
if (IS_ERR(data)) if (IS_ERR(data))
return PTR_ERR(data); return PTR_ERR(data);
wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data, wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
ACPI_EWRD_WIFI_DATA_SIZE); ACPI_EWRD_WIFI_DATA_SIZE);
if (IS_ERR(wifi_pkg)) { if (IS_ERR(wifi_pkg)) {
ret = PTR_ERR(wifi_pkg); ret = PTR_ERR(wifi_pkg);
...@@ -750,7 +702,7 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm) ...@@ -750,7 +702,7 @@ static int iwl_mvm_sar_get_wgds_table(struct iwl_mvm *mvm)
if (IS_ERR(data)) if (IS_ERR(data))
return PTR_ERR(data); return PTR_ERR(data);
wifi_pkg = iwl_mvm_sar_find_wifi_pkg(mvm, data, wifi_pkg = iwl_acpi_get_wifi_pkg(mvm->dev, data,
ACPI_WGDS_WIFI_DATA_SIZE); ACPI_WGDS_WIFI_DATA_SIZE);
if (IS_ERR(wifi_pkg)) { if (IS_ERR(wifi_pkg)) {
ret = PTR_ERR(wifi_pkg); ret = PTR_ERR(wifi_pkg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册