diff options
Diffstat (limited to 'drivers/media/pci/cx25821/cx25821-video.c')
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-video.c | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index 9919a0e93f4d..41e3475efec3 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c | |||
@@ -144,26 +144,6 @@ static int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm) | |||
144 | return 0; | 144 | return 0; |
145 | } | 145 | } |
146 | 146 | ||
147 | static struct video_device *cx25821_vdev_init(struct cx25821_dev *dev, | ||
148 | struct pci_dev *pci, | ||
149 | const struct video_device *template, | ||
150 | char *type) | ||
151 | { | ||
152 | struct video_device *vfd; | ||
153 | dprintk(1, "%s()\n", __func__); | ||
154 | |||
155 | vfd = video_device_alloc(); | ||
156 | if (NULL == vfd) | ||
157 | return NULL; | ||
158 | *vfd = *template; | ||
159 | vfd->v4l2_dev = &dev->v4l2_dev; | ||
160 | vfd->release = video_device_release; | ||
161 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type, | ||
162 | cx25821_boards[dev->board].name); | ||
163 | video_set_drvdata(vfd, dev); | ||
164 | return vfd; | ||
165 | } | ||
166 | |||
167 | /* | 147 | /* |
168 | static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) | 148 | static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) |
169 | { | 149 | { |
@@ -657,7 +637,7 @@ static int video_open(struct file *file) | |||
657 | v4l2_type_names[type]); | 637 | v4l2_type_names[type]); |
658 | 638 | ||
659 | for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++) | 639 | for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++) |
660 | if (dev->channels[ch_id].video_dev == vdev) | 640 | if (&dev->channels[ch_id].vdev == vdev) |
661 | break; | 641 | break; |
662 | 642 | ||
663 | /* Can't happen */ | 643 | /* Can't happen */ |
@@ -1692,6 +1672,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { | |||
1692 | static const struct video_device cx25821_video_device = { | 1672 | static const struct video_device cx25821_video_device = { |
1693 | .name = "cx25821-video", | 1673 | .name = "cx25821-video", |
1694 | .fops = &video_fops, | 1674 | .fops = &video_fops, |
1675 | .release = video_device_release_empty, | ||
1695 | .minor = -1, | 1676 | .minor = -1, |
1696 | .ioctl_ops = &video_ioctl_ops, | 1677 | .ioctl_ops = &video_ioctl_ops, |
1697 | .tvnorms = CX25821_NORMS, | 1678 | .tvnorms = CX25821_NORMS, |
@@ -1701,22 +1682,12 @@ void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num) | |||
1701 | { | 1682 | { |
1702 | cx_clear(PCI_INT_MSK, 1); | 1683 | cx_clear(PCI_INT_MSK, 1); |
1703 | 1684 | ||
1704 | if (dev->channels[chan_num].video_dev) { | 1685 | if (video_is_registered(&dev->channels[chan_num].vdev)) { |
1705 | if (video_is_registered(dev->channels[chan_num].video_dev)) | 1686 | video_unregister_device(&dev->channels[chan_num].vdev); |
1706 | video_unregister_device( | ||
1707 | dev->channels[chan_num].video_dev); | ||
1708 | else | ||
1709 | video_device_release( | ||
1710 | dev->channels[chan_num].video_dev); | ||
1711 | |||
1712 | dev->channels[chan_num].video_dev = NULL; | ||
1713 | 1687 | ||
1714 | btcx_riscmem_free(dev->pci, | 1688 | btcx_riscmem_free(dev->pci, |
1715 | &dev->channels[chan_num].vidq.stopper); | 1689 | &dev->channels[chan_num].vidq.stopper); |
1716 | |||
1717 | pr_warn("device %d released!\n", chan_num); | ||
1718 | } | 1690 | } |
1719 | |||
1720 | } | 1691 | } |
1721 | 1692 | ||
1722 | int cx25821_video_register(struct cx25821_dev *dev) | 1693 | int cx25821_video_register(struct cx25821_dev *dev) |
@@ -1727,6 +1698,8 @@ int cx25821_video_register(struct cx25821_dev *dev) | |||
1727 | spin_lock_init(&dev->slock); | 1698 | spin_lock_init(&dev->slock); |
1728 | 1699 | ||
1729 | for (i = 0; i < VID_CHANNEL_NUM; ++i) { | 1700 | for (i = 0; i < VID_CHANNEL_NUM; ++i) { |
1701 | struct video_device *vdev = &dev->channels[i].vdev; | ||
1702 | |||
1730 | if (i == SRAM_CH08) /* audio channel */ | 1703 | if (i == SRAM_CH08) /* audio channel */ |
1731 | continue; | 1704 | continue; |
1732 | 1705 | ||
@@ -1736,7 +1709,6 @@ int cx25821_video_register(struct cx25821_dev *dev) | |||
1736 | dev->channels[i].sram_channels->dma_ctl, 0x11, 0); | 1709 | dev->channels[i].sram_channels->dma_ctl, 0x11, 0); |
1737 | 1710 | ||
1738 | dev->channels[i].sram_channels = &cx25821_sram_channels[i]; | 1711 | dev->channels[i].sram_channels = &cx25821_sram_channels[i]; |
1739 | dev->channels[i].video_dev = NULL; | ||
1740 | dev->channels[i].resources = 0; | 1712 | dev->channels[i].resources = 0; |
1741 | 1713 | ||
1742 | cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff); | 1714 | cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff); |
@@ -1753,15 +1725,16 @@ int cx25821_video_register(struct cx25821_dev *dev) | |||
1753 | init_timer(&dev->channels[i].vidq.timeout); | 1725 | init_timer(&dev->channels[i].vidq.timeout); |
1754 | 1726 | ||
1755 | /* register v4l devices */ | 1727 | /* register v4l devices */ |
1756 | dev->channels[i].video_dev = cx25821_vdev_init(dev, dev->pci, | 1728 | *vdev = cx25821_video_device; |
1757 | &cx25821_video_device, "video"); | 1729 | vdev->v4l2_dev = &dev->v4l2_dev; |
1730 | snprintf(vdev->name, sizeof(vdev->name), "%s #%d", dev->name, i); | ||
1731 | video_set_drvdata(vdev, dev); | ||
1758 | 1732 | ||
1759 | err = video_register_device(dev->channels[i].video_dev, | 1733 | err = video_register_device(vdev, VFL_TYPE_GRABBER, |
1760 | VFL_TYPE_GRABBER, video_nr[dev->nr]); | 1734 | video_nr[dev->nr]); |
1761 | 1735 | ||
1762 | if (err < 0) | 1736 | if (err < 0) |
1763 | goto fail_unreg; | 1737 | goto fail_unreg; |
1764 | |||
1765 | } | 1738 | } |
1766 | 1739 | ||
1767 | /* set PCI interrupt */ | 1740 | /* set PCI interrupt */ |
@@ -1776,6 +1749,7 @@ int cx25821_video_register(struct cx25821_dev *dev) | |||
1776 | return 0; | 1749 | return 0; |
1777 | 1750 | ||
1778 | fail_unreg: | 1751 | fail_unreg: |
1779 | cx25821_video_unregister(dev, i); | 1752 | while (i >= 0) |
1753 | cx25821_video_unregister(dev, i--); | ||
1780 | return err; | 1754 | return err; |
1781 | } | 1755 | } |