Skip to content

Commit

Permalink
V4L/DVB (8776): radio: replace video_exclusive_open/release
Browse files Browse the repository at this point in the history
Move the video_exclusive_open/release functionality into the driver itself.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Oct 12, 2008
1 parent 3b5df8e commit 3ca685a
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 31 deletions.
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-aimslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ static struct mutex lock;

struct rt_device
{
unsigned long in_use;
int port;
int curvol;
unsigned long curfreq;
Expand Down Expand Up @@ -378,10 +379,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-aztech.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static struct mutex lock;

struct az_device
{
unsigned long in_use;
int curvol;
unsigned long curfreq;
int stereo;
Expand Down Expand Up @@ -342,10 +343,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,
Expand Down
18 changes: 14 additions & 4 deletions drivers/media/radio/radio-gemtek-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,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 )
{
Expand Down Expand Up @@ -364,10 +363,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-gemtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 "
Expand Down Expand Up @@ -393,10 +394,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,
Expand Down
18 changes: 16 additions & 2 deletions drivers/media/radio/radio-maestro.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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[] = {
Expand All @@ -98,8 +112,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-maxiradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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
Expand All @@ -99,10 +100,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-rtrack2.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static spinlock_t lock;

struct rt_device
{
unsigned long in_use;
int port;
unsigned long curfreq;
int muted;
Expand Down Expand Up @@ -284,10 +285,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-sf16fmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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 */
Expand Down Expand Up @@ -284,10 +285,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-sf16fmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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;
Expand Down Expand Up @@ -400,10 +401,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-terratec.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static spinlock_t lock;

struct tt_device
{
unsigned long in_use;
int port;
int curvol;
unsigned long curfreq;
Expand Down Expand Up @@ -356,10 +357,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,
Expand Down
16 changes: 14 additions & 2 deletions drivers/media/radio/radio-trust.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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
Expand Down Expand Up @@ -336,10 +337,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,
Expand Down
20 changes: 15 additions & 5 deletions drivers/media/radio/radio-typhoon.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static struct v4l2_queryctrl radio_qctrl[] = {
#endif

struct typhoon_device {
int users;
unsigned long in_use;
int iobase;
int curvol;
int muted;
Expand Down Expand Up @@ -334,10 +334,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,
Expand Down Expand Up @@ -447,8 +458,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;
}
Expand Down
Loading

0 comments on commit 3ca685a

Please sign in to comment.