From: Zinx Verituse <zinx@epicsol.org>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] serio_for_each_port() -- for serio hijacking
Date: Tue, 18 Nov 2003 12:40:00 -0600 [thread overview]
Message-ID: <20031118184000.GA9338@bliss> (raw)
[-- 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)
reply other threads:[~2003-11-18 18:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20031118184000.GA9338@bliss \
--to=zinx@epicsol.org \
--cc=linux-kernel@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 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.