The patch number 10358 was added via Jean-Francois Moine <[email protected]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <[email protected]>

------

merge v4l-dvb


---

 linux/drivers/media/video/em28xx/em28xx-core.c |    9 
 linux/drivers/media/video/em28xx/em28xx.h      |   21 +
 linux/drivers/media/video/zoran/zoran.h        |   12 -
 linux/drivers/media/video/zoran/zoran_card.c   |  183 ++++++-----------
 linux/drivers/media/video/zoran/zoran_card.h   |    2 
 linux/drivers/media/video/zoran/zoran_driver.c |  111 +++-------
 v4l/scripts/hg-pull-req.pl                     |    6 
 7 files changed, 145 insertions(+), 199 deletions(-)

diff -r d75b401fc7cd -r 110be1ddb768 
linux/drivers/media/video/em28xx/em28xx-core.c
--- a/linux/drivers/media/video/em28xx/em28xx-core.c    Tue Jan 13 10:07:59 
2009 +0100
+++ b/linux/drivers/media/video/em28xx/em28xx-core.c    Tue Jan 13 20:06:19 
2009 +0100
@@ -453,6 +453,15 @@ int em28xx_audio_analog_set(struct em28x
                        if (ret < 0)
                                em28xx_warn("couldn't setup AC97 register %d\n",
                                     outputs[i].reg);
+               }
+
+               if (dev->ctl_aoutput & EM28XX_AOUT_PCM_IN) {
+                       int sel = ac97_return_record_select(dev->ctl_aoutput);
+
+                       /* Use the same input for both left and right channels 
*/
+                       sel |= (sel << 8);
+
+                       em28xx_write_ac97(dev, AC97_RECORD_SELECT, sel);
                }
        }
 
