From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52DE0C433ED for ; Thu, 20 May 2021 18:35:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1FBF610CC for ; Thu, 20 May 2021 18:35:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1FBF610CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=evqZ8VTSfQgrdH0l4Wu2dum+AU5PP43U/rkYFwrCOA4=; b=ZyIBszKer4aZVdiFgHH76MM4wa AdCPWxGgnOfuekB3bBXWzhdvfFjLEypBkxZ96BLTjNXt6r8bMXepIT23dgpq50YpGfUN7+x5tugxL y6oMy/TRNFl7O2vgSDiXnj0lSjmbX1FMTkC0FP4Ue9CCSzOqDUalnuVGPr4Vs+YA7ZXlq8oY2AQdG YqgUwc8SDE2vOsMCm3balwiY1d/NrNmObvtX/HA/i68uDmnFpdJbAae4nzDhvtfY3WmGpQ9cS7HZH Y5mdHkKrL/r6BGLkvP4h9zVJY7WYjfobCd9kK+nimxCijva4qDf79v3Kln7Ry4LrppBVSPdsp5oLg 7s+U74MQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljnUK-002HN3-Pp; Thu, 20 May 2021 18:33:40 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljnUG-002HMh-Ry for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 18:33:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=VpIZNz0K+hrxnCAMqgX+GPbbK86F0GzoMq8JmMIGB7w=; b=mnOmi5Q2Oiu5p85au2UehHj9Ya iHc1wSY1CY00cE6VwXON81pPrFdhZiHxOP8TNuj4ZdnCWlaCc+Wz8Ct2zDKMQhgTpWCJaxYk0U18Q CdRg+HzprlFZ7zlc/DN5VPT/dDZhlZmnij1jN2j1lmkUDX8/7lHrsyqztGLAuIU97ZAuT5rrg+5qn fGywjKajw9yl7a7R9D2ROHbq/i02C1mo74HuUWM+MVX3vnd89IvqiKy2gNdOzv0NW5iAPEQpTfSAJ 6yW1klJxGQrS+ztrspFJsxxfeZczqnfi/uHhHtyhzT7Ke7VHJZNSwitbhGAopvh+QAgnrlf14Bayj gZPWKgGQ==; Received: from mail-oo1-f44.google.com ([209.85.161.44]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljnUE-00GZlE-92 for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 18:33:35 +0000 Received: by mail-oo1-f44.google.com with SMTP id f22-20020a4aeb160000b029021135f0f404so948973ooj.6 for ; Thu, 20 May 2021 11:33:33 -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=VpIZNz0K+hrxnCAMqgX+GPbbK86F0GzoMq8JmMIGB7w=; b=lCrw8f8x9G7/EVxWAJAfH/047QIguJbcm6RP1x8dR4tF1O012EnE4bSuPZeWM6GaIw U9eZPZp83TQNtZzZLpZQqxfNYZbMqO04y3KNON3GrCGnGA10XvcNr/h6SbClrZ25B6dM 6k4AhPwSU2hw350pA9wGnjxWxHawFE14gopkLegNzoRLQfP+swUYCXNs1TIFdJH/WzjV gassSSOEyduDowzXDC1uMwLsw5jeYOBHmHIGiLE7UMNWsB1NYDRv3zPhAWeJj/n7mEI5 kC61ID0CfDfe4T/ztTsyZqK+WCfK0+Lh48MrG6XWJSep0iJAKt1LADKl7xU/a2NgMZXC EbFg== X-Gm-Message-State: AOAM533Vw9ydm/yfSc4t2yVvdARDromk5GVjTFem8gRYboVtHzncKXkJ Vmz+TnEX0A+AQ8hNLlbqlblhc3c7b6JAKWrWmy/+r3g+vk8= X-Google-Smtp-Source: ABdhPJyt7I5FNcJxtfGw3djcsM8WjYoSDjCWd/Wk635t7zznxdsE+ePyb48FtPDEjnEzSsgrW+Rdz3XedxcVLKfq4P0= X-Received: by 2002:a4a:e5d5:: with SMTP id r21mr4913042oov.1.1621535612897; Thu, 20 May 2021 11:33:32 -0700 (PDT) MIME-Version: 1.0 References: <20210520140928.3252671-1-djrscally@gmail.com> <20210520140928.3252671-3-djrscally@gmail.com> In-Reply-To: <20210520140928.3252671-3-djrscally@gmail.com> From: "Rafael J. Wysocki" Date: Thu, 20 May 2021 20:33:21 +0200 Message-ID: Subject: Re: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device To: Daniel Scally Cc: "Rafael J . Wysocki" , Andy Shevchenko , Wolfram Sang , Lee Jones , Hans de Goede , Maximilian Luz , Linux Kernel Mailing List , ACPI Devel Maling List , Linux ARM , "open list:GPIO SUBSYSTEM" , linux-i2c , Platform Driver , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , Len Brown , Mika Westerberg , Russell King , Linus Walleij , Bartosz Golaszewski , Mark Gross , Robert Moore , Erik Kaneda , Laurent Pinchart , Kieran Bingham , Andy Shevchenko X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_113334_343531_91D108E8 X-CRM114-Status: GOOD ( 29.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, May 20, 2021 at 4:11 PM 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 v3: > > Both new functions were renamed. > > drivers/acpi/scan.c | 38 ++++++++++++++++++++++++++++++++++++++ > include/acpi/acpi_bus.h | 1 + > 2 files changed, 39 insertions(+) > > diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c > index 195635c3462b..1a76fbdfa669 100644 > --- a/drivers/acpi/scan.c > +++ b/drivers/acpi/scan.c > @@ -2105,6 +2105,21 @@ static void acpi_bus_attach(struct acpi_device *device, bool first_pass) > device->handler->hotplug.notify_online(device); > } > > +static int acpi_return_dep_dev(struct acpi_dep_data *dep, void *data) What about calling this acpi_get_first_consumer_cb()? > +{ > + struct acpi_device *adev; > + int ret; > + > + ret = acpi_bus_get_device(dep->consumer, &adev); > + if (ret) > + /* If we don't find an adev then we want to continue parsing */ > + return 0; > + > + *(struct acpi_device **)data = adev; And it can do the get_device() here, can't it? So maybe use acpi_bus_get_acpi_device() instead of acpi_bus_get_device()? Would be simpler. > + > + return 1; > +} > + > static int acpi_scan_clear_dep(struct acpi_dep_data *dep, void *data) > { > struct acpi_device *adev; > @@ -2168,6 +2183,29 @@ void acpi_dev_clear_dependencies(struct acpi_device *supplier) > } > EXPORT_SYMBOL_GPL(acpi_dev_clear_dependencies); > > +/** > + * acpi_dev_get_dependent_dev - Return ACPI device dependent on @supplier And what about calling this acpi_get_first_consumer() ? > + * @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_dependent_dev(struct acpi_device *supplier) > +{ > + struct acpi_device *adev = NULL; > + > + acpi_walk_dep_device_list(supplier->handle, acpi_return_dep_dev, &adev); > + > + if (adev) > + get_device(&adev->dev); > + > + return adev; > +} > +EXPORT_SYMBOL_GPL(acpi_dev_get_dependent_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..68d378207704 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_dependent_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 * > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel