Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: glue: Introduce acpi_find_child_by_adr()

Rearrange the ACPI device lookup code used internally by
acpi_find_child_device() so it can avoid extra checks after finding
one object with a matching _ADR and use it for defining
acpi_find_child_by_adr() that will allow the callers to find a given
ACPI device's child matching a given bus address without doing any
other checks in check_one_child().

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

+26 -4
+24 -4
drivers/acpi/glue.c
··· 119 119 struct acpi_device *adev; 120 120 u64 address; 121 121 int score; 122 + bool check_sta; 122 123 bool check_children; 123 124 }; 124 125 ··· 132 131 return 0; 133 132 134 133 if (!wd->adev) { 135 - /* This is the first matching object. Save it and continue. */ 134 + /* 135 + * This is the first matching object, so save it. If it is not 136 + * necessary to look for any other matching objects, stop the 137 + * search. 138 + */ 136 139 wd->adev = adev; 137 - return 0; 140 + return !(wd->check_sta || wd->check_children); 138 141 } 139 142 140 143 /* ··· 174 169 return 0; 175 170 } 176 171 177 - struct acpi_device *acpi_find_child_device(struct acpi_device *parent, 178 - u64 address, bool check_children) 172 + static struct acpi_device *acpi_find_child(struct acpi_device *parent, 173 + u64 address, bool check_children, 174 + bool check_sta) 179 175 { 180 176 struct find_child_walk_data wd = { 181 177 .address = address, 182 178 .check_children = check_children, 179 + .check_sta = check_sta, 183 180 .adev = NULL, 184 181 .score = 0, 185 182 }; ··· 191 184 192 185 return wd.adev; 193 186 } 187 + 188 + struct acpi_device *acpi_find_child_device(struct acpi_device *parent, 189 + u64 address, bool check_children) 190 + { 191 + return acpi_find_child(parent, address, check_children, true); 192 + } 194 193 EXPORT_SYMBOL_GPL(acpi_find_child_device); 194 + 195 + struct acpi_device *acpi_find_child_by_adr(struct acpi_device *adev, 196 + acpi_bus_address adr) 197 + { 198 + return acpi_find_child(adev, adr, false, false); 199 + } 200 + EXPORT_SYMBOL_GPL(acpi_find_child_by_adr); 195 201 196 202 static void acpi_physnode_link_name(char *buf, unsigned int node_id) 197 203 {
+2
include/acpi/acpi_bus.h
··· 622 622 } 623 623 struct acpi_device *acpi_find_child_device(struct acpi_device *parent, 624 624 u64 address, bool check_children); 625 + struct acpi_device *acpi_find_child_by_adr(struct acpi_device *adev, 626 + acpi_bus_address adr); 625 627 int acpi_is_root_bridge(acpi_handle); 626 628 struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle); 627 629