All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 1/19] psmouse state locking
Date: Mon, 28 Jun 2004 00:09:36 -0500	[thread overview]
Message-ID: <200406280009.37987.dtor_core@ameritech.net> (raw)
In-Reply-To: <200406280008.21465.dtor_core@ameritech.net>


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


ChangeSet@1.1775, 2004-06-27 15:44:44-05:00, dtor_core@ameritech.net
  Input: when changing psmouse state (activated, ignore) do it while
         holding serio lock so it will not fight with the interrupt
         handler.
  
  Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


 psmouse-base.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 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-06-27 17:46:50 -05:00
+++ b/drivers/input/mouse/psmouse-base.c	2004-06-27 17:46:50 -05:00
@@ -622,6 +622,23 @@
 }
 
 /*
+ * 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)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&psmouse->serio->lock, flags);
+	psmouse->state = new_state;
+	psmouse->pktcnt = psmouse->cmdcnt = psmouse->out_of_sync = 0;
+	psmouse->flags = 0;
+	spin_unlock_irqrestore(&psmouse->serio->lock, flags);
+}
+
+/*
  * psmouse_activate() enables the mouse so that we get motion reports from it.
  */
 
@@ -630,7 +647,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);
 }
 
 /*
@@ -652,7 +669,7 @@
 {
 	struct psmouse *psmouse = serio->private;
 
-	psmouse->state = PSMOUSE_CMD_MODE;
+	psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
 
 	if (psmouse->ptport) {
 		if (psmouse->ptport->deactivate)
@@ -665,7 +682,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);
@@ -693,9 +710,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, dev)) {
@@ -758,12 +775,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-06-28  5:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-28  5:08 [PATCH 0/19] New set of input patches Dmitry Torokhov
2004-06-28  5:09 ` Dmitry Torokhov [this message]
2004-06-28  5:10   ` [PATCH 2/19] serio connect/disconnect mandatory Dmitry Torokhov
2004-06-28  5:11     ` [PATCH 3/19] serio renames 1 Dmitry Torokhov
2004-06-28  5:12       ` [PATCH 4/19] serio renames 2 Dmitry Torokhov
2004-06-28  5:13         ` [PATCH 5/19] serio dynamic allocation Dmitry Torokhov
2004-06-28  5:14           ` [PATCH 6/19] serio avoid recursion Dmitry Torokhov
2004-06-28  5:15             ` [PATCH 7/19] serio sysfs intergration Dmitry Torokhov
2004-06-28  5:16               ` [PATCH 8/19] serio rebind Dmitry Torokhov
2004-06-28  5:17                 ` PATCH 9/19] serio manual bind Dmitry Torokhov
2004-06-28  5:17                   ` [PATCH 10/19] serio_raw driver Dmitry Torokhov
2004-06-28  5:19                     ` [PATCH 11/19] add platform_device_register_simple Dmitry Torokhov
2004-06-28  5:19                       ` [PATCH 12/19] convert i8042 into a platform device Dmitry Torokhov
2004-06-28  5:21                         ` [PATCH 13/19] more platform device conversions Dmitry Torokhov
2004-06-28  5:22                           ` [PATCH 14/19] bind serio ports and their parents Dmitry Torokhov
2004-06-28  5:23                             ` [PATCH 15/19] synaptics passthrough handling Dmitry Torokhov
2004-06-28  5:24                               ` [PATCH 16/19] add bus' default driver attributes Dmitry Torokhov
2004-06-28  5:25                                 ` [PATCH 17/19] serio use bus' default driver/device attributes Dmitry Torokhov
2004-06-28  5:26                                   ` [PATCH 18/19] add driver_find Dmitry Torokhov
2004-06-28  5:27                                     ` [PATCH 19/19] serio use driver_find Dmitry Torokhov
2004-06-28  6:52 ` [PATCH 0/19] New set of input patches Vojtech Pavlik
2004-06-28  7:13   ` Dmitry Torokhov
2004-06-28  7:51     ` Vojtech Pavlik
2004-06-28 10:32   ` Neil Brown
2004-06-28 12:13     ` Vojtech Pavlik

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=200406280009.37987.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=akpm@osdl.org \
    --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.