Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp468130iol; Thu, 9 Jun 2022 07:23:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4q9/I0BG+54iQZYjdlJSJeBz1nxmHbReljIeciyejVwRfFXXAHDBAuQSfu4gFV5doCZdQ X-Received: by 2002:a05:6402:908:b0:428:11f5:509d with SMTP id g8-20020a056402090800b0042811f5509dmr45146259edz.253.1654784604088; Thu, 09 Jun 2022 07:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654784604; cv=none; d=google.com; s=arc-20160816; b=qje904GJVRqITDAvazDBa+5505+U+2c746qm5QN3PDf/nChSDxyxBZ89G4bbLfYPA9 eB2XF2SDL4ca8AlcHRKTziecVFyLcgKQiohNJ1gVQp5y8lyAXgus77XdeosKVeDMggRp ya3PJtFD+86Z5z18nQ2vjeinKynQu5AEE5CRf8ouFYJIBfhOdt4FWJfFPDzPQxx79jCP 5NpJeVn41yAfgx0H7kZDc9mcAulLwAcS9egjbG5mXRBny/2wgXUdy6R+r5rFtNxmmlbY OLvJhPmI/o9RAqLG+sROHoBtFhbr/RCJCfPQ50/PBrUsol1ncixC9iKytOuF9RJlB+gH N9TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8aCgnQMhp0s+6J5EsF0SnFPExsKKBBE/BFRKb2pfo5k=; b=onMYdYvxRwvA6jLQ3bsWnWIIJAL6NDon3i2yICdCUG0X2EGELcpuSIOwYWnaujzEc0 r1YtbsZu61aQxI+xGPPkWo8cfBD3JTVwOfoTd5X/ixvu4rHQ7y1jTkzLJYZ0bElX2Zel 6OWSxGF5vrxi8FVHPOt3qFN0+nyDixT0id+ROnGQAzWT45SJ5cVbXQq3zbxyU8gmoIle EErYu9WytpMJ4v+9mnM8x848LJ1jiaTmmHpmkruahF3BzwQDUPEH/me1bDMIOLAtHtK8 Fnwjv5pkbDcoTQeoev48nUd58kA7Yqjzg4THDUulR0G8T0OX4QxS/Zg+Ew4GFCjlmlKS 1rIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp34-20020a1709073e2200b00711d61d0dedsi5090016ejc.593.2022.06.09.07.22.56; Thu, 09 Jun 2022 07:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243983AbiFIOV0 (ORCPT + 99 others); Thu, 9 Jun 2022 10:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245375AbiFIOUm (ORCPT ); Thu, 9 Jun 2022 10:20:42 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0ACF268544; Thu, 9 Jun 2022 07:20:41 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id b3029114fcd8b89a; Thu, 9 Jun 2022 16:20:40 +0200 Received: from kreacher.localnet (unknown [213.134.186.232]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 4C1D766C7CA; Thu, 9 Jun 2022 16:20:39 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Andy Shevchenko , Mika Westerberg , Hans de Goede , Sakari Ailus Subject: [PATCH v1 10/16] ACPI: bus: Introduce acpi_dev_for_each_child_reverse() Date: Thu, 09 Jun 2022 16:06:21 +0200 Message-ID: <2137459.Mh6RI2rZIc@kreacher> In-Reply-To: <1843211.tdWV9SEqCh@kreacher> References: <1843211.tdWV9SEqCh@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.186.232 X-CLIENT-HOSTNAME: 213.134.186.232 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedruddtledgjeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrddukeeirddvfedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekiedrvdefvddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhi nhhtvghlrdgtohhmpdhrtghpthhtohepmhhikhgrrdifvghsthgvrhgsvghrgheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehhuggvghhovgguvgesrhgvughhrghtrdgtohhmpdhrtghpthhtohepshgrkhgrrhhirdgrihhluhhssehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=7 Fuz1=7 Fuz2=7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Make it possible to walk the children of an ACPI device in the revese order by defining acpi_dev_for_each_child_reverse() in analogy with acpi_dev_for_each_child(). Signed-off-by: Rafael J. Wysocki --- drivers/acpi/bus.c | 13 +++++++++++++ include/acpi/acpi_bus.h | 3 +++ 2 files changed, 16 insertions(+) Index: linux-pm/drivers/acpi/bus.c =================================================================== --- linux-pm.orig/drivers/acpi/bus.c +++ linux-pm/drivers/acpi/bus.c @@ -1115,6 +1115,19 @@ int acpi_dev_for_each_child(struct acpi_ return device_for_each_child(&adev->dev, &adwc, acpi_dev_for_one_check); } +int acpi_dev_for_each_child_reverse(struct acpi_device *adev, + int (*fn)(struct acpi_device *, void *), + void *data) +{ + struct acpi_dev_walk_context adwc = { + .fn = fn, + .data = data, + }; + + return device_for_each_child_reverse(&adev->dev, &adwc, + acpi_dev_for_one_check); +} + /* -------------------------------------------------------------------------- Initialization/Cleanup -------------------------------------------------------------------------- */ Index: linux-pm/include/acpi/acpi_bus.h =================================================================== --- linux-pm.orig/include/acpi/acpi_bus.h +++ linux-pm/include/acpi/acpi_bus.h @@ -483,6 +483,9 @@ extern struct bus_type acpi_bus_type; int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data); int acpi_dev_for_each_child(struct acpi_device *adev, int (*fn)(struct acpi_device *, void *), void *data); +int acpi_dev_for_each_child_reverse(struct acpi_device *adev, + int (*fn)(struct acpi_device *, void *), + void *data); /* * Events