diff options
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/cx88/cx88-mpeg.c | 85 |
1 files changed, 29 insertions, 56 deletions
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index 11d9865e34f1..d4858e4c3e27 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -178,7 +178,6 @@ static int cx8802_restart_queue(struct cx8802_dev *dev, | |||
178 | struct cx88_dmaqueue *q) | 178 | struct cx88_dmaqueue *q) |
179 | { | 179 | { |
180 | struct cx88_buffer *buf; | 180 | struct cx88_buffer *buf; |
181 | struct list_head *item; | ||
182 | 181 | ||
183 | dprintk( 1, "cx8802_restart_queue\n" ); | 182 | dprintk( 1, "cx8802_restart_queue\n" ); |
184 | if (list_empty(&q->active)) | 183 | if (list_empty(&q->active)) |
@@ -224,10 +223,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev, | |||
224 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", | 223 | dprintk(2,"restart_queue [%p/%d]: restart dma\n", |
225 | buf, buf->vb.i); | 224 | buf, buf->vb.i); |
226 | cx8802_start_dma(dev, q, buf); | 225 | cx8802_start_dma(dev, q, buf); |
227 | list_for_each(item,&q->active) { | 226 | list_for_each_entry(buf, &q->active, vb.queue) |
228 | buf = list_entry(item, struct cx88_buffer, vb.queue); | ||
229 | buf->count = q->count++; | 227 | buf->count = q->count++; |
230 | } | ||
231 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 228 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
232 | return 0; | 229 | return 0; |
233 | } | 230 | } |
@@ -578,14 +575,11 @@ int cx8802_resume_common(struct pci_dev *pci_dev) | |||
578 | struct cx8802_dev * cx8802_get_device(struct inode *inode) | 575 | struct cx8802_dev * cx8802_get_device(struct inode *inode) |
579 | { | 576 | { |
580 | int minor = iminor(inode); | 577 | int minor = iminor(inode); |
581 | struct cx8802_dev *h = NULL; | 578 | struct cx8802_dev *dev; |
582 | struct list_head *list; | ||
583 | 579 | ||
584 | list_for_each(list,&cx8802_devlist) { | 580 | list_for_each_entry(dev, &cx8802_devlist, devlist) |
585 | h = list_entry(list, struct cx8802_dev, devlist); | 581 | if (dev->mpeg_dev && dev->mpeg_dev->minor == minor) |
586 | if (h->mpeg_dev && h->mpeg_dev->minor == minor) | 582 | return dev; |
587 | return h; | ||
588 | } | ||
589 | 583 | ||
590 | return NULL; | 584 | return NULL; |
591 | } | 585 | } |
@@ -595,14 +589,10 @@ EXPORT_SYMBOL(cx8802_get_device); | |||
595 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) | 589 | struct cx8802_driver * cx8802_get_driver(struct cx8802_dev *dev, enum cx88_board_type btype) |
596 | { | 590 | { |
597 | struct cx8802_driver *d; | 591 | struct cx8802_driver *d; |
598 | struct list_head *list; | ||
599 | |||
600 | list_for_each(list, &dev->drvlist) { | ||
601 | d = list_entry(list, struct cx8802_driver, drvlist); | ||
602 | 592 | ||
593 | list_for_each_entry(d, &dev->drvlist, drvlist) | ||
603 | if (d->type_id == btype) | 594 | if (d->type_id == btype) |
604 | return d; | 595 | return d; |
605 | } | ||
606 | 596 | ||
607 | return NULL; | 597 | return NULL; |
608 | } | 598 | } |
@@ -666,10 +656,9 @@ static int cx8802_check_driver(struct cx8802_driver *drv) | |||
666 | 656 | ||
667 | int cx8802_register_driver(struct cx8802_driver *drv) | 657 | int cx8802_register_driver(struct cx8802_driver *drv) |
668 | { | 658 | { |
669 | struct cx8802_dev *h; | 659 | struct cx8802_dev *dev; |
670 | struct cx8802_driver *driver; | 660 | struct cx8802_driver *driver; |
671 | struct list_head *list; | 661 | int err, i = 0; |
672 | int err = 0, i = 0; | ||
673 | 662 | ||
674 | printk(KERN_INFO | 663 | printk(KERN_INFO |
675 | "cx88/2: registering cx8802 driver, type: %s access: %s\n", | 664 | "cx88/2: registering cx8802 driver, type: %s access: %s\n", |
@@ -681,14 +670,12 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
681 | return err; | 670 | return err; |
682 | } | 671 | } |
683 | 672 | ||
684 | list_for_each(list,&cx8802_devlist) { | 673 | list_for_each_entry(dev, &cx8802_devlist, devlist) { |
685 | h = list_entry(list, struct cx8802_dev, devlist); | ||
686 | |||
687 | printk(KERN_INFO | 674 | printk(KERN_INFO |
688 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", | 675 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", |
689 | h->core->name, h->pci->subsystem_vendor, | 676 | dev->core->name, dev->pci->subsystem_vendor, |
690 | h->pci->subsystem_device, h->core->board.name, | 677 | dev->pci->subsystem_device, dev->core->board.name, |
691 | h->core->boardnr); | 678 | dev->core->boardnr); |
692 | 679 | ||
693 | /* Bring up a new struct for each driver instance */ | 680 | /* Bring up a new struct for each driver instance */ |
694 | driver = kzalloc(sizeof(*drv),GFP_KERNEL); | 681 | driver = kzalloc(sizeof(*drv),GFP_KERNEL); |
@@ -696,7 +683,7 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
696 | return -ENOMEM; | 683 | return -ENOMEM; |
697 | 684 | ||
698 | /* Snapshot of the driver registration data */ | 685 | /* Snapshot of the driver registration data */ |
699 | drv->core = h->core; | 686 | drv->core = dev->core; |
700 | drv->suspend = cx8802_suspend_common; | 687 | drv->suspend = cx8802_suspend_common; |
701 | drv->resume = cx8802_resume_common; | 688 | drv->resume = cx8802_resume_common; |
702 | drv->request_acquire = cx8802_request_acquire; | 689 | drv->request_acquire = cx8802_request_acquire; |
@@ -707,49 +694,38 @@ int cx8802_register_driver(struct cx8802_driver *drv) | |||
707 | if (err == 0) { | 694 | if (err == 0) { |
708 | i++; | 695 | i++; |
709 | mutex_lock(&drv->core->lock); | 696 | mutex_lock(&drv->core->lock); |
710 | list_add_tail(&driver->drvlist, &h->drvlist); | 697 | list_add_tail(&driver->drvlist, &dev->drvlist); |
711 | mutex_unlock(&drv->core->lock); | 698 | mutex_unlock(&drv->core->lock); |
712 | } else { | 699 | } else { |
713 | printk(KERN_ERR | 700 | printk(KERN_ERR |
714 | "%s/2: cx8802 probe failed, err = %d\n", | 701 | "%s/2: cx8802 probe failed, err = %d\n", |
715 | h->core->name, err); | 702 | dev->core->name, err); |
716 | } | 703 | } |
717 | 704 | ||
718 | } | 705 | } |
719 | if (i == 0) | ||
720 | err = -ENODEV; | ||
721 | else | ||
722 | err = 0; | ||
723 | 706 | ||
724 | return err; | 707 | return i ? 0 : -ENODEV; |
725 | } | 708 | } |
726 | 709 | ||
727 | int cx8802_unregister_driver(struct cx8802_driver *drv) | 710 | int cx8802_unregister_driver(struct cx8802_driver *drv) |
728 | { | 711 | { |
729 | struct cx8802_dev *h; | 712 | struct cx8802_dev *dev; |
730 | struct cx8802_driver *d; | 713 | struct cx8802_driver *d, *dtmp; |
731 | struct list_head *list; | 714 | int err = 0; |
732 | struct list_head *list2, *q; | ||
733 | int err = 0, i = 0; | ||
734 | 715 | ||
735 | printk(KERN_INFO | 716 | printk(KERN_INFO |
736 | "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", | 717 | "cx88/2: unregistering cx8802 driver, type: %s access: %s\n", |
737 | drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", | 718 | drv->type_id == CX88_MPEG_DVB ? "dvb" : "blackbird", |
738 | drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); | 719 | drv->hw_access == CX8802_DRVCTL_SHARED ? "shared" : "exclusive"); |
739 | 720 | ||
740 | list_for_each(list,&cx8802_devlist) { | 721 | list_for_each_entry(dev, &cx8802_devlist, devlist) { |
741 | i++; | ||
742 | h = list_entry(list, struct cx8802_dev, devlist); | ||
743 | |||
744 | printk(KERN_INFO | 722 | printk(KERN_INFO |
745 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", | 723 | "%s/2: subsystem: %04x:%04x, board: %s [card=%d]\n", |
746 | h->core->name, h->pci->subsystem_vendor, | 724 | dev->core->name, dev->pci->subsystem_vendor, |
747 | h->pci->subsystem_device, h->core->board.name, | 725 | dev->pci->subsystem_device, dev->core->board.name, |
748 | h->core->boardnr); | 726 | dev->core->boardnr); |
749 | |||
750 | list_for_each_safe(list2, q, &h->drvlist) { | ||
751 | d = list_entry(list2, struct cx8802_driver, drvlist); | ||
752 | 727 | ||
728 | list_for_each_entry_safe(d, dtmp, &dev->drvlist, drvlist) { | ||
753 | /* only unregister the correct driver type */ | 729 | /* only unregister the correct driver type */ |
754 | if (d->type_id != drv->type_id) | 730 | if (d->type_id != drv->type_id) |
755 | continue; | 731 | continue; |
@@ -757,11 +733,11 @@ int cx8802_unregister_driver(struct cx8802_driver *drv) | |||
757 | err = d->remove(d); | 733 | err = d->remove(d); |
758 | if (err == 0) { | 734 | if (err == 0) { |
759 | mutex_lock(&drv->core->lock); | 735 | mutex_lock(&drv->core->lock); |
760 | list_del(list2); | 736 | list_del(&d->drvlist); |
761 | mutex_unlock(&drv->core->lock); | 737 | mutex_unlock(&drv->core->lock); |
762 | } else | 738 | } else |
763 | printk(KERN_ERR "%s/2: cx8802 driver remove " | 739 | printk(KERN_ERR "%s/2: cx8802 driver remove " |
764 | "failed (%d)\n", h->core->name, err); | 740 | "failed (%d)\n", dev->core->name, err); |
765 | } | 741 | } |
766 | 742 | ||
767 | } | 743 | } |
@@ -825,21 +801,18 @@ static void __devexit cx8802_remove(struct pci_dev *pci_dev) | |||
825 | dprintk( 1, "%s\n", __FUNCTION__); | 801 | dprintk( 1, "%s\n", __FUNCTION__); |
826 | 802 | ||
827 | if (!list_empty(&dev->drvlist)) { | 803 | if (!list_empty(&dev->drvlist)) { |
828 | struct list_head *list, *tmp; | 804 | struct cx8802_driver *drv, *tmp; |
829 | struct cx8802_driver *drv; | ||
830 | int err; | 805 | int err; |
831 | 806 | ||
832 | printk(KERN_WARNING "%s/2: Trying to remove cx8802 driver " | 807 | printk(KERN_WARNING "%s/2: Trying to remove cx8802 driver " |
833 | "while cx8802 sub-drivers still loaded?!\n", | 808 | "while cx8802 sub-drivers still loaded?!\n", |
834 | dev->core->name); | 809 | dev->core->name); |
835 | 810 | ||
836 | list_for_each_safe(list, tmp, &dev->drvlist) { | 811 | list_for_each_entry_safe(drv, tmp, &dev->drvlist, drvlist) { |
837 | drv = list_entry(list, struct cx8802_driver, drvlist); | ||
838 | |||
839 | err = drv->remove(drv); | 812 | err = drv->remove(drv); |
840 | if (err == 0) { | 813 | if (err == 0) { |
841 | mutex_lock(&drv->core->lock); | 814 | mutex_lock(&drv->core->lock); |
842 | list_del(list); | 815 | list_del(&drv->drvlist); |
843 | mutex_unlock(&drv->core->lock); | 816 | mutex_unlock(&drv->core->lock); |
844 | } else | 817 | } else |
845 | printk(KERN_ERR "%s/2: cx8802 driver remove " | 818 | printk(KERN_ERR "%s/2: cx8802 driver remove " |