Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp810408iog; Mon, 13 Jun 2022 13:31:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1te32iKIqlEbXeqm7L8fMsGNtnYzCeh6CSzICvH02sD5pDanCtqZN8g/b3pgfxoUGRecH30 X-Received: by 2002:a17:907:9496:b0:711:f459:664 with SMTP id dm22-20020a170907949600b00711f4590664mr1309530ejc.704.1655152315506; Mon, 13 Jun 2022 13:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655152315; cv=none; d=google.com; s=arc-20160816; b=oi7k/IdI4bM8gFkaqhxETLuHdOwyuvb2Kb9+WbsJ8yP60N0BZCXlcLmmMRX1sfSG46 OkDYljZmUSDs0KSjr/UeO6X7FrMC+ObDF3biXdKzIS1wXQv85cdmnVDMPs64fdHTyrsy KRPeOKebz3qi7DKp5eWF+Rn3rrNkZxIODZt3X4E5qJ1cN8hbvfrArQ7aI8wD6/ZqrmbO WQpP2fjF0LfaSmfZ1PznJiRitcYL/aAky3Jy5ebkWs4ijdgt1a/9YpcLykOB2BYu15Rx GN+P7KQO5lHj1sEAGKBe8XwTxMbDUrYrJWXB/g+XUKG/bkeUjwLUO2NS4pnItTsQlC6e uPTQ== 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=8jTOYUZY1L2l6gkXI+0EbE6KpdnE/8Tmaz3rhEMaSXw=; b=XVf4/J4latbiRhV9pAtRbmHGg+qGgORbC09QTOZA+41yZ9+Z/EovT7ZEx5sNEkIZbh DJtaxXo+PCzDA3wA11EaVYAfHMbqPXcMIcja6DV4tFD4VW5BdL+qZX6Fcocd5op9PcC1 KyeXue8sDYNuZEP2m/H+iyFmNqw3yxywE6ZA0eUZVt41B676wHRMqFfkTIKsb3IE4epd nOTLypxRAOac2k89IzBEG6lSwIDWbBREzL9OIkjBpas+JRS7eBaY1erU0//x5nqE7QGQ H8I6B4zO3k6StS+dqp6rTvGGZ0M/srubI925TEp0CjHryXou1xp/ns2PSC14Bzm462dN /QEg== 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 ej27-20020a056402369b00b0042dd5fb66d7si8900293edb.433.2022.06.13.13.31.28; Mon, 13 Jun 2022 13:31:55 -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 S233671AbiFMUIN (ORCPT + 99 others); Mon, 13 Jun 2022 16:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346814AbiFMUHN (ORCPT ); Mon, 13 Jun 2022 16:07:13 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D6C85A5A4; Mon, 13 Jun 2022 11:41:10 -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 355df095173aca4e; Mon, 13 Jun 2022 20:41:09 +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 33F8466C81D; Mon, 13 Jun 2022 20:41:08 +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 02/16] ACPI: glue: Introduce acpi_dev_has_children() Date: Mon, 13 Jun 2022 20:06:18 +0200 Message-ID: <4765000.31r3eYUQgx@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: gggruggvucftvghtrhhoucdtuddrgedvfedruddujedguddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekjedrieegnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehinhgvthepvddufedrudefgedrudekjedrieegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeejpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghnughrihihrdhshhgvvhgthhgvnhhkoheslhhinhhugidrihhn 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 Define acpi_dev_has_children() as a wrapper around acpi_dev_for_each_child() and use it to check if the given ACPI device has any children instead of checking the children list head in struct acpi_device. 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: * Add R-by from Andy. --- drivers/acpi/glue.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Index: linux-pm/drivers/acpi/glue.c =================================================================== --- linux-pm.orig/drivers/acpi/glue.c +++ linux-pm/drivers/acpi/glue.c @@ -77,12 +77,22 @@ static struct acpi_bus_type *acpi_get_bu #define FIND_CHILD_MIN_SCORE 1 #define FIND_CHILD_MAX_SCORE 2 +static int match_any(struct acpi_device *adev, void *not_used) +{ + return 1; +} + +static bool acpi_dev_has_children(struct acpi_device *adev) +{ + return acpi_dev_for_each_child(adev, match_any, NULL) > 0; +} + static int find_child_checks(struct acpi_device *adev, bool check_children) { unsigned long long sta; acpi_status status; - if (check_children && list_empty(&adev->children)) + if (check_children && !acpi_dev_has_children(adev)) return -ENODEV; status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);