Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4300931pxu; Tue, 1 Dec 2020 01:16:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsIFH+/L0TkMn3Qb5QMNkqWwBcsL4tOiFCp5Hr7Do6ttVomxLgstoc06oJnhzidsXFGgAr X-Received: by 2002:a05:6402:b10:: with SMTP id bm16mr2031711edb.214.1606814178006; Tue, 01 Dec 2020 01:16:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606814177; cv=none; d=google.com; s=arc-20160816; b=buiQ98bM9aMp+RUqE3RZyChCMP66rEYcy89h3ox+JOVinaWYwpX9DsmSRFUkf2wTdI irasfrlpvHPmH7fz0DVdZHTf8KCzsa5RTafdlvu9FCOufgvNAEKWXy7kMmXzVpEgwvEh 8s1JYpJ7I2qlUntBPn3MZQ2auTt99OJnWrH5X2/UgNYYRUYpKYrVLPgYAjoCILDqsXMk ly0CJdB8hxclOBGIdTZmmRb8/cch5TMep+MgFOLq/dFZShT1mkvIRnk48E/PmME9/1FI 1a8CmJJl3+qarI0QRgnXnSKORgzmWksLNGkpSJKMOoHnF0aOs3HptHKfvud8sOjQwflI Q5nw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D1W/JUxaPO+NKNltOMTYUZl7hVa59lVej0w0gSN6PSs=; b=fIKfuu778u18CF5E0f3/G60tH+vIr6csaqK97g880PXaN6vO3swpsZwiI3KwpqiRIN kEQDQTqU3Tj0U6XDuAoQDEJZrhaMD1ErBqOIs1bN/p/WUQA+j9eAMHAgrwt9H3gbdEzh hGmSM8RdcAQJ5nq6+6/Dwiur27k0vJMYn8OoCTSbajsHPrsQOsMOLGVhEyxuHfxqNIBI OMSf61bRc/7YT00l/lpq1sbJ09VRT5Vda5BtPiJJxi71hTs6ze2iHFJ4pzmsyTt8OTln ouLqE/ZccZcGbsXa9yNe8EU3kNg4SYP8kVSLQe+giyhSOZroPVRYbhYmkfxG7CNChpLA UbmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=frR4Blp1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce19si561297ejc.444.2020.12.01.01.15.55; Tue, 01 Dec 2020 01:16:17 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=frR4Blp1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389835AbgLAJLV (ORCPT + 99 others); Tue, 1 Dec 2020 04:11:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:48620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389819AbgLAJLN (ORCPT ); Tue, 1 Dec 2020 04:11:13 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8942E21D7A; Tue, 1 Dec 2020 09:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813858; bh=JSZvPBfK4+zCBkiRFC8rx9kLIeN4qNLYFSnGYkiTKek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frR4Blp1rwAAiYPICbHru3fkLZdBcweTuBUkKQqrtgvkOwN7UXwO6NwHX1q8rFZOP H9gbjgcpoQm9NYbHnjn7Iaw/WGOC70twYV/XeoZ7Yx5zmCDqW6LhXE49zb6WVwtPRC IYxchYQf9KdJC0STPiJ7xM0Hl0zqlYDC52IYaSNc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Dmitry Torokhov , Sasha Levin , Marius Iacob Subject: [PATCH 5.9 043/152] Input: i8042 - allow insmod to succeed on devices without an i8042 controller Date: Tue, 1 Dec 2020 09:52:38 +0100 Message-Id: <20201201084717.484111139@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084711.707195422@linuxfoundation.org> References: <20201201084711.707195422@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede [ Upstream commit b1884583fcd17d6a1b1bba94bbb5826e6b5c6e17 ] The i8042 module exports several symbols which may be used by other modules. Before this commit it would refuse to load (when built as a module itself) on systems without an i8042 controller. This is a problem specifically for the asus-nb-wmi module. Many Asus laptops support the Asus WMI interface. Some of them have an i8042 controller and need to use i8042_install_filter() to filter some kbd events. Other models do not have an i8042 controller (e.g. they use an USB attached kbd). Before this commit the asus-nb-wmi driver could not be loaded on Asus models without an i8042 controller, when the i8042 code was built as a module (as Arch Linux does) because the module_init function of the i8042 module would fail with -ENODEV and thus the i8042_install_filter symbol could not be loaded. This commit fixes this by exiting from module_init with a return code of 0 if no controller is found. It also adds a i8042_present bool to make the module_exit function a no-op in this case and also adds a check for i8042_present to the exported i8042_command function. The latter i8042_present check should not really be necessary because when builtin that function can already be used on systems without an i8042 controller, but better safe then sorry. Reported-and-tested-by: Marius Iacob Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20201008112628.3979-2-hdegoede@redhat.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/serio/i8042.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index d3eda48032e39..944cbb519c6d7 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -122,6 +122,7 @@ module_param_named(unmask_kbd_data, i8042_unmask_kbd_data, bool, 0600); MODULE_PARM_DESC(unmask_kbd_data, "Unconditional enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-condition: i8042.debug=1 enabled]"); #endif +static bool i8042_present; static bool i8042_bypass_aux_irq_test; static char i8042_kbd_firmware_id[128]; static char i8042_aux_firmware_id[128]; @@ -343,6 +344,9 @@ int i8042_command(unsigned char *param, int command) unsigned long flags; int retval; + if (!i8042_present) + return -1; + spin_lock_irqsave(&i8042_lock, flags); retval = __i8042_command(param, command); spin_unlock_irqrestore(&i8042_lock, flags); @@ -1612,12 +1616,15 @@ static int __init i8042_init(void) err = i8042_platform_init(); if (err) - return err; + return (err == -ENODEV) ? 0 : err; err = i8042_controller_check(); if (err) goto err_platform_exit; + /* Set this before creating the dev to allow i8042_command to work right away */ + i8042_present = true; + pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0); if (IS_ERR(pdev)) { err = PTR_ERR(pdev); @@ -1636,6 +1643,9 @@ static int __init i8042_init(void) static void __exit i8042_exit(void) { + if (!i8042_present) + return; + platform_device_unregister(i8042_platform_device); platform_driver_unregister(&i8042_driver); i8042_platform_exit(); -- 2.27.0