*参照元 [#a0a59825] #backlinks *説明 [#w6329a9e] -パス: [[linux-4.4.1/drivers/staging/android/ion/ion.c]] -FIXME: これは何? --説明 **引数 [#e28bb246] -struct ion_client *client -- --[[linux-4.4.1/ion_client]] -size_t len -- -size_t align -- -unsigned int heap_id_mask -- -unsigned int flags -- **返り値 [#q0977eb4] -struct ion_handle * -- --[[linux-4.4.1/ion_handle]] **参考 [#g69f313c] *実装 [#s391287f] 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; - --[[linux-4.4.1/ion_handle]] --[[linux-4.4.1/ion_device]] --[[linux-4.4.1/ion_buffer]] --[[linux-4.4.1/ion_heap]] pr_debug("%s: len %zu align %zu heap_id_mask %u flags %x\n", __func__, len, align, heap_id_mask, flags); - --[[linux-4.4.1/pr_debug()]] /* * 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); - --[[linux-4.4.1/PAGE_ALIGN()]] --[[linux-4.4.1/ERR_PTR()]] 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); - --[[linux-4.4.1/down_read()]] --[[linux-4.4.1/plist_for_each_entry()]] --[[linux-4.4.1/ion_buffer_create()]] --[[linux-4.4.1/IS_ERR()]] --[[linux-4.4.1/up_read()]] if (buffer == NULL) return ERR_PTR(-ENODEV); if (IS_ERR(buffer)) return ERR_CAST(buffer); - --[[linux-4.4.1/ERR_CAST()]] handle = ion_handle_create(client, buffer); - --[[linux-4.4.1/ion_handle_create()]] /* * 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); - --[[linux-4.4.1/ion_buffer_put()]] 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); } - --[[linux-4.4.1/mutex_lock()]] --[[linux-4.4.1/ion_handle_add()]] --[[linux-4.4.1/mutex_unlock()]] return handle; } EXPORT_SYMBOL(ion_alloc); - --[[linux-4.4.1/EXPORT_SYMBOL()]] *コメント [#v6cc55ab]