Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3321105pxj; Mon, 7 Jun 2021 07:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzleHftBNIBDgGL6xXcQxCejq/T59jdOUsorNeSjcrkIHRS1cnA+402pQ9zUBFOs/tbHmKo X-Received: by 2002:a17:906:2dd2:: with SMTP id h18mr18497823eji.332.1623077703115; Mon, 07 Jun 2021 07:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623077703; cv=none; d=google.com; s=arc-20160816; b=1Jl/jZhWQ8QcXrBeSif8nVnd5/B+6cTYXlW5+aTYdL4eNkvcf93NbFMAQS+ZgbfmVE 1A5KnU48bXVJA0hqvmEUzprr0WReR0UcarNOr9neXTIWZnlP7VRaZIwb01hM1M9Udc0R HhrYUbwBQpkrnO86nucU9AUrbDDzpRRGTWBbx4CiVPpAknXTDlQvqSmP7T4Q33xkdBZR uNL73AZCm1q02AmY9nX0CCFlPLikqcCTdmZOV1bNwjyELFsNM8MOdW7SgQhEUzLddcPF o7a+IEE6QmXAd5IePDxnFHTi9xUvmD8FEtbhjUhXEZfbAPn1ilZfU05Fz7VYSskjHN0n VuOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=vFKKKRb67LGq4j/7jOKF7wGRXnfTmyHqm4pxSTe6iqE=; b=AVfrNoGrKq8hvlwGASspXb8vx72pPvt2S4ExCUIDmsgc6wyQoYEfDUKbkEI7yTQiR0 Rx1THhVqvhl+dhFSdT+qv+mVtW5ci7x2NovE8uGwuCoKcSL+15YtzTodTDuae+rfw6NC LIcCZNA4s2N/8qNow+wrWLKKZv8TgHJoz7xBpl49rxqt6vvqZ5Jj6gB6VH9Vkd0b3+qI fo3qxHfLtapMWvhE8CioB7Ag7/tIO2PjNNjIUFcZ/4mOHnXXduA10640rN8ySeuw3Pgi 8HiX5B8rasCWOVWYKXfEruK3ZxejClTaqdG+tXQHwy7/bM2j71xinh3swCHDL0h2Sk9G qKaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 4si7642320ejr.300.2021.06.07.07.54.40; Mon, 07 Jun 2021 07:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbhFGOzH (ORCPT + 99 others); Mon, 7 Jun 2021 10:55:07 -0400 Received: from mail-oi1-f171.google.com ([209.85.167.171]:40491 "EHLO mail-oi1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231501AbhFGOzA (ORCPT ); Mon, 7 Jun 2021 10:55:00 -0400 Received: by mail-oi1-f171.google.com with SMTP id r17so8056084oic.7; Mon, 07 Jun 2021 07:52:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vFKKKRb67LGq4j/7jOKF7wGRXnfTmyHqm4pxSTe6iqE=; b=mBQdOWvRwOxHF6ABeBC4ZKP8EUTILSIqM85QZ+mB8CMCIdkVn6x5IxwPArAI9GEkNU YmgnT6mFBLVbNQQav2zxaqWW3MhRh4yC/XZHDRYVARmnS4iKsJQzyijuhUeJTQZVow40 aDVedgN1gWvzsZIOfTfSYsbRaOueegEQWQJFwaparxXeg9M3mlHBA7YAJe1FJti6rpC3 eL8fPXCb7X1xNOaRmsVAXCjaV4zb31UwJs+3bxCp/6PSxTyjg66ii5tGBlg+Hbuu4txX slEPoBpDdSlj2H73XuL5l6CLaRrjhCrVArW2wkhPgYADr6Yh58K9HsMN9G7fSq5iCtUe gicw== X-Gm-Message-State: AOAM532t9y+AIl1t/wVdl/bph5kFR+1RheBvz5FnlHpAC09YpkyV+BJK q/E0pbcq32t48TOH+ao5yhHr/09n5vGdXFKdTuc= X-Received: by 2002:aca:b406:: with SMTP id d6mr11602849oif.71.1623077574350; Mon, 07 Jun 2021 07:52:54 -0700 (PDT) MIME-Version: 1.0 References: <20210603224007.120560-1-djrscally@gmail.com> <20210603224007.120560-3-djrscally@gmail.com> In-Reply-To: <20210603224007.120560-3-djrscally@gmail.com> From: "Rafael J. Wysocki" Date: Mon, 7 Jun 2021 16:52:43 +0200 Message-ID: Subject: Re: [PATCH v5 2/6] ACPI: scan: Add function to fetch dependent of acpi device To: Daniel Scally Cc: "Rafael J . Wysocki" , Andy Shevchenko , Lee Jones , Hans de Goede , Maximilian Luz , Linux Kernel Mailing List , ACPI Devel Maling List , "open list:GPIO SUBSYSTEM" , linux-i2c , Platform Driver , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , Len Brown , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang , Mark Gross , Robert Moore , Erik Kaneda , Laurent Pinchart , Kieran Bingham , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 4, 2021 at 12:41 AM Daniel Scally wrote: > > In some ACPI tables we encounter, devices use the _DEP method to assert > a dependence on other ACPI devices as opposed to the OpRegions that the > specification intends. We need to be able to find those devices "from" > the dependee, so add a callback and a wrapper to walk over the > acpi_dep_list and return the dependent ACPI device. > > Reviewed-by: Andy Shevchenko > Signed-off-by: Daniel Scally > --- > Changes since v5: > > - Functions renamed > > drivers/acpi/scan.c | 35 +++++++++++++++++++++++++++++++++++ > include/acpi/acpi_bus.h | 1 + > 2 files changed, 36 insertions(+) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 195635c3462b..9af64c34e286 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -2105,6 +2105,20 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) > device->handler->hotplug.notify_online(device); > } > > +static int acpi_dev_get_first_consumer_dev_cb(struct acpi_dep_data *dep, void *data) > +{ > + struct acpi_device *adev; > + > + adev = acpi_bus_get_acpi_device(dep->consumer); > + if (!adev) > + /* If we don't find an adev then we want to continue parsing */ > + return 0; > + > + *(struct acpi_device **)data = adev; > + > + return 1; > +} > + > static int acpi_scan_clear_dep(struct acpi_dep_data *dep, void *data) > { > struct acpi_device *adev; > @@ -2168,6 +2182,27 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier) > } > EXPORT_SYMBOL_GPL(acpi_dev_clear_dependencies); > > +/** > + * acpi_dev_get_first_consumer_dev - Return ACPI device dependent on @supplier > + * @supplier: Pointer to the dependee device > + * > + * Returns the first &struct acpi_device which declares itself dependent on > + * @supplier via the _DEP buffer, parsed from the acpi_dep_list. > + * > + * The caller is responsible for putting the reference to adev when it is no > + * longer needed. > + */ > +struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier) > +{ > + struct acpi_device *adev = NULL; > + > + acpi_walk_dep_device_list(supplier->handle, > + acpi_dev_get_first_consumer_dev_cb, &adev); > + > + return adev; > +} > +EXPORT_SYMBOL_GPL(acpi_dev_get_first_consumer_dev); > + > /** > * acpi_bus_scan - Add ACPI device node objects in a given namespace scope. > * @handle: Root of the namespace scope to scan. > diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h > index 0b2c4f170f4d..4bed30e61c5b 100644 > --- a/include/acpi/acpi_bus.h > +++ b/include/acpi/acpi_bus.h > @@ -692,6 +692,7 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) > bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2); > > void acpi_dev_clear_dependencies(struct acpi_device *supplier); > +struct acpi_device *acpi_dev_get_first_consumer_dev(struct acpi_device *supplier); > struct acpi_device * > acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const char *uid, s64 hrv); > struct acpi_device * > -- Applied as 5.14 material along the [1/6]. I'll expose a branch containing the 2 patches to pull from later this week. Thanks!