From patchwork Sun Nov 29 05:13:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 7718011 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4D58BEEE1 for ; Sun, 29 Nov 2015 05:16:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 101D72055B for ; Sun, 29 Nov 2015 05:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 280652055A for ; Sun, 29 Nov 2015 05:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751329AbbK2FOr (ORCPT ); Sun, 29 Nov 2015 00:14:47 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34034 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750837AbbK2FOD (ORCPT ); Sun, 29 Nov 2015 00:14:03 -0500 Received: by padhx2 with SMTP id hx2so150267958pad.1; Sat, 28 Nov 2015 21:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yIYl+3G353AOlrUsUh2WmWxj5NsI4TeqsLJwd9PcF+Y=; b=X8pOwOy/0jDN76cDGbxMJTed86UJ1leN9y0PX8LdWSAuU5ztxTmnLA1dvtoHFPOg0a pp/eeEb/BDseYZR6xhfEwf3+FJwsRFcuGF06VuVjj10DYdQd8+wSDP/7BR9xjurrJYtC j9TrJSsmzq+DiUIRmiOmCBHXnnSprWtfd0otKPJn7TjAID/7eAZ17GcHAgmcjvydh/2U 2FIiUkKQHJVvd1R+l1HFukWI9bm0Pi9wWPbRFO25lJFXqDIcrIT6ZgrTV8/FGxVwIRIp 1w8pn8ula8bR0ZFKrici0dVPLlgFTnV5+95gmBfoN8EhiEdM6rBeZaJp/9QQ13/ctTnk wFoA== X-Received: by 10.66.150.198 with SMTP id uk6mr79739834pab.70.1448774042582; Sat, 28 Nov 2015 21:14:02 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.64.149]) by smtp.gmail.com with ESMTPSA id pb9sm43616340pac.38.2015.11.28.21.14.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Nov 2015 21:14:02 -0800 (PST) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Hans de Goede , Benjamin Tissoires , Thomas Hellstrom , pali.rohar@gmail.com, jckeerthan@gmail.com, till2.schaefer@uni-dortmund.de, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] Input: psmouse - rearrange Focaltech init code Date: Sat, 28 Nov 2015 21:13:53 -0800 Message-Id: <1448774036-39040-4-git-send-email-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1448774036-39040-1-git-send-email-dmitry.torokhov@gmail.com> References: <1448774036-39040-1-git-send-email-dmitry.torokhov@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The fact that we were calling focaltech_init() even when Focaltech support is disabled was confusing. Rearrange the code so that if support is disabled we continue to fall through the rest of protocol probing code until we get to full reset that Focaltech devices need to work properly. Also, replace focaltech_init() with a stub now that it is only called when protocol is enabled. Signed-off-by: Dmitry Torokhov Reviewed-by: Pali Rohár --- I know I originally requested doing reset in focaltech_init() even when focaltech support is disabled, but as I was working with the code I found it confusing. drivers/input/mouse/focaltech.c | 22 ++++++---------------- drivers/input/mouse/focaltech.h | 8 ++++++++ drivers/input/mouse/psmouse-base.c | 23 ++++++++++++----------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c index 4d5576d..c8c6a8c 100644 --- a/drivers/input/mouse/focaltech.c +++ b/drivers/input/mouse/focaltech.c @@ -49,12 +49,6 @@ int focaltech_detect(struct psmouse *psmouse, bool set_properties) return 0; } -static void focaltech_reset(struct psmouse *psmouse) -{ - ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); - psmouse_reset(psmouse); -} - #ifdef CONFIG_MOUSE_PS2_FOCALTECH /* @@ -300,6 +294,12 @@ static int focaltech_switch_protocol(struct psmouse *psmouse) return 0; } +static void focaltech_reset(struct psmouse *psmouse) +{ + ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); + psmouse_reset(psmouse); +} + static void focaltech_disconnect(struct psmouse *psmouse) { focaltech_reset(psmouse); @@ -456,14 +456,4 @@ fail: kfree(priv); return error; } - -#else /* CONFIG_MOUSE_PS2_FOCALTECH */ - -int focaltech_init(struct psmouse *psmouse) -{ - focaltech_reset(psmouse); - - return 0; -} - #endif /* CONFIG_MOUSE_PS2_FOCALTECH */ diff --git a/drivers/input/mouse/focaltech.h b/drivers/input/mouse/focaltech.h index ca61ebf..783b28e 100644 --- a/drivers/input/mouse/focaltech.h +++ b/drivers/input/mouse/focaltech.h @@ -18,6 +18,14 @@ #define _FOCALTECH_H int focaltech_detect(struct psmouse *psmouse, bool set_properties); + +#ifdef CONFIG_MOUSE_PS2_FOCALTECH int focaltech_init(struct psmouse *psmouse); +#else +static inline int focaltech_init(struct psmouse *psmouse) +{ + return -ENOSYS; +} +#endif #endif diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 525de2e..c2bd866 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c @@ -750,19 +750,20 @@ static int psmouse_extensions(struct psmouse *psmouse, */ if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) { if (max_proto > PSMOUSE_IMEX) { - if (!set_properties || focaltech_init(psmouse) == 0) { - if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH)) - return PSMOUSE_FOCALTECH; - /* - * Note that we need to also restrict - * psmouse_max_proto so that psmouse_initialize() - * does not try to reset rate and resolution, - * because even that upsets the device. - */ - psmouse_max_proto = PSMOUSE_PS2; - return PSMOUSE_PS2; + if (IS_ENABLED(CONFIG_MOUSE_PS2_FOCALTECH) && + (!set_properties || focaltech_init(psmouse) == 0)) { + return PSMOUSE_FOCALTECH; } } + /* + * Restrict psmouse_max_proto so that psmouse_initialize() + * does not try to reset rate and resolution, because even + * that upsets the device. + * This also causes us to basically fall through to basic + * protocol detection, where we fully reset the mouse, + * and set it up as bare PS/2 protocol device. + */ + psmouse_max_proto = max_proto = PSMOUSE_PS2; } /*