[patch] Input - Use lists.h in serio core [8/23]

From: Vojtech Pavlik (vojtech@suse.cz)
Date: Tue Oct 08 2002 - 08:46:31 EST


You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.
'bk pull bk://linux-input.bkbits.net/linux-input' should work as well.

===================================================================

ChangeSet@1.573.1.37, 2002-09-25 12:03:31+02:00, vojtech@suse.cz
  Convert serio.[ch] to use list.h lists.

 drivers/input/serio/serio.c | 88 ++++++++++++++++++++++++--------------------
 include/linux/serio.h | 39 +++++--------------
 2 files changed, 59 insertions(+), 68 deletions(-)

===================================================================

diff -Nru a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
--- a/drivers/input/serio/serio.c Tue Oct 8 15:26:50 2002
+++ b/drivers/input/serio/serio.c Tue Oct 8 15:26:50 2002
@@ -37,6 +37,7 @@
 #include <linux/sched.h>
 #include <linux/smp_lock.h>
 #include <linux/suspend.h>
+#include <linux/slab.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
 MODULE_DESCRIPTION("Serio abstraction core");
@@ -51,19 +52,27 @@
 EXPORT_SYMBOL(serio_close);
 EXPORT_SYMBOL(serio_rescan);
 
-static struct serio *serio_list;
-static struct serio_dev *serio_dev;
+struct serio_event {
+ int type;
+ struct serio *serio;
+ struct list_head node;
+};
+
+static LIST_HEAD(serio_list);
+static LIST_HEAD(serio_dev_list);
+static LIST_HEAD(serio_event_list);
 static int serio_pid;
 
 static void serio_find_dev(struct serio *serio)
 {
- struct serio_dev *dev = serio_dev;
+ struct serio_dev *dev;
 
- while (dev && !serio->dev) {
+ list_for_each_entry(dev, &serio_dev_list, node) {
+ if (serio->dev)
+ break;
                 if (dev->connect)
- dev->connect(serio, dev);
- dev = dev->next;
- }
+ dev->connect(serio, dev);
+ }
 }
 
 #define SERIO_RESCAN 1
@@ -73,17 +82,23 @@
 
 void serio_handle_events(void)
 {
- struct serio *serio = serio_list;
+ struct list_head *node, *next;
+ struct serio_event *event;
 
- while (serio) {
- if (serio->event & SERIO_RESCAN) {
- if (serio->dev && serio->dev->disconnect)
- serio->dev->disconnect(serio);
- serio_find_dev(serio);
- }
+ list_for_each_safe(node, next, &serio_event_list) {
+ event = container_of(node, struct serio_event, node);
 
- serio->event = 0;
- serio = serio->next;
+ switch (event->type) {
+ case SERIO_RESCAN :
+ if (event->serio->dev && event->serio->dev->disconnect)
+ event->serio->dev->disconnect(event->serio);
+ serio_find_dev(event->serio);
+ break;
+ default:
+ break;
+ }
+ list_del_init(node);
+ kfree(event);
         }
 }
 
@@ -95,7 +110,7 @@
 
         do {
                 serio_handle_events();
- interruptible_sleep_on(&serio_wait);
+ wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
                 if (current->flags & PF_FREEZE)
                         refrigerator(PF_IOTHREAD);
         } while (!signal_pending(current));
@@ -108,7 +123,15 @@
 
 void serio_rescan(struct serio *serio)
 {
- serio->event |= SERIO_RESCAN;
+ struct serio_event *event;
+
+ if (!(event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC)))
+ return;
+
+ event->type = SERIO_RESCAN;
+ event->serio = serio;
+
+ list_add_tail(&event->node, &serio_event_list);
         wake_up(&serio_wait);
 }
 
