summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorKenneth Aafloy <devnull@localhost>2004-07-12 18:15:34 +0000
committerKenneth Aafloy <devnull@localhost>2004-07-12 18:15:34 +0000
commitbcfcd8a4a5a3ab5bac73391be855e5770379d504 (patch)
tree6682191b2ae7be87ef4867d5ae4d2c0c334e945b /linux/drivers
parent481ccf4d48f8ed8928ab6d2ef02b39a6349ac300 (diff)
downloadmediapointer-dvb-s2-bcfcd8a4a5a3ab5bac73391be855e5770379d504.tar.gz
mediapointer-dvb-s2-bcfcd8a4a5a3ab5bac73391be855e5770379d504.tar.bz2
- Properly lock the frontend module on open/close.
- Remove module ref count changes to av7110 and budget-core, as they did not do the right thing.
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_frontend.c18
-rw-r--r--linux/drivers/media/dvb/frontends/alps_tdlb7.c3
-rw-r--r--linux/drivers/media/dvb/frontends/alps_tdmb7.c3
-rw-r--r--linux/drivers/media/dvb/frontends/at76c651.c3
-rw-r--r--linux/drivers/media/dvb/frontends/sp887x.c3
-rw-r--r--linux/drivers/media/dvb/frontends/stv0299.c3
-rw-r--r--linux/drivers/media/dvb/frontends/tda1004x.c8
-rw-r--r--linux/drivers/media/dvb/frontends/ves1x93.c3
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c12
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-core.c10
10 files changed, 37 insertions, 29 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
index a45978f5e..7748ba9b6 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -96,6 +96,7 @@ struct dvb_frontend_data {
struct dvb_device *dvbdev;
struct dvb_frontend_parameters parameters;
struct dvb_fe_events events;
+ struct module *module;
struct semaphore sem;
struct list_head list_head;
wait_queue_head_t wait_queue;
@@ -834,6 +835,11 @@ static int dvb_frontend_open (struct inode *inode, struct file *file)
fe->events.eventr = fe->events.eventw = 0;
}
+ if (!ret && fe->module) {
+ if (!try_module_get(fe->module))
+ return -EINVAL;
+ }
+
return ret;
}
@@ -842,13 +848,19 @@ static int dvb_frontend_release (struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = file->private_data;
struct dvb_frontend_data *fe = dvbdev->priv;
+ int ret = 0;
dprintk ("%s\n", __FUNCTION__);
if ((file->f_flags & O_ACCMODE) != O_RDONLY)
fe->release_jiffies = jiffies;
- return dvb_generic_release (inode, file);
+ ret = dvb_generic_release (inode, file);
+
+ if (!ret && fe->module)
+ module_put(fe->module);
+
+ return ret;
}
@@ -1171,7 +1183,8 @@ dvb_register_frontend_new (int (*ioctl) (struct dvb_frontend *frontend,
unsigned int cmd, void *arg),
struct dvb_adapter *dvb_adapter,
void *data,
- struct dvb_frontend_info *info)
+ struct dvb_frontend_info *info,
+ struct module *module)
{
struct list_head *entry;
struct dvb_frontend_data *fe;
@@ -1201,6 +1214,7 @@ dvb_register_frontend_new (int (*ioctl) (struct dvb_frontend *frontend,
init_MUTEX (&fe->events.sem);
fe->events.eventw = fe->events.eventr = 0;
fe->events.overflow = 0;
+ fe->module = module;
fe->frontend.ioctl = ioctl;
fe->frontend.dvb_adapter = dvb_adapter;
diff --git a/linux/drivers/media/dvb/frontends/alps_tdlb7.c b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
index 12f546d4c..d6171d6e8 100644
--- a/linux/drivers/media/dvb/frontends/alps_tdlb7.c
+++ b/linux/drivers/media/dvb/frontends/alps_tdlb7.c
@@ -659,7 +659,8 @@ static int attach_adapter(struct i2c_adapter *adapter)
goto out;
}
- ret = dvb_register_frontend_new (tdlb7_ioctl, state->dvb, (void*) state, &tdlb7_info);
+ ret = dvb_register_frontend_new(tdlb7_ioctl, state->dvb, state,
+ &tdlb7_info, THIS_MODULE);
if (ret) {
printk("tdlb7: registering frontend to dvb-core failed.\n");
release_firmware(fw);
diff --git a/linux/drivers/media/dvb/frontends/alps_tdmb7.c b/linux/drivers/media/dvb/frontends/alps_tdmb7.c
index a5976bd0f..7956303ff 100644
--- a/linux/drivers/media/dvb/frontends/alps_tdmb7.c
+++ b/linux/drivers/media/dvb/frontends/alps_tdmb7.c
@@ -442,7 +442,8 @@ static int attach_adapter (struct i2c_adapter *adapter)
BUG_ON(!state->dvb);
- ret = dvb_register_frontend_new (tdmb7_ioctl, state->dvb, state, &tdmb7_info);
+ ret = dvb_register_frontend_new (tdmb7_ioctl, state->dvb, state,
+ &tdmb7_info, THIS_MODULE);
if (ret) {
i2c_detach_client(client);
kfree(state);
diff --git a/linux/drivers/media/dvb/frontends/at76c651.c b/linux/drivers/media/dvb/frontends/at76c651.c
index 237773b8d..7bd80c738 100644
--- a/linux/drivers/media/dvb/frontends/at76c651.c
+++ b/linux/drivers/media/dvb/frontends/at76c651.c
@@ -487,7 +487,8 @@ static int attach_adapter(struct i2c_adapter *adapter)
BUG_ON(!state->dvb);
- ret = dvb_register_frontend_new(at76c651_ioctl, state->dvb, state, &at76c651_info);
+ ret = dvb_register_frontend_new(at76c651_ioctl, state->dvb, state,
+ &at76c651_info, THIS_MODULE);
if (ret) {
i2c_detach_client(client);
kfree(client);
diff --git a/linux/drivers/media/dvb/frontends/sp887x.c b/linux/drivers/media/dvb/frontends/sp887x.c
index 5f7b9b87d..1f53e09c3 100644
--- a/linux/drivers/media/dvb/frontends/sp887x.c
+++ b/linux/drivers/media/dvb/frontends/sp887x.c
@@ -622,7 +622,8 @@ static int attach_adapter(struct i2c_adapter *adapter)
goto out;
}
- ret = dvb_register_frontend_new (sp887x_ioctl, state->dvb, (void*) state, &sp887x_info);
+ ret = dvb_register_frontend_new(sp887x_ioctl, state->dvb, state,
+ &sp887x_info, THIS_MODULE);
if (ret) {
printk("sp887x: registering frontend to dvb-core failed.\n");
goto out;
diff --git a/linux/drivers/media/dvb/frontends/stv0299.c b/linux/drivers/media/dvb/frontends/stv0299.c
index 3866ea2da..e4cd9a351 100644
--- a/linux/drivers/media/dvb/frontends/stv0299.c
+++ b/linux/drivers/media/dvb/frontends/stv0299.c
@@ -1395,7 +1395,8 @@ static int attach_adapter(struct i2c_adapter *adapter)
BUG_ON(!state->dvb);
- ret = dvb_register_frontend_new (uni0299_ioctl, state->dvb, (void*) state, &uni0299_info);
+ ret = dvb_register_frontend_new(uni0299_ioctl, state->dvb, state,
+ &uni0299_info, THIS_MODULE);
if (ret) {
i2c_detach_client(client);
kfree(client);
diff --git a/linux/drivers/media/dvb/frontends/tda1004x.c b/linux/drivers/media/dvb/frontends/tda1004x.c
index e172e4805..9b265bde3 100644
--- a/linux/drivers/media/dvb/frontends/tda1004x.c
+++ b/linux/drivers/media/dvb/frontends/tda1004x.c
@@ -1503,7 +1503,9 @@ static int attach_adapter(struct i2c_adapter *adapter)
goto out;
}
- ret = dvb_register_frontend_new (tda1004x_ioctl, state->dvb, (void*) state, &tda10045h_info);
+ ret = dvb_register_frontend_new(tda1004x_ioctl, state->dvb,
+ state, &tda10045h_info,
+ THIS_MODULE);
break;
case FE_TYPE_TDA10046H:
state->dspCodeCounterReg = TDA10046H_CODE_CPT;
@@ -1516,7 +1518,9 @@ static int attach_adapter(struct i2c_adapter *adapter)
goto out;
}
- ret = dvb_register_frontend_new (tda1004x_ioctl, state->dvb, (void*) state, &tda10046h_info);
+ ret = dvb_register_frontend_new(tda1004x_ioctl, state->dvb,
+ state, &tda10046h_info,
+ THIS_MODULE);
break;
default:
BUG_ON(1);
diff --git a/linux/drivers/media/dvb/frontends/ves1x93.c b/linux/drivers/media/dvb/frontends/ves1x93.c
index 0bd02b698..5563e2578 100644
--- a/linux/drivers/media/dvb/frontends/ves1x93.c
+++ b/linux/drivers/media/dvb/frontends/ves1x93.c
@@ -638,7 +638,8 @@ static int attach_adapter(struct i2c_adapter *adapter)
BUG_ON(!state->dvb);
- ret = dvb_register_frontend_new (ves1x93_ioctl, state->dvb, (void*) state, &ves1x93_info);
+ ret = dvb_register_frontend_new(ves1x93_ioctl, state->dvb, state,
+ &ves1x93_info, THIS_MODULE);
if (ret) {
i2c_detach_client(client);
kfree(client);
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index 5d9028e9a..3a2d1d23a 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -1409,10 +1409,6 @@ int client_register(struct i2c_client *client)
struct saa7146_dev *dev = (struct saa7146_dev*)i2c_get_adapdata(client->adapter);
struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
- if (!try_module_get(THIS_MODULE)) {
- return -EIO;
- }
-
/* fixme: check for "type" (ie. frontend type) */
if (client->driver->command)
return client->driver->command(client, FE_REGISTER, av7110->dvb_adapter);
@@ -1423,15 +1419,11 @@ int client_unregister(struct i2c_client *client)
{
struct saa7146_dev *dev = (struct saa7146_dev*)i2c_get_adapdata(client->adapter);
struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
- int ret = 0;
/* fixme: check for "type" (ie. frontend type) */
if (client->driver->command)
- ret = client->driver->command(client, FE_UNREGISTER, av7110->dvb_adapter);
-
- module_put(THIS_MODULE);
-
- return ret;
+ return client->driver->command(client, FE_UNREGISTER, av7110->dvb_adapter);
+ return 0;
}
static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_data *pci_ext)
diff --git a/linux/drivers/media/dvb/ttpci/budget-core.c b/linux/drivers/media/dvb/ttpci/budget-core.c
index c2dc9279e..c1172e96a 100644
--- a/linux/drivers/media/dvb/ttpci/budget-core.c
+++ b/linux/drivers/media/dvb/ttpci/budget-core.c
@@ -271,10 +271,6 @@ int client_register(struct i2c_client *client)
struct saa7146_dev *dev = (struct saa7146_dev*)i2c_get_adapdata(client->adapter);
struct budget *budget = (struct budget*)dev->ext_priv;
- if (!try_module_get(THIS_MODULE)) {
- return -EIO;
- }
-
if (client->driver->command)
return client->driver->command(client, FE_REGISTER, budget->dvb_adapter);
return 0;
@@ -284,13 +280,9 @@ int client_unregister(struct i2c_client *client)
{
struct saa7146_dev *dev = (struct saa7146_dev*)i2c_get_adapdata(client->adapter);
struct budget *budget = (struct budget*)dev->ext_priv;
- int ret = 0;
if (client->driver->command)
- ret = client->driver->command(client, FE_UNREGISTER, budget->dvb_adapter);
-
- module_put(THIS_MODULE);
-
+ return client->driver->command(client, FE_UNREGISTER, budget->dvb_adapter);
return 0;
}