Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp800481pxb; Sat, 18 Sep 2021 19:17:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT65hKhczikzLcP4COS+IqyxxUbA9e6hkqBtdaBrTSzh7QuLXdwd+SelVIsSZqh94LeVxx X-Received: by 2002:a05:6e02:1c84:: with SMTP id w4mr11543379ill.195.1632017833639; Sat, 18 Sep 2021 19:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632017833; cv=none; d=google.com; s=arc-20160816; b=K8ZoAl3I9GVRVFuJ1CfCbiDiGnix0HX7fOZ848xSw9GuPtf4QNMkFDpWR/maGuoIf/ 2fv0tD/wleLIPAldNxpA49xbS7HCD+fToc9H6l2w5BDYefqT72XOPyJGYx4U1gKMtGl1 RXkLB54ufmy0R91Xvjpg+AZCXlAtFGU+SytfZ99BT5oG4WNlKO7gMFXmPvIJcrYXpWwf tBUtgvxb4YnULsOwkurY6F19qInREShzBRIm6QZQX01OCuOaVPo5kjRLjIvYDgQs/btU C8+dMElfpok1CEEPxKYiqhKjL4qicpIX1YISfVJR9wwta8b8aav69EtDp1HXtQdzbndu klGg== 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=njraMYvFixzFdi8CKML6uYhX7o7YECq0Ouo0oH5Nrvo=; b=YnSRryQYr6AZtLThZhCcujHanXiQuO2MIPzj2hgbsr2XBLxu5Slh4duSZ/fEdEv2df ngbKsI3fVahuXUxsRrF78Q6ERhMRt2clsFF0G0hN8X5F1WdwGj7rGDjJHU17I7qGkRWA tbJnppxpCsJRzNId1NdZARsbvDIS/4Hkf1H4WNYVjlmlAJPiYBmIECFHRQNY0Fc9iib/ y+aXOSXHQqgGsCGqTDDoQ89SHQ33ORUYVnqhZzAkwGLk3Rv9kF2p+hp+Io5rSjBawSJV UELtSShvg97nomlWAQt9dVFTlW0i1Kt8oDtHgN7h1+6TDRDj0sgGhG8EEB/3/wN5qL5T bwPA== 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 y28si10055858iot.48.2021.09.18.19.17.02; Sat, 18 Sep 2021 19:17:13 -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 S236920AbhIRND7 (ORCPT + 99 others); Sat, 18 Sep 2021 09:03:59 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52750 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236097AbhIRND7 (ORCPT ); Sat, 18 Sep 2021 09:03:59 -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 3.0.0) id 8011dc6e58fefd45; Sat, 18 Sep 2021 15:02:34 +0200 Received: from kreacher.localnet (89-77-51-84.dynamic.chello.pl [89.77.51.84]) (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 571D566A568; Sat, 18 Sep 2021 15:02:33 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI , Linux PCI Cc: LKML , Bjorn Helgaas , Mika Westerberg , Andy Shevchenko Subject: [PATCH v1 3/3] ACPI: glue: Look for ACPI bus type only if ACPI companion is not known Date: Sat, 18 Sep 2021 15:02:23 +0200 Message-ID: <21197831.EfDdHjke4D@kreacher> In-Reply-To: <1794818.tdWV9SEqCh@kreacher> References: <1794818.tdWV9SEqCh@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.77.51.84 X-CLIENT-HOSTNAME: 89-77-51-84.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvtddrudehkedgheejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvffufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvjeelgffhiedukedtleekkedvudfggefhgfegjefgueekjeelvefggfdvledutdenucfkphepkeelrdejjedrhedurdekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeekledrjeejrdehuddrkeegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqphgtihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehhvghlghgrrghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehmihhkrgdrfigvshhtvghrsggvrhhgsehlihhn uhigrdhinhhtvghlrdgtohhmpdhrtghpthhtoheprghnughrihihrdhshhgvvhgthhgvnhhkoheslhhinhhugidrihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Notice that it is not necessary to look for the "ACPI bus type" of the device in acpi_device_notify() if the device's ACPI companion is set upfront, so modify the code to do that lookup only if it is necessary to find the ACPI companion. Also notice that if the device's ACPI companion is not set upfront in acpi_device_notify(), the device cannot be either a PCI one or a platform one, so check for these bus types only if the device's ACPI companion is set. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/glue.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) Index: linux-pm/drivers/acpi/glue.c =================================================================== --- linux-pm.orig/drivers/acpi/glue.c +++ linux-pm/drivers/acpi/glue.c @@ -289,12 +289,13 @@ EXPORT_SYMBOL_GPL(acpi_unbind_one); void acpi_device_notify(struct device *dev) { - struct acpi_bus_type *type = acpi_get_bus_type(dev); struct acpi_device *adev; int ret; ret = acpi_bind_one(dev, NULL); if (ret) { + struct acpi_bus_type *type = acpi_get_bus_type(dev); + if (!type) goto err; @@ -306,21 +307,26 @@ void acpi_device_notify(struct device *d ret = acpi_bind_one(dev, adev); if (ret) goto err; - } - adev = ACPI_COMPANION(dev); - if (dev_is_pci(dev)) { - pci_acpi_setup(dev, adev); + if (type->setup) { + type->setup(dev); + goto done; + } } else { - if (dev_is_platform(dev)) - acpi_configure_pmsi_domain(dev); + adev = ACPI_COMPANION(dev); - if (type && type->setup) - type->setup(dev); - else if (adev->handler && adev->handler->bind) - adev->handler->bind(dev); + if (dev_is_pci(dev)) { + pci_acpi_setup(dev, adev); + goto done; + } else if (dev_is_platform(dev)) { + acpi_configure_pmsi_domain(dev); + } } + if (adev->handler && adev->handler->bind) + adev->handler->bind(dev); + +done: acpi_handle_debug(ACPI_HANDLE(dev), "Bound to device %s\n", dev_name(dev));