connection: provide kdbus_conn_assert_active() wrapper
authorDavid Herrmann <dh.herrmann@gmail.com>
Fri, 9 Jan 2015 18:05:42 +0000 (19:05 +0100)
committerDavid Herrmann <dh.herrmann@gmail.com>
Fri, 9 Jan 2015 18:06:39 +0000 (19:06 +0100)
Avoid depending on lockdep internals everywhere. Use
kdbus_conn_assert_active() to check whether the caller holds an active
reference.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection.h
match.c

index e535ab83eb8b18fad202a9ce4d19a9e066e310f7..cde20038212c1c7566758665e1a941857e03b838 100644 (file)
@@ -247,4 +247,16 @@ static inline void kdbus_conn_unlock2(struct kdbus_conn *a,
                mutex_unlock(&b->lock);
 }
 
+/**
+ * kdbus_conn_assert_active() - lockdep assert on active lock
+ * @conn:      connection that shall be active
+ *
+ * This verifies via lockdep that the caller holds an active reference to the
+ * given connection.
+ */
+static inline void kdbus_conn_assert_active(struct kdbus_conn *conn)
+{
+       lockdep_assert_held(conn);
+}
+
 #endif
diff --git a/match.c b/match.c
index cac414e817b41ae77a986cece060527889edc9dc..d4f21848f66bdda508ef5fe05b71647b8066fc5b 100644 (file)
--- a/match.c
+++ b/match.c
@@ -372,7 +372,7 @@ int kdbus_match_db_add(struct kdbus_conn *conn,
        struct kdbus_item *item;
        int ret = 0;
 
-       lockdep_assert_held(conn);
+       kdbus_conn_assert_active(conn);
 
        entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        if (!entry)
@@ -525,7 +525,7 @@ int kdbus_match_db_remove(struct kdbus_conn *conn,
        struct kdbus_match_db *mdb = conn->match_db;
        int ret;
 
-       lockdep_assert_held(conn);
+       kdbus_conn_assert_active(conn);
 
        down_write(&mdb->mdb_rwlock);
        ret = kdbus_match_db_remove_unlocked(mdb, cmd->cookie);