From patchwork Mon Apr 23 08:28:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10356397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEA67601BE for ; Mon, 23 Apr 2018 08:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B20042899C for ; Mon, 23 Apr 2018 08:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4CAF289AF; Mon, 23 Apr 2018 08:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17FD62899C for ; Mon, 23 Apr 2018 08:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754452AbeDWI2u (ORCPT ); Mon, 23 Apr 2018 04:28:50 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42656 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754367AbeDWI2r (ORCPT ); Mon, 23 Apr 2018 04:28:47 -0400 Received: by mail-wr0-f193.google.com with SMTP id s18-v6so38681806wrg.9 for ; Mon, 23 Apr 2018 01:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=IPubFlq0RIU3F5nmOKeksmJK22vMYzrP019It9Qpr5I=; b=Fxf1ZoKAOyZpAIIBqEsbTGb1lkWUsDBIGOutWxxQv2dWNJq7b60wvPKfMT83uXyPH+ VVY8KGrCoZ25JtDZ99pRdWi3Brh4Rrk6afU8kBPQb+G8LhkTT6G0qOTBpPCRBUDW19nf AhitS0RIrguv/ZCnfN3f6fdiHfbxA8b8aBnxI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IPubFlq0RIU3F5nmOKeksmJK22vMYzrP019It9Qpr5I=; b=oCqmXayKYQb8a/JHdV7ljJ/wBddS2qvFa/H359W8a3nEgBY1HU0PixkhB76qK7BcRN lgHUwWp6NMsk+ARmdF9+gNw9k1LUokWrVFlulWFLvqkU4kngOK+GPZ2IsFL7W8Z1BBUK zLq5zIAG4FZUYflNP1cVh2hflStPMeSuT59rTPDWzJM6nEkzpjfolI/F4w8GxiSTDKaT 6zpz3HzdxpyYqQnl8xgbZT5BpssV4uBg3R6OLGzbVSFoMzxGw7rGA77+zubc0IZhFzyY Y3voWd8tVjyNl8eReNxFvPkItxcdIno5T7HO+TZryrxCyireKZj/lq3JY22QiItMDVyk yTIg== X-Gm-Message-State: ALQs6tATOmw6jVGytEuF8U8VUvNv9SHfxBURylLEmZbkzsY9G5CXQMwL hvxjpYSXOtCgGoInfqCCUvTatA== X-Google-Smtp-Source: AIpwx4+vN1x6RKndyQRLcyynGhA9XH/H/MaX9u1gN1D4FGdZeQvhCSNAx601f1ZJq1hxJYQu+rjNxQ== X-Received: by 10.28.69.86 with SMTP id s83mr8316687wma.156.1524472125821; Mon, 23 Apr 2018 01:28:45 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id d28sm13590382wmh.29.2018.04.23.01.28.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 01:28:45 -0700 (PDT) From: Ard Biesheuvel To: rjw@rjwysocki.net Cc: lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org, lorenzo.pieralisi@arm.com, bill.fletcher@linaro.org, linux-arm-kernel@lists.infradead.org, graeme.gregory@linaro.org, Ard Biesheuvel Subject: [PATCH] ACPI / button: make module loadable when booted in non-ACPI mode Date: Mon, 23 Apr 2018 10:28:34 +0200 Message-Id: <20180423082834.24617-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Modules such as nouveau.ko and i915.ko have a link time dependency on acpi_lid_open(), and due to its use of acpi_bus_register_driver(), the button.ko module that provides it is only loadable when booted in ACPI mode. However, the ACPI button driver can be built into the core kernel as well, in which case the dependency can always be satisfied, and the dependent modules can be loaded regardless of whether the system was booted in ACPI mode or not. So let's fix this asymmetry by making the ACPI button driver loadable as a module even if not booted in ACPI mode, so it can provide the acpi_lid_open() symbol in the same way as when built into the kernel. Signed-off-by: Ard Biesheuvel --- Could we perhaps get this into -stable as well? It is not a classic regression, but it completely breaks, e.g., Fedora when booting in DT mode on an ARM system. drivers/acpi/button.c | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c index e1eee7a60fad..0506ca56c615 100644 --- a/drivers/acpi/button.c +++ b/drivers/acpi/button.c @@ -635,4 +635,25 @@ module_param_call(lid_init_state, NULL, 0644); MODULE_PARM_DESC(lid_init_state, "Behavior for reporting LID initial state"); -module_acpi_driver(acpi_button_driver); +/* + * Modules such as nouveau.ko and i915.ko have a link time dependency on + * acpi_lid_open(), and would therefore not be loadable on ACPI capable kernels + * booted in non-ACPI mode if we use the ordinary acpi_bus_[un]register_driver + * routines here (which only work when booted in ACPI mode) and build this + * driver as a module. So provide our own versions instead. + */ +static int __acpi_bus_register_driver(struct acpi_driver *driver) +{ + if (!acpi_disabled) + return acpi_bus_register_driver(driver); + return 0; +} + +static void __acpi_bus_unregister_driver(struct acpi_driver *driver) +{ + if (!acpi_disabled) + acpi_bus_unregister_driver(driver); +} + +module_driver(acpi_button_driver, __acpi_bus_register_driver, + __acpi_bus_unregister_driver);