Commit 05ed62da authored by Daniel Scheller's avatar Daniel Scheller Committed by Mauro Carvalho Chehab

media: ddbridge: move ddb_wq and the wq+class initialisation to -core

Move the ddbridge module initialisation and cleanup code to ddbridge-core
and set up the ddb_wq workqueue there, and create and destroy the ddb
device class there aswell. Due to this, the prototypes for ddb_wq,
ddb_class_create() and ddb_class_destroy() aren't required in ddbridge.h
anymore, so remove them. Also, declare ddb_wq and the ddb_class_*()
functions static.

Picked up from the upstream dddvb-0.9.33 release.
Signed-off-by: default avatarDaniel Scheller <d.scheller@gmx.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5589974e
...@@ -100,7 +100,7 @@ MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods"); ...@@ -100,7 +100,7 @@ MODULE_PARM_DESC(stv0910_single, "use stv0910 cards as single demods");
static DEFINE_MUTEX(redirect_lock); static DEFINE_MUTEX(redirect_lock);
struct workqueue_struct *ddb_wq; static struct workqueue_struct *ddb_wq;
static struct ddb *ddbs[DDB_MAX_ADAPTER]; static struct ddb *ddbs[DDB_MAX_ADAPTER];
...@@ -3040,7 +3040,7 @@ static struct class ddb_class = { ...@@ -3040,7 +3040,7 @@ static struct class ddb_class = {
.devnode = ddb_devnode, .devnode = ddb_devnode,
}; };
int ddb_class_create(void) static int ddb_class_create(void)
{ {
ddb_major = register_chrdev(0, DDB_NAME, &ddb_fops); ddb_major = register_chrdev(0, DDB_NAME, &ddb_fops);
if (ddb_major < 0) if (ddb_major < 0)
...@@ -3050,7 +3050,7 @@ int ddb_class_create(void) ...@@ -3050,7 +3050,7 @@ int ddb_class_create(void)
return 0; return 0;
} }
void ddb_class_destroy(void) static void ddb_class_destroy(void)
{ {
class_unregister(&ddb_class); class_unregister(&ddb_class);
unregister_chrdev(ddb_major, DDB_NAME); unregister_chrdev(ddb_major, DDB_NAME);
...@@ -3322,3 +3322,29 @@ void ddb_unmap(struct ddb *dev) ...@@ -3322,3 +3322,29 @@ void ddb_unmap(struct ddb *dev)
iounmap(dev->regs); iounmap(dev->regs);
vfree(dev); vfree(dev);
} }
int ddb_exit_ddbridge(int stage, int error)
{
switch (stage) {
default:
case 2:
destroy_workqueue(ddb_wq);
/* fall-through */
case 1:
ddb_class_destroy();
break;
}
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;
}
...@@ -282,32 +282,25 @@ static struct pci_driver ddb_pci_driver = { ...@@ -282,32 +282,25 @@ 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);
......
...@@ -368,9 +368,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len); ...@@ -368,9 +368,6 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len);
/****************************************************************************/ /****************************************************************************/
/* ddbridge-main.c (modparams) */
extern struct workqueue_struct *ddb_wq;
/* ddbridge-core.c */ /* ddbridge-core.c */
void ddb_ports_detach(struct ddb *dev); void ddb_ports_detach(struct ddb *dev);
void ddb_ports_release(struct ddb *dev); void ddb_ports_release(struct ddb *dev);
...@@ -383,9 +380,9 @@ void ddb_ports_init(struct ddb *dev); ...@@ -383,9 +380,9 @@ void ddb_ports_init(struct ddb *dev);
int ddb_buffers_alloc(struct ddb *dev); int ddb_buffers_alloc(struct ddb *dev);
int ddb_ports_attach(struct ddb *dev); int ddb_ports_attach(struct ddb *dev);
int ddb_device_create(struct ddb *dev); int ddb_device_create(struct ddb *dev);
int ddb_class_create(void);
void ddb_class_destroy(void);
int ddb_init(struct ddb *dev); int ddb_init(struct ddb *dev);
void ddb_unmap(struct ddb *dev); void ddb_unmap(struct ddb *dev);
int ddb_exit_ddbridge(int stage, int error);
int ddb_init_ddbridge(void);
#endif /* DDBRIDGE_H */ #endif /* DDBRIDGE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment