Renames struct tee_filp to struct tee_context.
Note that this is an incompatible API change in tee_drv.h which causes a compile error in OP-TEE. This is fixed in next OP-TEE patch.
Signed-off-by: Jens Wiklander jens.wiklander@linaro.org --- drivers/sec-hw/tee.c | 56 +++++++++++++++++++++--------------------- drivers/sec-hw/tee_private.h | 6 ++--- drivers/sec-hw/tee_shm.c | 22 ++++++++--------- include/linux/sec-hw/tee_drv.h | 20 +++++++-------- 4 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/drivers/sec-hw/tee.c b/drivers/sec-hw/tee.c index afd2925..ce54be2 100644 --- a/drivers/sec-hw/tee.c +++ b/drivers/sec-hw/tee.c @@ -23,46 +23,46 @@ static int tee_open(struct inode *inode, struct file *filp) { int ret; struct tee_device *teedev; - struct tee_filp *teefilp; + struct tee_context *ctx;
teedev = container_of(filp->private_data, struct tee_device, miscdev); - teefilp = kzalloc(sizeof(*teefilp), GFP_KERNEL); - if (!teefilp) + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) return -ENOMEM;
- teefilp->teedev = teedev; - filp->private_data = teefilp; - ret = teedev->desc->ops->open(teefilp); + ctx->teedev = teedev; + filp->private_data = ctx; + ret = teedev->desc->ops->open(ctx); if (ret) - kfree(teefilp); + kfree(ctx); return ret; }
static int tee_release(struct inode *inode, struct file *filp) { - struct tee_filp *teefilp = filp->private_data; + struct tee_context *ctx = filp->private_data;
- /* Free all shm:s related to this teefilp */ - tee_shm_free_by_teefilp(teefilp); + /* Free all shm:s related to this ctx */ + tee_shm_free_by_tee_context(ctx);
- teefilp->teedev->desc->ops->release(teefilp); + ctx->teedev->desc->ops->release(ctx); return 0; }
-static long tee_ioctl_version(struct tee_filp *teefilp, +static long tee_ioctl_version(struct tee_context *ctx, struct tee_ioctl_version __user *uvers) { struct tee_ioctl_version vers;
memset(&vers, 0, sizeof(vers)); vers.gen_version = TEE_SUBSYS_VERSION; - teefilp->teedev->desc->ops->get_version(teefilp, &vers.spec_version, - vers.uuid); + ctx->teedev->desc->ops->get_version(ctx, &vers.spec_version, + vers.uuid);
return copy_to_user(uvers, &vers, sizeof(vers)); }
-static long tee_ioctl_cmd(struct tee_filp *teefilp, +static long tee_ioctl_cmd(struct tee_context *ctx, struct tee_ioctl_cmd_data __user *ucmd) { long ret; @@ -74,10 +74,10 @@ static long tee_ioctl_cmd(struct tee_filp *teefilp, return ret;
buf_ptr = (void __user *)(uintptr_t)cmd.buf_ptr; - return teefilp->teedev->desc->ops->cmd(teefilp, buf_ptr, cmd.buf_len); + return ctx->teedev->desc->ops->cmd(ctx, buf_ptr, cmd.buf_len); }
-static long tee_ioctl_shm_alloc(struct tee_filp *teefilp, +static long tee_ioctl_shm_alloc(struct tee_context *ctx, struct tee_ioctl_shm_alloc_data __user *udata) { long ret; @@ -93,12 +93,12 @@ static long tee_ioctl_shm_alloc(struct tee_filp *teefilp,
data.fd = -1;
- shm = tee_shm_alloc(teefilp->teedev, teefilp, data.size, + shm = tee_shm_alloc(ctx->teedev, ctx, data.size, TEE_SHM_MAPPED | TEE_SHM_DMA_BUF); if (IS_ERR(shm)) return PTR_ERR(shm);
- ret = teefilp->teedev->desc->ops->shm_share(shm); + ret = ctx->teedev->desc->ops->shm_share(shm); if (ret) goto err;
@@ -127,14 +127,14 @@ err: return ret; }
-static long tee_ioctl_mem_share(struct tee_filp *teefilp, +static long tee_ioctl_mem_share(struct tee_context *ctx, struct tee_ioctl_mem_share_data __user *udata) { /* Not supported yet */ return -ENOENT; }
-static long tee_ioctl_mem_unshare(struct tee_filp *teefilp, +static long tee_ioctl_mem_unshare(struct tee_context *ctx, struct tee_ioctl_mem_share_data __user *udata) { /* Not supported yet */ @@ -143,20 +143,20 @@ static long tee_ioctl_mem_unshare(struct tee_filp *teefilp,
static long tee_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { - struct tee_filp *teefilp = filp->private_data; + struct tee_context *ctx = filp->private_data; void __user *uarg = (void __user *)arg;
switch (cmd) { case TEE_IOC_VERSION: - return tee_ioctl_version(teefilp, uarg); + return tee_ioctl_version(ctx, uarg); case TEE_IOC_CMD: - return tee_ioctl_cmd(teefilp, uarg); + return tee_ioctl_cmd(ctx, uarg); case TEE_IOC_SHM_ALLOC: - return tee_ioctl_shm_alloc(teefilp, uarg); + return tee_ioctl_shm_alloc(ctx, uarg); case TEE_IOC_MEM_SHARE: - return tee_ioctl_mem_share(teefilp, uarg); + return tee_ioctl_mem_share(ctx, uarg); case TEE_IOC_MEM_UNSHARE: - return tee_ioctl_mem_unshare(teefilp, uarg); + return tee_ioctl_mem_unshare(ctx, uarg); default: return -EINVAL; } @@ -211,7 +211,7 @@ struct tee_device *tee_register(const struct tee_desc *teedesc, }
INIT_LIST_HEAD(&teedev->list_shm); - teedev->teefilp_private.teedev = teedev; + teedev->teectx_private.teedev = teedev;
dev_set_drvdata(teedev->miscdev.this_device, teedev);
diff --git a/drivers/sec-hw/tee_private.h b/drivers/sec-hw/tee_private.h index 06a59ab..291ec52 100644 --- a/drivers/sec-hw/tee_private.h +++ b/drivers/sec-hw/tee_private.h @@ -17,7 +17,7 @@ struct tee_device;
struct tee_shm { struct list_head list_node; - struct tee_filp *teefilp; + struct tee_context *teectx; phys_addr_t paddr; void *kaddr; size_t size; @@ -54,11 +54,11 @@ struct tee_device { void *driver_data;
struct list_head list_shm; - struct tee_filp teefilp_private; + struct tee_context teectx_private; struct tee_shm_pool *pool; };
-void tee_shm_free_by_teefilp(struct tee_filp *teefilp); +void tee_shm_free_by_tee_context(struct tee_context *ctx);
int tee_shm_init(void);
diff --git a/drivers/sec-hw/tee_shm.c b/drivers/sec-hw/tee_shm.c index 7e8a082..b8127c0 100644 --- a/drivers/sec-hw/tee_shm.c +++ b/drivers/sec-hw/tee_shm.c @@ -75,7 +75,7 @@ static struct dma_buf_ops tee_shm_dma_buf_ops = { };
struct tee_shm *tee_shm_alloc(struct tee_device *teedev, - struct tee_filp *teefilp, size_t size, u32 flags) + struct tee_context *ctx, size_t size, u32 flags) { struct tee_shm_pool_mgr *poolm = NULL; struct tee_shm *shm; @@ -99,20 +99,20 @@ struct tee_shm *tee_shm_alloc(struct tee_device *teedev, shm->flags = flags;
if (flags & TEE_SHM_DMA_BUF) { - /* dma_buf shm:s must have a teefilp attached */ - if (!teefilp) { + /* dma_buf shm:s must have a context attached */ + if (!ctx) { ret = ERR_PTR(-EINVAL); goto err; } - shm->teefilp = teefilp; + shm->teectx = ctx; poolm = &teedev->pool->dma_buf_mgr; } else { - /* Driver private shm:s must not have a teefilp attached */ - if (teefilp) { + /* Driver private shm:s must not have a context attached */ + if (ctx) { ret = ERR_PTR(-EINVAL); goto err; } - shm->teefilp = &teedev->teefilp_private; + shm->teectx = &teedev->teectx_private; poolm = &teedev->pool->private_mgr; }
@@ -177,7 +177,7 @@ EXPORT_SYMBOL_GPL(tee_shm_put_fd);
static void tee_shm_release(struct tee_shm *shm) { - struct tee_device *teedev = shm->teefilp->teedev; + struct tee_device *teedev = shm->teectx->teedev; struct tee_shm_pool_mgr *poolm;
mutex_lock(&teeshm_mutex); @@ -193,9 +193,9 @@ static void tee_shm_release(struct tee_shm *shm) kfree(shm); }
-void tee_shm_free_by_teefilp(struct tee_filp *teefilp) +void tee_shm_free_by_tee_context(struct tee_context *ctx) { - struct tee_device *teedev = teefilp->teedev; + struct tee_device *teedev = ctx->teedev; struct tee_shm *shm; struct tee_shm *tmp; LIST_HEAD(tmp_list); @@ -205,7 +205,7 @@ void tee_shm_free_by_teefilp(struct tee_filp *teefilp) */ mutex_lock(&teeshm_mutex); list_for_each_entry_safe(shm, tmp, &teedev->list_shm, list_node) { - if (shm->teefilp == teefilp) { + if (shm->teectx == ctx) { list_del(&shm->list_node); list_add_tail(&shm->list_node, &tmp_list); } diff --git a/include/linux/sec-hw/tee_drv.h b/include/linux/sec-hw/tee_drv.h index f9dd9d6..c47b06b 100644 --- a/include/linux/sec-hw/tee_drv.h +++ b/include/linux/sec-hw/tee_drv.h @@ -35,13 +35,13 @@ struct tee_shm; struct tee_shm_pool;
/** - * struct tee_filp - driver specific file pointer data + * struct tee_context - driver specific context on file pointer data * @teedev: pointer to this drivers struct tee_device - * @filp_data: driver specific file pointer data, managed by the driver + * @data: driver specific context data, managed by the driver */ -struct tee_filp { +struct tee_context { struct tee_device *teedev; - void *filp_data; + void *data; };
/** @@ -54,10 +54,10 @@ struct tee_filp { * @shm_unshare: unshare some memory with Secure OS */ struct tee_driver_ops { - void (*get_version)(struct tee_filp *teefilp, u32 *version, u8 *uuid); - int (*open)(struct tee_filp *teefilp); - void (*release)(struct tee_filp *teefilp); - int (*cmd)(struct tee_filp *teefilp, void __user *buf, size_t len); + void (*get_version)(struct tee_context *ctx, u32 *version, u8 *uuid); + int (*open)(struct tee_context *ctx); + void (*release)(struct tee_context *ctx); + int (*cmd)(struct tee_context *ctx, void __user *buf, size_t len); int (*shm_share)(struct tee_shm *shm); void (*shm_unshare)(struct tee_shm *shm); }; @@ -150,7 +150,7 @@ void *tee_get_drvdata(struct tee_device *teedev); /** * tee_shm_alloc() - Allocate shared memory * @teedev: Driver that allocates the shared memory - * @teefilp: TEE file pointer when allocating global shared memory, must be + * @ctx: TEE file pointer when allocating global shared memory, must be * NULL for driver private shared memory. * @size: Requested size of shared memory * @flags: Flags setting properties for the requested shared memory. @@ -164,7 +164,7 @@ void *tee_get_drvdata(struct tee_device *teedev); * @returns a pointer to 'struct tee_shm' */ struct tee_shm *tee_shm_alloc(struct tee_device *teedev, - struct tee_filp *teefilp, size_t size, u32 flags); + struct tee_context *ctx, size_t size, u32 flags);
/** * tee_shm_free() - Free shared memory