···4747 */4848static u64 spcr_uart_addr;49495050-struct acpi_dep_data {5151- struct list_head node;5252- acpi_handle supplier;5353- acpi_handle consumer;5454-};5555-5650void acpi_scan_lock_acquire(void)5751{5852 mutex_lock(&acpi_scan_lock);···16651671 device_initialize(&device->dev);16661672 dev_set_uevent_suppress(&device->dev, true);16671673 acpi_init_coherency(device);16681668- /* Assume there are unmet deps to start with. */16691669- device->dep_unmet = 1;16741674+}16751675+16761676+static void acpi_scan_dep_init(struct acpi_device *adev)16771677+{16781678+ struct acpi_dep_data *dep;16791679+16801680+ mutex_lock(&acpi_dep_list_lock);16811681+16821682+ list_for_each_entry(dep, &acpi_dep_list, node) {16831683+ if (dep->consumer == adev->handle)16841684+ adev->dep_unmet++;16851685+ }16861686+16871687+ mutex_unlock(&acpi_dep_list_lock);16701688}1671168916721690void acpi_device_add_finalize(struct acpi_device *device)···16941688}1695168916961690static int acpi_add_single_object(struct acpi_device **child,16971697- acpi_handle handle, int type)16911691+ acpi_handle handle, int type, bool dep_init)16981692{16991693 struct acpi_device *device;17001694 int result;···17091703 * acpi_bus_get_status() and use its quirk handling. Note that17101704 * this must be done before the get power-/wakeup_dev-flags calls.17111705 */17121712- if (type == ACPI_BUS_TYPE_DEVICE || type == ACPI_BUS_TYPE_PROCESSOR)17061706+ if (type == ACPI_BUS_TYPE_DEVICE || type == ACPI_BUS_TYPE_PROCESSOR) {17071707+ if (dep_init)17081708+ acpi_scan_dep_init(device);17091709+17131710 acpi_scan_init_status(device);17111711+ }1714171217151713 acpi_bus_get_power_flags(device);17161714 acpi_bus_get_wakeup_device_flags(device);···18961886 return count;18971887}1898188818991899-static void acpi_scan_dep_init(struct acpi_device *adev)19001900-{19011901- struct acpi_dep_data *dep;19021902-19031903- adev->dep_unmet = 0;19041904-19051905- mutex_lock(&acpi_dep_list_lock);19061906-19071907- list_for_each_entry(dep, &acpi_dep_list, node) {19081908- if (dep->consumer == adev->handle)19091909- adev->dep_unmet++;19101910- }19111911-19121912- mutex_unlock(&acpi_dep_list_lock);19131913-}19141914-19151889static bool acpi_bus_scan_second_pass;1916189019171891static acpi_status acpi_bus_check_add(acpi_handle handle, bool check_dep,···19431949 return AE_OK;19441950 }1945195119461946- acpi_add_single_object(&device, handle, type);19471947- if (!device)19481948- return AE_CTRL_DEPTH;19491949-19501950- acpi_scan_init_hotplug(device);19511952 /*19521953 * If check_dep is true at this point, the device has no dependencies,19531954 * or the creation of the device object would have been postponed above.19541955 */19551955- if (check_dep)19561956- device->dep_unmet = 0;19571957- else19581958- acpi_scan_dep_init(device);19561956+ acpi_add_single_object(&device, handle, type, !check_dep);19571957+ if (!device)19581958+ return AE_CTRL_DEPTH;19591959+19601960+ acpi_scan_init_hotplug(device);1959196119601962out:19611963 if (!*adev_p)···21012111 device->handler->hotplug.notify_online(device);21022112}2103211321042104-void acpi_walk_dep_device_list(acpi_handle handle)21142114+static int acpi_dev_get_first_consumer_dev_cb(struct acpi_dep_data *dep, void *data)21152115+{21162116+ struct acpi_device *adev;21172117+21182118+ adev = acpi_bus_get_acpi_device(dep->consumer);21192119+ if (!adev)21202120+ /* If we don't find an adev then we want to continue parsing */21212121+ return 0;21222122+21232123+ *(struct acpi_device **)data = adev;21242124+21252125+ return 1;21262126+}21272127+21282128+static int acpi_scan_clear_dep(struct acpi_dep_data *dep, void *data)21292129+{21302130+ struct acpi_device *adev;21312131+21322132+ acpi_bus_get_device(dep->consumer, &adev);21332133+21342134+ if (adev) {21352135+ adev->dep_unmet--;21362136+ if (!adev->dep_unmet)21372137+ acpi_bus_attach(adev, true);21382138+ }21392139+21402140+ list_del(&dep->node);21412141+ kfree(dep);21422142+21432143+ return 0;21442144+}21452145+21462146+/**21472147+ * acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list21482148+ * @handle: The ACPI handle of the supplier device21492149+ * @callback: Pointer to the callback function to apply21502150+ * @data: Pointer to some data to pass to the callback21512151+ *21522152+ * The return value of the callback determines this function's behaviour. If 021532153+ * is returned we continue to iterate over acpi_dep_list. If a positive value21542154+ * is returned then the loop is broken but this function returns 0. If a21552155+ * negative value is returned by the callback then the loop is broken and that21562156+ * value is returned as the final error.21572157+ */21582158+int acpi_walk_dep_device_list(acpi_handle handle,21592159+ int (*callback)(struct acpi_dep_data *, void *),21602160+ void *data)21052161{21062162 struct acpi_dep_data *dep, *tmp;21072107- struct acpi_device *adev;21632163+ int ret = 0;2108216421092165 mutex_lock(&acpi_dep_list_lock);21102166 list_for_each_entry_safe(dep, tmp, &acpi_dep_list, node) {21112167 if (dep->supplier == handle) {21122112- acpi_bus_get_device(dep->consumer, &adev);21132113-21142114- if (adev) {21152115- adev->dep_unmet--;21162116- if (!adev->dep_unmet)21172117- acpi_bus_attach(adev, true);21182118- }21192119-21202120- list_del(&dep->node);21212121- kfree(dep);21682168+ ret = callback(dep, data);21692169+ if (ret)21702170+ break;21222171 }21232172 }21242173 mutex_unlock(&acpi_dep_list_lock);21742174+21752175+ return ret > 0 ? 0 : ret;21252176}21262177EXPORT_SYMBOL_GPL(acpi_walk_dep_device_list);21782178+21792179+/**21802180+ * acpi_dev_clear_dependencies - Inform consumers that the device is now active21812181+ * @supplier: Pointer to the supplier &struct acpi_device21822182+ *21832183+ * Clear dependencies on the given device.21842184+ */21852185+void acpi_dev_clear_dependencies(struct acpi_device *supplier)21862186+{21872187+ acpi_walk_dep_device_list(supplier->handle, acpi_scan_clear_dep, NULL);21882188+}21892189+EXPORT_SYMBOL_GPL(acpi_dev_clear_dependencies);21902190+21912191+/**21922192+ * acpi_dev_get_first_consumer_dev - Return ACPI device dependent on @supplier21932193+ * @supplier: Pointer to the dependee device21942194+ *21952195+ * Returns the first &struct acpi_device which declares itself dependent on21962196+ * @supplier via the _DEP buffer, parsed from the acpi_dep_list.21972197+ *21982198+ * The caller is responsible for putting the reference to adev when it is no21992199+ * longer needed.22002200+ */22012201+struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier)22022202+{22032203+ struct acpi_device *adev = NULL;22042204+22052205+ acpi_walk_dep_device_list(supplier->handle,22062206+ acpi_dev_get_first_consumer_dev_cb, &adev);22072207+22082208+ return adev;22092209+}22102210+EXPORT_SYMBOL_GPL(acpi_dev_get_first_consumer_dev);2127221121282212/**21292213 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.···22872223 struct acpi_device *device = NULL;22882224 int result;2289222522902290- result = acpi_add_single_object(&device, NULL, type);22262226+ result = acpi_add_single_object(&device, NULL, type, false);22912227 if (result)22922228 return result;22932229···23072243 struct acpi_device *device = NULL;2308224423092245 result = acpi_add_single_object(&device, NULL,23102310- ACPI_BUS_TYPE_POWER_BUTTON);22462246+ ACPI_BUS_TYPE_POWER_BUTTON, false);23112247 if (result)23122248 return result;23132249···23232259 struct acpi_device *device = NULL;2324226023252261 result = acpi_add_single_object(&device, NULL,23262326- ACPI_BUS_TYPE_SLEEP_BUTTON);22622262+ ACPI_BUS_TYPE_SLEEP_BUTTON, false);23272263 if (result)23282264 return result;23292265
+5-5
drivers/gpio/gpiolib-acpi.c
···12841284void acpi_gpiochip_add(struct gpio_chip *chip)12851285{12861286 struct acpi_gpio_chip *acpi_gpio;12871287- acpi_handle handle;12871287+ struct acpi_device *adev;12881288 acpi_status status;1289128912901290 if (!chip || !chip->parent)12911291 return;1292129212931293- handle = ACPI_HANDLE(chip->parent);12941294- if (!handle)12931293+ adev = ACPI_COMPANION(chip->parent);12941294+ if (!adev)12951295 return;1296129612971297 acpi_gpio = kzalloc(sizeof(*acpi_gpio), GFP_KERNEL);···13051305 INIT_LIST_HEAD(&acpi_gpio->events);13061306 INIT_LIST_HEAD(&acpi_gpio->deferred_req_irqs_list_entry);1307130713081308- status = acpi_attach_data(handle, acpi_gpio_chip_dh, acpi_gpio);13081308+ status = acpi_attach_data(adev->handle, acpi_gpio_chip_dh, acpi_gpio);13091309 if (ACPI_FAILURE(status)) {13101310 dev_err(chip->parent, "Failed to attach ACPI GPIO chip\n");13111311 kfree(acpi_gpio);···1314131413151315 acpi_gpiochip_request_regions(acpi_gpio);13161316 acpi_gpiochip_scan_gpios(acpi_gpio);13171317- acpi_walk_dep_device_list(handle);13171317+ acpi_dev_clear_dependencies(adev);13181318}1319131913201320void acpi_gpiochip_remove(struct gpio_chip *chip)
+4-4
drivers/i2c/i2c-core-acpi.c
···259259 */260260void i2c_acpi_register_devices(struct i2c_adapter *adap)261261{262262+ struct acpi_device *adev;262263 acpi_status status;263263- acpi_handle handle;264264265265 if (!has_acpi_companion(&adap->dev))266266 return;···275275 if (!adap->dev.parent)276276 return;277277278278- handle = ACPI_HANDLE(adap->dev.parent);279279- if (!handle)278278+ adev = ACPI_COMPANION(adap->dev.parent);279279+ if (!adev)280280 return;281281282282- acpi_walk_dep_device_list(handle);282282+ acpi_dev_clear_dependencies(adev);283283}284284285285static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {
+3-3
drivers/platform/surface/aggregator/core.c
···621621622622static int ssam_serial_hub_probe(struct serdev_device *serdev)623623{624624+ struct acpi_device *ssh = ACPI_COMPANION(&serdev->dev);624625 struct ssam_controller *ctrl;625625- acpi_handle *ssh = ACPI_HANDLE(&serdev->dev);626626 acpi_status astatus;627627 int status;628628···652652 if (status)653653 goto err_devopen;654654655655- astatus = ssam_serdev_setup_via_acpi(ssh, serdev);655655+ astatus = ssam_serdev_setup_via_acpi(ssh->handle, serdev);656656 if (ACPI_FAILURE(astatus)) {657657 status = -ENXIO;658658 goto err_devinit;···706706 * For now let's thus default power/wakeup to false.707707 */708708 device_set_wakeup_capable(&serdev->dev, true);709709- acpi_walk_dep_device_list(ssh);709709+ acpi_dev_clear_dependencies(ssh);710710711711 return 0;712712
+11-11
drivers/platform/surface/surface3_power.c
···446446447447static int mshw0011_install_space_handler(struct i2c_client *client)448448{449449- acpi_handle handle;449449+ struct acpi_device *adev;450450 struct mshw0011_handler_data *data;451451 acpi_status status;452452453453- handle = ACPI_HANDLE(&client->dev);454454- if (!handle)453453+ adev = ACPI_COMPANION(&client->dev);454454+ if (!adev)455455 return -ENODEV;456456457457 data = kzalloc(sizeof(struct mshw0011_handler_data),···460460 return -ENOMEM;461461462462 data->client = client;463463- status = acpi_bus_attach_private_data(handle, (void *)data);463463+ status = acpi_bus_attach_private_data(adev->handle, (void *)data);464464 if (ACPI_FAILURE(status)) {465465 kfree(data);466466 return -ENOMEM;467467 }468468469469- status = acpi_install_address_space_handler(handle,470470- ACPI_ADR_SPACE_GSBUS,471471- &mshw0011_space_handler,472472- NULL,473473- data);469469+ status = acpi_install_address_space_handler(adev->handle,470470+ ACPI_ADR_SPACE_GSBUS,471471+ &mshw0011_space_handler,472472+ NULL,473473+ data);474474 if (ACPI_FAILURE(status)) {475475 dev_err(&client->dev, "Error installing i2c space handler\n");476476- acpi_bus_detach_private_data(handle);476476+ acpi_bus_detach_private_data(adev->handle);477477 kfree(data);478478 return -ENOMEM;479479 }480480481481- acpi_walk_dep_device_list(handle);481481+ acpi_dev_clear_dependencies(adev);482482 return 0;483483}484484