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) &&
148 resource->type == r->type) {
157 vmci_resource_put(resource);
158 wait_for_completion(&resource->done);
165 struct vmci_resource *r, *resource = NULL;
173 resource = vmci_resource_get(r);
178 return resource;
182 * Get a reference to given resource.
184 struct vmci_resource *vmci_resource_get(struct vmci_resource *resource)
186 kref_get(&resource->kref);
188 return resource;
193 struct vmci_resource *resource =
196 /* Verify the resource has been unlinked from hash table */
197 WARN_ON(!hlist_unhashed(&resource->node));
199 /* Signal that container of this resource can now be destroyed */
200 complete(&resource->done);
206 * can increment the count again (it's gone from the resource hash
209 int vmci_resource_put(struct vmci_resource *resource)
215 return kref_put(&resource->kref, vmci_release_resource) ?
219 struct vmci_handle vmci_resource_handle(struct vmci_resource *resource)
221 return resource->handle;