Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 707bcf32 authored by Tejun Heo's avatar Tejun Heo
Browse files

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: default avatarTejun Heo <tj@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
parent 883624a0
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -189,8 +189,14 @@ static void request_modules(struct bttv *dev)
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct bttv *dev)
{
	flush_work_sync(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */


@@ -4573,6 +4579,9 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
	if (bttv_verbose)
		printk("bttv%d: unloading\n",btv->c.nr);

	if (bttv_tvcards[btv->c.type].has_dvb)
		flush_request_modules(btv);

	/* shutdown everything (DMA+IRQs) */
	btand(~15, BT848_GPIO_DMA_CTL);
	btwrite(0, BT848_INT_MASK);
+8 −0
Original line number Diff line number Diff line
@@ -266,8 +266,14 @@ static void request_modules(struct cx18 *dev)
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct cx18 *dev)
{
	flush_work_sync(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */

/* Generic utility functions */
@@ -1226,6 +1232,8 @@ static void cx18_remove(struct pci_dev *pci_dev)

	CX18_DEBUG_INFO("Removing Card\n");

	flush_request_modules(cx);

	/* Stop all captures */
	CX18_DEBUG_INFO("Stopping all streams\n");
	if (atomic_read(&cx->tot_capturing) > 0)
+8 −0
Original line number Diff line number Diff line
@@ -762,8 +762,14 @@ static void request_modules(struct cx231xx *dev)
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct cx231xx *dev)
{
	flush_work_sync(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */

/*
@@ -1096,6 +1102,8 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface)
	if (!dev->udev)
		return;

	flush_request_modules(dev);

	/* delete v4l2 device */
	v4l2_device_unregister(&dev->v4l2_dev);

+8 −0
Original line number Diff line number Diff line
@@ -66,8 +66,14 @@ static void request_modules(struct cx8802_dev *dev)
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct cx8802_dev *dev)
{
	flush_work_sync(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */


@@ -819,6 +825,8 @@ static void __devexit cx8802_remove(struct pci_dev *pci_dev)

	dprintk( 1, "%s\n", __func__);

	flush_request_modules(dev);

	if (!list_empty(&dev->drvlist)) {
		struct cx8802_driver *drv, *tmp;
		int err;
+8 −0
Original line number Diff line number Diff line
@@ -2632,8 +2632,14 @@ static void request_modules(struct em28xx *dev)
	INIT_WORK(&dev->request_module_wk, request_module_async);
	schedule_work(&dev->request_module_wk);
}

static void flush_request_modules(struct em28xx *dev)
{
	flush_work_sync(&dev->request_module_wk);
}
#else
#define request_modules(dev)
#define flush_request_modules(dev)
#endif /* CONFIG_MODULES */

/*
@@ -3060,6 +3066,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)

	em28xx_info("disconnecting %s\n", dev->vdev->name);

	flush_request_modules(dev);

	/* wait until all current v4l2 io is finished then deallocate
	   resources */
	mutex_lock(&dev->lock);
Loading