linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>
Cc: "Yunkang Tang" <yunkang.tang@cn.alps.com>,
	"Vadim Klishko" <vadim@cirque.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH 2/7] input: alps: Move trackstick detection to alps_hw_init_*
Date: Fri, 14 Nov 2014 20:38:21 +0100	[thread overview]
Message-ID: <1415993906-13307-3-git-send-email-pali.rohar@gmail.com> (raw)
In-Reply-To: <1415993906-13307-1-git-send-email-pali.rohar@gmail.com>

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 <pali.rohar@gmail.com>
---
 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) {
-- 
1.7.9.5


  parent reply	other threads:[~2014-11-14 19:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14 19:38 [PATCH 0/7] Fixes for ALPS trackstick Pali Rohár
2014-11-14 19:38 ` [PATCH 1/7] input: alps: Set correct name of psmouse device in alps_init() Pali Rohár
2014-12-16  5:02   ` Dmitry Torokhov
2014-12-16 11:58     ` Pali Rohár
2014-12-20  8:53       ` Pali Rohár
2014-12-24  7:48         ` Pali Rohár
2015-01-08 17:58           ` Pali Rohár
2014-11-14 19:38 ` Pali Rohár [this message]
2014-11-14 19:38 ` [PATCH 3/7] input: alps: Move alps_dolphin_get_device_area into alps_hw_init_dolphin_v1 Pali Rohár
2014-11-14 19:38 ` [PATCH 4/7] input: alps: Use NULL instead dummy argument for alps_identify Pali Rohár
2014-11-14 19:38 ` [PATCH 5/7] input: alps: Fix name, product and version of dev2 input device Pali Rohár
2015-01-12  0:30   ` Dmitry Torokhov
2014-11-14 19:38 ` [PATCH 6/7] input: alps: Add sanity checks for non DualPoint devices Pali Rohár
2015-01-12  0:31   ` Dmitry Torokhov
2015-01-13  7:50     ` Pali Rohár
2014-11-14 19:38 ` [PATCH 7/7] input: alps: Do not report both trackstick and external PS/2 mouse data to one input device Pali Rohár
2014-11-14 20:59 ` [PATCH 0/7] Fixes for ALPS trackstick Dmitry Torokhov
2014-11-17  7:39   ` Pali Rohár
2014-11-19 23:29     ` Pali Rohár
2014-11-25 11:08       ` Pali Rohár
2014-11-27 18:08         ` Dmitry Torokhov
2014-12-03 10:59           ` Pali Rohár
2014-12-09 17:08 ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415993906-13307-3-git-send-email-pali.rohar@gmail.com \
    --to=pali.rohar@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vadim@cirque.com \
    --cc=yunkang.tang@cn.alps.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).