参照元

説明

引数

返り値

参考

実装

struct ion_handle *ion_alloc(struct ion_client *client, size_t len,
                             size_t align, unsigned int heap_id_mask,
                             unsigned int flags)
{
        struct ion_handle *handle;
        struct ion_device *dev = client->dev;
        struct ion_buffer *buffer = NULL;
        struct ion_heap *heap;
        int ret;
        pr_debug("%s: len %zu align %zu heap_id_mask %u flags %x\n", __func__,
                 len, align, heap_id_mask, flags);
        /*
         * traverse the list of heaps available in this system in priority
         * order.  If the heap type is supported by the client, and matches the
         * request of the caller allocate from it.  Repeat until allocate has
         * succeeded or all heaps have been tried
         */
        len = PAGE_ALIGN(len);

        if (!len)
                return ERR_PTR(-EINVAL);
        down_read(&dev->lock);
        plist_for_each_entry(heap, &dev->heaps, node) {
                /* if the caller didn't specify this heap id */
                if (!((1 << heap->id) & heap_id_mask))
                        continue;
                buffer = ion_buffer_create(heap, dev, len, align, flags);
                if (!IS_ERR(buffer))
                        break;
        }
        up_read(&dev->lock);
        if (buffer == NULL)
                return ERR_PTR(-ENODEV);

        if (IS_ERR(buffer))
                return ERR_CAST(buffer);
        handle = ion_handle_create(client, buffer);
        /*
         * ion_buffer_create will create a buffer with a ref_cnt of 1,
         * and ion_handle_create will take a second reference, drop one here
         */
        ion_buffer_put(buffer);
        if (IS_ERR(handle))
                return handle;

        mutex_lock(&client->lock);
        ret = ion_handle_add(client, handle);
        mutex_unlock(&client->lock);
        if (ret) {
                ion_handle_put(handle);
                handle = ERR_PTR(ret);
        }
        return handle;
}
EXPORT_SYMBOL(ion_alloc);

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-03-17 (木) 19:40:45