aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-01-05 07:57:31 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:32 -0500
commit6d79468dd8537530f4150e76ed9b4b63f80571c6 (patch)
treef785aeeec131c092b334e458127eb44fcf4ded2d /drivers/media/video/em28xx/em28xx-video.c
parent1a6f11e0e8db9e76ef34bc6731d5291e4df1ba37 (diff)
V4L/DVB (6951): Integrates em28xx-audio.c into em28xx kernel module
Also fixes the remaining CodingStyle issues that Lindent didn't fix. Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 1a284cb18c24..caa4757b7eb6 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1599,9 +1599,48 @@ static const struct video_device em28xx_video_template = {
1599 .current_norm = V4L2_STD_PAL, 1599 .current_norm = V4L2_STD_PAL,
1600}; 1600};
1601 1601
1602
1603/******************************** usb interface *****************************************/ 1602/******************************** usb interface *****************************************/
1604 1603
1604
1605static LIST_HEAD(em28xx_extension_devlist);
1606static DEFINE_MUTEX(em28xx_extension_devlist_lock);
1607
1608int em28xx_register_extension(struct em28xx_ops *ops)
1609{
1610 struct em28xx *h, *dev = NULL;
1611
1612 list_for_each_entry(h, &em28xx_devlist, devlist)
1613 dev = h;
1614
1615 mutex_lock(&em28xx_extension_devlist_lock);
1616 list_add_tail(&ops->next, &em28xx_extension_devlist);
1617 if (dev)
1618 ops->init(dev);
1619
1620 printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name);
1621 mutex_unlock(&em28xx_extension_devlist_lock);
1622
1623 return 0;
1624}
1625EXPORT_SYMBOL(em28xx_register_extension);
1626
1627void em28xx_unregister_extension(struct em28xx_ops *ops)
1628{
1629 struct em28xx *h, *dev = NULL;
1630
1631 list_for_each_entry(h, &em28xx_devlist, devlist)
1632 dev = h;
1633
1634 if (dev)
1635 ops->fini(dev);
1636
1637 mutex_lock(&em28xx_extension_devlist_lock);
1638 printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name);
1639 list_del(&ops->next);
1640 mutex_unlock(&em28xx_extension_devlist_lock);
1641}
1642EXPORT_SYMBOL(em28xx_unregister_extension);
1643
1605/* 1644/*
1606 * em28xx_init_dev() 1645 * em28xx_init_dev()
1607 * allocates and inits the device structs, registers i2c bus and v4l device 1646 * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1609,6 +1648,7 @@ static const struct video_device em28xx_video_template = {
1609static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, 1648static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1610 int minor) 1649 int minor)
1611{ 1650{
1651 struct em28xx_ops *ops = NULL;
1612 struct em28xx *dev = *devhandle; 1652 struct em28xx *dev = *devhandle;
1613 int retval = -ENOMEM; 1653 int retval = -ENOMEM;
1614 int errCode; 1654 int errCode;
@@ -1742,6 +1782,15 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1742 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, 1782 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN,
1743 dev->vbi_dev->minor-MINOR_VFL_TYPE_VBI_MIN); 1783 dev->vbi_dev->minor-MINOR_VFL_TYPE_VBI_MIN);
1744 1784
1785 mutex_lock(&em28xx_extension_devlist_lock);
1786 if (!list_empty(&em28xx_extension_devlist)) {
1787 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1788 if (ops->id)
1789 ops->init(dev);
1790 }
1791 }
1792 mutex_unlock(&em28xx_extension_devlist_lock);
1793
1745 return 0; 1794 return 0;
1746} 1795}
1747 1796
@@ -1862,6 +1911,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
1862static void em28xx_usb_disconnect(struct usb_interface *interface) 1911static void em28xx_usb_disconnect(struct usb_interface *interface)
1863{ 1912{
1864 struct em28xx *dev; 1913 struct em28xx *dev;
1914 struct em28xx_ops *ops = NULL;
1865 1915
1866 dev = usb_get_intfdata(interface); 1916 dev = usb_get_intfdata(interface);
1867 usb_set_intfdata(interface, NULL); 1917 usb_set_intfdata(interface, NULL);
@@ -1891,15 +1941,20 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
1891 dev->state |= DEV_DISCONNECTED; 1941 dev->state |= DEV_DISCONNECTED;
1892 em28xx_release_resources(dev); 1942 em28xx_release_resources(dev);
1893 } 1943 }
1894
1895
1896 mutex_unlock(&dev->lock); 1944 mutex_unlock(&dev->lock);
1897 1945
1946 mutex_lock(&em28xx_extension_devlist_lock);
1947 if (!list_empty(&em28xx_extension_devlist)) {
1948 list_for_each_entry(ops, &em28xx_extension_devlist, next) {
1949 ops->fini(dev);
1950 }
1951 }
1952 mutex_unlock(&em28xx_extension_devlist_lock);
1953
1898 if (!dev->users) { 1954 if (!dev->users) {
1899 kfree(dev->alt_max_pkt_size); 1955 kfree(dev->alt_max_pkt_size);
1900 kfree(dev); 1956 kfree(dev);
1901 } 1957 }
1902
1903} 1958}
1904 1959
1905static struct usb_driver em28xx_usb_driver = { 1960static struct usb_driver em28xx_usb_driver = {