@@ -122,49 +145,36 @@
 
 void serio_register_port(struct serio *serio)
 {
- serio->next = serio_list;
- serio_list = serio;
+ list_add_tail(&serio->node, &serio_list);
         serio_find_dev(serio);
 }
 
 void serio_unregister_port(struct serio *serio)
 {
- struct serio **serioptr = &serio_list;
-
- while (*serioptr && (*serioptr != serio)) serioptr = &((*serioptr)->next);
- *serioptr = (*serioptr)->next;
-
+ list_del_init(&serio->node);
         if (serio->dev && serio->dev->disconnect)
                 serio->dev->disconnect(serio);
 }
 
 void serio_register_device(struct serio_dev *dev)
 {
- struct serio *serio = serio_list;
-
- dev->next = serio_dev;
- serio_dev = dev;
-
- while (serio) {
+ struct serio *serio;
+ list_add_tail(&dev->node, &serio_dev_list);
+ list_for_each_entry(serio, &serio_list, node)
                 if (!serio->dev && dev->connect)
                         dev->connect(serio, dev);
- serio = serio->next;
- }
 }
 
 void serio_unregister_device(struct serio_dev *dev)
 {
- struct serio_dev **devptr = &serio_dev;
- struct serio *serio = serio_list;
+ struct serio *serio;
 
- while (*devptr && (*devptr != dev)) devptr = &((*devptr)->next);
- *devptr = (*devptr)->next;
+ list_del_init(&dev->node);
 
- while (serio) {
+ list_for_each_entry(serio, &serio_list, node) {
                 if (serio->dev == dev && dev->disconnect)
                         dev->disconnect(serio);
                 serio_find_dev(serio);
- serio = serio->next;
         }
 }
 
diff -Nru a/include/linux/serio.h b/include/linux/serio.h
--- a/include/linux/serio.h Tue Oct 8 15:26:50 2002
+++ b/include/linux/serio.h Tue Oct 8 15:26:50 2002
@@ -2,36 +2,16 @@
 #define _SERIO_H
 
 /*
- * $Id: serio.h,v 1.21 2001/12/19 05:15:21 skids Exp $
- *
- * Copyright (C) 1999-2001 Vojtech Pavlik
- */
-
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * Should you need to contact me, the author, you can do so either by
- * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
- * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
- */
-
-/*
- * The serial port set type ioctl.
+ * Copyright (C) 1999-2002 Vojtech Pavlik
+*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
  */
 
 #include <linux/ioctl.h>
+#include <linux/list.h>
+
 #define SPIOCSTYPE _IOW('q', 0x01, unsigned long)
 
 struct serio;
@@ -57,7 +37,8 @@
         void (*close)(struct serio *);
 
         struct serio_dev *dev;
- struct serio *next;
+
+ struct list_head node;
 };
 
 struct serio_dev {
@@ -71,7 +52,7 @@
         void (*disconnect)(struct serio *);
         void (*cleanup)(struct serio *);
 
- struct serio_dev *next;
+ struct list_head node;
 };
 
 int serio_open(struct serio *serio, struct serio_dev *dev);

===================================================================

This BitKeeper patch contains the following changesets:
1.573.1.37
## Wrapped with gzip_uu ##

begin 664 bkpatch18270
M'XL(`!K=HCT``[U7;7/:.!#^;/V*[70F`VD`R^^&2Z9I2%/F>FTF:>_+]881
MMER[&)NQ95)Z]+_?2G8)+WFYMG='@@72[J/=9U>[XBF\+WG1UQ;Y)\&#F#R%
M5WDI^EI9E;P;?,'O5WF.WWMQ/N.]1JHWF?:2;%X)@NN73`0Q+'A1]C7:-=<S
M8CGG?>WJ_.+]Z],K0HZ/X2QFV4=^S04<'Q.1%PN6AN5S)N(TS[JB8%DYXX)U
M@WRV6HNN#%TW\,^FKJG;SHHZNN6N`AI2RBS*0]VP/,<BC6'/&[-W]7W#ICB:
M^LJQ;-TE0Z!=VS6[:*\+NM'3_9YA`S7ZNMDWZ3,=/^BP@PG/#.CHY`7\NY:?
MD0#.\@SY$X"12/+N'T'\)VX"N"VD22FZL1K*+OD5',LU77)Y2R7I?.>+$)WI
MY.01+\(BD1'M!3$K>I_R92F28-JK[0LV/+-TW5[IEN,[*QXP>^+S*/1<RCG;
MI6\-J1*GAMH&K(-D&M[*I+[O/VICD@5I%?)>FF35YP8JWF3=MZR5[KC47;'(
M#%S7X=3FW&-AN&?<`UBW9EF6YSDJDQ_PY?'<_GENR9PM>/K/F<4$I+Z-'U>(
M:SLJ_:F^F_B&=U_B6SYT3/\_37W,]]U<K[/@+72*&_6/N7OY$/,_<!1&I@^4
M/&VB#[\TX4_9I!N?D*%M@4%&M@T^*451!<T)'?,%SP3\1;0$!UGG!D3;%(!#
M-=S.2I_&,6<A9'F(TE\'Y`-",HP\O!Y=OQ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;]VRZ(>3`MJ]FQY?FN%4TL\C</_Z:%2`X`````
`
end
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:24 EST