diff options
Diffstat (limited to 'drivers/media/video/cx18/cx18-driver.c')
| -rw-r--r-- | drivers/media/video/cx18/cx18-driver.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 52d04f640b73..450c48dd995a 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
| @@ -797,21 +797,28 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, | |||
| 797 | return -ENOMEM; | 797 | return -ENOMEM; |
| 798 | } | 798 | } |
| 799 | cx18_cards[cx18_cards_active] = cx; | 799 | cx18_cards[cx18_cards_active] = cx; |
| 800 | cx->pci_dev = pci_dev; | ||
| 801 | cx->num = cx18_cards_active++; | 800 | cx->num = cx18_cards_active++; |
| 802 | snprintf(cx->name, sizeof(cx->name), "cx18-%d", cx->num); | 801 | snprintf(cx->name, sizeof(cx->name), "cx18-%d", cx->num); |
| 803 | CX18_INFO("Initializing card #%d\n", cx->num); | 802 | CX18_INFO("Initializing card #%d\n", cx->num); |
| 804 | 803 | ||
| 805 | spin_unlock(&cx18_cards_lock); | 804 | spin_unlock(&cx18_cards_lock); |
| 806 | 805 | ||
| 806 | cx->pci_dev = pci_dev; | ||
| 807 | retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); | ||
| 808 | if (retval) { | ||
| 809 | CX18_ERR("Call to v4l2_device_register() failed\n"); | ||
| 810 | goto err; | ||
| 811 | } | ||
| 812 | CX18_DEBUG_INFO("registered v4l2_device name: %s\n", cx->v4l2_dev.name); | ||
| 813 | |||
| 807 | cx18_process_options(cx); | 814 | cx18_process_options(cx); |
| 808 | if (cx->options.cardtype == -1) { | 815 | if (cx->options.cardtype == -1) { |
| 809 | retval = -ENODEV; | 816 | retval = -ENODEV; |
| 810 | goto err; | 817 | goto unregister_v4l2; |
| 811 | } | 818 | } |
| 812 | if (cx18_init_struct1(cx)) { | 819 | if (cx18_init_struct1(cx)) { |
| 813 | retval = -ENOMEM; | 820 | retval = -ENOMEM; |
| 814 | goto err; | 821 | goto unregister_v4l2; |
| 815 | } | 822 | } |
| 816 | 823 | ||
| 817 | CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); | 824 | CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); |
| @@ -821,9 +828,6 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, | |||
| 821 | if (retval != 0) | 828 | if (retval != 0) |
| 822 | goto free_workqueue; | 829 | goto free_workqueue; |
| 823 | 830 | ||
| 824 | /* save cx in the pci struct for later use */ | ||
| 825 | pci_set_drvdata(pci_dev, cx); | ||
| 826 | |||
| 827 | /* map io memory */ | 831 | /* map io memory */ |
| 828 | CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", | 832 | CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", |
| 829 | cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); | 833 | cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); |
| @@ -1002,6 +1006,8 @@ free_mem: | |||
| 1002 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); | 1006 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); |
| 1003 | free_workqueue: | 1007 | free_workqueue: |
| 1004 | destroy_workqueue(cx->work_queue); | 1008 | destroy_workqueue(cx->work_queue); |
| 1009 | unregister_v4l2: | ||
| 1010 | v4l2_device_unregister(&cx->v4l2_dev); | ||
| 1005 | err: | 1011 | err: |
| 1006 | if (retval == 0) | 1012 | if (retval == 0) |
| 1007 | retval = -ENODEV; | 1013 | retval = -ENODEV; |
| @@ -1106,7 +1112,8 @@ static void cx18_cancel_epu_work_orders(struct cx18 *cx) | |||
| 1106 | 1112 | ||
| 1107 | static void cx18_remove(struct pci_dev *pci_dev) | 1113 | static void cx18_remove(struct pci_dev *pci_dev) |
| 1108 | { | 1114 | { |
| 1109 | struct cx18 *cx = pci_get_drvdata(pci_dev); | 1115 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
| 1116 | struct cx18 *cx = container_of(v4l2_dev, struct cx18, v4l2_dev); | ||
| 1110 | 1117 | ||
| 1111 | CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); | 1118 | CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); |
| 1112 | 1119 | ||
| @@ -1137,6 +1144,8 @@ static void cx18_remove(struct pci_dev *pci_dev) | |||
| 1137 | 1144 | ||
| 1138 | pci_disable_device(cx->pci_dev); | 1145 | pci_disable_device(cx->pci_dev); |
| 1139 | 1146 | ||
| 1147 | v4l2_device_unregister(v4l2_dev); | ||
| 1148 | |||
| 1140 | CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); | 1149 | CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); |
| 1141 | } | 1150 | } |
| 1142 | 1151 | ||
