names: rename "entries_lock" to "lock"
authorKay Sievers <kay@vrfy.org>
Sun, 23 Mar 2014 21:58:09 +0000 (22:58 +0100)
committerKay Sievers <kay@vrfy.org>
Sun, 23 Mar 2014 21:58:09 +0000 (22:58 +0100)
names.c
names.h

diff --git a/names.c b/names.c
index e031e83cea74892f2892ad4f08f005e0dc4763f1..be8ae5d334d831a24583019056682c7e2cb2b872 100644 (file)
--- a/names.c
+++ b/names.c
@@ -64,10 +64,10 @@ void kdbus_name_registry_free(struct kdbus_name_registry *reg)
        struct hlist_node *tmp;
        unsigned int i;
 
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
        hash_for_each_safe(reg->entries_hash, i, tmp, e, hentry)
                kdbus_name_entry_free(e);
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
 
        kfree(reg);
 }
@@ -87,10 +87,9 @@ int kdbus_name_registry_new(struct kdbus_name_registry **reg)
                return -ENOMEM;
 
        hash_init(r->entries_hash);
-       mutex_init(&r->entries_lock);
+       mutex_init(&r->lock);
 
        *reg = r;
-
        return 0;
 }
 
@@ -140,7 +139,6 @@ static void kdbus_name_entry_set_owner(struct kdbus_name_entry *e,
        mutex_unlock(&conn->lock);
 }
 
-/* called with entries_lock held */
 static int kdbus_name_replace_owner(struct kdbus_name_registry *reg,
                                    struct kdbus_conn *conn,
                                    struct kdbus_name_entry *e, u64 flags,
@@ -148,6 +146,8 @@ static int kdbus_name_replace_owner(struct kdbus_name_registry *reg,
 {
        int ret;
 
+       BUG_ON(!mutex_is_locked(&reg->lock));
+
        ret = kdbus_notify_name_change(KDBUS_ITEM_NAME_CHANGE,
                                       e->conn->id, conn->id,
                                       e->flags, flags,
@@ -274,7 +274,7 @@ void kdbus_name_remove_by_conn(struct kdbus_name_registry *reg,
        mutex_unlock(&conn->lock);
 
        mutex_lock(&conn->bus->lock);
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
        if (conn->flags & KDBUS_HELLO_ACTIVATOR) {
                activator = conn->activator_of->activator;
                conn->activator_of->activator = NULL;
@@ -283,7 +283,7 @@ void kdbus_name_remove_by_conn(struct kdbus_name_registry *reg,
                kdbus_name_queue_item_free(q);
        list_for_each_entry_safe(e, e_tmp, &names_list, conn_entry)
                kdbus_name_entry_release(e, &notify_list);
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
        mutex_unlock(&conn->bus->lock);
 
        kdbus_conn_unref(activator);
@@ -304,9 +304,9 @@ struct kdbus_name_entry *kdbus_name_lookup(struct kdbus_name_registry *reg,
        struct kdbus_name_entry *e = NULL;
        u32 hash = kdbus_str_hash(name);
 
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
        e = __kdbus_name_lookup(reg, hash, name);
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
 
        return e;
 }
@@ -409,7 +409,7 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
        hash = kdbus_str_hash(name);
 
        mutex_lock(&conn->bus->lock);
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
 
        e = __kdbus_name_lookup(reg, hash, name);
        if (e) {
@@ -528,7 +528,7 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
                *entry = e;
 
 exit_unlock:
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
        mutex_unlock(&conn->bus->lock);
        kdbus_conn_kmsg_list_send(conn->ep, &notify_list);
 
@@ -641,7 +641,7 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
        hash = kdbus_str_hash(cmd->name);
 
        mutex_lock(&bus->lock);
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
        e = __kdbus_name_lookup(reg, hash, cmd->name);
        if (!e) {
                ret = -ESRCH;
@@ -668,7 +668,7 @@ int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
        ret = kdbus_name_release(e, conn, &notify_list);
 
 exit_unlock:
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
        mutex_unlock(&bus->lock);
 
        if (conn) {
@@ -831,7 +831,7 @@ int kdbus_cmd_name_list(struct kdbus_name_registry *reg,
        policy_db = conn->ep->policy_db;
 
        mutex_lock(&conn->bus->lock);
-       mutex_lock(&reg->entries_lock);
+       mutex_lock(&reg->lock);
 
        if (policy_db)
                mutex_lock(&policy_db->entries_lock);
@@ -873,7 +873,7 @@ exit_unlock:
        if (policy_db)
                mutex_unlock(&policy_db->entries_lock);
 
-       mutex_unlock(&reg->entries_lock);
+       mutex_unlock(&reg->lock);
        mutex_unlock(&conn->bus->lock);
 
        return ret;
diff --git a/names.h b/names.h
index 09077637300e724f30cf1b1f35ff0b1f2c8096da..6e01cd1b693043d99f4d45a6acbf29c15653cf92 100644 (file)
--- a/names.h
+++ b/names.h
 /**
  * struct kdbus_name_registry - names registered for a bus
  * @entries_hash:      Map of entries
- * @entries_lock:      Registry data lock
+ * @lock:              Registry data lock
  * @name_seq_last:     Last used sequence number to assign to a name entry
  */
 struct kdbus_name_registry {
        DECLARE_HASHTABLE(entries_hash, 8);
-       struct mutex entries_lock;
+       struct mutex lock;
        u64 name_seq_last;
 };