[PATCH 1/2] staging: andriod: ion: Add ion_phys_get_by_id function
From: Feng Tang
Date: Sun Jan 04 2015 - 02:16:04 EST
There is user case that user only knows the ion_handle idand
needs to get the physical addr and len. So add this wrapper to
meet this requirement.
Signed-off-by: Feng Tang <feng.tang@xxxxxxxxx>
---
drivers/staging/android/ion/ion.c | 16 ++++++++++++++++
drivers/staging/android/ion/ion.h | 14 ++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index 296d347..3d378ef 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -577,6 +577,22 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle,
}
EXPORT_SYMBOL(ion_phys);
+int ion_phys_get_by_id(struct ion_client *client, int id,
+ ion_phys_addr_t *addr, size_t *len)
+{
+ struct ion_handle *handle;
+ int ret;
+
+ handle = ion_handle_get_by_id(client, id);
+ if (!handle)
+ return -EINVAL;
+
+ ret = ion_phys(client, handle, addr, len);
+ ion_handle_put(handle);
+ return ret;
+}
+EXPORT_SYMBOL(ion_phys_get_by_id);
+
static void *ion_buffer_kmap_get(struct ion_buffer *buffer)
{
void *vaddr;
diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h
index 443db84..9ef0f18 100644
--- a/drivers/staging/android/ion/ion.h
+++ b/drivers/staging/android/ion/ion.h
@@ -147,6 +147,20 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle,
ion_phys_addr_t *addr, size_t *len);
/**
+ * ion_phys_get_by_id - returns the physical address and len of a handle
+ * @client: the client
+ * @id: id bound to ion_handle, which may be passed to user space
+ * @addr: a pointer to put the address in
+ * @len: a pointer to put the length in
+ *
+ * This function will first get ion_handle from the id, and then
+ * use upper ion_phys() to get the physical and len.
+ */
+
+int ion_phys_get_by_id(struct ion_client *client, int id,
+ ion_phys_addr_t *addr, size_t *len);
+
+/**
* ion_map_dma - return an sg_table describing a handle
* @client: the client
* @handle: the handle
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/