Skip to content

Commit 9978f44

Browse files
andy-shevrafaeljw
authored andcommitted
ACPI: property: Get rid of redundant 'else'
In the snippets like the following if (...) return / goto / break / continue ...; else ... the 'else' is redundant. Get rid of it. While at it, replace conditional '<= 0' for unsigned type by '== 0' in acpi_data_prop_read(); update comment in the __acpi_node_get_property_reference() on how we parse the reference. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent babc92d commit 9978f44

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

drivers/acpi/property.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,8 @@ acpi_device_data_of_node(const struct fwnode_handle *fwnode)
541541
if (is_acpi_device_node(fwnode)) {
542542
const struct acpi_device *adev = to_acpi_device_node(fwnode);
543543
return &adev->data;
544-
} else if (is_acpi_data_node(fwnode)) {
544+
}
545+
if (is_acpi_data_node(fwnode)) {
545546
const struct acpi_data_node *dn = to_acpi_data_node(fwnode);
546547
return &dn->data;
547548
}
@@ -739,14 +740,19 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
739740
return -EINVAL;
740741
}
741742

742-
/* assume following integer elements are all args */
743+
/*
744+
* Assume the following integer elements are all args.
745+
* Stop counting on the first reference or end of the
746+
* package arguments. In case of neither reference,
747+
* nor integer, return an error, we can't parse it.
748+
*/
743749
for (i = 0; element + i < end && i < num_args; i++) {
744750
int type = element[i].type;
745751

752+
if (type == ACPI_TYPE_LOCAL_REFERENCE)
753+
break;
746754
if (type == ACPI_TYPE_INTEGER)
747755
nargs++;
748-
else if (type == ACPI_TYPE_LOCAL_REFERENCE)
749-
break;
750756
else
751757
return -EINVAL;
752758
}
@@ -950,7 +956,7 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
950956

951957
if (proptype != DEV_PROP_STRING && nval > obj->package.count)
952958
return -EOVERFLOW;
953-
else if (nval <= 0)
959+
if (nval == 0)
954960
return -EINVAL;
955961

956962
items = obj->package.elements;
@@ -1012,14 +1018,10 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
10121018
const struct list_head *head;
10131019
struct list_head *next;
10141020

1015-
if (!child || is_acpi_device_node(child)) {
1021+
if ((!child || is_acpi_device_node(child)) && adev) {
10161022
struct acpi_device *child_adev;
10171023

1018-
if (adev)
1019-
head = &adev->children;
1020-
else
1021-
goto nondev;
1022-
1024+
head = &adev->children;
10231025
if (list_empty(head))
10241026
goto nondev;
10251027

@@ -1089,7 +1091,8 @@ acpi_node_get_parent(const struct fwnode_handle *fwnode)
10891091
if (is_acpi_data_node(fwnode)) {
10901092
/* All data nodes have parent pointer so just return that */
10911093
return to_acpi_data_node(fwnode)->parent;
1092-
} else if (is_acpi_device_node(fwnode)) {
1094+
}
1095+
if (is_acpi_device_node(fwnode)) {
10931096
struct device *dev = to_acpi_device_node(fwnode)->dev.parent;
10941097

10951098
if (dev)

0 commit comments

Comments
 (0)