diff options
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/common/saa7146_core.c | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/linux/drivers/media/common/saa7146_core.c b/linux/drivers/media/common/saa7146_core.c index 0c721e100..d2485dfbd 100644 --- a/linux/drivers/media/common/saa7146_core.c +++ b/linux/drivers/media/common/saa7146_core.c @@ -253,7 +253,6 @@ static int video_ioctl(struct inode *inode, struct file *file, unsigned int cmd, static int video_mmap(struct file *file, struct vm_area_struct * vma) { struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; struct videobuf_queue *q; switch (fh->type) { @@ -277,7 +276,6 @@ static int video_mmap(struct file *file, struct vm_area_struct * vma) static unsigned int video_poll(struct file *file, struct poll_table_struct *wait) { struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; struct videobuf_buffer *buf = NULL; struct videobuf_queue *q; @@ -309,7 +307,6 @@ static unsigned int video_poll(struct file *file, struct poll_table_struct *wait static ssize_t video_read(struct file *file, char *data, size_t count, loff_t *ppos) { struct saa7146_fh *fh = file->private_data; - struct saa7146_dev *dev = fh->dev; switch (fh->type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: { @@ -680,17 +677,18 @@ int saa7146_unregister_extension(struct saa7146_extension* ext) static int config_a_device(struct pci_dev *pci) { unsigned long adr = 0, len = 0; - struct saa7146_dev* dev = (struct saa7146_dev*)kmalloc(sizeof(struct saa7146_dev),GFP_KERNEL); + struct saa7146_dev* dev = kmalloc (sizeof(struct saa7146_dev),GFP_KERNEL); - if( NULL == dev) { + if (!(dev = kmalloc (sizeof(struct saa7146_dev),GFP_KERNEL))) { ERR(("out of memory.\n")); return -ENOMEM; - } + } + /* clear out mem for sure */ memset(dev, 0x0, sizeof(struct saa7146_dev)); DEB_EE(("pci:%p\n",pci)); - + if (pci_enable_device(pci)) { ERR(("pci_enable_device() failed.\n")); kfree(dev); @@ -719,8 +717,7 @@ static int config_a_device(struct pci_dev *pci) return -ENODEV; } - dev->mem=ioremap(adr,len); - if ( 0 == dev->mem ) { + if (!(dev->mem = ioremap(adr,len))) { ERR(("ioremap() failed.\n")); release_mem_region(adr,len); kfree(dev); @@ -745,7 +742,9 @@ static int config_a_device(struct pci_dev *pci) saa7146_write(dev, MC2, 0xf8000000); /* request an interrupt for the saa7146 */ - if( 0 != request_irq(dev->pci->irq, interrupt_hw, SA_SHIRQ | SA_INTERRUPT, dev->name, (void *)dev)) { + if (request_irq(dev->pci->irq, interrupt_hw, SA_SHIRQ | SA_INTERRUPT, + dev->name, dev)) + { ERR(("request_irq() failed.\n")); iounmap(dev->mem); release_mem_region(adr,len); @@ -857,38 +856,45 @@ static void unconfig_a_device(struct saa7146_dev* dev) saa7146_num--; } -#ifdef MODULE + +static int __devinit saa7146_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { - if( 0 != config_a_device(pdev)) { + if (config_a_device(pdev)) return -EINVAL; - } - + return 0; } + +static void __devexit saa7146_remove_one(struct pci_dev *pdev) { - struct saa7146_dev* dev = (struct saa7146_dev*)pci_get_drvdata(pdev); + struct saa7146_dev* dev = (struct saa7146_dev*) pci_get_drvdata(pdev); unconfig_a_device(dev); } + +static struct pci_device_id saa7146_pci_tbl[] __devinitdata = { { PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, PCI_ANY_ID, PCI_ANY_ID, }, { 0,}, }; -MODULE_DEVICE_TABLE(pci, saa7146_pci_tbl); - +static MODULE_DEVICE_TABLE(pci, saa7146_pci_tbl); + +static struct pci_driver saa7146_driver = { - name: "saa7146", - id_table: saa7146_pci_tbl, - probe: saa7146_init_one, - remove: saa7146_remove_one, + .name = "saa7146", + .id_table = saa7146_pci_tbl, + .probe = saa7146_init_one, + .remove = saa7146_remove_one, }; + +static int __init saa7146_init_module(void) { INIT_LIST_HEAD(&devices); @@ -896,6 +902,8 @@ int __init saa7146_init_module(void) return pci_module_init(&saa7146_driver); } + +static void __exit saa7146_cleanup_module(void) { pci_unregister_driver(&saa7146_driver); @@ -917,5 +925,4 @@ EXPORT_SYMBOL_GPL(saa7146_i2c_transfer); MODULE_AUTHOR("Michael Hunold <michael@mihu.de>"); MODULE_DESCRIPTION("video4linux driver for saa7146-based video hardware"); MODULE_LICENSE("GPL"); -#endif |