2 * linux/arch/arm/mach-omap/dsp/proclist.h
4 * Linux task list handler
6 * Copyright (C) 2004,2005 Nokia Corporation
8 * Written by Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * 2004/11/22: DSP Gateway version 3.3
28 struct list_head list_head;
33 static __inline__ void proc_list_add(struct list_head *list,
34 struct task_struct *tsk)
37 struct proc_list *new;
39 list_for_each_entry(pl, list, list_head) {
40 if (pl->pid == tsk->pid) {
42 * this process has opened DSP devices multi time
49 new = kmalloc(sizeof(struct proc_list), GFP_KERNEL);
52 list_add_tail(&new->list_head, list);
55 static __inline__ void proc_list_del(struct list_head *list,
56 struct task_struct *tsk)
58 struct proc_list *pl, *next;
60 list_for_each_entry(pl, list, list_head) {
61 if (pl->pid == tsk->pid) {
63 list_del(&pl->list_head);
71 * correspinding pid wasn't found in the list
72 * -- this means the caller of proc_list_del is different from
73 * the proc_list_add's caller. in this case, the parent is
74 * cleaning up the context of a killed child.
75 * let's delete exiting task from the list.
77 /* need to lock tasklist_lock before calling find_task_by_pid_type. */
78 read_lock(&tasklist_lock);
79 list_for_each_entry_safe(pl, next, list, list_head) {
80 if (find_task_by_pid_type(PIDTYPE_PID, pl->pid) == NULL) {
81 list_del(&pl->list_head);
85 read_unlock(&tasklist_lock);
88 static __inline__ void proc_list_flush(struct list_head *list)
92 while (!list_empty(list)) {
93 pl = list_entry(list->next, struct proc_list, list_head);
94 list_del(&pl->list_head);