Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp883061pxf; Wed, 7 Apr 2021 14:05:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRLdeZ4NRpbMXAP6JXoN2Z2h+fpEmi8tjIGH/W0TjcxI9yYclMDqfzFedSvc7uT0Ip1l/S X-Received: by 2002:a92:1a4f:: with SMTP id z15mr4240175ill.7.1617829510814; Wed, 07 Apr 2021 14:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617829510; cv=none; d=google.com; s=arc-20160816; b=AQ6aWcjAGuQQuSLfJfVOjkD4lekjsE+CtuFXnMpTmscjtYhUDa0vBXLTraN5lCpkvG FszfmbwcLHRjJ/twf0KxJFvajw3ZMe5A7eSQANJrUylCKQP8bXvQkVWWBnJV7myv6X1O TokrAwUVQhXFySDJObuq09R+PZGkQOgFVLg1cTYwSbuMyITSS4aZ2UpDWJqRkM0QdA7O xqdWBTwRN/2kflXZq2rG+1k1POVG7/+C0ZkJuR/fax4YxbBEgUceNmdtrsT2yVifhBlw 5xZj47zBfT50skLIB7NvShM6nqlOjKDIcEhmgP1AkQkowCJyEQyzFadfnMmU1pmop9TK n5QQ== 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=v+qhdbiyutxuXJOHi3+ZF8vO/hK6HjK5H++qRg0Dq88=; b=dSJ2yYUudrZOazogRM1YwnL53vehqoK0EpmzSy3iZ+hZ0GtejyUcLHd7uwmEitHJKd BH9/yOGRpPnFHNbRVswqIlWNrE5oFYY+i4AGAXoHfER9BgdCm+/9WobptKncRYETaoKA zRXLcVAt2rCd0uE1OQ2ijKwR40qfAkxydBVGy9eYJPrUDoH7UsasQ3nP+VkA9LTxIdJh yvqE1G97ut0NT0OLyhIXDvb9I8Pi/U3iOTidi8EB3BVapz3kIi5bJ8leGcHbJkIcOnmK 8Aru4nPf9G8Tgg4zd0/+kla08mMT9rF20RHSEnUDNOy3lTFrGhaJC+NRg7vdNWaOeENv 3BCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si21728830ilq.94.2021.04.07.14.04.57; Wed, 07 Apr 2021 14:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352998AbhDGOeY (ORCPT + 99 others); Wed, 7 Apr 2021 10:34:24 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:50430 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352999AbhDGOeH (ORCPT ); Wed, 7 Apr 2021 10:34:07 -0400 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 2.0.3) id 6ec13df0c764e0e7; Wed, 7 Apr 2021 16:33:56 +0200 Received: from kreacher.localnet (89-64-81-116.dynamic.chello.pl [89.64.81.116]) (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 AE642669203; Wed, 7 Apr 2021 16:33:55 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Hans de Goede Subject: [PATCH v1 2/5] ACPI: scan: Rearrange checks in acpi_bus_check_add() Date: Wed, 07 Apr 2021 16:30:56 +0200 Message-ID: <12741615.uLZWGnKmhe@kreacher> In-Reply-To: <2192169.ElGaqSPkdT@kreacher> References: <2192169.ElGaqSPkdT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.81.116 X-CLIENT-HOSTNAME: 89-64-81-116.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrudejjedgjeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdeigedrkedurdduudeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeelrdeigedrkedurdduudeipdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohephhguvghgohgvuggvsehrvgguhhgrthdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Rearrange the checks in acpi_bus_check_add() to avoid checking the "type" twice and take "check_dep" into account only for ACPI_TYPE_DEVICE objects. No intentional functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/scan.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -1831,7 +1831,7 @@ static void acpi_scan_init_hotplug(struc } } -static u32 acpi_scan_check_dep(acpi_handle handle) +static u32 acpi_scan_check_dep(acpi_handle handle, bool check_dep) { struct acpi_handle_list dep_devices; acpi_status status; @@ -1844,7 +1844,8 @@ static u32 acpi_scan_check_dep(acpi_hand * 2. ACPI nodes describing USB ports. * Still, checking for _HID catches more then just these cases ... */ - if (!acpi_has_method(handle, "_DEP") || !acpi_has_method(handle, "_HID")) + if (!check_dep || !acpi_has_method(handle, "_DEP") || + !acpi_has_method(handle, "_HID")) return 0; status = acpi_evaluate_reference(handle, "_DEP", NULL, &dep_devices); @@ -1925,6 +1926,12 @@ static acpi_status acpi_bus_check_add(ac if (acpi_device_should_be_hidden(handle)) return AE_OK; + /* Bail out if there are dependencies. */ + if (acpi_scan_check_dep(handle, check_dep) > 0) { + acpi_bus_scan_second_pass = true; + return AE_CTRL_DEPTH; + } + fallthrough; case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */ type = ACPI_BUS_TYPE_DEVICE; @@ -1942,27 +1949,12 @@ static acpi_status acpi_bus_check_add(ac break; case ACPI_TYPE_POWER: - type = ACPI_BUS_TYPE_POWER; - break; - - default: - return AE_OK; - } - - if (type == ACPI_BUS_TYPE_POWER) { acpi_add_power_resource(handle); + fallthrough; + default: return AE_OK; } - if (type == ACPI_BUS_TYPE_DEVICE && check_dep) { - u32 count = acpi_scan_check_dep(handle); - /* Bail out if the number of recorded dependencies is not 0. */ - if (count > 0) { - acpi_bus_scan_second_pass = true; - return AE_CTRL_DEPTH; - } - } - acpi_add_single_object(&device, handle, type, sta); if (!device) return AE_CTRL_DEPTH;