From patchwork Tue Oct 24 15:18:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 157580 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2017775vqx; Tue, 24 Oct 2023 08:21:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHns61v4REvo1XH/0LcacU1dAsrBdhKurWcd8umI8Zc5zJTrEF+EtwEWBe63XaWM1AL5T1i X-Received: by 2002:a17:90a:183:b0:27f:bd9e:5a15 with SMTP id 3-20020a17090a018300b0027fbd9e5a15mr4102142pjc.28.1698160912022; Tue, 24 Oct 2023 08:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160912; cv=none; d=google.com; s=arc-20160816; b=yRCJyu0QAgph70Fxz6c26p0bHGR2FB043Q8sqvPQD/54JgVdKM47qVLWBg5gvgOkY0 Do9qjadEntqgJXMzz8IfbWg7zbRq+C06tG6AIyRGRbTTOpicP8chIrmvvUmjYu8oPny1 iNgQrwAUypLGChIkthQdMsJO9SKnmdE54Za7BlxfQ9+kw+BUerqVhM7LYoM5hhBGoyrO uypz/lsZ76BPVPLDOpsJoKCOZ7enlL1PXqjEZ1+ful6PNPkND34TYyySDSgaQmhdL+tf hEqNxGioV4Y6XJ9lPFfMXyzPwZb4yU86b9AMX2pWpsCyOT01JeEoTwwwfpgC625KhQ/m 5jsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=4b5HegDKciHN9mls7Lc2XkvXRncQJquMBML+u/Mzhus=; fh=SkTV5xOrq7hxTIOggvbIOXu+48dqXijvMNKji0VGfy8=; b=b9v5y3pBPGFMkolkafM/8Ix/8T7467RUmZE6B2/hE1VdEcH296/6xAr3WKdzG5UADK AM6KLQuYXlh1924Xx5bMERwn7N2oufeLTRBjFnKxla0eu2pmYp+RbFh6mSao6p15PIsH f2I8JJqSnLy6/HAdpYsKK/UeJLSsfXHFf5hs7MM00L+ONhG9ABMyahYL9t9b3V5At7JY o6AP8neBjXyjsW7XAcGMkQ0Ve8ESq9H1BKoBgc5SEfXtDq6f6s4MQGW+ElpQzpi8Z1eP IqvILBZkRPFxuqyucCAwguCTttizBCpb0fvosmvhW9edyFXb1Xl5h6jEWGe2VEfDo2tz UXzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=uc2nzMrU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id pf10-20020a17090b1d8a00b00263c23a5693si9200590pjb.13.2023.10.24.08.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=uc2nzMrU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B30D68034A57; Tue, 24 Oct 2023 08:21:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234795AbjJXPVd (ORCPT + 27 others); Tue, 24 Oct 2023 11:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343625AbjJXPUd (ORCPT ); Tue, 24 Oct 2023 11:20:33 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC08D1FCE; Tue, 24 Oct 2023 08:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4b5HegDKciHN9mls7Lc2XkvXRncQJquMBML+u/Mzhus=; b=uc2nzMrUE3t/feqmNPw6wzUhwD zNyvrYknjodQxhuBS9Y/uZVr2Fhh1qDmAQ3jFj85Tbg1Cpvv0zPd62W4gvQkUb5mYiKLs0H6yjrC5 PlsAMVktgdo6rE0Ziby+VQG0SIOKigLfdK/FcAFabzkFXd07BmFDxdCSRI9dTnZYYgzgm5VHObd8t lNJx81+9Naw4KOZvpgyTYTYhpeGZ1x7Se8E/np25G4B2DG2N3PCcZKrqV7OV1XNQXJ6tHscUNEzDO 9yV3ztYshVstk1Xc8sho4zuDFgcCVNRjzr2L1QP/LfXrFIr84zinCAaf3DISEiLFVEhhS8LRYlppY PZEWtDgQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57442 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qvJAZ-0004T9-19; Tue, 24 Oct 2023 16:18:11 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qvJAa-00AqRA-Pt; Tue, 24 Oct 2023 16:18:12 +0100 In-Reply-To: References: From: Russell King (Oracle) To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , "Rafael J. Wysocki" , Len Brown Subject: [PATCH 24/39] ACPI: Move acpi_bus_trim_one() before acpi_scan_hot_remove() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 24 Oct 2023 16:18:12 +0100 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:21:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780650776755237234 X-GMAIL-MSGID: 1780650776755237234 From: James Morse A subsequent patch will change acpi_scan_hot_remove() to call acpi_bus_trim_one() instead of acpi_bus_trim(), meaning it can no longer rely on the prototype in the header file. Move these functions further up the file. No change in behaviour. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan Signed-off-by: Russell King (Oracle) --- drivers/acpi/scan.c | 76 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 06e9bb4a633f..4343888c76d5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -244,6 +244,44 @@ static int acpi_scan_try_to_offline(struct acpi_device *device) return 0; } +static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) +{ + struct acpi_scan_handler *handler = adev->handler; + + acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, NULL); + + adev->flags.match_driver = false; + if (handler) { + if (handler->detach) + handler->detach(adev); + + adev->handler = NULL; + } else { + device_release_driver(&adev->dev); + } + /* + * Most likely, the device is going away, so put it into D3cold before + * that. + */ + acpi_device_set_power(adev, ACPI_STATE_D3_COLD); + adev->flags.initialized = false; + acpi_device_clear_enumerated(adev); + + return 0; +} + +/** + * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. + * @adev: Root of the ACPI namespace scope to walk. + * + * Must be called under acpi_scan_lock. + */ +void acpi_bus_trim(struct acpi_device *adev) +{ + acpi_bus_trim_one(adev, NULL); +} +EXPORT_SYMBOL_GPL(acpi_bus_trim); + static int acpi_scan_hot_remove(struct acpi_device *device) { acpi_handle handle = device->handle; @@ -2507,44 +2545,6 @@ int acpi_bus_scan(acpi_handle handle) } EXPORT_SYMBOL(acpi_bus_scan); -static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) -{ - struct acpi_scan_handler *handler = adev->handler; - - acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, NULL); - - adev->flags.match_driver = false; - if (handler) { - if (handler->detach) - handler->detach(adev); - - adev->handler = NULL; - } else { - device_release_driver(&adev->dev); - } - /* - * Most likely, the device is going away, so put it into D3cold before - * that. - */ - acpi_device_set_power(adev, ACPI_STATE_D3_COLD); - adev->flags.initialized = false; - acpi_device_clear_enumerated(adev); - - return 0; -} - -/** - * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. - * @adev: Root of the ACPI namespace scope to walk. - * - * Must be called under acpi_scan_lock. - */ -void acpi_bus_trim(struct acpi_device *adev) -{ - acpi_bus_trim_one(adev, NULL); -} -EXPORT_SYMBOL_GPL(acpi_bus_trim); - int acpi_bus_register_early_device(int type) { struct acpi_device *device = NULL;