From patchwork Wed Mar 8 15:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 9611437 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 53580602B4 for ; Wed, 8 Mar 2017 15:26:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 041E4285E2 for ; Wed, 8 Mar 2017 15:26:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB467285E8; Wed, 8 Mar 2017 15:26:37 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 9FC70285E2 for ; Wed, 8 Mar 2017 15:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985AbdCHPY5 (ORCPT ); Wed, 8 Mar 2017 10:24:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752467AbdCHPY4 (ORCPT ); Wed, 8 Mar 2017 10:24:56 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F16894DD6E; Wed, 8 Mar 2017 15:24:55 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v28FOqhn024394; Wed, 8 Mar 2017 10:24:54 -0500 From: Benjamin Tissoires To: Dmitry Torokhov , Andrew Duggan Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 1/3] input: serio - allow others to specify a driver for a serio device Date: Wed, 8 Mar 2017 16:24:43 +0100 Message-Id: <20170308152445.12082-2-benjamin.tissoires@redhat.com> In-Reply-To: <20170308152445.12082-1-benjamin.tissoires@redhat.com> References: <20170308152445.12082-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 08 Mar 2017 15:24:56 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Lenovo Thinkpads use RMI4 over SMBus in addition to PS/2 for their trackpad. The problem is that the device doesn't enumerate itself besides some registers in PS/2. Once the initial PS/2 initialization has been made, we need a way to unbind psmouse from the touchpad and use a different (dummy) serio driver to not interfere with SMBus. This patch adds the mechanisms to unbind psmouse and use a different serio driver, driver which can be marked as manual_bind to not be picked up by inadvertence. Signed-off-by: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/input/serio/serio.c | 20 ++++++++++++++++++++ include/linux/serio.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 1ca7f55..14cc383 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -704,6 +704,23 @@ void serio_reconnect(struct serio *serio) } EXPORT_SYMBOL(serio_reconnect); +void serio_bind_manual_driver(struct serio *serio, struct serio_driver *drv) +{ + mutex_lock(&serio_mutex); + serio->manual_bind = true; + serio->manual_drv = &drv->driver; + mutex_unlock(&serio_mutex); + serio_rescan(serio); +} +EXPORT_SYMBOL(serio_bind_manual_driver); + +void serio_clear_manual_driver(struct serio *serio) +{ + serio->manual_bind = false; + serio->manual_drv = NULL; +} +EXPORT_SYMBOL(serio_clear_manual_driver); + /* * Submits register request to kseriod for subsequent execution. * Note that port registration is always asynchronous. @@ -902,6 +919,9 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv) struct serio *serio = to_serio_port(dev); struct serio_driver *serio_drv = to_serio_driver(drv); + if (serio->manual_drv && serio->manual_drv == drv) + return serio_match_port(serio_drv->id_table, serio); + if (serio->manual_bind || serio_drv->manual_bind) return 0; diff --git a/include/linux/serio.h b/include/linux/serio.h index c733cff..1a6f4db 100644 --- a/include/linux/serio.h +++ b/include/linux/serio.h @@ -64,6 +64,9 @@ struct serio { * may get indigestion when exposed to concurrent access (i8042). */ struct mutex *ps2_cmd_mutex; + + /* Used when forcing a driver instead of the default one. */ + struct device_driver *manual_drv; }; #define to_serio_port(d) container_of(d, struct serio, dev) @@ -88,6 +91,8 @@ int serio_open(struct serio *serio, struct serio_driver *drv); void serio_close(struct serio *serio); void serio_rescan(struct serio *serio); void serio_reconnect(struct serio *serio); +void serio_bind_manual_driver(struct serio *serio, struct serio_driver *drv); +void serio_clear_manual_driver(struct serio *serio); irqreturn_t serio_interrupt(struct serio *serio, unsigned char data, unsigned int flags); void __serio_register_port(struct serio *serio, struct module *owner);