summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorAndrew de Quincy <devnull@localhost>2004-11-13 19:24:49 +0000
committerAndrew de Quincy <devnull@localhost>2004-11-13 19:24:49 +0000
commitee62618e61e336e3f62e9b07d95650d46e87eadb (patch)
tree3a3056f96563579f5d494404467ecef79f3776ef /linux
parentd3f8f1e3c54e43c5eb830f30fe37a251196d4d90 (diff)
downloadmediapointer-dvb-s2-ee62618e61e336e3f62e9b07d95650d46e87eadb.tar.gz
mediapointer-dvb-s2-ee62618e61e336e3f62e9b07d95650d46e87eadb.tar.bz2
Fix module usage count problem
Diffstat (limited to 'linux')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c10
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.h3
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-av.c13
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-ci.c31
4 files changed, 33 insertions, 24 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 7fe4c100d..1be92f9e1 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -1531,6 +1531,9 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
dprintk("%s\n", __FUNCTION__);
+ if (!try_module_get(ca->pub->owner))
+ return -EIO;
+
err = dvb_generic_open(inode, file);
if (err < 0)
return err;
@@ -1566,7 +1569,7 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
{
struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
struct dvb_ca_private *ca = (struct dvb_ca_private *) dvbdev->priv;
- int err;
+ int err = 0;
dprintk("%s\n", __FUNCTION__);
@@ -1575,8 +1578,9 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
dvb_ca_en50221_thread_update_delay(ca);
err = dvb_generic_release(inode, file);
- if (err < 0)
- return err;
+
+ module_put(ca->pub->owner);
+
return 0;
}
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.h b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
index dcb4e68b4..8467e63dd 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
@@ -42,6 +42,9 @@
/* Structure describing a CA interface */
struct dvb_ca_en50221 {
+ /* the module owning this structure */
+ struct module* owner;
+
/* NOTE: the read_*, write_* and poll_slot_status functions must use locks as
* they may be called from several threads at once */
diff --git a/linux/drivers/media/dvb/ttpci/budget-av.c b/linux/drivers/media/dvb/ttpci/budget-av.c
index 7f202cfc7..1c738b1d7 100644
--- a/linux/drivers/media/dvb/ttpci/budget-av.c
+++ b/linux/drivers/media/dvb/ttpci/budget-av.c
@@ -121,7 +121,7 @@ static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int ad
return -EINVAL;
saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
- result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0);
+ result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 0);
if (result == -ETIMEDOUT)
budget_av->slot_status = 0;
@@ -137,8 +137,7 @@ static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int a
return -EINVAL;
saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
- result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value,
- 0);
+ result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 0);
if (result == -ETIMEDOUT)
budget_av->slot_status = 0;
@@ -154,7 +153,7 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre
return -EINVAL;
saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
- result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0);
+ result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
if (result == -ETIMEDOUT)
budget_av->slot_status = 0;
@@ -170,7 +169,7 @@ static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addr
return -EINVAL;
saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
- result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0);
+ result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
if (result == -ETIMEDOUT)
budget_av->slot_status = 0;
@@ -244,7 +243,8 @@ static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open
if (cam)
budget_av->slot_status = 1;
} else if (!open) {
- if (ciintf_read_cam_control(ca, 0, 0) == -ETIMEDOUT)
+ saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
+ if (ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1) == -ETIMEDOUT)
budget_av->slot_status = 0;
}
@@ -276,6 +276,7 @@ static int ciintf_init(struct budget_av *budget_av)
saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
/* register CI interface */
+ budget_av->ca.owner = THIS_MODULE;
budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
budget_av->ca.read_cam_control = ciintf_read_cam_control;
diff --git a/linux/drivers/media/dvb/ttpci/budget-ci.c b/linux/drivers/media/dvb/ttpci/budget-ci.c
index ae4248da1..196d17740 100644
--- a/linux/drivers/media/dvb/ttpci/budget-ci.c
+++ b/linux/drivers/media/dvb/ttpci/budget-ci.c
@@ -145,7 +145,7 @@ static void msp430_ir_interrupt(unsigned long data)
struct budget_ci *budget_ci = (struct budget_ci *) data;
struct input_dev *dev = &budget_ci->input_dev;
unsigned int code =
- ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1) >> 8;
+ ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
if (code & 0x40) {
code &= 0x3f;
@@ -225,7 +225,7 @@ static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int ad
return -EINVAL;
return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
- DEBIADDR_ATTR | (address & 0xfff), 1, 1);
+ DEBIADDR_ATTR | (address & 0xfff), 1, 1, 0);
}
static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
@@ -236,7 +236,7 @@ static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int a
return -EINVAL;
return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
- DEBIADDR_ATTR | (address & 0xfff), 1, value, 1);
+ DEBIADDR_ATTR | (address & 0xfff), 1, value, 1, 0);
}
static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
@@ -247,7 +247,7 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre
return -EINVAL;
return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
- DEBIADDR_IO | (address & 3), 1, 1);
+ DEBIADDR_IO | (address & 3), 1, 1, 0);
}
static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
@@ -258,7 +258,7 @@ static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addr
return -EINVAL;
return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
- DEBIADDR_IO | (address & 3), 1, value, 1);
+ DEBIADDR_IO | (address & 3), 1, value, 1, 0);
}
static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
@@ -272,10 +272,10 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
// trigger on RISING edge during reset so we know when READY is re-asserted
saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
budget_ci->slot_status = SLOTSTATUS_RESET;
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1);
+ ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
msleep(1);
ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1);
+ CICONTROL_RESET, 1, 0);
saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
@@ -306,9 +306,9 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
- tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1);
+ tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- tmp | CICONTROL_ENABLETS, 1);
+ tmp | CICONTROL_ENABLETS, 1, 0);
ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
return 0;
@@ -325,7 +325,7 @@ static void ciintf_interrupt(unsigned long data)
return;
// read the CAM status
- flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1);
+ flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
if (flags & CICONTROL_CAMDETECT) {
// GPIO should be set to trigger on falling edge if a CAM is present
@@ -375,17 +375,18 @@ static int ciintf_init(struct budget_ci *budget_ci)
saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
// test if it is there
- if ((ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1) & 0xa0) != 0xa0) {
+ if ((ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0) & 0xa0) != 0xa0) {
result = -ENODEV;
goto error;
}
// determine whether a CAM is present or not
- flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1);
+ flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
budget_ci->slot_status = SLOTSTATUS_NONE;
if (flags & CICONTROL_CAMDETECT)
budget_ci->slot_status = SLOTSTATUS_PRESENT;
// register CI interface
+ budget_ci->ca.owner = THIS_MODULE;
budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem;
budget_ci->ca.write_attribute_mem = ciintf_write_attribute_mem;
budget_ci->ca.read_cam_control = ciintf_read_cam_control;
@@ -411,7 +412,7 @@ static int ciintf_init(struct budget_ci *budget_ci)
}
saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03);
ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1);
+ CICONTROL_RESET, 1, 0);
// success!
printk("budget_ci: CI interface initialised\n");
@@ -438,10 +439,10 @@ static void ciintf_deinit(struct budget_ci *budget_ci)
saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03);
saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
tasklet_kill(&budget_ci->ciintf_irq_tasklet);
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1);
+ ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
msleep(1);
ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1);
+ CICONTROL_RESET, 1, 0);
// disable TS data stream to CI interface
saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);