diff options
author | Tejun Heo <tj@kernel.org> | 2010-12-24 10:14:20 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-12-24 10:14:20 -0500 |
commit | 707bcf326bd50c875d82bd2e7c31dcfb92b7e813 (patch) | |
tree | 6359ba94e571ca15ef6fa0ff44f5872c8210e157 | |
parent | 883624a08cb4144343e7362d9fff0e2c69613ebf (diff) |
media/video: explicitly flush request_module work
Video drivers request submodules using a work during probe and calls
flush_scheduled_work() on exit to make sure the work is complete
before being unloaded. This patch makes these drivers flush the work
directly instead of using flush_scheduled_work().
While at it, relocate request_submodules() call in saa7134_initdev()
right right before successful return as in other drivers to avoid
failing after the work is scheduled and returning failure without the
work still active.
This is in preparation for the deprecation of flush_scheduled_work().
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/bt8xx/bttv-driver.c | 9 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.c | 8 | ||||
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 8 | ||||
-rw-r--r-- | drivers/media/video/cx88/cx88-mpeg.c | 8 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-cards.c | 8 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 11 |
6 files changed, 50 insertions, 2 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index a529619e51f6..53285aa6e72c 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
@@ -189,8 +189,14 @@ static void request_modules(struct bttv *dev) | |||
189 | INIT_WORK(&dev->request_module_wk, request_module_async); | 189 | INIT_WORK(&dev->request_module_wk, request_module_async); |
190 | schedule_work(&dev->request_module_wk); | 190 | schedule_work(&dev->request_module_wk); |
191 | } | 191 | } |
192 | |||
193 | static void flush_request_modules(struct bttv *dev) | ||
194 | { | ||
195 | flush_work_sync(&dev->request_module_wk); | ||
196 | } | ||
192 | #else | 197 | #else |
193 | #define request_modules(dev) | 198 | #define request_modules(dev) |
199 | #define flush_request_modules(dev) | ||
194 | #endif /* CONFIG_MODULES */ | 200 | #endif /* CONFIG_MODULES */ |
195 | 201 | ||
196 | 202 | ||
@@ -4573,6 +4579,9 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev) | |||
4573 | if (bttv_verbose) | 4579 | if (bttv_verbose) |
4574 | printk("bttv%d: unloading\n",btv->c.nr); | 4580 | printk("bttv%d: unloading\n",btv->c.nr); |
4575 | 4581 | ||
4582 | if (bttv_tvcards[btv->c.type].has_dvb) | ||
4583 | flush_request_modules(btv); | ||
4584 | |||
4576 | /* shutdown everything (DMA+IRQs) */ | 4585 | /* shutdown everything (DMA+IRQs) */ |
4577 | btand(~15, BT848_GPIO_DMA_CTL); | 4586 | btand(~15, BT848_GPIO_DMA_CTL); |
4578 | btwrite(0, BT848_INT_MASK); | 4587 | btwrite(0, BT848_INT_MASK); |
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index df60f27337cf..f6fdcfb1084b 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -266,8 +266,14 @@ static void request_modules(struct cx18 *dev) | |||
266 | INIT_WORK(&dev->request_module_wk, request_module_async); | 266 | INIT_WORK(&dev->request_module_wk, request_module_async); |
267 | schedule_work(&dev->request_module_wk); | 267 | schedule_work(&dev->request_module_wk); |
268 | } | 268 | } |
269 | |||
270 | static void flush_request_modules(struct cx18 *dev) | ||
271 | { | ||
272 | flush_work_sync(&dev->request_module_wk); | ||
273 | } | ||
269 | #else | 274 | #else |
270 | #define request_modules(dev) | 275 | #define request_modules(dev) |
276 | #define flush_request_modules(dev) | ||
271 | #endif /* CONFIG_MODULES */ | 277 | #endif /* CONFIG_MODULES */ |
272 | 278 | ||
273 | /* Generic utility functions */ | 279 | /* Generic utility functions */ |
@@ -1226,6 +1232,8 @@ static void cx18_remove(struct pci_dev *pci_dev) | |||
1226 | 1232 | ||
1227 | CX18_DEBUG_INFO("Removing Card\n"); | 1233 | CX18_DEBUG_INFO("Removing Card\n"); |
1228 | 1234 | ||
1235 | flush_request_modules(cx); | ||
1236 | |||
1229 | /* Stop all captures */ | 1237 | /* Stop all captures */ |
1230 | CX18_DEBUG_INFO("Stopping all streams\n"); | 1238 | CX18_DEBUG_INFO("Stopping all streams\n"); |
1231 | if (atomic_read(&cx->tot_capturing) > 0) | 1239 | if (atomic_read(&cx->tot_capturing) > 0) |
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 56c2d8195ac6..05b65057b8a7 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -762,8 +762,14 @@ static void request_modules(struct cx231xx *dev) | |||
762 | INIT_WORK(&dev->request_module_wk, request_module_async); | 762 | INIT_WORK(&dev->request_module_wk, request_module_async); |
763 | schedule_work(&dev->request_module_wk); | 763 | schedule_work(&dev->request_module_wk); |
764 | } | 764 | } |
765 | |||
766 | static void flush_request_modules(struct cx231xx *dev) | ||
767 | { | ||
768 | flush_work_sync(&dev->request_module_wk); | ||
769 | } | ||
765 | #else | 770 | #else |
766 | #define request_modules(dev) | 771 | #define request_modules(dev) |
772 | #define flush_request_modules(dev) | ||
767 | #endif /* CONFIG_MODULES */ | 773 | #endif /* CONFIG_MODULES */ |
768 | 774 | ||
769 | /* | 775 | /* |
@@ -1096,6 +1102,8 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
1096 | if (!dev->udev) | 1102 | if (!dev->udev) |
1097 | return; | 1103 | return; |
1098 | 1104 | ||
1105 | flush_request_modules(dev); | ||
1106 | |||
1099 | /* delete v4l2 device */ | 1107 | /* delete v4l2 device */ |
1100 | v4l2_device_unregister(&dev->v4l2_dev); | 1108 | v4l2_device_unregister(&dev->v4l2_dev); |
1101 | 1109 | ||
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index f7d71acbb078..addf9545e9bf 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
@@ -66,8 +66,14 @@ static void request_modules(struct cx8802_dev *dev) | |||
66 | INIT_WORK(&dev->request_module_wk, request_module_async); | 66 | INIT_WORK(&dev->request_module_wk, request_module_async); |
67 | schedule_work(&dev->request_module_wk); | 67 | schedule_work(&dev->request_module_wk); |
68 | } | 68 | } |
69 | |||
70 | static void flush_request_modules(struct cx8802_dev *dev) | ||
71 | { | ||
72 | flush_work_sync(&dev->request_module_wk); | ||
73 | } | ||
69 | #else | 74 | #else |
70 | #define request_modules(dev) | 75 | #define request_modules(dev) |
76 | #define flush_request_modules(dev) | ||
71 | #endif /* CONFIG_MODULES */ | 77 | #endif /* CONFIG_MODULES */ |
72 | 78 | ||
73 | 79 | ||
@@ -819,6 +825,8 @@ static void __devexit cx8802_remove(struct pci_dev *pci_dev) | |||
819 | 825 | ||
820 | dprintk( 1, "%s\n", __func__); | 826 | dprintk( 1, "%s\n", __func__); |
821 | 827 | ||
828 | flush_request_modules(dev); | ||
829 | |||
822 | if (!list_empty(&dev->drvlist)) { | 830 | if (!list_empty(&dev->drvlist)) { |
823 | struct cx8802_driver *drv, *tmp; | 831 | struct cx8802_driver *drv, *tmp; |
824 | int err; | 832 | int err; |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index 54859233f311..d60538bb22b3 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
@@ -2632,8 +2632,14 @@ static void request_modules(struct em28xx *dev) | |||
2632 | INIT_WORK(&dev->request_module_wk, request_module_async); | 2632 | INIT_WORK(&dev->request_module_wk, request_module_async); |
2633 | schedule_work(&dev->request_module_wk); | 2633 | schedule_work(&dev->request_module_wk); |
2634 | } | 2634 | } |
2635 | |||
2636 | static void flush_request_modules(struct em28xx *dev) | ||
2637 | { | ||
2638 | flush_work_sync(&dev->request_module_wk); | ||
2639 | } | ||
2635 | #else | 2640 | #else |
2636 | #define request_modules(dev) | 2641 | #define request_modules(dev) |
2642 | #define flush_request_modules(dev) | ||
2637 | #endif /* CONFIG_MODULES */ | 2643 | #endif /* CONFIG_MODULES */ |
2638 | 2644 | ||
2639 | /* | 2645 | /* |
@@ -3060,6 +3066,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
3060 | 3066 | ||
3061 | em28xx_info("disconnecting %s\n", dev->vdev->name); | 3067 | em28xx_info("disconnecting %s\n", dev->vdev->name); |
3062 | 3068 | ||
3069 | flush_request_modules(dev); | ||
3070 | |||
3063 | /* wait until all current v4l2 io is finished then deallocate | 3071 | /* wait until all current v4l2 io is finished then deallocate |
3064 | resources */ | 3072 | resources */ |
3065 | mutex_lock(&dev->lock); | 3073 | mutex_lock(&dev->lock); |
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 764d7d219fed..2ceeac7ae34d 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -166,8 +166,14 @@ static void request_submodules(struct saa7134_dev *dev) | |||
166 | schedule_work(&dev->request_module_wk); | 166 | schedule_work(&dev->request_module_wk); |
167 | } | 167 | } |
168 | 168 | ||
169 | static void flush_request_submodules(struct saa7134_dev *dev) | ||
170 | { | ||
171 | flush_work_sync(&dev->request_module_wk); | ||
172 | } | ||
173 | |||
169 | #else | 174 | #else |
170 | #define request_submodules(dev) | 175 | #define request_submodules(dev) |
176 | #define flush_request_submodules(dev) | ||
171 | #endif /* CONFIG_MODULES */ | 177 | #endif /* CONFIG_MODULES */ |
172 | 178 | ||
173 | /* ------------------------------------------------------------------ */ | 179 | /* ------------------------------------------------------------------ */ |
@@ -1010,8 +1016,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1010 | } | 1016 | } |
1011 | } | 1017 | } |
1012 | 1018 | ||
1013 | request_submodules(dev); | ||
1014 | |||
1015 | v4l2_prio_init(&dev->prio); | 1019 | v4l2_prio_init(&dev->prio); |
1016 | 1020 | ||
1017 | mutex_lock(&saa7134_devlist_lock); | 1021 | mutex_lock(&saa7134_devlist_lock); |
@@ -1066,6 +1070,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1066 | if (saa7134_dmasound_init && !dev->dmasound.priv_data) | 1070 | if (saa7134_dmasound_init && !dev->dmasound.priv_data) |
1067 | saa7134_dmasound_init(dev); | 1071 | saa7134_dmasound_init(dev); |
1068 | 1072 | ||
1073 | request_submodules(dev); | ||
1069 | return 0; | 1074 | return 0; |
1070 | 1075 | ||
1071 | fail4: | 1076 | fail4: |
@@ -1091,6 +1096,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | |||
1091 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); | 1096 | struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev); |
1092 | struct saa7134_mpeg_ops *mops; | 1097 | struct saa7134_mpeg_ops *mops; |
1093 | 1098 | ||
1099 | flush_request_submodules(dev); | ||
1100 | |||
1094 | /* Release DMA sound modules if present */ | 1101 | /* Release DMA sound modules if present */ |
1095 | if (saa7134_dmasound_exit && dev->dmasound.priv_data) { | 1102 | if (saa7134_dmasound_exit && dev->dmasound.priv_data) { |
1096 | saa7134_dmasound_exit(dev); | 1103 | saa7134_dmasound_exit(dev); |