Lines Matching refs:teedev

46 static 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()
87 ctx->teedev->desc->ops->release(ctx); in teedev_ctx_release()
101 tee_device_put(ctx->teedev); in teedev_close_context()
271 ctx->teedev->desc->ops->get_version(ctx->teedev, &vers); in tee_ioctl_version()
273 if (ctx->teedev->desc->flags & TEE_DESC_PRIVILEGED) in tee_ioctl_version()
475 if (!ctx->teedev->desc->ops->open_session) in tee_ioctl_open_session()
510 rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params); in tee_ioctl_open_session()
527 if (rc && have_session && ctx->teedev->desc->ops->close_session) in tee_ioctl_open_session()
528 ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_open_session()
553 if (!ctx->teedev->desc->ops->invoke_func) in tee_ioctl_invoke()
581 rc = ctx->teedev->desc->ops->invoke_func(ctx, &arg, params); in tee_ioctl_invoke()
608 if (!ctx->teedev->desc->ops->cancel_req) in tee_ioctl_cancel()
614 return ctx->teedev->desc->ops->cancel_req(ctx, arg.cancel_id, in tee_ioctl_cancel()
624 if (!ctx->teedev->desc->ops->close_session) in tee_ioctl_close_session()
630 return ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_close_session()
687 if (!ctx->teedev->desc->ops->supp_recv) in tee_ioctl_supp_recv()
712 rc = ctx->teedev->desc->ops->supp_recv(ctx, &func, &num_params, params); in tee_ioctl_supp_recv()
785 if (!ctx->teedev->desc->ops->supp_send) in tee_ioctl_supp_send()
811 rc = ctx->teedev->desc->ops->supp_send(ctx, ret, num_params, params); in tee_ioctl_supp_send()
856 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in tee_release_device() local
859 clear_bit(teedev->id, dev_mask); in tee_release_device()
861 mutex_destroy(&teedev->mutex); in tee_release_device()
862 idr_destroy(&teedev->idr); in tee_release_device()
863 kfree(teedev); in tee_release_device()
883 struct tee_device *teedev; in tee_device_alloc() local
893 teedev = kzalloc(sizeof(*teedev), GFP_KERNEL); in tee_device_alloc()
894 if (!teedev) { in tee_device_alloc()
907 teedev->id = find_next_zero_bit(dev_mask, max_id, offs); in tee_device_alloc()
908 if (teedev->id < max_id) in tee_device_alloc()
909 set_bit(teedev->id, dev_mask); in tee_device_alloc()
912 if (teedev->id >= max_id) { in tee_device_alloc()
917 snprintf(teedev->name, sizeof(teedev->name), "tee%s%d", in tee_device_alloc()
919 teedev->id - offs); in tee_device_alloc()
921 teedev->dev.class = tee_class; in tee_device_alloc()
922 teedev->dev.release = tee_release_device; in tee_device_alloc()
923 teedev->dev.parent = dev; in tee_device_alloc()
925 teedev->dev.devt = MKDEV(MAJOR(tee_devt), teedev->id); in tee_device_alloc()
927 rc = dev_set_name(&teedev->dev, "%s", teedev->name); in tee_device_alloc()
933 cdev_init(&teedev->cdev, &tee_fops); in tee_device_alloc()
934 teedev->cdev.owner = teedesc->owner; in tee_device_alloc()
936 dev_set_drvdata(&teedev->dev, driver_data); in tee_device_alloc()
937 device_initialize(&teedev->dev); in tee_device_alloc()
940 teedev->num_users = 1; in tee_device_alloc()
941 init_completion(&teedev->c_no_users); in tee_device_alloc()
942 mutex_init(&teedev->mutex); in tee_device_alloc()
943 idr_init(&teedev->idr); in tee_device_alloc()
945 teedev->desc = teedesc; in tee_device_alloc()
946 teedev->pool = pool; in tee_device_alloc()
948 return teedev; in tee_device_alloc()
950 unregister_chrdev_region(teedev->dev.devt, 1); in tee_device_alloc()
954 if (teedev && teedev->id < TEE_NUM_DEVICES) { in tee_device_alloc()
956 clear_bit(teedev->id, dev_mask); in tee_device_alloc()
959 kfree(teedev); in tee_device_alloc()
967 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in implementation_id_show() local
970 teedev->desc->ops->get_version(teedev, &vers); in implementation_id_show()
991 int tee_device_register(struct tee_device *teedev) in tee_device_register() argument
995 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { in tee_device_register()
996 dev_err(&teedev->dev, "attempt to register twice\n"); in tee_device_register()
1000 teedev->dev.groups = tee_dev_groups; in tee_device_register()
1002 rc = cdev_device_add(&teedev->cdev, &teedev->dev); in tee_device_register()
1004 dev_err(&teedev->dev, in tee_device_register()
1006 teedev->name, MAJOR(teedev->dev.devt), in tee_device_register()
1007 MINOR(teedev->dev.devt), rc); in tee_device_register()
1011 teedev->flags |= TEE_DEVICE_FLAG_REGISTERED; in tee_device_register()
1016 void tee_device_put(struct tee_device *teedev) in tee_device_put() argument
1018 mutex_lock(&teedev->mutex); in tee_device_put()
1020 if (!WARN_ON(!teedev->desc)) { in tee_device_put()
1021 teedev->num_users--; in tee_device_put()
1022 if (!teedev->num_users) { in tee_device_put()
1023 teedev->desc = NULL; in tee_device_put()
1024 complete(&teedev->c_no_users); in tee_device_put()
1027 mutex_unlock(&teedev->mutex); in tee_device_put()
1030 bool tee_device_get(struct tee_device *teedev) in tee_device_get() argument
1032 mutex_lock(&teedev->mutex); in tee_device_get()
1033 if (!teedev->desc) { in tee_device_get()
1034 mutex_unlock(&teedev->mutex); in tee_device_get()
1037 teedev->num_users++; in tee_device_get()
1038 mutex_unlock(&teedev->mutex); in tee_device_get()
1050 void tee_device_unregister(struct tee_device *teedev) in tee_device_unregister() argument
1052 if (!teedev) in tee_device_unregister()
1055 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) in tee_device_unregister()
1056 cdev_device_del(&teedev->cdev, &teedev->dev); in tee_device_unregister()
1058 tee_device_put(teedev); in tee_device_unregister()
1059 wait_for_completion(&teedev->c_no_users); in tee_device_unregister()
1066 teedev->pool = NULL; in tee_device_unregister()
1068 put_device(&teedev->dev); in tee_device_unregister()
1077 void *tee_get_drvdata(struct tee_device *teedev) in tee_get_drvdata() argument
1079 return dev_get_drvdata(&teedev->dev); in tee_get_drvdata()
1092 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in match_dev() local
1094 teedev->desc->ops->get_version(teedev, match_data->vers); in match_dev()
1111 dev = &start->teedev->dev; in tee_client_open_context()
1150 ctx->teedev->desc->ops->get_version(ctx->teedev, vers); in tee_client_get_version()
1158 if (!ctx->teedev->desc->ops->open_session) in tee_client_open_session()
1160 return ctx->teedev->desc->ops->open_session(ctx, arg, param); in tee_client_open_session()
1166 if (!ctx->teedev->desc->ops->close_session) in tee_client_close_session()
1168 return ctx->teedev->desc->ops->close_session(ctx, session); in tee_client_close_session()
1176 if (!ctx->teedev->desc->ops->invoke_func) in tee_client_invoke_func()
1178 return ctx->teedev->desc->ops->invoke_func(ctx, arg, param); in tee_client_invoke_func()
1185 if (!ctx->teedev->desc->ops->cancel_req) in tee_client_cancel_req()
1187 return ctx->teedev->desc->ops->cancel_req(ctx, arg->cancel_id, in tee_client_cancel_req()