Lines Matching refs:teedev

46 struct tee_context *teedev_open(struct tee_device *teedev)  in teedev_open()  argument
51 if (!tee_device_get(teedev)) in teedev_open()
61 ctx->teedev = teedev; in teedev_open()
62 rc = teedev->desc->ops->open(ctx); in teedev_open()
69 tee_device_put(teedev); in teedev_open()
88 ctx->teedev->desc->ops->release(ctx); in teedev_ctx_release()
102 struct tee_device *teedev = ctx->teedev; in teedev_close_context() local
105 tee_device_put(teedev); in teedev_close_context()
275 ctx->teedev->desc->ops->get_version(ctx->teedev, &vers); in tee_ioctl_version()
277 if (ctx->teedev->desc->flags & TEE_DESC_PRIVILEGED) in tee_ioctl_version()
476 if (!ctx->teedev->desc->ops->open_session) in tee_ioctl_open_session()
511 rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params); in tee_ioctl_open_session()
528 if (rc && have_session && ctx->teedev->desc->ops->close_session) in tee_ioctl_open_session()
529 ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_open_session()
554 if (!ctx->teedev->desc->ops->invoke_func) in tee_ioctl_invoke()
582 rc = ctx->teedev->desc->ops->invoke_func(ctx, &arg, params); in tee_ioctl_invoke()
609 if (!ctx->teedev->desc->ops->cancel_req) in tee_ioctl_cancel()
615 return ctx->teedev->desc->ops->cancel_req(ctx, arg.cancel_id, in tee_ioctl_cancel()
625 if (!ctx->teedev->desc->ops->close_session) in tee_ioctl_close_session()
631 return ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_close_session()
688 if (!ctx->teedev->desc->ops->supp_recv) in tee_ioctl_supp_recv()
713 rc = ctx->teedev->desc->ops->supp_recv(ctx, &func, &num_params, params); in tee_ioctl_supp_recv()
786 if (!ctx->teedev->desc->ops->supp_send) in tee_ioctl_supp_send()
812 rc = ctx->teedev->desc->ops->supp_send(ctx, ret, num_params, params); in tee_ioctl_supp_send()
857 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in tee_release_device() local
860 clear_bit(teedev->id, dev_mask); in tee_release_device()
862 mutex_destroy(&teedev->mutex); in tee_release_device()
863 idr_destroy(&teedev->idr); in tee_release_device()
864 kfree(teedev); in tee_release_device()
884 struct tee_device *teedev; in tee_device_alloc() local
894 teedev = kzalloc(sizeof(*teedev), GFP_KERNEL); in tee_device_alloc()
895 if (!teedev) { in tee_device_alloc()
908 teedev->id = find_next_zero_bit(dev_mask, max_id, offs); in tee_device_alloc()
909 if (teedev->id < max_id) in tee_device_alloc()
910 set_bit(teedev->id, dev_mask); in tee_device_alloc()
913 if (teedev->id >= max_id) { in tee_device_alloc()
918 snprintf(teedev->name, sizeof(teedev->name), "tee%s%d", in tee_device_alloc()
920 teedev->id - offs); in tee_device_alloc()
922 teedev->dev.class = tee_class; in tee_device_alloc()
923 teedev->dev.release = tee_release_device; in tee_device_alloc()
924 teedev->dev.parent = dev; in tee_device_alloc()
926 teedev->dev.devt = MKDEV(MAJOR(tee_devt), teedev->id); in tee_device_alloc()
928 rc = dev_set_name(&teedev->dev, "%s", teedev->name); in tee_device_alloc()
934 cdev_init(&teedev->cdev, &tee_fops); in tee_device_alloc()
935 teedev->cdev.owner = teedesc->owner; in tee_device_alloc()
937 dev_set_drvdata(&teedev->dev, driver_data); in tee_device_alloc()
938 device_initialize(&teedev->dev); in tee_device_alloc()
941 teedev->num_users = 1; in tee_device_alloc()
942 init_completion(&teedev->c_no_users); in tee_device_alloc()
943 mutex_init(&teedev->mutex); in tee_device_alloc()
944 idr_init(&teedev->idr); in tee_device_alloc()
946 teedev->desc = teedesc; in tee_device_alloc()
947 teedev->pool = pool; in tee_device_alloc()
949 return teedev; in tee_device_alloc()
951 unregister_chrdev_region(teedev->dev.devt, 1); in tee_device_alloc()
955 if (teedev && teedev->id < TEE_NUM_DEVICES) { in tee_device_alloc()
957 clear_bit(teedev->id, dev_mask); in tee_device_alloc()
960 kfree(teedev); in tee_device_alloc()
968 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in implementation_id_show() local
971 teedev->desc->ops->get_version(teedev, &vers); in implementation_id_show()
992 int tee_device_register(struct tee_device *teedev) in tee_device_register() argument
996 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { in tee_device_register()
997 dev_err(&teedev->dev, "attempt to register twice\n"); in tee_device_register()
1001 teedev->dev.groups = tee_dev_groups; in tee_device_register()
1003 rc = cdev_device_add(&teedev->cdev, &teedev->dev); in tee_device_register()
1005 dev_err(&teedev->dev, in tee_device_register()
1007 teedev->name, MAJOR(teedev->dev.devt), in tee_device_register()
1008 MINOR(teedev->dev.devt), rc); in tee_device_register()
1012 teedev->flags |= TEE_DEVICE_FLAG_REGISTERED; in tee_device_register()
1017 void tee_device_put(struct tee_device *teedev) in tee_device_put() argument
1019 mutex_lock(&teedev->mutex); in tee_device_put()
1021 if (!WARN_ON(!teedev->desc)) { in tee_device_put()
1022 teedev->num_users--; in tee_device_put()
1023 if (!teedev->num_users) { in tee_device_put()
1024 teedev->desc = NULL; in tee_device_put()
1025 complete(&teedev->c_no_users); in tee_device_put()
1028 mutex_unlock(&teedev->mutex); in tee_device_put()
1031 bool tee_device_get(struct tee_device *teedev) in tee_device_get() argument
1033 mutex_lock(&teedev->mutex); in tee_device_get()
1034 if (!teedev->desc) { in tee_device_get()
1035 mutex_unlock(&teedev->mutex); in tee_device_get()
1038 teedev->num_users++; in tee_device_get()
1039 mutex_unlock(&teedev->mutex); in tee_device_get()
1051 void tee_device_unregister(struct tee_device *teedev) in tee_device_unregister() argument
1053 if (!teedev) in tee_device_unregister()
1056 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) in tee_device_unregister()
1057 cdev_device_del(&teedev->cdev, &teedev->dev); in tee_device_unregister()
1059 tee_device_put(teedev); in tee_device_unregister()
1060 wait_for_completion(&teedev->c_no_users); in tee_device_unregister()
1067 teedev->pool = NULL; in tee_device_unregister()
1069 put_device(&teedev->dev); in tee_device_unregister()
1078 void *tee_get_drvdata(struct tee_device *teedev) in tee_get_drvdata() argument
1080 return dev_get_drvdata(&teedev->dev); in tee_get_drvdata()
1093 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in match_dev() local
1095 teedev->desc->ops->get_version(teedev, match_data->vers); in match_dev()
1112 dev = &start->teedev->dev; in tee_client_open_context()
1151 ctx->teedev->desc->ops->get_version(ctx->teedev, vers); in tee_client_get_version()
1159 if (!ctx->teedev->desc->ops->open_session) in tee_client_open_session()
1161 return ctx->teedev->desc->ops->open_session(ctx, arg, param); in tee_client_open_session()
1167 if (!ctx->teedev->desc->ops->close_session) in tee_client_close_session()
1169 return ctx->teedev->desc->ops->close_session(ctx, session); in tee_client_close_session()
1177 if (!ctx->teedev->desc->ops->invoke_func) in tee_client_invoke_func()
1179 return ctx->teedev->desc->ops->invoke_func(ctx, arg, param); in tee_client_invoke_func()
1186 if (!ctx->teedev->desc->ops->cancel_req) in tee_client_cancel_req()
1188 return ctx->teedev->desc->ops->cancel_req(ctx, arg->cancel_id, in tee_client_cancel_req()