linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
To: Len Brown <lenb@kernel.org>
Cc: ibm-acpi-devel@lists.sourceforge.net, linux-acpi@vger.kernel.org,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Subject: [PATCH 3/9] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path
Date: Sun, 23 Sep 2007 11:39:01 -0300	[thread overview]
Message-ID: <11905583472108-git-send-email-hmh@hmh.eng.br> (raw)
In-Reply-To: <11905583473293-git-send-email-hmh@hmh.eng.br>

Protect the input device event sending path with a mutex, since hot key
input events are not atomic and require an cohesive event block to be sent
together.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
---
 drivers/misc/thinkpad_acpi.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 8aa0f96..0ced9d6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -519,6 +519,7 @@ static char *next_cmd(char **cmds)
 static struct platform_device *tpacpi_pdev;
 static struct class_device *tpacpi_hwmon;
 static struct input_dev *tpacpi_inputdev;
+static struct mutex tpacpi_inputdev_send_mutex;
 
 
 static int tpacpi_resume_handler(struct platform_device *pdev)
@@ -1131,6 +1132,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
 				  unsigned int keycode)
 {
 	if (keycode != KEY_RESERVED) {
+		mutex_lock(&tpacpi_inputdev_send_mutex);
+
 		input_report_key(tpacpi_inputdev, keycode, 1);
 		if (keycode == KEY_UNKNOWN)
 			input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
@@ -1142,6 +1145,8 @@ static void tpacpi_input_send_key(unsigned int scancode,
 			input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
 				    scancode);
 		input_sync(tpacpi_inputdev);
+
+		mutex_unlock(&tpacpi_inputdev_send_mutex);
 	}
 }
 
@@ -1149,11 +1154,15 @@ static void tpacpi_input_send_radiosw(void)
 {
 	int wlsw;
 
+	mutex_lock(&tpacpi_inputdev_send_mutex);
+
 	if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw)) {
 		input_report_switch(tpacpi_inputdev,
 				    SW_RADIO, !!wlsw);
 		input_sync(tpacpi_inputdev);
 	}
+
+	mutex_unlock(&tpacpi_inputdev_send_mutex);
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -4737,6 +4746,7 @@ static int __init thinkpad_acpi_module_init(void)
 		thinkpad_acpi_module_exit();
 		return ret;
 	}
+	mutex_init(&tpacpi_inputdev_send_mutex);
 	tpacpi_inputdev = input_allocate_device();
 	if (!tpacpi_inputdev) {
 		printk(IBM_ERR "unable to allocate input device\n");
-- 
1.5.3.1


  parent reply	other threads:[~2007-09-23 14:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-23 14:38 [GIT PATCH v3.1] thinkpad-acpi changes for the merge window (part 1) Henrique de Moraes Holschuh
2007-09-23 14:38 ` [PATCH 1/9] ACPI: thinkpad-acpi: make room for more features in tp_features bitfield Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 2/9] ACPI: thinkpad-acpi: issue EV_SYNC after EV_SWITCH Henrique de Moraes Holschuh
2007-09-23 14:39 ` Henrique de Moraes Holschuh [this message]
2007-09-23 14:39 ` [PATCH 4/9] ACPI: thinkpad-acpi: keep track of module state Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 5/9] ACPI: thinkpad-acpi: check version of hot key firmware Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 6/9] ACPI: thinkpad-acpi: dequeue all pending hot key events at once (v2.2) Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 7/9] ACPI: thinkpad-acpi: fix regression on HKEY LID event handling Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 8/9] ACPI: thinkpad-acpi: use a separate platform device for hwmon and name it Henrique de Moraes Holschuh
2007-09-23 14:39 ` [PATCH 9/9] ACPI: thinkpad-acpi: duplicate driver attributes to new hwmon pdrv Henrique de Moraes Holschuh
2007-09-24  2:43 ` [GIT PATCH v3.1] thinkpad-acpi changes for the merge window (part 1) Len Brown
  -- strict thread matches above, loose matches on Subject: below --
2007-09-23 14:24 [GIT PATCH v3] " Henrique de Moraes Holschuh
     [not found] ` <1190557457539-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-09-23 14:24   ` [PATCH 3/9] ACPI: thinkpad-acpi: add mutex-based locking to input device event send path Henrique de Moraes Holschuh

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=11905583472108-git-send-email-hmh@hmh.eng.br \
    --to=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    /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).