diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-08-23 09:49:13 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2008-08-23 09:49:13 +0200 |
commit | 550d99d78a4cb96963d19e5c234dffd6f973d55f (patch) | |
tree | cd8057d0e8a70902ac9a9e65966ec4bc11981a34 | |
parent | ab19cb308e86c5aeb0531bbbf5bfb2c09d3423a3 (diff) | |
download | mediapointer-dvb-s2-550d99d78a4cb96963d19e5c234dffd6f973d55f.tar.gz mediapointer-dvb-s2-550d99d78a4cb96963d19e5c234dffd6f973d55f.tar.bz2 |
radio: replace video_exclusive_open/release
From: Hans Verkuil <hverkuil@xs4all.nl>
Move the video_exclusive_open/release functionality into the driver itself.
Priority: normal
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
-rw-r--r-- | linux/drivers/media/radio/radio-aimslab.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-aztech.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-gemtek-pci.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-gemtek.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-maestro.c | 18 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-maxiradio.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-rtrack2.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-sf16fmi.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-sf16fmr2.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-terratec.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-trust.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-typhoon.c | 20 | ||||
-rw-r--r-- | linux/drivers/media/radio/radio-zoltrix.c | 16 |
13 files changed, 185 insertions, 31 deletions
diff --git a/linux/drivers/media/radio/radio-aimslab.c b/linux/drivers/media/radio/radio-aimslab.c index 516677a98..64a1bf4fd 100644 --- a/linux/drivers/media/radio/radio-aimslab.c +++ b/linux/drivers/media/radio/radio-aimslab.c @@ -52,6 +52,7 @@ static struct mutex lock; struct rt_device { + unsigned long in_use; int port; int curvol; unsigned long curfreq; @@ -379,10 +380,21 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct rt_device rtrack_unit; +static int rtrack_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &rtrack_unit.in_use) ? -EBUSY : 0; +} + +static int rtrack_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &rtrack_unit.in_use); + return 0; +} + static const struct file_operations rtrack_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = rtrack_exclusive_open, + .release = rtrack_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-aztech.c b/linux/drivers/media/radio/radio-aztech.c index 8adb1b003..b4c03b675 100644 --- a/linux/drivers/media/radio/radio-aztech.c +++ b/linux/drivers/media/radio/radio-aztech.c @@ -71,6 +71,7 @@ static struct mutex lock; struct az_device { + unsigned long in_use; int curvol; unsigned long curfreq; int stereo; @@ -343,10 +344,21 @@ static int vidioc_s_ctrl (struct file *file, void *priv, static struct az_device aztech_unit; +static int aztech_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &aztech_unit.in_use) ? -EBUSY : 0; +} + +static int aztech_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &aztech_unit.in_use); + return 0; +} + static const struct file_operations aztech_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = aztech_exclusive_open, + .release = aztech_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-gemtek-pci.c b/linux/drivers/media/radio/radio-gemtek-pci.c index efee362c7..30e6673f6 100644 --- a/linux/drivers/media/radio/radio-gemtek-pci.c +++ b/linux/drivers/media/radio/radio-gemtek-pci.c @@ -101,9 +101,8 @@ struct gemtek_pci_card { u8 mute; }; -static const char rcsid[] = "$Id: radio-gemtek-pci.c,v 1.1 2001/07/23 08:08:16 ted Exp ted $"; - static int nr_radio = -1; +static unsigned long in_use; static inline u8 gemtek_pci_out( u16 value, u32 port ) { @@ -365,10 +364,21 @@ MODULE_DEVICE_TABLE( pci, gemtek_pci_id ); static int mx = 1; +static int gemtek_pci_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &in_use) ? -EBUSY : 0; +} + +static int gemtek_pci_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &in_use); + return 0; +} + static const struct file_operations gemtek_pci_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = gemtek_pci_exclusive_open, + .release = gemtek_pci_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-gemtek.c b/linux/drivers/media/radio/radio-gemtek.c index bf1837ab2..a8395fb23 100644 --- a/linux/drivers/media/radio/radio-gemtek.c +++ b/linux/drivers/media/radio/radio-gemtek.c @@ -58,6 +58,7 @@ static int shutdown = 1; static int keepmuted = 1; static int initmute = 1; static int radio_nr = -1; +static unsigned long in_use; module_param(io, int, 0444); MODULE_PARM_DESC(io, "Force I/O port for the GemTek Radio card if automatic " @@ -394,10 +395,21 @@ static struct v4l2_queryctrl radio_qctrl[] = { } }; +static int gemtek_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &in_use) ? -EBUSY : 0; +} + +static int gemtek_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &in_use); + return 0; +} + static const struct file_operations gemtek_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = gemtek_exclusive_open, + .release = gemtek_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-maestro.c b/linux/drivers/media/radio/radio-maestro.c index 3b382e2b3..5593332fe 100644 --- a/linux/drivers/media/radio/radio-maestro.c +++ b/linux/drivers/media/radio/radio-maestro.c @@ -76,7 +76,21 @@ static struct v4l2_queryctrl radio_qctrl[] = { static int radio_nr = -1; module_param(radio_nr, int, 0); +static unsigned long in_use; + static int maestro_probe(struct pci_dev *pdev, const struct pci_device_id *ent); + +static int maestro_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &in_use) ? -EBUSY : 0; +} + +static int maestro_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &in_use); + return 0; +} + static void maestro_remove(struct pci_dev *pdev); static struct pci_device_id maestro_r_pci_tbl[] = { @@ -99,8 +113,8 @@ static struct pci_driver maestro_r_driver = { static const struct file_operations maestro_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = maestro_exclusive_open, + .release = maestro_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-maxiradio.c b/linux/drivers/media/radio/radio-maxiradio.c index 0f6bbd81b..81cc7cbd6 100644 --- a/linux/drivers/media/radio/radio-maxiradio.c +++ b/linux/drivers/media/radio/radio-maxiradio.c @@ -86,6 +86,7 @@ static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16 ; static int radio_nr = -1; module_param(radio_nr, int, 0); +static unsigned long in_use; #define FREQ_LO 50*16000 #define FREQ_HI 150*16000 @@ -100,10 +101,21 @@ module_param(radio_nr, int, 0); #define BITS2FREQ(x) ((x) * FREQ_STEP - FREQ_IF) +static int maxiradio_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &in_use) ? -EBUSY : 0; +} + +static int maxiradio_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &in_use); + return 0; +} + static const struct file_operations maxiradio_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = maxiradio_exclusive_open, + .release = maxiradio_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-rtrack2.c b/linux/drivers/media/radio/radio-rtrack2.c index 31d6eabbb..4ae447c0c 100644 --- a/linux/drivers/media/radio/radio-rtrack2.c +++ b/linux/drivers/media/radio/radio-rtrack2.c @@ -53,6 +53,7 @@ static spinlock_t lock; struct rt_device { + unsigned long in_use; int port; unsigned long curfreq; int muted; @@ -285,10 +286,21 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct rt_device rtrack2_unit; +static int rtrack2_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &rtrack2_unit.in_use) ? -EBUSY : 0; +} + +static int rtrack2_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &rtrack2_unit.in_use); + return 0; +} + static const struct file_operations rtrack2_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = rtrack2_exclusive_open, + .release = rtrack2_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-sf16fmi.c b/linux/drivers/media/radio/radio-sf16fmi.c index d4433b6a3..1eee90daf 100644 --- a/linux/drivers/media/radio/radio-sf16fmi.c +++ b/linux/drivers/media/radio/radio-sf16fmi.c @@ -46,6 +46,7 @@ static struct v4l2_queryctrl radio_qctrl[] = { struct fmi_device { + unsigned long in_use; int port; int curvol; /* 1 or 0 */ unsigned long curfreq; /* freq in kHz */ @@ -285,10 +286,21 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct fmi_device fmi_unit; +static int fmi_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &fmi_unit.in_use) ? -EBUSY : 0; +} + +static int fmi_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &fmi_unit.in_use); + return 0; +} + static const struct file_operations fmi_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = fmi_exclusive_open, + .release = fmi_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-sf16fmr2.c b/linux/drivers/media/radio/radio-sf16fmr2.c index 7b7748561..4eb17f253 100644 --- a/linux/drivers/media/radio/radio-sf16fmr2.c +++ b/linux/drivers/media/radio/radio-sf16fmr2.c @@ -65,6 +65,7 @@ static struct v4l2_queryctrl radio_qctrl[] = { /* this should be static vars for module size */ struct fmr2_device { + unsigned long in_use; int port; int curvol; /* 0-15 */ int mute; @@ -401,10 +402,21 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct fmr2_device fmr2_unit; +static int fmr2_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &fmr2_unit.in_use) ? -EBUSY : 0; +} + +static int fmr2_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &fmr2_unit.in_use); + return 0; +} + static const struct file_operations fmr2_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = fmr2_exclusive_open, + .release = fmr2_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-terratec.c b/linux/drivers/media/radio/radio-terratec.c index 768582f53..9fea38ca9 100644 --- a/linux/drivers/media/radio/radio-terratec.c +++ b/linux/drivers/media/radio/radio-terratec.c @@ -80,6 +80,7 @@ static spinlock_t lock; struct tt_device { + unsigned long in_use; int port; int curvol; unsigned long curfreq; @@ -357,10 +358,21 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct tt_device terratec_unit; +static int terratec_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &terratec_unit.in_use) ? -EBUSY : 0; +} + +static int terratec_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &terratec_unit.in_use); + return 0; +} + static const struct file_operations terratec_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = terratec_exclusive_open, + .release = terratec_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-trust.c b/linux/drivers/media/radio/radio-trust.c index 648007027..ff411f216 100644 --- a/linux/drivers/media/radio/radio-trust.c +++ b/linux/drivers/media/radio/radio-trust.c @@ -79,6 +79,7 @@ static __u16 curtreble; static unsigned long curfreq; static int curstereo; static int curmute; +static unsigned long in_use; /* i2c addresses */ #define TDA7318_ADDR 0x88 @@ -340,10 +341,21 @@ static int vidioc_s_audio(struct file *file, void *priv, return 0; } +static int trust_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &in_use) ? -EBUSY : 0; +} + +static int trust_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &in_use); + return 0; +} + static const struct file_operations trust_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = trust_exclusive_open, + .release = trust_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, diff --git a/linux/drivers/media/radio/radio-typhoon.c b/linux/drivers/media/radio/radio-typhoon.c index fa66168d7..4511f144c 100644 --- a/linux/drivers/media/radio/radio-typhoon.c +++ b/linux/drivers/media/radio/radio-typhoon.c @@ -80,7 +80,7 @@ static struct v4l2_queryctrl radio_qctrl[] = { #endif struct typhoon_device { - int users; + unsigned long in_use; int iobase; int curvol; int muted; @@ -335,10 +335,21 @@ static struct typhoon_device typhoon_unit = .mutefreq = CONFIG_RADIO_TYPHOON_MUTEFREQ, }; +static int typhoon_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &typhoon_unit.in_use) ? -EBUSY : 0; +} + +static int typhoon_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &typhoon_unit.in_use); + return 0; +} + static const struct file_operations typhoon_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = typhoon_exclusive_open, + .release = typhoon_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, @@ -448,8 +459,7 @@ static int __init typhoon_init(void) } typhoon_radio.priv = &typhoon_unit; - if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO, radio_nr) == -1) - { + if (video_register_device(&typhoon_radio, VFL_TYPE_RADIO, radio_nr) < 0) { release_region(io, 8); return -EINVAL; } diff --git a/linux/drivers/media/radio/radio-zoltrix.c b/linux/drivers/media/radio/radio-zoltrix.c index ef6d6a66f..b4acd3810 100644 --- a/linux/drivers/media/radio/radio-zoltrix.c +++ b/linux/drivers/media/radio/radio-zoltrix.c @@ -70,6 +70,7 @@ static int io = CONFIG_RADIO_ZOLTRIX_PORT; static int radio_nr = -1; struct zol_device { + unsigned long in_use; int port; int curvol; unsigned long curfreq; @@ -397,11 +398,22 @@ static int vidioc_s_audio(struct file *file, void *priv, static struct zol_device zoltrix_unit; +static int zoltrix_exclusive_open(struct inode *inode, struct file *file) +{ + return test_and_set_bit(0, &zoltrix_unit.in_use) ? -EBUSY : 0; +} + +static int zoltrix_exclusive_release(struct inode *inode, struct file *file) +{ + clear_bit(0, &zoltrix_unit.in_use); + return 0; +} + static const struct file_operations zoltrix_fops = { .owner = THIS_MODULE, - .open = video_exclusive_open, - .release = video_exclusive_release, + .open = zoltrix_exclusive_open, + .release = zoltrix_exclusive_release, .ioctl = video_ioctl2, #ifdef CONFIG_COMPAT .compat_ioctl = v4l_compat_ioctl32, |