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

ACPI: scan: Add acpi_dev_get_next_consumer_dev()

In commit b83e2b306736 ("ACPI: scan: Add function to fetch dependent
of ACPI device") we added a means of fetching the first device to
declare itself dependent on another ACPI device in the _DEP method.
One assumption in that patch was that there would only be a single
consuming device, but this has not held.

Replace that function with a new function that fetches the next consumer
of a supplier device. Where no "previous" consumer is passed in, it
behaves identically to the original function.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Daniel Scally <djrscally@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Daniel Scally and committed by
Rafael J. Wysocki
cca8a7ef 98378956

+34 -12
+30 -10
drivers/acpi/scan.c
··· 2235 2235 return 0; 2236 2236 } 2237 2237 2238 - static int acpi_dev_get_first_consumer_dev_cb(struct acpi_dep_data *dep, void *data) 2238 + static int acpi_dev_get_next_consumer_dev_cb(struct acpi_dep_data *dep, void *data) 2239 2239 { 2240 - struct acpi_device *adev; 2240 + struct acpi_device **adev_p = data; 2241 + struct acpi_device *adev = *adev_p; 2242 + 2243 + /* 2244 + * If we're passed a 'previous' consumer device then we need to skip 2245 + * any consumers until we meet the previous one, and then NULL @data 2246 + * so the next one can be returned. 2247 + */ 2248 + if (adev) { 2249 + if (dep->consumer == adev->handle) 2250 + *adev_p = NULL; 2251 + 2252 + return 0; 2253 + } 2241 2254 2242 2255 adev = acpi_get_acpi_dev(dep->consumer); 2243 2256 if (adev) { ··· 2381 2368 EXPORT_SYMBOL_GPL(acpi_dev_ready_for_enumeration); 2382 2369 2383 2370 /** 2384 - * acpi_dev_get_first_consumer_dev - Return ACPI device dependent on @supplier 2371 + * acpi_dev_get_next_consumer_dev - Return the next adev dependent on @supplier 2385 2372 * @supplier: Pointer to the dependee device 2373 + * @start: Pointer to the current dependent device 2386 2374 * 2387 - * Returns the first &struct acpi_device which declares itself dependent on 2375 + * Returns the next &struct acpi_device which declares itself dependent on 2388 2376 * @supplier via the _DEP buffer, parsed from the acpi_dep_list. 2389 2377 * 2390 - * The caller is responsible for putting the reference to adev when it is no 2391 - * longer needed. 2378 + * If the returned adev is not passed as @start to this function, the caller is 2379 + * responsible for putting the reference to adev when it is no longer needed. 2392 2380 */ 2393 - struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier) 2381 + struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier, 2382 + struct acpi_device *start) 2394 2383 { 2395 - struct acpi_device *adev = NULL; 2384 + struct acpi_device *adev = start; 2396 2385 2397 2386 acpi_walk_dep_device_list(supplier->handle, 2398 - acpi_dev_get_first_consumer_dev_cb, &adev); 2387 + acpi_dev_get_next_consumer_dev_cb, &adev); 2388 + 2389 + acpi_dev_put(start); 2390 + 2391 + if (adev == start) 2392 + return NULL; 2399 2393 2400 2394 return adev; 2401 2395 } 2402 - EXPORT_SYMBOL_GPL(acpi_dev_get_first_consumer_dev); 2396 + EXPORT_SYMBOL_GPL(acpi_dev_get_next_consumer_dev); 2403 2397 2404 2398 /** 2405 2399 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
+1 -1
drivers/platform/x86/intel/int3472/common.c
··· 62 62 struct acpi_device *sensor; 63 63 int ret = 0; 64 64 65 - sensor = acpi_dev_get_first_consumer_dev(adev); 65 + sensor = acpi_dev_get_next_consumer_dev(adev, NULL); 66 66 if (!sensor) { 67 67 dev_err(dev, "INT3472 seems to have no dependents.\n"); 68 68 return -ENODEV;
+3 -1
include/acpi/acpi_bus.h
··· 742 742 743 743 void acpi_dev_clear_dependencies(struct acpi_device *supplier); 744 744 bool acpi_dev_ready_for_enumeration(const struct acpi_device *device); 745 - struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier); 745 + struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier, 746 + struct acpi_device *start); 747 + 746 748 struct acpi_device * 747 749 acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv); 748 750 struct acpi_device *