ioc4: use static work_struct for ioc4_load_modules()
There is no reason to dynamically allocate work_struct for ioc4_load_modules(). It makes the code more complex and makes it impossible to flush the work directly. Use static work ioc4_load_modules_work instead and flush it directly on exit. This removes the use of flush_scheduled_work() which is being deprecated. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Brent Casavant <bcasavan@sgi.com>
This commit is contained in:
parent
ee4569a3a7
commit
883624a08c
|
@ -273,13 +273,11 @@ ioc4_variant(struct ioc4_driver_data *idd)
|
||||||
static void __devinit
|
static void __devinit
|
||||||
ioc4_load_modules(struct work_struct *work)
|
ioc4_load_modules(struct work_struct *work)
|
||||||
{
|
{
|
||||||
/* arg just has to be freed */
|
|
||||||
|
|
||||||
request_module("sgiioc4");
|
request_module("sgiioc4");
|
||||||
|
|
||||||
kfree(work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DECLARE_WORK(ioc4_load_modules_work, ioc4_load_modules);
|
||||||
|
|
||||||
/* Adds a new instance of an IOC4 card */
|
/* Adds a new instance of an IOC4 card */
|
||||||
static int __devinit
|
static int __devinit
|
||||||
ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
|
ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
|
||||||
|
@ -396,21 +394,12 @@ ioc4_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
|
||||||
* PCI device.
|
* PCI device.
|
||||||
*/
|
*/
|
||||||
if (idd->idd_variant != IOC4_VARIANT_PCI_RT) {
|
if (idd->idd_variant != IOC4_VARIANT_PCI_RT) {
|
||||||
struct work_struct *work;
|
/* Request the module from a work procedure as the modprobe
|
||||||
work = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
|
* goes out to a userland helper and that will hang if done
|
||||||
if (!work) {
|
* directly from ioc4_probe().
|
||||||
printk(KERN_WARNING
|
|
||||||
"%s: IOC4 unable to allocate memory for "
|
|
||||||
"load of sub-modules.\n", __func__);
|
|
||||||
} else {
|
|
||||||
/* Request the module from a work procedure as the
|
|
||||||
* modprobe goes out to a userland helper and that
|
|
||||||
* will hang if done directly from ioc4_probe().
|
|
||||||
*/
|
*/
|
||||||
printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n");
|
printk(KERN_INFO "IOC4 loading sgiioc4 submodule\n");
|
||||||
INIT_WORK(work, ioc4_load_modules);
|
schedule_work(&ioc4_load_modules_work);
|
||||||
schedule_work(work);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -498,7 +487,7 @@ static void __exit
|
||||||
ioc4_exit(void)
|
ioc4_exit(void)
|
||||||
{
|
{
|
||||||
/* Ensure ioc4_load_modules() has completed before exiting */
|
/* Ensure ioc4_load_modules() has completed before exiting */
|
||||||
flush_scheduled_work();
|
flush_work_sync(&ioc4_load_modules_work);
|
||||||
pci_unregister_driver(&ioc4_driver);
|
pci_unregister_driver(&ioc4_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue