kernel: add functions to lock/unlock a pair of locks without saving irq flags
This commit is contained in:
@@ -180,20 +180,22 @@ void object_unlock_irqrestore(struct object *obj, unsigned long flags)
|
||||
spin_unlock_irqrestore(&obj->ob_lock, flags);
|
||||
}
|
||||
|
||||
void object_lock_pair(struct object *a, struct object *b)
|
||||
{
|
||||
spin_lock_pair(&a->ob_lock, &b->ob_lock);
|
||||
}
|
||||
|
||||
void object_unlock_pair(struct object *a, struct object *b)
|
||||
{
|
||||
spin_unlock_pair(&a->ob_lock, &b->ob_lock);
|
||||
}
|
||||
|
||||
void object_lock_pair_irqsave(
|
||||
struct object *a,
|
||||
struct object *b,
|
||||
unsigned long *flags)
|
||||
{
|
||||
if (a == b) {
|
||||
object_lock_irqsave(a, flags);
|
||||
} else if (a < b) {
|
||||
object_lock_irqsave(a, flags);
|
||||
object_lock(b);
|
||||
} else {
|
||||
object_lock_irqsave(b, flags);
|
||||
object_lock(a);
|
||||
}
|
||||
spin_lock_pair_irqsave(&a->ob_lock, &b->ob_lock, flags);
|
||||
}
|
||||
|
||||
void object_unlock_pair_irqrestore(
|
||||
@@ -201,15 +203,7 @@ void object_unlock_pair_irqrestore(
|
||||
struct object *b,
|
||||
unsigned long flags)
|
||||
{
|
||||
if (a == b) {
|
||||
object_unlock_irqrestore(a, flags);
|
||||
} else if (a < b) {
|
||||
object_unlock(b);
|
||||
object_unlock_irqrestore(a, flags);
|
||||
} else {
|
||||
object_unlock(a);
|
||||
object_unlock_irqrestore(b, flags);
|
||||
}
|
||||
spin_unlock_pair_irqrestore(&a->ob_lock, &b->ob_lock, flags);
|
||||
}
|
||||
|
||||
void *object_data(struct object *obj)
|
||||
|
||||
Reference in New Issue
Block a user