Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp467983iol; Thu, 9 Jun 2022 07:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+NkrB5hdDO7Hf+kIMqWflOfvrYYGrO3LLA9M+cI7bLEl5HqElakKwdkOMytYrO9jthyvR X-Received: by 2002:a17:90a:7023:b0:1e8:a692:b3e9 with SMTP id f32-20020a17090a702300b001e8a692b3e9mr3712788pjk.176.1654784594301; Thu, 09 Jun 2022 07:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654784594; cv=none; d=google.com; s=arc-20160816; b=Hmh2j29aYL1ZpFRz4+oHJM7yrUSXRYlz6DUCaUm/6mbJELm3u818N3ehhX1aJURIE6 SWZTzH+iVI4soSsacNZxkbgkTfUaB/Iuz3sVM2BxPKYUCru6pLnZQXlZvkgRkYMU456O p4Iv4h86UXukLP3PwZRYUUOornQx7O80lcBUM7WQwKDpvbk2XyNgGKHiiBmFzAjDn3SF Du0q+y+4RKU8QJ9t+R/0/p279S1R+CuDShkLBRLLdasb7gEA8hc3OoevrKI++pKSLr5K 6TcTrH/MfOybe2pr9sIYbxl2fHAZZ/pL7i2vFypce5ZoHXulKrINOOviHKqbjv0Z7LjN 8VNg== 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=Nxj5MUTUUxW5jGKf3KTxLJIqolwJvlxKKUOSQ8ox++U=; b=07j3uS5AMJUipu8QW6ZJDgGrymjusPbJNSDtpPt1QehqAQNSaO3lJTKzLkwrpXkPqe D8D3HROOgCV4bDyt86Q+OcGbMsqKgkjwuYQ/coQREMadOMYSSlW8VbSEg3S/ymw4OTbs yrcRPwq26Gc5lW65q7rY880IK1xYtsFYToX3wRhUG/6rOoTJMxrxPZJeJfpXEKHCefJi 2ttUY04uWBhtDe4NggSphXGdht0lQyP9w1K0gLCGUHbxFz++ixtEAX16yW93388QKUod yG9VPEHWyDsroHfsfFG6Gy1b5AgWWqomwuHojRljBTv/DNDKc6AznI4vp46Ql3SCL3jy AusA== 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 h1-20020a170902f54100b0015eb10a9f67si39066839plf.379.2022.06.09.07.22.57; Thu, 09 Jun 2022 07:23:14 -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 S1344003AbiFIOVp (ORCPT + 99 others); Thu, 9 Jun 2022 10:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244867AbiFIOUv (ORCPT ); Thu, 9 Jun 2022 10:20:51 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A532C369A; Thu, 9 Jun 2022 07:20:48 -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 85a8a82d3f3e703d; Thu, 9 Jun 2022 16:20:47 +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 155AD66C7CA; Thu, 9 Jun 2022 16:20:46 +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 06/16] ACPI: container: Use acpi_dev_for_each_child() Date: Thu, 09 Jun 2022 15:58:24 +0200 Message-ID: <3131424.5fSG56mABF@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: gggruggvucftvghtrhhoucdtuddrgedvfedruddtledgjeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppedvudefrddufeegrddukeeirddvfedvnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekiedrvdefvddphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepjedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhi 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 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 --- drivers/acpi/container.c | 18 ++++++++++-------- 1 file changed, 10 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,19 @@ 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)