*参照元 [#vfb51f8f] #backlinks *説明 [#m4629387] -パス: [[linux-4.4.1/drivers/media/v4l2-core/videobuf2-dma-contig.c]] -FIXME: これは何? --説明 **引数 [#x55a4f58] -void *alloc_ctx -- -unsigned long size -- -enum dma_data_direction dma_dir -- --[[linux-4.4.1/dma_data_direction]] -gfp_t gfp_flags -- --[[linux-4.4.1/gfp_t]] **返り値 [#g674173c] -void * -- **参考 [#l46cf1f2] *実装 [#y927cc46] static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size, enum dma_data_direction dma_dir, gfp_t gfp_flags) { struct vb2_dc_conf *conf = alloc_ctx; struct device *dev = conf->dev; struct vb2_dc_buf *buf; - --[[linux-4.4.1/vb2_dc_conf]] --[[linux-4.4.1/device]] --[[linux-4.4.1/vb2_dc_conf]] --[[linux-4.4.1/vb2_dc_buf]] buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); - --[[linux-4.4.1/kzalloc()]] --[[linux-4.4.1/ERR_PTR()]] buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL | gfp_flags); if (!buf->vaddr) { dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); kfree(buf); return ERR_PTR(-ENOMEM); } - --[[linux-4.4.1/dma_alloc_coherent()]] --[[linux-4.4.1/dev_err()]] /* Prevent the device from being released while the buffer is used */ buf->dev = get_device(dev); buf->size = size; buf->dma_dir = dma_dir; buf->handler.refcount = &buf->refcount; buf->handler.put = vb2_dc_put; buf->handler.arg = buf; - --[[linux-4.4.1/get_device()]] --[[linux-4.4.1/vb2_dc_put()]] atomic_inc(&buf->refcount); - --[[linux-4.4.1/atomic_inc()]] return buf; } *コメント [#o7d910ff]