Hello Marek Szyprowski Wrote: > Sent: Monday, December 06, 2010 7:53 PM > To: linux-media@xxxxxxxxxxxxxxx > Cc: m.szyprowski@xxxxxxxxxxx; pawel@xxxxxxxxxx; kyungmin.park@xxxxxxxxxxx; > andrzej.p@xxxxxxxxxxx > Subject: [PATCH 8/8] v4l: videobuf2: add CMA allocator <snip> > +struct vb2_cma_buf { > + struct vb2_cma_conf *conf; > + dma_addr_t paddr; > + unsigned long size; > + struct vm_area_struct *vma; > + atomic_t refcount; > + struct vb2_vmarea_handler handler; > +}; > + > +static void vb2_cma_put(void *buf_priv); > + > +static void *vb2_cma_alloc(void *alloc_ctx, unsigned long size) > +{ > + struct vb2_cma_conf *conf = alloc_ctx; I wonder that how to acquire vb2_cma_cont value without container_of() or explicit type conversion? Does not conversion from alloc_ctx type to vb2_cma_conf type when caller is called. > + struct vb2_cma_buf *buf; > + > + buf = kzalloc(sizeof *buf, GFP_KERNEL); > + if (!buf) > + return ERR_PTR(-ENOMEM); > + > + buf->paddr = cma_alloc(conf->dev, conf->type, size, conf- > >alignment); > + if (IS_ERR((void *)buf->paddr)) { > + printk(KERN_ERR "cma_alloc of size %ld failed\n", size); > + kfree(buf); > + return ERR_PTR(-ENOMEM); > + } > + > + buf->conf = conf; > + buf->size = size; > + > + buf->handler.refcount = &buf->refcount; > + buf->handler.put = vb2_cma_put; > + buf->handler.arg = buf; > + > + atomic_inc(&buf->refcount); > + > + return buf; > +} > + <snip> > +struct vb2_alloc_ctx *vb2_cma_init(struct device *dev, const char *type, > + unsigned long alignment); > +void vb2_cma_cleanup(struct vb2_alloc_ctx *alloc_ctx); > + > +struct vb2_alloc_ctx **vb2_cma_init_multi(struct device *dev, > + unsigned int num_planes, const char *types[], > + unsigned long alignments[]); > +void vb2_cma_cleanup_multi(struct vb2_alloc_ctx **alloc_ctxes); > + > +struct vb2_alloc_ctx *vb2_cma_init(struct device *dev, const char *type, > + unsigned long alignment); This function already exist. > +void vb2_cma_cleanup(struct vb2_alloc_ctx *alloc_ctx); Same > + > +extern const struct vb2_mem_ops vb2_cma_memops; > + > +#endif > -- > 1.7.1.569.g6f426 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html