ANDROID: dma-buf: add dma_buf_get_each function
Add and export dma_buf_get_each function which helps in traversing the db_list, this will be used by the minidump module to get dmabuf info. Bug: 267250898 Change-Id: Ie24788fcf9cf0a49316cb871dcb9191e8084ccde Signed-off-by: Vijayanand Jitta <vjitta@codeaurora.org> (cherry picked from commit 602e4e28d89ca9c8295a904b16f4f3caeda80b7e) [Yunfei: Change namespace get_each_dmabuf to dma_buf_get_each] Signed-off-by: Yunfei Wang <yf.wang@mediatek.com> Signed-off-by: Jaskaran Singh <quic_jasksing@quicinc.com>
This commit is contained in:
parent
0522dbb348
commit
358f859c30
@ -43,6 +43,39 @@ struct dma_buf_list {
|
||||
|
||||
static struct dma_buf_list db_list;
|
||||
|
||||
/**
|
||||
* dma_buf_get_each - Helps in traversing the db_list and calls the
|
||||
* callback function which can extract required info out of each
|
||||
* dmabuf.
|
||||
* The db_list needs to be locked to prevent the db_list from being
|
||||
* dynamically updated during the traversal process.
|
||||
*
|
||||
* @callback: [in] Handle for each dmabuf buffer in db_list.
|
||||
* @private: [in] User-defined, used to pass in when callback is
|
||||
* called.
|
||||
*
|
||||
* Returns 0 on success, otherwise returns a non-zero value for
|
||||
* mutex_lock_interruptible or callback.
|
||||
*/
|
||||
int dma_buf_get_each(int (*callback)(const struct dma_buf *dmabuf,
|
||||
void *private), void *private)
|
||||
{
|
||||
struct dma_buf *buf;
|
||||
int ret = mutex_lock_interruptible(&db_list.lock);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
list_for_each_entry(buf, &db_list.head, list_node) {
|
||||
ret = callback(buf, private);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
mutex_unlock(&db_list.lock);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_NS_GPL(dma_buf_get_each, MINIDUMP);
|
||||
|
||||
static char *dmabuffs_dname(struct dentry *dentry, char *buffer, int buflen)
|
||||
{
|
||||
struct dma_buf *dmabuf;
|
||||
|
@ -675,6 +675,8 @@ dma_buf_attachment_is_dynamic(struct dma_buf_attachment *attach)
|
||||
return !!attach->importer_ops;
|
||||
}
|
||||
|
||||
int dma_buf_get_each(int (*callback)(const struct dma_buf *dmabuf,
|
||||
void *private), void *private);
|
||||
struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf,
|
||||
struct device *dev);
|
||||
struct dma_buf_attachment *
|
||||
|
Loading…
Reference in New Issue
Block a user