Merge "msm: ion: Export msm_ion_do_cache_offset_op to do cache operations"

This commit is contained in:
Linux Build Service Account 2016-12-19 00:45:00 -08:00 committed by Gerrit - the friendly Code Review server
commit b5a61cbc34
2 changed files with 48 additions and 3 deletions

View file

@ -157,6 +157,15 @@ int msm_ion_do_cache_op(struct ion_client *client, struct ion_handle *handle,
}
EXPORT_SYMBOL(msm_ion_do_cache_op);
int msm_ion_do_cache_offset_op(
struct ion_client *client, struct ion_handle *handle,
void *vaddr, unsigned int offset, unsigned long len,
unsigned int cmd)
{
return ion_do_cache_op(client, handle, vaddr, offset, len, cmd);
}
EXPORT_SYMBOL(msm_ion_do_cache_offset_op);
static int ion_no_pages_cache_ops(struct ion_client *client,
struct ion_handle *handle,
void *vaddr,
@ -305,13 +314,23 @@ static int ion_pages_cache_ops(struct ion_client *client,
};
for_each_sg(table->sgl, sg, table->nents, i) {
unsigned int sg_offset, sg_left, size = 0;
len += sg->length;
if (len < offset)
if (len <= offset)
continue;
__do_cache_ops(sg_page(sg), sg->offset, sg->length, op);
sg_left = len - offset;
sg_offset = sg->length - sg_left;
if (len > length + offset)
size = (length < sg_left) ? length : sg_left;
__do_cache_ops(sg_page(sg), sg_offset, size, op);
offset += size;
length -= size;
if (length == 0)
break;
}
return 0;

View file

@ -1,3 +1,16 @@
/*
* Copyright (c) 2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _MSM_MSM_ION_H
#define _MSM_MSM_ION_H
@ -157,6 +170,11 @@ int ion_handle_get_size(struct ion_client *client, struct ion_handle *handle,
int msm_ion_do_cache_op(struct ion_client *client, struct ion_handle *handle,
void *vaddr, unsigned long len, unsigned int cmd);
int msm_ion_do_cache_offset_op(
struct ion_client *client, struct ion_handle *handle,
void *vaddr, unsigned int offset, unsigned long len,
unsigned int cmd);
#else
static inline struct ion_client *msm_ion_client_create(const char *name)
{
@ -176,6 +194,14 @@ static inline int msm_ion_do_cache_op(struct ion_client *client,
return -ENODEV;
}
int msm_ion_do_cache_offset_op(
struct ion_client *client, struct ion_handle *handle,
void *vaddr, unsigned int offset, unsigned long len,
unsigned int cmd)
{
return -ENODEV;
}
#endif /* CONFIG_ION */
#endif