From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/8] New set of input patches
Date: Thu, 8 Jul 2004 01:57:15 -0500 [thread overview]
Message-ID: <200407080157.17205.dtor_core@ameritech.net> (raw)
In-Reply-To: <200407080156.32341.dtor_core@ameritech.net>
===================================================================
ChangeSet@1.1823, 2004-07-08 00:24:20-05:00, dtor_core@ameritech.net
Input: add serio_pause_rx and serio_continue_rx so drivers can protect
their critical sections from port's interrupt handler
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/serio/serio.c | 18 ++++++++----------
include/linux/serio.h | 21 +++++++++++++++++++--
2 files changed, 27 insertions(+), 12 deletions(-)
===================================================================
diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c 2004-07-08 01:35:14 -05:00
+++ b/drivers/input/serio/serio.c 2004-07-08 01:35:14 -05:00
@@ -541,15 +541,14 @@
/* called from serio_driver->connect/disconnect methods under serio_sem */
int serio_open(struct serio *serio, struct serio_driver *drv)
{
- unsigned long flags;
-
- spin_lock_irqsave(&serio->lock, flags);
+ serio_pause_rx(serio);
serio->drv = drv;
- spin_unlock_irqrestore(&serio->lock, flags);
+ serio_continue_rx(serio);
+
if (serio->open && serio->open(serio)) {
- spin_lock_irqsave(&serio->lock, flags);
+ serio_pause_rx(serio);
serio->drv = NULL;
- spin_unlock_irqrestore(&serio->lock, flags);
+ serio_continue_rx(serio);
return -1;
}
return 0;
@@ -558,13 +557,12 @@
/* called from serio_driver->connect/disconnect methods under serio_sem */
void serio_close(struct serio *serio)
{
- unsigned long flags;
-
if (serio->close)
serio->close(serio);
- spin_lock_irqsave(&serio->lock, flags);
+
+ serio_pause_rx(serio);
serio->drv = NULL;
- spin_unlock_irqrestore(&serio->lock, flags);
+ serio_continue_rx(serio);
}
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-07-08 01:35:14 -05:00
+++ b/include/linux/serio.h 2004-07-08 01:35:14 -05:00
@@ -35,7 +35,7 @@
unsigned long type;
unsigned long event;
- spinlock_t lock;
+ spinlock_t lock; /* protects critical sections from port's interrupt handler */
int (*write)(struct serio *, unsigned char);
int (*open)(struct serio *);
@@ -43,7 +43,7 @@
struct serio *parent, *child;
- struct serio_driver *drv; /* Accessed from interrupt, writes must be protected by serio_lock */
+ struct serio_driver *drv; /* accessed from interrupt, must be protected by serio->lock */
struct device dev;
@@ -81,6 +81,7 @@
void serio_register_port_delayed(struct serio *serio);
void serio_unregister_port(struct serio *serio);
void serio_unregister_port_delayed(struct serio *serio);
+
void serio_register_driver(struct serio_driver *drv);
void serio_unregister_driver(struct serio_driver *drv);
@@ -103,6 +104,22 @@
if (serio->drv && serio->drv->cleanup)
serio->drv->cleanup(serio);
}
+
+
+/*
+ * Use the following fucntions to protect critical sections in
+ * driver code from port's interrupt handler
+ */
+static __inline__ void serio_pause_rx(struct serio *serio)
+{
+ spin_lock_irq(&serio->lock);
+}
+
+static __inline__ void serio_continue_rx(struct serio *serio)
+{
+ spin_unlock_irq(&serio->lock);
+}
+
#endif
next prev parent 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 ` Dmitry Torokhov [this message]
2004-07-08 6:57 ` [PATCH 5/8] " Dmitry Torokhov
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.17205.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