]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/plat-omap/dsp/proclist.h
cc5c3e0c0eb8a9d893e932a1e2255ad2f530edd6
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / dsp / proclist.h
1 /*
2  * This file is part of OMAP DSP driver (DSP Gateway version 3.3.1)
3  *
4  * Copyright (C) 2004-2006 Nokia Corporation. All rights reserved.
5  *
6  * Contact: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 struct proc_list {
25         struct list_head list_head;
26         pid_t pid;
27         struct file *file;
28 };
29
30 static __inline__ void proc_list_add(spinlock_t *lock, struct list_head *list,
31                                      struct task_struct *tsk, struct file *file)
32 {
33         struct proc_list *new;
34
35         new = kmalloc(sizeof(struct proc_list), GFP_KERNEL);
36         new->pid = tsk->pid;
37         new->file = file;
38         spin_lock(lock);
39         list_add_tail(&new->list_head, list);
40         spin_unlock(lock);
41 }
42
43 static __inline__ void proc_list_del(spinlock_t *lock, struct list_head *list,
44                                      struct task_struct *tsk, struct file *file)
45 {
46         struct proc_list *pl;
47
48         spin_lock(lock);
49         list_for_each_entry(pl, list, list_head) {
50                 if (pl->file == file) {
51                         list_del(&pl->list_head);
52                         kfree(pl);
53                         spin_unlock(lock);
54                         return;
55                 }
56         }
57
58         /* correspinding file struct isn't found in the list ???  */
59         printk(KERN_ERR "proc_list_del(): proc_list is inconsistent!\n"
60                         "struct file (%p) not found\n", file);
61         printk(KERN_ERR "listing proc_list...\n");
62         list_for_each_entry(pl, list, list_head)
63                 printk(KERN_ERR "  pid:%d file:%p\n", pl->pid, pl->file);
64         spin_unlock(lock);
65 }
66
67 static __inline__ void proc_list_flush(spinlock_t *lock, struct list_head *list)
68 {
69         struct proc_list *pl;
70
71         spin_lock(lock);
72         while (!list_empty(list)) {
73                 pl = list_entry(list->next, struct proc_list, list_head);
74                 list_del(&pl->list_head);
75                 kfree(pl);
76         }
77         spin_unlock(lock);
78 }