Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 8 Oct 2002 09:41:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 8 Oct 2002 09:41:10 -0400 Received: from twilight.ucw.cz ([195.39.74.230]:45204 "EHLO twilight.ucw.cz") by vger.kernel.org with ESMTP id ; Tue, 8 Oct 2002 09:40:56 -0400 Date: Tue, 8 Oct 2002 15:46:31 +0200 From: Vojtech Pavlik To: Vojtech Pavlik Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org Subject: [patch] Input - Use lists.h in serio core [8/23] Message-ID: <20021008154631.G18546@ucw.cz> References: <20021008153813.A18515@ucw.cz> <20021008153926.A18546@ucw.cz> <20021008154029.B18546@ucw.cz> <20021008154132.C18546@ucw.cz> <20021008154246.D18546@ucw.cz> <20021008154415.E18546@ucw.cz> <20021008154549.F18546@ucw.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20021008154549.F18546@ucw.cz>; from vojtech@suse.cz on Tue, Oct 08, 2002 at 03:45:49PM +0200 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8975 Lines: 292 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 #include #include +#include MODULE_AUTHOR("Vojtech Pavlik "); 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 , 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 +#include + #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:-=WJ_.+]Z],K0HZ/X2QFV4=^S04<'Q.1%PN6AN5S)N(TS[JB8%DYXX)U M@WRV6HNN#%TW\,^FKJG;SHHZNN6N`AI2RBS*0]VP/,+$)WI MY.01+\(BD1'M!3$K>I_R92F28-JK[0LV/+-TW5[IEN,[*QXP>^+S*/1FF35YP8JWF3=MZR5[KC47;'( M#%S7X=3FW&-AN&?<`UBW9EF6YSDJDQ_PY?'<_GENR9PM>/K/F<4$I+Z-'U>( M:SLJ_:F^F_B&=U_B6SYT3/\_37W,]]UW+<:\L4C$LJX M;S)#1T<'1^JY9:($@D-\2!E#R1A@$DU9&N7%F+,@'B-2L6RAU!$<;.]_I#QI M2Q*T)()Z[\X)+K=Q1IL4G$TEM(6@(\=!'G$65SLG09YE/!"UQA%(#23J*QFZ MCC3#5;)[O!W*[8YPX)_%#MM-.`[5@'NZ'CADY)D29]N=DD6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