Commit 88af7bbd authored by Sakari Ailus's avatar Sakari Ailus Committed by Rafael J. Wysocki

ACPI: property: Switch node property referencing from ifs to a switch

__acpi_node_get_property_reference() uses a series of if () statements for
testing the same variable. There's soon going to be one more value to be
tested.

Switch to use switch() instead.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1aef25d9
...@@ -778,11 +778,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -778,11 +778,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
if (ret) if (ret)
return ret == -EINVAL ? -ENOENT : -EINVAL; return ret == -EINVAL ? -ENOENT : -EINVAL;
/* switch (obj->type) {
* The simplest case is when the value is a single reference. Just case ACPI_TYPE_LOCAL_REFERENCE:
* return that reference then. /* Plain single reference without arguments. */
*/
if (obj->type == ACPI_TYPE_LOCAL_REFERENCE) {
if (index) if (index)
return -ENOENT; return -ENOENT;
...@@ -793,19 +791,21 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -793,19 +791,21 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
args->fwnode = acpi_fwnode_handle(device); args->fwnode = acpi_fwnode_handle(device);
args->nargs = 0; args->nargs = 0;
return 0; return 0;
case ACPI_TYPE_PACKAGE:
/*
* If it is not a single reference, then it is a package of
* references followed by number of ints as follows:
*
* Package () { REF, INT, REF, INT, INT }
*
* The index argument is then used to determine which reference
* the caller wants (along with the arguments).
*/
break;
default:
return -EINVAL;
} }
/*
* If it is not a single reference, then it is a package of
* references followed by number of ints as follows:
*
* Package () { REF, INT, REF, INT, INT }
*
* The index argument is then used to determine which reference
* the caller wants (along with the arguments).
*/
if (obj->type != ACPI_TYPE_PACKAGE)
return -EINVAL;
if (index >= obj->package.count) if (index >= obj->package.count)
return -ENOENT; return -ENOENT;
...@@ -813,7 +813,8 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -813,7 +813,8 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
end = element + obj->package.count; end = element + obj->package.count;
while (element < end) { while (element < end) {
if (element->type == ACPI_TYPE_LOCAL_REFERENCE) { switch (element->type) {
case ACPI_TYPE_LOCAL_REFERENCE:
device = acpi_fetch_acpi_dev(element->reference.handle); device = acpi_fetch_acpi_dev(element->reference.handle);
if (!device) if (!device)
return -EINVAL; return -EINVAL;
...@@ -829,11 +830,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, ...@@ -829,11 +830,13 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
if (idx == index) if (idx == index)
return 0; return 0;
} else if (element->type == ACPI_TYPE_INTEGER) { break;
case ACPI_TYPE_INTEGER:
if (idx == index) if (idx == index)
return -ENOENT; return -ENOENT;
element++; element++;
} else { break;
default:
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment