Lines Matching refs:teedev

31 static struct tee_context *teedev_open(struct tee_device *teedev)  in teedev_open()  argument
36 if (!tee_device_get(teedev)) in teedev_open()
46 ctx->teedev = teedev; in teedev_open()
48 rc = teedev->desc->ops->open(ctx); in teedev_open()
55 tee_device_put(teedev); in teedev_open()
73 ctx->teedev->desc->ops->release(ctx); in teedev_ctx_release()
87 tee_device_put(ctx->teedev); in teedev_close_context()
119 ctx->teedev->desc->ops->get_version(ctx->teedev, &vers); in tee_ioctl_version()
121 if (ctx->teedev->desc->flags & TEE_DESC_PRIVILEGED) in tee_ioctl_version()
309 if (!ctx->teedev->desc->ops->open_session) in tee_ioctl_open_session()
337 rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params); in tee_ioctl_open_session()
354 if (rc && have_session && ctx->teedev->desc->ops->close_session) in tee_ioctl_open_session()
355 ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_open_session()
380 if (!ctx->teedev->desc->ops->invoke_func) in tee_ioctl_invoke()
408 rc = ctx->teedev->desc->ops->invoke_func(ctx, &arg, params); in tee_ioctl_invoke()
435 if (!ctx->teedev->desc->ops->cancel_req) in tee_ioctl_cancel()
441 return ctx->teedev->desc->ops->cancel_req(ctx, arg.cancel_id, in tee_ioctl_cancel()
451 if (!ctx->teedev->desc->ops->close_session) in tee_ioctl_close_session()
457 return ctx->teedev->desc->ops->close_session(ctx, arg.session); in tee_ioctl_close_session()
514 if (!ctx->teedev->desc->ops->supp_recv) in tee_ioctl_supp_recv()
539 rc = ctx->teedev->desc->ops->supp_recv(ctx, &func, &num_params, params); in tee_ioctl_supp_recv()
612 if (!ctx->teedev->desc->ops->supp_send) in tee_ioctl_supp_send()
638 rc = ctx->teedev->desc->ops->supp_send(ctx, ret, num_params, params); in tee_ioctl_supp_send()
683 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in tee_release_device() local
686 clear_bit(teedev->id, dev_mask); in tee_release_device()
688 mutex_destroy(&teedev->mutex); in tee_release_device()
689 idr_destroy(&teedev->idr); in tee_release_device()
690 kfree(teedev); in tee_release_device()
710 struct tee_device *teedev; in tee_device_alloc() local
720 teedev = kzalloc(sizeof(*teedev), GFP_KERNEL); in tee_device_alloc()
721 if (!teedev) { in tee_device_alloc()
734 teedev->id = find_next_zero_bit(dev_mask, max_id, offs); in tee_device_alloc()
735 if (teedev->id < max_id) in tee_device_alloc()
736 set_bit(teedev->id, dev_mask); in tee_device_alloc()
739 if (teedev->id >= max_id) { in tee_device_alloc()
744 snprintf(teedev->name, sizeof(teedev->name), "tee%s%d", in tee_device_alloc()
746 teedev->id - offs); in tee_device_alloc()
748 teedev->dev.class = tee_class; in tee_device_alloc()
749 teedev->dev.release = tee_release_device; in tee_device_alloc()
750 teedev->dev.parent = dev; in tee_device_alloc()
752 teedev->dev.devt = MKDEV(MAJOR(tee_devt), teedev->id); in tee_device_alloc()
754 rc = dev_set_name(&teedev->dev, "%s", teedev->name); in tee_device_alloc()
760 cdev_init(&teedev->cdev, &tee_fops); in tee_device_alloc()
761 teedev->cdev.owner = teedesc->owner; in tee_device_alloc()
762 teedev->cdev.kobj.parent = &teedev->dev.kobj; in tee_device_alloc()
764 dev_set_drvdata(&teedev->dev, driver_data); in tee_device_alloc()
765 device_initialize(&teedev->dev); in tee_device_alloc()
768 teedev->num_users = 1; in tee_device_alloc()
769 init_completion(&teedev->c_no_users); in tee_device_alloc()
770 mutex_init(&teedev->mutex); in tee_device_alloc()
771 idr_init(&teedev->idr); in tee_device_alloc()
773 teedev->desc = teedesc; in tee_device_alloc()
774 teedev->pool = pool; in tee_device_alloc()
776 return teedev; in tee_device_alloc()
778 unregister_chrdev_region(teedev->dev.devt, 1); in tee_device_alloc()
782 if (teedev && teedev->id < TEE_NUM_DEVICES) { in tee_device_alloc()
784 clear_bit(teedev->id, dev_mask); in tee_device_alloc()
787 kfree(teedev); in tee_device_alloc()
795 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in implementation_id_show() local
798 teedev->desc->ops->get_version(teedev, &vers); in implementation_id_show()
821 int tee_device_register(struct tee_device *teedev) in tee_device_register() argument
825 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { in tee_device_register()
826 dev_err(&teedev->dev, "attempt to register twice\n"); in tee_device_register()
830 rc = cdev_add(&teedev->cdev, teedev->dev.devt, 1); in tee_device_register()
832 dev_err(&teedev->dev, in tee_device_register()
834 teedev->name, MAJOR(teedev->dev.devt), in tee_device_register()
835 MINOR(teedev->dev.devt), rc); in tee_device_register()
839 rc = device_add(&teedev->dev); in tee_device_register()
841 dev_err(&teedev->dev, in tee_device_register()
843 teedev->name, MAJOR(teedev->dev.devt), in tee_device_register()
844 MINOR(teedev->dev.devt), rc); in tee_device_register()
848 rc = sysfs_create_group(&teedev->dev.kobj, &tee_dev_group); in tee_device_register()
850 dev_err(&teedev->dev, in tee_device_register()
855 teedev->flags |= TEE_DEVICE_FLAG_REGISTERED; in tee_device_register()
859 device_del(&teedev->dev); in tee_device_register()
861 cdev_del(&teedev->cdev); in tee_device_register()
866 void tee_device_put(struct tee_device *teedev) in tee_device_put() argument
868 mutex_lock(&teedev->mutex); in tee_device_put()
870 if (!WARN_ON(!teedev->desc)) { in tee_device_put()
871 teedev->num_users--; in tee_device_put()
872 if (!teedev->num_users) { in tee_device_put()
873 teedev->desc = NULL; in tee_device_put()
874 complete(&teedev->c_no_users); in tee_device_put()
877 mutex_unlock(&teedev->mutex); in tee_device_put()
880 bool tee_device_get(struct tee_device *teedev) in tee_device_get() argument
882 mutex_lock(&teedev->mutex); in tee_device_get()
883 if (!teedev->desc) { in tee_device_get()
884 mutex_unlock(&teedev->mutex); in tee_device_get()
887 teedev->num_users++; in tee_device_get()
888 mutex_unlock(&teedev->mutex); in tee_device_get()
900 void tee_device_unregister(struct tee_device *teedev) in tee_device_unregister() argument
902 if (!teedev) in tee_device_unregister()
905 if (teedev->flags & TEE_DEVICE_FLAG_REGISTERED) { in tee_device_unregister()
906 sysfs_remove_group(&teedev->dev.kobj, &tee_dev_group); in tee_device_unregister()
907 cdev_del(&teedev->cdev); in tee_device_unregister()
908 device_del(&teedev->dev); in tee_device_unregister()
911 tee_device_put(teedev); in tee_device_unregister()
912 wait_for_completion(&teedev->c_no_users); in tee_device_unregister()
919 teedev->pool = NULL; in tee_device_unregister()
921 put_device(&teedev->dev); in tee_device_unregister()
930 void *tee_get_drvdata(struct tee_device *teedev) in tee_get_drvdata() argument
932 return dev_get_drvdata(&teedev->dev); in tee_get_drvdata()
945 struct tee_device *teedev = container_of(dev, struct tee_device, dev); in match_dev() local
947 teedev->desc->ops->get_version(teedev, match_data->vers); in match_dev()
964 dev = &start->teedev->dev; in tee_client_open_context()
1003 ctx->teedev->desc->ops->get_version(ctx->teedev, vers); in tee_client_get_version()
1011 if (!ctx->teedev->desc->ops->open_session) in tee_client_open_session()
1013 return ctx->teedev->desc->ops->open_session(ctx, arg, param); in tee_client_open_session()
1019 if (!ctx->teedev->desc->ops->close_session) in tee_client_close_session()
1021 return ctx->teedev->desc->ops->close_session(ctx, session); in tee_client_close_session()
1029 if (!ctx->teedev->desc->ops->invoke_func) in tee_client_invoke_func()
1031 return ctx->teedev->desc->ops->invoke_func(ctx, arg, param); in tee_client_invoke_func()
1038 if (!ctx->teedev->desc->ops->cancel_req) in tee_client_cancel_req()
1040 return ctx->teedev->desc->ops->cancel_req(ctx, arg->cancel_id, in tee_client_cancel_req()