Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp806926iog; Mon, 13 Jun 2022 13:26:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHz3QwnVC0fv+IXHYf3G3x5kcMfu/t+44vEddTc/HI4ZvG4SGPA3NdrB41Nj3/Xsz/H2mF X-Received: by 2002:a63:8541:0:b0:401:9c13:ffca with SMTP id u62-20020a638541000000b004019c13ffcamr1155965pgd.417.1655152003503; Mon, 13 Jun 2022 13:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655152003; cv=none; d=google.com; s=arc-20160816; b=oYRQU6+bVgU97NcJSCbWWnWkHZoUUESycwQ4wF9so7ibm2KeD4Yq0PI9hPH0cWrIMV /nS6JhMK1HJweJEliv/asdQrVFNEDoZmVqbvt7Rd7VxVaFwCMj5QcSUeHofsTCoxLaGY h1rq7IZtY/Y8K+mkq4RRhl9jplMbzZseW86EehjVyZsp1rgPXUnV7NJVVAAM87eRpSIr 8qCtB9z6XGesAe+7mwSLLZw9usu2jg5MKP4m9ZebvGROesHuDkcdKkRJ2O26k3KCua0F O8kux/ZSjkPsBQperTW/02JxqepZer8pxEatwKFc9xEsPbudcvP9QeFvb65f0u8mKsMs y6Ag== 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=v1uEc9dC15qExZyJMZTt/yRns8+UgABeol8ODtgMdDQ=; b=xAu88mi5qMIjVPI6oRfAOBUhNADiyePRNgId7/DVChQxLlQECl+8oJNw9LmfCpnmIj 8ZkvR4z6KXzak8Kz6DCXFE9NegoD7ZAJpAdXgeRHdzPYqwY1TNkQN+4gQsvhwXxQXwpi fj/0JVXCd5zb4s9CyOqdXfPVS1hiSRKF7xXZhAR5POZgJdLGWClaLnXGAEteXpyhf9u2 tVtFePVGSdtcVaMQcpgDPHieNRP1bpe8AcE7VE9AWeyIzXCAY4MZsNq2ZpFJSPeMEdkj v+ipfweGmHY8qZdhT7nImBgG1mar99WE+BjVAZCg+liI+miLMrm5QwcOaSf/ooxSdcLD hIGw== 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 a5-20020aa79705000000b0051bc46f9672si10690940pfg.45.2022.06.13.13.26.31; Mon, 13 Jun 2022 13:26:43 -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 S1350600AbiFMUHb (ORCPT + 99 others); Mon, 13 Jun 2022 16:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347539AbiFMUGj (ORCPT ); Mon, 13 Jun 2022 16:06:39 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1149062BEC; Mon, 13 Jun 2022 11:40:59 -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 1efb45c857d6edf4; Mon, 13 Jun 2022 20:40:58 +0200 Received: from kreacher.localnet (unknown [213.134.187.64]) (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 A920366C81D; Mon, 13 Jun 2022 20:40:57 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Linux PM , Andy Shevchenko , Mika Westerberg , Hans de Goede , Sakari Ailus Subject: [PATCH v2 10/16] ACPI: bus: Introduce acpi_dev_for_each_child_reverse() Date: Mon, 13 Jun 2022 20:26:47 +0200 Message-ID: <1813751.atdPhlSkOF@kreacher> In-Reply-To: <2653857.mvXUDI8C0e@kreacher> References: <1843211.tdWV9SEqCh@kreacher> <2653857.mvXUDI8C0e@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.187.64 X-CLIENT-HOSTNAME: 213.134.187.64 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedruddujedguddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekjedrieegnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekjedrieegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghnughrihihrdhshhgvvhgthhgvnhhkoheslhhinhhugidrihhn thgvlhdrtghomhdprhgtphhtthhopehmihhkrgdrfigvshhtvghrsggvrhhgsehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohephhguvghgohgvuggvsehrvgguhhgrthdrtghomhdprhgtphhtthhopehsrghkrghrihdrrghilhhusheslhhinhhugidrihhnthgvlhdrtghomh 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 Reviewed-by: Andy Shevchenko --- v1 -> v2: * Do not break the acpi_dev_for_each_child() call line (Andy). * Add R-by from Andy. --- drivers/acpi/bus.c | 12 ++++++++++++ include/acpi/acpi_bus.h | 3 +++ 2 files changed, 15 insertions(+) Index: linux-pm/drivers/acpi/bus.c =================================================================== --- linux-pm.orig/drivers/acpi/bus.c +++ linux-pm/drivers/acpi/bus.c @@ -1115,6 +1115,18 @@ 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