1
0
mirror of https://github.com/DigitalDevices/dddvb.git synced 2023-10-10 13:37:43 +02:00

move common workqueue and class init/exit to core

This commit is contained in:
Ralph Metzler 2017-10-22 20:58:58 +02:00
parent 3a2e87eefe
commit e239a6d772
4 changed files with 39 additions and 30 deletions

View File

@ -4422,3 +4422,24 @@ void ddb_unmap(struct ddb *dev)
vfree(dev); vfree(dev);
} }
int ddb_exit_ddbridge(int stage, int error)
{
switch (stage) {
default:
case 2:
destroy_workqueue(ddb_wq);
case 1:
ddb_class_destroy();
}
return error;
}
int ddb_init_ddbridge(void)
{
if (ddb_class_create() < 0)
return -1;
ddb_wq = alloc_workqueue("ddbridge", 0, 0);
if (!ddb_wq)
return ddb_exit_ddbridge(1, -1);
return 0;
}

View File

@ -31,8 +31,6 @@ MODULE_PARM_DESC(msi,
" Control MSI interrupts: 0-disable, 1-enable (default)"); " Control MSI interrupts: 0-disable, 1-enable (default)");
#endif #endif
extern struct workqueue_struct *ddb_wq;
#if (KERNEL_VERSION(4, 8, 0) > LINUX_VERSION_CODE) #if (KERNEL_VERSION(4, 8, 0) > LINUX_VERSION_CODE)
int pci_irq_vector(struct pci_dev *dev, unsigned int nr) int pci_irq_vector(struct pci_dev *dev, unsigned int nr)
{ {
@ -404,32 +402,24 @@ static struct pci_driver ddb_pci_driver = {
static __init int module_init_ddbridge(void) static __init int module_init_ddbridge(void)
{ {
int stat = -1; int stat;
pr_info("Digital Devices PCIE bridge driver " pr_info("Digital Devices PCIE bridge driver "
DDBRIDGE_VERSION DDBRIDGE_VERSION
", Copyright (C) 2010-17 Digital Devices GmbH\n"); ", Copyright (C) 2010-17 Digital Devices GmbH\n");
if (ddb_class_create() < 0) stat = ddb_init_ddbridge();
return -1; if (stat < 0)
ddb_wq = create_workqueue("ddbridge"); return stat;
if (!ddb_wq)
goto exit1;
stat = pci_register_driver(&ddb_pci_driver); stat = pci_register_driver(&ddb_pci_driver);
if (stat < 0) if (stat < 0)
goto exit2; ddb_exit_ddbridge(0, stat);
return stat;
exit2:
destroy_workqueue(ddb_wq);
exit1:
ddb_class_destroy();
return stat; return stat;
} }
static __exit void module_exit_ddbridge(void) static __exit void module_exit_ddbridge(void)
{ {
pci_unregister_driver(&ddb_pci_driver); pci_unregister_driver(&ddb_pci_driver);
destroy_workqueue(ddb_wq); ddb_exit_ddbridge(0, 0);
ddb_class_destroy();
} }
module_init(module_init_ddbridge); module_init(module_init_ddbridge);

View File

@ -560,8 +560,8 @@ irqreturn_t ddb_irq_handler(int irq, void *dev_id);
irqreturn_t ddb_irq_handler_v2(int irq, void *dev_id); irqreturn_t ddb_irq_handler_v2(int irq, void *dev_id);
void ddb_reset_ios(struct ddb *dev); void ddb_reset_ios(struct ddb *dev);
int ddb_init(struct ddb *dev); int ddb_init(struct ddb *dev);
int ddb_class_create(void); int ddb_exit_ddbridge(int stage, int error);
void ddb_class_destroy(void); int ddb_init_ddbridge(void);
int ddb_i2c_init(struct ddb *dev); int ddb_i2c_init(struct ddb *dev);
void ddb_i2c_release(struct ddb *dev); void ddb_i2c_release(struct ddb *dev);

View File

@ -141,25 +141,23 @@ static struct platform_driver octonet_driver __refdata = {
static __init int init_octonet(void) static __init int init_octonet(void)
{ {
int res; int stat;
pr_info("DDBridge: Digital Devices OctopusNet driver " DDBRIDGE_VERSION pr_info("DDBridge: Digital Devices OctopusNet driver " DDBRIDGE_VERSION
", Copyright (C) 2010-16 Digital Devices GmbH\n"); ", Copyright (C) 2010-17 Digital Devices GmbH\n");
res = ddb_class_create(); stat = ddb_init_ddbridge();
if (res) if (stat < 0)
return res; return stat;
res = platform_driver_probe(&octonet_driver, octonet_probe); stat = platform_driver_probe(&octonet_driver, octonet_probe);
if (res) { if (stat < 0)
ddb_class_destroy(); ddb_exit_ddbridge(0, stat);
return res; return stat;
}
return 0;
} }
static __exit void exit_octonet(void) static __exit void exit_octonet(void)
{ {
platform_driver_unregister(&octonet_driver); platform_driver_unregister(&octonet_driver);
ddb_class_destroy(); ddb_exit_ddbridge(0, 0);
} }
module_init(init_octonet); module_init(init_octonet);