Skip to content

Commit 2bc46b3

Browse files
Hans Verkuilmchehab
authored andcommitted
[media] media/pci: convert drivers to use the new vb2_queue dev field
Stop using alloc_ctx and just fill in the device pointer. Signed-off-by: Hans Verkuil <[email protected]> Cc: Federico Vaga <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 0e2f511 commit 2bc46b3

34 files changed

+32
-153
lines changed

drivers/media/pci/cobalt/cobalt-driver.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,10 @@ static int cobalt_probe(struct pci_dev *pci_dev,
691691
cobalt->pci_dev = pci_dev;
692692
cobalt->instance = i;
693693

694-
cobalt->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
695-
if (IS_ERR(cobalt->alloc_ctx)) {
696-
kfree(cobalt);
697-
return -ENOMEM;
698-
}
699-
700694
retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev);
701695
if (retval) {
702696
pr_err("cobalt: v4l2_device_register of card %d failed\n",
703697
cobalt->instance);
704-
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
705698
kfree(cobalt);
706699
return retval;
707700
}
@@ -782,7 +775,6 @@ static int cobalt_probe(struct pci_dev *pci_dev,
782775
cobalt_err("error %d on initialization\n", retval);
783776

784777
v4l2_device_unregister(&cobalt->v4l2_dev);
785-
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
786778
kfree(cobalt);
787779
return retval;
788780
}
@@ -818,7 +810,6 @@ static void cobalt_remove(struct pci_dev *pci_dev)
818810
cobalt_info("removed cobalt card\n");
819811

820812
v4l2_device_unregister(v4l2_dev);
821-
vb2_dma_sg_cleanup_ctx(cobalt->alloc_ctx);
822813
kfree(cobalt);
823814
}
824815

drivers/media/pci/cobalt/cobalt-driver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ struct cobalt {
262262
int instance;
263263
struct pci_dev *pci_dev;
264264
struct v4l2_device v4l2_dev;
265-
void *alloc_ctx;
266265

267266
void __iomem *bar0, *bar1;
268267

drivers/media/pci/cobalt/cobalt-v4l2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ static int cobalt_queue_setup(struct vb2_queue *q,
5454
*num_buffers = 3;
5555
if (*num_buffers > NR_BUFS)
5656
*num_buffers = NR_BUFS;
57-
alloc_ctxs[0] = s->cobalt->alloc_ctx;
5857
if (*num_planes)
5958
return sizes[0] < size ? -EINVAL : 0;
6059
*num_planes = 1;
@@ -1224,6 +1223,7 @@ static int cobalt_node_register(struct cobalt *cobalt, int node)
12241223
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
12251224
q->min_buffers_needed = 2;
12261225
q->lock = &s->lock;
1226+
q->dev = &cobalt->pci_dev->dev;
12271227
vdev->queue = q;
12281228

12291229
video_set_drvdata(vdev, s);

drivers/media/pci/cx23885/cx23885-417.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,6 @@ static int queue_setup(struct vb2_queue *q,
11481148
dev->ts1.ts_packet_count = mpeglines;
11491149
*num_planes = 1;
11501150
sizes[0] = mpeglinesize * mpeglines;
1151-
alloc_ctxs[0] = dev->alloc_ctx;
11521151
*num_buffers = mpegbufs;
11531152
return 0;
11541153
}

drivers/media/pci/cx23885/cx23885-core.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,14 +2005,9 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
20052005
err = pci_set_dma_mask(pci_dev, 0xffffffff);
20062006
if (err) {
20072007
printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
2008-
goto fail_context;
2008+
goto fail_ctrl;
20092009
}
20102010

2011-
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
2012-
if (IS_ERR(dev->alloc_ctx)) {
2013-
err = PTR_ERR(dev->alloc_ctx);
2014-
goto fail_context;
2015-
}
20162011
err = request_irq(pci_dev->irq, cx23885_irq,
20172012
IRQF_SHARED, dev->name, dev);
20182013
if (err < 0) {
@@ -2041,8 +2036,6 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
20412036
return 0;
20422037

20432038
fail_irq:
2044-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
2045-
fail_context:
20462039
cx23885_dev_unregister(dev);
20472040
fail_ctrl:
20482041
v4l2_ctrl_handler_free(hdl);
@@ -2068,7 +2061,6 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
20682061
pci_disable_device(pci_dev);
20692062

20702063
cx23885_dev_unregister(dev);
2071-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
20722064
v4l2_ctrl_handler_free(&dev->ctrl_handler);
20732065
v4l2_device_unregister(v4l2_dev);
20742066
kfree(dev);

drivers/media/pci/cx23885/cx23885-dvb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ static int queue_setup(struct vb2_queue *q,
102102
port->ts_packet_count = 32;
103103
*num_planes = 1;
104104
sizes[0] = port->ts_packet_size * port->ts_packet_count;
105-
alloc_ctxs[0] = port->dev->alloc_ctx;
106105
*num_buffers = 32;
107106
return 0;
108107
}
@@ -2397,6 +2396,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
23972396
q->mem_ops = &vb2_dma_sg_memops;
23982397
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
23992398
q->lock = &dev->lock;
2399+
q->dev = &dev->pci->dev;
24002400

24012401
err = vb2_queue_init(q);
24022402
if (err < 0)

drivers/media/pci/cx23885/cx23885-vbi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ static int queue_setup(struct vb2_queue *q,
131131
lines = VBI_NTSC_LINE_COUNT;
132132
*num_planes = 1;
133133
sizes[0] = lines * VBI_LINE_LENGTH * 2;
134-
alloc_ctxs[0] = dev->alloc_ctx;
135134
return 0;
136135
}
137136

drivers/media/pci/cx23885/cx23885-video.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ static int queue_setup(struct vb2_queue *q,
341341

342342
*num_planes = 1;
343343
sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3;
344-
alloc_ctxs[0] = dev->alloc_ctx;
345344
return 0;
346345
}
347346

@@ -1268,6 +1267,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
12681267
q->mem_ops = &vb2_dma_sg_memops;
12691268
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
12701269
q->lock = &dev->lock;
1270+
q->dev = &dev->pci->dev;
12711271

12721272
err = vb2_queue_init(q);
12731273
if (err < 0)
@@ -1284,6 +1284,7 @@ int cx23885_video_register(struct cx23885_dev *dev)
12841284
q->mem_ops = &vb2_dma_sg_memops;
12851285
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
12861286
q->lock = &dev->lock;
1287+
q->dev = &dev->pci->dev;
12871288

12881289
err = vb2_queue_init(q);
12891290
if (err < 0)

drivers/media/pci/cx23885/cx23885.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ struct cx23885_dev {
430430
struct vb2_queue vb2_vidq;
431431
struct cx23885_dmaqueue vbiq;
432432
struct vb2_queue vb2_vbiq;
433-
void *alloc_ctx;
434433

435434
spinlock_t slock;
436435

drivers/media/pci/cx25821/cx25821-core.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,15 +1301,10 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
13011301

13021302
goto fail_unregister_device;
13031303
}
1304-
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
1305-
if (IS_ERR(dev->alloc_ctx)) {
1306-
err = PTR_ERR(dev->alloc_ctx);
1307-
goto fail_unregister_pci;
1308-
}
13091304

13101305
err = cx25821_dev_setup(dev);
13111306
if (err)
1312-
goto fail_free_ctx;
1307+
goto fail_unregister_pci;
13131308

13141309
/* print pci info */
13151310
pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
@@ -1340,8 +1335,6 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
13401335
pr_info("cx25821_initdev() can't get IRQ !\n");
13411336
cx25821_dev_unregister(dev);
13421337

1343-
fail_free_ctx:
1344-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
13451338
fail_unregister_pci:
13461339
pci_disable_device(pci_dev);
13471340
fail_unregister_device:
@@ -1365,7 +1358,6 @@ static void cx25821_finidev(struct pci_dev *pci_dev)
13651358
free_irq(pci_dev->irq, dev);
13661359

13671360
cx25821_dev_unregister(dev);
1368-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
13691361
v4l2_device_unregister(v4l2_dev);
13701362
kfree(dev);
13711363
}

drivers/media/pci/cx25821/cx25821-video.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ static int cx25821_queue_setup(struct vb2_queue *q,
148148
struct cx25821_channel *chan = q->drv_priv;
149149
unsigned size = (chan->fmt->depth * chan->width * chan->height) >> 3;
150150

151-
alloc_ctxs[0] = chan->dev->alloc_ctx;
152-
153151
if (*num_planes)
154152
return sizes[0] < size ? -EINVAL : 0;
155153

@@ -759,6 +757,7 @@ int cx25821_video_register(struct cx25821_dev *dev)
759757
q->mem_ops = &vb2_dma_sg_memops;
760758
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
761759
q->lock = &dev->lock;
760+
q->dev = &dev->pci->dev;
762761

763762
if (!is_output) {
764763
err = vb2_queue_init(q);

drivers/media/pci/cx25821/cx25821.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ struct cx25821_dev {
249249
int hwrevision;
250250
/* used by cx25821-alsa */
251251
struct snd_card *card;
252-
void *alloc_ctx;
253252

254253
u32 clk_freq;
255254

drivers/media/pci/cx88/cx88-blackbird.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ static int queue_setup(struct vb2_queue *q,
647647
dev->ts_packet_size = 188 * 4;
648648
dev->ts_packet_count = 32;
649649
sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
650-
alloc_ctxs[0] = dev->alloc_ctx;
651650
return 0;
652651
}
653652

@@ -1183,6 +1182,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv)
11831182
q->mem_ops = &vb2_dma_sg_memops;
11841183
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
11851184
q->lock = &core->lock;
1185+
q->dev = &dev->pci->dev;
11861186

11871187
err = vb2_queue_init(q);
11881188
if (err < 0)

drivers/media/pci/cx88/cx88-dvb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ static int queue_setup(struct vb2_queue *q,
9292
dev->ts_packet_size = 188 * 4;
9393
dev->ts_packet_count = dvb_buf_tscnt;
9494
sizes[0] = dev->ts_packet_size * dev->ts_packet_count;
95-
alloc_ctxs[0] = dev->alloc_ctx;
9695
*num_buffers = dvb_buf_tscnt;
9796
return 0;
9897
}
@@ -1793,6 +1792,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv)
17931792
q->mem_ops = &vb2_dma_sg_memops;
17941793
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
17951794
q->lock = &core->lock;
1795+
q->dev = &dev->pci->dev;
17961796

17971797
err = vb2_queue_init(q);
17981798
if (err < 0)

drivers/media/pci/cx88/cx88-mpeg.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -726,19 +726,14 @@ static int cx8802_probe(struct pci_dev *pci_dev,
726726
if (NULL == dev)
727727
goto fail_core;
728728
dev->pci = pci_dev;
729-
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
730-
if (IS_ERR(dev->alloc_ctx)) {
731-
err = PTR_ERR(dev->alloc_ctx);
732-
goto fail_dev;
733-
}
734729
dev->core = core;
735730

736731
/* Maintain a reference so cx88-video can query the 8802 device. */
737732
core->dvbdev = dev;
738733

739734
err = cx8802_init_common(dev);
740735
if (err != 0)
741-
goto fail_free;
736+
goto fail_dev;
742737

743738
INIT_LIST_HEAD(&dev->drvlist);
744739
mutex_lock(&cx8802_mutex);
@@ -749,8 +744,6 @@ static int cx8802_probe(struct pci_dev *pci_dev,
749744
request_modules(dev);
750745
return 0;
751746

752-
fail_free:
753-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
754747
fail_dev:
755748
kfree(dev);
756749
fail_core:
@@ -798,7 +791,6 @@ static void cx8802_remove(struct pci_dev *pci_dev)
798791
/* common */
799792
cx8802_fini_common(dev);
800793
cx88_core_put(dev->core,dev->pci);
801-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
802794
kfree(dev);
803795
}
804796

drivers/media/pci/cx88/cx88-vbi.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ static int queue_setup(struct vb2_queue *q,
118118
sizes[0] = VBI_LINE_NTSC_COUNT * VBI_LINE_LENGTH * 2;
119119
else
120120
sizes[0] = VBI_LINE_PAL_COUNT * VBI_LINE_LENGTH * 2;
121-
alloc_ctxs[0] = dev->alloc_ctx;
122121
return 0;
123122
}
124123

drivers/media/pci/cx88/cx88-video.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@ static int queue_setup(struct vb2_queue *q,
438438

439439
*num_planes = 1;
440440
sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3;
441-
alloc_ctxs[0] = dev->alloc_ctx;
442441
return 0;
443442
}
444443

@@ -1319,12 +1318,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
13191318
printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
13201319
goto fail_core;
13211320
}
1322-
dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
1323-
if (IS_ERR(dev->alloc_ctx)) {
1324-
err = PTR_ERR(dev->alloc_ctx);
1325-
goto fail_core;
1326-
}
1327-
13281321

13291322
/* initialize driver struct */
13301323
spin_lock_init(&dev->slock);
@@ -1445,6 +1438,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
14451438
q->mem_ops = &vb2_dma_sg_memops;
14461439
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
14471440
q->lock = &core->lock;
1441+
q->dev = &dev->pci->dev;
14481442

14491443
err = vb2_queue_init(q);
14501444
if (err < 0)
@@ -1461,6 +1455,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
14611455
q->mem_ops = &vb2_dma_sg_memops;
14621456
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
14631457
q->lock = &core->lock;
1458+
q->dev = &dev->pci->dev;
14641459

14651460
err = vb2_queue_init(q);
14661461
if (err < 0)
@@ -1530,7 +1525,6 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
15301525
free_irq(pci_dev->irq, dev);
15311526
mutex_unlock(&core->lock);
15321527
fail_core:
1533-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
15341528
core->v4ldev = NULL;
15351529
cx88_core_put(core,dev->pci);
15361530
fail_free:
@@ -1564,7 +1558,6 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
15641558

15651559
/* free memory */
15661560
cx88_core_put(core,dev->pci);
1567-
vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
15681561
kfree(dev);
15691562
}
15701563

drivers/media/pci/cx88/cx88.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ struct cx8800_dev {
485485
/* pci i/o */
486486
struct pci_dev *pci;
487487
unsigned char pci_rev,pci_lat;
488-
void *alloc_ctx;
489488

490489
const struct cx8800_fmt *fmt;
491490

@@ -549,7 +548,6 @@ struct cx8802_dev {
549548
/* pci i/o */
550549
struct pci_dev *pci;
551550
unsigned char pci_rev,pci_lat;
552-
void *alloc_ctx;
553551

554552
/* dma queues */
555553
struct cx88_dmaqueue mpegq;

0 commit comments

Comments
 (0)