Lines Matching refs:teedev
47 struct tee_context *teedev_open(struct tee_device *teedev) in teedev_open() argument
52 if (!tee_device_get(teedev)) in teedev_open()
62 ctx->teedev = teedev; in teedev_open()
63 rc = teedev->desc->ops->open(ctx); in teedev_open()
70 tee_device_put(teedev); in teedev_open()
89 ctx->teedev->desc->ops->release(ctx); in teedev_ctx_release()
103 struct tee_device *teedev = ctx->teedev; in teedev_close_context() local
106 tee_device_put(teedev); in teedev_close_context()
276 ctx->teedev->desc->ops->get_version(ctx->teedev, &vers); in tee_ioctl_version()
278 if (ctx->teedev->desc->flags & TEE_DESC_PRIVILEGED) in tee_ioctl_version()
477 if (!ctx->teedev->desc->ops->open_session) in tee_ioctl_open_session()
512 rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params); in tee_ioctl_open_session()
529 if (rc && have_session && ctx->teedev->desc->ops->close_session) in tee_ioctl_open_session()
530 ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_open_session()
555 if (!ctx->teedev->desc->ops->invoke_func) in tee_ioctl_invoke()
583 rc = ctx->teedev->desc->ops->invoke_func(ctx, &arg, params); in tee_ioctl_invoke()
610 if (!ctx->teedev->desc->ops->cancel_req) in tee_ioctl_cancel()
616 return ctx->teedev->desc->ops->cancel_req(ctx, arg.cancel_id, in tee_ioctl_cancel()
626 if (!ctx->teedev->desc->ops->close_session) in tee_ioctl_close_session()
632 return ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_close_session()
689 if (!ctx->teedev->desc->ops->supp_recv) in tee_ioctl_supp_recv()
714 rc = ctx->teedev->desc->ops->supp_recv(ctx, &func, &num_params, params); in tee_ioctl_supp_recv()
787 if (!ctx->teedev->desc->ops->supp_send) in tee_ioctl_supp_send()
813 rc = ctx->teedev->desc->ops->supp_send(ctx, ret, num_params, params); in tee_ioctl_supp_send()
858 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in tee_release_device() local
861 clear_bit(teedev->id, dev_mask); in tee_release_device()
863 mutex_destroy(&teedev->mutex); in tee_release_device()
864 idr_destroy(&teedev->idr); in tee_release_device()
865 kfree(teedev); in tee_release_device()
885 struct tee_device *teedev; in tee_device_alloc() local
895 teedev = kzalloc(sizeof(*teedev), GFP_KERNEL); in tee_device_alloc()
896 if (!teedev) { in tee_device_alloc()
909 teedev->id = find_next_zero_bit(dev_mask, max_id, offs); in tee_device_alloc()
910 if (teedev->id < max_id) in tee_device_alloc()
911 set_bit(teedev->id, dev_mask); in tee_device_alloc()
914 if (teedev->id >= max_id) { in tee_device_alloc()
919 snprintf(teedev->name, sizeof(teedev->name), "tee%s%d", in tee_device_alloc()
921 teedev->id - offs); in tee_device_alloc()
923 teedev->dev.class = &tee_class; in tee_device_alloc()
924 teedev->dev.release = tee_release_device; in tee_device_alloc()
925 teedev->dev.parent = dev; in tee_device_alloc()
927 teedev->dev.devt = MKDEV(MAJOR(tee_devt), teedev->id); in tee_device_alloc()
929 rc = dev_set_name(&teedev->dev, "%s", teedev->name); in tee_device_alloc()
935 cdev_init(&teedev->cdev, &tee_fops); in tee_device_alloc()
936 teedev->cdev.owner = teedesc->owner; in tee_device_alloc()
938 dev_set_drvdata(&teedev->dev, driver_data); in tee_device_alloc()
939 device_initialize(&teedev->dev); in tee_device_alloc()
942 teedev->num_users = 1; in tee_device_alloc()
943 init_completion(&teedev->c_no_users); in tee_device_alloc()
944 mutex_init(&teedev->mutex); in tee_device_alloc()
945 idr_init(&teedev->idr); in tee_device_alloc()
947 teedev->desc = teedesc; in tee_device_alloc()
948 teedev->pool = pool; in tee_device_alloc()
950 return teedev; in tee_device_alloc()
952 unregister_chrdev_region(teedev->dev.devt, 1); in tee_device_alloc()
956 if (teedev && teedev->id < TEE_NUM_DEVICES) { in tee_device_alloc()
958 clear_bit(teedev->id, dev_mask); in tee_device_alloc()
961 kfree(teedev); in tee_device_alloc()
966 void tee_device_set_dev_groups(struct tee_device *teedev, in tee_device_set_dev_groups() argument
969 teedev->dev.groups = dev_groups; in tee_device_set_dev_groups()
976 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in implementation_id_show() local
979 teedev->desc->ops->get_version(teedev, &vers); in implementation_id_show()
1005 int tee_device_register(struct tee_device *teedev) in tee_device_register() argument
1009 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { in tee_device_register()
1010 dev_err(&teedev->dev, "attempt to register twice\n"); in tee_device_register()
1014 rc = cdev_device_add(&teedev->cdev, &teedev->dev); in tee_device_register()
1016 dev_err(&teedev->dev, in tee_device_register()
1018 teedev->name, MAJOR(teedev->dev.devt), in tee_device_register()
1019 MINOR(teedev->dev.devt), rc); in tee_device_register()
1023 teedev->flags |= TEE_DEVICE_FLAG_REGISTERED; in tee_device_register()
1028 void tee_device_put(struct tee_device *teedev) in tee_device_put() argument
1030 mutex_lock(&teedev->mutex); in tee_device_put()
1032 if (!WARN_ON(!teedev->desc)) { in tee_device_put()
1033 teedev->num_users--; in tee_device_put()
1034 if (!teedev->num_users) { in tee_device_put()
1035 teedev->desc = NULL; in tee_device_put()
1036 complete(&teedev->c_no_users); in tee_device_put()
1039 mutex_unlock(&teedev->mutex); in tee_device_put()
1042 bool tee_device_get(struct tee_device *teedev) in tee_device_get() argument
1044 mutex_lock(&teedev->mutex); in tee_device_get()
1045 if (!teedev->desc) { in tee_device_get()
1046 mutex_unlock(&teedev->mutex); in tee_device_get()
1049 teedev->num_users++; in tee_device_get()
1050 mutex_unlock(&teedev->mutex); in tee_device_get()
1062 void tee_device_unregister(struct tee_device *teedev) in tee_device_unregister() argument
1064 if (!teedev) in tee_device_unregister()
1067 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) in tee_device_unregister()
1068 cdev_device_del(&teedev->cdev, &teedev->dev); in tee_device_unregister()
1070 tee_device_put(teedev); in tee_device_unregister()
1071 wait_for_completion(&teedev->c_no_users); in tee_device_unregister()
1078 teedev->pool = NULL; in tee_device_unregister()
1080 put_device(&teedev->dev); in tee_device_unregister()
1089 void *tee_get_drvdata(struct tee_device *teedev) in tee_get_drvdata() argument
1091 return dev_get_drvdata(&teedev->dev); in tee_get_drvdata()
1104 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in match_dev() local
1106 teedev->desc->ops->get_version(teedev, match_data->vers); in match_dev()
1123 dev = &start->teedev->dev; in tee_client_open_context()
1162 ctx->teedev->desc->ops->get_version(ctx->teedev, vers); in tee_client_get_version()
1170 if (!ctx->teedev->desc->ops->open_session) in tee_client_open_session()
1172 return ctx->teedev->desc->ops->open_session(ctx, arg, param); in tee_client_open_session()
1178 if (!ctx->teedev->desc->ops->close_session) in tee_client_close_session()
1180 return ctx->teedev->desc->ops->close_session(ctx, session); in tee_client_close_session()
1186 if (!ctx->teedev->desc->ops->system_session) in tee_client_system_session()
1188 return ctx->teedev->desc->ops->system_session(ctx, session); in tee_client_system_session()
1196 if (!ctx->teedev->desc->ops->invoke_func) in tee_client_invoke_func()
1198 return ctx->teedev->desc->ops->invoke_func(ctx, arg, param); in tee_client_invoke_func()
1205 if (!ctx->teedev->desc->ops->cancel_req) in tee_client_cancel_req()
1207 return ctx->teedev->desc->ops->cancel_req(ctx, arg->cancel_id, in tee_client_cancel_req()