diff -r d75b401fc7cd -r 110be1ddb768 linux/drivers/media/video/em28xx/em28xx.h
--- a/linux/drivers/media/video/em28xx/em28xx.h Tue Jan 13 10:07:59 2009 +0100
+++ b/linux/drivers/media/video/em28xx/em28xx.h Tue Jan 13 20:06:19 2009 +0100
@@ -301,12 +301,31 @@ enum em28xx_amux {
 };
 
 enum em28xx_aout {
+       /* AC97 outputs */
        EM28XX_AOUT_MASTER = 1 << 0,
        EM28XX_AOUT_LINE   = 1 << 1,
        EM28XX_AOUT_MONO   = 1 << 2,
        EM28XX_AOUT_LFE    = 1 << 3,
        EM28XX_AOUT_SURR   = 1 << 4,
-};
+
+       /* PCM IN Mixer - used by AC97_RECORD_SELECT register */
+       EM28XX_AOUT_PCM_IN = 1 << 7,
+
+       /* Bits 10-8 are used to indicate the PCM IN record select */
+       EM28XX_AOUT_PCM_MIC_PCM = 0 << 8,
+       EM28XX_AOUT_PCM_CD      = 1 << 8,
+       EM28XX_AOUT_PCM_VIDEO   = 2 << 8,
+       EM28XX_AOUT_PCM_AUX     = 3 << 8,
+       EM28XX_AOUT_PCM_LINE    = 4 << 8,
+       EM28XX_AOUT_PCM_STEREO  = 5 << 8,
+       EM28XX_AOUT_PCM_MONO    = 6 << 8,
+       EM28XX_AOUT_PCM_PHONE   = 7 << 8,
+};
+
+static int ac97_return_record_select(int a_out)
+{
+       return (a_out & 0x700) >> 8;
+}
 
 struct em28xx_reg_seq {
        int reg;
diff -r d75b401fc7cd -r 110be1ddb768 linux/drivers/media/video/zoran/zoran.h
--- a/linux/drivers/media/video/zoran/zoran.h   Tue Jan 13 10:07:59 2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran.h   Tue Jan 13 20:06:19 2009 +0100
@@ -349,7 +349,6 @@ struct card_info {
        u16 i2c_decoder, i2c_encoder;                   /* I2C types */
        u16 video_vfe, video_codec;                     /* videocodec types */
        u16 audio_chip;                                 /* audio type */
-       u16 vendor_id, device_id;       /* subsystem vendor/device ID */
 
        int inputs;             /* number of video inputs */
        struct input {
@@ -401,7 +400,6 @@ struct zoran {
        char name[32];          /* name of this device */
        struct pci_dev *pci_dev;        /* PCI device */
        unsigned char revision; /* revision of zr36057 */
-       unsigned int zr36057_adr;       /* bus address of IO mem returned by 
PCI BIOS */
        unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */
 
        spinlock_t spinlock;    /* Spinlock */
@@ -490,16 +488,10 @@ struct zoran {
        wait_queue_head_t test_q;
 };
 
-/*The following should be done in more portable way. It depends on define
-  of _ALPHA_BUZ in the Makefile.*/
-
-#ifdef _ALPHA_BUZ
-#define btwrite(dat,adr)    writel((dat), zr->zr36057_adr+(adr))
-#define btread(adr)         readl(zr->zr36057_adr+(adr))
-#else
+/* There was something called _ALPHA_BUZ that used the PCI address instead of
+ * the kernel iomapped address for btread/btwrite.  */
 #define btwrite(dat,adr)    writel((dat), zr->zr36057_mem+(adr))
 #define btread(adr)         readl(zr->zr36057_mem+(adr))
-#endif
 
 #define btand(dat,adr)      btwrite((dat) & btread(adr), adr)
 #define btor(dat,adr)       btwrite((dat) | btread(adr), adr)
diff -r d75b401fc7cd -r 110be1ddb768 
linux/drivers/media/video/zoran/zoran_card.c
--- a/linux/drivers/media/video/zoran/zoran_card.c      Tue Jan 13 10:07:59 
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_card.c      Tue Jan 13 20:06:19 
2009 +0100
@@ -62,17 +62,17 @@
 
 extern const struct zoran_format zoran_formats[];
 
-static int card[BUZ_MAX] = { -1, -1, -1, -1 };
+static int card[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
 module_param_array(card, int, NULL, 0444);
-MODULE_PARM_DESC(card, "The type of card");
-
-static int encoder[BUZ_MAX] = { -1, -1, -1, -1 };
+MODULE_PARM_DESC(card, "Card type");
+
+static int encoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
 module_param_array(encoder, int, NULL, 0444);
-MODULE_PARM_DESC(encoder, "i2c TV encoder");
-
-static int decoder[BUZ_MAX] = { -1, -1, -1, -1 };
+MODULE_PARM_DESC(encoder, "Video encoder chip");
+
+static int decoder[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
 module_param_array(decoder, int, NULL, 0444);
-MODULE_PARM_DESC(decoder, "i2c TV decoder");
+MODULE_PARM_DESC(decoder, "Video decoder chip");
 
 /*
    The video mem address of the video card.
@@ -105,9 +105,9 @@ MODULE_PARM_DESC(default_norm, "Default 
 MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)");
 
 /* /dev/videoN, -1 for autodetect */
-static int video_nr[BUZ_MAX] = {-1, -1, -1, -1};
+static int video_nr[BUZ_MAX] = { [0 ... (BUZ_MAX-1)] = -1 };
 module_param_array(video_nr, int, NULL, 0444);
-MODULE_PARM_DESC(video_nr, "video device number (-1=Auto)");
+MODULE_PARM_DESC(video_nr, "Video device number (-1=Auto)");
 
 /*
    Number and size of grab buffers for Video 4 Linux
@@ -154,14 +154,21 @@ MODULE_AUTHOR("Serguei Miridonov");
 MODULE_AUTHOR("Serguei Miridonov");
 MODULE_LICENSE("GPL");
 
+#define ZR_DEVICE(subven, subdev, data)        { \
+       .vendor = PCI_VENDOR_ID_ZORAN, .device = PCI_DEVICE_ID_ZORAN_36057, \
+       .subvendor = (subven), .subdevice = (subdev), .driver_data = (data) }
+
 static struct pci_device_id zr36067_pci_tbl[] = {
-       { PCI_DEVICE(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057), },
+       ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC10PLUS, DC10plus),
+       ZR_DEVICE(PCI_VENDOR_ID_MIRO, PCI_DEVICE_ID_MIRO_DC30PLUS, DC30plus),
+       ZR_DEVICE(PCI_VENDOR_ID_ELECTRONICDESIGNGMBH, PCI_DEVICE_ID_LML_33R10, 
LML33R10),
+       ZR_DEVICE(PCI_VENDOR_ID_IOMEGA, PCI_DEVICE_ID_IOMEGA_BUZ, BUZ),
+       ZR_DEVICE(PCI_ANY_ID, PCI_ANY_ID, NUM_CARDS),
        {0}
 };
 MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
 
-atomic_t zoran_num = ATOMIC_INIT(0);           /* number of Buzs in use */
-struct zoran *zoran[BUZ_MAX];
+static unsigned int zoran_num;         /* number of cards found */
 
 /* videocodec bus functions ZR36060 */
 static u32
@@ -478,8 +485,6 @@ static struct card_info zoran_cards[NUM_
        }, {
                .type = DC10plus,
                .name = "DC10plus",
-               .vendor_id = PCI_VENDOR_ID_MIRO,
-               .device_id = PCI_DEVICE_ID_MIRO_DC10PLUS,
                .i2c_decoder = I2C_DRIVERID_SAA7110,
                .i2c_encoder = I2C_DRIVERID_ADV7175,
                .video_codec = CODEC_TYPE_ZR36060,
@@ -537,8 +542,6 @@ static struct card_info zoran_cards[NUM_
        }, {
                .type = DC30plus,
                .name = "DC30plus",
-               .vendor_id = PCI_VENDOR_ID_MIRO,
-               .device_id = PCI_DEVICE_ID_MIRO_DC30PLUS,
                .i2c_decoder = I2C_DRIVERID_VPX3220,
                .i2c_encoder = I2C_DRIVERID_ADV7175,
                .video_codec = CODEC_TYPE_ZR36050,
@@ -595,8 +598,6 @@ static struct card_info zoran_cards[NUM_
        }, {
                .type = LML33R10,
                .name = "LML33R10",
-               .vendor_id = PCI_VENDOR_ID_ELECTRONICDESIGNGMBH,
-               .device_id = PCI_DEVICE_ID_LML_33R10,
                .i2c_decoder = I2C_DRIVERID_SAA7114,
                .i2c_encoder = I2C_DRIVERID_ADV7170,
                .video_codec = CODEC_TYPE_ZR36060,
@@ -624,8 +625,6 @@ static struct card_info zoran_cards[NUM_
        }, {
                .type = BUZ,
                .name = "Buz",
-               .vendor_id = PCI_VENDOR_ID_IOMEGA,
-               .device_id = PCI_DEVICE_ID_IOMEGA_BUZ,
                .i2c_decoder = I2C_DRIVERID_SAA7111A,
                .i2c_encoder = I2C_DRIVERID_SAA7185B,
                .video_codec = CODEC_TYPE_ZR36060,
@@ -655,8 +654,6 @@ static struct card_info zoran_cards[NUM_
                .name = "6-Eyes",
                /* AverMedia chose not to brand the 6-Eyes. Thus it
                   can't be autodetected, and requires card=x. */
-               .vendor_id = -1,
-               .device_id = -1,
                .i2c_decoder = I2C_DRIVERID_KS0127,
                .i2c_encoder = I2C_DRIVERID_BT866,
                .video_codec = CODEC_TYPE_ZR36060,
@@ -1145,6 +1142,7 @@ zr36057_init (struct zoran *zr)
        err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, 
video_nr[zr->id]);
        if (err < 0)
                goto exit_free;
+       video_set_drvdata(zr->video_dev, zr);
 
        zoran_init_hardware(zr);
        if (zr36067_debug > 2)
@@ -1276,20 +1274,21 @@ static int __devinit zoran_probe(struct 
        unsigned int nr;
 
 
-       nr = atomic_inc_return(&zoran_num) - 1;
+       nr = zoran_num++;
        if (nr >= BUZ_MAX) {
-               dev_err(&pdev->dev, "driver limited to %d card(s) maximum\n", 
BUZ_MAX);
+               dprintk(1,
+                       KERN_ERR
+                       "%s: driver limited to %d card(s) maximum\n",
+                       ZORAN_NAME, BUZ_MAX);
                return -ENOENT;
        }
 
-       card_num = card[nr];
        zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
        if (!zr) {
                dprintk(1,
                        KERN_ERR
                        "%s: find_zr36057() - kzalloc failed\n",
                        ZORAN_NAME);
-               /* The entry in zoran[] gets leaked */
                return -ENOMEM;
        }
        zr->pci_dev = pdev;
@@ -1299,70 +1298,56 @@ static int __devinit zoran_probe(struct 
        mutex_init(&zr->resource_lock);
        if (pci_enable_device(pdev))
                goto zr_free_mem;
-       zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
        pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, &zr->revision);
-       if (zr->revision < 2) {
+
+       dprintk(1,
+               KERN_INFO
+               "%s: Zoran ZR360%c7 (rev %d), irq: %d, memory: 0x%08llx\n",
+               ZR_DEVNAME(zr), zr->revision < 2 ? '5' : '6', zr->revision,
+               zr->pci_dev->irq, (uint64_t)pci_resource_start(zr->pci_dev, 0));
+       if (zr->revision >= 2) {
                dprintk(1,
                        KERN_INFO
-                       "%s: Zoran ZR36057 (rev %d) irq: %d, memory: 0x%08x.\n",
-                       ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq,
-                       zr->zr36057_adr);
-
-               if (card_num == -1) {
+                       "%s: Subsystem vendor=0x%04x id=0x%04x\n",
+                       ZR_DEVNAME(zr), zr->pci_dev->subsystem_vendor,
+                       zr->pci_dev->subsystem_device);
+       }
+
+       /* Use auto-detected card type? */
+       if (card[nr] == -1) {
+               if (zr->revision < 2) {
                        dprintk(1,
                                KERN_ERR
-                               "%s: find_zr36057() - no card specified, please 
use the card=X insmod option\n",
+                               "%s: No card type specified, please use the 
card=X module parameter\n",
+                               ZR_DEVNAME(zr));
+                       dprintk(1,
+                               KERN_ERR
+                               "%s: It is not possible to auto-detect ZR36057 
based cards\n",
                                ZR_DEVNAME(zr));
                        goto zr_free_mem;
                }
+
+               card_num = ent->driver_data;
+               if (card_num >= NUM_CARDS) {
+                       dprintk(1,
+                               KERN_ERR
+                               "%s: Unknown card, try specifying card=X module 
parameter\n",
+                               ZR_DEVNAME(zr));
+                       goto zr_free_mem;
+               }
+               dprintk(3,
+                       KERN_DEBUG
+                       "%s: %s() - card %s detected\n",
+                       ZR_DEVNAME(zr), __func__, zoran_cards[card_num].name);
        } else {
-               int i;
-               unsigned short ss_vendor, ss_device;
-
-               ss_vendor = zr->pci_dev->subsystem_vendor;
-               ss_device = zr->pci_dev->subsystem_device;
-               dprintk(1,
-                       KERN_INFO
-                       "%s: Zoran ZR36067 (rev %d) irq: %d, memory: 0x%08x\n",
-                       ZR_DEVNAME(zr), zr->revision, zr->pci_dev->irq,
-                       zr->zr36057_adr);
-               dprintk(1,
-                       KERN_INFO
-                       "%s: subsystem vendor=0x%04x id=0x%04x\n",
-                       ZR_DEVNAME(zr), ss_vendor, ss_device);
-               if (card_num == -1) {
-                       dprintk(3,
-                               KERN_DEBUG
-                               "%s: find_zr36057() - trying to autodetect card 
type\n",
-                               ZR_DEVNAME(zr));
-                       for (i = 0; i < NUM_CARDS; i++) {
-                               if (ss_vendor == zoran_cards[i].vendor_id &&
-                                   ss_device == zoran_cards[i].device_id) {
-                                       dprintk(3,
-                                               KERN_DEBUG
-                                               "%s: find_zr36057() - card %s 
detected\n",
-                                               ZR_DEVNAME(zr),
-                                               zoran_cards[i].name);
-                                       card_num = i;
-                                       break;
-                               }
-                       }
-                       if (i == NUM_CARDS) {
-                               dprintk(1,
-                                       KERN_ERR
-                                       "%s: find_zr36057() - unknown card\n",
-                                       ZR_DEVNAME(zr));
-                               goto zr_free_mem;
-                       }
+               card_num = card[nr];
+               if (card_num >= NUM_CARDS || card_num < 0) {
+                       dprintk(1,
+                               KERN_ERR
+                               "%s: User specified card type %d out of range 
(0 .. %d)\n",
+                               ZR_DEVNAME(zr), card_num, NUM_CARDS - 1);
+                       goto zr_free_mem;
                }
-       }
-
-       if (card_num < 0 || card_num >= NUM_CARDS) {
-               dprintk(2,
-                       KERN_ERR
-                       "%s: find_zr36057() - invalid cardnum %d\n",
-                       ZR_DEVNAME(zr), card_num);
-               goto zr_free_mem;
        }
 
        /* even though we make this a non pointer and thus
@@ -1374,12 +1359,12 @@ static int __devinit zoran_probe(struct 
        snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)),
                 "%s[%u]", zr->card.name, zr->id);
 
-       zr->zr36057_mem = ioremap_nocache(zr->zr36057_adr, 0x1000);
+       zr->zr36057_mem = pci_ioremap_bar(zr->pci_dev, 0);
        if (!zr->zr36057_mem) {
                dprintk(1,
                        KERN_ERR
-                       "%s: find_zr36057() - ioremap failed\n",
-                       ZR_DEVNAME(zr));
+                       "%s: %s() - ioremap failed\n",
+                       ZR_DEVNAME(zr), __func__);
                goto zr_free_mem;
        }
 
@@ -1545,7 +1530,6 @@ static int __devinit zoran_probe(struct 
                        goto zr_detach_vfe;
                }
        }
-       zoran[nr] = zr;
 
        /* take care of Natoma chipset and a revision 1 zr36057 */
        if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
@@ -1565,29 +1549,21 @@ static int __devinit zoran_probe(struct 
 
        return 0;
 
-       /* Init errors */
 zr_detach_vfe:
        videocodec_detach(zr->vfe);
-
 zr_free_vfe:
        kfree(master_vfe);
-
 zr_detach_codec:
        videocodec_detach(zr->codec);
-
 zr_free_codec:
        kfree(master_codec);
-
 zr_unreg_i2c:
        zoran_unregister_i2c(zr);
-
 zr_free_irq:
        btwrite(0, ZR36057_SPGPPCR);
        free_irq(zr->pci_dev->irq, zr);
-
 zr_unmap:
        iounmap(zr->zr36057_mem);
-
 zr_free_mem:
        kfree(zr);
 
@@ -1603,9 +1579,8 @@ static struct pci_driver zoran_driver = 
 
 static int __init zoran_init(void)
 {
-       int i;
-
-       memset(zoran, 0, sizeof(zoran));
+       int res;
+
        printk(KERN_INFO "Zoran MJPEG board driver version %d.%d.%d\n",
               MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION);
 
@@ -1650,13 +1625,13 @@ static int __init zoran_init(void)
                        ZORAN_NAME);
        }
 
-       i = pci_register_driver(&zoran_driver);
-       if (i) {
+       res = pci_register_driver(&zoran_driver);
+       if (res) {
                dprintk(1,
                        KERN_ERR
                        "%s: Unable to register ZR36057 driver\n",
                        ZORAN_NAME);
-               return i;
+               return res;
        }
 
        return 0;
@@ -1669,13 +1644,3 @@ static void __exit zoran_exit(void)
 
 module_init(zoran_init);
 module_exit(zoran_exit);
-
-/*
-todo:
-       use pci ioremap functions
-
-       use id table to provide card type
-
-       get rid of zoran[] array
-*/
-
diff -r d75b401fc7cd -r 110be1ddb768 
linux/drivers/media/video/zoran/zoran_card.h
--- a/linux/drivers/media/video/zoran/zoran_card.h      Tue Jan 13 10:07:59 
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_card.h      Tue Jan 13 20:06:19 
2009 +0100
@@ -40,8 +40,6 @@ extern int zr36067_debug;
 
 /* Anybody who uses more than four? */
 #define BUZ_MAX 4
-extern atomic_t zoran_num;
-extern struct zoran *zoran[BUZ_MAX];
 
 extern struct video_device zoran_template;
 
diff -r d75b401fc7cd -r 110be1ddb768 
linux/drivers/media/video/zoran/zoran_driver.c
--- a/linux/drivers/media/video/zoran/zoran_driver.c    Tue Jan 13 10:07:59 
2009 +0100
+++ b/linux/drivers/media/video/zoran/zoran_driver.c    Tue Jan 13 20:06:19 
2009 +0100
@@ -1261,82 +1261,53 @@ zoran_close_end_session (struct file *fi
  *   Open a zoran card. Right now the flags stuff is just playing
  */
 
-static int
-zoran_open(struct file  *file)
+static int zoran_open(struct file *file)
 {
-       unsigned int minor = video_devdata(file)->minor;
-       struct zoran *zr = NULL;
+       struct zoran *zr = video_drvdata(file);
        struct zoran_fh *fh;
-       int i, res, first_open = 0, have_module_locks = 0;
+       int res, first_open = 0;
+
+       dprintk(2, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n",
+               ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user + 
1);
 
        lock_kernel();
-       /* find the device */
-       for (i = 0; i < atomic_read(&zoran_num); i++) {
-               if (zoran[i]->video_dev->minor == minor) {
-                       zr = zoran[i];
-                       break;
-               }
-       }
-
-       if (!zr) {
-               dprintk(1, KERN_ERR "%s: device not found!\n", ZORAN_NAME);
-               res = -ENODEV;
-               goto open_unlock_and_return;
-       }
 
        /* see fs/device.c - the kernel already locks during open(),
         * so locking ourselves only causes deadlocks */
        /*mutex_lock(&zr->resource_lock);*/
+
+       if (zr->user >= 2048) {
+               dprintk(1, KERN_ERR "%s: too many users (%d) on device\n",
+                       ZR_DEVNAME(zr), zr->user);
+               res = -EBUSY;
+               goto fail_unlock;
+       }
 
        if (!zr->decoder) {
                dprintk(1,
                        KERN_ERR "%s: no TV decoder loaded for device!\n",
                        ZR_DEVNAME(zr));
                res = -EIO;
-               goto open_unlock_and_return;
-       }
-
-       /* try to grab a module lock */
-       if (!try_module_get(THIS_MODULE)) {
-               dprintk(1,
-                       KERN_ERR
-                       "%s: failed to acquire my own lock! PANIC!\n",
-                       ZR_DEVNAME(zr));
-               res = -ENODEV;
-               goto open_unlock_and_return;
-       }
+               goto fail_unlock;
+       }
+
        if (!try_module_get(zr->decoder->driver->driver.owner)) {
                dprintk(1,
                        KERN_ERR
-                       "%s: failed to grab ownership of i2c decoder\n",
+                       "%s: failed to grab ownership of video decoder\n",
                        ZR_DEVNAME(zr));
                res = -EIO;
-               module_put(THIS_MODULE);
-               goto open_unlock_and_return;
+               goto fail_unlock;
        }
        if (zr->encoder &&
            !try_module_get(zr->encoder->driver->driver.owner)) {
                dprintk(1,
                        KERN_ERR
-                       "%s: failed to grab ownership of i2c encoder\n",
+                       "%s: failed to grab ownership of video encoder\n",
                        ZR_DEVNAME(zr));
                res = -EIO;
-               module_put(zr->decoder->driver->driver.owner);
-               module_put(THIS_MODULE);
-               goto open_unlock_and_return;
-       }
-
-       have_module_locks = 1;
-
-       if (zr->user >= 2048) {
-               dprintk(1, KERN_ERR "%s: too many users (%d) on device\n",
-                       ZR_DEVNAME(zr), zr->user);
-               res = -EBUSY;
-               goto open_unlock_and_return;
-       }
-
-       dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n",
-               ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user);
+               goto fail_decoder;
+       }
 
        /* now, create the open()-specific file_ops struct */
        fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL);
@@ -1346,7 +1317,7 @@ zoran_open(struct file  *file)
                        "%s: zoran_open() - allocation of zoran_fh failed\n",
                        ZR_DEVNAME(zr));
                res = -ENOMEM;
-               goto open_unlock_and_return;
+               goto fail_encoder;
        }
        /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
         * on norm-change! */
@@ -1357,9 +1328,8 @@ zoran_open(struct file  *file)
                        KERN_ERR
                        "%s: zoran_open() - allocation of overlay_mask 
failed\n",
                        ZR_DEVNAME(zr));
-               kfree(fh);
                res = -ENOMEM;
-               goto open_unlock_and_return;
+               goto fail_fh;
        }
 
        if (zr->user++ == 0)
@@ -1384,21 +1354,18 @@ zoran_open(struct file  *file)
 
        return 0;
 
-open_unlock_and_return:
-       /* if we grabbed locks, release them accordingly */
-       if (have_module_locks) {
-               module_put(zr->decoder->driver->driver.owner);
-               if (zr->encoder) {
-                       module_put(zr->encoder->driver->driver.owner);
-               }
-               module_put(THIS_MODULE);
-       }
-
-       /* if there's no device found, we didn't obtain the lock either */
-       if (zr) {
-               /*mutex_unlock(&zr->resource_lock);*/
-       }
+fail_fh:
+       kfree(fh);
+fail_encoder:
+       if (zr->encoder)
+               module_put(zr->encoder->driver->driver.owner);
+fail_decoder:
+       module_put(zr->decoder->driver->driver.owner);
+fail_unlock:
        unlock_kernel();
+
+       dprintk(2, KERN_INFO "%s: open failed (%d), users(-)=%d\n",
+               ZR_DEVNAME(zr), res, zr->user);
 
        return res;
 }
@@ -1409,8 +1376,8 @@ zoran_close(struct file  *file)
        struct zoran_fh *fh = file->private_data;
        struct zoran *zr = fh->zr;
 
-       dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n",
-               ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user);
+       dprintk(2, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n",
+               ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user - 
1);
 
        /* kernel locks (fs/device.c), so don't do that ourselves
         * (prevents deadlocks) */
@@ -1456,10 +1423,8 @@ zoran_close(struct file  *file)
 
        /* release locks on the i2c modules */
        module_put(zr->decoder->driver->driver.owner);
-       if (zr->encoder) {
-                module_put(zr->encoder->driver->driver.owner);
-       }
-       module_put(THIS_MODULE);
+       if (zr->encoder)
+               module_put(zr->encoder->driver->driver.owner);
 
        /*mutex_unlock(&zr->resource_lock);*/
 
diff -r d75b401fc7cd -r 110be1ddb768 v4l/scripts/hg-pull-req.pl
--- a/v4l/scripts/hg-pull-req.pl        Tue Jan 13 10:07:59 2009 +0100
+++ b/v4l/scripts/hg-pull-req.pl        Tue Jan 13 20:06:19 2009 +0100
@@ -81,11 +81,9 @@ if (`hg outgoing $from_repo` !~ /^no cha
 
 open IN, "hg outgoing -M $to_repo |";
 while(<IN>) {
-    if(/^changeset:\s+\d+:([[:xdigit:]]+)$/) {
+    if(/^changeset:\s+\d+:([[:xdigit:]]{12})$/) {
        push @changesets, $1;
-    } elsif(/^description:$/) {
-       $_ = <IN>;
-       /^(\S.*)$/;
+    } elsif(/^summary:\s+(\S.*)$/) {
        if ($1 =~ /^merge:/) {
            # Skip merge changesets
            pop @changesets;


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/110be1ddb768e6ce5bacf65f0336ed573a62341d

_______________________________________________
linuxtv-commits mailing list
[email protected]
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to