lkml.org 
[lkml]   [2015]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 32/44] kdbus: Remove duplicated code from kdbus_conn_lock2()
Date
Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
---
ipc/kdbus/connection.h | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/ipc/kdbus/connection.h b/ipc/kdbus/connection.h
index 679f393d3e68..3b382b604348 100644
--- a/ipc/kdbus/connection.h
+++ b/ipc/kdbus/connection.h
@@ -215,17 +215,13 @@ static inline int kdbus_conn_is_monitor(const struct kdbus_conn *conn)
*/
static inline void kdbus_conn_lock2(struct kdbus_conn *a, struct kdbus_conn *b)
{
- if (a < b) {
- if (a)
- mutex_lock(&a->lock);
- if (b && b != a)
- mutex_lock_nested(&b->lock, !!a);
- } else {
- if (b)
- mutex_lock(&b->lock);
- if (a && a != b)
- mutex_lock_nested(&a->lock, !!b);
- }
+ struct kdbus_conn *lo = min(a, b);
+ struct kdbus_conn *hi = max(a, b);
+
+ if (lo)
+ mutex_lock(&lo->lock);
+ if (hi && hi != lo)
+ mutex_lock_nested(&hi->lock, !!lo);
}

/**
--
1.8.3.1


\
 
 \ /
  Last update: 2015-10-08 14:01    [W:0.231 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site