Add another parameter to function that require the lock :
spinlock_t lock = SPIN_LOCK_UNLOCKED;
LIST_HEAD(list);
void add_entry(struct foo *f, int need_lock)
{
unsigned long flags;
if (need_lock)
spin_lock_irqsave(&lock, flags);
list_add(&f->list, &list);
if (need_lock)
spin_unlock_irqsave(&lock, flags);
}
void something(struct foo *f, int need_lock)
{
...
remove_entry(f, need_lock);
...
add_entry(fnew, need_lock);
...
}
void interrupt(int irq, void *bar, struct pt_regs *regs)
{
struct list_head *tmp, *head = &list;
spin_lock(&lock);
tmp = head->next;
while (tmp != head) {
struct *foo = list_entry(tmp, struct foo, list);
something(foo, 0);
}
spin_unlock(&lock);
}
Cheers,
Davide.
-- "Debian, the Freedom in Freedom."
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/