Lines Matching refs:fwctl
58 struct fwctl_device *fwctl = ucmd->uctx->fwctl; in fwctl_cmd_info() local
65 if (!fwctl->ops->info && cmd->device_data_len) { in fwctl_cmd_info()
71 fwctl->ops->info(ucmd->uctx, &driver_info_len); in fwctl_cmd_info()
81 cmd->out_device_type = fwctl->ops->device_type; in fwctl_cmd_info()
88 struct fwctl_device *fwctl = ucmd->uctx->fwctl; in fwctl_cmd_rpc() local
107 &fwctl->dev, in fwctl_cmd_rpc()
124 void *outbuf __free(kvfree) = fwctl->ops->fw_rpc( in fwctl_cmd_rpc()
201 guard(rwsem_read)(&uctx->fwctl->registration_lock); in fwctl_fops_ioctl()
202 if (!uctx->fwctl->ops) in fwctl_fops_ioctl()
209 struct fwctl_device *fwctl = in fwctl_fops_open() local
213 guard(rwsem_read)(&fwctl->registration_lock); in fwctl_fops_open()
214 if (!fwctl->ops) in fwctl_fops_open()
218 kzalloc(fwctl->ops->uctx_size, GFP_KERNEL_ACCOUNT); in fwctl_fops_open()
222 uctx->fwctl = fwctl; in fwctl_fops_open()
223 ret = fwctl->ops->open_uctx(uctx); in fwctl_fops_open()
227 scoped_guard(mutex, &fwctl->uctx_list_lock) { in fwctl_fops_open()
228 list_add_tail(&uctx->uctx_list_entry, &fwctl->uctx_list); in fwctl_fops_open()
231 get_device(&fwctl->dev); in fwctl_fops_open()
238 lockdep_assert_held(&uctx->fwctl->uctx_list_lock); in fwctl_destroy_uctx()
240 uctx->fwctl->ops->close_uctx(uctx); in fwctl_destroy_uctx()
246 struct fwctl_device *fwctl = uctx->fwctl; in fwctl_fops_release() local
248 scoped_guard(rwsem_read, &fwctl->registration_lock) { in fwctl_fops_release()
253 if (fwctl->ops) { in fwctl_fops_release()
254 guard(mutex)(&fwctl->uctx_list_lock); in fwctl_fops_release()
260 fwctl_put(fwctl); in fwctl_fops_release()
273 struct fwctl_device *fwctl = in fwctl_device_release() local
276 ida_free(&fwctl_ida, fwctl->dev.devt - fwctl_dev); in fwctl_device_release()
277 mutex_destroy(&fwctl->uctx_list_lock); in fwctl_device_release()
278 kfree(fwctl); in fwctl_device_release()
295 struct fwctl_device *fwctl __free(kfree) = kzalloc(size, GFP_KERNEL); in _alloc_device()
298 if (!fwctl) in _alloc_device()
305 fwctl->dev.devt = fwctl_dev + devnum; in _alloc_device()
306 fwctl->dev.class = &fwctl_class; in _alloc_device()
307 fwctl->dev.parent = parent; in _alloc_device()
309 init_rwsem(&fwctl->registration_lock); in _alloc_device()
310 mutex_init(&fwctl->uctx_list_lock); in _alloc_device()
311 INIT_LIST_HEAD(&fwctl->uctx_list); in _alloc_device()
313 device_initialize(&fwctl->dev); in _alloc_device()
314 return_ptr(fwctl); in _alloc_device()
322 struct fwctl_device *fwctl __free(fwctl) = in _fwctl_alloc_device()
325 if (!fwctl) in _fwctl_alloc_device()
328 cdev_init(&fwctl->cdev, &fwctl_fops); in _fwctl_alloc_device()
333 fwctl->cdev.owner = THIS_MODULE; in _fwctl_alloc_device()
335 if (dev_set_name(&fwctl->dev, "fwctl%d", fwctl->dev.devt - fwctl_dev)) in _fwctl_alloc_device()
338 fwctl->ops = ops; in _fwctl_alloc_device()
339 return_ptr(fwctl); in _fwctl_alloc_device()
350 int fwctl_register(struct fwctl_device *fwctl) in fwctl_register() argument
352 return cdev_device_add(&fwctl->cdev, &fwctl->dev); in fwctl_register()
372 void fwctl_unregister(struct fwctl_device *fwctl) in fwctl_unregister() argument
376 cdev_device_del(&fwctl->cdev, &fwctl->dev); in fwctl_unregister()
379 guard(rwsem_write)(&fwctl->registration_lock); in fwctl_unregister()
380 guard(mutex)(&fwctl->uctx_list_lock); in fwctl_unregister()
381 while ((uctx = list_first_entry_or_null(&fwctl->uctx_list, in fwctl_unregister()
390 fwctl->ops = NULL; in fwctl_unregister()