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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 18860C43461 for ; Thu, 20 May 2021 14:11:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8FC161355 for ; Thu, 20 May 2021 14:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243564AbhETONE (ORCPT ); Thu, 20 May 2021 10:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239826AbhETOMH (ORCPT ); Thu, 20 May 2021 10:12:07 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C85FC061358; Thu, 20 May 2021 07:09:44 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id d11so17799701wrw.8; Thu, 20 May 2021 07:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P0640m4NeG10qjpch2cOVQh+bHv5ZQPDXdCUWnzfzdA=; b=jyY6jgxb4uYgojvcdDZhGF/ZE/7r/S99lSJ7oh3FPWDSTMviwlW16F5cOpmkZ8PuAa BUNtTuJwvoVhthVmHa2h2IOFreTk1naTYUAL7042VYRa7/AFA6S4LMYJ4VneKAe08P7s YK0M+vSuRytKbU2Bh3fp4XMrt2nkJ6M8s4MO+BZuCD7Ot42RDedDxctDEmA6NkRwlZyL r/qMcwsc25251vnqo2PG2xzeh7IToVXVzmS9XMVOkXIdlbc3K+IrLevBoRLpRPXLuXYU xRMdV/5eftsnmLQNh5T3qk88xjfTnrl9f6/pTRLM63vTIO+uL7IBmxqZNgUZ++19Yh7C MNbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P0640m4NeG10qjpch2cOVQh+bHv5ZQPDXdCUWnzfzdA=; b=soGk1o2romaDxgskQx1byqA3Gnu4QFZeMEXePfb9DgQlWCCoD1d89PNMOBhV5ELt8A weADUWLE48TP/m+F1WBOQscvFfpRt0XngOsKU/DGu10uKHt8dS/j3EMgsCWw8MHhAkS/ pbw7DwVPObDa994pfm1nnBh2Ljf8LVNJvt8CVmTb6IoyGG8Jg1X69Rjom/GO8c2DpHgn 6e/GsAMOm3EXd5ZYDADTtEJB0yoHL+KVf4ekrLQFEOq+54gLNTsoKGkg84c2/Z2Xg8df NhxNO4ntqCLchuvQzKlykT8kZoZcjGf8xAH3S/OVwFV2oemv5vXM2eEhT1hFtyvyT1ir w5/Q== X-Gm-Message-State: AOAM530BhPDv0ohnjpCmLPw7wrWrvjriPoCX6C5L66R6qa5cixZLKdae dKw/q00r2ETxBUurLiR1+DI= X-Google-Smtp-Source: ABdhPJz+vIYzRjGHJK4yLN2l9Kp317miX7WKHiinnsfztPJK0si2S9oymiHzHkrOgZEWqNQeUZ/YjQ== X-Received: by 2002:adf:ebc4:: with SMTP id v4mr4435158wrn.217.1621519782899; Thu, 20 May 2021 07:09:42 -0700 (PDT) Received: from valhalla.home ([91.110.20.117]) by smtp.gmail.com with ESMTPSA id m6sm8411974wml.3.2021.05.20.07.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 07:09:42 -0700 (PDT) From: Daniel Scally To: "Rafael J . Wysocki" , Andy Shevchenko , Daniel Scally , Wolfram Sang , Lee Jones , Hans de Goede , Maximilian Luz , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org Cc: Len Brown , Mika Westerberg , Russell King , Linus Walleij , Bartosz Golaszewski , Mark Gross , Robert Moore , Erik Kaneda , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, Andy Shevchenko Subject: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device Date: Thu, 20 May 2021 15:09:22 +0100 Message-Id: <20210520140928.3252671-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210520140928.3252671-1-djrscally@gmail.com> References: <20210520140928.3252671-1-djrscally@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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) +{ + 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; + + 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 + * @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 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 A821FC43616 for ; Thu, 20 May 2021 14:12:25 +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 264636121E for ; Thu, 20 May 2021 14:12:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 264636121E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mAmxFFU3+Wp5dkAExL+WKUifenJlt/G4d4EB3gYX4uo=; b=n6VXrEPcGuUBF2HSTKraPrDiqt VG0pQRWP+glUuUVasUXwmZBWBnHkRlgv8+UR7jMR4loiTfQbeXW6zY1Hcbxei+A6Ul44Ia+5f8kA4 IUZjOTREXrA4srjVMe+ZNByOpYAucd1ZCF+Kxl5703xuqB8XODdo/B+xFFAXXZVZp9Bx5lcV+Eh11 w5Ba7k91bLVsF2fj57EJWxwZLxHnSwiO187tOPk/5OYvHozXHj37fzoJIHHxAJV59XLkR8YGGY42s lAW0vgaiUJXgKUngj4+jLVG2yHz3L4LQ1EfgtQ7nwutpzU+d6TWpBZG7XOIgbcMkLbF/5WYx52R5+ R+ART+QQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ljjNc-001N0q-0Q; Thu, 20 May 2021 14:10:30 +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 1ljjMz-001Mt5-6F for linux-arm-kernel@desiato.infradead.org; Thu, 20 May 2021 14:09:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=P0640m4NeG10qjpch2cOVQh+bHv5ZQPDXdCUWnzfzdA=; b=ZEjCkVH/7DyjN4Xv6FmYXiDY/Z mtyON7RC3N29USV5+5QfBrfIsQ+eTPT6bcZ2e53ODIRxGEGnUjmCFKFtlnLEOrFbvT7DnlgVL/g7m x0VW6xwXWfrdbybKHln2cU+zNNBQJTd7VfAzErSn4cjXku9K5VjoMvWimVmfY9qG1/C6NbZCIKc8S 4sb7c6t3z2C3nCs4y7OEir3h/gwfrw0NrSfbCjeEJSxB747GrWyrUdi9URJ7KA9YPuIv9LU+TLM3m CA4KjwU+taGQ2fI8f3HXHycyoCKRm9/y32mhUCTVVtngyXLObBqG2RWcIllWTWVpo6Y4axbU8IH66 eAXeCAnQ==; Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1ljjMu-00GPNU-O5 for linux-arm-kernel@lists.infradead.org; Thu, 20 May 2021 14:09:47 +0000 Received: by mail-wr1-x42c.google.com with SMTP id i17so17801755wrq.11 for ; Thu, 20 May 2021 07:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P0640m4NeG10qjpch2cOVQh+bHv5ZQPDXdCUWnzfzdA=; b=jyY6jgxb4uYgojvcdDZhGF/ZE/7r/S99lSJ7oh3FPWDSTMviwlW16F5cOpmkZ8PuAa BUNtTuJwvoVhthVmHa2h2IOFreTk1naTYUAL7042VYRa7/AFA6S4LMYJ4VneKAe08P7s YK0M+vSuRytKbU2Bh3fp4XMrt2nkJ6M8s4MO+BZuCD7Ot42RDedDxctDEmA6NkRwlZyL r/qMcwsc25251vnqo2PG2xzeh7IToVXVzmS9XMVOkXIdlbc3K+IrLevBoRLpRPXLuXYU xRMdV/5eftsnmLQNh5T3qk88xjfTnrl9f6/pTRLM63vTIO+uL7IBmxqZNgUZ++19Yh7C MNbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P0640m4NeG10qjpch2cOVQh+bHv5ZQPDXdCUWnzfzdA=; b=jJWHCDFsvvjtDC1JFNzGho+e08JvEoH/6LLz2AhFz4ISX23FSAMwvyz+z2v1lE9O7E s3jX9teZDLnnfGehsuqa8j9AAboReHAcXxUIpIat/8NnF32YDk5I7v8muMq0Wx4LKhS+ TrOaV13WjfQKVtUGPuVAh+CW2BaIkj9T4nVimLzwlMlrDd/RXbnhbWLcv5dHCwwk4WLe Ev/kk+/gwDfC2+zssKV3wpyuNVSy+nJ3D86er5F4G8E0UttYZ0D7YksnHOEaH2mSPzRy Ggu5huUVul7UDW4mYzPe3vAMnooBxVYBq9x5Wqyzj+HtoKip14Lztnom7gpE1xnmuXfg Zbhw== X-Gm-Message-State: AOAM533inWOE8Tv2IhJYcHxVU4l2C6s/CGfvCuJNCXOwFtTDvP80+c+N 2L5u3piF/8McPD/fJKN6lKo= X-Google-Smtp-Source: ABdhPJz+vIYzRjGHJK4yLN2l9Kp317miX7WKHiinnsfztPJK0si2S9oymiHzHkrOgZEWqNQeUZ/YjQ== X-Received: by 2002:adf:ebc4:: with SMTP id v4mr4435158wrn.217.1621519782899; Thu, 20 May 2021 07:09:42 -0700 (PDT) Received: from valhalla.home ([91.110.20.117]) by smtp.gmail.com with ESMTPSA id m6sm8411974wml.3.2021.05.20.07.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 07:09:42 -0700 (PDT) From: Daniel Scally To: "Rafael J . Wysocki" , Andy Shevchenko , Daniel Scally , Wolfram Sang , Lee Jones , Hans de Goede , Maximilian Luz , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org Cc: Len Brown , Mika Westerberg , Russell King , Linus Walleij , Bartosz Golaszewski , Mark Gross , Robert Moore , Erik Kaneda , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, Andy Shevchenko Subject: [PATCH v4 2/8] ACPI: scan: Add function to fetch dependent of acpi device Date: Thu, 20 May 2021 15:09:22 +0100 Message-Id: <20210520140928.3252671-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210520140928.3252671-1-djrscally@gmail.com> References: <20210520140928.3252671-1-djrscally@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210520_070944_808072_9E2C40A5 X-CRM114-Status: GOOD ( 19.34 ) 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 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) +{ + 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; + + 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 + * @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