[media] media/pci/tw686x: convert driver to use the new vb2_queue dev field
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 1 Jul 2016 09:50:17 +0000 (06:50 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 8 Jul 2016 17:37:50 +0000 (14:37 -0300)
Stop using alloc_ctx and just fill in the device pointer.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/tw686x/tw686x-video.c
drivers/media/pci/tw686x/tw686x.h

index 0e839f617e039a979a7942802351c1000c29b5df..d380a8d8e462362520478ebca01ddb2aff03fe2d 100644 (file)
@@ -177,24 +177,7 @@ static void tw686x_contig_buf_refill(struct tw686x_video_channel *vc,
        vc->curr_bufs[pb] = NULL;
 }
 
-static void tw686x_contig_cleanup(struct tw686x_dev *dev)
-{
-       vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
-}
-
-static int tw686x_contig_setup(struct tw686x_dev *dev)
-{
-       dev->alloc_ctx = vb2_dma_contig_init_ctx(&dev->pci_dev->dev);
-       if (IS_ERR(dev->alloc_ctx)) {
-               dev_err(&dev->pci_dev->dev, "unable to init DMA context\n");
-               return PTR_ERR(dev->alloc_ctx);
-       }
-       return 0;
-}
-
 const struct tw686x_dma_ops contig_dma_ops = {
-       .setup          = tw686x_contig_setup,
-       .cleanup        = tw686x_contig_cleanup,
        .buf_refill     = tw686x_contig_buf_refill,
        .mem_ops        = &vb2_dma_contig_memops,
        .hw_dma_mode    = TW686X_FRAME_MODE,
@@ -316,21 +299,10 @@ static int tw686x_sg_dma_alloc(struct tw686x_video_channel *vc,
        return 0;
 }
 
-static void tw686x_sg_cleanup(struct tw686x_dev *dev)
-{
-       vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
-}
-
 static int tw686x_sg_setup(struct tw686x_dev *dev)
 {
        unsigned int sg_table_size, pb, ch, channels;
 
-       dev->alloc_ctx = vb2_dma_sg_init_ctx(&dev->pci_dev->dev);
-       if (IS_ERR(dev->alloc_ctx)) {
-               dev_err(&dev->pci_dev->dev, "unable to init DMA context\n");
-               return PTR_ERR(dev->alloc_ctx);
-       }
-
        if (is_second_gen(dev)) {
                /*
                 * TW6865/TW6869: each channel needs a pair of
@@ -360,7 +332,6 @@ static int tw686x_sg_setup(struct tw686x_dev *dev)
 
 const struct tw686x_dma_ops sg_dma_ops = {
        .setup          = tw686x_sg_setup,
-       .cleanup        = tw686x_sg_cleanup,
        .alloc          = tw686x_sg_dma_alloc,
        .free           = tw686x_sg_dma_free,
        .buf_refill     = tw686x_sg_buf_refill,
@@ -449,7 +420,6 @@ static int tw686x_queue_setup(struct vb2_queue *vq,
                return 0;
        }
 
-       alloc_ctxs[0] = vc->dev->alloc_ctx;
        sizes[0] = szimage;
        *nplanes = 1;
        return 0;
@@ -1063,9 +1033,6 @@ void tw686x_video_free(struct tw686x_dev *dev)
                        for (pb = 0; pb < 2; pb++)
                                dev->dma_ops->free(vc, pb);
        }
-
-       if (dev->dma_ops->cleanup)
-               dev->dma_ops->cleanup(dev);
 }
 
 int tw686x_video_init(struct tw686x_dev *dev)
@@ -1135,6 +1102,7 @@ int tw686x_video_init(struct tw686x_dev *dev)
                vc->vidq.min_buffers_needed = 2;
                vc->vidq.lock = &vc->vb_mutex;
                vc->vidq.gfp_flags = GFP_DMA32;
+               vc->vidq.dev = &dev->pci_dev->dev;
 
                err = vb2_queue_init(&vc->vidq);
                if (err) {
index 35d7bc94f78fb9d2769a5e84aab836972d15e13f..f24a2a9bcdb202b64c27a18493c171e64d67965c 100644 (file)
@@ -106,7 +106,6 @@ struct tw686x_video_channel {
 
 struct tw686x_dma_ops {
        int (*setup)(struct tw686x_dev *dev);
-       void (*cleanup)(struct tw686x_dev *dev);
        int (*alloc)(struct tw686x_video_channel *vc, unsigned int pb);
        void (*free)(struct tw686x_video_channel *vc, unsigned int pb);
        void (*buf_refill)(struct tw686x_video_channel *vc, unsigned int pb);
@@ -132,8 +131,6 @@ struct tw686x_dev {
        struct pci_dev *pci_dev;
        __u32 __iomem *mmio;
 
-       void *alloc_ctx;
-
        const struct tw686x_dma_ops *dma_ops;
        struct tw686x_video_channel *video_channels;
        struct tw686x_audio_channel *audio_channels;