Lines Matching refs:cap

50 	struct gb_cap *cap = container_of(kref, struct gb_cap, kref);
52 kfree(cap);
56 * All users of cap take a reference (from within list_mutex lock), before
60 static void put_cap(struct gb_cap *cap)
62 kref_put(&cap->kref, cap_kref_release);
68 struct gb_cap *cap;
72 list_for_each_entry(cap, &cap_list, node) {
73 if (&cap->cdev == cdev) {
74 kref_get(&cap->kref);
79 cap = NULL;
84 return cap;
87 static int cap_get_endpoint_uid(struct gb_cap *cap, u8 *euid)
89 struct gb_connection *connection = cap->connection;
96 dev_err(cap->parent, "failed to get endpoint uid (%d)\n", ret);
105 static int cap_get_ims_certificate(struct gb_cap *cap, u32 class, u32 id,
108 struct gb_connection *connection = cap->connection;
129 dev_err(cap->parent, "failed to get certificate (%d)\n", ret);
143 static int cap_authenticate(struct gb_cap *cap, u32 auth_type, u8 *uid,
147 struct gb_connection *connection = cap->connection;
168 dev_err(cap->parent, "failed to authenticate (%d)\n", ret);
187 struct gb_cap *cap = get_cap(inode->i_cdev);
189 /* cap structure can't get freed until file descriptor is closed */
190 if (cap) {
191 file->private_data = cap;
200 struct gb_cap *cap = file->private_data;
202 put_cap(cap);
206 static int cap_ioctl(struct gb_cap *cap, unsigned int cmd,
217 ret = cap_get_endpoint_uid(cap, endpoint_uid.uid);
231 ret = cap_get_ims_certificate(cap, ims_cert->certificate_class,
247 ret = cap_authenticate(cap, authenticate->auth_type,
267 struct gb_cap *cap = file->private_data;
268 struct gb_bundle *bundle = cap->connection->bundle;
281 mutex_lock(&cap->mutex);
282 if (!cap->disabled) {
285 ret = cap_ioctl(cap, cmd, (void __user *)arg);
289 mutex_unlock(&cap->mutex);
303 struct gb_cap *cap;
309 cap = kzalloc(sizeof(*cap), GFP_KERNEL);
310 if (!cap)
313 cap->parent = &connection->bundle->dev;
314 cap->connection = connection;
315 mutex_init(&cap->mutex);
316 gb_connection_set_data(connection, cap);
317 kref_init(&cap->kref);
320 list_add(&cap->node, &cap_list);
333 /* Add a char device to allow userspace to interact with cap */
334 cap->dev_num = MKDEV(MAJOR(cap_dev_num), minor);
335 cdev_init(&cap->cdev, &cap_fops);
337 ret = cdev_add(&cap->cdev, cap->dev_num, 1);
342 cap->class_device = device_create(&cap_class, cap->parent, cap->dev_num,
344 if (IS_ERR(cap->class_device)) {
345 ret = PTR_ERR(cap->class_device);
352 cdev_del(&cap->cdev);
359 list_del(&cap->node);
362 put_cap(cap);
369 struct gb_cap *cap;
374 cap = gb_connection_get_data(connection);
376 device_destroy(&cap_class, cap->dev_num);
377 cdev_del(&cap->cdev);
378 ida_free(&cap_minors_map, MINOR(cap->dev_num));
384 mutex_lock(&cap->mutex);
385 cap->disabled = true;
386 mutex_unlock(&cap->mutex);
389 gb_connection_disable(cap->connection);
391 /* Disallow new users to get access to the cap structure */
393 list_del(&cap->node);
397 * All current users of cap would have taken a reference to it by
399 * cap freed.
401 put_cap(cap);