From patchwork Mon Mar 20 00:22:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9632943 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 ED50660249 for ; Mon, 20 Mar 2017 00:24:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E090827FA0 for ; Mon, 20 Mar 2017 00:24:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D585627FBC; Mon, 20 Mar 2017 00:24:05 +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=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 804B827FA0 for ; Mon, 20 Mar 2017 00:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752756AbdCTAWl (ORCPT ); Sun, 19 Mar 2017 20:22:41 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35549 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdCTAWi (ORCPT ); Sun, 19 Mar 2017 20:22:38 -0400 Received: by mail-pf0-f195.google.com with SMTP id n11so3535861pfg.2; Sun, 19 Mar 2017 17:22:37 -0700 (PDT) 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=lyTP1IyXCHkY/1iSEuq80mVatN7ZIzBlEwWUNqQ2mbM=; b=o2lYD4BafAB8Z9SFQxozCVHoZGGKbSrEZJDD+a2XCf1P/txFyTb+eCKk0tjZiplZmO FwEdyBBD3ndkossbPckVWVtBlpPWJuksN5DDbYhh6MknVN90Yxoxnd2xE7KPsVxuAGNl G13ghQsh5JKm1LkuiSDdfUEvjQe0bZhH87lggkZd9DkOI/A+OSAQEfCo8k1GvnI1ki8E ZtLLRL79wz6y1nbNHtW6A2/otoz5LxQZHERGQebp4fLrc/LItB+6BEUfTjRFHQXdTMfL NVOmDNMRNIk7R+8xAjZD93RyDo9tLFCxacLIV93uIvNvwaiIF9uLC6mtJVLhK16E5edx EuJg== 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=lyTP1IyXCHkY/1iSEuq80mVatN7ZIzBlEwWUNqQ2mbM=; b=tT3152fAnBmhveO8+PWZfR9wZZh/Q9GDJfTLWfYFprpgaXYbuAKZvrLgDMn7jhyYMD /Bua6vkTSuIHFc4agCehK/fGMJYoUZYIxXF9gQ8g3yEVafuoshn/cVNjjrfV1nXKIfOw OXgealDatyE7b8WmkekW6Aar3paiaDzMmWPN4pZezOsUZuV5AeXmZUCoapeC7ZPPAdXL M6I3U8kXczC+Zwl4TVBGzHJp3zT4jKeBFTw/0WP/bG5Gv9upkayrqo8YWCa9syNi4THq Qkp4SlR93l3YUZPmGLxgWL4efwuKq6v1pe9hLcIs+vetq6P+2VEYPYPH8YT+AiZdjmon tVxQ== X-Gm-Message-State: AFeK/H3QJovsmpYEWrZbPceYpFKDRCzFRD7KpIvwMF7amggRHj5+qZ2jqa2qXoGKdhIJrw== X-Received: by 10.99.62.4 with SMTP id l4mr27499381pga.172.1489969356396; Sun, 19 Mar 2017 17:22:36 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id n185sm29134460pga.9.2017.03.19.17.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Mar 2017 17:22:35 -0700 (PDT) From: Dmitry Torokhov To: Benjamin Tissoires Cc: Andrew Duggan , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v3 3/9] Input: psmouse - implement fast reconnect option Date: Sun, 19 Mar 2017 17:22:25 -0700 Message-Id: <20170320002231.31152-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.0.367.g23dc2f6d3c-goog In-Reply-To: <20170320002231.31152-1-dmitry.torokhov@gmail.com> References: <20170320002231.31152-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. Reviewed-by: Benjamin Tissoires 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);