From patchwork Fri Mar 10 23:01:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9618099 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 A7FE9604D9 for ; Fri, 10 Mar 2017 23:03:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CE672879D for ; Fri, 10 Mar 2017 23:03:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91CDE287BA; Fri, 10 Mar 2017 23:03:18 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 385DE2879D for ; Fri, 10 Mar 2017 23:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934444AbdCJXDQ (ORCPT ); Fri, 10 Mar 2017 18:03:16 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33399 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932904AbdCJXCR (ORCPT ); Fri, 10 Mar 2017 18:02:17 -0500 Received: by mail-pf0-f193.google.com with SMTP id v190so12217369pfb.0; Fri, 10 Mar 2017 15:01:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1yWgFzdF79zsp07vC3hk+QZqqRNPr3UT7akqapTtL1k=; b=GIQy/AnuR31JoUEnhXVdlPnACSKx+y1YDr/ZGU4I8PKmAiR/ec61OHaoORku+F/eWi PHQISp6n+p/SlMhxpYBxdDhex95UCadAEfXR+sm6uwMhHIaVmQIDQwuI0l2pLFPsYT73 oLocCPoVcCSqKMPcIPFiD1Jhee9hbb541YvcEBzD820uPZAJ8VhllWXbdU7Xt9FOSR1C Ou54VU1+kmtMFJCP4TmEk4uzlCnw4Tl9M591VnfOMOox5l7QJuqKQTv8iCEHf6rtdqkj oYSw1JibNpV4v94jiJPSQwq6d5h3X0+bVCJZ+NmcbQdu54KVz98HwWiCJC81APd9qCVi MVxQ== 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:in-reply-to :references; bh=1yWgFzdF79zsp07vC3hk+QZqqRNPr3UT7akqapTtL1k=; b=ZpYO0KKvEuv6o3HwjLIjmSutFQdVhUB6Fau0eJ3OaMiMSJFtathNRgNc62cY0IP5ek fC/p8NC5pU0r6C8AwNtoFsznpX2Dy2xWGKaEKzINTtMu2Rt+WvPhJ9cVvPOmsBLFHqBg nG5KiudUpuY/uckHY/ovd4yXHpNdgKHfIskkhA85eHnVftRYVctmbLvgWuNibWzIKuQ/ F2lFhudxsi3bVtWmm06j57aa+fzjrPquJkuYjkK1u4GJK95zrfrp5URddOV37fZT10ga JQhTJ0s9m96BgYQaFP7QbGCsTzHy2JsUBgvPRjfW6zBQ9QMOibO8zJ25iKa9jC1Op8jt HSBQ== X-Gm-Message-State: AMke39k+J50CYWejqBbqMB3jqHlThscQUpxhyM5XE8xP1q09yVyFk5+o+EJuQ5diNfEr6A== X-Received: by 10.84.208.227 with SMTP id c32mr28500715plj.71.1489186879210; Fri, 10 Mar 2017 15:01:19 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id z7sm20457800pfz.128.2017.03.10.15.01.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Mar 2017 15:01:18 -0800 (PST) From: Dmitry Torokhov To: Benjamin Tissoires Cc: Andrew Duggan , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v2 3/9] Input: psmouse - implement fast reconnect option Date: Fri, 10 Mar 2017 15:01:08 -0800 Message-Id: <20170310230114.788-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.0.246.ga2ecc84866-goog In-Reply-To: <20170310230114.788-1-dmitry.torokhov@gmail.com> References: <20170310230114.788-1-dmitry.torokhov@gmail.com> 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 Make use of serio's fast reconnect option and allow psmouse protocol handler's to implement fast reconnect handlers that will be called during system resume. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/psmouse-base.c | 30 +++++++++++++++++++++++++++--- drivers/input/mouse/psmouse.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index a598b7223cef..47fd2976da7f 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -966,6 +966,7 @@ static void psmouse_apply_defaults(struct psmouse *psmouse) psmouse->protocol_handler = psmouse_process_byte; psmouse->pktsize = 3; psmouse->reconnect = NULL; + psmouse->fast_reconnect = NULL; psmouse->disconnect = NULL; psmouse->cleanup = NULL; psmouse->pt_activate = NULL; @@ -1628,15 +1629,26 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv) goto out; } -static int psmouse_reconnect(struct serio *serio) +static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect) { struct psmouse *psmouse = serio_get_drvdata(serio); struct psmouse *parent = NULL; + int (*reconnect_handler)(struct psmouse *); unsigned char type; int rc = -1; mutex_lock(&psmouse_mutex); + if (fast_reconnect) { + reconnect_handler = psmouse->fast_reconnect; + if (!reconnect_handler) { + rc = -ENOENT; + goto out_unlock; + } + } else { + reconnect_handler = psmouse->reconnect; + } + if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { parent = serio_get_drvdata(serio->parent); psmouse_deactivate(parent); @@ -1644,8 +1656,8 @@ static int psmouse_reconnect(struct serio *serio) psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); - if (psmouse->reconnect) { - if (psmouse->reconnect(psmouse)) + if (reconnect_handler) { + if (reconnect_handler(psmouse)) goto out; } else { psmouse_reset(psmouse); @@ -1677,10 +1689,21 @@ static int psmouse_reconnect(struct serio *serio) if (parent) psmouse_activate(parent); +out_unlock: mutex_unlock(&psmouse_mutex); return rc; } +static int psmouse_reconnect(struct serio *serio) +{ + return __psmouse_reconnect(serio, false); +} + +static int psmouse_fast_reconnect(struct serio *serio) +{ + return __psmouse_reconnect(serio, true); +} + static struct serio_device_id psmouse_serio_ids[] = { { .type = SERIO_8042, @@ -1708,6 +1731,7 @@ static struct serio_driver psmouse_drv = { .interrupt = psmouse_interrupt, .connect = psmouse_connect, .reconnect = psmouse_reconnect, + .fast_reconnect = psmouse_fast_reconnect, .disconnect = psmouse_disconnect, .cleanup = psmouse_cleanup, }; diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h index 8c83b8e2505c..bc76e771812b 100644 --- a/drivers/input/mouse/psmouse.h +++ b/drivers/input/mouse/psmouse.h @@ -80,6 +80,7 @@ struct psmouse { void (*set_scale)(struct psmouse *psmouse, enum psmouse_scale scale); int (*reconnect)(struct psmouse *psmouse); + int (*fast_reconnect)(struct psmouse *psmouse); void (*disconnect)(struct psmouse *psmouse); void (*cleanup)(struct psmouse *psmouse); int (*poll)(struct psmouse *psmouse);