From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] serio-pin-driver.patch
Date: Fri, 17 Sep 2004 00:00:19 -0500 [thread overview]
Message-ID: <200409170000.21369.dtor_core@ameritech.net> (raw)
In-Reply-To: <200409162359.45766.dtor_core@ameritech.net>
===================================================================
ChangeSet@1.1903, 2004-09-16 23:06:29-05:00, dtor_core@ameritech.net
Input: add serio_[un]pin_driver() functions so attribute handlers
can safely access driver bound to a serio port.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/serio/serio.c | 20 ++++++++++++--------
include/linux/serio.h | 16 +++++++++++++++-
2 files changed, 27 insertions(+), 9 deletions(-)
===================================================================
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-09-16 23:31:24 -05:00
+++ b/drivers/input/serio/serio.c 2004-09-16 23:31:24 -05:00
@@ -326,6 +326,7 @@
try_module_get(THIS_MODULE);
spin_lock_init(&serio->lock);
+ init_MUTEX(&serio->drv_sem);
list_add_tail(&serio->node, &serio_list);
snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), "serio%d", serio_no++);
serio->dev.bus = &serio_bus;
@@ -595,17 +596,22 @@
up(&serio_sem);
}
-/* called from serio_driver->connect/disconnect methods under serio_sem */
-int serio_open(struct serio *serio, struct serio_driver *drv)
+static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
{
+ down(&serio->drv_sem);
serio_pause_rx(serio);
serio->drv = drv;
serio_continue_rx(serio);
+ up(&serio->drv_sem);
+}
+
+/* called from serio_driver->connect/disconnect methods under serio_sem */
+int serio_open(struct serio *serio, struct serio_driver *drv)
+{
+ serio_set_drv(serio, drv);
if (serio->open && serio->open(serio)) {
- serio_pause_rx(serio);
- serio->drv = NULL;
- serio_continue_rx(serio);
+ serio_set_drv(serio, NULL);
return -1;
}
return 0;
@@ -617,9 +623,7 @@
if (serio->close)
serio->close(serio);
- serio_pause_rx(serio);
- serio->drv = NULL;
- serio_continue_rx(serio);
+ serio_set_drv(serio, NULL);
}
irqreturn_t serio_interrupt(struct serio *serio,
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h 2004-09-16 23:31:24 -05:00
+++ b/include/linux/serio.h 2004-09-16 23:31:24 -05:00
@@ -45,7 +45,8 @@
struct serio *parent, *child;
- struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock */
+ struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock and serio->sem */
+ struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */
struct device dev;
@@ -120,6 +121,19 @@
static __inline__ void serio_continue_rx(struct serio *serio)
{
spin_unlock_irq(&serio->lock);
+}
+
+/*
+ * Use the following fucntions to pin serio's driver in process context
+ */
+static __inline__ int serio_pin_driver(struct serio *serio)
+{
+ return down_interruptible(&serio->drv_sem);
+}
+
+static __inline__ void serio_unpin_driver(struct serio *serio)
+{
+ up(&serio->drv_sem);
}
next prev parent reply other threads:[~2004-09-17 5:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-17 4:58 [PATCH 0/3] New input patches Dmitry Torokhov
2004-09-17 4:59 ` [PATCH 1/3] libps2.patch Dmitry Torokhov
2004-09-17 5:00 ` Dmitry Torokhov [this message]
2004-09-17 5:01 ` [PATCH 3/3] atkbd-sysfs-attr.patch Dmitry Torokhov
2004-09-21 12:10 ` [PATCH 0/3] New input patches Vojtech Pavlik
2004-09-21 13:15 ` Dmitry Torokhov
2004-09-22 7:12 ` Dmitry Torokhov
2004-09-22 7:30 ` 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=200409170000.21369.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox