From patchwork Fri Nov 14 19:38:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 5309281 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 19C5B9F667 for ; Fri, 14 Nov 2014 19:41:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 434A120176 for ; Fri, 14 Nov 2014 19:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6430B20131 for ; Fri, 14 Nov 2014 19:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161827AbaKNTjD (ORCPT ); Fri, 14 Nov 2014 14:39:03 -0500 Received: from mail-wi0-f178.google.com ([209.85.212.178]:51688 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161809AbaKNTi6 (ORCPT ); Fri, 14 Nov 2014 14:38:58 -0500 Received: by mail-wi0-f178.google.com with SMTP id bs8so3703660wib.17 for ; Fri, 14 Nov 2014 11:38:57 -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 :mime-version:content-type:content-transfer-encoding; bh=/N3Aj1oE12C1nxWBXBjVwIC2Pf7I08wb6BVLEf4Xa14=; b=s3aiqy3Wo3Do733H3IpwUB9cIQpy7zHktzTUXIWo0wyBp6zw3gm6vAp3JHgCvAVrHW izfjXWiNkk4BxvfVJiWCNMu6EicXtHJzX2OTYulnC6MihUXzvYoenhAtB05Zjldt/uMk 6o2l68WHsqJ7jrNdgQpi1/c5lOivt/J6yRgIrpgABFWIn7jGM5dc35wOKX0M43ztwNyX +tw2L3kl7SPCNHV7C6MQ4sTCvFI1SjL1gSE9aqjmXR2w6ZRGgLe/mzw0UGGDbtRbOs9G jZgpdw7l6L9kG84wDzkyTVmvlGXIYDbIVVlNuY7/dnp1t9d5DNp8yo4tBnizXnVud9ed jLgw== X-Received: by 10.180.219.106 with SMTP id pn10mr10559115wic.63.1415993937420; Fri, 14 Nov 2014 11:38:57 -0800 (PST) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id wr9sm40768945wjb.42.2014.11.14.11.38.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Nov 2014 11:38:56 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Dmitry Torokhov , Hans de Goede Cc: Yunkang Tang , Vadim Klishko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 2/7] input: alps: Move trackstick detection to alps_hw_init_* Date: Fri, 14 Nov 2014 20:38:21 +0100 Message-Id: <1415993906-13307-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1415993906-13307-1-git-send-email-pali.rohar@gmail.com> References: <1415993906-13307-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 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 Now when alps_identify() does not need do trackstick detection it is safe to move code init hw_init functions. This patch also fix trackstick detection in function alps_hw_init_v3() which remove ALPS_DUALPOINT flag when trackstick is not detected. Signed-off-by: Pali Rohár --- drivers/input/mouse/alps.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 9ffa98d..cbfdcfc 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -1732,6 +1732,7 @@ error: static int alps_hw_init_v3(struct psmouse *psmouse) { + struct alps_data *priv = psmouse->private; struct ps2dev *ps2dev = &psmouse->ps2dev; int reg_val; unsigned char param[4]; @@ -1740,9 +1741,15 @@ static int alps_hw_init_v3(struct psmouse *psmouse) if (reg_val == -EIO) goto error; - if (reg_val == 0 && - alps_setup_trackstick_v3(psmouse, ALPS_REG_BASE_PINNACLE) == -EIO) - goto error; + if (reg_val == 0) { + reg_val = alps_setup_trackstick_v3(psmouse, + ALPS_REG_BASE_PINNACLE); + if (reg_val == -EIO) + goto error; + } + + if (reg_val == -ENODEV) + priv->flags &= ~ALPS_DUALPOINT; if (alps_enter_command_mode(psmouse) || alps_absolute_mode_v3(psmouse)) { @@ -1849,15 +1856,20 @@ static int alps_hw_init_rushmore_v3(struct psmouse *psmouse) struct ps2dev *ps2dev = &psmouse->ps2dev; int reg_val, ret = -1; - if (priv->flags & ALPS_DUALPOINT) { + reg_val = alps_probe_trackstick_v3(psmouse, ALPS_REG_BASE_RUSHMORE); + if (reg_val == -EIO) + goto error; + + if (reg_val == 0) { reg_val = alps_setup_trackstick_v3(psmouse, ALPS_REG_BASE_RUSHMORE); if (reg_val == -EIO) goto error; - if (reg_val == -ENODEV) - priv->flags &= ~ALPS_DUALPOINT; } + if (reg_val == -ENODEV) + priv->flags &= ~ALPS_DUALPOINT; + if (alps_enter_command_mode(psmouse) || alps_command_mode_read_reg(psmouse, 0xc2d9) == -1 || alps_command_mode_write_reg(psmouse, 0xc2cb, 0x00)) @@ -2231,12 +2243,6 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv) priv->y_bits = 12; priv->flags |= ALPS_IS_RUSHMORE; - /* hack to make addr_command, nibble_command available */ - psmouse->private = priv; - - if (alps_probe_trackstick_v3(psmouse, ALPS_REG_BASE_RUSHMORE)) - priv->flags &= ~ALPS_DUALPOINT; - return 0; } else if (ec[0] == 0x88 && ec[1] == 0x07 && ec[2] >= 0x90 && ec[2] <= 0x9d) {