* [PATCH] serio_for_each_port() -- for serio hijacking
@ 2003-11-18 18:40 Zinx Verituse
0 siblings, 0 replies; only message in thread
From: Zinx Verituse @ 2003-11-18 18:40 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
Well, this is the best method I could think of for rescanning
the serio devices. I don't know if the overhead for function
calls is acceptable, or even if this functionality is desired.
Anyway, this is for questions and comments.
WARNING: Untested code, but I'm resonably sure it works ;)
--
Zinx Verituse
[-- Attachment #2: linux-2.6.0-test9-serio_for_each_port.diff --]
[-- Type: text/plain, Size: 1835 bytes --]
diff -ru linux-2.6.0-test9.orig/drivers/input/serio/serio.c linux-2.6.0-test9/drivers/input/serio/serio.c
--- linux-2.6.0-test9.orig/drivers/input/serio/serio.c 2003-10-25 13:42:48.000000000 -0500
+++ linux-2.6.0-test9/drivers/input/serio/serio.c 2003-11-18 12:23:46.000000000 -0600
@@ -28,6 +28,9 @@
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
*
* Changes:
+ * 18 Nov. 2003 Zinx Verituse <zinx@epicsol.org>
+ * serio_for_each_port()
+ *
* 20 Jul. 2003 Daniele Bellucci <bellucda@tiscali.it>
* Minor cleanups.
*/
@@ -57,6 +60,7 @@
EXPORT_SYMBOL(serio_open);
EXPORT_SYMBOL(serio_close);
EXPORT_SYMBOL(serio_rescan);
+EXPORT_SYMBOL(serio_for_each_port);
struct serio_event {
int type;
@@ -244,6 +248,27 @@
serio->dev = NULL;
}
+/*
+ * called without serio_sem locked
+ * func() should return non-zero to exit the for_each
+ * the last return value of func() is returned by serio_for_each_func
+ */
+int serio_for_each_port(int (*func)(struct serio*))
+{
+ struct serio *serio;
+ int retval;
+
+ down(&serio_sem);
+ list_for_each_entry(serio, &serio_list, node) {
+ retval = func(serio);
+ if (retval)
+ break;
+ }
+ up(&serio_sem);
+
+ return retval;
+}
+
static int __init serio_init(void)
{
int pid;
diff -ru linux-2.6.0-test9.orig/include/linux/serio.h linux-2.6.0-test9/include/linux/serio.h
--- linux-2.6.0-test9.orig/include/linux/serio.h 2003-10-25 13:43:52.000000000 -0500
+++ linux-2.6.0-test9/include/linux/serio.h 2003-11-18 12:15:04.000000000 -0600
@@ -67,6 +67,8 @@
void serio_register_device(struct serio_dev *dev);
void serio_unregister_device(struct serio_dev *dev);
+int serio_for_each_port(int (*func)(struct serio *));
+
static __inline__ int serio_write(struct serio *serio, unsigned char data)
{
if (serio->write)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-11-18 18:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-18 18:40 [PATCH] serio_for_each_port() -- for serio hijacking Zinx Verituse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox