diff options
Diffstat (limited to 'drivers/media/pci')
50 files changed, 236 insertions, 282 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c index 9144f795fb93..8824dd0fb331 100644 --- a/drivers/media/pci/bt8xx/bttv-driver.c +++ b/drivers/media/pci/bt8xx/bttv-driver.c @@ -2332,7 +2332,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv, field = V4L2_FIELD_SEQ_TB; break; } - /* fall through */ + fallthrough; default: /* FIELD_ANY case */ height2 = btv->crop[!!fh->do_crop].rect.height >> 1; field = (f->fmt.pix.height > height2) @@ -4013,11 +4013,13 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) btv->id = dev->device; if (pci_enable_device(dev)) { pr_warn("%d: Can't enable device\n", btv->c.nr); - return -EIO; + result = -EIO; + goto free_mem; } if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) { pr_warn("%d: No suitable DMA available\n", btv->c.nr); - return -EIO; + result = -EIO; + goto free_mem; } if (!request_mem_region(pci_resource_start(dev,0), pci_resource_len(dev,0), @@ -4025,7 +4027,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) pr_warn("%d: can't request iomem (0x%llx)\n", btv->c.nr, (unsigned long long)pci_resource_start(dev, 0)); - return -EBUSY; + result = -EBUSY; + goto free_mem; } pci_set_master(dev); pci_set_command(dev); @@ -4211,6 +4214,10 @@ fail0: release_mem_region(pci_resource_start(btv->c.pci,0), pci_resource_len(btv->c.pci,0)); pci_disable_device(btv->c.pci); + +free_mem: + bttvs[btv->c.nr] = NULL; + kfree(btv); return result; } diff --git a/drivers/media/pci/bt8xx/dvb-bt8xx.c b/drivers/media/pci/bt8xx/dvb-bt8xx.c index 02ebd43e672e..4cb890b949c3 100644 --- a/drivers/media/pci/bt8xx/dvb-bt8xx.c +++ b/drivers/media/pci/bt8xx/dvb-bt8xx.c @@ -39,9 +39,10 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ -static void dvb_bt8xx_task(unsigned long data) +static void dvb_bt8xx_task(struct tasklet_struct *t) { - struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; + struct bt878 *bt = from_tasklet(bt, t, tasklet); + struct dvb_bt8xx_card *card = dev_get_drvdata(&bt->adapter->dev); dprintk("%d\n", card->bt->finished_block); @@ -777,7 +778,7 @@ static int dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) goto err_disconnect_frontend; } - tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card); + tasklet_setup(&card->bt->tasklet, dvb_bt8xx_task); frontend_init(card, type); diff --git a/drivers/media/pci/cobalt/cobalt-i2c.c b/drivers/media/pci/cobalt/cobalt-i2c.c index c374dae78bf7..10c9ee33f73e 100644 --- a/drivers/media/pci/cobalt/cobalt-i2c.c +++ b/drivers/media/pci/cobalt/cobalt-i2c.c @@ -118,11 +118,11 @@ static int cobalt_tx_bytes(struct cobalt_i2c_regs __iomem *regs, iowrite8(data[i], ®s->txr_rxr); /* Setup command */ - if (i == 0 && start != 0) { + if (i == 0 && start) { /* Write + Start */ cmd = M00018_CR_BITMAP_WR_MSK | M00018_CR_BITMAP_STA_MSK; - } else if (i == len - 1 && stop != 0) { + } else if (i == len - 1 && stop) { /* Write + Stop */ cmd = M00018_CR_BITMAP_WR_MSK | M00018_CR_BITMAP_STO_MSK; @@ -173,11 +173,11 @@ static int cobalt_rx_bytes(struct cobalt_i2c_regs __iomem *regs, for (i = 0; i < len; i++) { /* Setup command */ - if (i == 0 && start != 0) { + if (i == 0 && start) { /* Read + Start */ cmd = M00018_CR_BITMAP_RD_MSK | M00018_CR_BITMAP_STA_MSK; - } else if (i == len - 1 && stop != 0) { + } else if (i == len - 1 && stop) { /* Read + Stop */ cmd = M00018_CR_BITMAP_RD_MSK | M00018_CR_BITMAP_STO_MSK; diff --git a/drivers/media/pci/cobalt/cobalt-omnitek.c b/drivers/media/pci/cobalt/cobalt-omnitek.c index 4c137453e679..01b82a2e8d33 100644 --- a/drivers/media/pci/cobalt/cobalt-omnitek.c +++ b/drivers/media/pci/cobalt/cobalt-omnitek.c @@ -116,7 +116,7 @@ void omni_sg_dma_abort_channel(struct cobalt_stream *s) { struct cobalt *cobalt = s->cobalt; - if (is_dma_done(s) == false) + if (!is_dma_done(s)) iowrite32(ABORT, CS_REG(s->dma_channel)); } diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c index df44ed7393a0..13689c5dd47f 100644 --- a/drivers/media/pci/cx23885/cx23885-alsa.c +++ b/drivers/media/pci/cx23885/cx23885-alsa.c @@ -68,7 +68,8 @@ MODULE_PARM_DESC(audio_debug, "enable debug messages [analog audio]"); #define AUD_INT_MCHG_IRQ (1 << 21) #define GP_COUNT_CONTROL_RESET 0x3 -static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages) +static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, + unsigned long nr_pages) { struct cx23885_audio_buffer *buf = chip->buf; struct page *pg; @@ -76,11 +77,11 @@ static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages) buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); if (NULL == buf->vaddr) { - dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); + dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages); return -ENOMEM; } - dprintk(1, "vmalloc is at addr %p, size=%d\n", + dprintk(1, "vmalloc is at addr %p, size=%lu\n", buf->vaddr, nr_pages << PAGE_SHIFT); memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); @@ -113,7 +114,7 @@ static int cx23885_alsa_dma_map(struct cx23885_audio_dev *dev) struct cx23885_audio_buffer *buf = dev->buf; buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, - buf->nr_pages, PCI_DMA_FROMDEVICE); + buf->nr_pages, DMA_FROM_DEVICE); if (0 == buf->sglen) { pr_warn("%s: cx23885_alsa_map_sg failed\n", __func__); @@ -129,7 +130,7 @@ static int cx23885_alsa_dma_unmap(struct cx23885_audio_dev *dev) if (!buf->sglen) return 0; - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, DMA_FROM_DEVICE); buf->sglen = 0; return 0; } diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c index 570a4a09c387..03eee606af91 100644 --- a/drivers/media/pci/cx23885/cx23885-cards.c +++ b/drivers/media/pci/cx23885/cx23885-cards.c @@ -2209,7 +2209,7 @@ void cx23885_card_setup(struct cx23885_dev *dev) ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; - /* fall-through */ + fallthrough; case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: ts1->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ @@ -2370,7 +2370,7 @@ void cx23885_card_setup(struct cx23885_dev *dev) /* Currently only enabled for the integrated IR controller */ if (!enable_885_ir) break; - /* fall-through */ + fallthrough; case CX23885_BOARD_HAUPPAUGE_HVR1250: case CX23885_BOARD_HAUPPAUGE_HVR1800: case CX23885_BOARD_HAUPPAUGE_IMPACTVCBE: diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 440d108b7ddd..a380e0920a21 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -637,7 +637,7 @@ static int vidioc_querycap(struct file *file, void *priv, sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO | V4L2_CAP_VBI_CAPTURE | - V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE | + V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_DEVICE_CAPS; switch (dev->board) { /* i2c device tuners */ case CX23885_BOARD_HAUPPAUGE_HVR1265_K4: diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h index c472498e57c4..349462ee2c48 100644 --- a/drivers/media/pci/cx23885/cx23885.h +++ b/drivers/media/pci/cx23885/cx23885.h @@ -325,8 +325,8 @@ struct cx23885_audio_buffer { struct cx23885_riscmem risc; void *vaddr; struct scatterlist *sglist; - int sglen; - int nr_pages; + int sglen; + unsigned long nr_pages; }; struct cx23885_audio_dev { diff --git a/drivers/media/pci/cx23885/cx23888-ir.c b/drivers/media/pci/cx23885/cx23888-ir.c index ad7f8ccad526..ddfd2eb37484 100644 --- a/drivers/media/pci/cx23885/cx23888-ir.c +++ b/drivers/media/pci/cx23885/cx23888-ir.c @@ -663,7 +663,7 @@ static int cx23888_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count, } v = (unsigned) pulse_width_count_to_ns( - (u16) (p->hw_fifo_data & FIFO_RXTX), divider); + (u16)(p->hw_fifo_data & FIFO_RXTX), divider) / 1000; if (v > IR_MAX_DURATION) v = IR_MAX_DURATION; diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index 301616426d8a..608fbaf0f659 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c @@ -53,8 +53,8 @@ struct cx25821_audio_buffer { struct cx25821_riscmem risc; void *vaddr; struct scatterlist *sglist; - int sglen; - int nr_pages; + int sglen; + unsigned long nr_pages; }; struct cx25821_audio_dev { @@ -131,7 +131,8 @@ MODULE_PARM_DESC(debug, "enable debug messages"); #define PCI_MSK_AUD_EXT (1 << 4) #define PCI_MSK_AUD_INT (1 << 3) -static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages) +static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, + unsigned long nr_pages) { struct cx25821_audio_buffer *buf = chip->buf; struct page *pg; @@ -139,11 +140,11 @@ static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages) buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); if (NULL == buf->vaddr) { - dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); + dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages); return -ENOMEM; } - dprintk(1, "vmalloc is at addr 0x%p, size=%d\n", + dprintk(1, "vmalloc is at addr 0x%p, size=%lu\n", buf->vaddr, nr_pages << PAGE_SHIFT); @@ -177,7 +178,7 @@ static int cx25821_alsa_dma_map(struct cx25821_audio_dev *dev) struct cx25821_audio_buffer *buf = dev->buf; buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, - buf->nr_pages, PCI_DMA_FROMDEVICE); + buf->nr_pages, DMA_FROM_DEVICE); if (0 == buf->sglen) { pr_warn("%s: cx25821_alsa_map_sg failed\n", __func__); @@ -193,7 +194,7 @@ static int cx25821_alsa_dma_unmap(struct cx25821_audio_dev *dev) if (!buf->sglen) return 0; - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, PCI_DMA_FROMDEVICE); + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, DMA_FROM_DEVICE); buf->sglen = 0; return 0; } diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c index 7d7aceecc985..95e0cbb1277d 100644 --- a/drivers/media/pci/cx88/cx88-alsa.c +++ b/drivers/media/pci/cx88/cx88-alsa.c @@ -42,12 +42,12 @@ */ struct cx88_audio_buffer { - unsigned int bpl; - struct cx88_riscmem risc; + unsigned int bpl; + struct cx88_riscmem risc; void *vaddr; struct scatterlist *sglist; int sglen; - int nr_pages; + unsigned long nr_pages; }; struct cx88_audio_dev { @@ -271,7 +271,8 @@ static irqreturn_t cx8801_irq(int irq, void *dev_id) return IRQ_RETVAL(handled); } -static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) +static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, + unsigned long nr_pages) { struct cx88_audio_buffer *buf = chip->buf; struct page *pg; @@ -279,11 +280,11 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) buf->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); if (!buf->vaddr) { - dprintk(1, "vmalloc_32(%d pages) failed\n", nr_pages); + dprintk(1, "vmalloc_32(%lu pages) failed\n", nr_pages); return -ENOMEM; } - dprintk(1, "vmalloc is at addr %p, size=%d\n", + dprintk(1, "vmalloc is at addr %p, size=%lu\n", buf->vaddr, nr_pages << PAGE_SHIFT); memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); @@ -316,7 +317,7 @@ static int cx88_alsa_dma_map(struct cx88_audio_dev *dev) struct cx88_audio_buffer *buf = dev->buf; buf->sglen = dma_map_sg(&dev->pci->dev, buf->sglist, - buf->nr_pages, PCI_DMA_FROMDEVICE); + buf->nr_pages, DMA_FROM_DEVICE); if (buf->sglen == 0) { pr_warn("%s: cx88_alsa_map_sg failed\n", __func__); @@ -332,8 +333,8 @@ static int cx88_alsa_dma_unmap(struct cx88_audio_dev *dev) if (!buf->sglen) return 0; - dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->sglen, - PCI_DMA_FROMDEVICE); + dma_unmap_sg(&dev->pci->dev, buf->sglist, buf->nr_pages, + DMA_FROM_DEVICE); buf->sglen = 0; return 0; } diff --git a/drivers/media/pci/cx88/cx88-cards.c b/drivers/media/pci/cx88/cx88-cards.c index 9fa388626bae..8e224fc0474d 100644 --- a/drivers/media/pci/cx88/cx88-cards.c +++ b/drivers/media/pci/cx88/cx88-cards.c @@ -3499,7 +3499,7 @@ static void cx88_card_setup(struct cx88_core *core) cx_clear(MO_GP0_IO, 0x00000040); msleep(1000); cx_set(MO_GP0_IO, 0x00004040); - /* FALLTHROUGH */ + fallthrough; case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c index 7e0fed9cd200..ce0ef0b8186f 100644 --- a/drivers/media/pci/cx88/cx88-input.c +++ b/drivers/media/pci/cx88/cx88-input.c @@ -479,7 +479,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) dev->scancode_mask = hardware_mask; if (ir->sampling) { - dev->timeout = 10 * 1000 * 1000; /* 10 ms */ + dev->timeout = MS_TO_US(10); /* 10 ms */ } else { dev->driver_type = RC_DRIVER_SCANCODE; dev->allowed_protocols = rc_proto; @@ -544,7 +544,7 @@ void cx88_ir_irq(struct cx88_core *core) for (todo = 32; todo > 0; todo -= bits) { ev.pulse = samples & 0x80000000 ? false : true; bits = min(todo, 32U - fls(ev.pulse ? samples : ~samples)); - ev.duration = (bits * (NSEC_PER_SEC / 1000)) / ir_samplerate; + ev.duration = (bits * (USEC_PER_SEC / 1000)) / ir_samplerate; ir_raw_event_store_with_filter(ir->dev, &ev); samples <<= bits; } diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c index e7fd7516787c..8cffdacf6007 100644 --- a/drivers/media/pci/cx88/cx88-video.c +++ b/drivers/media/pci/cx88/cx88-video.c @@ -1385,7 +1385,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, request_module("rtc-isl1208"); core->i2c_rtc = i2c_new_client_device(&core->i2c_adap, &rtc_info); } - /* fall-through */ + fallthrough; case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: request_module("ir-kbd-i2c"); } diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c index 7cabb9e9ffe2..92fe051c672f 100644 --- a/drivers/media/pci/ddbridge/ddbridge-core.c +++ b/drivers/media/pci/ddbridge/ddbridge-core.c @@ -1310,7 +1310,7 @@ static void dvb_input_detach(struct ddb_input *input) dvb_unregister_frontend(dvb->fe2); if (dvb->fe) dvb_unregister_frontend(dvb->fe); - /* fallthrough */ + fallthrough; case 0x30: dvb_module_release(dvb->i2c_client[0]); dvb->i2c_client[0] = NULL; @@ -1321,22 +1321,22 @@ static void dvb_input_detach(struct ddb_input *input) dvb_frontend_detach(dvb->fe); dvb->fe = NULL; dvb->fe2 = NULL; - /* fallthrough */ + fallthrough; case 0x20: dvb_net_release(&dvb->dvbnet); - /* fallthrough */ + fallthrough; case 0x12: dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &dvb->hw_frontend); dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &dvb->mem_frontend); - /* fallthrough */ + fallthrough; case 0x11: dvb_dmxdev_release(&dvb->dmxdev); - /* fallthrough */ + fallthrough; case 0x10: dvb_dmx_release(&dvb->demux); - /* fallthrough */ + fallthrough; case 0x01: break; } @@ -1559,7 +1559,7 @@ static int dvb_input_attach(struct ddb_input *input) osc24 = 0; else osc24 = 1; - /* fall-through */ + fallthrough; case DDB_TUNER_DVBCT2_SONY_P: case DDB_TUNER_DVBC2T2_SONY_P: case DDB_TUNER_ISDBT_SONY_P: @@ -1575,7 +1575,7 @@ static int dvb_input_attach(struct ddb_input *input) break; case DDB_TUNER_DVBC2T2I_SONY: osc24 = 1; - /* fall-through */ + fallthrough; case DDB_TUNER_DVBCT2_SONY: case DDB_TUNER_DVBC2T2_SONY: case DDB_TUNER_ISDBT_SONY: @@ -2036,7 +2036,7 @@ static int ddb_port_attach(struct ddb_port *port) ret = ddb_ci_attach(port, ci_bitrate); if (ret < 0) break; - /* fall-through */ + fallthrough; case DDB_PORT_LOOP: ret = dvb_register_device(port->dvb[0].adap, &port->dvb[0].dev, @@ -2432,7 +2432,8 @@ void ddb_ports_init(struct ddb *dev) ddb_input_init(port, 4 + i, 1, 4 + i); ddb_output_init(port, i); break; - } /* fallthrough */ + } + fallthrough; case DDB_OCTOPUS: ddb_input_init(port, 2 * i, 0, 2 * i); ddb_input_init(port, 2 * i + 1, 1, 2 * i + 1); @@ -3417,7 +3418,7 @@ int ddb_exit_ddbridge(int stage, int error) default: case 2: destroy_workqueue(ddb_wq); - /* fall-through */ + fallthrough; case 1: ddb_class_destroy(); break; diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c index ef8d5c9cfffe..961f844de99c 100644 --- a/drivers/media/pci/dt3155/dt3155.c +++ b/drivers/media/pci/dt3155/dt3155.c @@ -575,9 +575,8 @@ static void dt3155_remove(struct pci_dev *pdev) struct dt3155_priv *pd = container_of(v4l2_dev, struct dt3155_priv, v4l2_dev); - video_unregister_device(&pd->vdev); + vb2_video_unregister_device(&pd->vdev); free_irq(pd->pdev->irq, pd); - vb2_queue_release(&pd->vidq); v4l2_device_unregister(&pd->v4l2_dev); pci_iounmap(pdev, pd->regs); pci_release_region(pdev, 0); diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 92f5eadf2c99..4e598e937dfe 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2017 Intel Corporation + * Copyright (C) 2017,2020 Intel Corporation * * Based partially on Intel IPU4 driver written by * Sakari Ailus <sakari.ailus@linux.intel.com> @@ -9,13 +9,14 @@ * Jouni Ukkonen <jouni.ukkonen@intel.com> * Antti Laakso <antti.laakso@intel.com> * et al. - * */ #include <linux/delay.h> #include <linux/interrupt.h> +#include <linux/iopoll.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/pfn.h> #include <linux/pm_runtime.h> #include <linux/property.h> #include <linux/vmalloc.h> @@ -96,12 +97,12 @@ static inline u32 cio2_bytesperline(const unsigned int width) static void cio2_fbpt_exit_dummy(struct cio2_device *cio2) { if (cio2->dummy_lop) { - dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE, + dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE, cio2->dummy_lop, cio2->dummy_lop_bus_addr); cio2->dummy_lop = NULL; } if (cio2->dummy_page) { - dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE, + dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE, cio2->dummy_page, cio2->dummy_page_bus_addr); cio2->dummy_page = NULL; } @@ -111,12 +112,10 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2) { unsigned int i; - cio2->dummy_page = dma_alloc_coherent(&cio2->pci_dev->dev, - CIO2_PAGE_SIZE, + cio2->dummy_page = dma_alloc_coherent(&cio2->pci_dev->dev, PAGE_SIZE, &cio2->dummy_page_bus_addr, GFP_KERNEL); - cio2->dummy_lop = dma_alloc_coherent(&cio2->pci_dev->dev, - CIO2_PAGE_SIZE, + cio2->dummy_lop = dma_alloc_coherent(&cio2->pci_dev->dev, PAGE_SIZE, &cio2->dummy_lop_bus_addr, GFP_KERNEL); if (!cio2->dummy_page || !cio2->dummy_lop) { @@ -127,8 +126,8 @@ static int cio2_fbpt_init_dummy(struct cio2_device *cio2) * List of Pointers(LOP) contains 1024x32b pointers to 4KB page each * Initialize each entry to dummy_page bus base address. */ - for (i = 0; i < CIO2_PAGE_SIZE / sizeof(*cio2->dummy_lop); i++) - cio2->dummy_lop[i] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; + for (i = 0; i < CIO2_LOP_ENTRIES; i++) + cio2->dummy_lop[i] = PFN_DOWN(cio2->dummy_page_bus_addr); return 0; } @@ -160,12 +159,11 @@ static void cio2_fbpt_entry_init_dummy(struct cio2_device *cio2, unsigned int i; entry[0].first_entry.first_page_offset = 0; - entry[1].second_entry.num_of_pages = - CIO2_PAGE_SIZE / sizeof(u32) * CIO2_MAX_LOPS; - entry[1].second_entry.last_page_available_bytes = CIO2_PAGE_SIZE - 1; + entry[1].second_entry.num_of_pages = CIO2_LOP_ENTRIES * CIO2_MAX_LOPS; + entry[1].second_entry.last_page_available_bytes = PAGE_SIZE - 1; for (i = 0; i < CIO2_MAX_LOPS; i++) - entry[i].lop_page_addr = cio2->dummy_lop_bus_addr >> PAGE_SHIFT; + entry[i].lop_page_addr = PFN_DOWN(cio2->dummy_lop_bus_addr); cio2_fbpt_entry_enable(cio2, entry); } @@ -182,26 +180,24 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, entry[0].first_entry.first_page_offset = b->offset; remaining = length + entry[0].first_entry.first_page_offset; - entry[1].second_entry.num_of_pages = - DIV_ROUND_UP(remaining, CIO2_PAGE_SIZE); + entry[1].second_entry.num_of_pages = PFN_UP(remaining); /* * last_page_available_bytes has the offset of the last byte in the * last page which is still accessible by DMA. DMA cannot access * beyond this point. Valid range for this is from 0 to 4095. * 0 indicates 1st byte in the page is DMA accessible. - * 4095 (CIO2_PAGE_SIZE - 1) means every single byte in the last page + * 4095 (PAGE_SIZE - 1) means every single byte in the last page * is available for DMA transfer. */ entry[1].second_entry.last_page_available_bytes = (remaining & ~PAGE_MASK) ? - (remaining & ~PAGE_MASK) - 1 : - CIO2_PAGE_SIZE - 1; + (remaining & ~PAGE_MASK) - 1 : PAGE_SIZE - 1; /* Fill FBPT */ remaining = length; i = 0; while (remaining > 0) { - entry->lop_page_addr = b->lop_bus_addr[i] >> PAGE_SHIFT; - remaining -= CIO2_PAGE_SIZE / sizeof(u32) * CIO2_PAGE_SIZE; + entry->lop_page_addr = PFN_DOWN(b->lop_bus_addr[i]); + remaining -= CIO2_LOP_ENTRIES * PAGE_SIZE; entry++; i++; } @@ -209,7 +205,7 @@ static void cio2_fbpt_entry_init_buf(struct cio2_device *cio2, /* * The first not meaningful FBPT entry should point to a valid LOP */ - entry->lop_page_addr = cio2->dummy_lop_bus_addr >> PAGE_SHIFT; + entry->lop_page_addr = PFN_DOWN(cio2->dummy_lop_bus_addr); cio2_fbpt_entry_enable(cio2, entry); } @@ -295,7 +291,7 @@ static int cio2_csi2_calc_timing(struct cio2_device *cio2, struct cio2_queue *q, struct cio2_csi2_timing *timing) { struct device *dev = &cio2->pci_dev->dev; - struct v4l2_querymenu qm = {.id = V4L2_CID_LINK_FREQ, }; + struct v4l2_querymenu qm = { .id = V4L2_CID_LINK_FREQ }; struct v4l2_ctrl *link_freq; s64 freq; int r; @@ -475,8 +471,7 @@ static int cio2_hw_init(struct cio2_device *cio2, struct cio2_queue *q) } /* Enable DMA */ - writel(q->fbpt_bus_addr >> PAGE_SHIFT, - base + CIO2_REG_CDMABA(CIO2_DMA_CHAN)); + writel(PFN_DOWN(q->fbpt_bus_addr), base + CIO2_REG_CDMABA(CIO2_DMA_CHAN)); writel(num_buffers1 << CIO2_CDMAC0_FBPT_LEN_SHIFT | FBPT_WIDTH << CIO2_CDMAC0_FBPT_WIDTH_SHIFT | @@ -512,8 +507,10 @@ static int cio2_hw_init(struct cio2_device *cio2, struct cio2_queue *q) static void cio2_hw_exit(struct cio2_device *cio2, struct cio2_queue *q) { - void __iomem *base = cio2->base; - unsigned int i, maxloops = 1000; + void __iomem *const base = cio2->base; + unsigned int i; + u32 value; + int ret; /* Disable CSI receiver and MIPI backend devices */ writel(0, q->csi_rx_base + CIO2_REG_IRQCTRL_MASK); @@ -523,13 +520,10 @@ static void cio2_hw_exit(struct cio2_device *cio2, struct cio2_queue *q) /* Halt DMA */ writel(0, base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN)); - do { - if (readl(base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN)) & - CIO2_CDMAC0_DMA_HALTED) - break; - usleep_range(1000, 2000); - } while (--maxloops); - if (!maxloops) + ret = readl_poll_timeout(base + CIO2_REG_CDMAC0(CIO2_DMA_CHAN), + value, value & CIO2_CDMAC0_DMA_HALTED, + 4000, 2000000); + if (ret) dev_err(&cio2->pci_dev->dev, "DMA %i can not be halted\n", CIO2_DMA_CHAN); @@ -545,7 +539,7 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) { struct device *dev = &cio2->pci_dev->dev; struct cio2_queue *q = cio2->cur_queue; - int buffers_found = 0; + struct cio2_fbpt_entry *entry; u64 ns = ktime_get_ns(); if (dma_chan >= CIO2_QUEUES) { @@ -553,15 +547,18 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) return; } + entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; + if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID) { + dev_warn(&cio2->pci_dev->dev, + "no ready buffers found on DMA channel %u\n", + dma_chan); + return; + } + /* Find out which buffer(s) are ready */ do { - struct cio2_fbpt_entry *const entry = - &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; struct cio2_buffer *b; - if (entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID) - break; - b = q->bufs[q->bufs_first]; if (b) { unsigned int bytes = entry[1].second_entry.num_of_bytes; @@ -583,13 +580,8 @@ static void cio2_buffer_done(struct cio2_device *cio2, unsigned int dma_chan) atomic_inc(&q->frame_sequence); cio2_fbpt_entry_init_dummy(cio2, entry); q->bufs_first = (q->bufs_first + 1) % CIO2_MAX_BUFFERS; - buffers_found++; - } while (1); - - if (buffers_found == 0) - dev_warn(&cio2->pci_dev->dev, - "no ready buffers found on DMA channel %u\n", - dma_chan); + entry = &q->fbpt[q->bufs_first * CIO2_MAX_LOPS]; + } while (!(entry->first_entry.ctrl & CIO2_FBPT_CTRL_VALID)); } static void cio2_queue_event_sof(struct cio2_device *cio2, struct cio2_queue *q) @@ -841,13 +833,11 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) struct device *dev = &cio2->pci_dev->dev; struct cio2_buffer *b = container_of(vb, struct cio2_buffer, vbb.vb2_buf); - static const unsigned int entries_per_page = - CIO2_PAGE_SIZE / sizeof(u32); - unsigned int pages = DIV_ROUND_UP(vb->planes[0].length, CIO2_PAGE_SIZE); - unsigned int lops = DIV_ROUND_UP(pages + 1, entries_per_page); + unsigned int pages = PFN_UP(vb->planes[0].length); + unsigned int lops = DIV_ROUND_UP(pages + 1, CIO2_LOP_ENTRIES); struct sg_table *sg; struct sg_dma_page_iter sg_iter; - int i, j; + unsigned int i, j; if (lops <= 0 || lops > CIO2_MAX_LOPS) { dev_err(dev, "%s: bad buffer size (%i)\n", __func__, @@ -858,7 +848,7 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) memset(b->lop, 0, sizeof(b->lop)); /* Allocate LOP table */ for (i = 0; i < lops; i++) { - b->lop[i] = dma_alloc_coherent(dev, CIO2_PAGE_SIZE, + b->lop[i] = dma_alloc_coherent(dev, PAGE_SIZE, &b->lop_bus_addr[i], GFP_KERNEL); if (!b->lop[i]) goto fail; @@ -873,23 +863,22 @@ static int cio2_vb2_buf_init(struct vb2_buffer *vb) b->offset = sg->sgl->offset; i = j = 0; - for_each_sg_dma_page (sg->sgl, &sg_iter, sg->nents, 0) { + for_each_sg_dma_page(sg->sgl, &sg_iter, sg->nents, 0) { if (!pages--) break; - b->lop[i][j] = sg_page_iter_dma_address(&sg_iter) >> PAGE_SHIFT; + b->lop[i][j] = PFN_DOWN(sg_page_iter_dma_address(&sg_iter)); j++; - if (j == entries_per_page) { + if (j == CIO2_LOP_ENTRIES) { i++; j = 0; } } - b->lop[i][j] = cio2->dummy_page_bus_addr >> PAGE_SHIFT; + b->lop[i][j] = PFN_DOWN(cio2->dummy_page_bus_addr); return 0; fail: - for (i--; i >= 0; i--) - dma_free_coherent(dev, CIO2_PAGE_SIZE, - b->lop[i], b->lop_bus_addr[i]); + while (i--) + dma_free_coherent(dev, PAGE_SIZE, b->lop[i], b->lop_bus_addr[i]); return -ENOMEM; } @@ -979,7 +968,7 @@ static void cio2_vb2_buf_cleanup(struct vb2_buffer *vb) /* Free LOP table */ for (i = 0; i < CIO2_MAX_LOPS; i++) { if (b->lop[i]) - dma_free_coherent(&cio2->pci_dev->dev, CIO2_PAGE_SIZE, + dma_free_coherent(&cio2->pci_dev->dev, PAGE_SIZE, b->lop[i], b->lop_bus_addr[i]); } } @@ -1633,7 +1622,7 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) if (r) { dev_err(&cio2->pci_dev->dev, "failed to initialize videobuf2 queue (%d)\n", r); - goto fail_vbq; + goto fail_subdev; } /* Initialize vdev */ @@ -1664,10 +1653,8 @@ static int cio2_queue_init(struct cio2_device *cio2, struct cio2_queue *q) return 0; fail_link: - video_unregister_device(&q->vdev); + vb2_video_unregister_device(&q->vdev); fail_vdev: - vb2_queue_release(vbq); -fail_vbq: v4l2_device_unregister_subdev(subdev); fail_subdev: media_entity_cleanup(&vdev->entity); @@ -1683,9 +1670,8 @@ fail_fbpt: static void cio2_queue_exit(struct cio2_device *cio2, struct cio2_queue *q) { - video_unregister_device(&q->vdev); + vb2_video_unregister_device(&q->vdev); media_entity_cleanup(&q->vdev.entity); - vb2_queue_release(&q->vbq); v4l2_device_unregister_subdev(&q->subdev); media_entity_cleanup(&q->subdev.entity); cio2_fbpt_exit(q, &cio2->pci_dev->dev); @@ -1721,29 +1707,10 @@ static void cio2_queues_exit(struct cio2_device *cio2) /**************** PCI interface ****************/ -static int cio2_pci_config_setup(struct pci_dev *dev) -{ - u16 pci_command; - int r = pci_enable_msi(dev); - - if (r) { - dev_err(&dev->dev, "failed to enable MSI (%d)\n", r); - return r; - } - - pci_read_config_word(dev, PCI_COMMAND, &pci_command); - pci_command |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | - PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(dev, PCI_COMMAND, pci_command); - - return 0; -} - static int cio2_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { struct cio2_device *cio2; - void __iomem *const *iomap; int r; cio2 = devm_kzalloc(&pci_dev->dev, sizeof(*cio2), GFP_KERNEL); @@ -1766,13 +1733,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, return -ENODEV; } - iomap = pcim_iomap_table(pci_dev); - if (!iomap) { - dev_err(&pci_dev->dev, "failed to iomap table\n"); - return -ENODEV; - } - - cio2->base = iomap[CIO2_PCI_BAR]; + cio2->base = pcim_iomap_table(pci_dev)[CIO2_PCI_BAR]; pci_set_drvdata(pci_dev, cio2); @@ -1784,9 +1745,11 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, return -ENODEV; } - r = cio2_pci_config_setup(pci_dev); - if (r) - return -ENODEV; + r = pci_enable_msi(pci_dev); + if (r) { + dev_err(&pci_dev->dev, "failed to enable MSI (%d)\n", r); + return r; + } r = cio2_fbpt_init_dummy(cio2); if (r) @@ -2012,8 +1975,8 @@ static int __maybe_unused cio2_suspend(struct device *dev) static int __maybe_unused cio2_resume(struct device *dev) { struct cio2_device *cio2 = dev_get_drvdata(dev); - int r = 0; struct cio2_queue *q = cio2->cur_queue; + int r; dev_dbg(dev, "cio2 resume\n"); if (!cio2->streaming) @@ -2040,7 +2003,7 @@ static const struct dev_pm_ops cio2_pm_ops = { static const struct pci_device_id cio2_pci_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, CIO2_PCI_ID) }, - { 0 } + { } }; MODULE_DEVICE_TABLE(pci, cio2_pci_id_table); diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.h b/drivers/media/pci/intel/ipu3/ipu3-cio2.h index 7caab9b8c2b9..549b08f88f0c 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.h +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.h @@ -4,6 +4,8 @@ #ifndef __IPU3_CIO2_H #define __IPU3_CIO2_H +#include <linux/types.h> + #define CIO2_NAME "ipu3-cio2" #define CIO2_DEVICE_NAME "Intel IPU3 CIO2" #define CIO2_ENTITY_NAME "ipu3-csi2" @@ -17,6 +19,7 @@ /* 32MB = 8xFBPT_entry */ #define CIO2_MAX_LOPS 8 #define CIO2_MAX_BUFFERS (PAGE_SIZE / 16 / CIO2_MAX_LOPS) +#define CIO2_LOP_ENTRIES (PAGE_SIZE / sizeof(u32)) #define CIO2_PAD_SINK 0 #define CIO2_PAD_SOURCE 1 @@ -389,7 +392,6 @@ struct cio2_device { sizeof(struct cio2_fbpt_entry)) #define CIO2_FBPT_SUBENTRY_UNIT 4 -#define CIO2_PAGE_SIZE 4096 /* cio2 fbpt first_entry ctrl status */ #define CIO2_FBPT_CTRL_VALID BIT(0) diff --git a/drivers/media/pci/mantis/mantis_dma.c b/drivers/media/pci/mantis/mantis_dma.c index affc5977387f..4df571ff272b 100644 --- a/drivers/media/pci/mantis/mantis_dma.c +++ b/drivers/media/pci/mantis/mantis_dma.c @@ -200,9 +200,9 @@ void mantis_dma_stop(struct mantis_pci *mantis) } -void mantis_dma_xfer(unsigned long data) +void mantis_dma_xfer(struct tasklet_struct *t) { - struct mantis_pci *mantis = (struct mantis_pci *) data; + struct mantis_pci *mantis = from_tasklet(mantis, t, tasklet); struct mantis_hwconfig *config = mantis->hwconfig; while (mantis->last_block != mantis->busy_block) { diff --git a/drivers/media/pci/mantis/mantis_dma.h b/drivers/media/pci/mantis/mantis_dma.h index 421663443d62..37da982c9c29 100644 --- a/drivers/media/pci/mantis/mantis_dma.h +++ b/drivers/media/pci/mantis/mantis_dma.h @@ -13,6 +13,6 @@ extern int mantis_dma_init(struct mantis_pci *mantis); extern int mantis_dma_exit(struct mantis_pci *mantis); extern void mantis_dma_start(struct mantis_pci *mantis); extern void mantis_dma_stop(struct mantis_pci *mantis); -extern void mantis_dma_xfer(unsigned long data); +extern void mantis_dma_xfer(struct tasklet_struct *t); #endif /* __MANTIS_DMA_H */ diff --git a/drivers/media/pci/mantis/mantis_dvb.c b/drivers/media/pci/mantis/mantis_dvb.c index 2da94be5b373..c7ba4a76e608 100644 --- a/drivers/media/pci/mantis/mantis_dvb.c +++ b/drivers/media/pci/mantis/mantis_dvb.c @@ -205,7 +205,7 @@ int mantis_dvb_init(struct mantis_pci *mantis) } dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx); - tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis); + tasklet_setup(&mantis->tasklet, mantis_dma_xfer); tasklet_disable(&mantis->tasklet); if (mantis->hwconfig) { result = config->frontend_init(mantis, mantis->fe); diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c index 7fb3b1853b87..8944e4bd4638 100644 --- a/drivers/media/pci/meye/meye.c +++ b/drivers/media/pci/meye/meye.c @@ -952,7 +952,7 @@ static int meyeioc_sync(struct file *file, void *fh, int *i) mutex_unlock(&meye.lock); return -EINTR; } - /* fall through */ + fallthrough; case MEYE_BUF_DONE: meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; if (kfifo_out_locked(&meye.doneq, (unsigned char *)&unused, diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c index 80a7c41baa90..6f3125c2d097 100644 --- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c +++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c @@ -1016,8 +1016,6 @@ static struct pci_driver netup_unidvb_pci_driver = { .id_table = netup_unidvb_pci_tbl, .probe = netup_unidvb_initdev, .remove = netup_unidvb_finidev, - .suspend = NULL, - .resume = NULL, }; module_pci_driver(netup_unidvb_pci_driver); diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c index af15ca1c501b..f9f94f47d76b 100644 --- a/drivers/media/pci/ngene/ngene-core.c +++ b/drivers/media/pci/ngene/ngene-core.c @@ -50,9 +50,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); /* nGene interrupt handler **************************************************/ /****************************************************************************/ -static void event_tasklet(unsigned long data) +static void event_tasklet(struct tasklet_struct *t) { - struct ngene *dev = (struct ngene *)data; + struct ngene *dev = from_tasklet(dev, t, event_tasklet); while (dev->EventQueueReadIndex != dev->EventQueueWriteIndex) { struct EVENT_BUFFER Event = @@ -68,9 +68,9 @@ static void event_tasklet(unsigned long data) } } -static void demux_tasklet(unsigned long data) +static void demux_tasklet(struct tasklet_struct *t) { - struct ngene_channel *chan = (struct ngene_channel *)data; + struct ngene_channel *chan = from_tasklet(chan, t, demux_tasklet); struct device *pdev = &chan->dev->pci_dev->dev; struct SBufferHeader *Cur = chan->nextBuffer; @@ -1181,7 +1181,7 @@ static void ngene_init(struct ngene *dev) struct device *pdev = &dev->pci_dev->dev; int i; - tasklet_init(&dev->event_tasklet, event_tasklet, (unsigned long)dev); + tasklet_setup(&dev->event_tasklet, event_tasklet); memset_io(dev->iomem + 0xc000, 0x00, 0x220); memset_io(dev->iomem + 0xc400, 0x00, 0x100); @@ -1445,7 +1445,7 @@ static int init_channel(struct ngene_channel *chan) struct ngene_info *ni = dev->card_info; int io = ni->io_type[nr]; - tasklet_init(&chan->demux_tasklet, demux_tasklet, (unsigned long)chan); + tasklet_setup(&chan->demux_tasklet, demux_tasklet); chan->users = 0; chan->type = io; chan->mode = chan->type; /* for now only one mode */ diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c index 544ca57eee75..7a1fb067b0e0 100644 --- a/drivers/media/pci/saa7134/saa7134-alsa.c +++ b/drivers/media/pci/saa7134/saa7134-alsa.c @@ -252,7 +252,8 @@ static int snd_card_saa7134_capture_trigger(struct snd_pcm_substream * substream return err; } -static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages) +static int saa7134_alsa_dma_init(struct saa7134_dev *dev, + unsigned long nr_pages) { struct saa7134_dmasound *dma = &dev->dmasound; struct page *pg; @@ -260,11 +261,11 @@ static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages) dma->vaddr = vmalloc_32(nr_pages << PAGE_SHIFT); if (NULL == dma->vaddr) { - pr_debug("vmalloc_32(%d pages) failed\n", nr_pages); + pr_debug("vmalloc_32(%lu pages) failed\n", nr_pages); return -ENOMEM; } - pr_debug("vmalloc is at addr %p, size=%d\n", + pr_debug("vmalloc is at addr %p, size=%lu\n", dma->vaddr, nr_pages << PAGE_SHIFT); memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT); @@ -297,7 +298,7 @@ static int saa7134_alsa_dma_map(struct saa7134_dev *dev) struct saa7134_dmasound *dma = &dev->dmasound; dma->sglen = dma_map_sg(&dev->pci->dev, dma->sglist, - dma->nr_pages, PCI_DMA_FROMDEVICE); + dma->nr_pages, DMA_FROM_DEVICE); if (0 == dma->sglen) { pr_warn("%s: saa7134_alsa_map_sg failed\n", __func__); @@ -313,7 +314,7 @@ static int saa7134_alsa_dma_unmap(struct saa7134_dev *dev) if (!dma->sglen) return 0; - dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->sglen, PCI_DMA_FROMDEVICE); + dma_unmap_sg(&dev->pci->dev, dma->sglist, dma->nr_pages, DMA_FROM_DEVICE); dma->sglen = 0; return 0; } diff --git a/drivers/media/pci/saa7134/saa7134-cards.c b/drivers/media/pci/saa7134/saa7134-cards.c index c1937c33c33d..ce449c941171 100644 --- a/drivers/media/pci/saa7134/saa7134-cards.c +++ b/drivers/media/pci/saa7134/saa7134-cards.c @@ -7812,7 +7812,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) dev->name, saa7134_boards[dev->board].name); break; } - /* fall-through */ + fallthrough; case SAA7134_BOARD_VIDEOMATE_DVBT_300: case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: case SAA7134_BOARD_ASUS_EUROPA_HYBRID: @@ -7870,7 +7870,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) break; case SAA7134_BOARD_HAUPPAUGE_HVR1110: hauppauge_eeprom(dev, dev->eedata+0x80); - /* fall-through */ + fallthrough; case SAA7134_BOARD_PINNACLE_PCTV_310i: case SAA7134_BOARD_KWORLD_DVBT_210: case SAA7134_BOARD_TEVION_DVBT_220RF: diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c index e4623ed2f831..391572a6ec76 100644 --- a/drivers/media/pci/saa7134/saa7134-core.c +++ b/drivers/media/pci/saa7134/saa7134-core.c @@ -359,14 +359,12 @@ void saa7134_stop_streaming(struct saa7134_dev *dev, struct saa7134_dmaqueue *q) struct saa7134_buf *tmp; spin_lock_irqsave(&dev->slock, flags); - if (!list_empty(&q->queue)) { - list_for_each_safe(pos, n, &q->queue) { - tmp = list_entry(pos, struct saa7134_buf, entry); - vb2_buffer_done(&tmp->vb2.vb2_buf, - VB2_BUF_STATE_ERROR); - list_del(pos); - tmp = NULL; - } + list_for_each_safe(pos, n, &q->queue) { + tmp = list_entry(pos, struct saa7134_buf, entry); + vb2_buffer_done(&tmp->vb2.vb2_buf, + VB2_BUF_STATE_ERROR); + list_del(pos); + tmp = NULL; } spin_unlock_irqrestore(&dev->slock, flags); saa7134_buffer_timeout(&q->timeout); /* also calls del_timer(&q->timeout) */ @@ -965,21 +963,21 @@ static void saa7134_unregister_video(struct saa7134_dev *dev) if (dev->video_dev) { if (video_is_registered(dev->video_dev)) - video_unregister_device(dev->video_dev); + vb2_video_unregister_device(dev->video_dev); else video_device_release(dev->video_dev); dev->video_dev = NULL; } if (dev->vbi_dev) { if (video_is_registered(dev->vbi_dev)) - video_unregister_device(dev->vbi_dev); + vb2_video_unregister_device(dev->vbi_dev); else video_device_release(dev->vbi_dev); dev->vbi_dev = NULL; } if (dev->radio_dev) { if (video_is_registered(dev->radio_dev)) - video_unregister_device(dev->radio_dev); + vb2_video_unregister_device(dev->radio_dev); else video_device_release(dev->radio_dev); dev->radio_dev = NULL; @@ -1370,11 +1368,9 @@ static void saa7134_finidev(struct pci_dev *pci_dev) kfree(dev); } -#ifdef CONFIG_PM - /* resends a current buffer in queue after resume */ -static int saa7134_buffer_requeue(struct saa7134_dev *dev, - struct saa7134_dmaqueue *q) +static int __maybe_unused saa7134_buffer_requeue(struct saa7134_dev *dev, + struct saa7134_dmaqueue *q) { struct saa7134_buf *buf, *next; @@ -1397,8 +1393,9 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev, return 0; } -static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) +static int __maybe_unused saa7134_suspend(struct device *dev_d) { + struct pci_dev *pci_dev = to_pci_dev(dev_d); struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); @@ -1428,21 +1425,15 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) if (dev->remote && dev->remote->dev->users) saa7134_ir_close(dev->remote->dev); - pci_save_state(pci_dev); - pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state)); - return 0; } -static int saa7134_resume(struct pci_dev *pci_dev) +static int __maybe_unused saa7134_resume(struct device *dev_d) { - struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); + struct v4l2_device *v4l2_dev = dev_get_drvdata(dev_d); struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); unsigned long flags; - pci_set_power_state(pci_dev, PCI_D0); - pci_restore_state(pci_dev); - /* Do things that are done in saa7134_initdev , except of initializing memory structures.*/ @@ -1490,7 +1481,6 @@ static int saa7134_resume(struct pci_dev *pci_dev) return 0; } -#endif /* ----------------------------------------------------------- */ @@ -1522,15 +1512,14 @@ EXPORT_SYMBOL(saa7134_ts_unregister); /* ----------------------------------------------------------- */ +static SIMPLE_DEV_PM_OPS(saa7134_pm_ops, saa7134_suspend, saa7134_resume); + static struct pci_driver saa7134_pci_driver = { .name = "saa7134", .id_table = saa7134_pci_tbl, .probe = saa7134_initdev, .remove = saa7134_finidev, -#ifdef CONFIG_PM - .suspend = saa7134_suspend, - .resume = saa7134_resume -#endif + .driver.pm = &saa7134_pm_ops, }; static int __init saa7134_init(void) diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index 8ad7879bd840..39e3c7f8c5b4 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c @@ -314,8 +314,7 @@ static int empress_fini(struct saa7134_dev *dev) if (NULL == dev->empress_dev) return 0; flush_work(&dev->empress_workqueue); - video_unregister_device(dev->empress_dev); - vb2_queue_release(&dev->empress_vbq); + vb2_video_unregister_device(dev->empress_dev); v4l2_ctrl_handler_free(&dev->empress_ctrl_handler); dev->empress_dev = NULL; return 0; diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c index e1b034663958..f319edb39c0e 100644 --- a/drivers/media/pci/saa7134/saa7134-go7007.c +++ b/drivers/media/pci/saa7134/saa7134-go7007.c @@ -493,7 +493,7 @@ static int saa7134_go7007_fini(struct saa7134_dev *dev) free_page((unsigned long)saa->bottom); v4l2_device_unregister_subdev(&saa->sd); kfree(saa); - video_unregister_device(&go->vdev); + vb2_video_unregister_device(&go->vdev); v4l2_device_put(&go->v4l2_dev); dev->empress_dev = NULL; diff --git a/drivers/media/pci/saa7134/saa7134-tvaudio.c b/drivers/media/pci/saa7134/saa7134-tvaudio.c index 79e1afb71075..5cc4ef21f9d3 100644 --- a/drivers/media/pci/saa7134/saa7134-tvaudio.c +++ b/drivers/media/pci/saa7134/saa7134-tvaudio.c @@ -683,7 +683,8 @@ int saa_dsp_writel(struct saa7134_dev *dev, int reg, u32 value) { int err; - audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n", reg << 2, value); + audio_dbg(2, "dsp write reg 0x%x = 0x%06x\n", + (reg << 2) & 0xffffffff, value); err = saa_dsp_wait_bit(dev,SAA7135_DSP_RWSTATE_WRR); if (err < 0) return err; diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c index a8ac94fadc14..9a6a6b68f8e3 100644 --- a/drivers/media/pci/saa7134/saa7134-video.c +++ b/drivers/media/pci/saa7134/saa7134-video.c @@ -2154,9 +2154,7 @@ int saa7134_video_init1(struct saa7134_dev *dev) void saa7134_video_fini(struct saa7134_dev *dev) { /* free stuff */ - vb2_queue_release(&dev->video_vbq); saa7134_pgtable_free(dev->pci, &dev->video_q.pt); - vb2_queue_release(&dev->vbi_vbq); saa7134_pgtable_free(dev->pci, &dev->vbi_q.pt); v4l2_ctrl_handler_free(&dev->ctrl_handler); if (card_has_radio(dev)) diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h index 77c325e64a97..d29499cd7370 100644 --- a/drivers/media/pci/saa7134/saa7134.h +++ b/drivers/media/pci/saa7134/saa7134.h @@ -509,7 +509,7 @@ struct saa7134_dmasound { void *vaddr; struct scatterlist *sglist; int sglen; - int nr_pages; + unsigned long nr_pages; unsigned int dma_blk; unsigned int read_offset; unsigned int read_count; diff --git a/drivers/media/pci/saa7164/saa7164-buffer.c b/drivers/media/pci/saa7164/saa7164-buffer.c index 289cb901985b..245d9db280aa 100644 --- a/drivers/media/pci/saa7164/saa7164-buffer.c +++ b/drivers/media/pci/saa7164/saa7164-buffer.c @@ -250,15 +250,14 @@ int saa7164_buffer_cfg_port(struct saa7164_port *port) list_for_each_safe(c, n, &port->dmaqueue.list) { buf = list_entry(c, struct saa7164_buffer, list); - if (buf->flags != SAA7164_BUFFER_FREE) - BUG(); + BUG_ON(buf->flags != SAA7164_BUFFER_FREE); /* Place the buffer in the h/w queue */ saa7164_buffer_activate(buf, i); /* Don't exceed the device maximum # bufs */ - if (i++ > port->hwcfg.buffercount) - BUG(); + BUG_ON(i > port->hwcfg.buffercount); + i++; } mutex_unlock(&port->dmaqueue_lock); @@ -302,4 +301,3 @@ void saa7164_buffer_dealloc_user(struct saa7164_user_buffer *buf) kfree(buf); } - diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c index 4b637891b79a..6c08b77bfd47 100644 --- a/drivers/media/pci/saa7164/saa7164-core.c +++ b/drivers/media/pci/saa7164/saa7164-core.c @@ -575,8 +575,8 @@ static irqreturn_t saa7164_irq_ts(struct saa7164_port *port) /* Find the current write point from the hardware */ wp = saa7164_readl(port->bufcounter); - if (wp > (port->hwcfg.buffercount - 1)) - BUG(); + + BUG_ON(wp > (port->hwcfg.buffercount - 1)); /* Find the previous buffer to the current write point */ if (wp == 0) @@ -588,8 +588,8 @@ static irqreturn_t saa7164_irq_ts(struct saa7164_port *port) /* TODO: turn this into a worker thread */ list_for_each_safe(c, n, &port->dmaqueue.list) { buf = list_entry(c, struct saa7164_buffer, list); - if (i++ > port->hwcfg.buffercount) - BUG(); + BUG_ON(i > port->hwcfg.buffercount); + i++; if (buf->idx == rp) { /* Found the buffer, deal with it */ @@ -894,8 +894,7 @@ static int saa7164_port_init(struct saa7164_dev *dev, int portnr) { struct saa7164_port *port = NULL; - if ((portnr < 0) || (portnr >= SAA7164_MAX_PORTS)) - BUG(); + BUG_ON((portnr < 0) || (portnr >= SAA7164_MAX_PORTS)); port = &dev->ports[portnr]; @@ -1563,4 +1562,3 @@ static void __exit saa7164_fini(void) module_init(saa7164_init); module_exit(saa7164_fini); - diff --git a/drivers/media/pci/saa7164/saa7164-dvb.c b/drivers/media/pci/saa7164/saa7164-dvb.c index bf8c2bb8852e..24421c116b0b 100644 --- a/drivers/media/pci/saa7164/saa7164-dvb.c +++ b/drivers/media/pci/saa7164/saa7164-dvb.c @@ -337,8 +337,7 @@ static int dvb_register(struct saa7164_port *port) dprintk(DBGLVL_DVB, "%s(port=%d)\n", __func__, port->nr); - if (port->type != SAA7164_MPEG_DVB) - BUG(); + BUG_ON(port->type != SAA7164_MPEG_DVB); /* Sanity check that the PCI configuration space is active */ if (port->hwcfg.BARLocation == 0) { @@ -479,8 +478,7 @@ int saa7164_dvb_unregister(struct saa7164_port *port) dprintk(DBGLVL_DVB, "%s()\n", __func__); - if (port->type != SAA7164_MPEG_DVB) - BUG(); + BUG_ON(port->type != SAA7164_MPEG_DVB); /* Remove any allocated buffers */ mutex_lock(&port->dmaqueue_lock); @@ -740,4 +738,3 @@ frontend_detach: printk(KERN_ERR "%s() Frontend/I2C initialization failed\n", __func__); return -1; } - diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c index 49d61a64c8cb..cb2e09f0841d 100644 --- a/drivers/media/pci/saa7164/saa7164-vbi.c +++ b/drivers/media/pci/saa7164/saa7164-vbi.c @@ -703,8 +703,7 @@ int saa7164_vbi_register(struct saa7164_port *port) dprintk(DBGLVL_VBI, "%s()\n", __func__); - if (port->type != SAA7164_MPEG_VBI) - BUG(); + BUG_ON(port->type != SAA7164_MPEG_VBI); /* Sanity check that the PCI configuration space is active */ if (port->hwcfg.BARLocation == 0) { @@ -756,8 +755,7 @@ void saa7164_vbi_unregister(struct saa7164_port *port) dprintk(DBGLVL_VBI, "%s(port=%d)\n", __func__, port->nr); - if (port->type != SAA7164_MPEG_VBI) - BUG(); + BUG_ON(port->type != SAA7164_MPEG_VBI); if (port->v4l_device) { if (port->v4l_device->minor != -1) diff --git a/drivers/media/pci/smipcie/smipcie-ir.c b/drivers/media/pci/smipcie/smipcie-ir.c index 9445d792bfc9..e6b74e161a05 100644 --- a/drivers/media/pci/smipcie/smipcie-ir.c +++ b/drivers/media/pci/smipcie/smipcie-ir.c @@ -87,8 +87,7 @@ static void smi_ir_decode(struct smi_rc *ir) struct ir_raw_event rawir = {}; rawir.pulse = 0; - rawir.duration = US_TO_NS(SMI_SAMPLE_PERIOD * - SMI_SAMPLE_IDLEMIN); + rawir.duration = SMI_SAMPLE_PERIOD * SMI_SAMPLE_IDLEMIN; ir_raw_event_store_with_filter(rc_dev, &rawir); smi_set(IR_Init_Reg, rbIRhighidle); } @@ -151,8 +150,8 @@ int smi_ir_init(struct smi_dev *dev) rc_dev->dev.parent = &dev->pci_dev->dev; rc_dev->map_name = dev->info->rc_map; - rc_dev->timeout = MS_TO_NS(100); - rc_dev->rx_resolution = US_TO_NS(SMI_SAMPLE_PERIOD); + rc_dev->timeout = MS_TO_US(100); + rc_dev->rx_resolution = SMI_SAMPLE_PERIOD; ir->rc_dev = rc_dev; ir->dev = dev; diff --git a/drivers/media/pci/smipcie/smipcie-main.c b/drivers/media/pci/smipcie/smipcie-main.c index 9ca0fc3e6f80..e7604b7ecc8d 100644 --- a/drivers/media/pci/smipcie/smipcie-main.c +++ b/drivers/media/pci/smipcie/smipcie-main.c @@ -280,9 +280,9 @@ static void smi_port_clearInterrupt(struct smi_port *port) } /* tasklet handler: DMA data to dmx.*/ -static void smi_dma_xfer(unsigned long data) +static void smi_dma_xfer(struct tasklet_struct *t) { - struct smi_port *port = (struct smi_port *) data; + struct smi_port *port = from_tasklet(port, t, tasklet); struct smi_dev *dev = port->dev; u32 intr_status, finishedData, dmaManagement; u8 dmaChan0State, dmaChan1State; @@ -422,7 +422,7 @@ static int smi_port_init(struct smi_port *port, int dmaChanUsed) } smi_port_disableInterrupt(port); - tasklet_init(&port->tasklet, smi_dma_xfer, (unsigned long)port); + tasklet_setup(&port->tasklet, smi_dma_xfer); tasklet_disable(&port->tasklet); port->enable = 1; return 0; diff --git a/drivers/media/pci/solo6x10/solo6x10-core.c b/drivers/media/pci/solo6x10/solo6x10-core.c index c6e0090f27e8..d497afc7e7b7 100644 --- a/drivers/media/pci/solo6x10/solo6x10-core.c +++ b/drivers/media/pci/solo6x10/solo6x10-core.c @@ -503,7 +503,7 @@ static int solo_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) default: dev_warn(&pdev->dev, "Invalid chip_id 0x%02x, assuming 4 ch\n", chip_id); - /* fall through */ + fallthrough; case 5: solo_dev->nr_chans = 4; solo_dev->nr_ext = 1; diff --git a/drivers/media/pci/solo6x10/solo6x10-i2c.c b/drivers/media/pci/solo6x10/solo6x10-i2c.c index f86f12fa6350..7db785e9c997 100644 --- a/drivers/media/pci/solo6x10/solo6x10-i2c.c +++ b/drivers/media/pci/solo6x10/solo6x10-i2c.c @@ -183,7 +183,7 @@ int solo_i2c_isr(struct solo_dev *solo_dev) } solo_dev->i2c_state = IIC_STATE_WRITE; - /* fall through */ + fallthrough; case IIC_STATE_WRITE: ret = solo_i2c_handle_write(solo_dev); break; diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c index 0fdb0fd6e764..336df65c8af1 100644 --- a/drivers/media/pci/sta2x11/sta2x11_vip.c +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c @@ -1101,12 +1101,11 @@ static int sta2x11_vip_init_one(struct pci_dev *pdev, vunreg: video_set_drvdata(&vip->video_dev, NULL); vrelease: - video_unregister_device(&vip->video_dev); + vb2_video_unregister_device(&vip->video_dev); free_irq(pdev->irq, vip); release_buf: pci_disable_msi(pdev); unmap: - vb2_queue_release(&vip->vb_vidq); pci_iounmap(pdev, vip->iomem); release: pci_release_regions(pdev); @@ -1146,10 +1145,9 @@ static void sta2x11_vip_remove_one(struct pci_dev *pdev) sta2x11_vip_clear_register(vip); video_set_drvdata(&vip->video_dev, NULL); - video_unregister_device(&vip->video_dev); + vb2_video_unregister_device(&vip->video_dev); free_irq(pdev->irq, vip); pci_disable_msi(pdev); - vb2_queue_release(&vip->vb_vidq); pci_iounmap(pdev, vip->iomem); pci_release_regions(pdev); diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c index bf36b1e22b63..2f7069e19b78 100644 --- a/drivers/media/pci/ttpci/av7110.c +++ b/drivers/media/pci/ttpci/av7110.c @@ -357,9 +357,9 @@ static inline void start_debi_dma(struct av7110 *av7110, int dir, irdebi(av7110, DEBISWAB, addr, 0, len); } -static void debiirq(unsigned long cookie) +static void debiirq(struct tasklet_struct *t) { - struct av7110 *av7110 = (struct av7110 *)cookie; + struct av7110 *av7110 = from_tasklet(av7110, t, debi_tasklet); int type = av7110->debitype; int handle = (type >> 8) & 0x1f; unsigned int xfer = 0; @@ -458,9 +458,9 @@ debi_done: } /* irq from av7110 firmware writing the mailbox register in the DPRAM */ -static void gpioirq(unsigned long cookie) +static void gpioirq(struct tasklet_struct *t) { - struct av7110 *av7110 = (struct av7110 *)cookie; + struct av7110 *av7110 = from_tasklet(av7110, t, gpio_tasklet); u32 rxbuf, txbuf; int len; @@ -637,7 +637,7 @@ static void gpioirq(unsigned long cookie) iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2); break; } - /* fall through */ + fallthrough; case DATA_TS_RECORD: case DATA_PES_RECORD: @@ -1230,9 +1230,9 @@ static int budget_stop_feed(struct dvb_demux_feed *feed) return status; } -static void vpeirq(unsigned long cookie) +static void vpeirq(struct tasklet_struct *t) { - struct av7110 *budget = (struct av7110 *)cookie; + struct av7110 *budget = from_tasklet(budget, t, vpe_tasklet); u8 *mem = (u8 *) (budget->grabbing); u32 olddma = budget->ttbp; u32 newdma = saa7146_read(budget->dev, PCI_VDP3); @@ -2176,7 +2176,7 @@ static int frontend_init(struct av7110 *av7110) break; } } - /* fall-thru */ + fallthrough; case 0x0008: // Hauppauge/TT DVB-T // Grundig 29504-401 @@ -2518,7 +2518,7 @@ static int av7110_attach(struct saa7146_dev* dev, saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT << 16) | TS_WIDTH); saa7146_write(dev, MC2, MASK_04 | MASK_20); - tasklet_init(&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110); + tasklet_setup(&av7110->vpe_tasklet, vpeirq); } else if (budgetpatch) { spin_lock_init(&av7110->feedlock1); @@ -2599,7 +2599,7 @@ static int av7110_attach(struct saa7146_dev* dev, saa7146_write(dev, MC1, (MASK_13 | MASK_29)); /* end of budgetpatch register initialization */ - tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110); + tasklet_setup(&av7110->vpe_tasklet, vpeirq); } else { saa7146_write(dev, PCI_BT_V1, 0x1c00101f); saa7146_write(dev, BCS_CTRL, 0x80400040); @@ -2614,8 +2614,8 @@ static int av7110_attach(struct saa7146_dev* dev, saa7146_write(dev, GPIO_CTRL, 0x000000); } - tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110); - tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110); + tasklet_setup(&av7110->debi_tasklet, debiirq); + tasklet_setup(&av7110->gpio_tasklet, gpioirq); mutex_init(&av7110->pid_mutex); diff --git a/drivers/media/pci/ttpci/av7110_hw.c b/drivers/media/pci/ttpci/av7110_hw.c index e8a8ec5405e2..93ca31e38ddd 100644 --- a/drivers/media/pci/ttpci/av7110_hw.c +++ b/drivers/media/pci/ttpci/av7110_hw.c @@ -1107,7 +1107,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc) break; case OSD_SetRow: dc->y1 = dc->y0; - /* fall through */ + fallthrough; case OSD_SetBlock: ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data); break; diff --git a/drivers/media/pci/ttpci/av7110_ipack.c b/drivers/media/pci/ttpci/av7110_ipack.c index ec528fae7333..30330ed01ce8 100644 --- a/drivers/media/pci/ttpci/av7110_ipack.c +++ b/drivers/media/pci/ttpci/av7110_ipack.c @@ -182,7 +182,7 @@ int av7110_ipack_instant_repack (const u8 *buf, int count, struct ipack *p) case DSM_CC_STREAM : case ISO13522_STREAM: p->done = 1; - /* fall through */ + fallthrough; case PRIVATE_STREAM1: case VIDEO_STREAM_S ... VIDEO_STREAM_E: case AUDIO_STREAM_S ... AUDIO_STREAM_E: diff --git a/drivers/media/pci/ttpci/av7110_v4l.c b/drivers/media/pci/ttpci/av7110_v4l.c index cabe006658dd..c89f536f699c 100644 --- a/drivers/media/pci/ttpci/av7110_v4l.c +++ b/drivers/media/pci/ttpci/av7110_v4l.c @@ -160,9 +160,9 @@ static int ves1820_set_tv_freq(struct saa7146_dev *dev, u32 freq) buf[1] = div & 0xff; buf[2] = 0x8e; - if (freq < (u32) (16 * 168.25)) + if (freq < 16U * 16825 / 100) config = 0xa0; - else if (freq < (u32) (16 * 447.25)) + else if (freq < 16U * 44725 / 100) config = 0x90; else config = 0x30; diff --git a/drivers/media/pci/ttpci/budget-av.c b/drivers/media/pci/ttpci/budget-av.c index 38cac508bd72..3cb83005cf09 100644 --- a/drivers/media/pci/ttpci/budget-av.c +++ b/drivers/media/pci/ttpci/budget-av.c @@ -1226,7 +1226,7 @@ static void frontend_init(struct budget_av *budget_av) * but so far it has been only confirmed for this type */ budget_av->reinitialise_demod = 1; - /* fall through */ + fallthrough; case SUBID_DVBS_KNC1_PLUS: case SUBID_DVBS_EASYWATCH_1: if (saa->pci->subsystem_vendor == 0x1894) { diff --git a/drivers/media/pci/ttpci/budget-ci.c b/drivers/media/pci/ttpci/budget-ci.c index 77b102b8a013..d59d18647371 100644 --- a/drivers/media/pci/ttpci/budget-ci.c +++ b/drivers/media/pci/ttpci/budget-ci.c @@ -99,9 +99,10 @@ struct budget_ci { u8 tuner_pll_address; /* used for philips_tdm1316l configs */ }; -static void msp430_ir_interrupt(unsigned long data) +static void msp430_ir_interrupt(struct tasklet_struct *t) { - struct budget_ci *budget_ci = (struct budget_ci *) data; + struct budget_ci_ir *ir = from_tasklet(ir, t, msp430_irq_tasklet); + struct budget_ci *budget_ci = container_of(ir, typeof(*budget_ci), ir); struct rc_dev *dev = budget_ci->ir.dev; u32 command = ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8; @@ -229,8 +230,7 @@ static int msp430_ir_init(struct budget_ci *budget_ci) budget_ci->ir.dev = dev; - tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt, - (unsigned long) budget_ci); + tasklet_setup(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt); SAA7146_IER_ENABLE(saa, MASK_06); saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI); @@ -348,9 +348,10 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) return 0; } -static void ciintf_interrupt(unsigned long data) +static void ciintf_interrupt(struct tasklet_struct *t) { - struct budget_ci *budget_ci = (struct budget_ci *) data; + struct budget_ci *budget_ci = from_tasklet(budget_ci, t, + ciintf_irq_tasklet); struct saa7146_dev *saa = budget_ci->budget.dev; unsigned int flags; @@ -491,7 +492,7 @@ static int ciintf_init(struct budget_ci *budget_ci) // Setup CI slot IRQ if (budget_ci->ci_irq) { - tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci); + tasklet_setup(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt); if (budget_ci->slot_status != SLOTSTATUS_NONE) { saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO); } else { diff --git a/drivers/media/pci/ttpci/budget-core.c b/drivers/media/pci/ttpci/budget-core.c index 293867b9e796..d405eea5c37f 100644 --- a/drivers/media/pci/ttpci/budget-core.c +++ b/drivers/media/pci/ttpci/budget-core.c @@ -171,9 +171,9 @@ static int budget_read_fe_status(struct dvb_frontend *fe, return ret; } -static void vpeirq(unsigned long data) +static void vpeirq(struct tasklet_struct *t) { - struct budget *budget = (struct budget *) data; + struct budget *budget = from_tasklet(budget, t, vpe_tasklet); u8 *mem = (u8 *) (budget->grabbing); u32 olddma = budget->ttbp; u32 newdma = saa7146_read(budget->dev, PCI_VDP3); @@ -519,7 +519,7 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, /* upload all */ saa7146_write(dev, GPIO_CTRL, 0x000000); - tasklet_init(&budget->vpe_tasklet, vpeirq, (unsigned long) budget); + tasklet_setup(&budget->vpe_tasklet, vpeirq); /* frontend power on */ if (bi->type != BUDGET_FS_ACTIVY) diff --git a/drivers/media/pci/ttpci/budget.c b/drivers/media/pci/ttpci/budget.c index 9c811272abfe..a88711a3ac7f 100644 --- a/drivers/media/pci/ttpci/budget.c +++ b/drivers/media/pci/ttpci/budget.c @@ -613,7 +613,7 @@ static void frontend_init(struct budget *budget) break; } } - /* fall through */ + fallthrough; case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262) { struct dvb_frontend *fe; @@ -638,7 +638,7 @@ static void frontend_init(struct budget *budget) break; } } - /* fall through */ + fallthrough; case 0x101c: { /* TT S2-1600 */ const struct stv6110x_devctl *ctl; diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c index ec1e06da7e4f..9131265c2b87 100644 --- a/drivers/media/pci/tw5864/tw5864-video.c +++ b/drivers/media/pci/tw5864/tw5864-video.c @@ -175,7 +175,7 @@ static const unsigned int intra4x4_lambda3[] = { static v4l2_std_id tw5864_get_v4l2_std(enum tw5864_vid_std std); static enum tw5864_vid_std tw5864_from_v4l2_std(v4l2_std_id v4l2_std); -static void tw5864_handle_frame_task(unsigned long data); +static void tw5864_handle_frame_task(struct tasklet_struct *t); static void tw5864_handle_frame(struct tw5864_h264_frame *frame); static void tw5864_frame_interval_set(struct tw5864_input *input); @@ -767,6 +767,9 @@ static int tw5864_enum_frameintervals(struct file *file, void *priv, fintv->type = V4L2_FRMIVAL_TYPE_STEPWISE; ret = tw5864_frameinterval_get(input, &frameinterval); + if (ret) + return ret; + fintv->stepwise.step = frameinterval; fintv->stepwise.min = frameinterval; fintv->stepwise.max = frameinterval; @@ -785,6 +788,9 @@ static int tw5864_g_parm(struct file *file, void *priv, cp->capability = V4L2_CAP_TIMEPERFRAME; ret = tw5864_frameinterval_get(input, &cp->timeperframe); + if (ret) + return ret; + cp->timeperframe.numerator *= input->frame_interval; cp->capturemode = 0; cp->readbuffers = 2; @@ -1057,8 +1063,7 @@ int tw5864_video_init(struct tw5864_dev *dev, int *video_nr) dev->irqmask |= TW5864_INTR_VLC_DONE | TW5864_INTR_TIMER; tw5864_irqmask_apply(dev); - tasklet_init(&dev->tasklet, tw5864_handle_frame_task, - (unsigned long)dev); + tasklet_setup(&dev->tasklet, tw5864_handle_frame_task); for (i = 0; i < TW5864_INPUTS; i++) { dev->inputs[i].root = dev; @@ -1178,7 +1183,6 @@ static int tw5864_video_input_init(struct tw5864_input *input, int video_nr) free_v4l2_hdl: v4l2_ctrl_handler_free(hdl); - vb2_queue_release(&input->vidq); free_mutex: mutex_destroy(&input->lock); @@ -1187,9 +1191,8 @@ free_mutex: static void tw5864_video_input_fini(struct tw5864_input *dev) { - video_unregister_device(&dev->vdev); + vb2_video_unregister_device(&dev->vdev); v4l2_ctrl_handler_free(&dev->hdl); - vb2_queue_release(&dev->vidq); } void tw5864_video_fini(struct tw5864_dev *dev) @@ -1313,9 +1316,9 @@ static int tw5864_is_motion_triggered(struct tw5864_h264_frame *frame) return detected; } -static void tw5864_handle_frame_task(unsigned long data) +static void tw5864_handle_frame_task(struct tasklet_struct *t) { - struct tw5864_dev *dev = (struct tw5864_dev *)data; + struct tw5864_dev *dev = from_tasklet(dev, t, tasklet); unsigned long flags; int batch_size = H264_BUF_CNT; |