Signed-off-by: Sergei Zviagintsev <[email protected]>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to