Lines Matching refs:resource
32 return hash_32(handle.resource, VMCI_RESOURCE_HASH_BITS);
36 * Gets a resource (if one exists) matching given handle from the hash table.
41 struct vmci_resource *r, *resource = NULL;
48 u32 rid = r->handle.resource;
51 rid == handle.resource &&
54 resource = r;
60 return resource;
64 * Find an unused resource ID and return it. The first
67 * Returns VMCI resource id on success, VMCI_INVALID_ID on failure.
77 * Generate a unique resource ID. Keep on trying until we wrap around
99 int vmci_resource_add(struct vmci_resource *resource,
109 if (handle.resource == VMCI_INVALID_ID) {
110 handle.resource = vmci_resource_find_id(handle.context,
112 if (handle.resource == VMCI_INVALID_ID) {
121 resource->handle = handle;
122 resource->type = resource_type;
123 INIT_HLIST_NODE(&resource->node);
124 kref_init(&resource->kref);
125 init_completion(&resource->done);
127 idx = vmci_resource_hash(resource->handle);
128 hlist_add_head_rcu(&resource->node, &vmci_resource_table.entries[idx]);
137 void vmci_resource_remove(struct vmci_resource *resource)
139 struct vmci_handle handle = resource->handle;
143 /* Remove resource from hash table. */
147 if (vmci_handle_is_equal(r->handle, resource->handle)) {
156 vmci_resource_put(resource);
157 wait_for_completion(&resource->done);
164 struct vmci_resource *r, *resource = NULL;
172 resource = vmci_resource_get(r);
177 return resource;
181 * Get a reference to given resource.
183 struct vmci_resource *vmci_resource_get(struct vmci_resource *resource)
185 kref_get(&resource->kref);
187 return resource;
192 struct vmci_resource *resource =
195 /* Verify the resource has been unlinked from hash table */
196 WARN_ON(!hlist_unhashed(&resource->node));
198 /* Signal that container of this resource can now be destroyed */
199 complete(&resource->done);
205 * can increment the count again (it's gone from the resource hash
208 int vmci_resource_put(struct vmci_resource *resource)
214 return kref_put(&resource->kref, vmci_release_resource) ?
218 struct vmci_handle vmci_resource_handle(struct vmci_resource *resource)
220 return resource->handle;