serio_for_each_port() -- for serio hijacking
PATCH 1/1 serio_for_each_port() -- for serio hijacking
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 ;)
Signature · 1 line
Zinx Verituse
drivers/input/serio/serio.c +25 -0
@@ -28,6 +28,9 @@* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic * * Changes: +* 18 Nov. 2003 Zinx Verituse <[email protected]> +* serio_for_each_port() +* * 20 Jul. 2003 Daniele Bellucci <[email protected]> * 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;
include/linux/serio.h +2 -0
@@ -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)