diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 3409ecace582..e1de0064d424 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -3,7 +3,7 @@ * drivers/staging/android/ion/ion.c * * Copyright (C) 2011 Google, Inc. - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -1897,10 +1897,11 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) } EXPORT_SYMBOL(ion_device_add_heap); -int ion_walk_heaps(struct ion_client *client, int heap_id, void *data, +int ion_walk_heaps(struct ion_client *client, int heap_id, + enum ion_heap_type type, void *data, int (*f)(struct ion_heap *heap, void *data)) { - int ret_val = -EINVAL; + int ret_val = 0; struct ion_heap *heap; struct ion_device *dev = client->dev; /* @@ -1909,7 +1910,8 @@ int ion_walk_heaps(struct ion_client *client, int heap_id, void *data, */ down_write(&dev->lock); plist_for_each_entry(heap, &dev->heaps, node) { - if (ION_HEAP(heap->id) != heap_id) + if (ION_HEAP(heap->id) != heap_id || + type != heap->type) continue; ret_val = f(heap, data); break; diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index d665ab9dcc08..bae53350f7df 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -488,7 +488,8 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, void ion_pages_sync_for_device(struct device *dev, struct page *page, size_t size, enum dma_data_direction dir); -int ion_walk_heaps(struct ion_client *client, int heap_id, void *data, +int ion_walk_heaps(struct ion_client *client, int heap_id, + enum ion_heap_type type, void *data, int (*f)(struct ion_heap *heap, void *data)); struct ion_handle *ion_handle_get_by_id(struct ion_client *client, diff --git a/drivers/staging/android/ion/msm/msm_ion.c b/drivers/staging/android/ion/msm/msm_ion.c index da43a7334949..952edb7c9163 100644 --- a/drivers/staging/android/ion/msm/msm_ion.c +++ b/drivers/staging/android/ion/msm/msm_ion.c @@ -725,16 +725,28 @@ long msm_ion_custom_ioctl(struct ion_client *client, } case ION_IOC_PREFETCH: { - ion_walk_heaps(client, data.prefetch_data.heap_id, + int ret; + + ret = ion_walk_heaps(client, data.prefetch_data.heap_id, + ION_HEAP_TYPE_SECURE_DMA, (void *)data.prefetch_data.len, ion_secure_cma_prefetch); + + if (ret) + return ret; break; } case ION_IOC_DRAIN: { - ion_walk_heaps(client, data.prefetch_data.heap_id, + int ret; + + ret = ion_walk_heaps(client, data.prefetch_data.heap_id, + ION_HEAP_TYPE_SECURE_DMA, (void *)data.prefetch_data.len, ion_secure_cma_drain_pool); + + if (ret) + return ret; break; }