Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp401089pxu; Tue, 1 Dec 2020 14:19:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWqotDSWZ0tEJbm+jJIaaQIQJmHbwljHovJwmdB5ow2oGpnN+L9MileluyoT99M5xBbqLH X-Received: by 2002:a17:907:2506:: with SMTP id y6mr3576346ejl.53.1606861147222; Tue, 01 Dec 2020 14:19:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606861147; cv=none; d=google.com; s=arc-20160816; b=cGCj4zgUNKtm1PIixp71ynixUyA4jBbaonSibY11+u05cUkKNma8izqNBOgey1eZ2D NdH6zHlJcz1SwxRjfXgi5zIpyXrfgKrFjEY0M0CzfIF6louUAfmjJINUrkR6ygrq6zQr yVzsEEV3OUh0AaIHWdEHVWLzC0a07gFgGquaDmI0AWM8TfiGZayRHzitLnGN9ANMZhsp L215Rg6p7/LbztknuYLHvsRMF6AKRnVeUNLB1PI89tWSzwCd9q+Bn+eA/SMQwZpRiQWv Uf7dAj2tFiTXIf0GIoVu+r0q22pGV0gSdL8r4pnL1nkH4+sypr3f+xb8sWgdPuHoCF/8 CSNw== 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=cgyRtZYQ9xyYR34GCh6oO6cO30akMhDarP9bZhpZsus=; b=Un51PENTHJqPnSmC69bsytOagVqVWK460X2PaIaEwVdi5bzV8w2kI+gvDPNTtJnoZP 5AAR7gRPDvzoxscYVJMfjh25buIAsH1O3sTYWIbz1EW/QHlvj5qFZJBWNgV6bF9+zML/ BwGT3fQjjYhKf+MfMr6sUk458mD25/wVnliaCHrWoqAIIJQRlYcP74sVHGoiVgADz8BI wHWoWjqwq8vtPs03+i/9MpD+3L9i3ZU/acV//btQ/qXsOAVy+ALmtY+XkXu2kFLIbzO/ 3h56xT1qC3rcXIfe7gYWbkjD63UnJuI9hEkMQ4ueeWEau8lvEU+wu+xiCS9dqMiFB5WP DcDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BvAdLztx; 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 d7si816424ejb.73.2020.12.01.14.18.44; Tue, 01 Dec 2020 14:19:07 -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=BvAdLztx; 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 S2387891AbgLAI6M (ORCPT + 99 others); Tue, 1 Dec 2020 03:58:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:33524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387869AbgLAI6I (ORCPT ); Tue, 1 Dec 2020 03:58:08 -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 BAD3A21D7A; Tue, 1 Dec 2020 08:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813047; bh=rD9R8ywuvyJzpvVCslcaVxW/XILBcGtdSf+hE/VOSAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BvAdLztxhQaVsoSHBkLAuJulGPGkuisdl0z2agecU1PLIcram5Mir2i8Rz9W7Ex88 mbEvaj9rd57hcsIPCFjzLML50u3AxjKZPxs/BhUk2Kpo1Wj34X54w8201Tj6UWzuZv 5QYGsP5pZ4XErg8qBGmfCmhBeA8liAWvt86q9Oa4= 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 4.14 15/50] Input: i8042 - allow insmod to succeed on devices without an i8042 controller Date: Tue, 1 Dec 2020 09:53:14 +0100 Message-Id: <20201201084647.004315962@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@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 824f4c1c1f310..0e9f248370a3f 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -125,6 +125,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]; @@ -345,6 +346,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); @@ -1599,12 +1603,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); @@ -1623,6 +1630,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