From e3763055fa85f6e815d1cd8c26cb4453bf0869a7 Mon Sep 17 00:00:00 2001 From: Krishna Reddy Date: Thu, 29 Dec 2011 11:18:44 -0800 Subject: gpu: ion: Add api to get client from file id. Change-Id: Ifb3bc3d7fa54cddda7e3f0acd34dbcc4b1ed39d3 Signed-off-by: Krishna Reddy Reviewed-on: http://git-master/r/72644 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Aleksandr Frid --- drivers/gpu/ion/ion.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/gpu') diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index b90c4a826260..b32b1427e3e3 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -1114,3 +1114,19 @@ void ion_device_destroy(struct ion_device *dev) /* XXX need to free the heaps and clients ? */ kfree(dev); } + +struct ion_client *ion_client_get_file(int fd) +{ + struct ion_client *client = ERR_PTR(-EFAULT); + struct file *f = fget(fd); + if (!f) + return ERR_PTR(-EINVAL); + + if (f->f_op == &ion_fops) { + client = f->private_data; + ion_client_get(client); + } + + fput(f); + return client; +} -- cgit v1.2.3