All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/8] New set of input patches
Date: Thu, 8 Jul 2004 01:57:36 -0500	[thread overview]
Message-ID: <200407080157.38459.dtor_core@ameritech.net> (raw)
In-Reply-To: <200407080157.17205.dtor_core@ameritech.net>


===================================================================


ChangeSet@1.1824, 2004-07-08 00:25:13-05:00, dtor_core@ameritech.net
  Input: when changing psmouse state (activated, ignore) use srio_pause_rx/
         serio_continue_rx so it will not fight with the interrupt handler
  
  Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


 psmouse-base.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)


===================================================================



diff -Nru a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
--- a/drivers/input/mouse/psmouse-base.c	2004-07-08 01:35:23 -05:00
+++ b/drivers/input/mouse/psmouse-base.c	2004-07-08 01:35:23 -05:00
@@ -308,7 +308,7 @@
 	while (test_bit(PSMOUSE_FLAG_CMD, &psmouse->flags) && timeout--) {
 
 		if (!test_bit(PSMOUSE_FLAG_CMD1, &psmouse->flags)) {
-		    
+
 			if (command == PSMOUSE_CMD_RESET_BAT && timeout > 100000)
 				timeout = 100000;
 
@@ -626,6 +626,21 @@
 }
 
 /*
+ * psmouse_set_state() sets new psmouse state and resets all flags and
+ * counters while holding serio lock so fighting with interrupt handler
+ * is not a concern.
+ */
+
+static void psmouse_set_state(struct psmouse *psmouse, unsigned char new_state)
+{
+	serio_pause_rx(psmouse->serio);
+	psmouse->state = new_state;
+	psmouse->pktcnt = psmouse->cmdcnt = psmouse->out_of_sync = 0;
+	psmouse->flags = 0;
+	serio_continue_rx(psmouse->serio);
+}
+
+/*
  * psmouse_activate() enables the mouse so that we get motion reports from it.
  */
 
@@ -634,7 +649,7 @@
 	if (psmouse_command(psmouse, NULL, PSMOUSE_CMD_ENABLE))
 		printk(KERN_WARNING "psmouse.c: Failed to enable mouse on %s\n", psmouse->serio->phys);
 
-	psmouse->state = PSMOUSE_ACTIVATED;
+	psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
 }
 
 /*
@@ -657,7 +672,7 @@
 	struct psmouse *psmouse, *parent;
 
 	psmouse = serio->private;
-	psmouse->state = PSMOUSE_CMD_MODE;
+	psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
 
 	if (serio->parent && (serio->type & SERIO_TYPE) == SERIO_PS_PSTHRU) {
 		parent = serio->parent->private;
@@ -668,7 +683,7 @@
 	if (psmouse->disconnect)
 		psmouse->disconnect(psmouse);
 
-	psmouse->state = PSMOUSE_IGNORE;
+	psmouse_set_state(psmouse, PSMOUSE_IGNORE);
 
 	input_unregister_device(&psmouse->dev);
 	serio_close(serio);
@@ -699,9 +714,9 @@
 	psmouse->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
 	psmouse->dev.keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_MIDDLE) | BIT(BTN_RIGHT);
 	psmouse->dev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
-	psmouse->state = PSMOUSE_CMD_MODE;
 	psmouse->serio = serio;
 	psmouse->dev.private = psmouse;
+	psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
 
 	serio->private = psmouse;
 	if (serio_open(serio, drv)) {
@@ -780,12 +795,7 @@
 		return -1;
 	}
 
-	psmouse->state = PSMOUSE_CMD_MODE;
-
-	clear_bit(PSMOUSE_FLAG_ACK, &psmouse->flags);
-	clear_bit(PSMOUSE_FLAG_CMD,  &psmouse->flags);
-
-	psmouse->pktcnt = psmouse->out_of_sync = 0;
+	psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
 
 	if (psmouse->reconnect) {
 	       if (psmouse->reconnect(psmouse))

  reply	other threads:[~2004-07-08  7:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-08  6:55 [PATCH 0/8] New set of input patches Dmitry Torokhov
2004-07-08  6:55 ` [PATCH 1/8] " Dmitry Torokhov
2004-07-08  6:56   ` [PATCH 2/8] " Dmitry Torokhov
2004-07-08  6:56     ` [PATCH 3/8] " Dmitry Torokhov
2004-07-08  6:57       ` [PATCH 4/8] " Dmitry Torokhov
2004-07-08  6:57         ` Dmitry Torokhov [this message]
2004-07-08  6:58           ` [PATCH 6/8] " Dmitry Torokhov
2004-07-08  6:58             ` [PATCH 7/8] " Dmitry Torokhov
2004-07-08  6:59               ` [PATCH 8/8] " Dmitry Torokhov
2004-07-12  3:17   ` synaptics driver Ari Pollak
2004-07-12  3:41     ` Dmitry Torokhov
2004-07-08 20:32 ` [PATCH 0/8] New set of input patches Pavel Machek
2004-07-09  3:48   ` Dmitry Torokhov
2004-07-09  5:06     ` Pavel Machek

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=200407080157.38459.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vojtech@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.