Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp819142iog; Mon, 13 Jun 2022 13:45:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1R6/kPw8W7Gkc7MHHWLWx6UIIH0+k8PP0kH8fNhyqob068J1+pcRcrTmJ632p8Fqn81GE X-Received: by 2002:a05:6402:4248:b0:431:1133:aecb with SMTP id g8-20020a056402424800b004311133aecbmr1850014edb.222.1655153144221; Mon, 13 Jun 2022 13:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655153144; cv=none; d=google.com; s=arc-20160816; b=YojGM4wDnBmaskS5cGFGebh5elJKfEfp52yCFeDkm5psk3JnklhJEVOth21/62H+/b 9CRrfss1T74QJS2LdUk51CSgwn9+eJSLRgPKGVuE0uLxpE6v2Z9pbQDX2pfNTDBa0xv1 ll9OqSYzMMxxtJyDZMddJ2UQFFEAOtGIQdp6M124YQgSD5WmqLpaGtxy/UYKFbuZ07LX OOzF3QTz81wsFcn3NVuqw7Fl0VsOEmgs9HxvnF+0b+Whl6NdIZ+snOXxyRcH0M87U8Jm F8xg3jHAmDo41Z+zxAzFYlmMZjtuUfR7zsGML/Cs95TQ1E7Vx3unHC2YNe9PMOlFu0j8 KJOw== 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=N/OUCd8lzLauynUO0yXIawazjkjCx1KpFq5HOxxqxPM=; b=HY3yeZFGgieQb7B6sXaQ35cwqSiheJpTs////n7dTcS5Rl7EHsl4DstWKVTKXd0vZG eyOcimQ1JY8b99b1k/A1IH5CNeeCzLXWVZ6xXZ/G5olSNArA/Q2mgM9B7c78YyOoAZKT 2pCmv7jrHG+i5kJDdaI2sgxyEjAkdrP5GwQERnBu6p5G/xFIRgY1eaNjltJZl9Izg2Cq ikIzpczB0avaYHB5esCLK85lEREIQZDibpQbtV0rEGrUsWf7t2uQ0A0IY2IZpWBj7YKv 0wJAMirsMZJwhgqA/B+n3NU7BDpBmjae2lPtvgFsZfUGOhfFa6w+7ItLDX8rYo1bKkQ/ cDoQ== 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 i26-20020a056402055a00b0042df84a89f1si9680641edx.138.2022.06.13.13.45.19; Mon, 13 Jun 2022 13:45:44 -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 S244249AbiFMUG5 (ORCPT + 99 others); Mon, 13 Jun 2022 16:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235224AbiFMUGH (ORCPT ); Mon, 13 Jun 2022 16:06:07 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA51BDA1F; Mon, 13 Jun 2022 11:41:05 -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 aa3b020eaa639e53; Mon, 13 Jun 2022 20:41:04 +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 82C2066C81D; Mon, 13 Jun 2022 20:41:03 +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 06/16] ACPI: container: Use acpi_dev_for_each_child() Date: Mon, 13 Jun 2022 20:15:26 +0200 Message-ID: <10114811.nUPlyArG6x@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 Instead of walking the list of children of an ACPI device directly, use acpi_dev_for_each_child() to carry out an action for all of the given ACPI device's children. This will help to eliminate the children list head from struct acpi_device as it is redundant and it is used in questionable ways in some places (in particular, locking is needed for walking the list pointed to it safely, but it is often missing). 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/container.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) Index: linux-pm/drivers/acpi/container.c =================================================================== --- linux-pm.orig/drivers/acpi/container.c +++ linux-pm/drivers/acpi/container.c @@ -23,17 +23,18 @@ static const struct acpi_device_id conta #ifdef CONFIG_ACPI_CONTAINER -static int acpi_container_offline(struct container_dev *cdev) +static int check_offline(struct acpi_device *adev, void *not_used) { - struct acpi_device *adev = ACPI_COMPANION(&cdev->dev); - struct acpi_device *child; + if (acpi_scan_is_offline(adev, false)) + return 0; - /* Check all of the dependent devices' physical companions. */ - list_for_each_entry(child, &adev->children, node) - if (!acpi_scan_is_offline(child, false)) - return -EBUSY; + return -EBUSY; +} - return 0; +static int acpi_container_offline(struct container_dev *cdev) +{ + /* Check all of the dependent devices' physical companions. */ + return acpi_dev_for_each_child(ACPI_COMPANION(&cdev->dev), check_offline, NULL); } static void acpi_container_release(struct device *dev)