diff options
author | Sumit Semwal <sumit.semwal@linaro.org> | 2015-01-23 02:23:43 -0500 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2015-04-21 05:17:16 -0400 |
commit | d8fbe341beb617ebb22b98fb893e4aa32ae2d864 (patch) | |
tree | 2e19c951d2b6ffef2319d87ec8a6c39e4e1ab8ee /include/linux/dma-buf.h | |
parent | 646da63172f660ba84f195c1165360a9b73583ee (diff) |
dma-buf: cleanup dma_buf_export() to make it easily extensible
At present, dma_buf_export() takes a series of parameters, which
makes it difficult to add any new parameters for exporters, if required.
Make it simpler by moving all these parameters into a struct, and pass
the struct * as parameter to dma_buf_export().
While at it, unite dma_buf_export_named() with dma_buf_export(), and
change all callers accordingly.
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Acked-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Diffstat (limited to 'include/linux/dma-buf.h')
-rw-r--r-- | include/linux/dma-buf.h | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 694e1fe1c4b4..2f0b431b73e0 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h | |||
@@ -163,6 +163,33 @@ struct dma_buf_attachment { | |||
163 | }; | 163 | }; |
164 | 164 | ||
165 | /** | 165 | /** |
166 | * struct dma_buf_export_info - holds information needed to export a dma_buf | ||
167 | * @exp_name: name of the exporting module - useful for debugging. | ||
168 | * @ops: Attach allocator-defined dma buf ops to the new buffer | ||
169 | * @size: Size of the buffer | ||
170 | * @flags: mode flags for the file | ||
171 | * @resv: reservation-object, NULL to allocate default one | ||
172 | * @priv: Attach private data of allocator to this buffer | ||
173 | * | ||
174 | * This structure holds the information required to export the buffer. Used | ||
175 | * with dma_buf_export() only. | ||
176 | */ | ||
177 | struct dma_buf_export_info { | ||
178 | const char *exp_name; | ||
179 | const struct dma_buf_ops *ops; | ||
180 | size_t size; | ||
181 | int flags; | ||
182 | struct reservation_object *resv; | ||
183 | void *priv; | ||
184 | }; | ||
185 | |||
186 | /** | ||
187 | * helper macro for exporters; zeros and fills in most common values | ||
188 | */ | ||
189 | #define DEFINE_DMA_BUF_EXPORT_INFO(a) \ | ||
190 | struct dma_buf_export_info a = { .exp_name = KBUILD_MODNAME } | ||
191 | |||
192 | /** | ||
166 | * get_dma_buf - convenience wrapper for get_file. | 193 | * get_dma_buf - convenience wrapper for get_file. |
167 | * @dmabuf: [in] pointer to dma_buf | 194 | * @dmabuf: [in] pointer to dma_buf |
168 | * | 195 | * |
@@ -181,12 +208,7 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, | |||
181 | void dma_buf_detach(struct dma_buf *dmabuf, | 208 | void dma_buf_detach(struct dma_buf *dmabuf, |
182 | struct dma_buf_attachment *dmabuf_attach); | 209 | struct dma_buf_attachment *dmabuf_attach); |
183 | 210 | ||
184 | struct dma_buf *dma_buf_export_named(void *priv, const struct dma_buf_ops *ops, | 211 | struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info); |
185 | size_t size, int flags, const char *, | ||
186 | struct reservation_object *); | ||
187 | |||
188 | #define dma_buf_export(priv, ops, size, flags, resv) \ | ||
189 | dma_buf_export_named(priv, ops, size, flags, KBUILD_MODNAME, resv) | ||
190 | 212 | ||
191 | int dma_buf_fd(struct dma_buf *dmabuf, int flags); | 213 | int dma_buf_fd(struct dma_buf *dmabuf, int flags); |
192 | struct dma_buf *dma_buf_get(int fd); | 214 | struct dma_buf *dma_buf_get(int fd); |