diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-04-13 06:07:40 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-16 17:02:02 -0400 |
commit | a8f35ce3d6f5b776463f03403e0319c2415401f7 (patch) | |
tree | 0b089c96d8e4bd306edd495a0e5a697fd7a907a0 /drivers/media | |
parent | bfef0d35e57c08dff295e3203d30f9ca4077415a (diff) |
[media] cx25821: remove unnecessary global devlist
This device list is not necessary. The kernel already has all that information,
so just use that instead.
Also remove a bogus refcount and some dead 'private_free' code in the alsa driver.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-alsa.c | 79 | ||||
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-core.c | 21 | ||||
-rw-r--r-- | drivers/media/pci/cx25821/cx25821-video.c | 38 | ||||
-rw-r--r-- | drivers/media/pci/cx25821/cx25821.h | 9 |
4 files changed, 41 insertions, 106 deletions
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index b3cac75a4891..81361c26c54e 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c | |||
@@ -59,7 +59,6 @@ do { \ | |||
59 | Data type declarations - Can be moded to a header file later | 59 | Data type declarations - Can be moded to a header file later |
60 | ****************************************************************************/ | 60 | ****************************************************************************/ |
61 | 61 | ||
62 | static struct snd_card *snd_cx25821_cards[SNDRV_CARDS]; | ||
63 | static int devno; | 62 | static int devno; |
64 | 63 | ||
65 | struct cx25821_audio_buffer { | 64 | struct cx25821_audio_buffer { |
@@ -627,34 +626,6 @@ static DEFINE_PCI_DEVICE_TABLE(cx25821_audio_pci_tbl) = { | |||
627 | MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl); | 626 | MODULE_DEVICE_TABLE(pci, cx25821_audio_pci_tbl); |
628 | 627 | ||
629 | /* | 628 | /* |
630 | * Not used in the function snd_cx25821_dev_free so removing | ||
631 | * from the file. | ||
632 | */ | ||
633 | /* | ||
634 | static int snd_cx25821_free(struct cx25821_audio_dev *chip) | ||
635 | { | ||
636 | if (chip->irq >= 0) | ||
637 | free_irq(chip->irq, chip); | ||
638 | |||
639 | cx25821_dev_unregister(chip->dev); | ||
640 | pci_disable_device(chip->pci); | ||
641 | |||
642 | return 0; | ||
643 | } | ||
644 | */ | ||
645 | |||
646 | /* | ||
647 | * Component Destructor | ||
648 | */ | ||
649 | static void snd_cx25821_dev_free(struct snd_card *card) | ||
650 | { | ||
651 | struct cx25821_audio_dev *chip = card->private_data; | ||
652 | |||
653 | /* snd_cx25821_free(chip); */ | ||
654 | snd_card_free(chip->card); | ||
655 | } | ||
656 | |||
657 | /* | ||
658 | * Alsa Constructor - Component probe | 629 | * Alsa Constructor - Component probe |
659 | */ | 630 | */ |
660 | static int cx25821_audio_initdev(struct cx25821_dev *dev) | 631 | static int cx25821_audio_initdev(struct cx25821_dev *dev) |
@@ -685,7 +656,6 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev) | |||
685 | strcpy(card->driver, "cx25821"); | 656 | strcpy(card->driver, "cx25821"); |
686 | 657 | ||
687 | /* Card "creation" */ | 658 | /* Card "creation" */ |
688 | card->private_free = snd_cx25821_dev_free; | ||
689 | chip = card->private_data; | 659 | chip = card->private_data; |
690 | spin_lock_init(&chip->reg_lock); | 660 | spin_lock_init(&chip->reg_lock); |
691 | 661 | ||
@@ -729,8 +699,7 @@ static int cx25821_audio_initdev(struct cx25821_dev *dev) | |||
729 | goto error; | 699 | goto error; |
730 | } | 700 | } |
731 | 701 | ||
732 | snd_cx25821_cards[devno] = card; | 702 | dev->card = card; |
733 | |||
734 | devno++; | 703 | devno++; |
735 | return 0; | 704 | return 0; |
736 | 705 | ||
@@ -742,9 +711,31 @@ error: | |||
742 | /**************************************************************************** | 711 | /**************************************************************************** |
743 | LINUX MODULE INIT | 712 | LINUX MODULE INIT |
744 | ****************************************************************************/ | 713 | ****************************************************************************/ |
714 | |||
715 | static int cx25821_alsa_exit_callback(struct device *dev, void *data) | ||
716 | { | ||
717 | struct v4l2_device *v4l2_dev = dev_get_drvdata(dev); | ||
718 | struct cx25821_dev *cxdev = get_cx25821(v4l2_dev); | ||
719 | |||
720 | snd_card_free(cxdev->card); | ||
721 | return 0; | ||
722 | } | ||
723 | |||
745 | static void cx25821_audio_fini(void) | 724 | static void cx25821_audio_fini(void) |
746 | { | 725 | { |
747 | snd_card_free(snd_cx25821_cards[0]); | 726 | struct device_driver *drv = driver_find("cx25821", &pci_bus_type); |
727 | int ret; | ||
728 | |||
729 | ret = driver_for_each_device(drv, NULL, NULL, cx25821_alsa_exit_callback); | ||
730 | } | ||
731 | |||
732 | static int cx25821_alsa_init_callback(struct device *dev, void *data) | ||
733 | { | ||
734 | struct v4l2_device *v4l2_dev = dev_get_drvdata(dev); | ||
735 | struct cx25821_dev *cxdev = get_cx25821(v4l2_dev); | ||
736 | |||
737 | cx25821_audio_initdev(cxdev); | ||
738 | return 0; | ||
748 | } | 739 | } |
749 | 740 | ||
750 | /* | 741 | /* |
@@ -756,29 +747,11 @@ static void cx25821_audio_fini(void) | |||
756 | */ | 747 | */ |
757 | static int cx25821_alsa_init(void) | 748 | static int cx25821_alsa_init(void) |
758 | { | 749 | { |
759 | struct cx25821_dev *dev = NULL; | 750 | struct device_driver *drv = driver_find("cx25821", &pci_bus_type); |
760 | struct list_head *list; | ||
761 | 751 | ||
762 | mutex_lock(&cx25821_devlist_mutex); | 752 | return driver_for_each_device(drv, NULL, NULL, cx25821_alsa_init_callback); |
763 | list_for_each(list, &cx25821_devlist) { | ||
764 | dev = list_entry(list, struct cx25821_dev, devlist); | ||
765 | cx25821_audio_initdev(dev); | ||
766 | } | ||
767 | mutex_unlock(&cx25821_devlist_mutex); | ||
768 | |||
769 | if (dev == NULL) | ||
770 | pr_info("ERROR ALSA: no cx25821 cards found\n"); | ||
771 | |||
772 | return 0; | ||
773 | 753 | ||
774 | } | 754 | } |
775 | 755 | ||
776 | late_initcall(cx25821_alsa_init); | 756 | late_initcall(cx25821_alsa_init); |
777 | module_exit(cx25821_audio_fini); | 757 | module_exit(cx25821_audio_fini); |
778 | |||
779 | /* ----------------------------------------------------------- */ | ||
780 | /* | ||
781 | * Local variables: | ||
782 | * c-basic-offset: 8 | ||
783 | * End: | ||
784 | */ | ||
diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c index 48faf6fc273d..6205ade04a97 100644 --- a/drivers/media/pci/cx25821/cx25821-core.c +++ b/drivers/media/pci/cx25821/cx25821-core.c | |||
@@ -41,13 +41,6 @@ static unsigned int card[] = {[0 ... (CX25821_MAXBOARDS - 1)] = UNSET }; | |||
41 | module_param_array(card, int, NULL, 0444); | 41 | module_param_array(card, int, NULL, 0444); |
42 | MODULE_PARM_DESC(card, "card type"); | 42 | MODULE_PARM_DESC(card, "card type"); |
43 | 43 | ||
44 | static unsigned int cx25821_devcount; | ||
45 | |||
46 | DEFINE_MUTEX(cx25821_devlist_mutex); | ||
47 | EXPORT_SYMBOL(cx25821_devlist_mutex); | ||
48 | LIST_HEAD(cx25821_devlist); | ||
49 | EXPORT_SYMBOL(cx25821_devlist); | ||
50 | |||
51 | const struct sram_channel cx25821_sram_channels[] = { | 44 | const struct sram_channel cx25821_sram_channels[] = { |
52 | [SRAM_CH00] = { | 45 | [SRAM_CH00] = { |
53 | .i = SRAM_CH00, | 46 | .i = SRAM_CH00, |
@@ -871,6 +864,7 @@ static void cx25821_iounmap(struct cx25821_dev *dev) | |||
871 | 864 | ||
872 | static int cx25821_dev_setup(struct cx25821_dev *dev) | 865 | static int cx25821_dev_setup(struct cx25821_dev *dev) |
873 | { | 866 | { |
867 | static unsigned int cx25821_devcount; | ||
874 | int i; | 868 | int i; |
875 | 869 | ||
876 | pr_info("\n***********************************\n"); | 870 | pr_info("\n***********************************\n"); |
@@ -879,15 +873,9 @@ static int cx25821_dev_setup(struct cx25821_dev *dev) | |||
879 | 873 | ||
880 | mutex_init(&dev->lock); | 874 | mutex_init(&dev->lock); |
881 | 875 | ||
882 | atomic_inc(&dev->refcount); | ||
883 | |||
884 | dev->nr = ++cx25821_devcount; | 876 | dev->nr = ++cx25821_devcount; |
885 | sprintf(dev->name, "cx25821[%d]", dev->nr); | 877 | sprintf(dev->name, "cx25821[%d]", dev->nr); |
886 | 878 | ||
887 | mutex_lock(&cx25821_devlist_mutex); | ||
888 | list_add_tail(&dev->devlist, &cx25821_devlist); | ||
889 | mutex_unlock(&cx25821_devlist_mutex); | ||
890 | |||
891 | if (dev->pci->device != 0x8210) { | 879 | if (dev->pci->device != 0x8210) { |
892 | pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n", | 880 | pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n", |
893 | __func__, dev->pci->device); | 881 | __func__, dev->pci->device); |
@@ -1021,9 +1009,6 @@ void cx25821_dev_unregister(struct cx25821_dev *dev) | |||
1021 | 1009 | ||
1022 | release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0)); | 1010 | release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0)); |
1023 | 1011 | ||
1024 | if (!atomic_dec_and_test(&dev->refcount)) | ||
1025 | return; | ||
1026 | |||
1027 | for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) { | 1012 | for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) { |
1028 | if (i == SRAM_CH08) /* audio channel */ | 1013 | if (i == SRAM_CH08) /* audio channel */ |
1029 | continue; | 1014 | continue; |
@@ -1414,10 +1399,6 @@ static void cx25821_finidev(struct pci_dev *pci_dev) | |||
1414 | if (pci_dev->irq) | 1399 | if (pci_dev->irq) |
1415 | free_irq(pci_dev->irq, dev); | 1400 | free_irq(pci_dev->irq, dev); |
1416 | 1401 | ||
1417 | mutex_lock(&cx25821_devlist_mutex); | ||
1418 | list_del(&dev->devlist); | ||
1419 | mutex_unlock(&cx25821_devlist_mutex); | ||
1420 | |||
1421 | cx25821_dev_unregister(dev); | 1402 | cx25821_dev_unregister(dev); |
1422 | v4l2_device_unregister(v4l2_dev); | 1403 | v4l2_device_unregister(v4l2_dev); |
1423 | kfree(dev); | 1404 | kfree(dev); |
diff --git a/drivers/media/pci/cx25821/cx25821-video.c b/drivers/media/pci/cx25821/cx25821-video.c index c418e0d38c24..a9aa09651cab 100644 --- a/drivers/media/pci/cx25821/cx25821-video.c +++ b/drivers/media/pci/cx25821/cx25821-video.c | |||
@@ -654,45 +654,28 @@ static struct videobuf_queue_ops cx25821_video_qops = { | |||
654 | static int video_open(struct file *file) | 654 | static int video_open(struct file *file) |
655 | { | 655 | { |
656 | struct video_device *vdev = video_devdata(file); | 656 | struct video_device *vdev = video_devdata(file); |
657 | struct cx25821_dev *h, *dev = video_drvdata(file); | 657 | struct cx25821_dev *dev = video_drvdata(file); |
658 | struct cx25821_fh *fh; | 658 | struct cx25821_fh *fh; |
659 | struct list_head *list; | ||
660 | int minor = video_devdata(file)->minor; | ||
661 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 659 | enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
662 | u32 pix_format; | 660 | u32 pix_format; |
663 | int ch_id = 0; | 661 | int ch_id; |
664 | int i; | ||
665 | 662 | ||
666 | dprintk(1, "open dev=%s type=%s\n", video_device_node_name(vdev), | 663 | dprintk(1, "open dev=%s type=%s\n", video_device_node_name(vdev), |
667 | v4l2_type_names[type]); | 664 | v4l2_type_names[type]); |
668 | 665 | ||
666 | for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++) | ||
667 | if (dev->channels[ch_id].video_dev == vdev) | ||
668 | break; | ||
669 | |||
670 | /* Can't happen */ | ||
671 | if (ch_id >= MAX_VID_CHANNEL_NUM - 1) | ||
672 | return -ENODEV; | ||
673 | |||
669 | /* allocate + initialize per filehandle data */ | 674 | /* allocate + initialize per filehandle data */ |
670 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 675 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
671 | if (NULL == fh) | 676 | if (NULL == fh) |
672 | return -ENOMEM; | 677 | return -ENOMEM; |
673 | 678 | ||
674 | mutex_lock(&cx25821_devlist_mutex); | ||
675 | |||
676 | list_for_each(list, &cx25821_devlist) | ||
677 | { | ||
678 | h = list_entry(list, struct cx25821_dev, devlist); | ||
679 | |||
680 | for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) { | ||
681 | if (h->channels[i].video_dev && | ||
682 | h->channels[i].video_dev->minor == minor) { | ||
683 | dev = h; | ||
684 | ch_id = i; | ||
685 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | |||
690 | if (NULL == dev) { | ||
691 | mutex_unlock(&cx25821_devlist_mutex); | ||
692 | kfree(fh); | ||
693 | return -ENODEV; | ||
694 | } | ||
695 | |||
696 | file->private_data = fh; | 679 | file->private_data = fh; |
697 | fh->dev = dev; | 680 | fh->dev = dev; |
698 | fh->type = type; | 681 | fh->type = type; |
@@ -719,7 +702,6 @@ static int video_open(struct file *file) | |||
719 | fh, NULL); | 702 | fh, NULL); |
720 | 703 | ||
721 | dprintk(1, "post videobuf_queue_init()\n"); | 704 | dprintk(1, "post videobuf_queue_init()\n"); |
722 | mutex_unlock(&cx25821_devlist_mutex); | ||
723 | 705 | ||
724 | return 0; | 706 | return 0; |
725 | } | 707 | } |
diff --git a/drivers/media/pci/cx25821/cx25821.h b/drivers/media/pci/cx25821/cx25821.h index d7e71f46defc..195b00407b5a 100644 --- a/drivers/media/pci/cx25821/cx25821.h +++ b/drivers/media/pci/cx25821/cx25821.h | |||
@@ -238,9 +238,9 @@ struct cx25821_channel { | |||
238 | int cif_width; | 238 | int cif_width; |
239 | }; | 239 | }; |
240 | 240 | ||
241 | struct snd_card; | ||
242 | |||
241 | struct cx25821_dev { | 243 | struct cx25821_dev { |
242 | struct list_head devlist; | ||
243 | atomic_t refcount; | ||
244 | struct v4l2_device v4l2_dev; | 244 | struct v4l2_device v4l2_dev; |
245 | 245 | ||
246 | /* pci stuff */ | 246 | /* pci stuff */ |
@@ -252,6 +252,8 @@ struct cx25821_dev { | |||
252 | u8 __iomem *bmmio; | 252 | u8 __iomem *bmmio; |
253 | int pci_irqmask; | 253 | int pci_irqmask; |
254 | int hwrevision; | 254 | int hwrevision; |
255 | /* used by cx25821-alsa */ | ||
256 | struct snd_card *card; | ||
255 | 257 | ||
256 | u32 clk_freq; | 258 | u32 clk_freq; |
257 | 259 | ||
@@ -403,9 +405,6 @@ static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev) | |||
403 | #define cx25821_call_all(dev, o, f, args...) \ | 405 | #define cx25821_call_all(dev, o, f, args...) \ |
404 | v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) | 406 | v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) |
405 | 407 | ||
406 | extern struct list_head cx25821_devlist; | ||
407 | extern struct mutex cx25821_devlist_mutex; | ||
408 | |||
409 | extern struct cx25821_board cx25821_boards[]; | 408 | extern struct cx25821_board cx25821_boards[]; |
410 | extern struct cx25821_subid cx25821_subids[]; | 409 | extern struct cx25821_subid cx25821_subids[]; |
411 | 410 | ||